Skip to content

Commit 129e9f4

Browse files
committed
Merge branch 'feat/webauthn-credential-mng-methods' into feat/plugin/base
2 parents f4c3148 + 78eaa32 commit 129e9f4

File tree

6 files changed

+130
-2
lines changed

6 files changed

+130
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [unreleased]
99

10+
- Add WebAuthn credential management methods: `listCredentials`, `removeCredential`, `registerCredential2`
11+
1012
## [0.49.1] - 2025-03-27
1113

1214
- Fixed a type issue making the WebauthnPreBuitlUI not produce a type error when added to the prebuiltUIList

lib/build/recipe/webauthn/index.d.ts

Lines changed: 57 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/build/recipe/webauthn/types.d.ts

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/build/webauthn.js

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/ts/recipe/webauthn/index.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,48 @@ export default class Wrapper {
439439
return Webauthn.getInstanceOrThrow().webJSRecipe.registerCredentialWithRecoverAccount(input);
440440
}
441441

442+
static listCredentials(input: { options?: RecipeFunctionOptions; userContext: any }): Promise<
443+
| {
444+
status: "OK";
445+
credentials: {
446+
webauthnCredentialId: string;
447+
relyingPartyId: string;
448+
recipeUserId: string;
449+
createdAt: number;
450+
}[];
451+
}
452+
| GeneralErrorResponse
453+
> {
454+
return Webauthn.getInstanceOrThrow().webJSRecipe.listCredentials(input);
455+
}
456+
457+
static removeCredential(input: {
458+
webauthnCredentialId: string;
459+
userContext: any;
460+
}): Promise<
461+
{ status: "OK" } | GeneralErrorResponse | { status: "CREDENTIAL_NOT_FOUND_ERROR"; fetchResponse: Response }
462+
> {
463+
return Webauthn.getInstanceOrThrow().webJSRecipe.removeCredential(input);
464+
}
465+
466+
static registerCredential2(input: {
467+
recipeUserId: string;
468+
webauthnGeneratedOptionsId: string;
469+
credential: RegistrationResponseJSON;
470+
options?: RecipeFunctionOptions;
471+
userContext: any;
472+
}): Promise<
473+
| { status: "OK" }
474+
| GeneralErrorResponse
475+
| { status: "REGISTER_CREDENTIAL_NOT_ALLOWED"; reason: string }
476+
| { status: "INVALID_CREDENTIALS_ERROR" }
477+
| { status: "OPTIONS_NOT_FOUND_ERROR" }
478+
| { status: "INVALID_OPTIONS_ERROR" }
479+
| { status: "INVALID_AUTHENTICATOR_ERROR"; reason: string }
480+
> {
481+
return Webauthn.getInstanceOrThrow().webJSRecipe.registerCredential2(input);
482+
}
483+
442484
static doesBrowserSupportWebAuthn(input: { userContext: any }): Promise<
443485
| {
444486
status: "OK";
@@ -469,6 +511,9 @@ const authenticateCredential = Wrapper.authenticateCredential;
469511
const registerCredentialWithSignUp = Wrapper.registerCredentialWithSignUp;
470512
const authenticateCredentialWithSignIn = Wrapper.authenticateCredentialWithSignIn;
471513
const registerCredentialWithRecoverAccount = Wrapper.registerCredentialWithRecoverAccount;
514+
const listCredentials = Wrapper.listCredentials;
515+
const removeCredential = Wrapper.removeCredential;
516+
const registerCredential2 = Wrapper.registerCredential2;
472517
const doesBrowserSupportWebAuthn = Wrapper.doesBrowserSupportWebAuthn;
473518
const WebauthnComponentsOverrideProvider = Wrapper.ComponentsOverrideProvider;
474519

@@ -488,4 +533,7 @@ export {
488533
registerCredentialWithRecoverAccount,
489534
doesBrowserSupportWebAuthn,
490535
WebauthnComponentsOverrideProvider,
536+
listCredentials,
537+
removeCredential,
538+
registerCredential2,
491539
};

lib/ts/recipe/webauthn/types.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ export type PreAndPostAPIHookAction =
5757
| "SIGN_IN"
5858
| "EMAIL_EXISTS"
5959
| "GENERATE_RECOVER_ACCOUNT_TOKEN"
60-
| "RECOVER_ACCOUNT";
60+
| "RECOVER_ACCOUNT"
61+
| "REGISTER_CREDENTIAL"
62+
| "REMOVE_CREDENTIAL"
63+
| "LIST_CREDENTIALS";
6164

6265
export type OnHandleEventContext =
6366
| {

0 commit comments

Comments
 (0)