From a442a26c2af3ab584b814a836976991b1ca65da9 Mon Sep 17 00:00:00 2001 From: Andre Staltz Date: Sun, 25 Jun 2023 20:50:02 +0300 Subject: [PATCH] tiny refactor around msgv3.createIdentity() --- lib/msg-v3/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/msg-v3/index.js b/lib/msg-v3/index.js index 06d9b6b..64c61c0 100644 --- a/lib/msg-v3/index.js +++ b/lib/msg-v3/index.js @@ -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 },