This library contains utilities and Node.js gRPC bindings for use with ddrpd nodes.
The below usage information is a high-level overview of the library. More in-depth documentation can be found by viewing the TSDoc. The TSDoc can be generating by running
npm run docs.
To use the gRPC API, you'll need to instantiate
DDRPDClient like this:
// replace 127.0.0.1:9098 with your node's URL,// if other than the default:;
Once done, you can call any of the service mthods defined on
Reading Social Data
ddrp-js includes support for reading and writing social data to DDRP blobs. To read social data out of a blob, we recommend using the
iterateAllEnvelopes method like this:
;;// creates an instance of a buffered Readable, which will read// from the blob using gRPC and keep the data in a 1MB buffer.;iterateAllEnvelopesreader,;
Writing Social Data
Writing social data to a blob is a similar process to reading, however doing so requires the private key of the blob being written to:
;;// replace the below with your actual private key;;;await writer.open;// see TSDoc for docs on creating Envelopes;await writer.writeEnvelopeenvelope;await writer.commit;
Note that this will start writing from the beginning of the blob.
ddrp-js does not keep track of last-used offsets within a blob; this is left up to applications.
A Note on Streams
ddrp-js uses its own internal streaming implementation. Classes that make use of streaming IO generally implement the
Writer interfaces. Helper methods are provided that abstract this detail away, however more advanced use cases may need to make use of the streaming libraries directly.