ssb-invite
Advanced tools
Comparing version 3.0.1 to 3.0.2
46
index.js
'use strict' | ||
var valid = require('muxrpc-validation')({}) | ||
var crypto = require('crypto') | ||
var ssbKeys = require('ssb-keys') | ||
var cont = require('cont') | ||
var explain = require('explain-error') | ||
var ip = require('ip') | ||
var ref = require('ssb-ref') | ||
var level = require('level') | ||
var path = require('path') | ||
const valid = require('muxrpc-validation')({}) | ||
const crypto = require('crypto') | ||
const ssbKeys = require('ssb-keys') | ||
const cont = require('cont') | ||
const explain = require('explain-error') | ||
const ip = require('ip') | ||
const ref = require('ssb-ref') | ||
const level = require('level') | ||
const path = require('path') | ||
var createClient = require('ssb-client/client') | ||
const createClient = require('ssb-client/client') | ||
@@ -53,3 +53,3 @@ // invite plugin | ||
server.auth.hook((fn, args) => { | ||
var pubkey = args[0]; var cb = args[1] | ||
const pubkey = args[0]; const cb = args[1] | ||
@@ -89,3 +89,3 @@ // run normal authentication | ||
var addr = getInviteAddress() | ||
let addr = getInviteAddress() | ||
if (!addr) { | ||
@@ -99,3 +99,3 @@ return cb(new Error( | ||
addr = addr.split(';').shift() | ||
var host = ref.parseAddress(addr).host | ||
let host = ref.parseAddress(addr).host | ||
if (typeof host !== 'string') { | ||
@@ -120,4 +120,4 @@ return cb(new Error('Could not parse host portion from server address:' + addr)) | ||
// generate a key-seed and its key | ||
var seed = crypto.randomBytes(32) | ||
var keyCap = ssbKeys.generate('ed25519', seed) | ||
const seed = crypto.randomBytes(32) | ||
const keyCap = ssbKeys.generate('ed25519', seed) | ||
@@ -135,3 +135,3 @@ // store metadata under the generated pubkey | ||
else if (opts.modern) { | ||
var wsAddr = getInviteAddress().split(';').sort(function (a, b) { | ||
const wsAddr = getInviteAddress().split(';').sort(function (a, b) { | ||
return +/^ws/.test(b) - +/^ws/.test(a) | ||
@@ -149,3 +149,3 @@ }).shift() | ||
use: valid.async(function (req, cb) { | ||
var rpc = this | ||
const rpc = this | ||
@@ -202,3 +202,3 @@ // fetch the code | ||
if (invite.charAt(0) === '"' && invite.charAt(invite.length - 1) === '"') { invite = invite.slice(1, -1) } | ||
var opts | ||
let opts | ||
// connect to the address in the invite code | ||
@@ -208,6 +208,6 @@ // using a keypair generated from the key-seed in the invite code | ||
if (ref.isLegacyInvite(invite)) { | ||
var parts = invite.split('~') | ||
const parts = invite.split('~') | ||
opts = ref.parseAddress(parts[0])// .split(':') | ||
// convert legacy code to multiserver invite code. | ||
var protocol = 'net:' | ||
let protocol = 'net:' | ||
if (opts.host.endsWith('.onion')) { protocol = 'onion:' } | ||
@@ -227,3 +227,3 @@ invite = protocol + opts.host + ':' + opts.port + '~shs:' + opts.key.slice(1, -8) + ':' + parts[1] | ||
remote: invite, | ||
config: config, | ||
config, | ||
manifest: { invite: { use: 'async' }, getAddress: 'async' } | ||
@@ -239,5 +239,5 @@ }, cb) | ||
function retry (fn, cb) { | ||
var n = 0 | ||
let n = 0 | ||
;(function next () { | ||
var start = Date.now() | ||
const start = Date.now() | ||
fn(function (err, value) { | ||
@@ -244,0 +244,0 @@ n++ |
{ | ||
"name": "ssb-invite", | ||
"description": "", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"homepage": "https://github.com/ssbc/ssb-invite", | ||
@@ -11,4 +11,5 @@ "repository": { | ||
"scripts": { | ||
"test": "npm run test:js && npm run lint", | ||
"test": "npm run test:js && npm run test:js:old && npm run lint", | ||
"test:js": "tape 'test/*.test.js' | tap-arc", | ||
"test:js:old": "OLD_DEPS=true npm run test:js", | ||
"lint": "standard --fix" | ||
@@ -23,15 +24,19 @@ }, | ||
"ssb-client": "^4.9.0", | ||
"ssb-keys": "^7.2.2", | ||
"ssb-ref": "^2.14.0" | ||
"ssb-keys": "^8.5.0", | ||
"ssb-ref": "^2.16.0" | ||
}, | ||
"devDependencies": { | ||
"pull-stream": "^3.6.14", | ||
"scuttle-testbot": "^1.10.0", | ||
"ssb-ebt": "^8.1.1", | ||
"ssb-friends": "^5.1.5", | ||
"ssb-replication-scheduler": "^2.0.3", | ||
"pull-stream": "^3.7.0", | ||
"scuttle-testbot": "^2.2.0", | ||
"ssb-ebt": "^9.1.2", | ||
"ssb-friends": "^5.1.7", | ||
"ssb-friends-4": "npm:ssb-friends@4.4.10", | ||
"ssb-invite-2": "npm:ssb-invite@2.1.7", | ||
"ssb-conn-1": "npm:ssb-conn@1.0.0", | ||
"ssb-replicate": "^1.3.5", | ||
"ssb-replication-scheduler": "^3.1.0", | ||
"ssb-ws": "^6.2.3", | ||
"standard": "^14.3.4", | ||
"tap-arc": "^0.3.4", | ||
"tape": "^4.13.2" | ||
"standard": "^17.1.0", | ||
"tap-arc": "^1.2.2", | ||
"tape": "^5.7.2" | ||
}, | ||
@@ -38,0 +43,0 @@ "author": "Dominic Tarr <dominic.tarr@gmail.com> (http://dominictarr.com)", |
// WARNING: this test currently only passes if the computer has a network. | ||
var tape = require('tape') | ||
var pull = require('pull-stream') | ||
var ref = require('ssb-ref') | ||
var crypto = require('crypto') | ||
var Server = require('./test-bot') | ||
const tape = require('tape') | ||
const pull = require('pull-stream') | ||
const ref = require('ssb-ref') | ||
const crypto = require('crypto') | ||
const Server = require('./test-bot') | ||
let skipIPv6 = false | ||
if (process.env.TRAVIS === 'true') { | ||
console.warn('IPv6 is unsupported under Travis CI, test skipped') | ||
var skipIPv6 = true | ||
skipIPv6 = true | ||
} | ||
@@ -18,5 +19,5 @@ | ||
tape('test invite.accept api', function (t) { | ||
var alice = Server({ allowPrivate: true }) | ||
var bob = Server() | ||
var carol = Server() | ||
const alice = Server({ allowPrivate: true }) | ||
const bob = Server() | ||
const carol = Server() | ||
@@ -56,9 +57,9 @@ if (!alice.getAddress('device')) { throw new Error('alice must have device address') } | ||
tape('test invite.accept api using non default app key', function (t) { | ||
var caps = { | ||
const caps = { | ||
shs: crypto.randomBytes(32).toString('base64') | ||
} | ||
var alice = Server({ allowPrivate: true, caps }) | ||
var bob = Server({ caps }) | ||
var carol = Server({ caps }) | ||
const alice = Server({ allowPrivate: true, caps }) | ||
const bob = Server({ caps }) | ||
const carol = Server({ caps }) | ||
@@ -98,4 +99,4 @@ if (!alice.getAddress('device')) { throw new Error('alice must have device address') } | ||
tape('test invite.accept doesnt follow if already followed', function (t) { | ||
var alice = Server({ allowPrivate: true }) | ||
var bob = Server() | ||
const alice = Server({ allowPrivate: true }) | ||
const bob = Server() | ||
@@ -120,3 +121,3 @@ // request a secret that with particular permissions. | ||
// this makes the tests fail unless we get the address the same way as invite code. | ||
var expected = alice.address('public') || alice.address('local') || alice.address('device') | ||
const expected = alice.address('public') || alice.address('local') || alice.address('device') | ||
t.deepEqual( | ||
@@ -172,4 +173,4 @@ ary.map(m => m.value.content), | ||
tape('test invite.accept publishes new "pub" msg if same pub at different address', function (t) { | ||
var alice = Server({ allowPrivate: true }) | ||
var bob = Server() | ||
const alice = Server({ allowPrivate: true }) | ||
const bob = Server() | ||
@@ -232,4 +233,4 @@ // request a secret that with particular permissions. | ||
tape('test invite.accept api with ipv6', { skip: skipIPv6 }, function (t) { | ||
var alice = Server({ allowPrivate: true }) | ||
var bob = Server() | ||
const alice = Server({ allowPrivate: true }) | ||
const bob = Server() | ||
@@ -246,5 +247,5 @@ alice.invite.create(1, function (err, invite) { | ||
// console.log(inviteV6, invite) | ||
var parts = invite.split('~') | ||
const parts = invite.split('~') | ||
var addr = ref.parseAddress(parts[0]) | ||
const addr = ref.parseAddress(parts[0]) | ||
@@ -251,0 +252,0 @@ addr.host = '::1' |
// WARNING: this test currently only passes if the computer has a network. | ||
var tape = require('tape') | ||
var ssbKeys = require('ssb-keys') | ||
var ssbClient = require('ssb-client') | ||
var crypto = require('crypto') | ||
var Server = require('./test-bot') | ||
const tape = require('tape') | ||
const ssbKeys = require('ssb-keys') | ||
const ssbClient = require('ssb-client') | ||
const crypto = require('crypto') | ||
const Server = require('./test-bot') | ||
var host = '127.0.0.1' | ||
const host = '127.0.0.1' | ||
// var host = '::' | ||
@@ -13,3 +13,3 @@ // WARNING host '::' currently fails this tests because it creates an invite | ||
var wsConnections = { | ||
const wsConnections = { | ||
incoming: { | ||
@@ -26,8 +26,8 @@ net: [{ scope: ['local', 'device'], transform: 'shs', host }], | ||
tape('test invite.create with modern', function (t) { | ||
var alice = Server({ | ||
const alice = Server({ | ||
allowPrivate: true, | ||
connections: wsConnections | ||
}) | ||
var bob = Server() | ||
var carol = Server() | ||
const bob = Server() | ||
const carol = Server() | ||
console.log({ | ||
@@ -73,7 +73,7 @@ alice: alice.id, | ||
tape('invite guest may NOT call get', function (t) { | ||
var caps = { | ||
const caps = { | ||
shs: crypto.randomBytes(32).toString('base64') | ||
} | ||
var alice = Server({ | ||
const alice = Server({ | ||
allowPrivate: true, | ||
@@ -83,3 +83,3 @@ connections: wsConnections, | ||
}) | ||
var bobKeys = ssbKeys.generate() | ||
const bobKeys = ssbKeys.generate() | ||
@@ -86,0 +86,0 @@ alice.publish({ type: 'test', okay: true }, function (err, msg) { |
// WARNING: this test currently only passes if the computer has a network. | ||
var tape = require('tape') | ||
var pull = require('pull-stream') | ||
var Server = require('./test-bot') | ||
const tape = require('tape') | ||
const pull = require('pull-stream') | ||
const Server = require('./test-bot') | ||
@@ -11,3 +11,3 @@ function all (stream, cb) { | ||
tape('test invite with note', function (t) { | ||
var wsConnections = { | ||
const wsConnections = { | ||
incoming: { | ||
@@ -22,7 +22,7 @@ net: [{ scope: ['local', 'device'], transform: 'shs', host: '::' }], | ||
} | ||
var alice = Server({ | ||
const alice = Server({ | ||
allowPrivate: true, | ||
connections: wsConnections | ||
}) | ||
var bob = Server() | ||
const bob = Server() | ||
@@ -29,0 +29,0 @@ alice.invite.create({ uses: 1, note: 'bob' }, (err, invite) => { |
@@ -1,5 +0,7 @@ | ||
var ssbKeys = require('ssb-keys') | ||
var crypto = require('crypto') | ||
const ssbKeys = require('ssb-keys') | ||
const crypto = require('crypto') | ||
var caps = { shs: crypto.randomBytes(32).toString('base64') } | ||
const caps = { | ||
shs: crypto.randomBytes(32).toString('base64') | ||
} | ||
@@ -13,8 +15,20 @@ module.exports = function (opts = {}) { | ||
.use(require('..')) | ||
.use(require('ssb-friends')) | ||
.use(require('ssb-ebt')) | ||
.use(require('ssb-replication-scheduler')) | ||
.use(require('ssb-ws')) | ||
return stack(opts) | ||
if (process.env.OLD_DEPS) { | ||
stack | ||
.use(require('ssb-replicate')) | ||
.use(require('ssb-friends-4')) | ||
.use(require('ssb-conn-1')) | ||
} else { | ||
stack | ||
.use(require('ssb-friends')) | ||
.use(require('ssb-ebt')) | ||
.use(require('ssb-replication-scheduler')) | ||
} | ||
return stack({ | ||
db1: true, | ||
...opts | ||
}) | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32277
12
762
13
3
Updatedssb-keys@^8.5.0
Updatedssb-ref@^2.16.0