nuxt-auth-utils 0.5.3 → 0.5.4
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/dist/module.d.mts +5 -0
- package/dist/module.d.ts +5 -0
- package/dist/module.json +1 -1
- package/dist/runtime/app/composables/session.js +14 -3
- package/package.json +4 -3
package/dist/module.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
import { ScryptConfig } from '@adonisjs/hash/types';
|
|
3
|
+
import { SessionConfig } from 'h3';
|
|
3
4
|
|
|
4
5
|
interface ModuleOptions {
|
|
5
6
|
/**
|
|
@@ -22,6 +23,10 @@ declare module 'nuxt/schema' {
|
|
|
22
23
|
hash: {
|
|
23
24
|
scrypt: ScryptConfig;
|
|
24
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* Session configuration
|
|
28
|
+
*/
|
|
29
|
+
session: SessionConfig;
|
|
25
30
|
}
|
|
26
31
|
}
|
|
27
32
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
package/dist/module.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
import { ScryptConfig } from '@adonisjs/hash/types';
|
|
3
|
+
import { SessionConfig } from 'h3';
|
|
3
4
|
|
|
4
5
|
interface ModuleOptions {
|
|
5
6
|
/**
|
|
@@ -22,6 +23,10 @@ declare module 'nuxt/schema' {
|
|
|
22
23
|
hash: {
|
|
23
24
|
scrypt: ScryptConfig;
|
|
24
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* Session configuration
|
|
28
|
+
*/
|
|
29
|
+
session: SessionConfig;
|
|
25
30
|
}
|
|
26
31
|
}
|
|
27
32
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
package/dist/module.json
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { appendResponseHeader } from "h3";
|
|
2
|
+
import { useState, computed, useRequestFetch, useRequestEvent } from "#imports";
|
|
2
3
|
export function useUserSession() {
|
|
4
|
+
const serverEvent = import.meta.server ? useRequestEvent() : null;
|
|
3
5
|
const sessionState = useState("nuxt-session", () => ({}));
|
|
4
6
|
const authReadyState = useState("nuxt-auth-ready", () => false);
|
|
5
7
|
const clear = async () => {
|
|
6
|
-
await
|
|
8
|
+
await useRequestFetch()("/api/_auth/session", {
|
|
9
|
+
method: "DELETE",
|
|
10
|
+
onResponse({ response: { headers } }) {
|
|
11
|
+
if (import.meta.server && serverEvent) {
|
|
12
|
+
for (const setCookie of headers.getSetCookie()) {
|
|
13
|
+
appendResponseHeader(serverEvent, "Set-Cookie", setCookie);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
7
18
|
sessionState.value = {};
|
|
8
19
|
};
|
|
9
20
|
const fetch = async () => {
|
|
10
21
|
sessionState.value = await useRequestFetch()("/api/_auth/session", {
|
|
11
22
|
headers: {
|
|
12
|
-
|
|
23
|
+
accept: "application/json"
|
|
13
24
|
},
|
|
14
25
|
retry: false
|
|
15
26
|
}).catch(() => ({}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-auth-utils",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"description": "Add Authentication to Nuxt applications with secured & sealed cookies sessions.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"type": "module",
|
|
11
|
-
"packageManager": "pnpm@9.
|
|
11
|
+
"packageManager": "pnpm@9.13.0",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
14
|
"types": "./dist/types.d.ts",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"@adonisjs/hash": "^9.0.5",
|
|
39
39
|
"@nuxt/kit": "^3.14.159",
|
|
40
40
|
"defu": "^6.1.4",
|
|
41
|
+
"h3": "^1.13.0",
|
|
41
42
|
"hookable": "^5.5.3",
|
|
42
43
|
"ofetch": "^1.4.1",
|
|
43
44
|
"ohash": "^1.1.4",
|
|
@@ -71,7 +72,7 @@
|
|
|
71
72
|
"eslint": "^9.14.0",
|
|
72
73
|
"nuxt": "^3.14.159",
|
|
73
74
|
"typescript": "^5.6.3",
|
|
74
|
-
"vitest": "^2.1.
|
|
75
|
+
"vitest": "^2.1.5",
|
|
75
76
|
"vue-tsc": "^2.1.10"
|
|
76
77
|
}
|
|
77
78
|
}
|