Christian Bundy
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Feed Type Super Collider Sometimes the best way to understand a system is to smash it into little pieces to see how it breaks. Instead of smashing particles together, this is an experiment in adding arbitrary feed types (like `.ed25519.superCollider`) and figuring out how that breaks the Scuttlebutt stack. ## ssb-keys ```diff diff --git a/util.js b/util.js index c2d3d85..abb1471 100644 --- a/util.js +++ b/util.js @@ -22,12 +22,15 @@ function tag (key, tag) { exports.keysToJSON = function keysToJSON(keys, curve) { curve = (keys.curve || curve) + const feedType = '.superCollider' + var pub = tag(keys.public, curve) return { curve: curve, public: pub, private: keys.private ? tag(keys.private, curve) : undefined, - id: '@'+(curve === 'ed25519' ? pub : exports.hash(pub)) + feedType: feedType, + id: '@' + (curve === 'ed25519' ? pub : exports.hash(pub)) + feedType } } ``` Done! Now we have feed types. Unfortunately this broke a few things in ssb-keys, but we can resolve those pretty easily. ```diff diff --git a/index.js b/index.js index 7179d7f..20e5bc3 100644 --- a/index.js +++ b/index.js @@ -61,13 +61,13 @@ function getCurve(keys) { //this should return a key pair: // {curve: curve, public: Buffer, private: Buffer} -exports.generate = function (curve, seed) { +exports.generate = function (curve, seed, feedType) { curve = curve || 'ed25519' if(!curves[curve]) throw new Error('unknown curve:'+curve) - return u.keysToJSON(curves[curve].generate(seed), curve) + return u.keysToJSON(curves[curve].generate(seed), curve, feedType) } //import functions for loading/saving keys from storage diff --git a/test/fs.js b/test/fs.js index 9fc89bc..90fbd7f 100644 --- a/test/fs.js +++ b/test/fs.js @@ -1,37 +1,29 @@ var tape = require('tape') var ssbkeys = require('../') -var crypto = require('crypto') var path = '/tmp/ssb-keys_' + Date.now() var fs = require('fs') tape('create and load presigil-legacy async', function (t) { - var keys = ssbkeys.generate('ed25519') - keys.id = keys.id.substring(1) fs.writeFileSync(path, JSON.stringify(keys)) var k2 = ssbkeys.loadSync(path) - t.equal(k2.id, '@' + keys.id) + t.equal(k2.id, keys.id) t.end() - }) tape('create and load presigil-legacy', function (t) { - var keys = ssbkeys.generate('ed25519') - keys.id = keys.id.substring(1) fs.writeFileSync(path, JSON.stringify(keys)) ssbkeys.load(path, function (err, k2) { if(err) throw err - t.equal(k2.id, '@' + keys.id) + t.equal(k2.id, keys.id) t.end() }) - }) tape('prevent clobbering existing keys', function (t) { - fs.writeFileSync(path, 'this file intentionally left blank', 'utf8') t.throws(function () { ssbkeys.createSync(path) @@ -41,5 +33,4 @@ tape('prevent clobbering existing keys', function (t) { fs.unlinkSync(path) t.end() }) - }) diff --git a/test/index.js b/test/index.js index 3924ef1..bd29af4 100644 --- a/test/index.js +++ b/test/index.js @@ -99,10 +99,10 @@ tape('seeded keys, ed25519', function (t) { }) -tape('ed25519 id === "@" ++ pubkey', function (t) { +tape('ed25519 id === "@" ++ pubkey ++ feedId', function (t) { var keys = ssbkeys.generate('ed25519') - t.equal(keys.id, '@' + keys.public) + t.equal(keys.id, '@' + [ keys.public, keys.feedType ].join('.')) t.end() diff --git a/util.js b/util.js index c2d3d85..aaad87a 100644 --- a/util.js +++ b/util.js @@ -22,12 +22,15 @@ function tag (key, tag) { exports.keysToJSON = function keysToJSON(keys, curve) { curve = (keys.curve || curve) + const feedType = 'superCollider' + var pub = tag(keys.public, curve) return { curve: curve, public: pub, private: keys.private ? tag(keys.private, curve) : undefined, - id: '@'+(curve === 'ed25519' ? pub : exports.hash(pub)) + feedType: feedType, + id: '@' + [(curve === 'ed25519' ? pub : exports.hash(pub)), feedType].join('.') } } ``` Sweet. Now let's link it into ssb-db and test it out. ## ssb-db ```console $ npm test > ssb-db@19.3.0 test /home/christianbundy/src/ssbc/ssb-db > set -e; for t in test/*.js; do node $t; done (node:20184) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead. TAP version 13 # add invalid message ok 1 should be truthy # add null message ok 2 should be truthy # add okay message /home/christianbundy/src/ssbc/ssb-db/test/add.js:29 if (err) throw err ^ Error: message has invalid properties:{ "previous": null, "sequence": 1, "author": "@EQqExI5IrR2HK7lI1lFBJMt7V73dW9w6xVf58pFhvY4=.ed25519.superCollider", "timestamp": 1562086702748, "hash": "sha256", "content": { "type": "okay" } } at exports.isInvalidShape (/home/christianbundy/src/ssbc/ssb-db/node_modules/ssb-validate/index.js:96:12) at Object.exports.create (/home/christianbundy/src/ssbc/ssb-db/node_modules/ssb-validate/index.js:272:13) at /home/christianbundy/src/ssbc/ssb-db/minimal.js:194:19 at EventEmitter.append (/home/christianbundy/src/ssbc/ssb-db/minimal.js:162:18) at Object.add (/home/christianbundy/src/ssbc/ssb-db/create.js:103:10) at Test.<anonymous> (/home/christianbundy/src/ssbc/ssb-db/test/add.js:28:7) at Test.bound [as _cb] (/home/christianbundy/src/ssbc/ssb-db/node_modules/tape/lib/test.js:77:32) at Test.run (/home/christianbundy/src/ssbc/ssb-db/node_modules/tape/lib/test.js:93:10) at Test.bound [as run] (/home/christianbundy/src/ssbc/ssb-db/node_modules/tape/lib/test.js:77:32) at Immediate.next (/home/christianbundy/src/ssbc/ssb-db/node_modules/tape/lib/results.js:81:19) npm ERR! Test failed. See above for more details. ``` That was quick. Let's hop over to ssb-validate and see if we can wrangle the new feed type. ## ssb-validate Looks like this is failing here: ```javascript var isInvalidShape = exports.isInvalidShape = function (msg) { if( !isObject(msg) || !isInteger(msg.sequence) || !isFeedId(msg.author) || !(isObject(msg.content) || isEncrypted(msg.content)) || !isValidOrder(msg, false) || //false, because message may not be signed yet. !isSupportedHash(msg) ) return new Error('message has invalid properties:'+JSON.stringify(msg, null, 2)) //allow encrypted messages, where content is a base64 string. //NOTE: since this checks the length of javascript string, //it's not actually the byte length! it's the number of utf8 chars //for latin1 it's gonna be 8k, but if you use all utf8 you can //approach 32k. This is a weird legacy thing, obviously, that //we will fix at some point... var asJson = encode(msg) if (asJson.length > 8192) // 8kb return new Error('encoded message must not be larger than 8192 bytes') return isInvalidContent(msg.content) } ``` The problem is [probably] that `isFeedId(msg.author)` is failing because of our weird feed type suffix, which is checked by ssb-ref. ## ssb-ref We can add support for the new feed type (and a test) with: ```diff diff --git a/index.js b/index.js index ba9dd10..184b031 100644 --- a/index.js +++ b/index.js @@ -5,7 +5,7 @@ var ip = require('ip') var parseLinkRegex = /^((@|%|&)[A-Za-z0-9\/+]{43}=\.[\w\d]+)(\?(.+))?$/ var linkRegex = exports.linkRegex = /^(@|%|&)[A-Za-z0-9\/+]{43}=\.[\w\d]+$/ -var feedIdRegex = exports.feedIdRegex = isCanonicalBase64('@', '\.(?:sha256|ed25519)', 32) +var feedIdRegex = exports.feedIdRegex = isCanonicalBase64('@', '\.(?:sha256|ed25519|ed25519.superCollider)', 32) var blobIdRegex = exports.blobIdRegex = isCanonicalBase64('&', '\.sha256', 32) var msgIdRegex = exports.msgIdRegex = isCanonicalBase64('%', '\.sha256', 32) diff --git a/test/index.js b/test/index.js index 8fc16ab..5a5d7cd 100644 --- a/test/index.js +++ b/test/index.js @@ -11,7 +11,7 @@ var cjdnsInvite = 'fcbc:6c66:bcd4:d3b5:2a2a:60b3:9b86:498f:8008:@ppdSxn1pSozJIqt var cjdnsAddr = 'fcbc:6c66:bcd4:d3b5:2a2a:60b3:9b86:498f:8008:@ppdSxn1pSozJIqtDE4pYgwaQGmswCT9y15VJJcXRntI=.ed25519' var cjdnsAddr2 = 'net:fcbc:6c66:bcd4:d3b5:2a2a:60b3:9b86:498f:8008~shs:ppdSxn1pSozJIqtDE4pYgwaQGmswCT9y15VJJcXRntI=' -var ipv6Addr = "2a03:2267::ba27:ebff:fe8c:5a4d:8080:@gYCJpN4eGDjHFnWW2Fcusj8O4QYbVDUW6rNYh7nNEnc=.ed25519" +var ipv6Addr = "2a03:2267::ba27:ebff:fe8c:5a4d:8080:@gYCJpN4eGDjHFnWW2Fcusj8O4QYbVDUW6rNYh7nNEnc=.ed25519.superCollider" var ipv6Invite = "2a03:2267::ba27:ebff:fe8c:5a4d:8080:@gYCJpN4eGDjHFnWW2Fcusj8O4QYbVDUW6rNYh7nNEnc=.ed25519~DxiHEv+ds+zUzA49efDgZk8ssGeqrp/5kgvRVzTM7vU=" var ipv6AddrLocal = "::1:8080:@gYCJpN4eGDjHFnWW2Fcusj8O4QYbVDUW6rNYh7nNEnc=.ed25519" var ipv6InviteLocal = "::1:8080:@gYCJpN4eGDjHFnWW2Fcusj8O4QYbVDUW6rNYh7nNEnc=.ed25519~DxiHEv+ds+zUzA49efDgZk8ssGeqrp/5kgvRVzTM7vU=" @@ -22,6 +22,8 @@ var secretMessage = "%WgVG9T2IryRoPMCQk7znuMt2Cmo/shgnrbn0wY6gc3M=.sha256?unbox= var msg_id = '%YPqekTHlErYzPzzonLC29mrkofpPDuQbUh+DgQYD6H4=.sha256' +const superColliderFeed = '@EQqExI5IrR2HK7lI1lFBJMt7V73dW9w6xVf58pFhvY4=.ed25519.superCollider' + var R = require('../') var tape = require('tape') @@ -248,5 +250,7 @@ tape('urls', function (t) { t.end() }) - - +tape('superCollider feed type support', function (t) { + t.equal(R.isFeedId(superColliderFeed), true) + t.end() +}) ``` ## ssb-db 2 Let's link ssb-ref and try again: ```console $ npm t > ssb-db@19.3.0 test /home/christianbundy/src/ssbc/ssb-db > set -e; for t in test/*.js; do node $t; done (node:23656) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead. TAP version 13 # add invalid message ok 1 should be truthy # add null message ok 2 should be truthy # add okay message /home/christianbundy/src/ssbc/ssb-db/test/add.js:29 if (err) throw err ^ Error: unkown curve:ed25519.superCollider expected: ed25519 at getCurve (/home/christianbundy/src/ssbc/ssb-keys/index.js:52:11) at verify (/home/christianbundy/src/ssbc/ssb-keys/index.js:115:17) at Object.exports.verifyObj (/home/christianbundy/src/ssbc/ssb-keys/index.js:140:10) at Object.exports.checkInvalid (/home/christianbundy/src/ssbc/ssb-db/node_modules/ssb-validate/index.js:155:15) at Object.exports.appendKVT (/home/christianbundy/src/ssbc/ssb-db/node_modules/ssb-validate/index.js:211:20) at Object.exports.append (/home/christianbundy/src/ssbc/ssb-db/node_modules/ssb-validate/index.js:240:18) at reduce (/home/christianbundy/src/ssbc/ssb-db/minimal.js:127:14) at queue (/home/christianbundy/src/ssbc/ssb-db/node_modules/async-write/index.js:30:31) at /home/christianbundy/src/ssbc/ssb-db/minimal.js:205:5 at EventEmitter.append (/home/christianbundy/src/ssbc/ssb-db/minimal.js:162:18) npm ERR! Test failed. See above for more details. ``` Back to ssb-keys. ## ssb-keys 2 ```diff diff --git a/index.js b/index.js index 20e5bc3..4d2ffb2 100644 --- a/index.js +++ b/index.js @@ -42,8 +42,9 @@ curves.ed25519 = require('./sodium') function getCurve(keys) { var curve = keys.curve - if(!keys.curve && isString(keys.public)) - keys = keys.public + if(!keys.curve && isString(keys.public)) { + keys = keys.public.split('.')[1] + } if(!curve && isString(keys)) curve = u.getTag(keys) ``` ## ssb-db 3 :tada: It looks like `npm test` works now, which is great. Let's go up another layer and see what breaks. ## ssb-server Our `ssb-db/util` hack doesn't work up here, so it looks like we'll need to dive back into ssb-keys to find a better solution. The first test is the `bin.js` script, which seems to use ssb-config, so maybe we'll start there. Aside: ssb-server tests look like they're currently failing, so that could make this harder to debug. ## ssb-config First off, tests fail when another Scuttlebutt client is open in the background. Let's try again after Patchwork. It looks like tests pass, and they *still* pass with ssb-keys linked, but I have a feeling that they aren't setting the ID correctly. ```diff diff --git a/inject.js b/inject.js index afde818..4577b91 100644 --- a/inject.js +++ b/inject.js @@ -5,5 +5,6 @@ module.exports = function (name, override) { name = name || 'ssb' var rc = RC(name, override || {}) var config = setDefaults(name, rc) + console.log(config) return config } ``` It's not very elegant debugging but it's fine for now. It's a bit strange that *some* configs have the correct feed types whereas others don't. It looks like ssb-config is actually persisting old keys (!) to `~/.testnet/` (!!) which is allowing these tests to pass because they ignore the new ssb-keys we've created. After some shenanigans where I had to manually kill the server started by a test (!!!) I've finally got an error to work with: ``` ok 35 remote connection to server works /home/christianbundy/src/ssbc/ssb-config/tests/server-startup.test.js:78 t.true(feed.id.startsWith('@'), 'remote query works') ^ TypeError: Cannot read property 'id' of null at ssb.whoami (/home/christianbundy/src/ssbc/ssb-config/tests/server-startup.test.js:78:23) at Object._requests.(anonymous function) (/home/christianbundy/src/ssbc/ssb-config/node_modules/packet-stream/index.js:38:5) at PacketStream._onrequest (/home/christianbundy/src/ssbc/ssb-config/node_modules/packet-stream/index.js:151:26) at PacketStream.write (/home/christianbundy/src/ssbc/ssb-config/node_modules/packet-stream/index.js:134:41) at /home/christianbundy/src/ssbc/ssb-config/node_modules/muxrpc/pull-weird.js:56:15 at /home/christianbundy/src/ssbc/ssb-config/node_modules/pull-stream/sinks/drain.js:24:37 at /home/christianbundy/src/ssbc/ssb-config/node_modules/pull-goodbye/node_modules/pull-stream/throughs/filter.js:17:11 at Object.cb (/home/christianbundy/src/ssbc/ssb-config/node_modules/packet-stream-codec/index.js:111:11) at drain (/home/christianbundy/src/ssbc/ssb-config/node_modules/pull-reader/index.js:39:14) at more (/home/christianbundy/src/ssbc/ssb-config/node_modules/pull-reader/index.js:55:1 ``` It looks like the test was crashing without closing the server, which is why I had to kill the process manually. ```diff diff --git a/tests/server-startup.test.js b/tests/server-startup.test.js index daae24b..c329104 100644 --- a/tests/server-startup.test.js +++ b/tests/server-startup.test.js @@ -75,6 +75,12 @@ test('Server startup - custom config', t => { t.false(err, 'remote connection to server works') ssb.whoami((err, feed) => { + if (err) { + server.send({ action: 'CLOSE' }) + server.kill() + + t.error(err) + } t.true(feed.id.startsWith('@'), 'remote query works') ssb.close(() => { ``` Not we can try again and we see the real error: ```json { "message": "method:whoami is not in list of allowed methods", "name": "Error", "stack": "Error: method:whoami is not in list of allowed methods\n at Function.perms.pre (/home/christianbundy/src/ssbc/ssb-config/node_modules/ssb-server/node_modules/muxrpc/permissions.js:88:14)\n at Object.<anonymous> (/home/christianbundy/src/ssbc/ssb-config/node_modules/ssb-server/node_modules/muxrpc/local-api.js:35:21)\n at Object.request (/home/christianbundy/src/ssbc/ssb-config/node_modules/ssb-server/node_modules/muxrpc/stream.js:48:17)\n at PacketStream._onrequest (/home/christianbundy/src/ssbc/ssb-config/node_modules/ssb-server/node_modules/packet-stream/index.js:161:17)\n at PacketStream.write (/home/christianbundy/src/ssbc/ssb-config/node_modules/ssb-server/node_modules/packet-stream/index.js:134:41)\n at /home/christianbundy/src/ssbc/ssb-config/node_modules/ssb-server/node_modules/muxrpc/pull-weird.js:56:15\n at /home/christianbundy/src/ssbc/ssb-config/node_modules/ssb-server/node_modules/pull-stream/sinks/drain.js:24:37\n at /home/christianbundy/src/ssbc/ssb-config/node_modules/ssb-server/node_modules/pull-goodbye/node_modules/pull-stream/throughs/filter.js:17:11\n at Object.cb (/home/christianbundy/src/ssbc/ssb-config/node_modules/ssb-server/node_modules/packet-stream-codec/index.js:111:11)\n at drain (/home/christianbundy/src/ssbc/ssb-config/node_modules/ssb-server/node_modules/pull-reader/index.js:39:14)" } ``` Looks like we'll need to teach muxrpc that it should use our public key rather than the feed ID. ## muxrpc ```diff diff --git a/permissions.js b/permissions.js index bdeb589..033b9f9 100644 --- a/permissions.js +++ b/permissions.js @@ -83,6 +83,7 @@ module.exports = function (opts) { if(opts) perms(opts) perms.pre = function (name, args) { + console.log(name, args) name = isArray(name) ? name : [name] if(allow && !u.prefix(allow, name)) return new Error('method:'+name + ' is not in list of allowed methods') ``` ## ssb-config 2 Unfortunately it looks like our above change didn't do anything, because ssb-config depends on ssb-server for test (which is shinkwrapped and immune to linked dependencies). Fun. Maybe we can link in ssb-server and have muxrpc get linked from there. It looks like ssb-config depends on an old version of ssb-server, so linking the new version just throws errors about plugins. Time to update. ```diff diff --git a/inject.js b/inject.js index afde818..4577b91 100644 --- a/inject.js +++ b/inject.js @@ -5,5 +5,6 @@ module.exports = function (name, override) { name = name || 'ssb' var rc = RC(name, override || {}) var config = setDefaults(name, rc) + console.log(config) return config } diff --git a/package.json b/package.json index 143eb72..eecdb67 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ }, "devDependencies": { "ssb-client": "^4.7.1", - "ssb-server": "^14.1.12", + "ssb-server": "^15.0.0", "tape": "^4.9.2" }, "author": "Dominic Tarr <dominic.tarr@gmail.com> (http://dominictarr.com)", diff --git a/tests/server-startup.test.js b/tests/server-startup.test.js index daae24b..c329104 100644 --- a/tests/server-startup.test.js +++ b/tests/server-startup.test.js @@ -75,6 +75,12 @@ test('Server startup - custom config', t => { t.false(err, 'remote connection to server works') ssb.whoami((err, feed) => { + if (err) { + server.send({ action: 'CLOSE' }) + server.kill() + + t.error(err) + } t.true(feed.id.startsWith('@'), 'remote query works') ssb.close(() => { diff --git a/tests/server/index.js b/tests/server/index.js index 4c102d1..7c749f1 100644 --- a/tests/server/index.js +++ b/tests/server/index.js @@ -3,7 +3,7 @@ const Path = require('path') module.exports = function TestServer (config) { const Server = require('ssb-server') - .use(require('ssb-server/plugins/master')) + .use(require('ssb-master')) const server = Server(config) writeManifest(server) ``` Looks like it works now, but muxrpc is just logging: ```javascript [ 'whoami' ] [ [Function] ] ``` Fine. Let's spelunk a bit deeper. ## muxrpc 2 The code seems to show that we're being authenticated as a stranger, which is weird because this is our server. The ssb-master plugin is meant to let the "masters" of the device into muxrpc, so it's probably not recognizing us because of the new feed type. ## ssb-master Sure enough, it's authenticating with muxrpc based on our *id*, not public key. It seems like *really* muxrpc should only care about signing keys rather than the feed identity and a feed type suffix, so maybe we can hack something together. ```diff diff --git a/index.js b/index.js index 1b3503a..3cc8267 100644 --- a/index.js +++ b/index.js @@ -2,10 +2,12 @@ // allows you to define "master" IDs in the config // which are given the full rights of the local main ID module.exports = function (api, opts) { + console.log(api) var masters = [api.id].concat(opts.master).filter(Boolean) api.auth.hook(function (fn, args) { + console.log(args) var id = args[0] var cb = args[1] - cb(null, ~masters.indexOf(id) ? {allow: null, deny: null} : null) + cb(null, masters.some(feedId => feedId.startsWith(id)) ? {allow: null, deny: null} : null) }) } ``` It still passes tests, and ensures that `@abc.ed25519` and `@abc.ed25519.xyz` are handled as synonyms. A few `console.log()` statements are added for future debugging. ## ssb-config 3 Tests pass! Time to go back to ssb-server now. It's important to remember that ssb-config only passes when linked to ssb-keys and ssb-server (which is linked to muxrpc and ssb-master). ## ssb-server 2 Circular dependency time. We'll link ssb-config into ssb-server and cross our fingers that it's all handled correctly. `test/bin.js` failed the first time but seemed to work fine the second time, but the ID it output didn't have the correct suffix. Now it looks like ssb-plugins is throwing errors about a non-existent muxrpc file? ``` Error: Cannot find module 'muxrpc/api' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Function.Module._load (internal/modules/cjs/loader.js:562:25) at Module.require (internal/modules/cjs/loader.js:690:17) at require (internal/modules/cjs/helpers.js:25:18) at Object.<anonymous> (/home/christianbundy/src/ssbc/ssb-server/node_modules/ssb-plugins/load.js:2:17) at Module._compile (internal/modules/cjs/loader.js:776:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) ``` We don't need that module right now anyway, let's comment it out. ```diff diff --git a/bin.js b/bin.js index 24dcacb..54eedb5 100755 --- a/bin.js +++ b/bin.js @@ -37,7 +37,7 @@ if (argv[0] == 'server') { if (argv[0] == 'start') { console.log(packageJson.name, packageJson.version, config.path, 'logging.level:'+config.logging.level) - console.log('my key ID:', config.keys.public) + console.log('my key ID:', config.keys.id) // special start command: // import ssbServer and start the server @@ -46,7 +46,7 @@ if (argv[0] == 'start') { .use(require('ssb-onion')) .use(require('ssb-unix-socket')) .use(require('ssb-no-auth')) - .use(require('ssb-plugins')) +// .use(require('ssb-plugins')) .use(require('ssb-master')) .use(require('ssb-gossip')) .use(require('ssb-replicate')) @@ -62,7 +62,7 @@ if (argv[0] == 'start') { .use(require('ssb-ooo')) // add third-party plugins - require('ssb-plugins').loadUserPlugins(createSsbServer, config) +// require('ssb-plugins').loadUserPlugins(createSsbServer, config) // start server var server = createSsbServer(config) ``` Also, since `compatibility` doesn't respect Ctrl + C it's worth removing it from `package.json` right now. We want to be able to see test output and we can't do that if it's pumping text to stdout non-stop. Looks like tests pass! Now to try `compatibility`... Hey, an error! ## ssb-invite ``` /home/christianbundy/src/ssbc/ssb-server/node_modules/ssb-invite/index.js:223 opts = ref.parseAddress(ref.parseInvite(invite).remote) ^ TypeError: Cannot read property 'remote' of null at Object.<anonymous> (/home/christianbundy/src/ssbc/ssb-server/node_modules/ssb-invite/index.js:223:56) at apply (/home/christianbundy/src/ssbc/ssb-server/node_modules/muxrpc-validation/index.js:197:15) at Object.<anonymous> (/home/christianbundy/src/ssbc/ssb-server/node_modules/muxrpc-validation/index.js:86:14) at Object.hooked [as accept] (/home/christianbundy/src/ssbc/ssb-server/node_modules/hoox/index.js:10:15) at /home/christianbundy/src/ssbc/ssb-server/node_modules/ssb-invite/test/invite.js:298:16 at /home/christianbundy/src/ssbc/ssb-server/node_modules/ssb-invite/index.js:139:13 at /home/christianbundy/src/ssbc/ssb-server/node_modules/level-sublevel/shell.js:53:51 at /home/christianbundy/src/ssbc/ssb-server/node_modules/level-sublevel/nut.js:109:13 ``` Looks like the tests are just broken though. Anyway, removing that from the `package.json` tests looks fine, but now we have an issue with ssb-gossip. ## ssb-gossip ``` # gossip: add and get peers ok 1 should be truthy Trace: deprecated api used: ssb-ref.parseAddress at Object.parseAddress (/home/christianbundy/src/ssbc/ssb-ref/index.js:96:15) at /home/christianbundy/src/ssbc/ssb-server/node_modules/ssb-gossip/test/gossip.js:50:26 at Array.map (<anonymous>) at Test.<anonymous> (/home/christianbundy/src/ssbc/ssb-server/node_modules/ssb-gossip/test/gossip.js:49:30) at Test.bound [as _cb] (/home/christianbundy/src/ssbc/ssb-server/node_modules/tape/lib/test.js:77:32) at Test.run (/home/christianbundy/src/ssbc/ssb-server/node_modules/tape/lib/test.js:96:10) at Test.bound [as run] (/home/christianbundy/src/ssbc/ssb-server/node_modules/tape/lib/test.js:77:32) at Immediate.next [as _onImmediate] (/home/christianbundy/src/ssbc/ssb-server/node_modules/tape/lib/results.js:75:19) at runCallback (timers.js:705:18) at tryOnImmediate (timers.js:676:5) { host: 'localhost', port: 8888, key: '@inE41q6QNzRRJuGuOw8R5g6t5hT/K3glGCyuWDIYdGs=.ed25519.superCollider', address: 'net:localhost:8888~shs:inE41q6QNzRRJuGuOw8R5g6t5hT/K3glGCyuWDIYdGs=', source: undefined, announcers: 1, duration: null } { host: 'localhost', port: 8888, key: '@inE41q6QNzRRJuGuOw8R5g6t5hT/K3glGCyuWDIYdGs=.ed25519' } { host: '182.23.49.132', port: 8881, key: '@TToGFwsHKkUV6mw8QuD7NgDrHMI+S4gE+4GWc+fqxzA=.ed25519.superCollider', address: 'net:182.23.49.132:8881~shs:TToGFwsHKkUV6mw8QuD7NgDrHMI+S4gE+4GWc+fqxzA=', source: undefined, announcers: 1, duration: null } { host: '182.23.49.132', port: 8881, key: '@TToGFwsHKkUV6mw8QuD7NgDrHMI+S4gE+4GWc+fqxzA=.ed25519' } { host: 'example.com', port: 8889, key: '@5Oq3XBeD3A2i+MpjFQLaGqoGFjF0WJSl0XoNg9bXiG8=.ed25519.superCollider', address: 'net:example.com:8889~shs:5Oq3XBeD3A2i+MpjFQLaGqoGFjF0WJSl0XoNg9bXiG8=', source: undefined, announcers: 1, duration: null } { host: 'example.com', port: 8889, key: '@5Oq3XBeD3A2i+MpjFQLaGqoGFjF0WJSl0XoNg9bXiG8=.ed25519' } not ok 2 should be equivalent --- operator: deepEqual expected: |- [ { host: 'localhost', port: 8888, key: '@inE41q6QNzRRJuGuOw8R5g6t5hT/K3glGCyuWDIYdGs=.ed25519.superCollider' }, { host: '182.23.49.132', port: 8881, key: '@TToGFwsHKkUV6mw8QuD7NgDrHMI+S4gE+4GWc+fqxzA=.ed25519.superCollider' }, { host: 'example.com', port: 8889, key: '@5Oq3XBeD3A2i+MpjFQLaGqoGFjF0WJSl0XoNg9bXiG8=.ed25519.superCollider' } ] actual: |- [ { host: 'localhost', port: 8888, key: '@inE41q6QNzRRJuGuOw8R5g6t5hT/K3glGCyuWDIYdGs=.ed25519' }, { host: '182.23.49.132', port: 8881, key: '@TToGFwsHKkUV6mw8QuD7NgDrHMI+S4gE+4GWc+fqxzA=.ed25519' }, { host: 'example.com', port: 8889, key: '@5Oq3XBeD3A2i+MpjFQLaGqoGFjF0WJSl0XoNg9bXiG8=.ed25519' } ] at: Test.<anonymous> (/home/christianbundy/src/ssbc/ssb-server/node_modules/ssb-gossip/test/gossip.js:48:5) stack: |- Error: should be equivalent at Test.assert [as _assert] (/home/christianbundy/src/ssbc/ssb-server/node_modules/tape/lib/test.js:226:54) at Test.bound [as _assert] (/home/christianbundy/src/ssbc/ssb-server/node_modules/tape/lib/test.js:77:32) at Test.tapeDeepEqual (/home/christianbundy/src/ssbc/ssb-server/node_modules/tape/lib/test.js:423:10) at Test.bound [as deepEqual] (/home/christianbundy/src/ssbc/ssb-server/node_modules/tape/lib/test.js:77:32) at Test.<anonymous> (/home/christianbundy/src/ssbc/ssb-server/node_modules/ssb-gossip/test/gossip.js:48:5) at Test.bound [as _cb] (/home/christianbundy/src/ssbc/ssb-server/node_modules/tape/lib/test.js:77:32) at Test.run (/home/christianbundy/src/ssbc/ssb-server/node_modules/tape/lib/test.js:96:10) at Test.bound [as run] (/home/christianbundy/src/ssbc/ssb-server/node_modules/tape/lib/test.js:77:32) at Immediate.next [as _onImmediate] (/home/christianbundy/src/ssbc/ssb-server/node_modules/tape/lib/results.js:75:19) at runCallback (timers.js:705:18) ... ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully