1.9.6 • Published 2 years ago

@cere-ddc-sdk/content-addressable-storage v1.9.6

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 years ago

@cere-ddc-sdk/content-addressable-storage

Basic package for working with data in DDC.

Support commands:

  • store - store data in DDC
  • storeEncrypted - store encrypted data in DDC
  • read - download piece with data from DDC
  • readDecrypted - download and decrypt piece with data from DDC
  • search - search pieces by tags and download from DDC

Example

Setup

Initialize client by cluster id and secret phrase.

import {ContentAddressableStorage} from '@cere-ddc-sdk/content-addressable-storage';

const signatureAlgorithm = 'ed25519';
const secretPhrase = '0x9gh7...';
const cdnClusterId = 2n;

const storage = await ContentAddressableStorage.build(
    {
        clusterAddress: cdnClusterId,
        scheme: signatureAlgorithm,
    },
    secretPhrase,
);

Store

Store piece with data in DDC.

import {Piece, PieceUri, Tag} from '@cere-ddc-sdk/content-addressable-storage';

const data = new Uint8Array([1, 2, 3, 4]); // data for storing
const bucketId = 1n;
const tags = [new Tag('key', 'test')]; // tag for search
const piece = new Piece(data, tags);

const pieceUri: PieceUri = await storage.store(bucketId, piece);

Store Encrypted

Store encrypted data in DDC.

import {Piece} from '@cere-ddc-sdk/content-addressable-storage';

const data = new Uint8Array([1, 2, 3, 4]); // data for storing
const bucketId = 1n;
const tags = [new Tag('key', 'test')]; // tag for search
const piece = new Piece(data, tags);

const encryptionOptions = {dekPath: '/data/secret', dek: dekBytes};

const pieceUri = await storage.storeEncrypted(bucketId, piece, encryptionOptions);

Read

Download piece from DDC.

import {Piece} from '@cere-ddc-sdk/content-addressable-storage';

const bucketId = 1n;
const cid = 'b89mndf...'; // CID can get from pieceUri (pieceUri.cid)

const piece: Piece = await storage.read(bucketId, cid);

Read Decrypted

Read and decrypt piece from DDC.

import {Piece} from '@cere-ddc-sdk/content-addressable-storage';

const bucketId = 1n;
const cid = 'b89mndf...'; // CID can get from pieceUri (pieceUri.cid)

const piece: Piece = await storage.readDecrypted(bucketId, cid, dekBytes);

Search data

Search by tags pieces and download.

import {Piece, Query, SearchResult, Tag} from '@cere-ddc-sdk/content-addressable-storage';

const bucketId = 1n;
const tags = [new Tag('key', 'test')];
const skipData = false; // download pieces with data or metadata only
const query = new Query(bucketId, tags, skipData);

const searchResult: SearchResult = await storage.search(query);
const pieces: Array<Piece> = searchResult.pieces;
1.9.0-rc.10

2 years ago

1.7.6-rc.1

2 years ago

1.9.0-rc.9

2 years ago

1.9.0-rc.8

2 years ago

1.9.0-rc.7

2 years ago

1.9.0-rc.6

2 years ago

1.8.0-rc.5

2 years ago

1.8.0-rc.6

2 years ago

1.8.0-rc.7

2 years ago

1.8.0-rc.8

2 years ago

1.9.0-rc.1

2 years ago

1.8.0-rc.1

2 years ago

1.9.0-rc.0

2 years ago

1.8.0-rc.2

2 years ago

1.8.0-rc.3

2 years ago

1.8.0-rc.4

2 years ago

1.9.0-rc.5

2 years ago

1.9.0-rc.4

2 years ago

1.9.0-rc.3

2 years ago

1.9.0-rc.2

2 years ago

1.7.6-rc.2

2 years ago

1.7.6-rc.3

2 years ago

1.7.6-rc.4

2 years ago

1.9.6

2 years ago

1.9.5

2 years ago

1.9.4

2 years ago

1.7.6

2 years ago

1.9.3

2 years ago

1.9.2

2 years ago

1.9.1

2 years ago

1.9.0

2 years ago

1.7.5-beta.2

2 years ago

1.7.5-beta.3

2 years ago

1.7.5-beta.1

2 years ago

1.7.5-RC2

2 years ago

1.7.5-RC1

2 years ago

1.7.5

2 years ago

1.7.4

2 years ago

1.4.4

3 years ago

1.6.0

3 years ago

1.7.3

3 years ago

1.7.2

3 years ago

1.7.1

3 years ago

1.7.0

3 years ago

1.5.0

3 years ago

1.4.3

3 years ago

1.4.1

3 years ago

1.3.4

3 years ago

1.2.0

3 years ago

1.2.8

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.3.3

3 years ago

1.2.4

3 years ago

1.3.2

3 years ago

1.2.3

3 years ago

1.3.1

3 years ago

1.2.2

3 years ago

1.3.0

3 years ago

1.2.1

3 years ago

1.2.9

3 years ago

1.1.0

3 years ago

1.0.19

3 years ago

1.0.20

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.10-RC1

3 years ago

1.0.9-RC1

3 years ago

1.0.8-RC2

3 years ago

1.0.8-RC1

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago