Skip to content

Commit

Permalink
always pass EPEK to enclave wether it remembers auth method or not
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
2 people authored and ditoglez committed Dec 16, 2024
1 parent 33fba6c commit d321844
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions apps/idos-enclave/src/lib/enclave.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions apps/idos-enclave/src/pages/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function App({ store, enclave }: AppProps) {
// Confirm options.
const [origin, setOrigin] = useState<string | null>(null);
const [message, setMessage] = useState<string | null>(null);
const [encryptionPublicKey, setEncryptionUserPublicKey] = useState<string | undefined>();
const [encryptionPublicKey, setEncryptionUserPublicKey] = useState<string>("");
const [humanId] = useState<string | null>(
new URLSearchParams(window.location.search).get("humanId"),
);
Expand Down Expand Up @@ -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":
Expand Down

0 comments on commit d321844

Please sign in to comment.