dn-react-router-toolkit 0.2.7 → 0.3.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.
Files changed (276) 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 +276 -0
  4. package/dist/api/create_handler.mjs +282 -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 +276 -0
  8. package/dist/api/index.mjs +282 -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/index.d.mts +4 -0
  16. package/dist/auth/index.d.ts +4 -0
  17. package/dist/auth/index.js +116 -0
  18. package/dist/auth/index.mjs +89 -0
  19. package/dist/auth/server/index.d.mts +1 -0
  20. package/dist/auth/server/index.d.ts +1 -0
  21. package/dist/{slug.js → auth/server/index.js} +6 -14
  22. package/dist/auth/server/index.mjs +2 -0
  23. package/dist/auth/with_auth.d.mts +2 -6
  24. package/dist/auth/with_auth.d.ts +2 -6
  25. package/dist/auth/with_auth.js +3 -0
  26. package/dist/auth/with_auth.mjs +3 -0
  27. package/dist/{components → client}/client_env.d.mts +1 -1
  28. package/dist/{components → client}/client_env.d.ts +1 -1
  29. package/dist/{components → client}/client_env.js +6 -2
  30. package/dist/{components → client}/client_env.mjs +2 -2
  31. package/dist/client/index.d.mts +3 -0
  32. package/dist/client/index.d.ts +3 -0
  33. package/dist/{auth/client/google_login_button.js → client/index.js} +30 -33
  34. package/dist/client/index.mjs +31 -0
  35. package/dist/client/use_user_agent.d.mts +8 -0
  36. package/dist/client/use_user_agent.d.ts +8 -0
  37. package/dist/{file/client/format_size.js → client/use_user_agent.js} +14 -14
  38. package/dist/client/use_user_agent.mjs +13 -0
  39. package/dist/file/client/index.d.mts +1 -0
  40. package/dist/file/client/index.d.ts +1 -0
  41. package/dist/file/{cdn.js → client/index.js} +6 -16
  42. package/dist/file/client/index.mjs +2 -0
  43. package/dist/file/index.d.mts +1 -0
  44. package/dist/file/index.d.ts +1 -0
  45. package/dist/{cn.js → file/index.js} +6 -14
  46. package/dist/file/index.mjs +2 -0
  47. package/dist/file/server/index.d.mts +1 -0
  48. package/dist/file/server/index.d.ts +1 -0
  49. package/dist/file/server/index.js +24 -0
  50. package/dist/file/server/index.mjs +2 -0
  51. package/dist/http/index.d.mts +1 -1
  52. package/dist/http/index.d.ts +1 -1
  53. package/dist/http/index.js +3 -90
  54. package/dist/http/index.mjs +2 -68
  55. package/dist/index.d.mts +8 -6
  56. package/dist/index.d.ts +8 -6
  57. package/dist/index.js +3 -79
  58. package/dist/index.mjs +2 -58
  59. package/dist/modal/index.d.mts +1 -0
  60. package/dist/modal/index.d.ts +1 -0
  61. package/dist/{sleep.js → modal/index.js} +6 -14
  62. package/dist/modal/index.mjs +2 -0
  63. package/dist/seo/index.d.mts +4 -0
  64. package/dist/seo/index.d.ts +4 -0
  65. package/dist/seo/index.js +304 -0
  66. package/dist/seo/index.mjs +267 -0
  67. package/dist/text_editor/index.d.mts +1 -0
  68. package/dist/text_editor/index.d.ts +1 -0
  69. package/dist/text_editor/index.js +24 -0
  70. package/dist/text_editor/index.mjs +2 -0
  71. package/package.json +58 -32
  72. package/dist/auth/apple_auth.d.mts +0 -38
  73. package/dist/auth/apple_auth.d.ts +0 -38
  74. package/dist/auth/apple_auth.js +0 -88
  75. package/dist/auth/apple_auth.mjs +0 -63
  76. package/dist/auth/auth_repository.d.mts +0 -41
  77. package/dist/auth/auth_repository.d.ts +0 -41
  78. package/dist/auth/auth_repository.js +0 -18
  79. package/dist/auth/auth_repository.mjs +0 -0
  80. package/dist/auth/auth_service.d.mts +0 -63
  81. package/dist/auth/auth_service.d.ts +0 -63
  82. package/dist/auth/auth_service.js +0 -210
  83. package/dist/auth/auth_service.mjs +0 -171
  84. package/dist/auth/client/google_login_button.d.mts +0 -7
  85. package/dist/auth/client/google_login_button.d.ts +0 -7
  86. package/dist/auth/client/google_login_button.mjs +0 -37
  87. package/dist/auth/client/provider.d.mts +0 -24
  88. package/dist/auth/client/provider.d.ts +0 -24
  89. package/dist/auth/client/provider.js +0 -154
  90. package/dist/auth/client/provider.mjs +0 -118
  91. package/dist/auth/google_auth.d.mts +0 -33
  92. package/dist/auth/google_auth.d.ts +0 -33
  93. package/dist/auth/google_auth.js +0 -135
  94. package/dist/auth/google_auth.mjs +0 -108
  95. package/dist/auth/handlers/find_auth.d.mts +0 -13
  96. package/dist/auth/handlers/find_auth.d.ts +0 -13
  97. package/dist/auth/handlers/find_auth.js +0 -82
  98. package/dist/auth/handlers/find_auth.mjs +0 -55
  99. package/dist/auth/handlers/login.d.mts +0 -13
  100. package/dist/auth/handlers/login.d.ts +0 -13
  101. package/dist/auth/handlers/login.js +0 -107
  102. package/dist/auth/handlers/login.mjs +0 -80
  103. package/dist/auth/handlers/login_with_thirdparty.d.mts +0 -15
  104. package/dist/auth/handlers/login_with_thirdparty.d.ts +0 -15
  105. package/dist/auth/handlers/login_with_thirdparty.js +0 -98
  106. package/dist/auth/handlers/login_with_thirdparty.mjs +0 -71
  107. package/dist/auth/handlers/logout.d.mts +0 -13
  108. package/dist/auth/handlers/logout.d.ts +0 -13
  109. package/dist/auth/handlers/logout.js +0 -102
  110. package/dist/auth/handlers/logout.mjs +0 -75
  111. package/dist/auth/handlers/refresh.d.mts +0 -13
  112. package/dist/auth/handlers/refresh.d.ts +0 -13
  113. package/dist/auth/handlers/refresh.js +0 -92
  114. package/dist/auth/handlers/refresh.mjs +0 -65
  115. package/dist/auth/handlers/request_password_reset.d.mts +0 -10
  116. package/dist/auth/handlers/request_password_reset.d.ts +0 -10
  117. package/dist/auth/handlers/request_password_reset.js +0 -87
  118. package/dist/auth/handlers/request_password_reset.mjs +0 -60
  119. package/dist/auth/handlers/reset_password.d.mts +0 -10
  120. package/dist/auth/handlers/reset_password.d.ts +0 -10
  121. package/dist/auth/handlers/reset_password.js +0 -88
  122. package/dist/auth/handlers/reset_password.mjs +0 -61
  123. package/dist/auth/handlers/signup.d.mts +0 -15
  124. package/dist/auth/handlers/signup.d.ts +0 -15
  125. package/dist/auth/handlers/signup.js +0 -147
  126. package/dist/auth/handlers/signup.mjs +0 -112
  127. package/dist/auth/handlers/signup_with_thirdparty.d.mts +0 -17
  128. package/dist/auth/handlers/signup_with_thirdparty.d.ts +0 -17
  129. package/dist/auth/handlers/signup_with_thirdparty.js +0 -123
  130. package/dist/auth/handlers/signup_with_thirdparty.mjs +0 -98
  131. package/dist/auth/handlers/thirdparty_auth_callback.d.mts +0 -16
  132. package/dist/auth/handlers/thirdparty_auth_callback.d.ts +0 -16
  133. package/dist/auth/handlers/thirdparty_auth_callback.js +0 -129
  134. package/dist/auth/handlers/thirdparty_auth_callback.mjs +0 -102
  135. package/dist/auth/jwt_manager.d.mts +0 -38
  136. package/dist/auth/jwt_manager.d.ts +0 -38
  137. package/dist/auth/jwt_manager.js +0 -90
  138. package/dist/auth/jwt_manager.mjs +0 -65
  139. package/dist/auth/kakao_auth.d.mts +0 -27
  140. package/dist/auth/kakao_auth.d.ts +0 -27
  141. package/dist/auth/kakao_auth.js +0 -56
  142. package/dist/auth/kakao_auth.mjs +0 -31
  143. package/dist/auth/password_recovery.d.mts +0 -34
  144. package/dist/auth/password_recovery.d.ts +0 -34
  145. package/dist/auth/password_recovery.js +0 -169
  146. package/dist/auth/password_recovery.mjs +0 -134
  147. package/dist/auth/thirdparty_auth.d.mts +0 -41
  148. package/dist/auth/thirdparty_auth.d.ts +0 -41
  149. package/dist/auth/thirdparty_auth.js +0 -113
  150. package/dist/auth/thirdparty_auth.mjs +0 -86
  151. package/dist/cn.d.mts +0 -3
  152. package/dist/cn.d.ts +0 -3
  153. package/dist/cn.mjs +0 -7
  154. package/dist/components/index.d.mts +0 -5
  155. package/dist/components/index.d.ts +0 -5
  156. package/dist/components/index.js +0 -261
  157. package/dist/components/index.mjs +0 -219
  158. package/dist/components/modal/fullscreen_container.d.mts +0 -7
  159. package/dist/components/modal/fullscreen_container.d.ts +0 -7
  160. package/dist/components/modal/fullscreen_container.js +0 -102
  161. package/dist/components/modal/fullscreen_container.mjs +0 -68
  162. package/dist/components/modal/hooks.d.mts +0 -18
  163. package/dist/components/modal/hooks.d.ts +0 -18
  164. package/dist/components/modal/hooks.js +0 -236
  165. package/dist/components/modal/hooks.mjs +0 -204
  166. package/dist/components/modal/index.d.mts +0 -4
  167. package/dist/components/modal/index.d.ts +0 -4
  168. package/dist/components/modal/index.js +0 -238
  169. package/dist/components/modal/index.mjs +0 -203
  170. package/dist/components/modal/modal.d.mts +0 -13
  171. package/dist/components/modal/modal.d.ts +0 -13
  172. package/dist/components/modal/modal.js +0 -155
  173. package/dist/components/modal/modal.mjs +0 -130
  174. package/dist/components/styles.d.mts +0 -9
  175. package/dist/components/styles.d.ts +0 -9
  176. package/dist/components/styles.js +0 -48
  177. package/dist/components/styles.mjs +0 -17
  178. package/dist/date.d.mts +0 -5
  179. package/dist/date.d.ts +0 -5
  180. package/dist/date.mjs +0 -29
  181. package/dist/file/cdn.d.mts +0 -6
  182. package/dist/file/cdn.d.ts +0 -6
  183. package/dist/file/cdn.mjs +0 -9
  184. package/dist/file/client/drop_file_input.d.mts +0 -36
  185. package/dist/file/client/drop_file_input.d.ts +0 -36
  186. package/dist/file/client/drop_file_input.js +0 -323
  187. package/dist/file/client/drop_file_input.mjs +0 -294
  188. package/dist/file/client/file_upload_button.d.mts +0 -10
  189. package/dist/file/client/file_upload_button.d.ts +0 -10
  190. package/dist/file/client/file_upload_button.js +0 -89
  191. package/dist/file/client/file_upload_button.mjs +0 -58
  192. package/dist/file/client/file_uploader.d.mts +0 -13
  193. package/dist/file/client/file_uploader.d.ts +0 -13
  194. package/dist/file/client/file_uploader.js +0 -163
  195. package/dist/file/client/file_uploader.mjs +0 -136
  196. package/dist/file/client/format_size.d.mts +0 -3
  197. package/dist/file/client/format_size.d.ts +0 -3
  198. package/dist/file/client/format_size.mjs +0 -13
  199. package/dist/file/client/metadata.d.mts +0 -7
  200. package/dist/file/client/metadata.d.ts +0 -7
  201. package/dist/file/client/metadata.js +0 -85
  202. package/dist/file/client/metadata.mjs +0 -60
  203. package/dist/file/file_repository.d.mts +0 -16
  204. package/dist/file/file_repository.d.ts +0 -16
  205. package/dist/file/file_repository.js +0 -18
  206. package/dist/file/file_repository.mjs +0 -0
  207. package/dist/file/file_service.d.mts +0 -32
  208. package/dist/file/file_service.d.ts +0 -32
  209. package/dist/file/file_service.js +0 -66
  210. package/dist/file/file_service.mjs +0 -41
  211. package/dist/file/handlers/delete_file.d.mts +0 -17
  212. package/dist/file/handlers/delete_file.d.ts +0 -17
  213. package/dist/file/handlers/delete_file.js +0 -99
  214. package/dist/file/handlers/delete_file.mjs +0 -72
  215. package/dist/file/handlers/upload_file.d.mts +0 -16
  216. package/dist/file/handlers/upload_file.d.ts +0 -16
  217. package/dist/file/handlers/upload_file.js +0 -106
  218. package/dist/file/handlers/upload_file.mjs +0 -79
  219. package/dist/file/object_storage.d.mts +0 -20
  220. package/dist/file/object_storage.d.ts +0 -20
  221. package/dist/file/object_storage.js +0 -90
  222. package/dist/file/object_storage.mjs +0 -70
  223. package/dist/file/responsive_image.d.mts +0 -20
  224. package/dist/file/responsive_image.d.ts +0 -20
  225. package/dist/file/responsive_image.js +0 -132
  226. package/dist/file/responsive_image.mjs +0 -96
  227. package/dist/http/response.d.mts +0 -19
  228. package/dist/http/response.d.ts +0 -19
  229. package/dist/http/response.js +0 -109
  230. package/dist/http/response.mjs +0 -68
  231. package/dist/route/api.d.mts +0 -21
  232. package/dist/route/api.d.ts +0 -21
  233. package/dist/route/api.js +0 -584
  234. package/dist/route/api.mjs +0 -547
  235. package/dist/singleton.d.mts +0 -3
  236. package/dist/singleton.d.ts +0 -3
  237. package/dist/singleton.js +0 -37
  238. package/dist/singleton.mjs +0 -12
  239. package/dist/sleep.d.mts +0 -3
  240. package/dist/sleep.d.ts +0 -3
  241. package/dist/sleep.mjs +0 -7
  242. package/dist/slug.d.mts +0 -3
  243. package/dist/slug.d.ts +0 -3
  244. package/dist/slug.mjs +0 -7
  245. package/dist/text_editor/attach_media.d.mts +0 -16
  246. package/dist/text_editor/attach_media.d.ts +0 -16
  247. package/dist/text_editor/attach_media.js +0 -237
  248. package/dist/text_editor/attach_media.mjs +0 -210
  249. package/dist/text_editor/plugins/drag_and_drop.d.mts +0 -13
  250. package/dist/text_editor/plugins/drag_and_drop.d.ts +0 -13
  251. package/dist/text_editor/plugins/drag_and_drop.js +0 -59
  252. package/dist/text_editor/plugins/drag_and_drop.mjs +0 -34
  253. package/dist/text_editor/plugins/keymap.d.mts +0 -5
  254. package/dist/text_editor/plugins/keymap.d.ts +0 -5
  255. package/dist/text_editor/plugins/keymap.js +0 -40
  256. package/dist/text_editor/plugins/keymap.mjs +0 -15
  257. package/dist/text_editor/plugins/placehoder.d.mts +0 -5
  258. package/dist/text_editor/plugins/placehoder.d.ts +0 -5
  259. package/dist/text_editor/plugins/placehoder.js +0 -112
  260. package/dist/text_editor/plugins/placehoder.mjs +0 -87
  261. package/dist/text_editor/plugins/trailing_paragraph.d.mts +0 -5
  262. package/dist/text_editor/plugins/trailing_paragraph.d.ts +0 -5
  263. package/dist/text_editor/plugins/trailing_paragraph.js +0 -46
  264. package/dist/text_editor/plugins/trailing_paragraph.mjs +0 -21
  265. package/dist/text_editor/plugins/upload_placeholder.d.mts +0 -7
  266. package/dist/text_editor/plugins/upload_placeholder.d.ts +0 -7
  267. package/dist/text_editor/plugins/upload_placeholder.js +0 -94
  268. package/dist/text_editor/plugins/upload_placeholder.mjs +0 -68
  269. package/dist/text_editor/schema.d.mts +0 -9
  270. package/dist/text_editor/schema.d.ts +0 -9
  271. package/dist/text_editor/schema.js +0 -354
  272. package/dist/text_editor/schema.mjs +0 -319
  273. package/dist/text_editor/text_editor.d.mts +0 -45
  274. package/dist/text_editor/text_editor.d.ts +0 -45
  275. package/dist/text_editor/text_editor.js +0 -834
  276. package/dist/text_editor/text_editor.mjs +0 -806
@@ -1,547 +0,0 @@
1
- // src/http/response.ts
2
- var createJsonResponse = (status) => {
3
- return (data = {}, init) => {
4
- return Response.json(data, { status, ...init });
5
- };
6
- };
7
- var OK = createJsonResponse(200);
8
- var CREATED = createJsonResponse(201);
9
- var ACCEPTED = createJsonResponse(202);
10
- var NO_CONTENT = (init) => {
11
- return new Response(null, {
12
- ...init,
13
- status: 204
14
- });
15
- };
16
- var createException = (status, defaultMessage = "\uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4.") => {
17
- return (message = defaultMessage, init) => {
18
- return createJsonResponse(status)({ message }, init);
19
- };
20
- };
21
- var BAD_REQUEST = createException(400, "\uC694\uCCAD\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.");
22
- var UNAUTHORIZED = createException(401, "\uC778\uC99D\uC774 \uD544\uC694\uD569\uB2C8\uB2E4.");
23
- var FORBIDDEN = createException(403, "\uAD8C\uD55C\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.");
24
- var NOT_FOUND = createException(
25
- 404,
26
- "\uC694\uCCAD\uD55C \uB9AC\uC18C\uC2A4\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."
27
- );
28
- var METHOD_NOT_ALLOWED = createException(
29
- 405,
30
- "\uBA54\uC11C\uB4DC\uB97C \uC0AC\uC6A9\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."
31
- );
32
- var NOT_ACCEPTABLE = createException(
33
- 406,
34
- "\uC694\uCCAD\uD55C \uD615\uC2DD\uC744 \uC0AC\uC6A9\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."
35
- );
36
- var REQUEST_TIMEOUT = createException(
37
- 408,
38
- "\uC694\uCCAD \uC2DC\uAC04\uC774 \uCD08\uACFC\uB418\uC5C8\uC2B5\uB2C8\uB2E4."
39
- );
40
- var CONFLICT = createException(409, "\uC694\uCCAD\uC774 \uCDA9\uB3CC\uD588\uC2B5\uB2C8\uB2E4.");
41
- var UNPROCESSABLE_ENTITY = createException(
42
- 422,
43
- "\uCC98\uB9AC\uD560 \uC218 \uC5C6\uB294 \uC5D4\uD2F0\uD2F0\uC785\uB2C8\uB2E4."
44
- );
45
- var TOO_MANY_REQUESTS = createException(429, "\uC694\uCCAD\uC774 \uB108\uBB34 \uB9CE\uC2B5\uB2C8\uB2E4.");
46
- var INTERNAL_SERVER_ERROR = createException(
47
- 500,
48
- "\uC608\uAE30\uCE58 \uBABB\uD55C \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."
49
- );
50
-
51
- // src/auth/handlers/thirdparty_auth_callback.tsx
52
- var thirdpartyAuthCallbackHandler = async (request, {
53
- provider,
54
- authService,
55
- getThirdPartyAuth
56
- }) => {
57
- const url = new URL(request.url);
58
- const code = url.searchParams.get("code");
59
- if (!code) {
60
- throw BAD_REQUEST("\uCF54\uB4DC\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
61
- }
62
- try {
63
- const { accessToken, refreshToken } = await getThirdPartyAuth(
64
- provider
65
- ).login(code);
66
- const [accessTokenSetCookie, refreshTokenSetCookie] = await Promise.all([
67
- authService.getAccessTokenSetCookie(accessToken),
68
- authService.getRefreshTokenSetCookie(refreshToken)
69
- ]);
70
- const headers = new Headers();
71
- headers.append("Set-Cookie", accessTokenSetCookie);
72
- headers.append("Set-Cookie", refreshTokenSetCookie);
73
- const redirectUrl = url.searchParams.get("state") || "/";
74
- return new Response("Temporary Redirect", {
75
- status: 307,
76
- headers: {
77
- ...headers,
78
- Location: new URL(
79
- `/r?redirectUrl=${encodeURIComponent(redirectUrl)}`,
80
- request.url
81
- ).toString()
82
- }
83
- });
84
- } catch (error) {
85
- if (error instanceof Response) {
86
- if (error.status == 404) {
87
- const body = await error.json();
88
- const token = body.token;
89
- return new Response(
90
- "Temporary Redirect",
91
- {
92
- status: 307,
93
- headers: {
94
- Location: new URL(
95
- `/signup?token=${token}`,
96
- request.url
97
- ).toString()
98
- }
99
- }
100
- );
101
- }
102
- }
103
- throw error;
104
- }
105
- };
106
-
107
- // src/file/handlers/upload_file.ts
108
- var uploadFileHandler = async (request, {
109
- authService,
110
- fileService
111
- }) => {
112
- const auth = await authService.verifyOrRefresh(request);
113
- const { name, type, size, metadata } = await request.json();
114
- const headers = {
115
- "Access-Control-Allow-Origin": "*"
116
- };
117
- if (typeof name !== "string") {
118
- return BAD_REQUEST("\uD30C\uC77C \uC774\uB984\uC774 \uD544\uC694\uD574\uC694.", { headers });
119
- }
120
- if (typeof type !== "string") {
121
- return BAD_REQUEST("\uD30C\uC77C \uD0C0\uC785\uC774 \uD544\uC694\uD574\uC694.", { headers });
122
- }
123
- try {
124
- const result = await fileService.generateSignedUrl({
125
- userId: auth?.userId,
126
- name,
127
- type,
128
- size,
129
- metadata
130
- });
131
- return CREATED(result, { headers });
132
- } catch (e) {
133
- if (e instanceof Error) {
134
- return INTERNAL_SERVER_ERROR(e.message, { headers });
135
- }
136
- return INTERNAL_SERVER_ERROR(e, { headers });
137
- }
138
- };
139
-
140
- // src/file/handlers/delete_file.ts
141
- var deleteFileHandler = async (request, { fileId }, {
142
- authService,
143
- fileRepository
144
- }) => {
145
- const auth = await authService.verifyOrRefresh(request);
146
- const file = await fileRepository.findFileById(fileId);
147
- const headers = {
148
- "Access-Control-Allow-Origin": "*"
149
- };
150
- if (!file) {
151
- return NOT_FOUND("\uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.", { headers });
152
- }
153
- if (!fileRepository.hasPermission(file, auth?.userId)) {
154
- return FORBIDDEN("\uD30C\uC77C\uC744 \uC0AD\uC81C\uD560 \uAD8C\uD55C\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.", { headers });
155
- }
156
- await fileRepository.deleteFile(fileId);
157
- return NO_CONTENT({ headers });
158
- };
159
-
160
- // src/auth/handlers/find_auth.ts
161
- var findAuthHandler = async (request, { authService }) => {
162
- const auth = await authService.verifyOrRefresh(request);
163
- if (!auth) {
164
- return UNAUTHORIZED();
165
- }
166
- return OK(auth);
167
- };
168
-
169
- // src/auth/handlers/login_with_thirdparty.ts
170
- var loginWithThirdPartyHandler = async (request, {
171
- provider,
172
- getThirdPartyAuth
173
- }) => {
174
- const { code } = await request.json();
175
- if (!code) {
176
- return BAD_REQUEST("\uCF54\uB4DC\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
177
- }
178
- try {
179
- const { accessToken, refreshToken } = await getThirdPartyAuth(
180
- provider
181
- ).login(code);
182
- return CREATED({
183
- accessToken,
184
- refreshToken
185
- });
186
- } catch (error) {
187
- if (error instanceof Response) {
188
- return error;
189
- }
190
- throw INTERNAL_SERVER_ERROR();
191
- }
192
- };
193
-
194
- // src/auth/handlers/login.ts
195
- var loginHandler = async (request, {
196
- authService
197
- }) => {
198
- const { id, password } = await request.json();
199
- try {
200
- const { accessToken, refreshToken } = await authService.login({
201
- id,
202
- password
203
- });
204
- const searchParams = new URL(request.url).searchParams;
205
- const type = searchParams.get("type");
206
- if (type === "json") {
207
- return CREATED({ accessToken, refreshToken });
208
- }
209
- const [accessTokenSetCookie, refreshTokenSetCookie] = await Promise.all([
210
- authService.getAccessTokenSetCookie(accessToken),
211
- authService.getRefreshTokenSetCookie(refreshToken)
212
- ]);
213
- const payload = authService.jwtManager.decode(accessToken);
214
- const headers = new Headers();
215
- headers.append("Set-Cookie", accessTokenSetCookie);
216
- headers.append("Set-Cookie", refreshTokenSetCookie);
217
- return CREATED(payload, {
218
- headers
219
- });
220
- } catch (e) {
221
- if (e instanceof Error) {
222
- return UNAUTHORIZED(e.message);
223
- }
224
- throw e;
225
- }
226
- };
227
-
228
- // src/auth/handlers/logout.ts
229
- var logoutHandler = async (request, { authService }) => {
230
- const auth = await authService.verifyOrRefresh(request);
231
- if (!auth) {
232
- return UNAUTHORIZED();
233
- }
234
- await authService.authRepository.updateUserRefreshToken(auth.userId, null);
235
- const type = new URL(request.url).searchParams.get("type");
236
- if (type === "json") {
237
- return NO_CONTENT();
238
- }
239
- const headers = new Headers();
240
- const [accessTokenSetCookie, refreshTokenSetCookie] = await Promise.all([
241
- authService.getAccessTokenSetCookie(null),
242
- authService.getRefreshTokenSetCookie(null)
243
- ]);
244
- headers.append("Set-Cookie", accessTokenSetCookie);
245
- headers.append("Set-Cookie", refreshTokenSetCookie);
246
- return NO_CONTENT({
247
- headers
248
- });
249
- };
250
-
251
- // src/auth/handlers/refresh.ts
252
- var refreshHandler = async (request, {
253
- authService
254
- }) => {
255
- const refreshToken = request?.headers.get("Authorization")?.replace("Bearer ", "") || await authService.getRefreshTokenFromCookies(request);
256
- if (!refreshToken) {
257
- return BAD_REQUEST();
258
- }
259
- try {
260
- const accessToken = await authService.refreshAccessToken(refreshToken);
261
- return CREATED({ accessToken });
262
- } catch (e) {
263
- if (e instanceof Error) {
264
- return UNAUTHORIZED(e.message);
265
- }
266
- throw e;
267
- }
268
- };
269
-
270
- // src/auth/handlers/signup.ts
271
- import { v5 } from "uuid";
272
- import * as bcrypt from "bcryptjs";
273
- var signupHandler = async (request, {
274
- authService,
275
- fileRepository
276
- }) => {
277
- const body = await request.json();
278
- const {
279
- email,
280
- password,
281
- passwordConfirm,
282
- name,
283
- profileImageId
284
- } = body;
285
- if (!email) {
286
- return BAD_REQUEST("\uC774\uBA54\uC77C\uC744 \uC785\uB825\uD574\uC8FC\uC138\uC694.");
287
- }
288
- if (!password) {
289
- return BAD_REQUEST("\uBE44\uBC00\uBC88\uD638\uB97C \uC785\uB825\uD574\uC8FC\uC138\uC694.");
290
- }
291
- if (!passwordConfirm) {
292
- return BAD_REQUEST("\uBE44\uBC00\uBC88\uD638 \uD655\uC778\uC744 \uC785\uB825\uD574\uC8FC\uC138\uC694.");
293
- }
294
- const existing = await authService.authRepository.findCredentialById(email);
295
- if (existing) {
296
- return CONFLICT("\uC774\uBBF8 \uAC00\uC785\uD55C \uC774\uBA54\uC77C\uC785\uB2C8\uB2E4.");
297
- }
298
- if (password !== passwordConfirm) {
299
- return BAD_REQUEST("\uBE44\uBC00\uBC88\uD638\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.");
300
- }
301
- const profileImage = profileImageId ? await fileRepository.findFileById(profileImageId) : void 0;
302
- const userId = v5(email, v5.DNS);
303
- const user = await authService.authRepository.createUser({
304
- id: userId,
305
- name,
306
- role: "user",
307
- email,
308
- profileImage
309
- });
310
- await authService.authRepository.createCredential({
311
- id: email,
312
- userId,
313
- password: bcrypt.hashSync(password, 10)
314
- });
315
- const { accessToken, refreshToken } = await authService.issueTokenPair(user);
316
- const searchParams = new URL(request.url).searchParams;
317
- const type = searchParams.get("type");
318
- if (type === "json") {
319
- return CREATED({ accessToken, refreshToken });
320
- }
321
- const [accessTokenSetCookie, refreshTokenSetCookie] = await Promise.all([
322
- authService.getAccessTokenSetCookie(accessToken),
323
- authService.getRefreshTokenSetCookie(refreshToken)
324
- ]);
325
- const payload = authService.jwtManager.decode(accessToken);
326
- const headers = new Headers();
327
- headers.append("Set-Cookie", accessTokenSetCookie);
328
- headers.append("Set-Cookie", refreshTokenSetCookie);
329
- return CREATED(payload, {
330
- headers
331
- });
332
- };
333
-
334
- // src/auth/handlers/signup_with_thirdparty.ts
335
- import { v5 as v52 } from "uuid";
336
- var signUpWithThirdpartyHandler = async (request, {
337
- authService,
338
- fileService,
339
- signupTokenSecret
340
- }) => {
341
- const body = await request.json();
342
- const {
343
- token
344
- } = body;
345
- const payload = await authService.jwtManager.verify(token, signupTokenSecret);
346
- const { provider, id: thirdpartyId, email, name, picture } = payload;
347
- const existing = await authService.authRepository.findThirdPartyAuth(
348
- provider,
349
- thirdpartyId
350
- );
351
- if (existing) {
352
- return CONFLICT("\uC774\uBBF8 \uAC00\uC785\uB41C \uC81C3\uC790 \uC778\uC99D \uC815\uBCF4\uC785\uB2C8\uB2E4.");
353
- }
354
- const userId = v52(thirdpartyId, v52.DNS);
355
- const profileImage = await (async () => {
356
- if (!picture) {
357
- return;
358
- }
359
- const arrayBuffer = await fetch(picture).then((res) => res.arrayBuffer());
360
- const { file } = await fileService.putFile(Buffer.from(arrayBuffer), {
361
- userId,
362
- name: "profile.jpg",
363
- type: "image/jpeg",
364
- size: arrayBuffer.byteLength
365
- });
366
- return file;
367
- })();
368
- const user = await authService.authRepository.createUser({
369
- id: userId,
370
- name,
371
- role: "user",
372
- email,
373
- profileImage
374
- });
375
- await authService.authRepository.createThirdPartyAuth({
376
- id: thirdpartyId,
377
- provider,
378
- userId
379
- });
380
- const { accessToken, refreshToken } = await authService.issueTokenPair(user);
381
- return CREATED({ accessToken, refreshToken });
382
- };
383
-
384
- // src/auth/handlers/request_password_reset.ts
385
- var requestPasswordResetHandler = async (request, {
386
- passwordRecoveryService
387
- }) => {
388
- const { email } = await request.json();
389
- try {
390
- await passwordRecoveryService.requestPasswordReset(email);
391
- return CREATED({ message: "\uBE44\uBC00\uBC88\uD638 \uC7AC\uC124\uC815 \uC774\uBA54\uC77C\uC744 \uC804\uC1A1\uD588\uC2B5\uB2C8\uB2E4." });
392
- } catch (error) {
393
- console.error(error);
394
- return INTERNAL_SERVER_ERROR("\uC774\uBA54\uC77C \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4.");
395
- }
396
- };
397
-
398
- // src/auth/handlers/reset_password.ts
399
- var resetPasswordHandler = async (request, {
400
- passwordRecoveryService
401
- }) => {
402
- const { token, password, passwordConfirm } = await request.json();
403
- await passwordRecoveryService.resetPassword(token, password, passwordConfirm);
404
- return NO_CONTENT();
405
- };
406
-
407
- // src/route/api.ts
408
- var createAPIHandler = ({
409
- authService,
410
- fileService,
411
- passwordRecoveryService,
412
- getThirdPartyAuth,
413
- signupTokenSecret
414
- }) => {
415
- const handler = async ({ request, params }) => {
416
- const method = request.method.toUpperCase();
417
- const slug = params["*"] ? params["*"].split("/") : [];
418
- switch (slug[0]) {
419
- case "auth": {
420
- switch (slug[1]) {
421
- case void 0: {
422
- switch (method) {
423
- case "GET": {
424
- return findAuthHandler(request, { authService });
425
- }
426
- }
427
- }
428
- case "login": {
429
- switch (slug[2]) {
430
- case void 0: {
431
- switch (method) {
432
- case "POST": {
433
- return loginHandler(request, {
434
- authService
435
- });
436
- }
437
- }
438
- }
439
- default: {
440
- const provider = slug[2];
441
- switch (method) {
442
- case "POST": {
443
- return loginWithThirdPartyHandler(
444
- request,
445
- { provider, getThirdPartyAuth }
446
- );
447
- }
448
- }
449
- }
450
- }
451
- }
452
- case "logout": {
453
- switch (method) {
454
- case "POST": {
455
- return logoutHandler(request, {
456
- authService
457
- });
458
- }
459
- }
460
- }
461
- case "refresh": {
462
- switch (method) {
463
- case "GET": {
464
- return refreshHandler(request, { authService });
465
- }
466
- }
467
- }
468
- case "signup": {
469
- switch (slug[2]) {
470
- case void 0: {
471
- switch (method) {
472
- case "POST": {
473
- return signupHandler(request, {
474
- authService,
475
- fileRepository: fileService.fileRepository
476
- });
477
- }
478
- }
479
- }
480
- default: {
481
- switch (method) {
482
- case "POST": {
483
- return signUpWithThirdpartyHandler(
484
- request,
485
- { authService, fileService, signupTokenSecret }
486
- );
487
- }
488
- }
489
- }
490
- }
491
- }
492
- case "callback": {
493
- if (slug[2]) {
494
- const provider = slug[2];
495
- if (method === "GET") {
496
- return thirdpartyAuthCallbackHandler(
497
- request,
498
- {
499
- provider,
500
- authService,
501
- getThirdPartyAuth
502
- }
503
- );
504
- }
505
- }
506
- }
507
- case "request-password-reset": {
508
- return requestPasswordResetHandler(request, { passwordRecoveryService });
509
- }
510
- case "reset-password": {
511
- return resetPasswordHandler(request, { passwordRecoveryService });
512
- }
513
- }
514
- }
515
- case "files": {
516
- switch (slug[1]) {
517
- case void 0: {
518
- switch (method) {
519
- case "POST": {
520
- return uploadFileHandler(request, { authService, fileService });
521
- }
522
- }
523
- }
524
- default: {
525
- switch (method) {
526
- case "DELETE": {
527
- const fileId = slug[1];
528
- return deleteFileHandler(
529
- request,
530
- { fileId },
531
- { authService, fileRepository: fileService.fileRepository }
532
- );
533
- }
534
- }
535
- }
536
- }
537
- }
538
- default: {
539
- return NOT_FOUND();
540
- }
541
- }
542
- };
543
- return handler;
544
- };
545
- export {
546
- createAPIHandler
547
- };
@@ -1,3 +0,0 @@
1
- declare function singleton<T>(name: string, fn: () => T): T;
2
-
3
- export { singleton };
@@ -1,3 +0,0 @@
1
- declare function singleton<T>(name: string, fn: () => T): T;
2
-
3
- export { singleton };
package/dist/singleton.js DELETED
@@ -1,37 +0,0 @@
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/singleton.ts
21
- var singleton_exports = {};
22
- __export(singleton_exports, {
23
- singleton: () => singleton
24
- });
25
- module.exports = __toCommonJS(singleton_exports);
26
- function singleton(name, fn) {
27
- const globalAny = globalThis;
28
- globalAny.__singletons = globalAny.__singletons || {};
29
- if (!globalAny.__singletons[name]) {
30
- globalAny.__singletons[name] = fn();
31
- }
32
- return globalAny.__singletons[name];
33
- }
34
- // Annotate the CommonJS export names for ESM import in node:
35
- 0 && (module.exports = {
36
- singleton
37
- });
@@ -1,12 +0,0 @@
1
- // src/singleton.ts
2
- function singleton(name, fn) {
3
- const globalAny = globalThis;
4
- globalAny.__singletons = globalAny.__singletons || {};
5
- if (!globalAny.__singletons[name]) {
6
- globalAny.__singletons[name] = fn();
7
- }
8
- return globalAny.__singletons[name];
9
- }
10
- export {
11
- singleton
12
- };
package/dist/sleep.d.mts DELETED
@@ -1,3 +0,0 @@
1
- declare const sleep: (ms: number) => Promise<unknown>;
2
-
3
- export { sleep };
package/dist/sleep.d.ts DELETED
@@ -1,3 +0,0 @@
1
- declare const sleep: (ms: number) => Promise<unknown>;
2
-
3
- export { sleep };
package/dist/sleep.mjs DELETED
@@ -1,7 +0,0 @@
1
- // src/sleep.ts
2
- var sleep = (ms) => {
3
- return new Promise((resolve) => setTimeout(resolve, ms));
4
- };
5
- export {
6
- sleep
7
- };
package/dist/slug.d.mts DELETED
@@ -1,3 +0,0 @@
1
- declare const toSlug: (str: string) => string;
2
-
3
- export { toSlug };
package/dist/slug.d.ts DELETED
@@ -1,3 +0,0 @@
1
- declare const toSlug: (str: string) => string;
2
-
3
- export { toSlug };
package/dist/slug.mjs DELETED
@@ -1,7 +0,0 @@
1
- // src/slug.ts
2
- var toSlug = (str) => {
3
- return str.toLowerCase().replace(/[^a-zA-Z0-9가-힣ㄱ-ㅎㅏ-ㅣ]+/g, "-").replace(/^-|-$/g, "");
4
- };
5
- export {
6
- toSlug
7
- };
@@ -1,16 +0,0 @@
1
- import { EditorView } from 'prosemirror-view';
2
- import { Node } from 'prosemirror-model';
3
- import { FileUploader } from '../file/client/file_uploader.mjs';
4
- import { createSchema } from './schema.mjs';
5
- import 'orderedmap';
6
-
7
- declare function createAttachMedia<TFile extends {
8
- name?: string;
9
- key: string;
10
- }>({ schema, cdnOrigin, fileUploader, }: {
11
- schema: ReturnType<typeof createSchema>;
12
- cdnOrigin: string;
13
- fileUploader: FileUploader<TFile>;
14
- }): (view: EditorView, medias: File[], pos?: number) => Promise<Node[]>;
15
-
16
- export { createAttachMedia };
@@ -1,16 +0,0 @@
1
- import { EditorView } from 'prosemirror-view';
2
- import { Node } from 'prosemirror-model';
3
- import { FileUploader } from '../file/client/file_uploader.js';
4
- import { createSchema } from './schema.js';
5
- import 'orderedmap';
6
-
7
- declare function createAttachMedia<TFile extends {
8
- name?: string;
9
- key: string;
10
- }>({ schema, cdnOrigin, fileUploader, }: {
11
- schema: ReturnType<typeof createSchema>;
12
- cdnOrigin: string;
13
- fileUploader: FileUploader<TFile>;
14
- }): (view: EditorView, medias: File[], pos?: number) => Promise<Node[]>;
15
-
16
- export { createAttachMedia };