fix which domain is used in identity.add()

This commit is contained in:
Andre Staltz 2023-07-20 20:23:27 +03:00
parent 54f00d1944
commit 5f76000531
No known key found for this signature in database
GPG Key ID: 9EDE23EA7E8A4890
2 changed files with 8 additions and 1 deletions

View File

@ -518,6 +518,12 @@ function initDB(peer, config) {
return cb(new Error('identity.add() failed because the consent is invalid')) return cb(new Error('identity.add() failed because the consent is invalid'))
} }
const identityRoot = get(opts.identity)
if (!identityRoot) {
// prettier-ignore
return cb(new Error(`identity.add() failed because the identity root "${opts.identity}" is unknown`))
}
/** @type {IdentityData} */ /** @type {IdentityData} */
const data = { const data = {
action: 'add', action: 'add',
@ -538,7 +544,7 @@ function initDB(peer, config) {
tangles: populateTangles([opts.identity]), tangles: populateTangles([opts.identity]),
keypair: signingKeypair, keypair: signingKeypair,
data, data,
domain: 'identity', domain: identityRoot.metadata.domain,
} }
// Create the actual message: // Create the actual message:

View File

@ -55,6 +55,7 @@ test('identity.add()', async (t) => {
) )
assert.equal(msg.metadata.identity, 'self', 'msg.metadata.identity') assert.equal(msg.metadata.identity, 'self', 'msg.metadata.identity')
assert.equal(msg.metadata.identityTips, null, 'msg.metadata.identityTips') assert.equal(msg.metadata.identityTips, null, 'msg.metadata.identityTips')
assert.equal(msg.metadata.domain, 'person', 'msg.metadata.domain')
assert.deepEqual( assert.deepEqual(
msg.metadata.tangles, msg.metadata.tangles,
{ [id]: { depth: 1, prev: [id] } }, { [id]: { depth: 1, prev: [id] } },