Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: optimize passkey authentication for iOS 15 #5214

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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