Skip to content
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
2 changes: 1 addition & 1 deletion packages/thirdweb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
"@google/model-viewer": "2.1.1",
"@noble/curves": "1.6.0",
"@noble/hashes": "1.5.0",
"@passwordless-id/webauthn": "^1.6.1",
"@passwordless-id/webauthn": "^2.1.2",
"@radix-ui/react-dialog": "1.1.2",
"@radix-ui/react-focus-scope": "1.1.0",
"@radix-ui/react-icons": "1.3.2",
Expand Down
47 changes: 24 additions & 23 deletions packages/thirdweb/src/wallets/in-app/web/lib/auth/passkeys.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { client } from "@passwordless-id/webauthn";
import { client, parsers } from "@passwordless-id/webauthn";
import type { ThirdwebClient } from "../../../../../client/client.js";
import { webLocalStorage } from "../../../../../utils/storage/webStorage.js";
import {
Expand All @@ -25,22 +25,26 @@
rp: RpInfo;
}): Promise<RegisterResult> {
const { name, challenge, rp } = args;
const registration = await client.register(name, challenge, {
authenticatorType: "auto",
const registration = await client.register({
user: name,
challenge,

Check warning on line 30 in packages/thirdweb/src/wallets/in-app/web/lib/auth/passkeys.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/wallets/in-app/web/lib/auth/passkeys.ts#L28-L30

Added lines #L28 - L30 were not covered by tests
userVerification: "required",
domain: rp.id,
attestation: true,
debug: false,
});
const clientDataB64 = base64UrlToBase64(registration.clientData);
const clientDataB64 = base64UrlToBase64(
registration.response.clientDataJSON,
);

Check warning on line 37 in packages/thirdweb/src/wallets/in-app/web/lib/auth/passkeys.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/wallets/in-app/web/lib/auth/passkeys.ts#L35-L37

Added lines #L35 - L37 were not covered by tests
const clientDataParsed = JSON.parse(base64ToString(clientDataB64));
return {
authenticatorData: registration.authenticatorData,
credentialId: registration.credential.id,
clientData: registration.clientData,
authenticatorData: registration.response.authenticatorData,
credentialId: registration.id,
clientData: registration.response.clientDataJSON,

Check warning on line 42 in packages/thirdweb/src/wallets/in-app/web/lib/auth/passkeys.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/wallets/in-app/web/lib/auth/passkeys.ts#L40-L42

Added lines #L40 - L42 were not covered by tests
credential: {
publicKey: registration.credential.publicKey,
algorithm: registration.credential.algorithm,
publicKey: registration.response.publicKey,
algorithm: parsers.getAlgoName(
registration.response.publicKeyAlgorithm,
),

Check warning on line 47 in packages/thirdweb/src/wallets/in-app/web/lib/auth/passkeys.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/wallets/in-app/web/lib/auth/passkeys.ts#L44-L47

Added lines #L44 - L47 were not covered by tests
},
origin: clientDataParsed.origin,
};
Expand All @@ -52,22 +56,19 @@
rp: RpInfo;
}): Promise<AuthenticateResult> {
const { credentialId, challenge, rp } = args;
const result = await client.authenticate(
credentialId ? [credentialId] : [],
const result = await client.authenticate({
allowCredentials: credentialId ? [credentialId] : [],

Check warning on line 60 in packages/thirdweb/src/wallets/in-app/web/lib/auth/passkeys.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/wallets/in-app/web/lib/auth/passkeys.ts#L59-L60

Added lines #L59 - L60 were not covered by tests
challenge,
{
authenticatorType: "auto",
userVerification: "required",
domain: rp.id,
},
);
const clientDataB64 = base64UrlToBase64(result.clientData);
userVerification: "required",
domain: rp.id,
});
const clientDataB64 = base64UrlToBase64(result.response.clientDataJSON);

Check warning on line 65 in packages/thirdweb/src/wallets/in-app/web/lib/auth/passkeys.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/wallets/in-app/web/lib/auth/passkeys.ts#L62-L65

Added lines #L62 - L65 were not covered by tests
const clientDataParsed = JSON.parse(base64ToString(clientDataB64));
return {
authenticatorData: result.authenticatorData,
credentialId: result.credentialId,
clientData: result.clientData,
signature: result.signature,
authenticatorData: result.response.authenticatorData,
credentialId: result.id,
clientData: result.response.clientDataJSON,
signature: result.response.signature,

Check warning on line 71 in packages/thirdweb/src/wallets/in-app/web/lib/auth/passkeys.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/wallets/in-app/web/lib/auth/passkeys.ts#L68-L71

Added lines #L68 - L71 were not covered by tests
origin: clientDataParsed.origin,
};
}
Expand Down
36 changes: 18 additions & 18 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading