mirror of https://codeberg.org/pzp/pzp-invite.git
change how tunnel-connect commands parse
This commit is contained in:
parent
7283a1e5b7
commit
2c753a76a8
|
@ -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 }
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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',
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue