dn-react-router-toolkit 0.2.7 → 0.3.2
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 +13 -0
- package/dist/api/create_handler.d.ts +13 -0
- package/dist/api/create_handler.js +298 -0
- package/dist/api/create_handler.mjs +304 -0
- package/dist/api/index.d.mts +4 -0
- package/dist/api/index.d.ts +4 -0
- package/dist/api/index.js +298 -0
- package/dist/api/index.mjs +304 -0
- package/dist/auth/client/index.d.mts +3 -0
- package/dist/auth/client/index.d.ts +3 -0
- package/dist/{date.js → auth/client/index.js} +25 -32
- package/dist/auth/client/index.mjs +21 -0
- package/dist/auth/client/redirect_page.d.mts +1 -0
- package/dist/auth/client/redirect_page.d.ts +1 -0
- package/dist/auth/cookie_store.d.mts +13 -0
- package/dist/auth/cookie_store.d.ts +13 -0
- package/dist/{text_editor/plugins/keymap.js → auth/cookie_store.js} +24 -16
- package/dist/auth/cookie_store.mjs +23 -0
- package/dist/auth/index.d.mts +5 -0
- package/dist/auth/index.d.ts +5 -0
- package/dist/auth/index.js +139 -0
- package/dist/auth/index.mjs +111 -0
- package/dist/auth/server/index.d.mts +1 -0
- package/dist/auth/server/index.d.ts +1 -0
- package/dist/{slug.js → auth/server/index.js} +6 -14
- package/dist/auth/server/index.mjs +2 -0
- package/dist/auth/with_auth.d.mts +2 -6
- package/dist/auth/with_auth.d.ts +2 -6
- package/dist/auth/with_auth.js +3 -0
- package/dist/auth/with_auth.mjs +3 -0
- package/dist/{components → client}/client_env.d.mts +1 -1
- package/dist/{components → client}/client_env.d.ts +1 -1
- package/dist/{components → client}/client_env.js +6 -2
- package/dist/{components → client}/client_env.mjs +2 -2
- package/dist/client/index.d.mts +3 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/{auth/client/google_login_button.js → client/index.js} +30 -33
- package/dist/client/index.mjs +31 -0
- package/dist/client/use_user_agent.d.mts +8 -0
- package/dist/client/use_user_agent.d.ts +8 -0
- package/dist/{file/client/format_size.js → client/use_user_agent.js} +14 -14
- package/dist/client/use_user_agent.mjs +13 -0
- package/dist/file/client/index.d.mts +1 -0
- package/dist/file/client/index.d.ts +1 -0
- package/dist/file/{cdn.js → client/index.js} +6 -16
- package/dist/file/client/index.mjs +2 -0
- package/dist/file/index.d.mts +1 -0
- package/dist/file/index.d.ts +1 -0
- package/dist/{cn.js → file/index.js} +6 -14
- package/dist/file/index.mjs +2 -0
- package/dist/file/server/index.d.mts +1 -0
- package/dist/file/server/index.d.ts +1 -0
- package/dist/file/server/index.js +24 -0
- package/dist/file/server/index.mjs +2 -0
- package/dist/http/index.d.mts +1 -1
- package/dist/http/index.d.ts +1 -1
- package/dist/http/index.js +3 -90
- package/dist/http/index.mjs +2 -68
- package/dist/index.d.mts +8 -6
- package/dist/index.d.ts +8 -6
- package/dist/index.js +3 -79
- package/dist/index.mjs +2 -58
- package/dist/modal/index.d.mts +1 -0
- package/dist/modal/index.d.ts +1 -0
- package/dist/{sleep.js → modal/index.js} +6 -14
- package/dist/modal/index.mjs +2 -0
- package/dist/seo/index.d.mts +4 -0
- package/dist/seo/index.d.ts +4 -0
- package/dist/seo/index.js +304 -0
- package/dist/seo/index.mjs +267 -0
- package/dist/text_editor/index.d.mts +1 -0
- package/dist/text_editor/index.d.ts +1 -0
- package/dist/text_editor/index.js +24 -0
- package/dist/text_editor/index.mjs +2 -0
- package/package.json +58 -32
- package/dist/auth/apple_auth.d.mts +0 -38
- package/dist/auth/apple_auth.d.ts +0 -38
- package/dist/auth/apple_auth.js +0 -88
- package/dist/auth/apple_auth.mjs +0 -63
- package/dist/auth/auth_repository.d.mts +0 -41
- package/dist/auth/auth_repository.d.ts +0 -41
- package/dist/auth/auth_repository.js +0 -18
- package/dist/auth/auth_repository.mjs +0 -0
- package/dist/auth/auth_service.d.mts +0 -63
- package/dist/auth/auth_service.d.ts +0 -63
- package/dist/auth/auth_service.js +0 -210
- package/dist/auth/auth_service.mjs +0 -171
- package/dist/auth/client/google_login_button.d.mts +0 -7
- package/dist/auth/client/google_login_button.d.ts +0 -7
- package/dist/auth/client/google_login_button.mjs +0 -37
- package/dist/auth/client/provider.d.mts +0 -24
- package/dist/auth/client/provider.d.ts +0 -24
- package/dist/auth/client/provider.js +0 -154
- package/dist/auth/client/provider.mjs +0 -118
- package/dist/auth/google_auth.d.mts +0 -33
- package/dist/auth/google_auth.d.ts +0 -33
- package/dist/auth/google_auth.js +0 -135
- package/dist/auth/google_auth.mjs +0 -108
- package/dist/auth/handlers/find_auth.d.mts +0 -13
- package/dist/auth/handlers/find_auth.d.ts +0 -13
- package/dist/auth/handlers/find_auth.js +0 -82
- package/dist/auth/handlers/find_auth.mjs +0 -55
- package/dist/auth/handlers/login.d.mts +0 -13
- package/dist/auth/handlers/login.d.ts +0 -13
- package/dist/auth/handlers/login.js +0 -107
- package/dist/auth/handlers/login.mjs +0 -80
- package/dist/auth/handlers/login_with_thirdparty.d.mts +0 -15
- package/dist/auth/handlers/login_with_thirdparty.d.ts +0 -15
- package/dist/auth/handlers/login_with_thirdparty.js +0 -98
- package/dist/auth/handlers/login_with_thirdparty.mjs +0 -71
- package/dist/auth/handlers/logout.d.mts +0 -13
- package/dist/auth/handlers/logout.d.ts +0 -13
- package/dist/auth/handlers/logout.js +0 -102
- package/dist/auth/handlers/logout.mjs +0 -75
- package/dist/auth/handlers/refresh.d.mts +0 -13
- package/dist/auth/handlers/refresh.d.ts +0 -13
- package/dist/auth/handlers/refresh.js +0 -92
- package/dist/auth/handlers/refresh.mjs +0 -65
- package/dist/auth/handlers/request_password_reset.d.mts +0 -10
- package/dist/auth/handlers/request_password_reset.d.ts +0 -10
- package/dist/auth/handlers/request_password_reset.js +0 -87
- package/dist/auth/handlers/request_password_reset.mjs +0 -60
- package/dist/auth/handlers/reset_password.d.mts +0 -10
- package/dist/auth/handlers/reset_password.d.ts +0 -10
- package/dist/auth/handlers/reset_password.js +0 -88
- package/dist/auth/handlers/reset_password.mjs +0 -61
- package/dist/auth/handlers/signup.d.mts +0 -15
- package/dist/auth/handlers/signup.d.ts +0 -15
- package/dist/auth/handlers/signup.js +0 -147
- package/dist/auth/handlers/signup.mjs +0 -112
- package/dist/auth/handlers/signup_with_thirdparty.d.mts +0 -17
- package/dist/auth/handlers/signup_with_thirdparty.d.ts +0 -17
- package/dist/auth/handlers/signup_with_thirdparty.js +0 -123
- package/dist/auth/handlers/signup_with_thirdparty.mjs +0 -98
- package/dist/auth/handlers/thirdparty_auth_callback.d.mts +0 -16
- package/dist/auth/handlers/thirdparty_auth_callback.d.ts +0 -16
- package/dist/auth/handlers/thirdparty_auth_callback.js +0 -129
- package/dist/auth/handlers/thirdparty_auth_callback.mjs +0 -102
- package/dist/auth/jwt_manager.d.mts +0 -38
- package/dist/auth/jwt_manager.d.ts +0 -38
- package/dist/auth/jwt_manager.js +0 -90
- package/dist/auth/jwt_manager.mjs +0 -65
- package/dist/auth/kakao_auth.d.mts +0 -27
- package/dist/auth/kakao_auth.d.ts +0 -27
- package/dist/auth/kakao_auth.js +0 -56
- package/dist/auth/kakao_auth.mjs +0 -31
- package/dist/auth/password_recovery.d.mts +0 -34
- package/dist/auth/password_recovery.d.ts +0 -34
- package/dist/auth/password_recovery.js +0 -169
- package/dist/auth/password_recovery.mjs +0 -134
- package/dist/auth/thirdparty_auth.d.mts +0 -41
- package/dist/auth/thirdparty_auth.d.ts +0 -41
- package/dist/auth/thirdparty_auth.js +0 -113
- package/dist/auth/thirdparty_auth.mjs +0 -86
- package/dist/cn.d.mts +0 -3
- package/dist/cn.d.ts +0 -3
- package/dist/cn.mjs +0 -7
- package/dist/components/index.d.mts +0 -5
- package/dist/components/index.d.ts +0 -5
- package/dist/components/index.js +0 -261
- package/dist/components/index.mjs +0 -219
- package/dist/components/modal/fullscreen_container.d.mts +0 -7
- package/dist/components/modal/fullscreen_container.d.ts +0 -7
- package/dist/components/modal/fullscreen_container.js +0 -102
- package/dist/components/modal/fullscreen_container.mjs +0 -68
- package/dist/components/modal/hooks.d.mts +0 -18
- package/dist/components/modal/hooks.d.ts +0 -18
- package/dist/components/modal/hooks.js +0 -236
- package/dist/components/modal/hooks.mjs +0 -204
- package/dist/components/modal/index.d.mts +0 -4
- package/dist/components/modal/index.d.ts +0 -4
- package/dist/components/modal/index.js +0 -238
- package/dist/components/modal/index.mjs +0 -203
- package/dist/components/modal/modal.d.mts +0 -13
- package/dist/components/modal/modal.d.ts +0 -13
- package/dist/components/modal/modal.js +0 -155
- package/dist/components/modal/modal.mjs +0 -130
- package/dist/components/styles.d.mts +0 -9
- package/dist/components/styles.d.ts +0 -9
- package/dist/components/styles.js +0 -48
- package/dist/components/styles.mjs +0 -17
- package/dist/date.d.mts +0 -5
- package/dist/date.d.ts +0 -5
- package/dist/date.mjs +0 -29
- package/dist/file/cdn.d.mts +0 -6
- package/dist/file/cdn.d.ts +0 -6
- package/dist/file/cdn.mjs +0 -9
- package/dist/file/client/drop_file_input.d.mts +0 -36
- package/dist/file/client/drop_file_input.d.ts +0 -36
- package/dist/file/client/drop_file_input.js +0 -323
- package/dist/file/client/drop_file_input.mjs +0 -294
- package/dist/file/client/file_upload_button.d.mts +0 -10
- package/dist/file/client/file_upload_button.d.ts +0 -10
- package/dist/file/client/file_upload_button.js +0 -89
- package/dist/file/client/file_upload_button.mjs +0 -58
- package/dist/file/client/file_uploader.d.mts +0 -13
- package/dist/file/client/file_uploader.d.ts +0 -13
- package/dist/file/client/file_uploader.js +0 -163
- package/dist/file/client/file_uploader.mjs +0 -136
- package/dist/file/client/format_size.d.mts +0 -3
- package/dist/file/client/format_size.d.ts +0 -3
- package/dist/file/client/format_size.mjs +0 -13
- package/dist/file/client/metadata.d.mts +0 -7
- package/dist/file/client/metadata.d.ts +0 -7
- package/dist/file/client/metadata.js +0 -85
- package/dist/file/client/metadata.mjs +0 -60
- package/dist/file/file_repository.d.mts +0 -16
- package/dist/file/file_repository.d.ts +0 -16
- package/dist/file/file_repository.js +0 -18
- package/dist/file/file_repository.mjs +0 -0
- package/dist/file/file_service.d.mts +0 -32
- package/dist/file/file_service.d.ts +0 -32
- package/dist/file/file_service.js +0 -66
- package/dist/file/file_service.mjs +0 -41
- package/dist/file/handlers/delete_file.d.mts +0 -17
- package/dist/file/handlers/delete_file.d.ts +0 -17
- package/dist/file/handlers/delete_file.js +0 -99
- package/dist/file/handlers/delete_file.mjs +0 -72
- package/dist/file/handlers/upload_file.d.mts +0 -16
- package/dist/file/handlers/upload_file.d.ts +0 -16
- package/dist/file/handlers/upload_file.js +0 -106
- package/dist/file/handlers/upload_file.mjs +0 -79
- package/dist/file/object_storage.d.mts +0 -20
- package/dist/file/object_storage.d.ts +0 -20
- package/dist/file/object_storage.js +0 -90
- package/dist/file/object_storage.mjs +0 -70
- package/dist/file/responsive_image.d.mts +0 -20
- package/dist/file/responsive_image.d.ts +0 -20
- package/dist/file/responsive_image.js +0 -132
- package/dist/file/responsive_image.mjs +0 -96
- package/dist/http/response.d.mts +0 -19
- package/dist/http/response.d.ts +0 -19
- package/dist/http/response.js +0 -109
- package/dist/http/response.mjs +0 -68
- package/dist/route/api.d.mts +0 -21
- package/dist/route/api.d.ts +0 -21
- package/dist/route/api.js +0 -584
- package/dist/route/api.mjs +0 -547
- package/dist/singleton.d.mts +0 -3
- package/dist/singleton.d.ts +0 -3
- package/dist/singleton.js +0 -37
- package/dist/singleton.mjs +0 -12
- package/dist/sleep.d.mts +0 -3
- package/dist/sleep.d.ts +0 -3
- package/dist/sleep.mjs +0 -7
- package/dist/slug.d.mts +0 -3
- package/dist/slug.d.ts +0 -3
- package/dist/slug.mjs +0 -7
- package/dist/text_editor/attach_media.d.mts +0 -16
- package/dist/text_editor/attach_media.d.ts +0 -16
- package/dist/text_editor/attach_media.js +0 -237
- package/dist/text_editor/attach_media.mjs +0 -210
- package/dist/text_editor/plugins/drag_and_drop.d.mts +0 -13
- package/dist/text_editor/plugins/drag_and_drop.d.ts +0 -13
- package/dist/text_editor/plugins/drag_and_drop.js +0 -59
- package/dist/text_editor/plugins/drag_and_drop.mjs +0 -34
- package/dist/text_editor/plugins/keymap.d.mts +0 -5
- package/dist/text_editor/plugins/keymap.d.ts +0 -5
- package/dist/text_editor/plugins/keymap.mjs +0 -15
- package/dist/text_editor/plugins/placehoder.d.mts +0 -5
- package/dist/text_editor/plugins/placehoder.d.ts +0 -5
- package/dist/text_editor/plugins/placehoder.js +0 -112
- package/dist/text_editor/plugins/placehoder.mjs +0 -87
- package/dist/text_editor/plugins/trailing_paragraph.d.mts +0 -5
- package/dist/text_editor/plugins/trailing_paragraph.d.ts +0 -5
- package/dist/text_editor/plugins/trailing_paragraph.js +0 -46
- package/dist/text_editor/plugins/trailing_paragraph.mjs +0 -21
- package/dist/text_editor/plugins/upload_placeholder.d.mts +0 -7
- package/dist/text_editor/plugins/upload_placeholder.d.ts +0 -7
- package/dist/text_editor/plugins/upload_placeholder.js +0 -94
- package/dist/text_editor/plugins/upload_placeholder.mjs +0 -68
- package/dist/text_editor/schema.d.mts +0 -9
- package/dist/text_editor/schema.d.ts +0 -9
- package/dist/text_editor/schema.js +0 -354
- package/dist/text_editor/schema.mjs +0 -319
- package/dist/text_editor/text_editor.d.mts +0 -45
- package/dist/text_editor/text_editor.d.ts +0 -45
- package/dist/text_editor/text_editor.js +0 -834
- package/dist/text_editor/text_editor.mjs +0 -806
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Cookie } from 'react-router';
|
|
2
|
+
import { CookieStore } from 'dn-react-toolkit/auth/server';
|
|
3
|
+
|
|
4
|
+
declare class ReactRouterCookieStore implements CookieStore {
|
|
5
|
+
store: Cookie;
|
|
6
|
+
constructor(key: string);
|
|
7
|
+
parse(request: Request): Promise<string | null>;
|
|
8
|
+
serialize(value: string | null, options: {
|
|
9
|
+
expires: Date;
|
|
10
|
+
}): Promise<string>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { ReactRouterCookieStore };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Cookie } from 'react-router';
|
|
2
|
+
import { CookieStore } from 'dn-react-toolkit/auth/server';
|
|
3
|
+
|
|
4
|
+
declare class ReactRouterCookieStore implements CookieStore {
|
|
5
|
+
store: Cookie;
|
|
6
|
+
constructor(key: string);
|
|
7
|
+
parse(request: Request): Promise<string | null>;
|
|
8
|
+
serialize(value: string | null, options: {
|
|
9
|
+
expires: Date;
|
|
10
|
+
}): Promise<string>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { ReactRouterCookieStore };
|
|
@@ -17,24 +17,32 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// src/
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
23
|
-
|
|
20
|
+
// src/auth/cookie_store.ts
|
|
21
|
+
var cookie_store_exports = {};
|
|
22
|
+
__export(cookie_store_exports, {
|
|
23
|
+
ReactRouterCookieStore: () => ReactRouterCookieStore
|
|
24
24
|
});
|
|
25
|
-
module.exports = __toCommonJS(
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
module.exports = __toCommonJS(cookie_store_exports);
|
|
26
|
+
var import_react_router = require("react-router");
|
|
27
|
+
var ReactRouterCookieStore = class {
|
|
28
|
+
store;
|
|
29
|
+
constructor(key) {
|
|
30
|
+
this.store = (0, import_react_router.createCookie)(key, {
|
|
31
|
+
path: "/",
|
|
32
|
+
httpOnly: process.env.NODE_ENV === "production",
|
|
33
|
+
secure: process.env.NODE_ENV === "production",
|
|
34
|
+
sameSite: "strict"
|
|
35
|
+
});
|
|
31
36
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
parse(request) {
|
|
38
|
+
const cookieHeader = request.headers.get("cookie") || "";
|
|
39
|
+
return this.store.parse(cookieHeader);
|
|
40
|
+
}
|
|
41
|
+
serialize(value, options) {
|
|
42
|
+
return this.store.serialize(value, options);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
37
45
|
// Annotate the CommonJS export names for ESM import in node:
|
|
38
46
|
0 && (module.exports = {
|
|
39
|
-
|
|
47
|
+
ReactRouterCookieStore
|
|
40
48
|
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// src/auth/cookie_store.ts
|
|
2
|
+
import { createCookie } from "react-router";
|
|
3
|
+
var ReactRouterCookieStore = class {
|
|
4
|
+
store;
|
|
5
|
+
constructor(key) {
|
|
6
|
+
this.store = createCookie(key, {
|
|
7
|
+
path: "/",
|
|
8
|
+
httpOnly: process.env.NODE_ENV === "production",
|
|
9
|
+
secure: process.env.NODE_ENV === "production",
|
|
10
|
+
sameSite: "strict"
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
parse(request) {
|
|
14
|
+
const cookieHeader = request.headers.get("cookie") || "";
|
|
15
|
+
return this.store.parse(cookieHeader);
|
|
16
|
+
}
|
|
17
|
+
serialize(value, options) {
|
|
18
|
+
return this.store.serialize(value, options);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
ReactRouterCookieStore
|
|
23
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/auth/index.ts
|
|
22
|
+
var auth_exports = {};
|
|
23
|
+
__export(auth_exports, {
|
|
24
|
+
ReactRouterCookieStore: () => ReactRouterCookieStore,
|
|
25
|
+
createWithAuthHandler: () => createWithAuthHandler
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(auth_exports);
|
|
28
|
+
__reExport(auth_exports, require("dn-react-toolkit/auth"), module.exports);
|
|
29
|
+
|
|
30
|
+
// src/auth/with_auth.ts
|
|
31
|
+
function createWithAuthHandler({ authService }) {
|
|
32
|
+
return function(fn) {
|
|
33
|
+
const handler = async function(arg) {
|
|
34
|
+
const respond = async (auth) => {
|
|
35
|
+
const userAgent = arg.request.headers.get("User-Agent") || "";
|
|
36
|
+
const res = await fn(auth)(arg);
|
|
37
|
+
if (typeof res === "object" && res !== null && !Array.isArray(res)) {
|
|
38
|
+
if (res instanceof Response) {
|
|
39
|
+
if (res.status < 300 && res.headers.get("Content-Type")?.includes("application/json")) {
|
|
40
|
+
const data = await res.json();
|
|
41
|
+
return new Response(
|
|
42
|
+
JSON.stringify({
|
|
43
|
+
AUTH: auth,
|
|
44
|
+
userAgent,
|
|
45
|
+
...data
|
|
46
|
+
}),
|
|
47
|
+
{
|
|
48
|
+
status: res.status,
|
|
49
|
+
headers: res.headers
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
return res;
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
AUTH: auth,
|
|
57
|
+
userAgent,
|
|
58
|
+
...res
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return res;
|
|
62
|
+
};
|
|
63
|
+
const accessToken = await authService.getAccessTokenFromRequest(
|
|
64
|
+
arg.request
|
|
65
|
+
);
|
|
66
|
+
if (accessToken) {
|
|
67
|
+
const payload = await authService.jwtManager.verifyAccessToken(
|
|
68
|
+
accessToken
|
|
69
|
+
);
|
|
70
|
+
if (payload) {
|
|
71
|
+
return respond(payload);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const refreshToken = await authService.getRefreshTokenFromCookies(
|
|
75
|
+
arg.request
|
|
76
|
+
);
|
|
77
|
+
if (refreshToken) {
|
|
78
|
+
try {
|
|
79
|
+
const newAccessToken = await authService.refreshAccessToken(
|
|
80
|
+
refreshToken
|
|
81
|
+
);
|
|
82
|
+
const setCookieHeader = await authService.getAccessTokenSetCookie(
|
|
83
|
+
newAccessToken
|
|
84
|
+
);
|
|
85
|
+
const headers = new Headers();
|
|
86
|
+
headers.append("Set-Cookie", setCookieHeader);
|
|
87
|
+
headers.append("Location", arg.request.url);
|
|
88
|
+
return new Response("Temporary Redirect", {
|
|
89
|
+
status: 307,
|
|
90
|
+
headers
|
|
91
|
+
});
|
|
92
|
+
} catch (e) {
|
|
93
|
+
if (e instanceof Error) {
|
|
94
|
+
console.log(e.message);
|
|
95
|
+
}
|
|
96
|
+
const setCookieHeader = await authService.getRefreshTokenSetCookie(
|
|
97
|
+
null
|
|
98
|
+
);
|
|
99
|
+
const headers = new Headers();
|
|
100
|
+
headers.append("Set-Cookie", setCookieHeader);
|
|
101
|
+
headers.append("Location", arg.request.url);
|
|
102
|
+
return new Response("Temporary Redirect", {
|
|
103
|
+
status: 307,
|
|
104
|
+
headers
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return respond(void 0);
|
|
109
|
+
};
|
|
110
|
+
return handler;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// src/auth/cookie_store.ts
|
|
115
|
+
var import_react_router = require("react-router");
|
|
116
|
+
var ReactRouterCookieStore = class {
|
|
117
|
+
store;
|
|
118
|
+
constructor(key) {
|
|
119
|
+
this.store = (0, import_react_router.createCookie)(key, {
|
|
120
|
+
path: "/",
|
|
121
|
+
httpOnly: process.env.NODE_ENV === "production",
|
|
122
|
+
secure: process.env.NODE_ENV === "production",
|
|
123
|
+
sameSite: "strict"
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
parse(request) {
|
|
127
|
+
const cookieHeader = request.headers.get("cookie") || "";
|
|
128
|
+
return this.store.parse(cookieHeader);
|
|
129
|
+
}
|
|
130
|
+
serialize(value, options) {
|
|
131
|
+
return this.store.serialize(value, options);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
135
|
+
0 && (module.exports = {
|
|
136
|
+
ReactRouterCookieStore,
|
|
137
|
+
createWithAuthHandler,
|
|
138
|
+
...require("dn-react-toolkit/auth")
|
|
139
|
+
});
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// src/auth/index.ts
|
|
2
|
+
export * from "dn-react-toolkit/auth";
|
|
3
|
+
|
|
4
|
+
// src/auth/with_auth.ts
|
|
5
|
+
function createWithAuthHandler({ authService }) {
|
|
6
|
+
return function(fn) {
|
|
7
|
+
const handler = async function(arg) {
|
|
8
|
+
const respond = async (auth) => {
|
|
9
|
+
const userAgent = arg.request.headers.get("User-Agent") || "";
|
|
10
|
+
const res = await fn(auth)(arg);
|
|
11
|
+
if (typeof res === "object" && res !== null && !Array.isArray(res)) {
|
|
12
|
+
if (res instanceof Response) {
|
|
13
|
+
if (res.status < 300 && res.headers.get("Content-Type")?.includes("application/json")) {
|
|
14
|
+
const data = await res.json();
|
|
15
|
+
return new Response(
|
|
16
|
+
JSON.stringify({
|
|
17
|
+
AUTH: auth,
|
|
18
|
+
userAgent,
|
|
19
|
+
...data
|
|
20
|
+
}),
|
|
21
|
+
{
|
|
22
|
+
status: res.status,
|
|
23
|
+
headers: res.headers
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
return res;
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
AUTH: auth,
|
|
31
|
+
userAgent,
|
|
32
|
+
...res
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return res;
|
|
36
|
+
};
|
|
37
|
+
const accessToken = await authService.getAccessTokenFromRequest(
|
|
38
|
+
arg.request
|
|
39
|
+
);
|
|
40
|
+
if (accessToken) {
|
|
41
|
+
const payload = await authService.jwtManager.verifyAccessToken(
|
|
42
|
+
accessToken
|
|
43
|
+
);
|
|
44
|
+
if (payload) {
|
|
45
|
+
return respond(payload);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const refreshToken = await authService.getRefreshTokenFromCookies(
|
|
49
|
+
arg.request
|
|
50
|
+
);
|
|
51
|
+
if (refreshToken) {
|
|
52
|
+
try {
|
|
53
|
+
const newAccessToken = await authService.refreshAccessToken(
|
|
54
|
+
refreshToken
|
|
55
|
+
);
|
|
56
|
+
const setCookieHeader = await authService.getAccessTokenSetCookie(
|
|
57
|
+
newAccessToken
|
|
58
|
+
);
|
|
59
|
+
const headers = new Headers();
|
|
60
|
+
headers.append("Set-Cookie", setCookieHeader);
|
|
61
|
+
headers.append("Location", arg.request.url);
|
|
62
|
+
return new Response("Temporary Redirect", {
|
|
63
|
+
status: 307,
|
|
64
|
+
headers
|
|
65
|
+
});
|
|
66
|
+
} catch (e) {
|
|
67
|
+
if (e instanceof Error) {
|
|
68
|
+
console.log(e.message);
|
|
69
|
+
}
|
|
70
|
+
const setCookieHeader = await authService.getRefreshTokenSetCookie(
|
|
71
|
+
null
|
|
72
|
+
);
|
|
73
|
+
const headers = new Headers();
|
|
74
|
+
headers.append("Set-Cookie", setCookieHeader);
|
|
75
|
+
headers.append("Location", arg.request.url);
|
|
76
|
+
return new Response("Temporary Redirect", {
|
|
77
|
+
status: 307,
|
|
78
|
+
headers
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return respond(void 0);
|
|
83
|
+
};
|
|
84
|
+
return handler;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// src/auth/cookie_store.ts
|
|
89
|
+
import { createCookie } from "react-router";
|
|
90
|
+
var ReactRouterCookieStore = class {
|
|
91
|
+
store;
|
|
92
|
+
constructor(key) {
|
|
93
|
+
this.store = createCookie(key, {
|
|
94
|
+
path: "/",
|
|
95
|
+
httpOnly: process.env.NODE_ENV === "production",
|
|
96
|
+
secure: process.env.NODE_ENV === "production",
|
|
97
|
+
sameSite: "strict"
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
parse(request) {
|
|
101
|
+
const cookieHeader = request.headers.get("cookie") || "";
|
|
102
|
+
return this.store.parse(cookieHeader);
|
|
103
|
+
}
|
|
104
|
+
serialize(value, options) {
|
|
105
|
+
return this.store.serialize(value, options);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
export {
|
|
109
|
+
ReactRouterCookieStore,
|
|
110
|
+
createWithAuthHandler
|
|
111
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from 'dn-react-toolkit/auth/server';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from 'dn-react-toolkit/auth/server';
|
|
@@ -3,10 +3,6 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
6
|
var __copyProps = (to, from, except, desc) => {
|
|
11
7
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
8
|
for (let key of __getOwnPropNames(from))
|
|
@@ -15,18 +11,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
11
|
}
|
|
16
12
|
return to;
|
|
17
13
|
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
16
|
|
|
20
|
-
// src/
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(slug_exports);
|
|
26
|
-
var toSlug = (str) => {
|
|
27
|
-
return str.toLowerCase().replace(/[^a-zA-Z0-9가-힣ㄱ-ㅎㅏ-ㅣ]+/g, "-").replace(/^-|-$/g, "");
|
|
28
|
-
};
|
|
17
|
+
// src/auth/server/index.tsx
|
|
18
|
+
var server_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(server_exports);
|
|
20
|
+
__reExport(server_exports, require("dn-react-toolkit/auth/server"), module.exports);
|
|
29
21
|
// Annotate the CommonJS export names for ESM import in node:
|
|
30
22
|
0 && (module.exports = {
|
|
31
|
-
|
|
23
|
+
...require("dn-react-toolkit/auth/server")
|
|
32
24
|
});
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
+
import { AccessTokenPayload } from 'dn-react-toolkit/auth';
|
|
2
|
+
import { AuthService } from 'dn-react-toolkit/auth/server';
|
|
1
3
|
import { LoaderFunctionArgs, ActionFunctionArgs } from 'react-router';
|
|
2
|
-
import { AuthService } from './auth_service.mjs';
|
|
3
|
-
import { AccessTokenPayload } from './jwt_manager.mjs';
|
|
4
|
-
import 'jose';
|
|
5
|
-
import '../file/object_storage.mjs';
|
|
6
|
-
import '@aws-sdk/client-s3';
|
|
7
|
-
import './auth_repository.mjs';
|
|
8
4
|
|
|
9
5
|
type Handler<T extends LoaderFunctionArgs | ActionFunctionArgs> = (arg: T) => Promise<unknown> | unknown;
|
|
10
6
|
type InputFN = (auth?: AccessTokenPayload) => Handler<LoaderFunctionArgs> | Handler<ActionFunctionArgs>;
|
package/dist/auth/with_auth.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
+
import { AccessTokenPayload } from 'dn-react-toolkit/auth';
|
|
2
|
+
import { AuthService } from 'dn-react-toolkit/auth/server';
|
|
1
3
|
import { LoaderFunctionArgs, ActionFunctionArgs } from 'react-router';
|
|
2
|
-
import { AuthService } from './auth_service.js';
|
|
3
|
-
import { AccessTokenPayload } from './jwt_manager.js';
|
|
4
|
-
import 'jose';
|
|
5
|
-
import '../file/object_storage.js';
|
|
6
|
-
import '@aws-sdk/client-s3';
|
|
7
|
-
import './auth_repository.js';
|
|
8
4
|
|
|
9
5
|
type Handler<T extends LoaderFunctionArgs | ActionFunctionArgs> = (arg: T) => Promise<unknown> | unknown;
|
|
10
6
|
type InputFN = (auth?: AccessTokenPayload) => Handler<LoaderFunctionArgs> | Handler<ActionFunctionArgs>;
|
package/dist/auth/with_auth.js
CHANGED
|
@@ -27,6 +27,7 @@ function createWithAuthHandler({ authService }) {
|
|
|
27
27
|
return function(fn) {
|
|
28
28
|
const handler = async function(arg) {
|
|
29
29
|
const respond = async (auth) => {
|
|
30
|
+
const userAgent = arg.request.headers.get("User-Agent") || "";
|
|
30
31
|
const res = await fn(auth)(arg);
|
|
31
32
|
if (typeof res === "object" && res !== null && !Array.isArray(res)) {
|
|
32
33
|
if (res instanceof Response) {
|
|
@@ -35,6 +36,7 @@ function createWithAuthHandler({ authService }) {
|
|
|
35
36
|
return new Response(
|
|
36
37
|
JSON.stringify({
|
|
37
38
|
AUTH: auth,
|
|
39
|
+
userAgent,
|
|
38
40
|
...data
|
|
39
41
|
}),
|
|
40
42
|
{
|
|
@@ -47,6 +49,7 @@ function createWithAuthHandler({ authService }) {
|
|
|
47
49
|
}
|
|
48
50
|
return {
|
|
49
51
|
AUTH: auth,
|
|
52
|
+
userAgent,
|
|
50
53
|
...res
|
|
51
54
|
};
|
|
52
55
|
}
|
package/dist/auth/with_auth.mjs
CHANGED
|
@@ -3,6 +3,7 @@ function createWithAuthHandler({ authService }) {
|
|
|
3
3
|
return function(fn) {
|
|
4
4
|
const handler = async function(arg) {
|
|
5
5
|
const respond = async (auth) => {
|
|
6
|
+
const userAgent = arg.request.headers.get("User-Agent") || "";
|
|
6
7
|
const res = await fn(auth)(arg);
|
|
7
8
|
if (typeof res === "object" && res !== null && !Array.isArray(res)) {
|
|
8
9
|
if (res instanceof Response) {
|
|
@@ -11,6 +12,7 @@ function createWithAuthHandler({ authService }) {
|
|
|
11
12
|
return new Response(
|
|
12
13
|
JSON.stringify({
|
|
13
14
|
AUTH: auth,
|
|
15
|
+
userAgent,
|
|
14
16
|
...data
|
|
15
17
|
}),
|
|
16
18
|
{
|
|
@@ -23,6 +25,7 @@ function createWithAuthHandler({ authService }) {
|
|
|
23
25
|
}
|
|
24
26
|
return {
|
|
25
27
|
AUTH: auth,
|
|
28
|
+
userAgent,
|
|
26
29
|
...res
|
|
27
30
|
};
|
|
28
31
|
}
|
|
@@ -27,10 +27,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
|
-
// src/
|
|
30
|
+
// src/client/client_env.tsx
|
|
31
31
|
var client_env_exports = {};
|
|
32
32
|
__export(client_env_exports, {
|
|
33
|
-
|
|
33
|
+
ClientEnv: () => ClientEnv
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(client_env_exports);
|
|
36
36
|
var import_react = __toESM(require("react"));
|
|
@@ -48,3 +48,7 @@ function ClientEnv({ dataKey = "ENV" }) {
|
|
|
48
48
|
}
|
|
49
49
|
));
|
|
50
50
|
}
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
ClientEnv
|
|
54
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/client/client_env.tsx
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { useRouteLoaderData } from "react-router";
|
|
4
4
|
function ClientEnv({ dataKey = "ENV" }) {
|
|
@@ -15,5 +15,5 @@ function ClientEnv({ dataKey = "ENV" }) {
|
|
|
15
15
|
));
|
|
16
16
|
}
|
|
17
17
|
export {
|
|
18
|
-
ClientEnv
|
|
18
|
+
ClientEnv
|
|
19
19
|
};
|
|
@@ -27,46 +27,43 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
|
-
// src/
|
|
31
|
-
var
|
|
32
|
-
__export(
|
|
33
|
-
|
|
30
|
+
// src/client/index.ts
|
|
31
|
+
var client_exports = {};
|
|
32
|
+
__export(client_exports, {
|
|
33
|
+
ClientEnv: () => ClientEnv,
|
|
34
|
+
useUserAgent: () => useUserAgent
|
|
34
35
|
});
|
|
35
|
-
module.exports = __toCommonJS(
|
|
36
|
-
var import_react3 = __toESM(require("react"));
|
|
37
|
-
var import_fc = require("react-icons/fc");
|
|
38
|
-
var import_react_router2 = require("react-router");
|
|
36
|
+
module.exports = __toCommonJS(client_exports);
|
|
39
37
|
|
|
40
|
-
// src/
|
|
38
|
+
// src/client/client_env.tsx
|
|
41
39
|
var import_react = __toESM(require("react"));
|
|
42
|
-
var import_react2 = require("react");
|
|
43
40
|
var import_react_router = require("react-router");
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
// src/auth/client/google_login_button.tsx
|
|
50
|
-
function GoogleLoginButton({
|
|
51
|
-
className = "max-w-[300px] w-full"
|
|
52
|
-
}) {
|
|
53
|
-
const { loginWithGoogle } = useAuth();
|
|
54
|
-
const [searchParams] = (0, import_react_router2.useSearchParams)();
|
|
55
|
-
const redirectUrl = searchParams.get("redirectUrl") || "";
|
|
56
|
-
return /* @__PURE__ */ import_react3.default.createElement("div", { className }, /* @__PURE__ */ import_react3.default.createElement(
|
|
57
|
-
"button",
|
|
41
|
+
function ClientEnv({ dataKey = "ENV" }) {
|
|
42
|
+
const data = (0, import_react_router.useRouteLoaderData)("root");
|
|
43
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, data && /* @__PURE__ */ import_react.default.createElement(
|
|
44
|
+
"script",
|
|
58
45
|
{
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
/* @__PURE__ */ import_react3.default.createElement(import_fc.FcGoogle, null),
|
|
66
|
-
/* @__PURE__ */ import_react3.default.createElement("p", { className: "text-[14px] text-black absolute left-0 right-0 text-center" }, "\uAD6C\uAE00\uB85C \uACC4\uC18D\uD558\uAE30")
|
|
46
|
+
dangerouslySetInnerHTML: {
|
|
47
|
+
__html: `window.process = ${JSON.stringify({
|
|
48
|
+
env: data?.[dataKey]
|
|
49
|
+
})}`
|
|
50
|
+
}
|
|
51
|
+
}
|
|
67
52
|
));
|
|
68
53
|
}
|
|
54
|
+
|
|
55
|
+
// src/client/use_user_agent.tsx
|
|
56
|
+
var import_react_router2 = require("react-router");
|
|
57
|
+
function useUserAgent() {
|
|
58
|
+
const data = (0, import_react_router2.useRouteLoaderData)("root");
|
|
59
|
+
const userAgent = data?.userAgent || "";
|
|
60
|
+
const isMobile = /Mobi|Android/i.test(userAgent);
|
|
61
|
+
const isTablet = /Tablet|iPad/i.test(userAgent);
|
|
62
|
+
const isDesktop = !isMobile && !isTablet;
|
|
63
|
+
return { userAgent, isMobile, isTablet, isDesktop };
|
|
64
|
+
}
|
|
69
65
|
// Annotate the CommonJS export names for ESM import in node:
|
|
70
66
|
0 && (module.exports = {
|
|
71
|
-
|
|
67
|
+
ClientEnv,
|
|
68
|
+
useUserAgent
|
|
72
69
|
});
|