ssb-invite
Advanced tools
Comparing version 2.1.4 to 2.1.5
41
index.js
@@ -8,3 +8,2 @@ 'use strict' | ||
var ip = require('ip') | ||
var fs = require('fs') | ||
var ref = require('ssb-ref') | ||
@@ -25,6 +24,2 @@ var level = require('level') | ||
function isString (s) { | ||
return 'string' === typeof s | ||
} | ||
function isObject(o) { | ||
@@ -47,3 +42,3 @@ return o && 'object' === typeof o | ||
init: function (server, config) { | ||
var codes = {}, codesDB | ||
let codesDB | ||
if(server.sublevel) | ||
@@ -79,3 +74,3 @@ codesDB = server.sublevel('codes') | ||
: server.getAddress('public') | ||
) | ||
) | ||
} | ||
@@ -111,4 +106,5 @@ | ||
if(!config.allowPrivate && (ip.isPrivate(host) || 'localhost' === host || host === '')) | ||
return cb(new Error('Server has no public ip address, ' | ||
+ 'cannot create useable invitation')) | ||
return cb(new Error( | ||
'Server has no public ip address, cannot create useable invitation') | ||
) | ||
@@ -126,3 +122,2 @@ //this stuff is SECURITY CRITICAL | ||
// store metadata under the generated pubkey | ||
var owner = server.id | ||
codesDB.put(keyCap.id, { | ||
@@ -139,3 +134,3 @@ id: keyCap.id, | ||
var ws_addr = getInviteAddress().split(';').sort(function (a, b) { | ||
return +/^ws/.test(b) - +/^ws/.test(a) | ||
return +/^ws/.test(b) - +/^ws/.test(a) | ||
}).shift() | ||
@@ -162,4 +157,4 @@ | ||
server.friends.get(function (err, follows) { | ||
// server.friends.all('follow', function(err, follows) { | ||
// if(hops[req.feed] == 1) | ||
// server.friends.all('follow', function(err, follows) { | ||
// if(hops[req.feed] == 1) | ||
if (follows && follows[server.id] && follows[server.id][req.feed]) | ||
@@ -215,3 +210,2 @@ return cb(new Error('already following')) | ||
// using a keypair generated from the key-seed in the invite code | ||
var modern = false | ||
if(ref.isInvite(invite)) { //legacy ivite | ||
@@ -227,4 +221,2 @@ if(ref.isLegacyInvite(invite)) { | ||
} | ||
else | ||
modern = true | ||
} | ||
@@ -279,15 +271,14 @@ | ||
? cont(server.publish)({ | ||
type: 'pub', | ||
address: opts | ||
}) | ||
type: 'pub', | ||
address: opts | ||
}) | ||
: function (cb) { cb() } | ||
) | ||
]) | ||
(function (err, results) { | ||
])(function (err, results) { | ||
if(err) return cb(err) | ||
rpc.close() | ||
rpc.close() | ||
//ignore err if this is new style invite | ||
if(server.gossip) server.gossip.add(ref.parseInvite(invite).remote, 'seed') | ||
cb(null, results) | ||
rpc.close() | ||
//ignore err if this is new style invite | ||
if(server.gossip) server.gossip.add(ref.parseInvite(invite).remote, 'seed') | ||
cb(null, results) | ||
}) | ||
@@ -294,0 +285,0 @@ }) |
{ | ||
"name": "ssb-invite", | ||
"description": "", | ||
"version": "2.1.4", | ||
"version": "2.1.5", | ||
"homepage": "https://github.com/ssbc/ssb-invite", | ||
@@ -14,3 +14,3 @@ "repository": { | ||
"ip": "^1.1.5", | ||
"level": "^5.0.0", | ||
"level": "^6.0.1", | ||
"level-sublevel": "^6.6.5", | ||
@@ -17,0 +17,0 @@ "muxrpc-validation": "^3.0.0", |
@@ -16,19 +16,7 @@ # ssb-invite | ||
### create: async | ||
### create ({uses, note, external, modern}, cb(err, invite_code)) | ||
Create a new invite code. | ||
```shell | ||
create {n} [{note}, {external}] | ||
``` | ||
```javascript | ||
create(n[, note, external], cb) | ||
``` | ||
This produces an invite-code which encodes the ssb-server instance's public address, and a keypair seed. | ||
The keypair seed is used to generate a keypair, which is then used to authenticate a connection with the ssb-server instance. | ||
The ssb-server instance will then grant access to the `use` call. | ||
- `n` (number): How many times the invite can be used before it expires. | ||
- `uses` (number): How many times the invite can be used before it expires. | ||
- `note` (string): A note to associate with the invite code. The ssb-server instance will | ||
@@ -38,18 +26,15 @@ include this note in the follow message that it creates when `use` is | ||
- `external` (string): An external hostname to use | ||
- `modern` (boolean): if true the invite code will be a valid multiserver address. | ||
if modern is enabled, uses will be set to 1. | ||
This produces an invite-code which encodes the ssb-server instance's public address, | ||
and a keypair seed. The keypair seed is used to generate a keypair, which is then used to authenticate a connection with the ssb-server instance. | ||
The ssb-server instance will then grant access to the `use` call. | ||
### accept: async | ||
### accept(invite_code, cb) | ||
Use an invite code. | ||
- invitecode (string) | ||
- invite_code (string): an invite code returned by `create` | ||
```bash | ||
accept {invitecode} | ||
``` | ||
```js | ||
accept(invitecode, cb) | ||
``` | ||
This connects to the server address encoded in the invite-code, then calls `use()` on the server. | ||
@@ -59,14 +44,10 @@ It will cause the server to follow the local user. | ||
### use: async | ||
### use ({feed:feedId}), cb) | ||
Use an invite code created by this ssb-server instance (advanced function). | ||
This method is used internally, it is called on the remote pub by your local instance | ||
when you call `accept`. To call `use` you must authenticate | ||
as a guest, by using the seed in an invite code, that was created by this pub. | ||
```bash | ||
use --feed {feedid} | ||
``` | ||
`use({feed: feed_id}, cb)` | ||
```javascript | ||
use({ feed: }, cb) | ||
``` | ||
This commands the receiving server to follow the given feed. | ||
@@ -73,0 +54,0 @@ |
@@ -240,3 +240,3 @@ //WARNING: this test currently only passes | ||
var inviteV6 | ||
let inviteV6 | ||
= invite.replace(/localhost|([0-9.]*)/, '::1') | ||
@@ -253,3 +253,3 @@ | ||
var inviteV6 = addr.host + ':'+ addr.port + ':' + addr.key + '~' + parts[1] | ||
inviteV6 = addr.host + ':'+ addr.port + ':' + addr.key + '~' + parts[1] | ||
@@ -256,0 +256,0 @@ bob.invite.accept(inviteV6, function (err, msg) { |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
1
25178
624
60
1
+ Addedimmediate@3.3.0(transitive)
+ Addedlevel@6.0.1(transitive)
+ Addedlevel-js@5.0.2(transitive)
- Removedabstract-leveldown@6.0.36.3.0(transitive)
- Removedimmediate@3.2.3(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedlevel@5.0.1(transitive)
- Removedlevel-js@4.0.2(transitive)
- Removedopencollective-postinstall@2.0.3(transitive)
- Removedtypedarray-to-buffer@3.1.5(transitive)
Updatedlevel@^6.0.1