nuxt-auth-utils 0.0.15 → 0.0.17
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 +14 -5
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -0
- package/dist/runtime/server/api/session.get.d.ts +1 -1
- 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 +7 -1
- package/dist/runtime/server/utils/session.mjs +6 -0
- package/dist/runtime/types/index.d.ts +1 -1
- package/dist/runtime/types/session.d.ts +3 -1
- 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
|
|
|
@@ -112,10 +116,15 @@ You can define the type for your user session by creating a type declaration fil
|
|
|
112
116
|
|
|
113
117
|
```ts
|
|
114
118
|
declare module '#auth-utils' {
|
|
119
|
+
interface User {
|
|
120
|
+
// Add your own fields
|
|
121
|
+
}
|
|
122
|
+
|
|
115
123
|
interface UserSession {
|
|
116
|
-
//
|
|
124
|
+
// Add your own fields
|
|
117
125
|
}
|
|
118
126
|
}
|
|
127
|
+
|
|
119
128
|
export {}
|
|
120
129
|
```
|
|
121
130
|
|
|
@@ -239,14 +248,14 @@ npm run release
|
|
|
239
248
|
```
|
|
240
249
|
|
|
241
250
|
<!-- Badges -->
|
|
242
|
-
[npm-version-src]: https://img.shields.io/npm/v/nuxt-auth-utils/latest.svg?style=flat&colorA=
|
|
251
|
+
[npm-version-src]: https://img.shields.io/npm/v/nuxt-auth-utils/latest.svg?style=flat&colorA=020420&colorB=00DC82
|
|
243
252
|
[npm-version-href]: https://npmjs.com/package/nuxt-auth-utils
|
|
244
253
|
|
|
245
|
-
[npm-downloads-src]: https://img.shields.io/npm/dm/nuxt-auth-utils.svg?style=flat&colorA=
|
|
254
|
+
[npm-downloads-src]: https://img.shields.io/npm/dm/nuxt-auth-utils.svg?style=flat&colorA=020420&colorB=00DC82
|
|
246
255
|
[npm-downloads-href]: https://npmjs.com/package/nuxt-auth-utils
|
|
247
256
|
|
|
248
|
-
[license-src]: https://img.shields.io/npm/l/nuxt-auth-utils.svg?style=flat&colorA=
|
|
257
|
+
[license-src]: https://img.shields.io/npm/l/nuxt-auth-utils.svg?style=flat&colorA=020420&colorB=00DC82
|
|
249
258
|
[license-href]: https://npmjs.com/package/nuxt-auth-utils
|
|
250
259
|
|
|
251
|
-
[nuxt-src]: https://img.shields.io/badge/Nuxt-
|
|
260
|
+
[nuxt-src]: https://img.shields.io/badge/Nuxt-020420?logo=nuxt.js
|
|
252
261
|
[nuxt-href]: https://nuxt.com
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<
|
|
1
|
+
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
|
|
2
2
|
export default _default;
|
|
@@ -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
|
-
export declare function requireUserSession(event: H3Event): Promise<
|
|
30
|
+
export declare function requireUserSession(event: H3Event): Promise<any>;
|
|
@@ -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);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { UserSession } from './session';
|
|
1
|
+
export type { UserSession, User } from './session';
|
|
2
2
|
export type { OAuthConfig } from './oauth-config';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-auth-utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
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.2",
|
|
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.2",
|
|
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.19",
|
|
49
49
|
"changelogen": "^0.5.5",
|
|
50
50
|
"eslint": "^8.56.0",
|
|
51
|
-
"nuxt": "^3.
|
|
51
|
+
"nuxt": "^3.10.2",
|
|
52
52
|
"typescript": "^5.3.3",
|
|
53
53
|
"vitest": "^1.2.2",
|
|
54
54
|
"vue-tsc": "^1.8.27"
|