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