Skip to content

Commit 83f4ef1

Browse files
committed
Merge branch 'feat/webauthn-credential-mng-methods' into feat/plugin/base
# Conflicts: # lib/build/webauthn.js
2 parents d9b6413 + 32159eb commit 83f4ef1

File tree

4 files changed

+113
-45
lines changed

4 files changed

+113
-45
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ 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`
10+
- Add WebAuthn credential management methods: `listCredentials`, `removeCredential`
11+
- Added `registerCredentialWithUser` method that creates and registers a credential with a user
12+
13+
### Breaking changes
14+
15+
- 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.
1116

1217
## [0.49.1] - 2025-03-27
1318

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

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

lib/build/webauthn.js

Lines changed: 29 additions & 30 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: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ export default class Wrapper {
247247
return Webauthn.getInstanceOrThrow().webJSRecipe.recoverAccount(input);
248248
}
249249

250-
static registerCredential(input: {
250+
static createCredential(input: {
251251
registrationOptions: Omit<RegistrationOptions, "fetchResponse" | "status">;
252252
userContext: any;
253253
}): Promise<
@@ -267,7 +267,7 @@ export default class Wrapper {
267267
error: any;
268268
}
269269
> {
270-
return Webauthn.getInstanceOrThrow().webJSRecipe.registerCredential(input);
270+
return Webauthn.getInstanceOrThrow().webJSRecipe.createCredential(input);
271271
}
272272

273273
static authenticateCredential(input: {
@@ -463,7 +463,28 @@ export default class Wrapper {
463463
return Webauthn.getInstanceOrThrow().webJSRecipe.removeCredential(input);
464464
}
465465

466-
static registerCredential2(input: {
466+
static registerCredentialWithUser(input: {
467+
recipeUserId: string;
468+
email: string;
469+
options?: RecipeFunctionOptions;
470+
userContext: any;
471+
}): Promise<
472+
| { status: "OK" }
473+
| GeneralErrorResponse
474+
| { status: "REGISTER_CREDENTIAL_NOT_ALLOWED"; reason: string }
475+
| { status: "INVALID_EMAIL_ERROR"; err: 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+
| { status: "AUTHENTICATOR_ALREADY_REGISTERED" }
481+
| { status: "FAILED_TO_REGISTER_USER"; error: any }
482+
| { status: "WEBAUTHN_NOT_SUPPORTED"; error: any }
483+
> {
484+
return Webauthn.getInstanceOrThrow().webJSRecipe.registerCredentialWithUser(input);
485+
}
486+
487+
static registerCredential(input: {
467488
recipeUserId: string;
468489
webauthnGeneratedOptionsId: string;
469490
credential: RegistrationResponseJSON;
@@ -478,7 +499,7 @@ export default class Wrapper {
478499
| { status: "INVALID_OPTIONS_ERROR" }
479500
| { status: "INVALID_AUTHENTICATOR_ERROR"; reason: string }
480501
> {
481-
return Webauthn.getInstanceOrThrow().webJSRecipe.registerCredential2(input);
502+
return Webauthn.getInstanceOrThrow().webJSRecipe.registerCredential(input);
482503
}
483504

484505
static doesBrowserSupportWebAuthn(input: { userContext: any }): Promise<
@@ -506,14 +527,14 @@ const signIn = Wrapper.signIn;
506527
const getEmailExists = Wrapper.getEmailExists;
507528
const generateRecoverAccountToken = Wrapper.generateRecoverAccountToken;
508529
const recoverAccount = Wrapper.recoverAccount;
509-
const registerCredential = Wrapper.registerCredential;
530+
const createCredential = Wrapper.createCredential;
510531
const authenticateCredential = Wrapper.authenticateCredential;
511532
const registerCredentialWithSignUp = Wrapper.registerCredentialWithSignUp;
512533
const authenticateCredentialWithSignIn = Wrapper.authenticateCredentialWithSignIn;
513534
const registerCredentialWithRecoverAccount = Wrapper.registerCredentialWithRecoverAccount;
514535
const listCredentials = Wrapper.listCredentials;
515536
const removeCredential = Wrapper.removeCredential;
516-
const registerCredential2 = Wrapper.registerCredential2;
537+
const registerCredential = Wrapper.registerCredential;
517538
const doesBrowserSupportWebAuthn = Wrapper.doesBrowserSupportWebAuthn;
518539
const WebauthnComponentsOverrideProvider = Wrapper.ComponentsOverrideProvider;
519540

@@ -526,7 +547,7 @@ export {
526547
getEmailExists,
527548
generateRecoverAccountToken,
528549
recoverAccount,
529-
registerCredential,
550+
createCredential,
530551
authenticateCredential,
531552
registerCredentialWithSignUp,
532553
authenticateCredentialWithSignIn,
@@ -535,5 +556,5 @@ export {
535556
WebauthnComponentsOverrideProvider,
536557
listCredentials,
537558
removeCredential,
538-
registerCredential2,
559+
registerCredential,
539560
};

0 commit comments

Comments
 (0)