Skip to content

Commit 1144588

Browse files
authored
Support auto passkey registration (#84)
* Support auto passkey registration * fix version * wip
1 parent 9de98e5 commit 1144588

File tree

4 files changed

+21
-16
lines changed

4 files changed

+21
-16
lines changed

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@authsignal/browser",
3-
"version": "1.2.1",
3+
"version": "1.3.0",
44
"type": "module",
55
"main": "dist/index.js",
66
"module": "dist/index.js",
@@ -28,8 +28,8 @@
2828
},
2929
"dependencies": {
3030
"@fingerprintjs/fingerprintjs": "^3.3.6",
31-
"@simplewebauthn/browser": "^10.0.0",
32-
"@simplewebauthn/types": "^10.0.0",
31+
"@simplewebauthn/browser": "^11.0.0",
32+
"@simplewebauthn/types": "^11.0.0",
3333
"a11y-dialog": "8.0.4",
3434
"uuid": "^9.0.0"
3535
},

src/passkey.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ type SignUpParams = {
1818
username?: string;
1919
displayName?: string;
2020
authenticatorAttachment?: AuthenticatorAttachment | null;
21+
useAutoRegister?: boolean;
2122
};
2223

2324
type SignUpResponse = {
@@ -58,6 +59,7 @@ export class Passkey {
5859
displayName,
5960
token,
6061
authenticatorAttachment = "platform",
62+
useAutoRegister = false,
6163
}: SignUpParams): Promise<AuthsignalResponse<SignUpResponse>> {
6264
const userToken = token ?? this.cache.token;
6365

@@ -78,7 +80,7 @@ export class Passkey {
7880
return handleErrorResponse(optionsResponse);
7981
}
8082

81-
const registrationResponse = await startRegistration(optionsResponse.options);
83+
const registrationResponse = await startRegistration({optionsJSON: optionsResponse.options, useAutoRegister});
8284

8385
const addAuthenticatorResponse = await this.api.addAuthenticator({
8486
challengeId: optionsResponse.challengeId,
@@ -133,7 +135,10 @@ export class Passkey {
133135
return handleErrorResponse(optionsResponse);
134136
}
135137

136-
const authenticationResponse = await startAuthentication(optionsResponse.options, params?.autofill);
138+
const authenticationResponse = await startAuthentication({
139+
optionsJSON: optionsResponse.options,
140+
useBrowserAutofill: params?.autofill,
141+
});
137142

138143
if (params?.onVerificationStarted) {
139144
params.onVerificationStarted();

src/security-key.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class SecurityKey {
4646
return handleErrorResponse(optionsResponse);
4747
}
4848

49-
const registrationResponse = await startRegistration(optionsResponse);
49+
const registrationResponse = await startRegistration({optionsJSON: optionsResponse});
5050

5151
const addAuthenticatorResponse = await this.api.addAuthenticator({
5252
registrationCredential: registrationResponse,
@@ -82,7 +82,7 @@ export class SecurityKey {
8282
return handleErrorResponse(optionsResponse);
8383
}
8484

85-
const authenticationResponse = await startAuthentication(optionsResponse);
85+
const authenticationResponse = await startAuthentication({optionsJSON: optionsResponse});
8686

8787
const verifyResponse = await this.api.verify({
8888
authenticationCredential: authenticationResponse,

yarn.lock

+9-9
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,17 @@
152152
estree-walker "^1.0.1"
153153
picomatch "^2.2.2"
154154

155-
"@simplewebauthn/browser@^10.0.0":
156-
version "10.0.0"
157-
resolved "https://registry.npmjs.org/@simplewebauthn/browser/-/browser-10.0.0.tgz#8305a57dacb35ab6a71a8b670c699ee7ef1c11c4"
158-
integrity sha512-hG0JMZD+LiLUbpQcAjS4d+t4gbprE/dLYop/CkE01ugU/9sKXflxV5s0DRjdz3uNMFecatRfb4ZLG3XvF8m5zg==
155+
"@simplewebauthn/browser@^11.0.0":
156+
version "11.0.0"
157+
resolved "https://registry.npmjs.org/@simplewebauthn/browser/-/browser-11.0.0.tgz#270b47039b4561199bc16f25197431c8f10dbfb5"
158+
integrity sha512-KEGCStrl08QC2I561BzxqGiwoknblP6O1YW7jApdXLPtIqZ+vgJYAv8ssLCdm1wD8HGAHd49CJLkUF8X70x/pg==
159159
dependencies:
160-
"@simplewebauthn/types" "^10.0.0"
160+
"@simplewebauthn/types" "^11.0.0"
161161

162-
"@simplewebauthn/types@^10.0.0":
163-
version "10.0.0"
164-
resolved "https://registry.npmjs.org/@simplewebauthn/types/-/types-10.0.0.tgz#a07259d42fbdff7a014473f78401d262b298ed8e"
165-
integrity sha512-SFXke7xkgPRowY2E+8djKbdEznTVnD5R6GO7GPTthpHrokLvNKw8C3lFZypTxLI7KkCfGPfhtqB3d7OVGGa9jQ==
162+
"@simplewebauthn/types@^11.0.0":
163+
version "11.0.0"
164+
resolved "https://registry.npmjs.org/@simplewebauthn/types/-/types-11.0.0.tgz#f329abc4c1bc3b18d6c7a4346af9fdec90d8a67e"
165+
integrity sha512-b2o0wC5u2rWts31dTgBkAtSNKGX0cvL6h8QedNsKmj8O4QoLFQFR3DBVBUlpyVEhYKA+mXGUaXbcOc4JdQ3HzA==
166166

167167
168168
version "0.0.39"

0 commit comments

Comments
 (0)