ssbc / ssb-ref

check if a string is a valid ssb-reference
MIT License
14 stars 10 forks source link

support secret blobs and add parseBlob #15

Closed mmckegg closed 6 years ago

mmckegg commented 6 years ago

This PR adds support for detecting secret blobs using isBlob.

It also adds a new parseBlob export that when given a blob ref, returns an object containing {id, key}.

var ref = require('ssb-ref')
var secretBlob = '&abcdefg6bIh5dmyss7QH7uMrQxz3LKvgjer68we30aQ=.sha256?unbox=abcdefgqAYfzLrychmP5KchZ6JaLHyYv1aYOviDnSZk=.boxs'
ref.parseBlob(secretBlob) // => {
//    id: "&abcdefg6bIh5dmyss7QH7uMrQxz3LKvgjer68we30aQ=.sha256",
//    key: "abcdefgqAYfzLrychmP5KchZ6JaLHyYv1aYOviDnSZk="
//  }

I plan to use this in ssb-mentions and patchcore, rather than using slightly differing hand-rolled implementations that are currently there.

cc @clehner @dominictarr

dominictarr commented 6 years ago

to be honest, I think this is too specific. why not allow any query string on the end of an id? same suggestion here: https://github.com/ssbc/ssb-mentions/pull/11

mmckegg commented 6 years ago

Okay updated this module to match your proposal @dominictarr!

I'm gonna go ahead merge and publish this!

mmckegg commented 6 years ago

Released as v2.10.0 🎉

mmckegg commented 6 years ago

I unpublished 2.10.0 and instead submit https://github.com/ssbc/ssb-ref/pull/16