Returns a set of functions as an API for validating, building, publishing and reading records dictated by ssb-dark-crystal-schema.
var DarkCrystal = require('scuttle-dark-crystal')
var darkCrystal = DarkCrystal(server) // a scuttlebutt server or connection to one
Takes an object with properties:
name
a name referring to the secretsecret
the secret string itselfquorum
the minimum number of shards required to recombinerecps
an array of ssb feedIds for the shard recipients
The secret is sharded and a root message, ritual message and one shard message for each recipient are published. If successful, the published messages will be passed as an object to the callback.
This method publishes invite
messages with a request to return a shard. If recipients
is falsey, invite messages to all shardholders associated with the given rootId will be published. If recipients
is an array containing one or more feedIds, invite messages to only the given recipients will be published, provided they hold shards associated with the given rootId. If successful, the published invite messages are passed to the callback.
This method can also be called : darkCrystal.recover.async.request(rootId, callback)
and it will send requests to al shard-holders
This will respond to a given invite message, by decrypting the associated shard and publishing an invite-reply
message providing the shard in the body
property. If successful, the reply message is passed to the callback.
WIP This will attempt to recombine the decrypted shards included in reply messages associated with a given rootId. If successful the secret will be passed to the callback.
Takes a secret name as an argument and publishes a root message. If successful, the published message will be passed to the callback.
Takes an object with properties:
root
the ID of the root messageshards
the number of shardsquorum
the minimum number of shards required to recombine
A ritual message is published. If successful, the published message will be passed to the callback.
Takes an object with properties:
shards
an array of shard stringsrecps
an array of ssb feedIds for the shard recipientsrootId
the ID of the root message
For each shard, a shard message will be published to both the recipient and the sender. If successful, the published messages will be passed to the callback. In the case of at least one validation error, no messages will be published.
Returns a stream of shards others have shared with you. Takes opts
- standard stream options like live
, reverse
etc.
These are validation methods for each message type as described in ssb-dark-crystal-schema.