From 78eaa32bba5065d766f76e44ffeecb7df0002b46 Mon Sep 17 00:00:00 2001 From: Victor Bojica Date: Sun, 3 Aug 2025 14:13:11 +0300 Subject: [PATCH 1/5] feat: add WebAuthn credential management methods --- CHANGELOG.md | 2 + lib/build/recipe/webauthn/index.d.ts | 57 ++++++++++++++++++++++++++++ lib/build/recipe/webauthn/types.d.ts | 5 ++- lib/build/webauthn.js | 15 ++++++++ lib/ts/recipe/webauthn/index.ts | 48 +++++++++++++++++++++++ lib/ts/recipe/webauthn/types.ts | 5 ++- 6 files changed, 130 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aacc5e850..ef87d2459 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [unreleased] +- Add WebAuthn credential management methods: `listCredentials`, `removeCredential`, `registerCredential2` + ## [0.49.1] - 2025-03-27 - Fixed a type issue making the WebauthnPreBuitlUI not produce a type error when added to the prebuiltUIList diff --git a/lib/build/recipe/webauthn/index.d.ts b/lib/build/recipe/webauthn/index.d.ts index e47ec016e..454bb5d56 100644 --- a/lib/build/recipe/webauthn/index.d.ts +++ b/lib/build/recipe/webauthn/index.d.ts @@ -389,6 +389,57 @@ export default class Wrapper { error: any; } >; + static listCredentials(input: { options?: RecipeFunctionOptions; userContext: any }): Promise< + | { + status: "OK"; + credentials: { + webauthnCredentialId: string; + relyingPartyId: string; + recipeUserId: string; + createdAt: number; + }[]; + } + | GeneralErrorResponse + >; + static removeCredential(input: { webauthnCredentialId: string; userContext: any }): Promise< + | { + status: "OK"; + } + | GeneralErrorResponse + | { + status: "CREDENTIAL_NOT_FOUND_ERROR"; + fetchResponse: Response; + } + >; + static registerCredential2(input: { + recipeUserId: string; + webauthnGeneratedOptionsId: string; + credential: RegistrationResponseJSON; + options?: RecipeFunctionOptions; + userContext: any; + }): Promise< + | { + status: "OK"; + } + | GeneralErrorResponse + | { + status: "REGISTER_CREDENTIAL_NOT_ALLOWED"; + reason: string; + } + | { + status: "INVALID_CREDENTIALS_ERROR"; + } + | { + status: "OPTIONS_NOT_FOUND_ERROR"; + } + | { + status: "INVALID_OPTIONS_ERROR"; + } + | { + status: "INVALID_AUTHENTICATOR_ERROR"; + reason: string; + } + >; static doesBrowserSupportWebAuthn(input: { userContext: any }): Promise< | { status: "OK"; @@ -419,6 +470,9 @@ declare const authenticateCredential: typeof Wrapper.authenticateCredential; declare const registerCredentialWithSignUp: typeof Wrapper.registerCredentialWithSignUp; declare const authenticateCredentialWithSignIn: typeof Wrapper.authenticateCredentialWithSignIn; declare const registerCredentialWithRecoverAccount: typeof Wrapper.registerCredentialWithRecoverAccount; +declare const listCredentials: typeof Wrapper.listCredentials; +declare const removeCredential: typeof Wrapper.removeCredential; +declare const registerCredential2: typeof Wrapper.registerCredential2; declare const doesBrowserSupportWebAuthn: typeof Wrapper.doesBrowserSupportWebAuthn; declare const WebauthnComponentsOverrideProvider: import("react").FC< import("react").PropsWithChildren<{ @@ -441,4 +495,7 @@ export { registerCredentialWithRecoverAccount, doesBrowserSupportWebAuthn, WebauthnComponentsOverrideProvider, + listCredentials, + removeCredential, + registerCredential2, }; diff --git a/lib/build/recipe/webauthn/types.d.ts b/lib/build/recipe/webauthn/types.d.ts index 2fdb40499..cace33386 100644 --- a/lib/build/recipe/webauthn/types.d.ts +++ b/lib/build/recipe/webauthn/types.d.ts @@ -38,7 +38,10 @@ export declare type PreAndPostAPIHookAction = | "SIGN_IN" | "EMAIL_EXISTS" | "GENERATE_RECOVER_ACCOUNT_TOKEN" - | "RECOVER_ACCOUNT"; + | "RECOVER_ACCOUNT" + | "REGISTER_CREDENTIAL" + | "REMOVE_CREDENTIAL" + | "LIST_CREDENTIALS"; export declare type OnHandleEventContext = | { action: "SUCCESS"; diff --git a/lib/build/webauthn.js b/lib/build/webauthn.js index a412b3e76..867031618 100644 --- a/lib/build/webauthn.js +++ b/lib/build/webauthn.js @@ -79,6 +79,15 @@ var Wrapper = /** @class */ (function () { Wrapper.registerCredentialWithRecoverAccount = function (input) { return recipe.Webauthn.getInstanceOrThrow().webJSRecipe.registerCredentialWithRecoverAccount(input); }; + Wrapper.listCredentials = function (input) { + return recipe.Webauthn.getInstanceOrThrow().webJSRecipe.listCredentials(input); + }; + Wrapper.removeCredential = function (input) { + return recipe.Webauthn.getInstanceOrThrow().webJSRecipe.removeCredential(input); + }; + Wrapper.registerCredential2 = function (input) { + return recipe.Webauthn.getInstanceOrThrow().webJSRecipe.registerCredential2(input); + }; Wrapper.doesBrowserSupportWebAuthn = function (input) { return recipe.Webauthn.getInstanceOrThrow().webJSRecipe.doesBrowserSupportWebAuthn(input); }; @@ -98,6 +107,9 @@ var authenticateCredential = Wrapper.authenticateCredential; var registerCredentialWithSignUp = Wrapper.registerCredentialWithSignUp; var authenticateCredentialWithSignIn = Wrapper.authenticateCredentialWithSignIn; var registerCredentialWithRecoverAccount = Wrapper.registerCredentialWithRecoverAccount; +var listCredentials = Wrapper.listCredentials; +var removeCredential = Wrapper.removeCredential; +var registerCredential2 = Wrapper.registerCredential2; var doesBrowserSupportWebAuthn = Wrapper.doesBrowserSupportWebAuthn; var WebauthnComponentsOverrideProvider = Wrapper.ComponentsOverrideProvider; @@ -111,9 +123,12 @@ exports.getEmailExists = getEmailExists; exports.getRegisterOptions = getRegisterOptions; exports.getSignInOptions = getSignInOptions; exports.init = init; +exports.listCredentials = listCredentials; exports.recoverAccount = recoverAccount; exports.registerCredential = registerCredential; +exports.registerCredential2 = registerCredential2; exports.registerCredentialWithRecoverAccount = registerCredentialWithRecoverAccount; exports.registerCredentialWithSignUp = registerCredentialWithSignUp; +exports.removeCredential = removeCredential; exports.signIn = signIn; exports.signUp = signUp; diff --git a/lib/ts/recipe/webauthn/index.ts b/lib/ts/recipe/webauthn/index.ts index 4dfa3fbdb..ef87fb60b 100644 --- a/lib/ts/recipe/webauthn/index.ts +++ b/lib/ts/recipe/webauthn/index.ts @@ -439,6 +439,48 @@ export default class Wrapper { return Webauthn.getInstanceOrThrow().webJSRecipe.registerCredentialWithRecoverAccount(input); } + static listCredentials(input: { options?: RecipeFunctionOptions; userContext: any }): Promise< + | { + status: "OK"; + credentials: { + webauthnCredentialId: string; + relyingPartyId: string; + recipeUserId: string; + createdAt: number; + }[]; + } + | GeneralErrorResponse + > { + return Webauthn.getInstanceOrThrow().webJSRecipe.listCredentials(input); + } + + static removeCredential(input: { + webauthnCredentialId: string; + userContext: any; + }): Promise< + { status: "OK" } | GeneralErrorResponse | { status: "CREDENTIAL_NOT_FOUND_ERROR"; fetchResponse: Response } + > { + return Webauthn.getInstanceOrThrow().webJSRecipe.removeCredential(input); + } + + static registerCredential2(input: { + recipeUserId: string; + webauthnGeneratedOptionsId: string; + credential: RegistrationResponseJSON; + options?: RecipeFunctionOptions; + userContext: any; + }): Promise< + | { status: "OK" } + | GeneralErrorResponse + | { status: "REGISTER_CREDENTIAL_NOT_ALLOWED"; reason: string } + | { status: "INVALID_CREDENTIALS_ERROR" } + | { status: "OPTIONS_NOT_FOUND_ERROR" } + | { status: "INVALID_OPTIONS_ERROR" } + | { status: "INVALID_AUTHENTICATOR_ERROR"; reason: string } + > { + return Webauthn.getInstanceOrThrow().webJSRecipe.registerCredential2(input); + } + static doesBrowserSupportWebAuthn(input: { userContext: any }): Promise< | { status: "OK"; @@ -469,6 +511,9 @@ const authenticateCredential = Wrapper.authenticateCredential; const registerCredentialWithSignUp = Wrapper.registerCredentialWithSignUp; const authenticateCredentialWithSignIn = Wrapper.authenticateCredentialWithSignIn; const registerCredentialWithRecoverAccount = Wrapper.registerCredentialWithRecoverAccount; +const listCredentials = Wrapper.listCredentials; +const removeCredential = Wrapper.removeCredential; +const registerCredential2 = Wrapper.registerCredential2; const doesBrowserSupportWebAuthn = Wrapper.doesBrowserSupportWebAuthn; const WebauthnComponentsOverrideProvider = Wrapper.ComponentsOverrideProvider; @@ -488,4 +533,7 @@ export { registerCredentialWithRecoverAccount, doesBrowserSupportWebAuthn, WebauthnComponentsOverrideProvider, + listCredentials, + removeCredential, + registerCredential2, }; diff --git a/lib/ts/recipe/webauthn/types.ts b/lib/ts/recipe/webauthn/types.ts index ec4b28081..6da6d01e1 100644 --- a/lib/ts/recipe/webauthn/types.ts +++ b/lib/ts/recipe/webauthn/types.ts @@ -57,7 +57,10 @@ export type PreAndPostAPIHookAction = | "SIGN_IN" | "EMAIL_EXISTS" | "GENERATE_RECOVER_ACCOUNT_TOKEN" - | "RECOVER_ACCOUNT"; + | "RECOVER_ACCOUNT" + | "REGISTER_CREDENTIAL" + | "REMOVE_CREDENTIAL" + | "LIST_CREDENTIALS"; export type OnHandleEventContext = | { From 32159eb991fcae33f46d052305d1c885277c3c15 Mon Sep 17 00:00:00 2001 From: Victor Bojica Date: Tue, 5 Aug 2025 14:41:08 +0300 Subject: [PATCH 2/5] feat: renamed `registerCredential` to `createCredential` and added `registerCredentialWithUser` method for user-specific credential registration --- CHANGELOG.md | 7 +++- lib/build/recipe/webauthn/index.d.ts | 55 +++++++++++++++++++++++++--- lib/build/webauthn.js | 17 +++++---- lib/ts/recipe/webauthn/index.ts | 37 +++++++++++++++---- 4 files changed, 94 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef87d2459..d7daa11ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [unreleased] -- Add WebAuthn credential management methods: `listCredentials`, `removeCredential`, `registerCredential2` +- Add WebAuthn credential management methods: `listCredentials`, `removeCredential` +- Added `registerCredentialWithUser` method that creates and registers a credential with a user + +### Breaking changes + +- The `registerCredential` method has been renamed to `createCredential`. This was done to better represent the creation of a credential and not the actual registration of it with the backend API. The new `registerCredential` implementation now calls the backend API. ## [0.49.1] - 2025-03-27 diff --git a/lib/build/recipe/webauthn/index.d.ts b/lib/build/recipe/webauthn/index.d.ts index 454bb5d56..a143bc9cc 100644 --- a/lib/build/recipe/webauthn/index.d.ts +++ b/lib/build/recipe/webauthn/index.d.ts @@ -212,7 +212,7 @@ export default class Wrapper { fetchResponse: Response; } >; - static registerCredential(input: { + static createCredential(input: { registrationOptions: Omit; userContext: any; }): Promise< @@ -411,7 +411,50 @@ export default class Wrapper { fetchResponse: Response; } >; - static registerCredential2(input: { + static registerCredentialWithUser(input: { + recipeUserId: string; + email: string; + options?: RecipeFunctionOptions; + userContext: any; + }): Promise< + | { + status: "OK"; + } + | GeneralErrorResponse + | { + status: "REGISTER_CREDENTIAL_NOT_ALLOWED"; + reason: string; + } + | { + status: "INVALID_EMAIL_ERROR"; + err: string; + } + | { + status: "INVALID_CREDENTIALS_ERROR"; + } + | { + status: "OPTIONS_NOT_FOUND_ERROR"; + } + | { + status: "INVALID_OPTIONS_ERROR"; + } + | { + status: "INVALID_AUTHENTICATOR_ERROR"; + reason: string; + } + | { + status: "AUTHENTICATOR_ALREADY_REGISTERED"; + } + | { + status: "FAILED_TO_REGISTER_USER"; + error: any; + } + | { + status: "WEBAUTHN_NOT_SUPPORTED"; + error: any; + } + >; + static registerCredential(input: { recipeUserId: string; webauthnGeneratedOptionsId: string; credential: RegistrationResponseJSON; @@ -465,14 +508,14 @@ declare const signIn: typeof Wrapper.signIn; declare const getEmailExists: typeof Wrapper.getEmailExists; declare const generateRecoverAccountToken: typeof Wrapper.generateRecoverAccountToken; declare const recoverAccount: typeof Wrapper.recoverAccount; -declare const registerCredential: typeof Wrapper.registerCredential; +declare const createCredential: typeof Wrapper.createCredential; declare const authenticateCredential: typeof Wrapper.authenticateCredential; declare const registerCredentialWithSignUp: typeof Wrapper.registerCredentialWithSignUp; declare const authenticateCredentialWithSignIn: typeof Wrapper.authenticateCredentialWithSignIn; declare const registerCredentialWithRecoverAccount: typeof Wrapper.registerCredentialWithRecoverAccount; declare const listCredentials: typeof Wrapper.listCredentials; declare const removeCredential: typeof Wrapper.removeCredential; -declare const registerCredential2: typeof Wrapper.registerCredential2; +declare const registerCredential: typeof Wrapper.registerCredential; declare const doesBrowserSupportWebAuthn: typeof Wrapper.doesBrowserSupportWebAuthn; declare const WebauthnComponentsOverrideProvider: import("react").FC< import("react").PropsWithChildren<{ @@ -488,7 +531,7 @@ export { getEmailExists, generateRecoverAccountToken, recoverAccount, - registerCredential, + createCredential, authenticateCredential, registerCredentialWithSignUp, authenticateCredentialWithSignIn, @@ -497,5 +540,5 @@ export { WebauthnComponentsOverrideProvider, listCredentials, removeCredential, - registerCredential2, + registerCredential, }; diff --git a/lib/build/webauthn.js b/lib/build/webauthn.js index 867031618..498ccaeff 100644 --- a/lib/build/webauthn.js +++ b/lib/build/webauthn.js @@ -64,8 +64,8 @@ var Wrapper = /** @class */ (function () { Wrapper.recoverAccount = function (input) { return recipe.Webauthn.getInstanceOrThrow().webJSRecipe.recoverAccount(input); }; - Wrapper.registerCredential = function (input) { - return recipe.Webauthn.getInstanceOrThrow().webJSRecipe.registerCredential(input); + Wrapper.createCredential = function (input) { + return recipe.Webauthn.getInstanceOrThrow().webJSRecipe.createCredential(input); }; Wrapper.authenticateCredential = function (input) { return recipe.Webauthn.getInstanceOrThrow().webJSRecipe.authenticateCredential(input); @@ -85,8 +85,11 @@ var Wrapper = /** @class */ (function () { Wrapper.removeCredential = function (input) { return recipe.Webauthn.getInstanceOrThrow().webJSRecipe.removeCredential(input); }; - Wrapper.registerCredential2 = function (input) { - return recipe.Webauthn.getInstanceOrThrow().webJSRecipe.registerCredential2(input); + Wrapper.registerCredentialWithUser = function (input) { + return recipe.Webauthn.getInstanceOrThrow().webJSRecipe.registerCredentialWithUser(input); + }; + Wrapper.registerCredential = function (input) { + return recipe.Webauthn.getInstanceOrThrow().webJSRecipe.registerCredential(input); }; Wrapper.doesBrowserSupportWebAuthn = function (input) { return recipe.Webauthn.getInstanceOrThrow().webJSRecipe.doesBrowserSupportWebAuthn(input); @@ -102,20 +105,21 @@ var signIn = Wrapper.signIn; var getEmailExists = Wrapper.getEmailExists; var generateRecoverAccountToken = Wrapper.generateRecoverAccountToken; var recoverAccount = Wrapper.recoverAccount; -var registerCredential = Wrapper.registerCredential; +var createCredential = Wrapper.createCredential; var authenticateCredential = Wrapper.authenticateCredential; var registerCredentialWithSignUp = Wrapper.registerCredentialWithSignUp; var authenticateCredentialWithSignIn = Wrapper.authenticateCredentialWithSignIn; var registerCredentialWithRecoverAccount = Wrapper.registerCredentialWithRecoverAccount; var listCredentials = Wrapper.listCredentials; var removeCredential = Wrapper.removeCredential; -var registerCredential2 = Wrapper.registerCredential2; +var registerCredential = Wrapper.registerCredential; var doesBrowserSupportWebAuthn = Wrapper.doesBrowserSupportWebAuthn; var WebauthnComponentsOverrideProvider = Wrapper.ComponentsOverrideProvider; exports.WebauthnComponentsOverrideProvider = WebauthnComponentsOverrideProvider; exports.authenticateCredential = authenticateCredential; exports.authenticateCredentialWithSignIn = authenticateCredentialWithSignIn; +exports.createCredential = createCredential; exports.default = Wrapper; exports.doesBrowserSupportWebAuthn = doesBrowserSupportWebAuthn; exports.generateRecoverAccountToken = generateRecoverAccountToken; @@ -126,7 +130,6 @@ exports.init = init; exports.listCredentials = listCredentials; exports.recoverAccount = recoverAccount; exports.registerCredential = registerCredential; -exports.registerCredential2 = registerCredential2; exports.registerCredentialWithRecoverAccount = registerCredentialWithRecoverAccount; exports.registerCredentialWithSignUp = registerCredentialWithSignUp; exports.removeCredential = removeCredential; diff --git a/lib/ts/recipe/webauthn/index.ts b/lib/ts/recipe/webauthn/index.ts index ef87fb60b..235ea0b24 100644 --- a/lib/ts/recipe/webauthn/index.ts +++ b/lib/ts/recipe/webauthn/index.ts @@ -247,7 +247,7 @@ export default class Wrapper { return Webauthn.getInstanceOrThrow().webJSRecipe.recoverAccount(input); } - static registerCredential(input: { + static createCredential(input: { registrationOptions: Omit; userContext: any; }): Promise< @@ -267,7 +267,7 @@ export default class Wrapper { error: any; } > { - return Webauthn.getInstanceOrThrow().webJSRecipe.registerCredential(input); + return Webauthn.getInstanceOrThrow().webJSRecipe.createCredential(input); } static authenticateCredential(input: { @@ -463,7 +463,28 @@ export default class Wrapper { return Webauthn.getInstanceOrThrow().webJSRecipe.removeCredential(input); } - static registerCredential2(input: { + static registerCredentialWithUser(input: { + recipeUserId: string; + email: string; + options?: RecipeFunctionOptions; + userContext: any; + }): Promise< + | { status: "OK" } + | GeneralErrorResponse + | { status: "REGISTER_CREDENTIAL_NOT_ALLOWED"; reason: string } + | { status: "INVALID_EMAIL_ERROR"; err: string } + | { status: "INVALID_CREDENTIALS_ERROR" } + | { status: "OPTIONS_NOT_FOUND_ERROR" } + | { status: "INVALID_OPTIONS_ERROR" } + | { status: "INVALID_AUTHENTICATOR_ERROR"; reason: string } + | { status: "AUTHENTICATOR_ALREADY_REGISTERED" } + | { status: "FAILED_TO_REGISTER_USER"; error: any } + | { status: "WEBAUTHN_NOT_SUPPORTED"; error: any } + > { + return Webauthn.getInstanceOrThrow().webJSRecipe.registerCredentialWithUser(input); + } + + static registerCredential(input: { recipeUserId: string; webauthnGeneratedOptionsId: string; credential: RegistrationResponseJSON; @@ -478,7 +499,7 @@ export default class Wrapper { | { status: "INVALID_OPTIONS_ERROR" } | { status: "INVALID_AUTHENTICATOR_ERROR"; reason: string } > { - return Webauthn.getInstanceOrThrow().webJSRecipe.registerCredential2(input); + return Webauthn.getInstanceOrThrow().webJSRecipe.registerCredential(input); } static doesBrowserSupportWebAuthn(input: { userContext: any }): Promise< @@ -506,14 +527,14 @@ const signIn = Wrapper.signIn; const getEmailExists = Wrapper.getEmailExists; const generateRecoverAccountToken = Wrapper.generateRecoverAccountToken; const recoverAccount = Wrapper.recoverAccount; -const registerCredential = Wrapper.registerCredential; +const createCredential = Wrapper.createCredential; const authenticateCredential = Wrapper.authenticateCredential; const registerCredentialWithSignUp = Wrapper.registerCredentialWithSignUp; const authenticateCredentialWithSignIn = Wrapper.authenticateCredentialWithSignIn; const registerCredentialWithRecoverAccount = Wrapper.registerCredentialWithRecoverAccount; const listCredentials = Wrapper.listCredentials; const removeCredential = Wrapper.removeCredential; -const registerCredential2 = Wrapper.registerCredential2; +const registerCredential = Wrapper.registerCredential; const doesBrowserSupportWebAuthn = Wrapper.doesBrowserSupportWebAuthn; const WebauthnComponentsOverrideProvider = Wrapper.ComponentsOverrideProvider; @@ -526,7 +547,7 @@ export { getEmailExists, generateRecoverAccountToken, recoverAccount, - registerCredential, + createCredential, authenticateCredential, registerCredentialWithSignUp, authenticateCredentialWithSignIn, @@ -535,5 +556,5 @@ export { WebauthnComponentsOverrideProvider, listCredentials, removeCredential, - registerCredential2, + registerCredential, }; From a3740169927df1c26d4fe56a10c6cafedff36b2f Mon Sep 17 00:00:00 2001 From: Victor Bojica Date: Tue, 5 Aug 2025 15:01:33 +0300 Subject: [PATCH 3/5] fix: added missing exports --- lib/build/recipe/webauthn/index.d.ts | 2 ++ lib/build/webauthn.js | 2 ++ lib/ts/recipe/webauthn/index.ts | 2 ++ 3 files changed, 6 insertions(+) diff --git a/lib/build/recipe/webauthn/index.d.ts b/lib/build/recipe/webauthn/index.d.ts index a143bc9cc..2f3805c3e 100644 --- a/lib/build/recipe/webauthn/index.d.ts +++ b/lib/build/recipe/webauthn/index.d.ts @@ -513,6 +513,7 @@ declare const authenticateCredential: typeof Wrapper.authenticateCredential; declare const registerCredentialWithSignUp: typeof Wrapper.registerCredentialWithSignUp; declare const authenticateCredentialWithSignIn: typeof Wrapper.authenticateCredentialWithSignIn; declare const registerCredentialWithRecoverAccount: typeof Wrapper.registerCredentialWithRecoverAccount; +declare const registerCredentialWithUser: typeof Wrapper.registerCredentialWithUser; declare const listCredentials: typeof Wrapper.listCredentials; declare const removeCredential: typeof Wrapper.removeCredential; declare const registerCredential: typeof Wrapper.registerCredential; @@ -536,6 +537,7 @@ export { registerCredentialWithSignUp, authenticateCredentialWithSignIn, registerCredentialWithRecoverAccount, + registerCredentialWithUser, doesBrowserSupportWebAuthn, WebauthnComponentsOverrideProvider, listCredentials, diff --git a/lib/build/webauthn.js b/lib/build/webauthn.js index 498ccaeff..886662596 100644 --- a/lib/build/webauthn.js +++ b/lib/build/webauthn.js @@ -110,6 +110,7 @@ var authenticateCredential = Wrapper.authenticateCredential; var registerCredentialWithSignUp = Wrapper.registerCredentialWithSignUp; var authenticateCredentialWithSignIn = Wrapper.authenticateCredentialWithSignIn; var registerCredentialWithRecoverAccount = Wrapper.registerCredentialWithRecoverAccount; +var registerCredentialWithUser = Wrapper.registerCredentialWithUser; var listCredentials = Wrapper.listCredentials; var removeCredential = Wrapper.removeCredential; var registerCredential = Wrapper.registerCredential; @@ -132,6 +133,7 @@ exports.recoverAccount = recoverAccount; exports.registerCredential = registerCredential; exports.registerCredentialWithRecoverAccount = registerCredentialWithRecoverAccount; exports.registerCredentialWithSignUp = registerCredentialWithSignUp; +exports.registerCredentialWithUser = registerCredentialWithUser; exports.removeCredential = removeCredential; exports.signIn = signIn; exports.signUp = signUp; diff --git a/lib/ts/recipe/webauthn/index.ts b/lib/ts/recipe/webauthn/index.ts index 235ea0b24..1818d4f64 100644 --- a/lib/ts/recipe/webauthn/index.ts +++ b/lib/ts/recipe/webauthn/index.ts @@ -532,6 +532,7 @@ const authenticateCredential = Wrapper.authenticateCredential; const registerCredentialWithSignUp = Wrapper.registerCredentialWithSignUp; const authenticateCredentialWithSignIn = Wrapper.authenticateCredentialWithSignIn; const registerCredentialWithRecoverAccount = Wrapper.registerCredentialWithRecoverAccount; +const registerCredentialWithUser = Wrapper.registerCredentialWithUser; const listCredentials = Wrapper.listCredentials; const removeCredential = Wrapper.removeCredential; const registerCredential = Wrapper.registerCredential; @@ -552,6 +553,7 @@ export { registerCredentialWithSignUp, authenticateCredentialWithSignIn, registerCredentialWithRecoverAccount, + registerCredentialWithUser, doesBrowserSupportWebAuthn, WebauthnComponentsOverrideProvider, listCredentials, From 4a0901b219b6ce8296a3a1a6b1f8838e03575316 Mon Sep 17 00:00:00 2001 From: Mihaly Lengyel Date: Fri, 8 Aug 2025 17:53:39 +0200 Subject: [PATCH 4/5] fix: temporarily set web-js version new version branch --- lib/build/recipe/webauthn/index.d.ts | 14 +++++++------- lib/build/webauthn.js | 8 ++++---- lib/build/webauthnprebuiltui.js | 2 +- .../features/recoverAccountWithToken/index.tsx | 2 +- lib/ts/recipe/webauthn/index.ts | 16 ++++++++-------- package-lock.json | 6 +++--- package.json | 2 +- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lib/build/recipe/webauthn/index.d.ts b/lib/build/recipe/webauthn/index.d.ts index 2f3805c3e..e97066873 100644 --- a/lib/build/recipe/webauthn/index.d.ts +++ b/lib/build/recipe/webauthn/index.d.ts @@ -411,7 +411,7 @@ export default class Wrapper { fetchResponse: Response; } >; - static registerCredentialWithUser(input: { + static createAndRegisterCredentialForSessionUser(input: { recipeUserId: string; email: string; options?: RecipeFunctionOptions; @@ -423,7 +423,7 @@ export default class Wrapper { | GeneralErrorResponse | { status: "REGISTER_CREDENTIAL_NOT_ALLOWED"; - reason: string; + reason?: string; } | { status: "INVALID_EMAIL_ERROR"; @@ -440,7 +440,7 @@ export default class Wrapper { } | { status: "INVALID_AUTHENTICATOR_ERROR"; - reason: string; + reason?: string; } | { status: "AUTHENTICATOR_ALREADY_REGISTERED"; @@ -467,7 +467,7 @@ export default class Wrapper { | GeneralErrorResponse | { status: "REGISTER_CREDENTIAL_NOT_ALLOWED"; - reason: string; + reason?: string; } | { status: "INVALID_CREDENTIALS_ERROR"; @@ -480,7 +480,7 @@ export default class Wrapper { } | { status: "INVALID_AUTHENTICATOR_ERROR"; - reason: string; + reason?: string; } >; static doesBrowserSupportWebAuthn(input: { userContext: any }): Promise< @@ -513,7 +513,7 @@ declare const authenticateCredential: typeof Wrapper.authenticateCredential; declare const registerCredentialWithSignUp: typeof Wrapper.registerCredentialWithSignUp; declare const authenticateCredentialWithSignIn: typeof Wrapper.authenticateCredentialWithSignIn; declare const registerCredentialWithRecoverAccount: typeof Wrapper.registerCredentialWithRecoverAccount; -declare const registerCredentialWithUser: typeof Wrapper.registerCredentialWithUser; +declare const createAndRegisterCredentialForSessionUser: typeof Wrapper.createAndRegisterCredentialForSessionUser; declare const listCredentials: typeof Wrapper.listCredentials; declare const removeCredential: typeof Wrapper.removeCredential; declare const registerCredential: typeof Wrapper.registerCredential; @@ -537,7 +537,7 @@ export { registerCredentialWithSignUp, authenticateCredentialWithSignIn, registerCredentialWithRecoverAccount, - registerCredentialWithUser, + createAndRegisterCredentialForSessionUser, doesBrowserSupportWebAuthn, WebauthnComponentsOverrideProvider, listCredentials, diff --git a/lib/build/webauthn.js b/lib/build/webauthn.js index 886662596..a89208f5e 100644 --- a/lib/build/webauthn.js +++ b/lib/build/webauthn.js @@ -85,8 +85,8 @@ var Wrapper = /** @class */ (function () { Wrapper.removeCredential = function (input) { return recipe.Webauthn.getInstanceOrThrow().webJSRecipe.removeCredential(input); }; - Wrapper.registerCredentialWithUser = function (input) { - return recipe.Webauthn.getInstanceOrThrow().webJSRecipe.registerCredentialWithUser(input); + Wrapper.createAndRegisterCredentialForSessionUser = function (input) { + return recipe.Webauthn.getInstanceOrThrow().webJSRecipe.createAndRegisterCredentialForSessionUser(input); }; Wrapper.registerCredential = function (input) { return recipe.Webauthn.getInstanceOrThrow().webJSRecipe.registerCredential(input); @@ -110,7 +110,7 @@ var authenticateCredential = Wrapper.authenticateCredential; var registerCredentialWithSignUp = Wrapper.registerCredentialWithSignUp; var authenticateCredentialWithSignIn = Wrapper.authenticateCredentialWithSignIn; var registerCredentialWithRecoverAccount = Wrapper.registerCredentialWithRecoverAccount; -var registerCredentialWithUser = Wrapper.registerCredentialWithUser; +var createAndRegisterCredentialForSessionUser = Wrapper.createAndRegisterCredentialForSessionUser; var listCredentials = Wrapper.listCredentials; var removeCredential = Wrapper.removeCredential; var registerCredential = Wrapper.registerCredential; @@ -120,6 +120,7 @@ var WebauthnComponentsOverrideProvider = Wrapper.ComponentsOverrideProvider; exports.WebauthnComponentsOverrideProvider = WebauthnComponentsOverrideProvider; exports.authenticateCredential = authenticateCredential; exports.authenticateCredentialWithSignIn = authenticateCredentialWithSignIn; +exports.createAndRegisterCredentialForSessionUser = createAndRegisterCredentialForSessionUser; exports.createCredential = createCredential; exports.default = Wrapper; exports.doesBrowserSupportWebAuthn = doesBrowserSupportWebAuthn; @@ -133,7 +134,6 @@ exports.recoverAccount = recoverAccount; exports.registerCredential = registerCredential; exports.registerCredentialWithRecoverAccount = registerCredentialWithRecoverAccount; exports.registerCredentialWithSignUp = registerCredentialWithSignUp; -exports.registerCredentialWithUser = registerCredentialWithUser; exports.removeCredential = removeCredential; exports.signIn = signIn; exports.signUp = signUp; diff --git a/lib/build/webauthnprebuiltui.js b/lib/build/webauthnprebuiltui.js index 23f1c7da4..229dd011e 100644 --- a/lib/build/webauthnprebuiltui.js +++ b/lib/build/webauthnprebuiltui.js @@ -804,7 +804,7 @@ var RecoverAccountUsingToken = function (props) { } return [ 4 /*yield*/, - props.recipe.webJSRecipe.registerCredential({ + props.recipe.webJSRecipe.createCredential({ registrationOptions: registerOptions, userContext: props.userContext, }), diff --git a/lib/ts/recipe/webauthn/components/features/recoverAccountWithToken/index.tsx b/lib/ts/recipe/webauthn/components/features/recoverAccountWithToken/index.tsx index 30a0aa5a1..d31faf419 100644 --- a/lib/ts/recipe/webauthn/components/features/recoverAccountWithToken/index.tsx +++ b/lib/ts/recipe/webauthn/components/features/recoverAccountWithToken/index.tsx @@ -131,7 +131,7 @@ export const RecoverAccountUsingToken: React.FC = // Use the register options to register the credential and recover the account. // We should have received a valid registration options response. - const registerCredentialResponse = await props.recipe.webJSRecipe.registerCredential({ + const registerCredentialResponse = await props.recipe.webJSRecipe.createCredential({ registrationOptions: registerOptions, userContext: props.userContext, }); diff --git a/lib/ts/recipe/webauthn/index.ts b/lib/ts/recipe/webauthn/index.ts index 1818d4f64..c7b1a4f86 100644 --- a/lib/ts/recipe/webauthn/index.ts +++ b/lib/ts/recipe/webauthn/index.ts @@ -463,7 +463,7 @@ export default class Wrapper { return Webauthn.getInstanceOrThrow().webJSRecipe.removeCredential(input); } - static registerCredentialWithUser(input: { + static createAndRegisterCredentialForSessionUser(input: { recipeUserId: string; email: string; options?: RecipeFunctionOptions; @@ -471,17 +471,17 @@ export default class Wrapper { }): Promise< | { status: "OK" } | GeneralErrorResponse - | { status: "REGISTER_CREDENTIAL_NOT_ALLOWED"; reason: string } + | { status: "REGISTER_CREDENTIAL_NOT_ALLOWED"; reason?: string } | { status: "INVALID_EMAIL_ERROR"; err: string } | { status: "INVALID_CREDENTIALS_ERROR" } | { status: "OPTIONS_NOT_FOUND_ERROR" } | { status: "INVALID_OPTIONS_ERROR" } - | { status: "INVALID_AUTHENTICATOR_ERROR"; reason: string } + | { status: "INVALID_AUTHENTICATOR_ERROR"; reason?: string } | { status: "AUTHENTICATOR_ALREADY_REGISTERED" } | { status: "FAILED_TO_REGISTER_USER"; error: any } | { status: "WEBAUTHN_NOT_SUPPORTED"; error: any } > { - return Webauthn.getInstanceOrThrow().webJSRecipe.registerCredentialWithUser(input); + return Webauthn.getInstanceOrThrow().webJSRecipe.createAndRegisterCredentialForSessionUser(input); } static registerCredential(input: { @@ -493,11 +493,11 @@ export default class Wrapper { }): Promise< | { status: "OK" } | GeneralErrorResponse - | { status: "REGISTER_CREDENTIAL_NOT_ALLOWED"; reason: string } + | { status: "REGISTER_CREDENTIAL_NOT_ALLOWED"; reason?: string } | { status: "INVALID_CREDENTIALS_ERROR" } | { status: "OPTIONS_NOT_FOUND_ERROR" } | { status: "INVALID_OPTIONS_ERROR" } - | { status: "INVALID_AUTHENTICATOR_ERROR"; reason: string } + | { status: "INVALID_AUTHENTICATOR_ERROR"; reason?: string } > { return Webauthn.getInstanceOrThrow().webJSRecipe.registerCredential(input); } @@ -532,7 +532,7 @@ const authenticateCredential = Wrapper.authenticateCredential; const registerCredentialWithSignUp = Wrapper.registerCredentialWithSignUp; const authenticateCredentialWithSignIn = Wrapper.authenticateCredentialWithSignIn; const registerCredentialWithRecoverAccount = Wrapper.registerCredentialWithRecoverAccount; -const registerCredentialWithUser = Wrapper.registerCredentialWithUser; +const createAndRegisterCredentialForSessionUser = Wrapper.createAndRegisterCredentialForSessionUser; const listCredentials = Wrapper.listCredentials; const removeCredential = Wrapper.removeCredential; const registerCredential = Wrapper.registerCredential; @@ -553,7 +553,7 @@ export { registerCredentialWithSignUp, authenticateCredentialWithSignIn, registerCredentialWithRecoverAccount, - registerCredentialWithUser, + createAndRegisterCredentialForSessionUser, doesBrowserSupportWebAuthn, WebauthnComponentsOverrideProvider, listCredentials, diff --git a/package-lock.json b/package-lock.json index ccdb3f4e2..ea485c55c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -106,7 +106,7 @@ "peerDependencies": { "react": ">=16.8.0", "react-dom": ">=16.8.0", - "supertokens-web-js": "^0.15" + "supertokens-web-js": "github:supertokens/supertokens-web-js#0.16" } }, "eslint": { @@ -24452,8 +24452,8 @@ "license": "Apache-2.0" }, "node_modules/supertokens-web-js": { - "version": "0.15.0", - "resolved": "git+ssh://git@github.com/supertokens/supertokens-web-js.git#64366a553d3e5611a2ec5cd9ffa66856dd0fd063", + "version": "0.16.0", + "resolved": "git+ssh://git@github.com/supertokens/supertokens-web-js.git#0df91a3837c76406d13d86d8e5dbb9a4a65de2a2", "license": "Apache-2.0", "peer": true, "dependencies": { diff --git a/package.json b/package.json index 5f85f4aa2..c025e30ec 100644 --- a/package.json +++ b/package.json @@ -101,7 +101,7 @@ "peerDependencies": { "react": ">=16.8.0", "react-dom": ">=16.8.0", - "supertokens-web-js": "^0.15" + "supertokens-web-js": "github:supertokens/supertokens-web-js#0.16" }, "scripts": { "init": "bash ./init.sh", From a13b2f798624d574b8336cde0bf1ea09bce13461 Mon Sep 17 00:00:00 2001 From: Mihaly Lengyel Date: Fri, 8 Aug 2025 17:55:07 +0200 Subject: [PATCH 5/5] chore: update changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d7daa11ca..58e9f13ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [unreleased] +## [0.50] - 2025-08-11 + - Add WebAuthn credential management methods: `listCredentials`, `removeCredential` -- Added `registerCredentialWithUser` method that creates and registers a credential with a user +- Added `createAndRegisterCredentialWithUser` method that creates and registers a credential with a user ### Breaking changes