From d3218446bad85e9ef47b1ad7249fa4098c4d4027 Mon Sep 17 00:00:00 2001 From: Mohammed-Mamoun98 Date: Thu, 12 Dec 2024 12:09:54 +0200 Subject: [PATCH] always pass EPEK to enclave wether it remembers auth method or not PR comment resolved fix encryptionPublicKey useState type & handle no currentUserPublicKey available Update apps/idos-enclave/src/pages/App.tsx Co-authored-by: web the third --- apps/idos-enclave/src/lib/enclave.js | 11 ++++++----- apps/idos-enclave/src/pages/App.tsx | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/apps/idos-enclave/src/lib/enclave.js b/apps/idos-enclave/src/lib/enclave.js index 200ac7ec3..379d4f74a 100644 --- a/apps/idos-enclave/src/lib/enclave.js +++ b/apps/idos-enclave/src/lib/enclave.js @@ -125,12 +125,13 @@ export class Enclave { try { if (storedCredentialId) { ({ password, credentialId } = await getWebAuthnCredential(storedCredentialId)); - } else if (preferredAuthMethod) { - ({ password, duration } = await this.#openDialog(preferredAuthMethod)); } else { - ({ password, duration, credentialId } = await this.#openDialog("auth", { - expectedUserEncryptionPublicKey: this.expectedUserEncryptionPublicKey, - })); + ({ password, duration, credentialId } = await this.#openDialog( + preferredAuthMethod || "auth", + { + expectedUserEncryptionPublicKey: this.expectedUserEncryptionPublicKey, + }, + )); } } catch (e) { return reject(e); diff --git a/apps/idos-enclave/src/pages/App.tsx b/apps/idos-enclave/src/pages/App.tsx index 4953c0f82..75f109eea 100644 --- a/apps/idos-enclave/src/pages/App.tsx +++ b/apps/idos-enclave/src/pages/App.tsx @@ -63,7 +63,7 @@ export function App({ store, enclave }: AppProps) { // Confirm options. const [origin, setOrigin] = useState(null); const [message, setMessage] = useState(null); - const [encryptionPublicKey, setEncryptionUserPublicKey] = useState(); + const [encryptionPublicKey, setEncryptionUserPublicKey] = useState(""); const [humanId] = useState( new URLSearchParams(window.location.search).get("humanId"), ); @@ -102,11 +102,11 @@ export function App({ store, enclave }: AppProps) { throw new Error(`Unexpected request from parent: ${requestData.intent}`); responsePort.current = ports[0]; + setEncryptionUserPublicKey(requestData.message?.expectedUserEncryptionPublicKey); switch (requestData.intent) { case "auth": setMethod(null); - setEncryptionUserPublicKey(event.data.message.expectedUserEncryptionPublicKey); break; case "passkey":