nuxt-auth-utils 0.4.4 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -296,7 +296,7 @@ To enable WebAuthn you need to:
296
296
  1. Install the peer dependencies:
297
297
 
298
298
  ```bash
299
- npx nypm i @simplewebauthn/server @simplewebauthn/browser
299
+ npx nypm i @simplewebauthn/server@11 @simplewebauthn/browser@11
300
300
  ```
301
301
 
302
302
  2. Enable it in your `nuxt.config.ts`
@@ -425,7 +425,7 @@ export default defineWebAuthnAuthenticateEventHandler({
425
425
  ```
426
426
 
427
427
  > [!IMPORTANT]
428
- > Webauthn uses challenges to prevent replay attacks. By default, this module does not make use if this feature. If you want to use challenges (**which is highly recommended**), the `storeChallenge` and `getChallenge` functions are provided. An attempt ID is created and sent with each autentication request. You can use this ID to store the challenge in a database or KV store as shown in the example below.
428
+ > Webauthn uses challenges to prevent replay attacks. By default, this module does not make use if this feature. If you want to use challenges (**which is highly recommended**), the `storeChallenge` and `getChallenge` functions are provided. An attempt ID is created and sent with each authentication request. You can use this ID to store the challenge in a database or KV store as shown in the example below.
429
429
 
430
430
  > ```ts
431
431
  > export default defineWebAuthnAuthenticateEventHandler({
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "auth-utils",
3
3
  "configKey": "auth",
4
- "version": "0.4.4",
4
+ "version": "0.5.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.4",
7
7
  "unbuild": "2.0.0"
@@ -10,4 +10,9 @@ export declare function useWebAuthn(options?: {
10
10
  * @default '/api/webauthn/authenticate'
11
11
  */
12
12
  authenticateEndpoint?: string;
13
+ /**
14
+ * Enable browser autofill for authentication
15
+ * @default false
16
+ */
17
+ useBrowserAutofill?: boolean;
13
18
  }): WebAuthnComposable;
@@ -7,7 +7,11 @@ import {
7
7
  } from "@simplewebauthn/browser";
8
8
  import { ref, onMounted } from "#imports";
9
9
  export function useWebAuthn(options = {}) {
10
- const { registerEndpoint = "/api/webauthn/register", authenticateEndpoint = "/api/webauthn/authenticate" } = options;
10
+ const {
11
+ registerEndpoint = "/api/webauthn/register",
12
+ authenticateEndpoint = "/api/webauthn/authenticate",
13
+ useBrowserAutofill = false
14
+ } = options;
11
15
  async function register(user) {
12
16
  const { creationOptions, attemptId } = await $fetch(registerEndpoint, {
13
17
  method: "POST",
@@ -16,7 +20,9 @@ export function useWebAuthn(options = {}) {
16
20
  verify: false
17
21
  }
18
22
  });
19
- const attestationResponse = await startRegistration(creationOptions);
23
+ const attestationResponse = await startRegistration({
24
+ optionsJSON: creationOptions
25
+ });
20
26
  const verificationResponse = await $fetch(registerEndpoint, {
21
27
  method: "POST",
22
28
  body: {
@@ -36,7 +42,10 @@ export function useWebAuthn(options = {}) {
36
42
  userName
37
43
  }
38
44
  });
39
- const assertionResponse = await startAuthentication(requestOptions);
45
+ const assertionResponse = await startAuthentication({
46
+ optionsJSON: requestOptions,
47
+ useBrowserAutofill
48
+ });
40
49
  const verificationResponse = await $fetch(authenticateEndpoint, {
41
50
  method: "POST",
42
51
  body: {
@@ -49,9 +49,9 @@ export function defineWebAuthnAuthenticateEventHandler({
49
49
  expectedChallenge,
50
50
  expectedOrigin: url.origin,
51
51
  expectedRPID: url.hostname,
52
- authenticator: {
53
- credentialID: credential.id,
54
- credentialPublicKey: new Uint8Array(base64URLStringToBuffer(credential.publicKey)),
52
+ credential: {
53
+ id: credential.id,
54
+ publicKey: new Uint8Array(base64URLStringToBuffer(credential.publicKey)),
55
55
  counter: credential.counter,
56
56
  transports: credential.transports
57
57
  }
@@ -76,11 +76,11 @@ export function defineWebAuthnRegisterEventHandler({
76
76
  await onSuccess(event, {
77
77
  user,
78
78
  credential: {
79
- id: verification.registrationInfo.credentialID,
80
- publicKey: bufferToBase64URLString(verification.registrationInfo.credentialPublicKey),
81
- counter: verification.registrationInfo.counter,
79
+ id: verification.registrationInfo.credential.id,
80
+ publicKey: bufferToBase64URLString(verification.registrationInfo.credential.publicKey),
81
+ counter: verification.registrationInfo.credential.counter,
82
82
  backedUp: verification.registrationInfo.credentialBackedUp,
83
- transports: body.response.response.transports
83
+ transports: verification.registrationInfo.credential.transports
84
84
  },
85
85
  registrationInfo: verification.registrationInfo
86
86
  });
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "nuxt-auth-utils",
3
- "version": "0.4.4",
3
+ "version": "0.5.0",
4
4
  "description": "Add Authentication to Nuxt applications with secured & sealed cookies sessions.",
5
5
  "repository": "atinux/nuxt-auth-utils",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
- "packageManager": "pnpm@9.12.0",
8
+ "packageManager": "pnpm@9.12.2",
9
9
  "exports": {
10
10
  ".": {
11
11
  "types": "./dist/types.d.ts",
@@ -36,15 +36,15 @@
36
36
  "@nuxt/kit": "^3.13.2",
37
37
  "defu": "^6.1.4",
38
38
  "hookable": "^5.5.3",
39
- "ofetch": "^1.4.0",
39
+ "ofetch": "^1.4.1",
40
40
  "ohash": "^1.1.4",
41
41
  "pathe": "^1.1.2",
42
42
  "scule": "^1.3.0",
43
43
  "uncrypto": "^0.1.3"
44
44
  },
45
45
  "peerDependencies": {
46
- "@simplewebauthn/browser": "^10.0.0",
47
- "@simplewebauthn/server": "^10.0.1"
46
+ "@simplewebauthn/browser": "^11.0.0",
47
+ "@simplewebauthn/server": "^11.0.0"
48
48
  },
49
49
  "peerDependenciesMeta": {
50
50
  "@simplewebauthn/browser": {
@@ -55,20 +55,20 @@
55
55
  }
56
56
  },
57
57
  "devDependencies": {
58
- "@iconify-json/simple-icons": "^1.2.6",
58
+ "@iconify-json/simple-icons": "^1.2.9",
59
59
  "@nuxt/devtools": "latest",
60
- "@nuxt/eslint-config": "^0.5.7",
60
+ "@nuxt/eslint-config": "^0.6.0",
61
61
  "@nuxt/module-builder": "^0.8.4",
62
62
  "@nuxt/schema": "^3.13.2",
63
- "@nuxt/test-utils": "^3.14.2",
64
- "@nuxt/ui": "^2.18.6",
65
- "@nuxt/ui-pro": "^1.4.3",
66
- "@simplewebauthn/types": "^10.0.0",
63
+ "@nuxt/test-utils": "^3.14.4",
64
+ "@nuxt/ui": "^2.18.7",
65
+ "@nuxt/ui-pro": "^1.4.4",
66
+ "@simplewebauthn/types": "^11.0.0",
67
67
  "changelogen": "^0.5.7",
68
- "eslint": "^9.12.0",
68
+ "eslint": "^9.13.0",
69
69
  "nuxt": "^3.13.2",
70
- "typescript": "^5.6.2",
71
- "vitest": "^2.1.2",
70
+ "typescript": "^5.6.3",
71
+ "vitest": "^2.1.3",
72
72
  "vue-tsc": "^2.1.6"
73
73
  }
74
74
  }