gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated: anastasis-core: fix user id c


From: gnunet
Subject: [taler-wallet-core] branch master updated: anastasis-core: fix user id caching
Date: Thu, 04 Nov 2021 21:56:05 +0100

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository wallet-core.

The following commit(s) were added to refs/heads/master by this push:
     new 34d2e470 anastasis-core: fix user id caching
34d2e470 is described below

commit 34d2e4703d8a583c8e7c3c2ea398c1280acccd08
Author: Florian Dold <florian@dold.me>
AuthorDate: Thu Nov 4 21:56:02 2021 +0100

    anastasis-core: fix user id caching
---
 packages/anastasis-core/src/index.ts | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/packages/anastasis-core/src/index.ts 
b/packages/anastasis-core/src/index.ts
index f2b8ff1d..0f391b73 100644
--- a/packages/anastasis-core/src/index.ts
+++ b/packages/anastasis-core/src/index.ts
@@ -458,6 +458,19 @@ async function uploadSecret(
 
   const truthPayUris: string[] = [];
   const userIdCache: Record<string, UserIdentifier> = {};
+  const getUserIdCaching = async (providerUrl: string) => {
+    let userId = userIdCache[providerUrl];
+    if (!userId) {
+      const provider = state.authentication_providers![
+        providerUrl
+      ] as AuthenticationProviderStatusOk;
+      userId = userIdCache[providerUrl] = await userIdentifierDerive(
+        state.identity_attributes!,
+        provider.salt,
+      );
+    }
+    return userId;
+  };
   for (const truthKey of Object.keys(truthMetadataMap)) {
     const tm = truthMetadataMap[truthKey];
     const pol = state.policies![tm.policy_index];
@@ -471,16 +484,7 @@ async function uploadSecret(
       truthValue,
     );
     logger.info(`uploading to ${meth.provider}`);
-    let userId = userIdCache[meth.provider];
-    if (!userId) {
-      const provider = state.authentication_providers![
-        meth.provider
-      ] as AuthenticationProviderStatusOk;
-      userId = userIdCache[meth.provider] = await userIdentifierDerive(
-        state.identity_attributes!,
-        provider.salt,
-      );
-    }
+    const userId = await getUserIdCaching(meth.provider);
     // FIXME: check that the question salt is okay here, looks weird.
     const encryptedKeyShare = await encryptKeyshare(
       tm.key_share,
@@ -537,11 +541,11 @@ async function uploadSecret(
   const policyPayUris: string[] = [];
 
   for (const prov of state.policy_providers!) {
-    const uid = userIdCache[prov.provider_url];
-    const acctKeypair = accountKeypairDerive(uid);
+    const userId = await getUserIdCaching(prov.provider_url);
+    const acctKeypair = accountKeypairDerive(userId);
     const zippedDoc = await compressRecoveryDoc(rd);
     const encRecoveryDoc = await encryptRecoveryDocument(
-      uid,
+      userId,
       encodeCrock(zippedDoc),
     );
     const bodyHash = hash(decodeCrock(encRecoveryDoc));

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]