ssbc / ssb-peer-invites

A new ssb invite system to create invites without having a pub
MIT License
26 stars 2 forks source link

Crashing when running into bad messages #27

Open Powersource opened 4 years ago

Powersource commented 4 years ago

Installed the plugins (in the right order hopefully/I think, doing the same as https://github.com/ssbc/ssb-peer-invites/issues/20 ) and when ssb-peer-invites is doing its indexing it is always after a while crashing on this line https://github.com/ssbc/ssb-peer-invites/blob/master/types.js#L32

some debug stuff i've gotten out of it

the bad msg on that line:

{
  "previous": "%kGpWtt0hYZYgceya6UcSuAqenjKBHqH/9NkvYslgi8A=.sha256",
  "sequence": 571,
  "author": "@gslfzChyXwRD4A1iJ5a88gi0JmphVXyQeb77fXXj2mo=.ed25519",
  "timestamp": 1549257332319,
  "hash": "sha256",
  "content": {
    "type": "peer-invite",
    "invite": "@GzOYyFL0oNcgAlJOoiiktJd669xUmmlruYviaSdZ/pY=.ed25519",
    "host": "@gslfzChyXwRD4A1iJ5a88gi0JmphVXyQeb77fXXj2mo=.ed25519",
    "signature": "wrEyZZk7KI8fp7apQtGwyptfLisRYEq+f/y39vV1pB7Ppgx0H208hqLlTixH/G5EHkNLI86E3kum8aHp/ebIAw==.sig.ed25519"
  },
  "signature": "uesDTPAb52s9MGeb+e3d2+yWcGOrkHwtDbRBm+2C4Yp18FKjTkia4xDeNIIUgcU4d6LyQ3t0LgXpvXbZFVsXCw==.sig.ed25519"
}

caps on that line

<ref *1> {
  shs: '1KHLiKZvAvjbY1ziZEHMXawbCEIM6qwjCDm3VYRan/s=',
  sign: null,
  invite: 'HT0wIYuk3OWc2FtaCfHNnakV68jSGRrjRMP9Kos7IQc=',
  peerInvite: [Circular *1]
}

the stacktrace

/home/me/prj/ssb/ssb-peer-invites/node_modules/ssb-keys/util.js:42
  var i = buf.indexOf('.')
              ^

TypeError: buf.indexOf is not a function
    at Object.exports.toBuffer (/home/me/prj/ssb/ssb-peer-invites/node_modules/ssb-keys/util.js:42:15)
    at Object.exports.verifyObj (/home/me/prj/ssb/ssb-peer-invites/node_modules/ssb-keys/index.js:139:30)
    at Object.exports.isInvite (/home/me/prj/ssb/ssb-peer-invites/types.js:37:13)
    at reduce (/home/me/prj/ssb/ssb-peer-invites/index.js:77:14)
    at /home/me/prj/ssb/ssb-peer-invites/node_modules/flumeview-reduce/inject.js:148:39
    at /home/me/prj/ssb/ssb-peer-invites/node_modules/pull-stream/sinks/drain.js:24:37
    at /home/me/prj/ssb/flotilla/node_modules/pull-stream/throughs/async-map.js:39:20
    at /home/me/prj/ssb/flotilla/node_modules/flumedb/index.js:60:13
    at Array.unboxerMap (/home/me/prj/ssb/flotilla/node_modules/ssb-db/minimal.js:98:35)
    at chainMaps (/home/me/prj/ssb/flotilla/node_modules/ssb-db/minimal.js:103:14)

Am I doing something wrong or is this a bug? It feels like ssb-keys should return false if it's a bad msg and if I'm doing something wrong it should tell me more about what I'm doing wrong.


Was going to guess that @gslfzChyXwRD4A1iJ5a88gi0JmphVXyQeb77fXXj2mo=.ed25519 was one of my testing accounts but it seems it's @giarc

Powersource commented 4 years ago

My flotilla (server used by oasis) branch for reference https://github.com/Powersource/flotilla/tree/add-peer-invites

KyleMaas commented 1 year ago

I think I just hit this. My ssb-minimal-pub-server crashes with:

/home/ssb-pub/.nvm/versions/node/v10.24.1/lib/node_modules/ssb-minimal-pub-server/node_modules/ssb-keys/util.js:42
  var i = buf.indexOf('.')
              ^

TypeError: buf.indexOf is not a function
    at Object.exports.toBuffer (/home/ssb-pub/.nvm/versions/node/v10.24.1/lib/node_modules/ssb-minimal-pub-server/node_modules/ssb-keys/util.js:42:15)
    at Object.exports.verifyObj (/home/ssb-pub/.nvm/versions/node/v10.24.1/lib/node_modules/ssb-minimal-pub-server/node_modules/ssb-keys/index.js:139:30)
    at Object.exports.isInvite (/home/ssb-pub/.nvm/versions/node/v10.24.1/lib/node_modules/ssb-minimal-pub-server/node_modules/ssb-peer-invites/types.js:32:13)
    at reduce (/home/ssb-pub/.nvm/versions/node/v10.24.1/lib/node_modules/ssb-minimal-pub-server/node_modules/ssb-peer-invites/index.js:77:14)
    at /home/ssb-pub/.nvm/versions/node/v10.24.1/lib/node_modules/ssb-minimal-pub-server/node_modules/flumeview-reduce/inject.js:149:39
    at /home/ssb-pub/.nvm/versions/node/v10.24.1/lib/node_modules/ssb-minimal-pub-server/node_modules/pull-stream/sinks/drain.js:24:37
    at /home/ssb-pub/.nvm/versions/node/v10.24.1/lib/node_modules/ssb-minimal-pub-server/node_modules/pull-stream/throughs/async-map.js:39:20
    at mapper (/home/ssb-pub/.nvm/versions/node/v10.24.1/lib/node_modules/ssb-minimal-pub-server/node_modules/flumedb/index.js:60:13)
    at Array.unboxerMap (/home/ssb-pub/.nvm/versions/node/v10.24.1/lib/node_modules/ssb-minimal-pub-server/node_modules/ssb-db/minimal.js:85:35)
    at chainMaps (/home/ssb-pub/.nvm/versions/node/v10.24.1/lib/node_modules/ssb-minimal-pub-server/node_modules/ssb-db/minimal.js:90:14)

So I added the following two lines at https://github.com/ssbc/ssb-peer-invites/blob/491c777152c37eb60e9933209b92b3a4421e7369/types.js#L25

  var util = require('util')
  console.log("Peer invite: " + util.inspect(caps.peerInvite));

Which yields console output of:

Peer invite: { shs: '1KHLiKZvAvjbY1ziZEHMXawbCEIM6qwjCDm3VYRan/s=',
  sign: null,
  peerInvite: [Circular] }

Which appears to be what's causing it. If I uncomment the return true line and skip all that, the pub seems to operate as it should.

Powersource commented 1 year ago

Easiest solution might be to uninstall peer-invites, I don't think it's widely adopted.

KyleMaas commented 1 year ago

If the general sentiment is that this module is obsolete, then there should probably be a deprecation notice added to the README.

Powersource commented 1 year ago

I think it's used in ssb-browser-demo and patchbay. Patchbay isn't maintained and the other one's a demo. I also don't think this module supports db2 or will. You can still use it so maybe obsolete is the wrong word, but maybe not recommended to adopt.