diff --git a/lib/index.js b/lib/index.js index b01cb5e..6b2a846 100644 --- a/lib/index.js +++ b/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} */ diff --git a/test/createForFriend.test.js b/test/createForFriend.test.js index 32a2e2e..c5bb24d 100644 --- a/test/createForFriend.test.js +++ b/test/createForFriend.test.js @@ -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') }, }