mirror of https://codeberg.org/pzp/pzp-hub.git
update secret-stack to bare mode
This commit is contained in:
parent
11fa0eba58
commit
b3168890a7
11
lib/peer.cjs
11
lib/peer.cjs
|
@ -1,24 +1,25 @@
|
||||||
const Path = require('node:path')
|
const Path = require('node:path')
|
||||||
const Keypair = require('ppppp-keypair')
|
const Keypair = require('ppppp-keypair')
|
||||||
const caps = require('ppppp-caps')
|
const caps = require('ppppp-caps')
|
||||||
const SSAPI = require('secret-stack/lib/api')
|
const SecretStack = require('secret-stack/bare')
|
||||||
|
|
||||||
module.exports = function startPeer() {
|
module.exports = function startPeer() {
|
||||||
const path = Path.join(__dirname, '..', 'data')
|
const path = Path.join(__dirname, '..', 'data')
|
||||||
const keypairPath = Path.join(path, 'keypair')
|
const keypairPath = Path.join(path, 'keypair')
|
||||||
const keypair = Keypair.loadOrCreateSync(keypairPath)
|
const keypair = Keypair.loadOrCreateSync(keypairPath)
|
||||||
|
|
||||||
SSAPI([], {})
|
SecretStack({ caps })
|
||||||
.use(require('secret-stack/lib/core'))
|
.use(require('secret-stack/plugins/net'))
|
||||||
.use(require('secret-stack/lib/plugins/net'))
|
|
||||||
.use(require('secret-handshake-ext/secret-stack'))
|
.use(require('secret-handshake-ext/secret-stack'))
|
||||||
.use(require('ssb-conn'))
|
.use(require('ssb-conn'))
|
||||||
.use(require('./plugin-hub.cjs'))
|
.use(require('./plugin-hub.cjs'))
|
||||||
.use(require('./plugin-hub-client.cjs'))
|
.use(require('./plugin-hub-client.cjs'))
|
||||||
.call(null, {
|
.call(null, {
|
||||||
path,
|
path,
|
||||||
caps,
|
|
||||||
keypair,
|
keypair,
|
||||||
|
timers: {
|
||||||
|
inactivity: 600e3,
|
||||||
|
},
|
||||||
conn: {
|
conn: {
|
||||||
autostart: false,
|
autostart: false,
|
||||||
},
|
},
|
||||||
|
|
|
@ -10,10 +10,10 @@ module.exports = {
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {any} sstack
|
* @param {any} local
|
||||||
* @param {any} config
|
* @param {any} config
|
||||||
*/
|
*/
|
||||||
init(sstack, config) {
|
init(local, config) {
|
||||||
return {
|
return {
|
||||||
/**
|
/**
|
||||||
* @param {string} origin
|
* @param {string} origin
|
||||||
|
|
|
@ -33,17 +33,17 @@ module.exports = {
|
||||||
allow: ['createTunnel', 'ping', 'metadata', 'attendants', 'createToken'],
|
allow: ['createTunnel', 'ping', 'metadata', 'attendants', 'createToken'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
init(sstack, config) {
|
init(local, config) {
|
||||||
if (!sstack.conn || !sstack.conn.connect) {
|
if (!local.conn || !local.conn.connect) {
|
||||||
throw new Error('tunnel plugin is missing the required ssb-conn plugin')
|
throw new Error('tunnel plugin is missing the required ssb-conn plugin')
|
||||||
}
|
}
|
||||||
debug('running multiserver at %s', sstack.getAddress('public'))
|
debug('running multiserver at %s', local.getAddress('public'))
|
||||||
|
|
||||||
Tokens.load(config.path)
|
Tokens.load(config.path)
|
||||||
Members.load(config.path)
|
Members.load(config.path)
|
||||||
|
|
||||||
// Ensure that client connections are only from members or to-be members
|
// Ensure that client connections are only from members or to-be members
|
||||||
sstack.auth.hook(function (fn, args) {
|
local.auth.hook(function (fn, args) {
|
||||||
const [clientMetadata, cb] = args
|
const [clientMetadata, cb] = args
|
||||||
const { pubkey, extra } = clientMetadata
|
const { pubkey, extra } = clientMetadata
|
||||||
if (Members.has(pubkey)) {
|
if (Members.has(pubkey)) {
|
||||||
|
@ -64,7 +64,7 @@ module.exports = {
|
||||||
const notifyAttendants = Notify()
|
const notifyAttendants = Notify()
|
||||||
|
|
||||||
pull(
|
pull(
|
||||||
sstack.conn.hub().listen(),
|
local.conn.hub().listen(),
|
||||||
pull.filter(
|
pull.filter(
|
||||||
({ type }) => type === 'connecting-failed' || type === 'disconnected'
|
({ type }) => type === 'connecting-failed' || type === 'disconnected'
|
||||||
),
|
),
|
||||||
|
@ -83,8 +83,8 @@ module.exports = {
|
||||||
return {
|
return {
|
||||||
attendants() {
|
attendants() {
|
||||||
const clientPubkey = bs58.encode(Buffer.from(this.id, 'base64'))
|
const clientPubkey = bs58.encode(Buffer.from(this.id, 'base64'))
|
||||||
const clientRPC = sstack.peers[this.id][0]
|
const clientRPC = local.peers[this.id][0]
|
||||||
if (clientPubkey && clientPubkey !== sstack.pubkey) {
|
if (clientPubkey && clientPubkey !== local.pubkey) {
|
||||||
debug('welcome %s', clientPubkey)
|
debug('welcome %s', clientPubkey)
|
||||||
if (!attendants.has(clientPubkey)) {
|
if (!attendants.has(clientPubkey)) {
|
||||||
attendants.set(clientPubkey, clientRPC)
|
attendants.set(clientPubkey, clientRPC)
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
"rehype-stringify": "9.0.3",
|
"rehype-stringify": "9.0.3",
|
||||||
"remark-parse": "10.0.2",
|
"remark-parse": "10.0.2",
|
||||||
"remark-rehype": "10.1.0",
|
"remark-rehype": "10.1.0",
|
||||||
"secret-handshake-ext": "0.0.6",
|
"secret-handshake-ext": "0.0.8",
|
||||||
"secret-stack": "6.4.1",
|
"secret-stack": "ssbc/secret-stack#bare-mode",
|
||||||
"ssb-caps": "1.1.0",
|
"ssb-caps": "1.1.0",
|
||||||
"ssb-conn": "6.0.4",
|
"ssb-conn": "6.0.4",
|
||||||
"unified": "10.1.2"
|
"unified": "10.1.2"
|
||||||
|
@ -2914,9 +2914,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/secret-handshake-ext": {
|
"node_modules/secret-handshake-ext": {
|
||||||
"version": "0.0.6",
|
"version": "0.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/secret-handshake-ext/-/secret-handshake-ext-0.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/secret-handshake-ext/-/secret-handshake-ext-0.0.8.tgz",
|
||||||
"integrity": "sha512-cAyQpQYdzvIVhBWzG4qKWBkJh+AZWBP/ny0B5DiMgWWTeISucwm99Kw0noW6SmsbrG+UJNcSpiMYzJFWotpfoQ==",
|
"integrity": "sha512-YshYQpP1z0ZxVvvu3bgnnwAI251w+Na75ph8pOOeFgc0nP54Q2cQo/WHlpKxzvc47OJPuGrgxewMXa9bwJ78eA==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"b4a": "~1.6.4",
|
"b4a": "~1.6.4",
|
||||||
"bs58": "~5.0.0",
|
"bs58": "~5.0.0",
|
||||||
|
@ -2931,11 +2931,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/secret-stack": {
|
"node_modules/secret-stack": {
|
||||||
"version": "6.4.1",
|
"version": "6.4.2",
|
||||||
"resolved": "https://registry.npmjs.org/secret-stack/-/secret-stack-6.4.1.tgz",
|
"resolved": "git+ssh://git@github.com/ssbc/secret-stack.git#e91f4d9cd0f63fff9b06dc538c844cd73ccaba5f",
|
||||||
"integrity": "sha512-7rRcTEj7t0H3ShMKQvv7QGYAUFjVRmDqNNgrvpdedVlVnEIyfkZu0RaFPpes6yUSiE9Iwi0lHi03+6HsltLCMA==",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"debug": "^4.1.0",
|
"debug": "^4.3.0",
|
||||||
"hoox": "0.0.1",
|
"hoox": "0.0.1",
|
||||||
"map-merge": "^1.1.0",
|
"map-merge": "^1.1.0",
|
||||||
"multiserver": "^3.1.0",
|
"multiserver": "^3.1.0",
|
||||||
|
@ -2946,7 +2946,7 @@
|
||||||
"to-camel-case": "^1.0.0"
|
"to-camel-case": "^1.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=5.10.0"
|
"node": ">=16"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/secret-stack-decorators": {
|
"node_modules/secret-stack-decorators": {
|
||||||
|
@ -5985,9 +5985,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"secret-handshake-ext": {
|
"secret-handshake-ext": {
|
||||||
"version": "0.0.6",
|
"version": "0.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/secret-handshake-ext/-/secret-handshake-ext-0.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/secret-handshake-ext/-/secret-handshake-ext-0.0.8.tgz",
|
||||||
"integrity": "sha512-cAyQpQYdzvIVhBWzG4qKWBkJh+AZWBP/ny0B5DiMgWWTeISucwm99Kw0noW6SmsbrG+UJNcSpiMYzJFWotpfoQ==",
|
"integrity": "sha512-YshYQpP1z0ZxVvvu3bgnnwAI251w+Na75ph8pOOeFgc0nP54Q2cQo/WHlpKxzvc47OJPuGrgxewMXa9bwJ78eA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"b4a": "~1.6.4",
|
"b4a": "~1.6.4",
|
||||||
"bs58": "~5.0.0",
|
"bs58": "~5.0.0",
|
||||||
|
@ -5999,11 +5999,10 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"secret-stack": {
|
"secret-stack": {
|
||||||
"version": "6.4.1",
|
"version": "git+ssh://git@github.com/ssbc/secret-stack.git#e91f4d9cd0f63fff9b06dc538c844cd73ccaba5f",
|
||||||
"resolved": "https://registry.npmjs.org/secret-stack/-/secret-stack-6.4.1.tgz",
|
"from": "secret-stack@ssbc/secret-stack#bare-mode",
|
||||||
"integrity": "sha512-7rRcTEj7t0H3ShMKQvv7QGYAUFjVRmDqNNgrvpdedVlVnEIyfkZu0RaFPpes6yUSiE9Iwi0lHi03+6HsltLCMA==",
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"debug": "^4.1.0",
|
"debug": "^4.3.0",
|
||||||
"hoox": "0.0.1",
|
"hoox": "0.0.1",
|
||||||
"map-merge": "^1.1.0",
|
"map-merge": "^1.1.0",
|
||||||
"multiserver": "^3.1.0",
|
"multiserver": "^3.1.0",
|
||||||
|
|
|
@ -37,8 +37,8 @@
|
||||||
"pull-cat": "1.1.11",
|
"pull-cat": "1.1.11",
|
||||||
"pull-notify": "0.1.2",
|
"pull-notify": "0.1.2",
|
||||||
"pull-stream": "3.7.0",
|
"pull-stream": "3.7.0",
|
||||||
"secret-stack": "6.4.1",
|
"secret-stack": "ssbc/secret-stack#bare-mode",
|
||||||
"secret-handshake-ext": "0.0.6",
|
"secret-handshake-ext": "0.0.8",
|
||||||
"ssb-caps": "1.1.0",
|
"ssb-caps": "1.1.0",
|
||||||
"ssb-conn": "6.0.4",
|
"ssb-conn": "6.0.4",
|
||||||
"unified": "10.1.2",
|
"unified": "10.1.2",
|
||||||
|
|
Loading…
Reference in New Issue