dn-react-router-toolkit 0.3.11 → 0.4.1
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/api/create_handler.d.mts +3 -3
- package/dist/api/create_handler.d.ts +3 -3
- package/dist/api/create_handler.js +6 -38
- package/dist/api/create_handler.mjs +6 -55
- package/dist/api/index.js +6 -36
- package/dist/api/index.mjs +6 -55
- package/dist/auth/cookie_store.d.mts +10 -10
- package/dist/auth/cookie_store.d.ts +10 -10
- package/dist/auth/cookie_store.js +15 -11
- package/dist/auth/cookie_store.mjs +14 -10
- package/dist/auth/index.d.mts +3 -2
- package/dist/auth/index.d.ts +3 -2
- package/dist/auth/index.js +18 -17
- package/dist/auth/index.mjs +16 -15
- package/dist/auth/with_auth.js +2 -2
- package/dist/auth/with_auth.mjs +2 -2
- package/dist/index.d.mts +2 -8
- package/dist/index.d.ts +2 -8
- package/dist/index.js +0 -6
- package/dist/index.mjs +0 -2
- package/package.json +56 -114
- package/dist/auth/client/index.d.mts +0 -3
- package/dist/auth/client/index.d.ts +0 -3
- package/dist/auth/client/index.js +0 -58
- package/dist/auth/client/index.mjs +0 -21
- package/dist/auth/client/redirect_page.d.mts +0 -6
- package/dist/auth/client/redirect_page.d.ts +0 -6
- package/dist/auth/client/redirect_page.js +0 -53
- package/dist/auth/client/redirect_page.mjs +0 -18
- package/dist/auth/server/index.d.mts +0 -1
- package/dist/auth/server/index.d.ts +0 -1
- package/dist/auth/server/index.js +0 -24
- package/dist/auth/server/index.mjs +0 -2
- package/dist/file/client/index.d.mts +0 -1
- package/dist/file/client/index.d.ts +0 -1
- package/dist/file/client/index.js +0 -24
- package/dist/file/client/index.mjs +0 -2
- package/dist/file/index.d.mts +0 -1
- package/dist/file/index.d.ts +0 -1
- package/dist/file/index.js +0 -24
- package/dist/file/index.mjs +0 -2
- package/dist/file/server/index.d.mts +0 -1
- package/dist/file/server/index.d.ts +0 -1
- package/dist/file/server/index.js +0 -24
- package/dist/file/server/index.mjs +0 -2
- package/dist/http/index.d.mts +0 -1
- package/dist/http/index.d.ts +0 -1
- package/dist/http/index.js +0 -24
- package/dist/http/index.mjs +0 -2
- package/dist/modal/index.d.mts +0 -1
- package/dist/modal/index.d.ts +0 -1
- package/dist/modal/index.js +0 -24
- package/dist/modal/index.mjs +0 -2
- package/dist/text_editor/index.d.mts +0 -1
- package/dist/text_editor/index.d.ts +0 -1
- package/dist/text_editor/index.js +0 -24
- package/dist/text_editor/index.mjs +0 -2
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { LoaderFunctionArgs, ActionFunctionArgs } from 'react-router';
|
|
2
|
-
import { AuthService, PasswordRecoveryService, ThirdpartyAuth } from 'dn-react-toolkit/auth/server';
|
|
2
|
+
import { AuthService, PasswordRecoveryService, ThirdpartyAuth, JWTManager, ThirdpartySignupTokenPayload } from 'dn-react-toolkit/auth/server';
|
|
3
3
|
import { FileService } from 'dn-react-toolkit/file/server';
|
|
4
4
|
|
|
5
|
-
declare const createAPIHandler: <TFile>({ authService, fileService, passwordRecoveryService, getThirdPartyAuth,
|
|
5
|
+
declare const createAPIHandler: <TFile>({ authService, fileService, passwordRecoveryService, getThirdPartyAuth, signupTokenManager, }: {
|
|
6
6
|
authService: AuthService<TFile>;
|
|
7
7
|
fileService: FileService<TFile>;
|
|
8
8
|
passwordRecoveryService: PasswordRecoveryService;
|
|
9
9
|
getThirdPartyAuth: (provider: string) => ThirdpartyAuth;
|
|
10
|
-
|
|
10
|
+
signupTokenManager: JWTManager<ThirdpartySignupTokenPayload>;
|
|
11
11
|
}) => (args: LoaderFunctionArgs | ActionFunctionArgs) => Promise<(({ request }: LoaderFunctionArgs<any> | ActionFunctionArgs<any>) => Promise<Response>) | Response>;
|
|
12
12
|
|
|
13
13
|
export { createAPIHandler };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { LoaderFunctionArgs, ActionFunctionArgs } from 'react-router';
|
|
2
|
-
import { AuthService, PasswordRecoveryService, ThirdpartyAuth } from 'dn-react-toolkit/auth/server';
|
|
2
|
+
import { AuthService, PasswordRecoveryService, ThirdpartyAuth, JWTManager, ThirdpartySignupTokenPayload } from 'dn-react-toolkit/auth/server';
|
|
3
3
|
import { FileService } from 'dn-react-toolkit/file/server';
|
|
4
4
|
|
|
5
|
-
declare const createAPIHandler: <TFile>({ authService, fileService, passwordRecoveryService, getThirdPartyAuth,
|
|
5
|
+
declare const createAPIHandler: <TFile>({ authService, fileService, passwordRecoveryService, getThirdPartyAuth, signupTokenManager, }: {
|
|
6
6
|
authService: AuthService<TFile>;
|
|
7
7
|
fileService: FileService<TFile>;
|
|
8
8
|
passwordRecoveryService: PasswordRecoveryService;
|
|
9
9
|
getThirdPartyAuth: (provider: string) => ThirdpartyAuth;
|
|
10
|
-
|
|
10
|
+
signupTokenManager: JWTManager<ThirdpartySignupTokenPayload>;
|
|
11
11
|
}) => (args: LoaderFunctionArgs | ActionFunctionArgs) => Promise<(({ request }: LoaderFunctionArgs<any> | ActionFunctionArgs<any>) => Promise<Response>) | Response>;
|
|
12
12
|
|
|
13
13
|
export { createAPIHandler };
|
|
@@ -15,7 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
}
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
19
|
|
|
21
20
|
// src/api/create_handler.ts
|
|
@@ -24,22 +23,9 @@ __export(create_handler_exports, {
|
|
|
24
23
|
createAPIHandler: () => createAPIHandler
|
|
25
24
|
});
|
|
26
25
|
module.exports = __toCommonJS(create_handler_exports);
|
|
27
|
-
|
|
28
|
-
// src/http/index.ts
|
|
29
|
-
var http_exports = {};
|
|
30
|
-
__reExport(http_exports, require("dn-react-toolkit/http"));
|
|
31
|
-
|
|
32
|
-
// src/api/create_handler.ts
|
|
26
|
+
var import_http = require("dn-react-toolkit/http");
|
|
33
27
|
var import_server = require("dn-react-toolkit/auth/server");
|
|
34
28
|
|
|
35
|
-
// src/auth/index.ts
|
|
36
|
-
var auth_exports = {};
|
|
37
|
-
__export(auth_exports, {
|
|
38
|
-
ReactRouterCookieStore: () => ReactRouterCookieStore,
|
|
39
|
-
createWithAuthHandler: () => createWithAuthHandler
|
|
40
|
-
});
|
|
41
|
-
__reExport(auth_exports, require("dn-react-toolkit/auth"));
|
|
42
|
-
|
|
43
29
|
// src/auth/with_auth.ts
|
|
44
30
|
var toResponse = (result) => {
|
|
45
31
|
if (result instanceof Response) {
|
|
@@ -64,7 +50,7 @@ function createWithAuthHandler({ authService }) {
|
|
|
64
50
|
arg.request
|
|
65
51
|
);
|
|
66
52
|
if (accessToken) {
|
|
67
|
-
const payload = await authService.
|
|
53
|
+
const payload = await authService.accessTokenManager.verify(
|
|
68
54
|
accessToken
|
|
69
55
|
);
|
|
70
56
|
if (payload) {
|
|
@@ -84,7 +70,7 @@ function createWithAuthHandler({ authService }) {
|
|
|
84
70
|
);
|
|
85
71
|
const headers = new Headers();
|
|
86
72
|
headers.append("Set-Cookie", setCookieHeader);
|
|
87
|
-
const payload = authService.
|
|
73
|
+
const payload = authService.accessTokenManager.decode(
|
|
88
74
|
newAccessToken
|
|
89
75
|
);
|
|
90
76
|
return respond(payload, headers);
|
|
@@ -106,24 +92,6 @@ function createWithAuthHandler({ authService }) {
|
|
|
106
92
|
|
|
107
93
|
// src/auth/cookie_store.ts
|
|
108
94
|
var import_react_router = require("react-router");
|
|
109
|
-
var ReactRouterCookieStore = class {
|
|
110
|
-
store;
|
|
111
|
-
constructor(key) {
|
|
112
|
-
this.store = (0, import_react_router.createCookie)(key, {
|
|
113
|
-
path: "/",
|
|
114
|
-
httpOnly: process.env.NODE_ENV === "production",
|
|
115
|
-
secure: process.env.NODE_ENV === "production",
|
|
116
|
-
sameSite: "strict"
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
parse(request) {
|
|
120
|
-
const cookieHeader = request.headers.get("cookie") || "";
|
|
121
|
-
return this.store.parse(cookieHeader);
|
|
122
|
-
}
|
|
123
|
-
serialize(value, options) {
|
|
124
|
-
return this.store.serialize(value, options);
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
95
|
|
|
128
96
|
// src/api/create_handler.ts
|
|
129
97
|
var import_server2 = require("dn-react-toolkit/file/server");
|
|
@@ -132,7 +100,7 @@ var createAPIHandler = ({
|
|
|
132
100
|
fileService,
|
|
133
101
|
passwordRecoveryService,
|
|
134
102
|
getThirdPartyAuth,
|
|
135
|
-
|
|
103
|
+
signupTokenManager
|
|
136
104
|
}) => {
|
|
137
105
|
const handler = async (args) => {
|
|
138
106
|
const { request, params } = args;
|
|
@@ -211,7 +179,7 @@ var createAPIHandler = ({
|
|
|
211
179
|
return (0, import_server.signUpWithThirdpartyHandler)(request, {
|
|
212
180
|
authService,
|
|
213
181
|
fileService,
|
|
214
|
-
|
|
182
|
+
signupTokenManager
|
|
215
183
|
});
|
|
216
184
|
}
|
|
217
185
|
}
|
|
@@ -266,7 +234,7 @@ var createAPIHandler = ({
|
|
|
266
234
|
}
|
|
267
235
|
}
|
|
268
236
|
default: {
|
|
269
|
-
return (0,
|
|
237
|
+
return (0, import_http.NOT_FOUND)();
|
|
270
238
|
}
|
|
271
239
|
}
|
|
272
240
|
};
|
|
@@ -1,27 +1,5 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
-
|
|
19
|
-
// src/http/index.ts
|
|
20
|
-
var http_exports = {};
|
|
21
|
-
__reExport(http_exports, http_star);
|
|
22
|
-
import * as http_star from "dn-react-toolkit/http";
|
|
23
|
-
|
|
24
1
|
// src/api/create_handler.ts
|
|
2
|
+
import { NOT_FOUND } from "dn-react-toolkit/http";
|
|
25
3
|
import {
|
|
26
4
|
findAuthHandler,
|
|
27
5
|
loginHandler,
|
|
@@ -35,15 +13,6 @@ import {
|
|
|
35
13
|
thirdpartyAuthCallbackHandler
|
|
36
14
|
} from "dn-react-toolkit/auth/server";
|
|
37
15
|
|
|
38
|
-
// src/auth/index.ts
|
|
39
|
-
var auth_exports = {};
|
|
40
|
-
__export(auth_exports, {
|
|
41
|
-
ReactRouterCookieStore: () => ReactRouterCookieStore,
|
|
42
|
-
createWithAuthHandler: () => createWithAuthHandler
|
|
43
|
-
});
|
|
44
|
-
__reExport(auth_exports, auth_star);
|
|
45
|
-
import * as auth_star from "dn-react-toolkit/auth";
|
|
46
|
-
|
|
47
16
|
// src/auth/with_auth.ts
|
|
48
17
|
var toResponse = (result) => {
|
|
49
18
|
if (result instanceof Response) {
|
|
@@ -68,7 +37,7 @@ function createWithAuthHandler({ authService }) {
|
|
|
68
37
|
arg.request
|
|
69
38
|
);
|
|
70
39
|
if (accessToken) {
|
|
71
|
-
const payload = await authService.
|
|
40
|
+
const payload = await authService.accessTokenManager.verify(
|
|
72
41
|
accessToken
|
|
73
42
|
);
|
|
74
43
|
if (payload) {
|
|
@@ -88,7 +57,7 @@ function createWithAuthHandler({ authService }) {
|
|
|
88
57
|
);
|
|
89
58
|
const headers = new Headers();
|
|
90
59
|
headers.append("Set-Cookie", setCookieHeader);
|
|
91
|
-
const payload = authService.
|
|
60
|
+
const payload = authService.accessTokenManager.decode(
|
|
92
61
|
newAccessToken
|
|
93
62
|
);
|
|
94
63
|
return respond(payload, headers);
|
|
@@ -110,24 +79,6 @@ function createWithAuthHandler({ authService }) {
|
|
|
110
79
|
|
|
111
80
|
// src/auth/cookie_store.ts
|
|
112
81
|
import { createCookie } from "react-router";
|
|
113
|
-
var ReactRouterCookieStore = class {
|
|
114
|
-
store;
|
|
115
|
-
constructor(key) {
|
|
116
|
-
this.store = createCookie(key, {
|
|
117
|
-
path: "/",
|
|
118
|
-
httpOnly: process.env.NODE_ENV === "production",
|
|
119
|
-
secure: process.env.NODE_ENV === "production",
|
|
120
|
-
sameSite: "strict"
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
parse(request) {
|
|
124
|
-
const cookieHeader = request.headers.get("cookie") || "";
|
|
125
|
-
return this.store.parse(cookieHeader);
|
|
126
|
-
}
|
|
127
|
-
serialize(value, options) {
|
|
128
|
-
return this.store.serialize(value, options);
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
82
|
|
|
132
83
|
// src/api/create_handler.ts
|
|
133
84
|
import {
|
|
@@ -139,7 +90,7 @@ var createAPIHandler = ({
|
|
|
139
90
|
fileService,
|
|
140
91
|
passwordRecoveryService,
|
|
141
92
|
getThirdPartyAuth,
|
|
142
|
-
|
|
93
|
+
signupTokenManager
|
|
143
94
|
}) => {
|
|
144
95
|
const handler = async (args) => {
|
|
145
96
|
const { request, params } = args;
|
|
@@ -218,7 +169,7 @@ var createAPIHandler = ({
|
|
|
218
169
|
return signUpWithThirdpartyHandler(request, {
|
|
219
170
|
authService,
|
|
220
171
|
fileService,
|
|
221
|
-
|
|
172
|
+
signupTokenManager
|
|
222
173
|
});
|
|
223
174
|
}
|
|
224
175
|
}
|
|
@@ -273,7 +224,7 @@ var createAPIHandler = ({
|
|
|
273
224
|
}
|
|
274
225
|
}
|
|
275
226
|
default: {
|
|
276
|
-
return
|
|
227
|
+
return NOT_FOUND();
|
|
277
228
|
}
|
|
278
229
|
}
|
|
279
230
|
};
|
package/dist/api/index.js
CHANGED
|
@@ -15,7 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
}
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
19
|
|
|
21
20
|
// src/api/index.ts
|
|
@@ -25,21 +24,10 @@ __export(api_exports, {
|
|
|
25
24
|
});
|
|
26
25
|
module.exports = __toCommonJS(api_exports);
|
|
27
26
|
|
|
28
|
-
// src/http/index.ts
|
|
29
|
-
var http_exports = {};
|
|
30
|
-
__reExport(http_exports, require("dn-react-toolkit/http"));
|
|
31
|
-
|
|
32
27
|
// src/api/create_handler.ts
|
|
28
|
+
var import_http = require("dn-react-toolkit/http");
|
|
33
29
|
var import_server = require("dn-react-toolkit/auth/server");
|
|
34
30
|
|
|
35
|
-
// src/auth/index.ts
|
|
36
|
-
var auth_exports = {};
|
|
37
|
-
__export(auth_exports, {
|
|
38
|
-
ReactRouterCookieStore: () => ReactRouterCookieStore,
|
|
39
|
-
createWithAuthHandler: () => createWithAuthHandler
|
|
40
|
-
});
|
|
41
|
-
__reExport(auth_exports, require("dn-react-toolkit/auth"));
|
|
42
|
-
|
|
43
31
|
// src/auth/with_auth.ts
|
|
44
32
|
var toResponse = (result) => {
|
|
45
33
|
if (result instanceof Response) {
|
|
@@ -64,7 +52,7 @@ function createWithAuthHandler({ authService }) {
|
|
|
64
52
|
arg.request
|
|
65
53
|
);
|
|
66
54
|
if (accessToken) {
|
|
67
|
-
const payload = await authService.
|
|
55
|
+
const payload = await authService.accessTokenManager.verify(
|
|
68
56
|
accessToken
|
|
69
57
|
);
|
|
70
58
|
if (payload) {
|
|
@@ -84,7 +72,7 @@ function createWithAuthHandler({ authService }) {
|
|
|
84
72
|
);
|
|
85
73
|
const headers = new Headers();
|
|
86
74
|
headers.append("Set-Cookie", setCookieHeader);
|
|
87
|
-
const payload = authService.
|
|
75
|
+
const payload = authService.accessTokenManager.decode(
|
|
88
76
|
newAccessToken
|
|
89
77
|
);
|
|
90
78
|
return respond(payload, headers);
|
|
@@ -106,24 +94,6 @@ function createWithAuthHandler({ authService }) {
|
|
|
106
94
|
|
|
107
95
|
// src/auth/cookie_store.ts
|
|
108
96
|
var import_react_router = require("react-router");
|
|
109
|
-
var ReactRouterCookieStore = class {
|
|
110
|
-
store;
|
|
111
|
-
constructor(key) {
|
|
112
|
-
this.store = (0, import_react_router.createCookie)(key, {
|
|
113
|
-
path: "/",
|
|
114
|
-
httpOnly: process.env.NODE_ENV === "production",
|
|
115
|
-
secure: process.env.NODE_ENV === "production",
|
|
116
|
-
sameSite: "strict"
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
parse(request) {
|
|
120
|
-
const cookieHeader = request.headers.get("cookie") || "";
|
|
121
|
-
return this.store.parse(cookieHeader);
|
|
122
|
-
}
|
|
123
|
-
serialize(value, options) {
|
|
124
|
-
return this.store.serialize(value, options);
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
97
|
|
|
128
98
|
// src/api/create_handler.ts
|
|
129
99
|
var import_server2 = require("dn-react-toolkit/file/server");
|
|
@@ -132,7 +102,7 @@ var createAPIHandler = ({
|
|
|
132
102
|
fileService,
|
|
133
103
|
passwordRecoveryService,
|
|
134
104
|
getThirdPartyAuth,
|
|
135
|
-
|
|
105
|
+
signupTokenManager
|
|
136
106
|
}) => {
|
|
137
107
|
const handler = async (args) => {
|
|
138
108
|
const { request, params } = args;
|
|
@@ -211,7 +181,7 @@ var createAPIHandler = ({
|
|
|
211
181
|
return (0, import_server.signUpWithThirdpartyHandler)(request, {
|
|
212
182
|
authService,
|
|
213
183
|
fileService,
|
|
214
|
-
|
|
184
|
+
signupTokenManager
|
|
215
185
|
});
|
|
216
186
|
}
|
|
217
187
|
}
|
|
@@ -266,7 +236,7 @@ var createAPIHandler = ({
|
|
|
266
236
|
}
|
|
267
237
|
}
|
|
268
238
|
default: {
|
|
269
|
-
return (0,
|
|
239
|
+
return (0, import_http.NOT_FOUND)();
|
|
270
240
|
}
|
|
271
241
|
}
|
|
272
242
|
};
|
package/dist/api/index.mjs
CHANGED
|
@@ -1,27 +1,5 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
-
|
|
19
|
-
// src/http/index.ts
|
|
20
|
-
var http_exports = {};
|
|
21
|
-
__reExport(http_exports, http_star);
|
|
22
|
-
import * as http_star from "dn-react-toolkit/http";
|
|
23
|
-
|
|
24
1
|
// src/api/create_handler.ts
|
|
2
|
+
import { NOT_FOUND } from "dn-react-toolkit/http";
|
|
25
3
|
import {
|
|
26
4
|
findAuthHandler,
|
|
27
5
|
loginHandler,
|
|
@@ -35,15 +13,6 @@ import {
|
|
|
35
13
|
thirdpartyAuthCallbackHandler
|
|
36
14
|
} from "dn-react-toolkit/auth/server";
|
|
37
15
|
|
|
38
|
-
// src/auth/index.ts
|
|
39
|
-
var auth_exports = {};
|
|
40
|
-
__export(auth_exports, {
|
|
41
|
-
ReactRouterCookieStore: () => ReactRouterCookieStore,
|
|
42
|
-
createWithAuthHandler: () => createWithAuthHandler
|
|
43
|
-
});
|
|
44
|
-
__reExport(auth_exports, auth_star);
|
|
45
|
-
import * as auth_star from "dn-react-toolkit/auth";
|
|
46
|
-
|
|
47
16
|
// src/auth/with_auth.ts
|
|
48
17
|
var toResponse = (result) => {
|
|
49
18
|
if (result instanceof Response) {
|
|
@@ -68,7 +37,7 @@ function createWithAuthHandler({ authService }) {
|
|
|
68
37
|
arg.request
|
|
69
38
|
);
|
|
70
39
|
if (accessToken) {
|
|
71
|
-
const payload = await authService.
|
|
40
|
+
const payload = await authService.accessTokenManager.verify(
|
|
72
41
|
accessToken
|
|
73
42
|
);
|
|
74
43
|
if (payload) {
|
|
@@ -88,7 +57,7 @@ function createWithAuthHandler({ authService }) {
|
|
|
88
57
|
);
|
|
89
58
|
const headers = new Headers();
|
|
90
59
|
headers.append("Set-Cookie", setCookieHeader);
|
|
91
|
-
const payload = authService.
|
|
60
|
+
const payload = authService.accessTokenManager.decode(
|
|
92
61
|
newAccessToken
|
|
93
62
|
);
|
|
94
63
|
return respond(payload, headers);
|
|
@@ -110,24 +79,6 @@ function createWithAuthHandler({ authService }) {
|
|
|
110
79
|
|
|
111
80
|
// src/auth/cookie_store.ts
|
|
112
81
|
import { createCookie } from "react-router";
|
|
113
|
-
var ReactRouterCookieStore = class {
|
|
114
|
-
store;
|
|
115
|
-
constructor(key) {
|
|
116
|
-
this.store = createCookie(key, {
|
|
117
|
-
path: "/",
|
|
118
|
-
httpOnly: process.env.NODE_ENV === "production",
|
|
119
|
-
secure: process.env.NODE_ENV === "production",
|
|
120
|
-
sameSite: "strict"
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
parse(request) {
|
|
124
|
-
const cookieHeader = request.headers.get("cookie") || "";
|
|
125
|
-
return this.store.parse(cookieHeader);
|
|
126
|
-
}
|
|
127
|
-
serialize(value, options) {
|
|
128
|
-
return this.store.serialize(value, options);
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
82
|
|
|
132
83
|
// src/api/create_handler.ts
|
|
133
84
|
import {
|
|
@@ -139,7 +90,7 @@ var createAPIHandler = ({
|
|
|
139
90
|
fileService,
|
|
140
91
|
passwordRecoveryService,
|
|
141
92
|
getThirdPartyAuth,
|
|
142
|
-
|
|
93
|
+
signupTokenManager
|
|
143
94
|
}) => {
|
|
144
95
|
const handler = async (args) => {
|
|
145
96
|
const { request, params } = args;
|
|
@@ -218,7 +169,7 @@ var createAPIHandler = ({
|
|
|
218
169
|
return signUpWithThirdpartyHandler(request, {
|
|
219
170
|
authService,
|
|
220
171
|
fileService,
|
|
221
|
-
|
|
172
|
+
signupTokenManager
|
|
222
173
|
});
|
|
223
174
|
}
|
|
224
175
|
}
|
|
@@ -273,7 +224,7 @@ var createAPIHandler = ({
|
|
|
273
224
|
}
|
|
274
225
|
}
|
|
275
226
|
default: {
|
|
276
|
-
return
|
|
227
|
+
return NOT_FOUND();
|
|
277
228
|
}
|
|
278
229
|
}
|
|
279
230
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { CookieManager } from 'dn-react-toolkit/auth/server';
|
|
2
|
+
import { SerializeOptions, ParseOptions } from 'cookie';
|
|
3
3
|
|
|
4
|
-
declare class
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
declare class ReactRouterCookieManager implements CookieManager {
|
|
5
|
+
name: string;
|
|
6
|
+
options: SerializeOptions;
|
|
7
|
+
private store;
|
|
8
|
+
constructor(name: string);
|
|
9
|
+
parse(request: Request, parseOptions?: ParseOptions | undefined): Promise<string | null>;
|
|
10
|
+
serialize(value: string, serializeOptions?: SerializeOptions | undefined): Promise<string>;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export {
|
|
13
|
+
export { ReactRouterCookieManager };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { CookieManager } from 'dn-react-toolkit/auth/server';
|
|
2
|
+
import { SerializeOptions, ParseOptions } from 'cookie';
|
|
3
3
|
|
|
4
|
-
declare class
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
declare class ReactRouterCookieManager implements CookieManager {
|
|
5
|
+
name: string;
|
|
6
|
+
options: SerializeOptions;
|
|
7
|
+
private store;
|
|
8
|
+
constructor(name: string);
|
|
9
|
+
parse(request: Request, parseOptions?: ParseOptions | undefined): Promise<string | null>;
|
|
10
|
+
serialize(value: string, serializeOptions?: SerializeOptions | undefined): Promise<string>;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export {
|
|
13
|
+
export { ReactRouterCookieManager };
|
|
@@ -20,29 +20,33 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/auth/cookie_store.ts
|
|
21
21
|
var cookie_store_exports = {};
|
|
22
22
|
__export(cookie_store_exports, {
|
|
23
|
-
|
|
23
|
+
ReactRouterCookieManager: () => ReactRouterCookieManager
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(cookie_store_exports);
|
|
26
26
|
var import_react_router = require("react-router");
|
|
27
|
-
var
|
|
27
|
+
var ReactRouterCookieManager = class {
|
|
28
|
+
name;
|
|
29
|
+
options;
|
|
28
30
|
store;
|
|
29
|
-
constructor(
|
|
30
|
-
this.
|
|
31
|
+
constructor(name) {
|
|
32
|
+
this.name = name;
|
|
33
|
+
this.options = {
|
|
31
34
|
path: "/",
|
|
32
35
|
httpOnly: process.env.NODE_ENV === "production",
|
|
33
36
|
secure: process.env.NODE_ENV === "production",
|
|
34
37
|
sameSite: "strict"
|
|
35
|
-
}
|
|
38
|
+
};
|
|
39
|
+
this.store = (0, import_react_router.createCookie)(this.name, this.options);
|
|
36
40
|
}
|
|
37
|
-
parse(request) {
|
|
38
|
-
const
|
|
39
|
-
return this.store.parse(
|
|
41
|
+
async parse(request, parseOptions) {
|
|
42
|
+
const cookieStore = request.headers.get("cookie") || "";
|
|
43
|
+
return this.store.parse(cookieStore, parseOptions);
|
|
40
44
|
}
|
|
41
|
-
serialize(value,
|
|
42
|
-
return this.store.serialize(value, options);
|
|
45
|
+
async serialize(value, serializeOptions) {
|
|
46
|
+
return this.store.serialize(value, { ...this.options, ...serializeOptions });
|
|
43
47
|
}
|
|
44
48
|
};
|
|
45
49
|
// Annotate the CommonJS export names for ESM import in node:
|
|
46
50
|
0 && (module.exports = {
|
|
47
|
-
|
|
51
|
+
ReactRouterCookieManager
|
|
48
52
|
});
|
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
// src/auth/cookie_store.ts
|
|
2
2
|
import { createCookie } from "react-router";
|
|
3
|
-
var
|
|
3
|
+
var ReactRouterCookieManager = class {
|
|
4
|
+
name;
|
|
5
|
+
options;
|
|
4
6
|
store;
|
|
5
|
-
constructor(
|
|
6
|
-
this.
|
|
7
|
+
constructor(name) {
|
|
8
|
+
this.name = name;
|
|
9
|
+
this.options = {
|
|
7
10
|
path: "/",
|
|
8
11
|
httpOnly: process.env.NODE_ENV === "production",
|
|
9
12
|
secure: process.env.NODE_ENV === "production",
|
|
10
13
|
sameSite: "strict"
|
|
11
|
-
}
|
|
14
|
+
};
|
|
15
|
+
this.store = createCookie(this.name, this.options);
|
|
12
16
|
}
|
|
13
|
-
parse(request) {
|
|
14
|
-
const
|
|
15
|
-
return this.store.parse(
|
|
17
|
+
async parse(request, parseOptions) {
|
|
18
|
+
const cookieStore = request.headers.get("cookie") || "";
|
|
19
|
+
return this.store.parse(cookieStore, parseOptions);
|
|
16
20
|
}
|
|
17
|
-
serialize(value,
|
|
18
|
-
return this.store.serialize(value, options);
|
|
21
|
+
async serialize(value, serializeOptions) {
|
|
22
|
+
return this.store.serialize(value, { ...this.options, ...serializeOptions });
|
|
19
23
|
}
|
|
20
24
|
};
|
|
21
25
|
export {
|
|
22
|
-
|
|
26
|
+
ReactRouterCookieManager
|
|
23
27
|
};
|
package/dist/auth/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export * from 'dn-react-toolkit/auth';
|
|
2
1
|
export { WithAuthHandler, createWithAuthHandler } from './with_auth.mjs';
|
|
3
|
-
export {
|
|
2
|
+
export { ReactRouterCookieManager } from './cookie_store.mjs';
|
|
3
|
+
import 'dn-react-toolkit/auth';
|
|
4
4
|
import 'dn-react-toolkit/auth/server';
|
|
5
5
|
import 'react-router';
|
|
6
|
+
import 'cookie';
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export * from 'dn-react-toolkit/auth';
|
|
2
1
|
export { WithAuthHandler, createWithAuthHandler } from './with_auth.js';
|
|
3
|
-
export {
|
|
2
|
+
export { ReactRouterCookieManager } from './cookie_store.js';
|
|
3
|
+
import 'dn-react-toolkit/auth';
|
|
4
4
|
import 'dn-react-toolkit/auth/server';
|
|
5
5
|
import 'react-router';
|
|
6
|
+
import 'cookie';
|