/js-gabbygrove

experimental, cbor based feed format for ssb

Primary LanguageJavaScriptMIT LicenseMIT

Gabby Grove

this is an experimental, CBOR based feed format for secure-scuttlebutt.

It spec draft will be published to the ssb-spec-drafts. The current working copy can be found on the core-gabbygrove-00 branch.

Structures

See the working copy for an detailed description of the fields in the Event and Transfer strucutre.

API

verifyTransfer

verifyTransfer(Buffer, cb) expects a Buffer as it's first argument, it will be decoded as a Transfer message (three cbor arrays). Then, the first element of Transfer will be decoded as an Event. The author inside the event will be used to verify the Signature (field number to of Transfer). If present, the content will be hashed and compared against the content.hash inside the Event, as well.

If anything fails, the callback will be called with an error as it's first argument. If successfull, the first argument will be null and the seconed one will get this decoded data:

{
    key: BinaryRef(), // of the received event
    evt: decodedEvent,
    content: jsonObject, // JSON.parse of content (if that's the `content.encoding`)
}

makeEvent

makeEvent(keyPair, sequence, prev, content) creates a new Transfer object with a signed event inside. It's a low level function and should be wrapped apropriatly to create the right sequence numbers and use the correct previous hashes.

It throws in case of mis-use.

It returns this object:

{
    key: BinaryRef(),  // of the new event
    event: []...,      // array of fields of event
    trBytes: Buffer(), // complete encoded Transfer object
}
`