mirror of https://codeberg.org/pzp/pzp-db.git
tiny refactor around msgv3.createIdentity()
This commit is contained in:
parent
df98d499f1
commit
a442a26c2a
|
@ -178,17 +178,17 @@ function createRoot(id, domain, keypair) {
|
|||
return msg
|
||||
}
|
||||
|
||||
function getRandomNonce() {
|
||||
return base58.encode(crypto.randomBytes(32))
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Keypair} keypair
|
||||
* @param {string} domain
|
||||
* @param {string | (() => string)} nonce
|
||||
* @returns {Msg}
|
||||
*/
|
||||
function createIdentity(
|
||||
keypair,
|
||||
domain,
|
||||
nonce = () => base58.encode(crypto.randomBytes(32))
|
||||
) {
|
||||
function createIdentity(keypair, domain, nonce = getRandomNonce) {
|
||||
const actualNonce = typeof nonce === 'function' ? nonce() : nonce
|
||||
return create({
|
||||
data: { add: keypair.public, nonce: actualNonce },
|
||||
|
|
Loading…
Reference in New Issue