nuxt-auth-utils 0.0.15 → 0.0.16
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 +4 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -0
- package/dist/runtime/server/lib/oauth/google.d.ts +0 -5
- package/dist/runtime/server/tsconfig.json +3 -0
- package/dist/runtime/server/utils/session.d.ts +6 -0
- package/dist/runtime/server/utils/session.mjs +6 -0
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -90,6 +90,7 @@ The following helpers are auto-imported in your `server/` directory.
|
|
|
90
90
|
```ts
|
|
91
91
|
// Set a user session, note that this data is encrypted in the cookie but can be decrypted with an API call
|
|
92
92
|
// Only store the data that allow you to recognize an user, but do not store sensitive data
|
|
93
|
+
// Merges new data with existing data using defu()
|
|
93
94
|
await setUserSession(event, {
|
|
94
95
|
user: {
|
|
95
96
|
// ... user data
|
|
@@ -98,6 +99,9 @@ await setUserSession(event, {
|
|
|
98
99
|
// Any extra fields
|
|
99
100
|
})
|
|
100
101
|
|
|
102
|
+
// Replace a user session. Same behaviour as setUserSession, except it does not merge data with existing data
|
|
103
|
+
await replaceUserSession(event, data)
|
|
104
|
+
|
|
101
105
|
// Get the current user session
|
|
102
106
|
const session = await getUserSession(event)
|
|
103
107
|
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -27,10 +27,5 @@ export interface OAuthGoogleConfig {
|
|
|
27
27
|
* @default 'https://oauth2.googleapis.com/token'
|
|
28
28
|
*/
|
|
29
29
|
tokenURL?: string;
|
|
30
|
-
/**
|
|
31
|
-
* Redirect URL post authenticating via google
|
|
32
|
-
* @default '/auth/google'
|
|
33
|
-
*/
|
|
34
|
-
redirectUrl: '/auth/google';
|
|
35
30
|
}
|
|
36
31
|
export declare function googleEventHandler({ config, onSuccess, onError, }: OAuthConfig<OAuthGoogleConfig>): import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
|
|
@@ -20,5 +20,11 @@ export declare function getUserSession(event: H3Event): Promise<UserSession>;
|
|
|
20
20
|
* @param data User session data, please only store public information since it can be decoded with API calls
|
|
21
21
|
*/
|
|
22
22
|
export declare function setUserSession(event: H3Event, data: UserSession): Promise<UserSession>;
|
|
23
|
+
/**
|
|
24
|
+
* Replace a user session
|
|
25
|
+
* @param event
|
|
26
|
+
* @param data User session data, please only store public information since it can be decoded with API calls
|
|
27
|
+
*/
|
|
28
|
+
export declare function replaceUserSession(event: H3Event, data: UserSession): Promise<UserSession>;
|
|
23
29
|
export declare function clearUserSession(event: H3Event): Promise<boolean>;
|
|
24
30
|
export declare function requireUserSession(event: H3Event): Promise<UserSession>;
|
|
@@ -11,6 +11,12 @@ export async function setUserSession(event, data) {
|
|
|
11
11
|
await session.update(defu(data, session.data));
|
|
12
12
|
return session.data;
|
|
13
13
|
}
|
|
14
|
+
export async function replaceUserSession(event, data) {
|
|
15
|
+
const session = await _useSession(event);
|
|
16
|
+
await session.clear();
|
|
17
|
+
await session.update(data);
|
|
18
|
+
return session.data;
|
|
19
|
+
}
|
|
14
20
|
export async function clearUserSession(event) {
|
|
15
21
|
const session = await _useSession(event);
|
|
16
22
|
await sessionHooks.callHookParallel("clear", session.data, event);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-auth-utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "Minimalist Auth module for Nuxt with SSR",
|
|
5
5
|
"repository": "Atinux/nuxt-auth-utils",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,25 +30,25 @@
|
|
|
30
30
|
"test:watch": "vitest watch"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@nuxt/kit": "^3.
|
|
33
|
+
"@nuxt/kit": "^3.10.1",
|
|
34
34
|
"defu": "^6.1.4",
|
|
35
35
|
"hookable": "^5.5.3",
|
|
36
36
|
"ofetch": "^1.3.3",
|
|
37
37
|
"ohash": "^1.1.3"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@iconify-json/simple-icons": "^1.1.
|
|
40
|
+
"@iconify-json/simple-icons": "^1.1.91",
|
|
41
41
|
"@nuxt/devtools": "latest",
|
|
42
42
|
"@nuxt/eslint-config": "^0.2.0",
|
|
43
43
|
"@nuxt/module-builder": "^0.5.5",
|
|
44
|
-
"@nuxt/schema": "^3.
|
|
44
|
+
"@nuxt/schema": "^3.10.1",
|
|
45
45
|
"@nuxt/test-utils": "^3.11.0",
|
|
46
|
-
"@nuxt/ui": "^2.
|
|
47
|
-
"@nuxt/ui-pro": "^0.7.
|
|
48
|
-
"@types/node": "^20.11.
|
|
46
|
+
"@nuxt/ui": "^2.13.0",
|
|
47
|
+
"@nuxt/ui-pro": "^0.7.5",
|
|
48
|
+
"@types/node": "^20.11.17",
|
|
49
49
|
"changelogen": "^0.5.5",
|
|
50
50
|
"eslint": "^8.56.0",
|
|
51
|
-
"nuxt": "^3.
|
|
51
|
+
"nuxt": "^3.10.1",
|
|
52
52
|
"typescript": "^5.3.3",
|
|
53
53
|
"vitest": "^1.2.2",
|
|
54
54
|
"vue-tsc": "^1.8.27"
|