%DrLpM6ehOGgkYmdiLcHYMI6NzduYuc7XWawhh3G4VFY=.sha256
ssb-db2 version 5.0.0
The #batts team has an announcement to make: we made a new major version of ssb-db2 with a new architecture centered around composable feed formats and encryption formats. This is the refactor I mentioned before and said that "massive refactor to be done. It got me worried. Are we going to manage doing all this?" and it makes me happy to say YES we managed to do it. Thank you @arj for the countless reviews and benchmarking over the past 2 months, thank you @mixmix @Mix Android for the patience to adapt your private group libraries to our new needs.
ssb-db2 version 5 has a new API, create()
, which is the new publish()
(which in turn is now soft-deprecated). The difference between create
and publish
is that create
is agnostic to feed formats, while publish
assumes the classic feed format. A quick example:
Before
ssb.db.publish({ type: 'post', text: 'hi' }, cb)
After
ssb.db.create({
content: { type: 'post', text: 'hi' },
feedFormat: 'classic', // optional, defaults to 'classic',
keys, // optional, defaults to config.keys
}, cb)
We couldn't change the publish
API because that would be a breaking change that's hard to hunt and replace everywhere, so create
allows you to customize various aspects of the new message on your log:
- Who is signing the message (by specifying
keys
)- This will be very important as we transition to a world where you control/own many feed IDs, and we can't assume there's just one signing keys
- What feed format to use
- This is important for
bendybutt
and to allow easy experimentation with new feed formats, be thatbuttwoo
or new ones
- This is important for
- What encryption format to use
- Whether it's the traditional private-box,
box2
(for private groups) or something else we come up in the future
- Whether it's the traditional private-box,
- Any other custom information that the feed format requires
- E.g. buttwoo has "tags", bendybutt has signing keys for the
content
section which can be different to the signing keys for the entire message
- E.g. buttwoo has "tags", bendybutt has signing keys for the
Here's an advanced example:
ssb.db.create(
{
feedFormat: 'buttwoo-v1',
content: {
type: 'post',
text: 'Heat death of the universe',
},
keys: buttwooKeys,
tag: 0, // specific to the buttwoo feed format
recps: [buttwooKeys.id, keys.id],
encryptionFormat: 'box2',
},
cb
)
Now I'm busy with updating the various other libraries to use this new API, but I'm happy that this change is going to be good in the long-term. For instance, now ssb-classic contains everything related to the "good old" SSB format, such as message creation, validation, conversion of the message to other shapes. Before, we used to have just one library for validation, and other aspects like conversion were elsewhere.