dn-react-router-toolkit 0.1.5 → 0.1.6
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.
|
@@ -6,12 +6,12 @@ import '../file-kit/object_storage.mjs';
|
|
|
6
6
|
import '@aws-sdk/client-s3';
|
|
7
7
|
import './repository.mjs';
|
|
8
8
|
|
|
9
|
-
type
|
|
10
|
-
type InputFN = (auth?: JWTPayload) =>
|
|
11
|
-
type WithAuthHandler<T extends LoaderFunctionArgs | ActionFunctionArgs> = (fn: InputFN) =>
|
|
12
|
-
declare function createWithAuthHandler<T extends LoaderFunctionArgs | ActionFunctionArgs>({ JWT_MANAGER, AUTH
|
|
9
|
+
type Handler<T extends LoaderFunctionArgs | ActionFunctionArgs> = (arg: T) => Promise<unknown> | unknown;
|
|
10
|
+
type InputFN = (auth?: JWTPayload) => Handler<LoaderFunctionArgs> | Handler<ActionFunctionArgs>;
|
|
11
|
+
type WithAuthHandler<T extends LoaderFunctionArgs | ActionFunctionArgs> = (fn: InputFN) => Handler<T>;
|
|
12
|
+
declare function createWithAuthHandler<T extends LoaderFunctionArgs | ActionFunctionArgs>({ JWT_MANAGER, AUTH }: {
|
|
13
13
|
JWT_MANAGER: JWTManager;
|
|
14
14
|
AUTH: AuthService;
|
|
15
|
-
}):
|
|
15
|
+
}): <THandler extends Handler<T>>(fn: (auth?: JWTPayload) => THandler) => THandler;
|
|
16
16
|
|
|
17
17
|
export { type WithAuthHandler, createWithAuthHandler };
|
|
@@ -6,12 +6,12 @@ import '../file-kit/object_storage.js';
|
|
|
6
6
|
import '@aws-sdk/client-s3';
|
|
7
7
|
import './repository.js';
|
|
8
8
|
|
|
9
|
-
type
|
|
10
|
-
type InputFN = (auth?: JWTPayload) =>
|
|
11
|
-
type WithAuthHandler<T extends LoaderFunctionArgs | ActionFunctionArgs> = (fn: InputFN) =>
|
|
12
|
-
declare function createWithAuthHandler<T extends LoaderFunctionArgs | ActionFunctionArgs>({ JWT_MANAGER, AUTH
|
|
9
|
+
type Handler<T extends LoaderFunctionArgs | ActionFunctionArgs> = (arg: T) => Promise<unknown> | unknown;
|
|
10
|
+
type InputFN = (auth?: JWTPayload) => Handler<LoaderFunctionArgs> | Handler<ActionFunctionArgs>;
|
|
11
|
+
type WithAuthHandler<T extends LoaderFunctionArgs | ActionFunctionArgs> = (fn: InputFN) => Handler<T>;
|
|
12
|
+
declare function createWithAuthHandler<T extends LoaderFunctionArgs | ActionFunctionArgs>({ JWT_MANAGER, AUTH }: {
|
|
13
13
|
JWT_MANAGER: JWTManager;
|
|
14
14
|
AUTH: AuthService;
|
|
15
|
-
}):
|
|
15
|
+
}): <THandler extends Handler<T>>(fn: (auth?: JWTPayload) => THandler) => THandler;
|
|
16
16
|
|
|
17
17
|
export { type WithAuthHandler, createWithAuthHandler };
|
|
@@ -54,12 +54,9 @@ var REFRESH_TOKEN_COOKIE = (0, import_react_router.createCookie)(REFRESH_TOKEN_K
|
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
// src/auth-kit/with_auth.ts
|
|
57
|
-
function createWithAuthHandler({
|
|
58
|
-
JWT_MANAGER,
|
|
59
|
-
AUTH
|
|
60
|
-
}) {
|
|
57
|
+
function createWithAuthHandler({ JWT_MANAGER, AUTH }) {
|
|
61
58
|
return function(fn) {
|
|
62
|
-
|
|
59
|
+
const handler = async function(arg) {
|
|
63
60
|
const cookie = arg.request.headers.get("cookie");
|
|
64
61
|
const accessToken = await ACCESS_TOKEN_COOKIE.parse(cookie);
|
|
65
62
|
if (accessToken) {
|
|
@@ -98,6 +95,7 @@ function createWithAuthHandler({
|
|
|
98
95
|
}
|
|
99
96
|
return fn(void 0)(arg);
|
|
100
97
|
};
|
|
98
|
+
return handler;
|
|
101
99
|
};
|
|
102
100
|
}
|
|
103
101
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -18,12 +18,9 @@ var REFRESH_TOKEN_COOKIE = createCookie(REFRESH_TOKEN_KEY, {
|
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
// src/auth-kit/with_auth.ts
|
|
21
|
-
function createWithAuthHandler({
|
|
22
|
-
JWT_MANAGER,
|
|
23
|
-
AUTH
|
|
24
|
-
}) {
|
|
21
|
+
function createWithAuthHandler({ JWT_MANAGER, AUTH }) {
|
|
25
22
|
return function(fn) {
|
|
26
|
-
|
|
23
|
+
const handler = async function(arg) {
|
|
27
24
|
const cookie = arg.request.headers.get("cookie");
|
|
28
25
|
const accessToken = await ACCESS_TOKEN_COOKIE.parse(cookie);
|
|
29
26
|
if (accessToken) {
|
|
@@ -62,6 +59,7 @@ function createWithAuthHandler({
|
|
|
62
59
|
}
|
|
63
60
|
return fn(void 0)(arg);
|
|
64
61
|
};
|
|
62
|
+
return handler;
|
|
65
63
|
};
|
|
66
64
|
}
|
|
67
65
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dn-react-router-toolkit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"types": "./dist/index.d.ts",
|
|
5
5
|
"main": "./dist/index.mjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -76,8 +76,8 @@
|
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"drizzle-orm": "^0.44",
|
|
79
|
-
"react": "^
|
|
80
|
-
"react-dom": "^
|
|
79
|
+
"react": "^19",
|
|
80
|
+
"react-dom": "^19",
|
|
81
81
|
"react-router": "^7"
|
|
82
82
|
}
|
|
83
83
|
}
|