Skip to content

Commit

Permalink
Fix breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rinarakaki committed Jan 1, 2025
1 parent b8a079b commit 4b5bdd5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
18 changes: 9 additions & 9 deletions packages/core/src/lib/utils/webauthn-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type WebAuthnOptionsResponse = ResponseInternal & {
export type CredentialDeviceType = "singleDevice" | "multiDevice"
interface InternalAuthenticator {
providerAccountId: string
credentialID: Uint8Array
credentialID: string
credentialPublicKey: Uint8Array
counter: number
credentialDeviceType: CredentialDeviceType
Expand All @@ -72,8 +72,8 @@ type RGetUserInfo = Awaited<ReturnType<GetUserInfo>>
* Infers the WebAuthn options based on the provided parameters.
*
* @param action - The WebAuthn action to perform (optional).
* @param loggedInUser - The logged-in user (optional).
* @param userInfoResponse - The response containing user information (optional).
* @param loggedIn - Whether the user is logged in or not.
* @param userInfoResponse - The response containing user information.
*
* @returns The WebAuthn action to perform, or null if no inference could be made.
*/
Expand Down Expand Up @@ -371,7 +371,7 @@ export async function verifyRegister(

// Build a new account
const account = {
providerAccountId: toBase64(verification.registrationInfo.credentialID),
providerAccountId: verification.registrationInfo.credentialID,
provider: options.provider.id,
type: provider.type,
}
Expand All @@ -380,7 +380,7 @@ export async function verifyRegister(
const authenticator = {
providerAccountId: account.providerAccountId,
counter: verification.registrationInfo.counter,
credentialID: toBase64(verification.registrationInfo.credentialID),
credentialID: verification.registrationInfo.credentialID,
credentialPublicKey: toBase64(
verification.registrationInfo.credentialPublicKey
),
Expand Down Expand Up @@ -428,7 +428,7 @@ async function getAuthenticationOptions(
...provider.authenticationOptions,
rpID: relayingParty.id,
allowCredentials: authenticators?.map((a) => ({
id: fromBase64(a.credentialID),
id: a.credentialID,
type: "public-key",
transports: stringToTransports(a.transports),
})),
Expand Down Expand Up @@ -466,13 +466,13 @@ async function getRegistrationOptions(
// Return the registration options.
return await provider.simpleWebAuthn.generateRegistrationOptions({
...provider.registrationOptions,
userID,
userID: new Uint8Array(Buffer.from(userID)),
userName: user.email,
userDisplayName: user.name ?? undefined,
rpID: relayingParty.id,
rpName: relayingParty.name,
excludeCredentials: authenticators?.map((a) => ({
id: fromBase64(a.credentialID),
id: a.credentialID,
type: "public-key",
transports: stringToTransports(a.transports),
})),
Expand Down Expand Up @@ -503,7 +503,7 @@ function fromAdapterAuthenticator(
credentialDeviceType:
authenticator.credentialDeviceType as InternalAuthenticator["credentialDeviceType"],
transports: stringToTransports(authenticator.transports),
credentialID: fromBase64(authenticator.credentialID),
credentialID: authenticator.credentialID,
credentialPublicKey: fromBase64(authenticator.credentialPublicKey),
}
}
Expand Down
10 changes: 5 additions & 5 deletions packages/core/test/webauthn-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function prepareVerifyTest(
verified: true,
registrationInfo: {
counter: authenticator.counter,
credentialID: fromBase64(authenticator.credentialID),
credentialID: authenticator.credentialID,
credentialPublicKey: fromBase64(authenticator.credentialPublicKey),
credentialBackedUp: authenticator.credentialBackedUp,
// @ts-expect-error
Expand Down Expand Up @@ -547,7 +547,7 @@ describe("getRegistrationResponse", () => {
userName: user.email,
userDisplayName: user.name,
excludeCredentials: authenticators.map((a) => ({
id: fromBase64(a.credentialID),
id: a.credentialID,
type: "public-key",
transports: stringToTransports(a.transports),
})),
Expand Down Expand Up @@ -617,7 +617,7 @@ describe("getRegistrationResponse", () => {
userName: user.email,
userDisplayName: user.name,
excludeCredentials: authenticators.map((a) => ({
id: fromBase64(a.credentialID),
id: a.credentialID,
type: "public-key",
transports: stringToTransports(a.transports),
})),
Expand Down Expand Up @@ -739,7 +739,7 @@ describe("getAuthenticationResponse", () => {
...defaultWebAuthnConfig.authenticationOptions,
rpID: rp.id,
allowCredentials: authenticators.map((a) => ({
id: fromBase64(a.credentialID),
id: a.credentialID,
type: "public-key",
transports: stringToTransports(a.transports),
})),
Expand Down Expand Up @@ -801,7 +801,7 @@ describe("getAuthenticationResponse", () => {
...defaultWebAuthnConfig.authenticationOptions,
rpID: rp.id,
allowCredentials: authenticators.map((a) => ({
id: fromBase64(a.credentialID),
id: a.credentialID,
type: "public-key",
transports: stringToTransports(a.transports),
})),
Expand Down

0 comments on commit 4b5bdd5

Please sign in to comment.