mirror of https://codeberg.org/pzp/pzp-promise.git
use db.identity.has
This commit is contained in:
parent
d70d119e7c
commit
9e98e36752
17
lib/index.js
17
lib/index.js
|
@ -180,20 +180,21 @@ module.exports = {
|
|||
cb(new Error('Invalid token'))
|
||||
return
|
||||
}
|
||||
const promise = /** @type {PPromise} */ (promises.get(token))
|
||||
if (promise.type !== 'identity-add') {
|
||||
const promise = /** @type {IdentityAddPromise} */ (promises.get(token))
|
||||
const { type, identity } = promise
|
||||
if (type !== 'identity-add') {
|
||||
cb(new Error('Invalid token'))
|
||||
return
|
||||
}
|
||||
|
||||
// TODO identity.has, and if true, then call cb with false
|
||||
const keypair = { curve: 'ed25519', public: addition.key.bytes }
|
||||
if (local.db.identity.has({ identity, keypair })) {
|
||||
cb(null, false)
|
||||
return
|
||||
}
|
||||
|
||||
local.db.identity.add(
|
||||
{
|
||||
identity: promise.identity,
|
||||
keypair: { curve: 'ed25519', public: addition.key.bytes },
|
||||
consent: addition.consent,
|
||||
},
|
||||
{ identity, keypair, consent: addition.consent },
|
||||
/**
|
||||
* @param {Error | null} err
|
||||
* @param {any} rec
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
"c8": "^7.11.0",
|
||||
"husky": "^4.3.0",
|
||||
"ppppp-caps": "github:staltz/ppppp-caps",
|
||||
"ppppp-db": "github:staltz/ppppp-db",
|
||||
"ppppp-db": "file:../db",
|
||||
"ppppp-keypair": "github:staltz/ppppp-keypair",
|
||||
"prettier": "^2.6.2",
|
||||
"pretty-quick": "^3.1.3",
|
||||
|
|
Loading…
Reference in New Issue