ssbc / ssb-conn

SSB plugin for establishing and managing peer connections
MIT License
16 stars 5 forks source link

unable to load ssb-conn or ssb-legacy-conn as a plugin with ~/.ssb/config #19

Open khimaros opened 4 years ago

khimaros commented 4 years ago

When I build this package, install to ~/.ssb/node_modules, and include in ~/.ssb/config, an error of this form is thrown on ssb-server startup:

/home/.../ssb/ssb-server/node_modules/ssb-plugins/load-user-plugins.js:55
        throw new Error('plugin at:'+module_name+' expected name:'+name+' but had:'+(plugin||{}).name)
        ^
Error: plugin at:ssb-conn expected name:conn but had:undefined

The configuration is of the form:

{
  "plugins": {
    "ssb-conn": true,
    // ...
  }
}

I'm able to work around this by modifying ssb-server/index.js SecretStack to .use(require('ssb-conn')):

  return SecretStack({ caps: { shs: Buffer.from(caps.shs, 'base64') } })
    .use(require('ssb-db'))
    .use(require('ssb-conn'))

I have a similar issue with ssb-legacy-conn and other similarly shaped plugins.

Are these not meant to be loaded via ~/.ssb/config? Am I holding it wrong?

staltz commented 4 years ago

Yeah, this plugin wasn't designed to be installed in ~/.ssb, it's meant to be installed in app code. But I'm not opposed to supporting this use case, I just haven't done it and don't have time to dedicate, so PRs are welcome for this.