nextauthz 1.3.27 → 1.3.28
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/index.d.mts +19 -21
- package/dist/index.d.ts +19 -21
- package/dist/index.js +2 -7
- package/dist/index.mjs +1 -6
- package/package.json +1 -1
- package/src/index.ts +1 -12
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
3
|
-
import React__default from 'react';
|
|
2
|
+
import React, { ReactNode } from 'react';
|
|
4
3
|
|
|
5
|
-
type User
|
|
4
|
+
type User = {
|
|
6
5
|
[key: string]: any;
|
|
7
6
|
};
|
|
8
7
|
|
|
9
|
-
type AuthContextType<UserType extends User
|
|
8
|
+
type AuthContextType<UserType extends User = User> = {
|
|
10
9
|
user: UserType | null;
|
|
11
10
|
role: string | null;
|
|
12
11
|
isAuthenticated: boolean;
|
|
@@ -16,32 +15,31 @@ type AuthContextType<UserType extends User$1 = User$1> = {
|
|
|
16
15
|
setUser: (user: UserType | null) => void;
|
|
17
16
|
tokenKey: string;
|
|
18
17
|
};
|
|
18
|
+
declare function createAuthContext<UserType extends User = User>(option?: {
|
|
19
|
+
storage?: 'localStorage' | 'sessionStorage' | 'cookie';
|
|
20
|
+
tokenKey?: string;
|
|
21
|
+
rolePath?: string;
|
|
22
|
+
}): {
|
|
23
|
+
AuthProvider: ({ children }: {
|
|
24
|
+
children: ReactNode;
|
|
25
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
26
|
+
useAuth: () => AuthContextType<UserType>;
|
|
27
|
+
tokenKey: string;
|
|
28
|
+
};
|
|
19
29
|
|
|
20
30
|
type AuthGuardProps = {
|
|
21
|
-
children:
|
|
31
|
+
children: React.ReactNode;
|
|
22
32
|
redirectTo?: string;
|
|
23
|
-
fallback?:
|
|
33
|
+
fallback?: React.ReactNode;
|
|
24
34
|
};
|
|
25
35
|
declare const AuthGuard: ({ children, redirectTo, fallback, }: AuthGuardProps) => react_jsx_runtime.JSX.Element | null;
|
|
26
36
|
|
|
27
37
|
type RoleGuardProps = {
|
|
28
|
-
children:
|
|
38
|
+
children: React.ReactNode;
|
|
29
39
|
allowedRoles: string[];
|
|
30
40
|
redirectTo?: string;
|
|
31
|
-
fallback?:
|
|
41
|
+
fallback?: React.ReactNode;
|
|
32
42
|
};
|
|
33
43
|
declare const RoleGuard: ({ children, allowedRoles, redirectTo, fallback, }: RoleGuardProps) => react_jsx_runtime.JSX.Element | null;
|
|
34
44
|
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Factory to create isolated auth instance
|
|
38
|
-
*/
|
|
39
|
-
declare function createAppAuth(storage: 'localStorage' | 'sessionStorage' | 'cookie', tokenKey?: string): {
|
|
40
|
-
AuthProvider: ({ children }: {
|
|
41
|
-
children: React.ReactNode;
|
|
42
|
-
}) => react_jsx_runtime.JSX.Element;
|
|
43
|
-
useAuth: () => AuthContextType<User$1>;
|
|
44
|
-
tokenKey: string;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export { AuthGuard, RoleGuard, type User, createAppAuth };
|
|
45
|
+
export { AuthGuard, RoleGuard, createAuthContext };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
3
|
-
import React__default from 'react';
|
|
2
|
+
import React, { ReactNode } from 'react';
|
|
4
3
|
|
|
5
|
-
type User
|
|
4
|
+
type User = {
|
|
6
5
|
[key: string]: any;
|
|
7
6
|
};
|
|
8
7
|
|
|
9
|
-
type AuthContextType<UserType extends User
|
|
8
|
+
type AuthContextType<UserType extends User = User> = {
|
|
10
9
|
user: UserType | null;
|
|
11
10
|
role: string | null;
|
|
12
11
|
isAuthenticated: boolean;
|
|
@@ -16,32 +15,31 @@ type AuthContextType<UserType extends User$1 = User$1> = {
|
|
|
16
15
|
setUser: (user: UserType | null) => void;
|
|
17
16
|
tokenKey: string;
|
|
18
17
|
};
|
|
18
|
+
declare function createAuthContext<UserType extends User = User>(option?: {
|
|
19
|
+
storage?: 'localStorage' | 'sessionStorage' | 'cookie';
|
|
20
|
+
tokenKey?: string;
|
|
21
|
+
rolePath?: string;
|
|
22
|
+
}): {
|
|
23
|
+
AuthProvider: ({ children }: {
|
|
24
|
+
children: ReactNode;
|
|
25
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
26
|
+
useAuth: () => AuthContextType<UserType>;
|
|
27
|
+
tokenKey: string;
|
|
28
|
+
};
|
|
19
29
|
|
|
20
30
|
type AuthGuardProps = {
|
|
21
|
-
children:
|
|
31
|
+
children: React.ReactNode;
|
|
22
32
|
redirectTo?: string;
|
|
23
|
-
fallback?:
|
|
33
|
+
fallback?: React.ReactNode;
|
|
24
34
|
};
|
|
25
35
|
declare const AuthGuard: ({ children, redirectTo, fallback, }: AuthGuardProps) => react_jsx_runtime.JSX.Element | null;
|
|
26
36
|
|
|
27
37
|
type RoleGuardProps = {
|
|
28
|
-
children:
|
|
38
|
+
children: React.ReactNode;
|
|
29
39
|
allowedRoles: string[];
|
|
30
40
|
redirectTo?: string;
|
|
31
|
-
fallback?:
|
|
41
|
+
fallback?: React.ReactNode;
|
|
32
42
|
};
|
|
33
43
|
declare const RoleGuard: ({ children, allowedRoles, redirectTo, fallback, }: RoleGuardProps) => react_jsx_runtime.JSX.Element | null;
|
|
34
44
|
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Factory to create isolated auth instance
|
|
38
|
-
*/
|
|
39
|
-
declare function createAppAuth(storage: 'localStorage' | 'sessionStorage' | 'cookie', tokenKey?: string): {
|
|
40
|
-
AuthProvider: ({ children }: {
|
|
41
|
-
children: React.ReactNode;
|
|
42
|
-
}) => react_jsx_runtime.JSX.Element;
|
|
43
|
-
useAuth: () => AuthContextType<User$1>;
|
|
44
|
-
tokenKey: string;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export { AuthGuard, RoleGuard, type User, createAppAuth };
|
|
45
|
+
export { AuthGuard, RoleGuard, createAuthContext };
|
package/dist/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var index_exports = {};
|
|
|
23
23
|
__export(index_exports, {
|
|
24
24
|
AuthGuard: () => AuthGuard_default,
|
|
25
25
|
RoleGuard: () => RoleGuard_default,
|
|
26
|
-
|
|
26
|
+
createAuthContext: () => createAuthContext
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(index_exports);
|
|
29
29
|
|
|
@@ -201,14 +201,9 @@ var RoleGuard = ({
|
|
|
201
201
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children });
|
|
202
202
|
};
|
|
203
203
|
var RoleGuard_default = RoleGuard;
|
|
204
|
-
|
|
205
|
-
// src/index.ts
|
|
206
|
-
function createAppAuth(storage, tokenKey = "access_token") {
|
|
207
|
-
return createAuthContext({ storage, tokenKey });
|
|
208
|
-
}
|
|
209
204
|
// Annotate the CommonJS export names for ESM import in node:
|
|
210
205
|
0 && (module.exports = {
|
|
211
206
|
AuthGuard,
|
|
212
207
|
RoleGuard,
|
|
213
|
-
|
|
208
|
+
createAuthContext
|
|
214
209
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -174,13 +174,8 @@ var RoleGuard = ({
|
|
|
174
174
|
return /* @__PURE__ */ jsx3(Fragment2, { children });
|
|
175
175
|
};
|
|
176
176
|
var RoleGuard_default = RoleGuard;
|
|
177
|
-
|
|
178
|
-
// src/index.ts
|
|
179
|
-
function createAppAuth(storage, tokenKey = "access_token") {
|
|
180
|
-
return createAuthContext({ storage, tokenKey });
|
|
181
|
-
}
|
|
182
177
|
export {
|
|
183
178
|
AuthGuard_default as AuthGuard,
|
|
184
179
|
RoleGuard_default as RoleGuard,
|
|
185
|
-
|
|
180
|
+
createAuthContext
|
|
186
181
|
};
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export { createAuthContext } from './AuthProvider'
|
|
4
4
|
|
|
5
5
|
export { default as AuthGuard } from './AuthGuard'
|
|
6
6
|
export { default as RoleGuard } from './RoleGuard'
|
|
7
7
|
|
|
8
|
-
export type User = Record<string, any>
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Factory to create isolated auth instance
|
|
12
|
-
*/
|
|
13
|
-
export function createAppAuth(
|
|
14
|
-
storage: 'localStorage' | 'sessionStorage' | 'cookie',
|
|
15
|
-
tokenKey: string = 'access_token' // <-- default token key
|
|
16
|
-
) {
|
|
17
|
-
return createAuthContext({ storage, tokenKey })
|
|
18
|
-
}
|