Skip to content

Commit

Permalink
perf: optimize passkey authentication for iOS 15
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquim-verges committed Oct 29, 2024
1 parent 6cb66c6 commit 678bca7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/smart-chicken-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Reduce async calls before requesting webauthn credentials for ios 15
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,17 @@ export async function loginWithPasskey(options: {
}
const fetchWithId = getClientFetch(options.client, options.ecosystem);
// 1. request challenge from server/iframe
const res = await fetchWithId(getChallengePath("sign-in"));
const challengeData = await res.json();
const [challengeData, credentialId] = await Promise.all([
fetchWithId(getChallengePath("sign-in")).then((r) => r.json()),
options.storage?.getPasskeyCredentialId(),
]);
if (!challengeData.challenge) {
throw new Error("No challenge received");
}
const challenge = challengeData.challenge;
// 1.2. find the user's credentialId in local storage
const credentialId =
(await options.storage?.getPasskeyCredentialId()) ?? undefined;

// 2. initiate login
const authentication = await options.passkeyClient.authenticate({
credentialId,
credentialId: credentialId ?? undefined,
challenge,
rp: options.rp,
});
Expand Down

0 comments on commit 678bca7

Please sign in to comment.