mirror of https://codeberg.org/pzp/pzp-hub.git
add secret-stack, shse, ppppp-keypair
This commit is contained in:
parent
aa09550c75
commit
c5085c64cf
|
@ -1,4 +1,5 @@
|
|||
node_modules
|
||||
pnpm-lock.yaml
|
||||
yarn.lock
|
||||
TODO
|
||||
TODO
|
||||
keypair
|
|
@ -1,9 +1,9 @@
|
|||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { unified } from 'unified'
|
||||
import remarkParse from 'remark-parse'
|
||||
import remarkRehype from 'remark-rehype'
|
||||
import rehypeStringify from 'rehype-stringify'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
const __dirname = path.dirname(new URL(import.meta.url).pathname)
|
||||
const homepagePath = path.join(__dirname, '..', 'HOMEPAGE.md')
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { createRequire } from 'module'
|
||||
import path from 'path'
|
||||
import { createRequire } from 'node:module'
|
||||
import path from 'node:path'
|
||||
import homepageHTML from './homepage.js'
|
||||
|
||||
const require = createRequire(import.meta.url)
|
||||
|
|
13
lib/peer.cjs
13
lib/peer.cjs
|
@ -1,11 +1,18 @@
|
|||
const SecretStack = require('secret-stack')
|
||||
const caps = require('ssb-caps')
|
||||
const Keypair = require('ppppp-keypair')
|
||||
const SSAPI = require('secret-stack/lib/api')
|
||||
|
||||
module.exports = function startPeer() {
|
||||
SecretStack({ appKey: caps.shs })
|
||||
const keypair = Keypair.loadOrCreateSync('./keypair')
|
||||
|
||||
SSAPI([], {})
|
||||
.use(require('secret-stack/lib/core'))
|
||||
.use(require('secret-stack/lib/plugins/net'))
|
||||
.use(require('secret-handshake-ext/secret-stack'))
|
||||
.use(require('ssb-conn'))
|
||||
.use(require('./plugin-hub.cjs'))
|
||||
.call(null, {
|
||||
caps: { shse: 'p2pLq5VZKvNWaaafMUEcxH9BKm2WjNBCxsc8TRQV5gS' },
|
||||
keypair,
|
||||
port: 8008,
|
||||
host: '0.0.0.0',
|
||||
conn: {
|
||||
|
|
|
@ -19,14 +19,14 @@ module.exports = {
|
|||
name: 'hub',
|
||||
version: '1.0.0',
|
||||
manifest: {
|
||||
connect: 'duplex',
|
||||
createTunnel: 'duplex',
|
||||
ping: 'sync',
|
||||
attendants: 'source',
|
||||
createToken: 'async',
|
||||
},
|
||||
permissions: {
|
||||
anonymous: {
|
||||
allow: ['connect', 'ping', 'attendants', 'createToken'],
|
||||
allow: ['createTunnel', 'ping', 'attendants', 'createToken'],
|
||||
},
|
||||
},
|
||||
init(me) {
|
||||
|
@ -82,20 +82,15 @@ module.exports = {
|
|||
return cat([initial, notifyAttendants.listen()])
|
||||
},
|
||||
|
||||
connect(opts) {
|
||||
if (!opts) return ErrorDuplex('opts MUST be provided')
|
||||
|
||||
const target = opts.target
|
||||
createTunnel(target) {
|
||||
if (attendants.has(target)) {
|
||||
debug(
|
||||
'received tunnel request for target %s from %s',
|
||||
target,
|
||||
this.id
|
||||
)
|
||||
opts.origin = this.id
|
||||
return attendants.get(target).tunnel.connect(opts, () => {})
|
||||
// prettier-ignore
|
||||
debug('received tunnel request for target %s from %s', target, this.id)
|
||||
const origin = this.id
|
||||
return attendants.get(target).hubClient.connect(origin, () => {})
|
||||
} else {
|
||||
return ErrorDuplex('Could not connect to: ' + target)
|
||||
// prettier-ignore
|
||||
return ErrorDuplex(`Cannot createTunnel with ${target} who appears to be offline`)
|
||||
}
|
||||
},
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -29,11 +29,13 @@
|
|||
"debug": "4.3.4",
|
||||
"ejs": "3.1.9",
|
||||
"fastify": "4.17.0",
|
||||
"ppppp-keypair": "github:staltz/ppppp-keypair",
|
||||
"pino": "8.14.1",
|
||||
"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.4",
|
||||
"ssb-caps": "1.1.0",
|
||||
"ssb-conn": "6.0.4",
|
||||
"unified": "10.1.2",
|
||||
|
@ -44,14 +46,12 @@
|
|||
"devDependencies": {
|
||||
"c8": "7",
|
||||
"prettier": "^2.6.2",
|
||||
"pretty-quick": "^3.1.3",
|
||||
"tap-arc": "^0.3.5",
|
||||
"tape": "^5.6.3"
|
||||
"pretty-quick": "^3.1.3"
|
||||
},
|
||||
"scripts": {
|
||||
"setup": "npm install --omit=dev",
|
||||
"start": "DEBUG=*,-avvio node lib/index.js",
|
||||
"test": "tape test/*.js | tap-arc --bail",
|
||||
"test": "node --test",
|
||||
"format-code": "prettier --write \"(lib|test)/**/*.(c)?js\"",
|
||||
"format-code-staged": "pretty-quick --staged --pattern \"(lib|test)/**/*.(c)?js\"",
|
||||
"coverage": "c8 --reporter=lcov npm run test"
|
||||
|
|
Loading…
Reference in New Issue