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.
Files changed (279) hide show
  1. package/dist/api/create_handler.d.mts +13 -0
  2. package/dist/api/create_handler.d.ts +13 -0
  3. package/dist/api/create_handler.js +298 -0
  4. package/dist/api/create_handler.mjs +304 -0
  5. package/dist/api/index.d.mts +4 -0
  6. package/dist/api/index.d.ts +4 -0
  7. package/dist/api/index.js +298 -0
  8. package/dist/api/index.mjs +304 -0
  9. package/dist/auth/client/index.d.mts +3 -0
  10. package/dist/auth/client/index.d.ts +3 -0
  11. package/dist/{date.js → auth/client/index.js} +25 -32
  12. package/dist/auth/client/index.mjs +21 -0
  13. package/dist/auth/client/redirect_page.d.mts +1 -0
  14. package/dist/auth/client/redirect_page.d.ts +1 -0
  15. package/dist/auth/cookie_store.d.mts +13 -0
  16. package/dist/auth/cookie_store.d.ts +13 -0
  17. package/dist/{text_editor/plugins/keymap.js → auth/cookie_store.js} +24 -16
  18. package/dist/auth/cookie_store.mjs +23 -0
  19. package/dist/auth/index.d.mts +5 -0
  20. package/dist/auth/index.d.ts +5 -0
  21. package/dist/auth/index.js +139 -0
  22. package/dist/auth/index.mjs +111 -0
  23. package/dist/auth/server/index.d.mts +1 -0
  24. package/dist/auth/server/index.d.ts +1 -0
  25. package/dist/{slug.js → auth/server/index.js} +6 -14
  26. package/dist/auth/server/index.mjs +2 -0
  27. package/dist/auth/with_auth.d.mts +2 -6
  28. package/dist/auth/with_auth.d.ts +2 -6
  29. package/dist/auth/with_auth.js +3 -0
  30. package/dist/auth/with_auth.mjs +3 -0
  31. package/dist/{components → client}/client_env.d.mts +1 -1
  32. package/dist/{components → client}/client_env.d.ts +1 -1
  33. package/dist/{components → client}/client_env.js +6 -2
  34. package/dist/{components → client}/client_env.mjs +2 -2
  35. package/dist/client/index.d.mts +3 -0
  36. package/dist/client/index.d.ts +3 -0
  37. package/dist/{auth/client/google_login_button.js → client/index.js} +30 -33
  38. package/dist/client/index.mjs +31 -0
  39. package/dist/client/use_user_agent.d.mts +8 -0
  40. package/dist/client/use_user_agent.d.ts +8 -0
  41. package/dist/{file/client/format_size.js → client/use_user_agent.js} +14 -14
  42. package/dist/client/use_user_agent.mjs +13 -0
  43. package/dist/file/client/index.d.mts +1 -0
  44. package/dist/file/client/index.d.ts +1 -0
  45. package/dist/file/{cdn.js → client/index.js} +6 -16
  46. package/dist/file/client/index.mjs +2 -0
  47. package/dist/file/index.d.mts +1 -0
  48. package/dist/file/index.d.ts +1 -0
  49. package/dist/{cn.js → file/index.js} +6 -14
  50. package/dist/file/index.mjs +2 -0
  51. package/dist/file/server/index.d.mts +1 -0
  52. package/dist/file/server/index.d.ts +1 -0
  53. package/dist/file/server/index.js +24 -0
  54. package/dist/file/server/index.mjs +2 -0
  55. package/dist/http/index.d.mts +1 -1
  56. package/dist/http/index.d.ts +1 -1
  57. package/dist/http/index.js +3 -90
  58. package/dist/http/index.mjs +2 -68
  59. package/dist/index.d.mts +8 -6
  60. package/dist/index.d.ts +8 -6
  61. package/dist/index.js +3 -79
  62. package/dist/index.mjs +2 -58
  63. package/dist/modal/index.d.mts +1 -0
  64. package/dist/modal/index.d.ts +1 -0
  65. package/dist/{sleep.js → modal/index.js} +6 -14
  66. package/dist/modal/index.mjs +2 -0
  67. package/dist/seo/index.d.mts +4 -0
  68. package/dist/seo/index.d.ts +4 -0
  69. package/dist/seo/index.js +304 -0
  70. package/dist/seo/index.mjs +267 -0
  71. package/dist/text_editor/index.d.mts +1 -0
  72. package/dist/text_editor/index.d.ts +1 -0
  73. package/dist/text_editor/index.js +24 -0
  74. package/dist/text_editor/index.mjs +2 -0
  75. package/package.json +58 -32
  76. package/dist/auth/apple_auth.d.mts +0 -38
  77. package/dist/auth/apple_auth.d.ts +0 -38
  78. package/dist/auth/apple_auth.js +0 -88
  79. package/dist/auth/apple_auth.mjs +0 -63
  80. package/dist/auth/auth_repository.d.mts +0 -41
  81. package/dist/auth/auth_repository.d.ts +0 -41
  82. package/dist/auth/auth_repository.js +0 -18
  83. package/dist/auth/auth_repository.mjs +0 -0
  84. package/dist/auth/auth_service.d.mts +0 -63
  85. package/dist/auth/auth_service.d.ts +0 -63
  86. package/dist/auth/auth_service.js +0 -210
  87. package/dist/auth/auth_service.mjs +0 -171
  88. package/dist/auth/client/google_login_button.d.mts +0 -7
  89. package/dist/auth/client/google_login_button.d.ts +0 -7
  90. package/dist/auth/client/google_login_button.mjs +0 -37
  91. package/dist/auth/client/provider.d.mts +0 -24
  92. package/dist/auth/client/provider.d.ts +0 -24
  93. package/dist/auth/client/provider.js +0 -154
  94. package/dist/auth/client/provider.mjs +0 -118
  95. package/dist/auth/google_auth.d.mts +0 -33
  96. package/dist/auth/google_auth.d.ts +0 -33
  97. package/dist/auth/google_auth.js +0 -135
  98. package/dist/auth/google_auth.mjs +0 -108
  99. package/dist/auth/handlers/find_auth.d.mts +0 -13
  100. package/dist/auth/handlers/find_auth.d.ts +0 -13
  101. package/dist/auth/handlers/find_auth.js +0 -82
  102. package/dist/auth/handlers/find_auth.mjs +0 -55
  103. package/dist/auth/handlers/login.d.mts +0 -13
  104. package/dist/auth/handlers/login.d.ts +0 -13
  105. package/dist/auth/handlers/login.js +0 -107
  106. package/dist/auth/handlers/login.mjs +0 -80
  107. package/dist/auth/handlers/login_with_thirdparty.d.mts +0 -15
  108. package/dist/auth/handlers/login_with_thirdparty.d.ts +0 -15
  109. package/dist/auth/handlers/login_with_thirdparty.js +0 -98
  110. package/dist/auth/handlers/login_with_thirdparty.mjs +0 -71
  111. package/dist/auth/handlers/logout.d.mts +0 -13
  112. package/dist/auth/handlers/logout.d.ts +0 -13
  113. package/dist/auth/handlers/logout.js +0 -102
  114. package/dist/auth/handlers/logout.mjs +0 -75
  115. package/dist/auth/handlers/refresh.d.mts +0 -13
  116. package/dist/auth/handlers/refresh.d.ts +0 -13
  117. package/dist/auth/handlers/refresh.js +0 -92
  118. package/dist/auth/handlers/refresh.mjs +0 -65
  119. package/dist/auth/handlers/request_password_reset.d.mts +0 -10
  120. package/dist/auth/handlers/request_password_reset.d.ts +0 -10
  121. package/dist/auth/handlers/request_password_reset.js +0 -87
  122. package/dist/auth/handlers/request_password_reset.mjs +0 -60
  123. package/dist/auth/handlers/reset_password.d.mts +0 -10
  124. package/dist/auth/handlers/reset_password.d.ts +0 -10
  125. package/dist/auth/handlers/reset_password.js +0 -88
  126. package/dist/auth/handlers/reset_password.mjs +0 -61
  127. package/dist/auth/handlers/signup.d.mts +0 -15
  128. package/dist/auth/handlers/signup.d.ts +0 -15
  129. package/dist/auth/handlers/signup.js +0 -147
  130. package/dist/auth/handlers/signup.mjs +0 -112
  131. package/dist/auth/handlers/signup_with_thirdparty.d.mts +0 -17
  132. package/dist/auth/handlers/signup_with_thirdparty.d.ts +0 -17
  133. package/dist/auth/handlers/signup_with_thirdparty.js +0 -123
  134. package/dist/auth/handlers/signup_with_thirdparty.mjs +0 -98
  135. package/dist/auth/handlers/thirdparty_auth_callback.d.mts +0 -16
  136. package/dist/auth/handlers/thirdparty_auth_callback.d.ts +0 -16
  137. package/dist/auth/handlers/thirdparty_auth_callback.js +0 -129
  138. package/dist/auth/handlers/thirdparty_auth_callback.mjs +0 -102
  139. package/dist/auth/jwt_manager.d.mts +0 -38
  140. package/dist/auth/jwt_manager.d.ts +0 -38
  141. package/dist/auth/jwt_manager.js +0 -90
  142. package/dist/auth/jwt_manager.mjs +0 -65
  143. package/dist/auth/kakao_auth.d.mts +0 -27
  144. package/dist/auth/kakao_auth.d.ts +0 -27
  145. package/dist/auth/kakao_auth.js +0 -56
  146. package/dist/auth/kakao_auth.mjs +0 -31
  147. package/dist/auth/password_recovery.d.mts +0 -34
  148. package/dist/auth/password_recovery.d.ts +0 -34
  149. package/dist/auth/password_recovery.js +0 -169
  150. package/dist/auth/password_recovery.mjs +0 -134
  151. package/dist/auth/thirdparty_auth.d.mts +0 -41
  152. package/dist/auth/thirdparty_auth.d.ts +0 -41
  153. package/dist/auth/thirdparty_auth.js +0 -113
  154. package/dist/auth/thirdparty_auth.mjs +0 -86
  155. package/dist/cn.d.mts +0 -3
  156. package/dist/cn.d.ts +0 -3
  157. package/dist/cn.mjs +0 -7
  158. package/dist/components/index.d.mts +0 -5
  159. package/dist/components/index.d.ts +0 -5
  160. package/dist/components/index.js +0 -261
  161. package/dist/components/index.mjs +0 -219
  162. package/dist/components/modal/fullscreen_container.d.mts +0 -7
  163. package/dist/components/modal/fullscreen_container.d.ts +0 -7
  164. package/dist/components/modal/fullscreen_container.js +0 -102
  165. package/dist/components/modal/fullscreen_container.mjs +0 -68
  166. package/dist/components/modal/hooks.d.mts +0 -18
  167. package/dist/components/modal/hooks.d.ts +0 -18
  168. package/dist/components/modal/hooks.js +0 -236
  169. package/dist/components/modal/hooks.mjs +0 -204
  170. package/dist/components/modal/index.d.mts +0 -4
  171. package/dist/components/modal/index.d.ts +0 -4
  172. package/dist/components/modal/index.js +0 -238
  173. package/dist/components/modal/index.mjs +0 -203
  174. package/dist/components/modal/modal.d.mts +0 -13
  175. package/dist/components/modal/modal.d.ts +0 -13
  176. package/dist/components/modal/modal.js +0 -155
  177. package/dist/components/modal/modal.mjs +0 -130
  178. package/dist/components/styles.d.mts +0 -9
  179. package/dist/components/styles.d.ts +0 -9
  180. package/dist/components/styles.js +0 -48
  181. package/dist/components/styles.mjs +0 -17
  182. package/dist/date.d.mts +0 -5
  183. package/dist/date.d.ts +0 -5
  184. package/dist/date.mjs +0 -29
  185. package/dist/file/cdn.d.mts +0 -6
  186. package/dist/file/cdn.d.ts +0 -6
  187. package/dist/file/cdn.mjs +0 -9
  188. package/dist/file/client/drop_file_input.d.mts +0 -36
  189. package/dist/file/client/drop_file_input.d.ts +0 -36
  190. package/dist/file/client/drop_file_input.js +0 -323
  191. package/dist/file/client/drop_file_input.mjs +0 -294
  192. package/dist/file/client/file_upload_button.d.mts +0 -10
  193. package/dist/file/client/file_upload_button.d.ts +0 -10
  194. package/dist/file/client/file_upload_button.js +0 -89
  195. package/dist/file/client/file_upload_button.mjs +0 -58
  196. package/dist/file/client/file_uploader.d.mts +0 -13
  197. package/dist/file/client/file_uploader.d.ts +0 -13
  198. package/dist/file/client/file_uploader.js +0 -163
  199. package/dist/file/client/file_uploader.mjs +0 -136
  200. package/dist/file/client/format_size.d.mts +0 -3
  201. package/dist/file/client/format_size.d.ts +0 -3
  202. package/dist/file/client/format_size.mjs +0 -13
  203. package/dist/file/client/metadata.d.mts +0 -7
  204. package/dist/file/client/metadata.d.ts +0 -7
  205. package/dist/file/client/metadata.js +0 -85
  206. package/dist/file/client/metadata.mjs +0 -60
  207. package/dist/file/file_repository.d.mts +0 -16
  208. package/dist/file/file_repository.d.ts +0 -16
  209. package/dist/file/file_repository.js +0 -18
  210. package/dist/file/file_repository.mjs +0 -0
  211. package/dist/file/file_service.d.mts +0 -32
  212. package/dist/file/file_service.d.ts +0 -32
  213. package/dist/file/file_service.js +0 -66
  214. package/dist/file/file_service.mjs +0 -41
  215. package/dist/file/handlers/delete_file.d.mts +0 -17
  216. package/dist/file/handlers/delete_file.d.ts +0 -17
  217. package/dist/file/handlers/delete_file.js +0 -99
  218. package/dist/file/handlers/delete_file.mjs +0 -72
  219. package/dist/file/handlers/upload_file.d.mts +0 -16
  220. package/dist/file/handlers/upload_file.d.ts +0 -16
  221. package/dist/file/handlers/upload_file.js +0 -106
  222. package/dist/file/handlers/upload_file.mjs +0 -79
  223. package/dist/file/object_storage.d.mts +0 -20
  224. package/dist/file/object_storage.d.ts +0 -20
  225. package/dist/file/object_storage.js +0 -90
  226. package/dist/file/object_storage.mjs +0 -70
  227. package/dist/file/responsive_image.d.mts +0 -20
  228. package/dist/file/responsive_image.d.ts +0 -20
  229. package/dist/file/responsive_image.js +0 -132
  230. package/dist/file/responsive_image.mjs +0 -96
  231. package/dist/http/response.d.mts +0 -19
  232. package/dist/http/response.d.ts +0 -19
  233. package/dist/http/response.js +0 -109
  234. package/dist/http/response.mjs +0 -68
  235. package/dist/route/api.d.mts +0 -21
  236. package/dist/route/api.d.ts +0 -21
  237. package/dist/route/api.js +0 -584
  238. package/dist/route/api.mjs +0 -547
  239. package/dist/singleton.d.mts +0 -3
  240. package/dist/singleton.d.ts +0 -3
  241. package/dist/singleton.js +0 -37
  242. package/dist/singleton.mjs +0 -12
  243. package/dist/sleep.d.mts +0 -3
  244. package/dist/sleep.d.ts +0 -3
  245. package/dist/sleep.mjs +0 -7
  246. package/dist/slug.d.mts +0 -3
  247. package/dist/slug.d.ts +0 -3
  248. package/dist/slug.mjs +0 -7
  249. package/dist/text_editor/attach_media.d.mts +0 -16
  250. package/dist/text_editor/attach_media.d.ts +0 -16
  251. package/dist/text_editor/attach_media.js +0 -237
  252. package/dist/text_editor/attach_media.mjs +0 -210
  253. package/dist/text_editor/plugins/drag_and_drop.d.mts +0 -13
  254. package/dist/text_editor/plugins/drag_and_drop.d.ts +0 -13
  255. package/dist/text_editor/plugins/drag_and_drop.js +0 -59
  256. package/dist/text_editor/plugins/drag_and_drop.mjs +0 -34
  257. package/dist/text_editor/plugins/keymap.d.mts +0 -5
  258. package/dist/text_editor/plugins/keymap.d.ts +0 -5
  259. package/dist/text_editor/plugins/keymap.mjs +0 -15
  260. package/dist/text_editor/plugins/placehoder.d.mts +0 -5
  261. package/dist/text_editor/plugins/placehoder.d.ts +0 -5
  262. package/dist/text_editor/plugins/placehoder.js +0 -112
  263. package/dist/text_editor/plugins/placehoder.mjs +0 -87
  264. package/dist/text_editor/plugins/trailing_paragraph.d.mts +0 -5
  265. package/dist/text_editor/plugins/trailing_paragraph.d.ts +0 -5
  266. package/dist/text_editor/plugins/trailing_paragraph.js +0 -46
  267. package/dist/text_editor/plugins/trailing_paragraph.mjs +0 -21
  268. package/dist/text_editor/plugins/upload_placeholder.d.mts +0 -7
  269. package/dist/text_editor/plugins/upload_placeholder.d.ts +0 -7
  270. package/dist/text_editor/plugins/upload_placeholder.js +0 -94
  271. package/dist/text_editor/plugins/upload_placeholder.mjs +0 -68
  272. package/dist/text_editor/schema.d.mts +0 -9
  273. package/dist/text_editor/schema.d.ts +0 -9
  274. package/dist/text_editor/schema.js +0 -354
  275. package/dist/text_editor/schema.mjs +0 -319
  276. package/dist/text_editor/text_editor.d.mts +0 -45
  277. package/dist/text_editor/text_editor.d.ts +0 -45
  278. package/dist/text_editor/text_editor.js +0 -834
  279. package/dist/text_editor/text_editor.mjs +0 -806
@@ -0,0 +1,298 @@
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/api/index.ts
22
+ var api_exports = {};
23
+ __export(api_exports, {
24
+ createAPIHandler: () => createAPIHandler
25
+ });
26
+ module.exports = __toCommonJS(api_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
33
+ var import_server = require("dn-react-toolkit/auth/server");
34
+
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
+ // src/auth/with_auth.ts
44
+ function createWithAuthHandler({ authService }) {
45
+ return function(fn) {
46
+ const handler = async function(arg) {
47
+ const respond = async (auth) => {
48
+ const userAgent = arg.request.headers.get("User-Agent") || "";
49
+ const res = await fn(auth)(arg);
50
+ if (typeof res === "object" && res !== null && !Array.isArray(res)) {
51
+ if (res instanceof Response) {
52
+ if (res.status < 300 && res.headers.get("Content-Type")?.includes("application/json")) {
53
+ const data = await res.json();
54
+ return new Response(
55
+ JSON.stringify({
56
+ AUTH: auth,
57
+ userAgent,
58
+ ...data
59
+ }),
60
+ {
61
+ status: res.status,
62
+ headers: res.headers
63
+ }
64
+ );
65
+ }
66
+ return res;
67
+ }
68
+ return {
69
+ AUTH: auth,
70
+ userAgent,
71
+ ...res
72
+ };
73
+ }
74
+ return res;
75
+ };
76
+ const accessToken = await authService.getAccessTokenFromRequest(
77
+ arg.request
78
+ );
79
+ if (accessToken) {
80
+ const payload = await authService.jwtManager.verifyAccessToken(
81
+ accessToken
82
+ );
83
+ if (payload) {
84
+ return respond(payload);
85
+ }
86
+ }
87
+ const refreshToken = await authService.getRefreshTokenFromCookies(
88
+ arg.request
89
+ );
90
+ if (refreshToken) {
91
+ try {
92
+ const newAccessToken = await authService.refreshAccessToken(
93
+ refreshToken
94
+ );
95
+ const setCookieHeader = await authService.getAccessTokenSetCookie(
96
+ newAccessToken
97
+ );
98
+ const headers = new Headers();
99
+ headers.append("Set-Cookie", setCookieHeader);
100
+ headers.append("Location", arg.request.url);
101
+ return new Response("Temporary Redirect", {
102
+ status: 307,
103
+ headers
104
+ });
105
+ } catch (e) {
106
+ if (e instanceof Error) {
107
+ console.log(e.message);
108
+ }
109
+ const setCookieHeader = await authService.getRefreshTokenSetCookie(
110
+ null
111
+ );
112
+ const headers = new Headers();
113
+ headers.append("Set-Cookie", setCookieHeader);
114
+ headers.append("Location", arg.request.url);
115
+ return new Response("Temporary Redirect", {
116
+ status: 307,
117
+ headers
118
+ });
119
+ }
120
+ }
121
+ return respond(void 0);
122
+ };
123
+ return handler;
124
+ };
125
+ }
126
+
127
+ // src/auth/cookie_store.ts
128
+ var import_react_router = require("react-router");
129
+ var ReactRouterCookieStore = class {
130
+ store;
131
+ constructor(key) {
132
+ this.store = (0, import_react_router.createCookie)(key, {
133
+ path: "/",
134
+ httpOnly: process.env.NODE_ENV === "production",
135
+ secure: process.env.NODE_ENV === "production",
136
+ sameSite: "strict"
137
+ });
138
+ }
139
+ parse(request) {
140
+ const cookieHeader = request.headers.get("cookie") || "";
141
+ return this.store.parse(cookieHeader);
142
+ }
143
+ serialize(value, options) {
144
+ return this.store.serialize(value, options);
145
+ }
146
+ };
147
+
148
+ // src/api/create_handler.ts
149
+ var import_server2 = require("dn-react-toolkit/file/server");
150
+ var createAPIHandler = ({
151
+ authService,
152
+ fileService,
153
+ passwordRecoveryService,
154
+ getThirdPartyAuth,
155
+ signupTokenSecret
156
+ }) => {
157
+ const handler = async (args) => {
158
+ const { request, params } = args;
159
+ const method = request.method.toUpperCase();
160
+ const slug = params["*"] ? params["*"].split("/") : [];
161
+ const withAuth = createWithAuthHandler({ authService });
162
+ switch (slug[0]) {
163
+ case "auth": {
164
+ switch (slug[1]) {
165
+ case void 0: {
166
+ switch (method) {
167
+ case "GET": {
168
+ return withAuth(
169
+ (auth) => ({ request: request2 }) => (0, import_server.findAuthHandler)(auth)(request2)
170
+ );
171
+ }
172
+ }
173
+ }
174
+ case "login": {
175
+ switch (slug[2]) {
176
+ case void 0: {
177
+ switch (method) {
178
+ case "POST": {
179
+ return (0, import_server.loginHandler)(request, {
180
+ authService
181
+ });
182
+ }
183
+ }
184
+ }
185
+ default: {
186
+ const provider = slug[2];
187
+ switch (method) {
188
+ case "POST": {
189
+ return (0, import_server.loginWithThirdPartyHandler)(request, {
190
+ provider,
191
+ getThirdPartyAuth
192
+ });
193
+ }
194
+ }
195
+ }
196
+ }
197
+ }
198
+ case "logout": {
199
+ switch (method) {
200
+ case "POST": {
201
+ return withAuth(
202
+ (auth) => async ({ request: request2 }) => (0, import_server.logoutHandler)({
203
+ authService
204
+ })(auth)(request2)
205
+ )(args);
206
+ }
207
+ }
208
+ }
209
+ case "refresh": {
210
+ switch (method) {
211
+ case "GET": {
212
+ return (0, import_server.refreshHandler)(request, { authService });
213
+ }
214
+ }
215
+ }
216
+ case "signup": {
217
+ switch (slug[2]) {
218
+ case void 0: {
219
+ switch (method) {
220
+ case "POST": {
221
+ return (0, import_server.signupHandler)(request, {
222
+ authService,
223
+ fileRepository: fileService.fileRepository
224
+ });
225
+ }
226
+ }
227
+ }
228
+ default: {
229
+ switch (method) {
230
+ case "POST": {
231
+ return (0, import_server.signUpWithThirdpartyHandler)(request, {
232
+ authService,
233
+ fileService,
234
+ signupTokenSecret
235
+ });
236
+ }
237
+ }
238
+ }
239
+ }
240
+ }
241
+ case "callback": {
242
+ if (slug[2]) {
243
+ const provider = slug[2];
244
+ if (method === "GET") {
245
+ return (0, import_server.thirdpartyAuthCallbackHandler)(request, {
246
+ provider,
247
+ authService,
248
+ getThirdPartyAuth
249
+ });
250
+ }
251
+ }
252
+ }
253
+ case "request-password-reset": {
254
+ return (0, import_server.requestPasswordResetHandler)(request, {
255
+ passwordRecoveryService
256
+ });
257
+ }
258
+ case "reset-password": {
259
+ return (0, import_server.resetPasswordHandler)(request, { passwordRecoveryService });
260
+ }
261
+ }
262
+ }
263
+ case "files": {
264
+ switch (slug[1]) {
265
+ case void 0: {
266
+ switch (method) {
267
+ case "POST": {
268
+ return withAuth(
269
+ (auth) => ({ request: request2 }) => (0, import_server2.uploadFileHandler)({ fileService })(auth)(request2)
270
+ )(args);
271
+ }
272
+ }
273
+ }
274
+ default: {
275
+ switch (method) {
276
+ case "DELETE": {
277
+ const fileId = slug[1];
278
+ return withAuth(
279
+ (auth) => () => (0, import_server2.deleteFileHandler)({
280
+ fileRepository: fileService.fileRepository
281
+ })({ fileId })(auth)()
282
+ );
283
+ }
284
+ }
285
+ }
286
+ }
287
+ }
288
+ default: {
289
+ return (0, http_exports.NOT_FOUND)();
290
+ }
291
+ }
292
+ };
293
+ return handler;
294
+ };
295
+ // Annotate the CommonJS export names for ESM import in node:
296
+ 0 && (module.exports = {
297
+ createAPIHandler
298
+ });
@@ -0,0 +1,304 @@
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
+ // src/api/create_handler.ts
25
+ import {
26
+ findAuthHandler,
27
+ loginHandler,
28
+ loginWithThirdPartyHandler,
29
+ logoutHandler,
30
+ refreshHandler,
31
+ requestPasswordResetHandler,
32
+ resetPasswordHandler,
33
+ signupHandler,
34
+ signUpWithThirdpartyHandler,
35
+ thirdpartyAuthCallbackHandler
36
+ } from "dn-react-toolkit/auth/server";
37
+
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
+ // src/auth/with_auth.ts
48
+ function createWithAuthHandler({ authService }) {
49
+ return function(fn) {
50
+ const handler = async function(arg) {
51
+ const respond = async (auth) => {
52
+ const userAgent = arg.request.headers.get("User-Agent") || "";
53
+ const res = await fn(auth)(arg);
54
+ if (typeof res === "object" && res !== null && !Array.isArray(res)) {
55
+ if (res instanceof Response) {
56
+ if (res.status < 300 && res.headers.get("Content-Type")?.includes("application/json")) {
57
+ const data = await res.json();
58
+ return new Response(
59
+ JSON.stringify({
60
+ AUTH: auth,
61
+ userAgent,
62
+ ...data
63
+ }),
64
+ {
65
+ status: res.status,
66
+ headers: res.headers
67
+ }
68
+ );
69
+ }
70
+ return res;
71
+ }
72
+ return {
73
+ AUTH: auth,
74
+ userAgent,
75
+ ...res
76
+ };
77
+ }
78
+ return res;
79
+ };
80
+ const accessToken = await authService.getAccessTokenFromRequest(
81
+ arg.request
82
+ );
83
+ if (accessToken) {
84
+ const payload = await authService.jwtManager.verifyAccessToken(
85
+ accessToken
86
+ );
87
+ if (payload) {
88
+ return respond(payload);
89
+ }
90
+ }
91
+ const refreshToken = await authService.getRefreshTokenFromCookies(
92
+ arg.request
93
+ );
94
+ if (refreshToken) {
95
+ try {
96
+ const newAccessToken = await authService.refreshAccessToken(
97
+ refreshToken
98
+ );
99
+ const setCookieHeader = await authService.getAccessTokenSetCookie(
100
+ newAccessToken
101
+ );
102
+ const headers = new Headers();
103
+ headers.append("Set-Cookie", setCookieHeader);
104
+ headers.append("Location", arg.request.url);
105
+ return new Response("Temporary Redirect", {
106
+ status: 307,
107
+ headers
108
+ });
109
+ } catch (e) {
110
+ if (e instanceof Error) {
111
+ console.log(e.message);
112
+ }
113
+ const setCookieHeader = await authService.getRefreshTokenSetCookie(
114
+ null
115
+ );
116
+ const headers = new Headers();
117
+ headers.append("Set-Cookie", setCookieHeader);
118
+ headers.append("Location", arg.request.url);
119
+ return new Response("Temporary Redirect", {
120
+ status: 307,
121
+ headers
122
+ });
123
+ }
124
+ }
125
+ return respond(void 0);
126
+ };
127
+ return handler;
128
+ };
129
+ }
130
+
131
+ // src/auth/cookie_store.ts
132
+ import { createCookie } from "react-router";
133
+ var ReactRouterCookieStore = class {
134
+ store;
135
+ constructor(key) {
136
+ this.store = createCookie(key, {
137
+ path: "/",
138
+ httpOnly: process.env.NODE_ENV === "production",
139
+ secure: process.env.NODE_ENV === "production",
140
+ sameSite: "strict"
141
+ });
142
+ }
143
+ parse(request) {
144
+ const cookieHeader = request.headers.get("cookie") || "";
145
+ return this.store.parse(cookieHeader);
146
+ }
147
+ serialize(value, options) {
148
+ return this.store.serialize(value, options);
149
+ }
150
+ };
151
+
152
+ // src/api/create_handler.ts
153
+ import {
154
+ deleteFileHandler,
155
+ uploadFileHandler
156
+ } from "dn-react-toolkit/file/server";
157
+ var createAPIHandler = ({
158
+ authService,
159
+ fileService,
160
+ passwordRecoveryService,
161
+ getThirdPartyAuth,
162
+ signupTokenSecret
163
+ }) => {
164
+ const handler = async (args) => {
165
+ const { request, params } = args;
166
+ const method = request.method.toUpperCase();
167
+ const slug = params["*"] ? params["*"].split("/") : [];
168
+ const withAuth = createWithAuthHandler({ authService });
169
+ switch (slug[0]) {
170
+ case "auth": {
171
+ switch (slug[1]) {
172
+ case void 0: {
173
+ switch (method) {
174
+ case "GET": {
175
+ return withAuth(
176
+ (auth) => ({ request: request2 }) => findAuthHandler(auth)(request2)
177
+ );
178
+ }
179
+ }
180
+ }
181
+ case "login": {
182
+ switch (slug[2]) {
183
+ case void 0: {
184
+ switch (method) {
185
+ case "POST": {
186
+ return loginHandler(request, {
187
+ authService
188
+ });
189
+ }
190
+ }
191
+ }
192
+ default: {
193
+ const provider = slug[2];
194
+ switch (method) {
195
+ case "POST": {
196
+ return loginWithThirdPartyHandler(request, {
197
+ provider,
198
+ getThirdPartyAuth
199
+ });
200
+ }
201
+ }
202
+ }
203
+ }
204
+ }
205
+ case "logout": {
206
+ switch (method) {
207
+ case "POST": {
208
+ return withAuth(
209
+ (auth) => async ({ request: request2 }) => logoutHandler({
210
+ authService
211
+ })(auth)(request2)
212
+ )(args);
213
+ }
214
+ }
215
+ }
216
+ case "refresh": {
217
+ switch (method) {
218
+ case "GET": {
219
+ return refreshHandler(request, { authService });
220
+ }
221
+ }
222
+ }
223
+ case "signup": {
224
+ switch (slug[2]) {
225
+ case void 0: {
226
+ switch (method) {
227
+ case "POST": {
228
+ return signupHandler(request, {
229
+ authService,
230
+ fileRepository: fileService.fileRepository
231
+ });
232
+ }
233
+ }
234
+ }
235
+ default: {
236
+ switch (method) {
237
+ case "POST": {
238
+ return signUpWithThirdpartyHandler(request, {
239
+ authService,
240
+ fileService,
241
+ signupTokenSecret
242
+ });
243
+ }
244
+ }
245
+ }
246
+ }
247
+ }
248
+ case "callback": {
249
+ if (slug[2]) {
250
+ const provider = slug[2];
251
+ if (method === "GET") {
252
+ return thirdpartyAuthCallbackHandler(request, {
253
+ provider,
254
+ authService,
255
+ getThirdPartyAuth
256
+ });
257
+ }
258
+ }
259
+ }
260
+ case "request-password-reset": {
261
+ return requestPasswordResetHandler(request, {
262
+ passwordRecoveryService
263
+ });
264
+ }
265
+ case "reset-password": {
266
+ return resetPasswordHandler(request, { passwordRecoveryService });
267
+ }
268
+ }
269
+ }
270
+ case "files": {
271
+ switch (slug[1]) {
272
+ case void 0: {
273
+ switch (method) {
274
+ case "POST": {
275
+ return withAuth(
276
+ (auth) => ({ request: request2 }) => uploadFileHandler({ fileService })(auth)(request2)
277
+ )(args);
278
+ }
279
+ }
280
+ }
281
+ default: {
282
+ switch (method) {
283
+ case "DELETE": {
284
+ const fileId = slug[1];
285
+ return withAuth(
286
+ (auth) => () => deleteFileHandler({
287
+ fileRepository: fileService.fileRepository
288
+ })({ fileId })(auth)()
289
+ );
290
+ }
291
+ }
292
+ }
293
+ }
294
+ }
295
+ default: {
296
+ return (0, http_exports.NOT_FOUND)();
297
+ }
298
+ }
299
+ };
300
+ return handler;
301
+ };
302
+ export {
303
+ createAPIHandler
304
+ };
@@ -0,0 +1,3 @@
1
+ export * from 'dn-react-toolkit/auth/client';
2
+ export { RedirectPage } from './redirect_page.mjs';
3
+ import 'react';
@@ -0,0 +1,3 @@
1
+ export * from 'dn-react-toolkit/auth/client';
2
+ export { RedirectPage } from './redirect_page.js';
3
+ import 'react';
@@ -17,6 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  }
18
18
  return to;
19
19
  };
20
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
21
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
22
  // If the importer is in node compatibility mode or this is not an ESM
22
23
  // file that has been converted to a CommonJS file using a Babel-
@@ -27,39 +28,31 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
28
  ));
28
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
30
 
30
- // src/date.ts
31
- var date_exports = {};
32
- __export(date_exports, {
33
- formatHumanDateTime: () => formatHumanDateTime,
34
- moment: () => import_moment_timezone.default
31
+ // src/auth/client/index.tsx
32
+ var client_exports = {};
33
+ __export(client_exports, {
34
+ RedirectPage: () => RedirectPage
35
35
  });
36
- module.exports = __toCommonJS(date_exports);
37
- var import_moment_timezone = __toESM(require("moment-timezone"));
38
- var formatHumanDateTime = (value) => {
39
- const date = (0, import_moment_timezone.default)(value).tz("Asia/Seoul");
40
- const now = (0, import_moment_timezone.default)().tz("Asia/Seoul");
41
- if (date.isAfter(now.clone().subtract(1, "minute"))) {
42
- return "\uBC29\uAE08 \uC804";
43
- }
44
- if (date.isAfter(now.clone().subtract(1, "hour"))) {
45
- const diff = now.diff(date, "minute");
46
- return `${diff}\uBD84 \uC804`;
47
- }
48
- if (date.isAfter(now.clone().subtract(6, "hours"))) {
49
- const diff = now.diff(date, "hour");
50
- return `${diff}\uC2DC\uAC04 \uC804`;
51
- }
52
- if (date.isAfter(now.clone().subtract(1, "week"))) {
53
- const diff = now.diff(date, "day");
54
- return `${diff}\uC77C \uC804`;
55
- }
56
- if (date.isSame(now, "year")) {
57
- return date.format("M\uC6D4 D\uC77C");
58
- }
59
- return date.format("YYYY\uB144 M\uC6D4 D\uC77C");
60
- };
36
+ module.exports = __toCommonJS(client_exports);
37
+ __reExport(client_exports, require("dn-react-toolkit/auth/client"), module.exports);
38
+
39
+ // src/auth/client/redirect_page.tsx
40
+ var import_react = __toESM(require("react"));
41
+ var import_react2 = require("react");
42
+ var import_react_router = require("react-router");
43
+ function RedirectPage() {
44
+ const navigate = (0, import_react_router.useNavigate)();
45
+ (0, import_react2.useEffect)(() => {
46
+ const searchParams = new URLSearchParams(window.location.search);
47
+ const redirectUrl = searchParams.get("redirectUrl") || new URL("/", window.location.origin).toString();
48
+ if (redirectUrl) {
49
+ navigate(redirectUrl);
50
+ }
51
+ }, [navigate]);
52
+ return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null);
53
+ }
61
54
  // Annotate the CommonJS export names for ESM import in node:
62
55
  0 && (module.exports = {
63
- formatHumanDateTime,
64
- moment
56
+ RedirectPage,
57
+ ...require("dn-react-toolkit/auth/client")
65
58
  });
@@ -0,0 +1,21 @@
1
+ // src/auth/client/index.tsx
2
+ export * from "dn-react-toolkit/auth/client";
3
+
4
+ // src/auth/client/redirect_page.tsx
5
+ import React from "react";
6
+ import { useEffect } from "react";
7
+ import { useNavigate } from "react-router";
8
+ function RedirectPage() {
9
+ const navigate = useNavigate();
10
+ useEffect(() => {
11
+ const searchParams = new URLSearchParams(window.location.search);
12
+ const redirectUrl = searchParams.get("redirectUrl") || new URL("/", window.location.origin).toString();
13
+ if (redirectUrl) {
14
+ navigate(redirectUrl);
15
+ }
16
+ }, [navigate]);
17
+ return /* @__PURE__ */ React.createElement(React.Fragment, null);
18
+ }
19
+ export {
20
+ RedirectPage
21
+ };