That's kind of sad, we have to build a bunch of Buffer and slice buffers and stuff just to know if feedId is an encoded BFE of the type "feed". It's also error prone to fiddle with buffers like that, untested.
Solution
Similar to ssb-uri2 has isGabbyGroveV1MessageSSBURI(input) => boolean, there are now:
such that the input is a buffer and you get a boolean answering you that the type/format is the thing.
Details
I started implementing this manually, like isEncodedFeedClassic implemented by hand, etc. Half the way I figured this is stupid. There is way too many cases, and when we update ssb-bfe-spec we will have to manually update ssb-bfe.
So instead I found a way of using bfe.json from ssb-bfe-spec to automatically create these functions. Should fit the style of this library which doesn't manually list all the types/formats, but instead uses TYPES and NAMED_TYPES.
Problem
There are a couple other modules that use ssb-bfe like this:
That's kind of sad, we have to build a bunch of Buffer and slice buffers and stuff just to know if
feedId
is an encoded BFE of the type "feed". It's also error prone to fiddle with buffers like that, untested.Solution
Similar to
ssb-uri2
hasisGabbyGroveV1MessageSSBURI(input) => boolean
, there are now:isEncodedFeed(input) => boolean
isEncodedFeedClassic(input) => boolean
isEncodedFeedGabbygroveV1(input) => boolean
isEncodedFeedBamboo(input) => boolean
isEncodedFeedBendybuttV1(input) => boolean
isEncodedFeedButtwooV1(input) => boolean
isEncodedMessage(input) => boolean
isEncodedMessageClassic(input) => boolean
isEncodedMessageGabbygroveV1(input) => boolean
isEncodedMessageCloaked(input) => boolean
isEncodedMessageBamboo(input) => boolean
isEncodedMessageBendybuttV1(input) => boolean
isEncodedMessageButtwooV1(input) => boolean
isEncodedBlob(input) => boolean
isEncodedBlobClassic(input) => boolean
isEncodedEncryptionKey(input) => boolean
isEncodedEncryptionKeyBox2DmDh(input) => boolean
isEncodedEncryptionKeyBox2PoboxDh(input) => boolean
isEncodedSignature(input) => boolean
isEncodedSignatureMsgEd25519(input) => boolean
isEncodedEncrypted(input) => boolean
isEncodedEncryptedBox1(input) => boolean
isEncodedEncryptedBox2(input) => boolean
isEncodedGeneric(input) => boolean
isEncodedGenericStringUTF8(input) => boolean
isEncodedGenericBoolean(input) => boolean
isEncodedGenericNil(input) => boolean
isEncodedGenericAnyBytes(input) => boolean
isEncodedIdentity(input) => boolean
isEncodedIdentityPoBox(input) => boolean
such that the input is a buffer and you get a boolean answering you that the type/format is the thing.
Details
I started implementing this manually, like
isEncodedFeedClassic
implemented by hand, etc. Half the way I figured this is stupid. There is way too many cases, and when we update ssb-bfe-spec we will have to manually update ssb-bfe.So instead I found a way of using bfe.json from ssb-bfe-spec to automatically create these functions. Should fit the style of this library which doesn't manually list all the types/formats, but instead uses
TYPES
andNAMED_TYPES
.