update follow promise to have account

This commit is contained in:
Andre Staltz 2024-01-14 13:19:02 +02:00
parent 96ffc426b3
commit 14de10b5d3
No known key found for this signature in database
GPG Key ID: 9EDE23EA7E8A4890
2 changed files with 11 additions and 7 deletions

View File

@ -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} */

View File

@ -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')
},
}