Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

- Include the `shouldTryLinkingToSessionUser` flag in the `Webauthn` recipe methods
- Update supported FDI versions and package version

## [0.15.0] - 2025-03-20
Expand Down
9 changes: 8 additions & 1 deletion lib/ts/recipe/webauthn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export default class RecipeWrapper {
static signUp(input: {
webauthnGeneratedOptionsId: string;
credential: RegistrationResponseJSON;
shouldTryLinkingWithSessionUser?: boolean;
options?: RecipeFunctionOptions;
userContext: any;
}): Promise<
Expand Down Expand Up @@ -197,6 +198,7 @@ export default class RecipeWrapper {
static signIn(input: {
webauthnGeneratedOptionsId: string;
credential: AuthenticationResponseJSON;
shouldTryLinkingWithSessionUser?: boolean;
options?: RecipeFunctionOptions;
userContext: any;
}): Promise<
Expand Down Expand Up @@ -376,6 +378,7 @@ export default class RecipeWrapper {
*/
static registerCredentialWithSignUp(input: {
email: string;
shouldTryLinkingWithSessionUser?: boolean;
options?: RecipeFunctionOptions;
userContext: any;
}): Promise<
Expand Down Expand Up @@ -427,7 +430,11 @@ export default class RecipeWrapper {
*
* @returns `{ status: "OK", ...}` if successful along a description of the user details (id, etc.) and email
*/
static authenticateCredentialWithSignIn(input: { options?: RecipeFunctionOptions; userContext: any }): Promise<
static authenticateCredentialWithSignIn(input: {
options?: RecipeFunctionOptions;
userContext: any;
shouldTryLinkingWithSessionUser?: boolean;
}): Promise<
| {
status: "OK";
user: User;
Expand Down
29 changes: 25 additions & 4 deletions lib/ts/recipe/webauthn/recipeImplementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,13 @@ export default function getRecipeImplementation(
fetchResponse,
};
},
signUp: async function ({ webauthnGeneratedOptionsId, credential, options, userContext }) {
signUp: async function ({
webauthnGeneratedOptionsId,
credential,
shouldTryLinkingWithSessionUser,
options,
userContext,
}) {
const { jsonBody, fetchResponse } = await querier.post<
| {
status: "OK";
Expand All @@ -185,6 +191,7 @@ export default function getRecipeImplementation(
body: JSON.stringify({
webauthnGeneratedOptionsId,
credential,
shouldTryLinkingWithSessionUser,
}),
},
Querier.preparePreAPIHook({
Expand All @@ -205,7 +212,13 @@ export default function getRecipeImplementation(
fetchResponse,
};
},
signIn: async function ({ webauthnGeneratedOptionsId, credential, options, userContext }) {
signIn: async function ({
webauthnGeneratedOptionsId,
credential,
shouldTryLinkingWithSessionUser,
options,
userContext,
}) {
const { jsonBody, fetchResponse } = await querier.post<
| {
status: "OK";
Expand All @@ -226,6 +239,7 @@ export default function getRecipeImplementation(
body: JSON.stringify({
webauthnGeneratedOptionsId,
credential,
shouldTryLinkingWithSessionUser,
}),
},
Querier.preparePreAPIHook({
Expand Down Expand Up @@ -383,7 +397,12 @@ export default function getRecipeImplementation(
registrationResponse,
};
},
registerCredentialWithSignUp: async function ({ email, options, userContext }) {
registerCredentialWithSignUp: async function ({
email,
shouldTryLinkingWithSessionUser,
options,
userContext,
}) {
// Get the registration options by using the passed email ID.
const registrationOptions = await this.getRegisterOptions({ options, userContext, email });
if (registrationOptions?.status !== "OK") {
Expand All @@ -410,6 +429,7 @@ export default function getRecipeImplementation(
return await this.signUp({
webauthnGeneratedOptionsId: registrationOptions.webauthnGeneratedOptionsId,
credential: registerCredentialResponse.registrationResponse,
shouldTryLinkingWithSessionUser,
options,
userContext,
});
Expand Down Expand Up @@ -437,7 +457,7 @@ export default function getRecipeImplementation(
authenticationResponse: authenticationResponse,
};
},
authenticateCredentialWithSignIn: async function ({ options, userContext }) {
authenticateCredentialWithSignIn: async function ({ shouldTryLinkingWithSessionUser, options, userContext }) {
// Make a call to get the sign in options using the entered email ID.
const signInOptions = await this.getSignInOptions({ options, userContext });
if (signInOptions?.status !== "OK") {
Expand All @@ -459,6 +479,7 @@ export default function getRecipeImplementation(
return await this.signIn({
webauthnGeneratedOptionsId: signInOptions.webauthnGeneratedOptionsId,
credential: authenticateCredentialResponse.authenticationResponse,
shouldTryLinkingWithSessionUser,
options: options,
userContext: userContext,
});
Expand Down
9 changes: 8 additions & 1 deletion lib/ts/recipe/webauthn/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export type RecipeInterface = {
signUp: (input: {
webauthnGeneratedOptionsId: string;
credential: RegistrationResponseJSON;
shouldTryLinkingWithSessionUser?: boolean;
options?: RecipeFunctionOptions;
userContext: any;
}) => Promise<
Expand All @@ -175,6 +176,7 @@ export type RecipeInterface = {
signIn: (input: {
webauthnGeneratedOptionsId: string;
credential: AuthenticationResponseJSON;
shouldTryLinkingWithSessionUser?: boolean;
options?: RecipeFunctionOptions;
userContext: any;
}) => Promise<
Expand Down Expand Up @@ -256,6 +258,7 @@ export type RecipeInterface = {
>;
registerCredentialWithSignUp: (input: {
email: string;
shouldTryLinkingWithSessionUser?: boolean;
options?: RecipeFunctionOptions;
userContext: any;
}) => Promise<
Expand Down Expand Up @@ -284,7 +287,11 @@ export type RecipeInterface = {
| { status: "FAILED_TO_REGISTER_USER"; error: any }
| { status: "WEBAUTHN_NOT_SUPPORTED"; error: any }
>;
authenticateCredentialWithSignIn: (input: { options?: RecipeFunctionOptions; userContext: any }) => Promise<
authenticateCredentialWithSignIn: (input: {
shouldTryLinkingWithSessionUser?: boolean;
options?: RecipeFunctionOptions;
userContext: any;
}) => Promise<
| {
status: "OK";
user: User;
Expand Down
Loading