Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update modules, lint #35

Merged
merged 2 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
node-version: [14.x, 16.x, 18.x]

steps:
- uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
package-lock.json
48 changes: 24 additions & 24 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
'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')

var createClient = require('ssb-client/client')
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')

const createClient = require('ssb-client/client')

// invite plugin
// adds methods for producing invite-codes,
Expand Down Expand Up @@ -50,7 +50,7 @@ module.exports = {

// add an auth hook.
server.auth.hook((fn, args) => {
var pubkey = args[0]; var cb = args[1]
const pubkey = args[0]; const cb = args[1]

// run normal authentication
fn(pubkey, function (err, auth) {
Expand Down Expand Up @@ -85,7 +85,7 @@ module.exports = {
opts = {}
}

var addr = getInviteAddress()
let addr = getInviteAddress()
if (!addr) {
return cb(new Error(
'no address available for creating an invite,' +
Expand All @@ -94,7 +94,7 @@ module.exports = {
))
}
addr = addr.split(';').shift()
var host = ref.parseAddress(addr).host
let host = ref.parseAddress(addr).host
if (typeof host !== 'string') {
return cb(new Error('Could not parse host portion from server address:' + addr))
}
Expand All @@ -114,8 +114,8 @@ module.exports = {
// it should be able to diminish it's own permissions.

// 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)

// store metadata under the generated pubkey
codesDB.put(keyCap.id, {
Expand All @@ -128,7 +128,7 @@ module.exports = {
// emit the invite code: our server address, plus the key-seed
if (err) cb(err)
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)
}).shift()

Expand All @@ -141,7 +141,7 @@ module.exports = {
})
}, 'number|object', 'string?'),
use: valid.async(function (req, cb) {
var rpc = this
const rpc = this

// fetch the code
codesDB.get(rpc.id, function (err, invite) {
Expand Down Expand Up @@ -193,15 +193,15 @@ module.exports = {
if (isObject(invite)) { invite = invite.invite }

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
// using a keypair generated from the key-seed in the invite code
if (ref.isInvite(invite)) { // legacy invite
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:' }
invite = protocol + opts.host + ':' + opts.port + '~shs:' + opts.key.slice(1, -8) + ':' + parts[1]
}
Expand All @@ -216,7 +216,7 @@ module.exports = {
createClient({
keys: true, // use seed from invite instead.
remote: invite,
config: config,
config,
manifest: { invite: { use: 'async' }, getAddress: 'async' }
}, cb)
}
Expand All @@ -227,9 +227,9 @@ module.exports = {
// when it connects?

function retry (fn, cb) {
var n = 0
let n = 0
;(function next () {
var start = Date.now()
const start = Date.now()
fn(function (err, value) {
n++
if (n >= 3) cb(err, value)
Expand Down
Loading
Loading