support for URIs from ssb-uri
adding issue tracker link
bugfixes
A JS library to handle SSB custom URLs.
This library and its API is inspired and informed by the conversations in:
%g3hPVPDEO1Aj/uPl0+J2NlhFB2bbFLIHlty+YuqFZ3w=.sha256
And the fromSigilLink
and toSigilLink
API signatures have been copied from:
https://github.com/fraction/ssb-uri
This library is a drop-in replacement for that library.
The issue tracker is at https://todo.sr.ht/~soapdog/ssb-custom-uri
import ssbUri from "./ssb-custom-uri.js"
Converts a sigil link from SSB into a custom ssb:
URL.
ssbUri.fromSigilLink("%EOgRe5ppgaugsqGyoWxJQ3QCFaGV7akjFUQ+9RR1jfk=.sha256")
// => ssb:message/sha256/EOgRe5ppgaugsqGyoWxJQ3QCFaGV7akjFUQ+9RR1jfk=
Converts a ssb:
url back into a ssb sigil link:
ssbUri.toSigilLink("ssb:message/sha256/EOgRe5ppgaugsqGyoWxJQ3QCFaGV7akjFUQ+9RR1jfk=")
// => %EOgRe5ppgaugsqGyoWxJQ3QCFaGV7akjFUQ+9RR1jfk=.sha256
Converts a DHT peer invite to a shareable link
ssbUri.peerInviteToLink("dht:DAy3i1tSOyqCsb+vVXc7enc+lo9XI26VknqCJ+PmCnc=:@FuvN1MpxWHGGYAswLAmfpTkkS5iKaFog2aPL4baU1cE=.ed25519")
// => ssb:invite/dht/DAy3i1tSOyqCsb%2BvVXc7enc%2Blo9XI26VknqCJ%2BPmCnc%3D/feed/ed25519/FuvN1MpxWHGGYAswLAmfpTkkS5iKaFog2aPL4baU1cE%3D
Converts a link back into a peer invite
ssbUri.peerInviteToLink("ssb:invite/dht/DAy3i1tSOyqCsb%2BvVXc7enc%2Blo9XI26VknqCJ%2BPmCnc%3D/feed/ed25519/FuvN1MpxWHGGYAswLAmfpTkkS5iKaFog2aPL4baU1cE%3D")
// => dht:DAy3i1tSOyqCsb+vVXc7enc+lo9XI26VknqCJ+PmCnc=:@FuvN1MpxWHGGYAswLAmfpTkkS5iKaFog2aPL4baU1cE=.ed25519
Converts a pub invite to a shareable link
ssbUri.pubInviteToLink("foo.bar.co.nz:8009:@6lOh+rLq4MQubPQoKenbB827dh5NVc2FAjy30MTc08o=.ed25519~93RP4aT6YNm+7++Ab3VQd+w/CL2w6p8QuX7fRaUs9cY=")
// => ssb:invite/pub/foo.bar.co.nz/8009/93RP4aT6YNm%2B7%2B%2BAb3VQd%2Bw%2FCL2w6p8QuX7fRaUs9cY%3D/feed/ed25519/6lOh%2BrLq4MQubPQoKenbB827dh5NVc2FAjy30MTc08o%3D
Converts a link back into a pub invite
ssbUri.pubInviteToLink("ssb:invite/pub/foo.bar.co.nz/8009/93RP4aT6YNm%2B7%2B%2BAb3VQd%2Bw%2FCL2w6p8QuX7fRaUs9cY%3D/feed/ed25519/6lOh%2BrLq4MQubPQoKenbB827dh5NVc2FAjy30MTc08o%3D")
// => foo.bar.co.nz:8009:@6lOh+rLq4MQubPQoKenbB827dh5NVc2FAjy30MTc08o=.ed25519~93RP4aT6YNm+7++Ab3VQd+w/CL2w6p8QuX7fRaUs9cY=
You might want a protocol schema for your app so that you can launch a default SSB client for ssb:
links and your own client for some more specific need. This function allows you to change the protocol schema being used. A potential use case is specific apps such as Whakapapa Ora which could have their own whakapapa-ora:
custom URL and still use this library.
ssbUri.setCustomProtocolSchema("whakapapa-ora")
ssbUri.fromSigilLink("%EOgRe5ppgaugsqGyoWxJQ3QCFaGV7akjFUQ+9RR1jfk=.sha256")
// => whakapapa-ora:message/sha256/EOgRe5ppgaugsqGyoWxJQ3QCFaGV7akjFUQ+9RR1jfk=
MIT