Skip to content

Commit 678bca7

Browse files
perf: optimize passkey authentication for iOS 15
1 parent 6cb66c6 commit 678bca7

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

.changeset/smart-chicken-beam.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Reduce async calls before requesting webauthn credentials for ios 15

packages/thirdweb/src/wallets/in-app/core/authentication/passkeys.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,19 +137,17 @@ export async function loginWithPasskey(options: {
137137
}
138138
const fetchWithId = getClientFetch(options.client, options.ecosystem);
139139
// 1. request challenge from server/iframe
140-
const res = await fetchWithId(getChallengePath("sign-in"));
141-
const challengeData = await res.json();
140+
const [challengeData, credentialId] = await Promise.all([
141+
fetchWithId(getChallengePath("sign-in")).then((r) => r.json()),
142+
options.storage?.getPasskeyCredentialId(),
143+
]);
142144
if (!challengeData.challenge) {
143145
throw new Error("No challenge received");
144146
}
145147
const challenge = challengeData.challenge;
146-
// 1.2. find the user's credentialId in local storage
147-
const credentialId =
148-
(await options.storage?.getPasskeyCredentialId()) ?? undefined;
149-
150148
// 2. initiate login
151149
const authentication = await options.passkeyClient.authenticate({
152-
credentialId,
150+
credentialId: credentialId ?? undefined,
153151
challenge,
154152
rp: options.rp,
155153
});

0 commit comments

Comments
 (0)