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
|
// prettier-ignore
|
||||||
throw new Error(`Invalid URI "${uri}" for invite.parse, missing some "join" arguments`)
|
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') {
|
if (hostFormat !== 'ip4' && hostFormat !== 'ip6' && hostFormat !== 'dns') {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
throw new Error(`Invalid URI "${uri}" for invite.parse, unsupported "join" host format "${hostFormat}"`)
|
throw new Error(`Invalid URI "${uri}" for invite.parse, unsupported "join" host format "${hostFormat}"`)
|
||||||
|
@ -107,7 +107,7 @@ function parseJoinCommand(pieces, uri) {
|
||||||
* @returns {FollowCommand}
|
* @returns {FollowCommand}
|
||||||
*/
|
*/
|
||||||
function parseFollowCommand(pieces, uri) {
|
function parseFollowCommand(pieces, uri) {
|
||||||
const [, id] = pieces
|
const [label, id] = pieces
|
||||||
if (!id) {
|
if (!id) {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
throw new Error(`Invalid URI "${uri}" for invite.parse, missing follow id`)
|
throw new Error(`Invalid URI "${uri}" for invite.parse, missing follow id`)
|
||||||
|
@ -123,7 +123,7 @@ function parseFollowCommand(pieces, uri) {
|
||||||
* @returns {TunnelConnectCommand}
|
* @returns {TunnelConnectCommand}
|
||||||
*/
|
*/
|
||||||
function parseTunnelConnectCommand(pieces, uri) {
|
function parseTunnelConnectCommand(pieces, uri) {
|
||||||
const [, hubPubkey, targetPubkey] = pieces
|
const [label, hubPubkey, targetPubkey] = pieces
|
||||||
// TODO: base58 validation for the hubPubkey (and maybe length)
|
// TODO: base58 validation for the hubPubkey (and maybe length)
|
||||||
if (!hubPubkey) {
|
if (!hubPubkey) {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
|
@ -147,7 +147,7 @@ function parseTunnelConnectCommand(pieces, uri) {
|
||||||
* @returns {PromiseFollowCommand}
|
* @returns {PromiseFollowCommand}
|
||||||
*/
|
*/
|
||||||
function parsePromiseFollowCommand(pieces, uri) {
|
function parsePromiseFollowCommand(pieces, uri) {
|
||||||
const [, issuerAndType, token] = pieces
|
const [label, issuerAndType, token] = pieces
|
||||||
if (!issuerAndType) {
|
if (!issuerAndType) {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
throw new Error(`Invalid URI "${uri}" for invite.parse, missing promise.follow issuer`)
|
throw new Error(`Invalid URI "${uri}" for invite.parse, missing promise.follow issuer`)
|
||||||
|
@ -173,7 +173,7 @@ function parsePromiseFollowCommand(pieces, uri) {
|
||||||
* @returns {PromiseAccountAddCommand}
|
* @returns {PromiseAccountAddCommand}
|
||||||
*/
|
*/
|
||||||
function parsePromiseAccountAddCommand(pieces, uri) {
|
function parsePromiseAccountAddCommand(pieces, uri) {
|
||||||
const [, issuerAndType, token] = pieces
|
const [label, issuerAndType, token] = pieces
|
||||||
if (!issuerAndType) {
|
if (!issuerAndType) {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
throw new Error(`Invalid URI "${uri}" for invite.parse, missing promise.account-add issuer`)
|
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) {
|
if (!opts._hubMsAddr) {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
|
// FIXME: load hubs from ppppp-net
|
||||||
return cb(new Error(`invite.createForFriend expected opts._hubMsAddr because loading from connDB not yet supported`))
|
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
|
const [pubkey] = shse.data
|
||||||
|
|
||||||
// Create follow promise
|
// 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)
|
if (err3) return cb(err3)
|
||||||
|
|
||||||
/** @type {JoinCommandStr} */
|
/** @type {JoinCommandStr} */
|
||||||
|
|
|
@ -49,7 +49,7 @@ test('createForFriend()', async (t) => {
|
||||||
return {
|
return {
|
||||||
create(opts, cb) {
|
create(opts, cb) {
|
||||||
createPromiseCalled = true
|
createPromiseCalled = true
|
||||||
assert.deepEqual(opts, { type: 'follow' })
|
assert.deepEqual(opts, { type: 'follow', account: 'MOCK_ID' })
|
||||||
cb(null, 'MOCK_PROMISE')
|
cb(null, 'MOCK_PROMISE')
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue