From 4febda05efb7125cb205b963b11f3f5e608dba09 Mon Sep 17 00:00:00 2001 From: Andre Staltz Date: Wed, 10 Jan 2024 18:56:48 +0200 Subject: [PATCH] update join command inspired by multiformats --- lib/index.js | 4 ++-- lib/plugin-hub.cjs | 7 +++---- lib/public/bootstrap.js | 5 +++-- lib/views/bootstrap.ejs | 5 ++--- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/index.js b/lib/index.js index c4a5a2c..23a6582 100644 --- a/lib/index.js +++ b/lib/index.js @@ -22,8 +22,8 @@ app.register(fastifyStatic, { root: staticsPath }) app.get('/', (req, reply) => { if (peer.hub.numMembers() === 0) { - const { port, pubkey, token } = peer.hub.getBootstrap() - reply.view('bootstrap.ejs', { port, pubkey, token }) + const { tcpPort, shseCredentials } = peer.hub.getBootstrap() + reply.view('bootstrap.ejs', { tcpPort, shseCredentials }) } else { reply.view('homepage.ejs', { markdown: homepageHTML }) } diff --git a/lib/plugin-hub.cjs b/lib/plugin-hub.cjs index 83212a0..0ad146f 100644 --- a/lib/plugin-hub.cjs +++ b/lib/plugin-hub.cjs @@ -125,10 +125,9 @@ module.exports = { }, getBootstrap() { - const port = config.global.connections.incoming.net[0].port - const pubkey = peer.shse.pubkey - const token = 'none' - return { port, pubkey, token } + const tcpPort = config.global.connections.incoming.net[0].port + const shseCredentials = peer.shse.pubkey + return { tcpPort, shseCredentials } }, } }, diff --git a/lib/public/bootstrap.js b/lib/public/bootstrap.js index 6e153f6..2f28862 100644 --- a/lib/public/bootstrap.js +++ b/lib/public/bootstrap.js @@ -7,8 +7,9 @@ window.addEventListener('focus', () => { }) const host = window.location.hostname -const { port, pubkey, token } = window.hubInvite -const uri = `ppppp://invite/join/${host}/${port}/${pubkey}/${token}` +const hostFormat = /[a-zA-Z]/.test(window.location.hostname) ? 'dns' : 'ip4'; +const { tcpPort, shseCredentials } = window.hubInvite +const uri = `ppppp://invite/join/${hostFormat}/${host}/tcp/${tcpPort}/shse/${shseCredentials}` const inviteLinkElem = document.getElementById('invite') inviteLinkElem.href = uri diff --git a/lib/views/bootstrap.ejs b/lib/views/bootstrap.ejs index 54ee7f2..469b0d9 100644 --- a/lib/views/bootstrap.ejs +++ b/lib/views/bootstrap.ejs @@ -16,9 +16,8 @@