mirror of https://codeberg.org/pzp/pzp-invite.git
update follow promise to have account
This commit is contained in:
parent
96ffc426b3
commit
14de10b5d3
16
lib/index.js
16
lib/index.js
|
@ -58,7 +58,7 @@ function parseJoinCommand(pieces, uri) {
|
|||
// prettier-ignore
|
||||
throw new Error(`Invalid URI "${uri}" for invite.parse, missing some "join" arguments`)
|
||||
}
|
||||
const [, hostFormat, host, transport, port, transform, cred] = pieces // pubkey, token] = pieces
|
||||
const [label, hostFormat, host, transport, port, transform, cred] = pieces
|
||||
if (hostFormat !== 'ip4' && hostFormat !== 'ip6' && hostFormat !== 'dns') {
|
||||
// prettier-ignore
|
||||
throw new Error(`Invalid URI "${uri}" for invite.parse, unsupported "join" host format "${hostFormat}"`)
|
||||
|
@ -107,7 +107,7 @@ function parseJoinCommand(pieces, uri) {
|
|||
* @returns {FollowCommand}
|
||||
*/
|
||||
function parseFollowCommand(pieces, uri) {
|
||||
const [, id] = pieces
|
||||
const [label, id] = pieces
|
||||
if (!id) {
|
||||
// prettier-ignore
|
||||
throw new Error(`Invalid URI "${uri}" for invite.parse, missing follow id`)
|
||||
|
@ -123,7 +123,7 @@ function parseFollowCommand(pieces, uri) {
|
|||
* @returns {TunnelConnectCommand}
|
||||
*/
|
||||
function parseTunnelConnectCommand(pieces, uri) {
|
||||
const [, hubPubkey, targetPubkey] = pieces
|
||||
const [label, hubPubkey, targetPubkey] = pieces
|
||||
// TODO: base58 validation for the hubPubkey (and maybe length)
|
||||
if (!hubPubkey) {
|
||||
// prettier-ignore
|
||||
|
@ -147,7 +147,7 @@ function parseTunnelConnectCommand(pieces, uri) {
|
|||
* @returns {PromiseFollowCommand}
|
||||
*/
|
||||
function parsePromiseFollowCommand(pieces, uri) {
|
||||
const [, issuerAndType, token] = pieces
|
||||
const [label, issuerAndType, token] = pieces
|
||||
if (!issuerAndType) {
|
||||
// prettier-ignore
|
||||
throw new Error(`Invalid URI "${uri}" for invite.parse, missing promise.follow issuer`)
|
||||
|
@ -173,7 +173,7 @@ function parsePromiseFollowCommand(pieces, uri) {
|
|||
* @returns {PromiseAccountAddCommand}
|
||||
*/
|
||||
function parsePromiseAccountAddCommand(pieces, uri) {
|
||||
const [, issuerAndType, token] = pieces
|
||||
const [label, issuerAndType, token] = pieces
|
||||
if (!issuerAndType) {
|
||||
// prettier-ignore
|
||||
throw new Error(`Invalid URI "${uri}" for invite.parse, missing promise.account-add issuer`)
|
||||
|
@ -273,6 +273,7 @@ function initInvite(peer, config) {
|
|||
|
||||
if (!opts._hubMsAddr) {
|
||||
// prettier-ignore
|
||||
// FIXME: load hubs from ppppp-net
|
||||
return cb(new Error(`invite.createForFriend expected opts._hubMsAddr because loading from connDB not yet supported`))
|
||||
}
|
||||
|
||||
|
@ -302,7 +303,10 @@ function initInvite(peer, config) {
|
|||
const [pubkey] = shse.data
|
||||
|
||||
// Create follow promise
|
||||
const [err3, token] = await p(peer.promise.create)({ type: 'follow' })
|
||||
const [err3, token] = await p(peer.promise.create)({
|
||||
account: opts.id,
|
||||
type: 'follow',
|
||||
})
|
||||
if (err3) return cb(err3)
|
||||
|
||||
/** @type {JoinCommandStr} */
|
||||
|
|
|
@ -49,7 +49,7 @@ test('createForFriend()', async (t) => {
|
|||
return {
|
||||
create(opts, cb) {
|
||||
createPromiseCalled = true
|
||||
assert.deepEqual(opts, { type: 'follow' })
|
||||
assert.deepEqual(opts, { type: 'follow', account: 'MOCK_ID' })
|
||||
cb(null, 'MOCK_PROMISE')
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue