diff --git a/lib/index.js b/lib/index.js index 5a169d4..0b81b43 100644 --- a/lib/index.js +++ b/lib/index.js @@ -24,8 +24,7 @@ const p = require('promisify-tuple') * * @typedef {{ * type: 'tunnel-connect', - * hubPubkey: string, - * targetPubkey: string, + * address: string, * }} TunnelConnectCommand * * @typedef {`tunnel-connect/${string}/${string}`} TunnelConnectCommandStr @@ -126,7 +125,8 @@ function parseTunnelConnectCommand(pieces, uri) { pieces.shift() pieces.shift() pieces.shift() - return { type: 'tunnel-connect', hubPubkey, targetPubkey } + const address = `tunnel:${hubPubkey}:${targetPubkey}~shse:${targetPubkey}` + return { type: 'tunnel-connect', address } } /** diff --git a/test/parse.test.js b/test/parse.test.js index f1587f7..c3656cc 100644 --- a/test/parse.test.js +++ b/test/parse.test.js @@ -14,7 +14,7 @@ test('parse() error cases', (t) => { }) }) -test('parse() good cases', (t) => { +test('parse() good friend invite', (t) => { const commands = plugin.parse( 'ppppp://invite/join/HOST/PORT/PUBKEY/TOKEN/follow/ALICE/promise.follow/identity.ALICE/ALICE_TOKEN' ) @@ -34,3 +34,25 @@ test('parse() good cases', (t) => { }, ]) }) + +test('parse() good myself invite', (t) => { + const commands = plugin.parse( + 'ppppp://invite/join/HOST/PORT/PUBKEY/TOKEN/tunnel-connect/HUB_PUBKEY/OLD_PUBKEY/promise.identity-add/identity.IDENTITY_ID/OLD_TOKEN' + ) + assert.deepEqual(commands, [ + { + type: 'join', + address: 'net:HOST:PORT~shse:PUBKEY:TOKEN', + }, + { + type: 'tunnel-connect', + address: 'tunnel:HUB_PUBKEY:OLD_PUBKEY~shse:OLD_PUBKEY', + }, + { + type: 'promise.identity-add', + issuerID: 'IDENTITY_ID', + token: 'OLD_TOKEN', + }, + ]) +}) +