dn-react-router-toolkit 0.1.11 → 0.2.0

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 (183) hide show
  1. package/dist/auth/apple_auth.d.mts +38 -0
  2. package/dist/auth/apple_auth.d.ts +38 -0
  3. package/dist/{auth-kit → auth}/apple_auth.js +31 -18
  4. package/dist/auth/apple_auth.mjs +63 -0
  5. package/dist/{auth-kit/repository.d.mts → auth/auth_repository.d.mts} +6 -9
  6. package/dist/{auth-kit/repository.d.ts → auth/auth_repository.d.ts} +6 -9
  7. package/dist/{file-kit/repository.js → auth/auth_repository.js} +3 -3
  8. package/dist/{auth-kit → auth}/auth_service.d.mts +12 -22
  9. package/dist/{auth-kit → auth}/auth_service.d.ts +12 -22
  10. package/dist/{auth-kit → auth}/auth_service.js +30 -77
  11. package/dist/{auth-kit → auth}/auth_service.mjs +30 -77
  12. package/dist/auth/client/google_login_button.d.mts +7 -0
  13. package/dist/auth/client/google_login_button.d.ts +7 -0
  14. package/dist/{auth-kit → auth}/client/google_login_button.js +24 -19
  15. package/dist/auth/client/google_login_button.mjs +37 -0
  16. package/dist/auth/client/provider.d.mts +23 -0
  17. package/dist/auth/client/provider.d.ts +23 -0
  18. package/dist/auth/client/provider.js +137 -0
  19. package/dist/auth/client/provider.mjs +101 -0
  20. package/dist/{auth-kit → auth}/client/redirect_page.js +1 -1
  21. package/dist/{auth-kit → auth}/client/redirect_page.mjs +1 -1
  22. package/dist/auth/google_auth.d.mts +33 -0
  23. package/dist/auth/google_auth.d.ts +33 -0
  24. package/dist/{auth-kit → auth}/google_auth.js +23 -32
  25. package/dist/{auth-kit → auth}/google_auth.mjs +22 -31
  26. package/dist/auth/handlers/find_auth.d.mts +13 -0
  27. package/dist/auth/handlers/find_auth.d.ts +13 -0
  28. package/dist/{route/api/auth/route.js → auth/handlers/find_auth.js} +10 -10
  29. package/dist/{route/api/auth/route.mjs → auth/handlers/find_auth.mjs} +5 -5
  30. package/dist/auth/handlers/login.d.mts +13 -0
  31. package/dist/auth/handlers/login.d.ts +13 -0
  32. package/dist/{route/api/auth/login/route.js → auth/handlers/login.js} +17 -17
  33. package/dist/{route/api/auth/login/route.mjs → auth/handlers/login.mjs} +12 -12
  34. package/dist/auth/handlers/login_with_thirdparty.d.mts +15 -0
  35. package/dist/auth/handlers/login_with_thirdparty.d.ts +15 -0
  36. package/dist/{route/api/auth/login/[provider]/route.js → auth/handlers/login_with_thirdparty.js} +12 -27
  37. package/dist/{route/api/auth/login/[provider]/route.mjs → auth/handlers/login_with_thirdparty.mjs} +7 -22
  38. package/dist/auth/handlers/logout.d.mts +13 -0
  39. package/dist/auth/handlers/logout.d.ts +13 -0
  40. package/dist/{route/api/auth/logout/route.js → auth/handlers/logout.js} +15 -11
  41. package/dist/{route/api/auth/logout/route.mjs → auth/handlers/logout.mjs} +11 -7
  42. package/dist/auth/handlers/refresh.d.mts +13 -0
  43. package/dist/auth/handlers/refresh.d.ts +13 -0
  44. package/dist/{route/api/auth/refresh/route.js → auth/handlers/refresh.js} +12 -12
  45. package/dist/{route/api/auth/refresh/route.mjs → auth/handlers/refresh.mjs} +7 -7
  46. package/dist/auth/handlers/signup.d.mts +15 -0
  47. package/dist/auth/handlers/signup.d.ts +15 -0
  48. package/dist/auth/handlers/signup.js +135 -0
  49. package/dist/auth/handlers/signup.mjs +100 -0
  50. package/dist/auth/handlers/signup_with_thirdparty.d.mts +17 -0
  51. package/dist/auth/handlers/signup_with_thirdparty.d.ts +17 -0
  52. package/dist/auth/handlers/signup_with_thirdparty.js +123 -0
  53. package/dist/auth/handlers/signup_with_thirdparty.mjs +98 -0
  54. package/dist/auth/handlers/thirdparty_auth_callback.d.mts +16 -0
  55. package/dist/auth/handlers/thirdparty_auth_callback.d.ts +16 -0
  56. package/dist/{route/auth/callback/[provider]/route.js → auth/handlers/thirdparty_auth_callback.js} +54 -45
  57. package/dist/{route/auth/callback/[provider]/route.mjs → auth/handlers/thirdparty_auth_callback.mjs} +49 -40
  58. package/dist/{auth-kit/jwt.d.mts → auth/jwt_manager.d.mts} +11 -1
  59. package/dist/{auth-kit/jwt.d.ts → auth/jwt_manager.d.ts} +11 -1
  60. package/dist/{auth-kit/jwt.js → auth/jwt_manager.js} +25 -11
  61. package/dist/{auth-kit/jwt.mjs → auth/jwt_manager.mjs} +22 -8
  62. package/dist/auth/kakao_auth.d.mts +27 -0
  63. package/dist/auth/kakao_auth.d.ts +27 -0
  64. package/dist/auth/kakao_auth.js +56 -0
  65. package/dist/auth/kakao_auth.mjs +31 -0
  66. package/dist/auth/thirdparty_auth.d.mts +41 -0
  67. package/dist/auth/thirdparty_auth.d.ts +41 -0
  68. package/dist/{auth-kit/kakao_auth.js → auth/thirdparty_auth.js} +31 -33
  69. package/dist/{auth-kit/kakao_auth.mjs → auth/thirdparty_auth.mjs} +26 -28
  70. package/dist/{auth-kit → auth}/with_auth.d.mts +5 -6
  71. package/dist/{auth-kit → auth}/with_auth.d.ts +5 -6
  72. package/dist/{auth-kit → auth}/with_auth.js +26 -42
  73. package/dist/auth/with_auth.mjs +63 -0
  74. package/dist/date.d.mts +2 -0
  75. package/dist/date.d.ts +2 -0
  76. package/dist/date.js +4 -2
  77. package/dist/date.mjs +2 -1
  78. package/dist/{file-kit → file}/cdn.js +1 -1
  79. package/dist/{file-kit → file}/cdn.mjs +1 -1
  80. package/dist/{file-kit → file}/client/drop_file_input.js +3 -3
  81. package/dist/{file-kit → file}/client/drop_file_input.mjs +3 -3
  82. package/dist/{file-kit → file}/client/file_upload_button.js +1 -1
  83. package/dist/{file-kit → file}/client/file_upload_button.mjs +1 -1
  84. package/dist/{file-kit → file}/client/file_uploader.js +3 -3
  85. package/dist/{file-kit → file}/client/file_uploader.mjs +2 -2
  86. package/dist/{file-kit → file}/client/format_size.js +1 -1
  87. package/dist/{file-kit → file}/client/format_size.mjs +1 -1
  88. package/dist/{file-kit → file}/client/metadata.js +1 -1
  89. package/dist/{file-kit → file}/client/metadata.mjs +1 -1
  90. package/dist/{file-kit/repository.d.mts → file/file_repository.d.mts} +4 -4
  91. package/dist/{file-kit/repository.d.ts → file/file_repository.d.ts} +4 -4
  92. package/dist/{auth-kit/repository.js → file/file_repository.js} +3 -3
  93. package/dist/file/file_service.d.mts +32 -0
  94. package/dist/file/file_service.d.ts +32 -0
  95. package/dist/{file-kit → file}/file_service.js +27 -21
  96. package/dist/file/file_service.mjs +41 -0
  97. package/dist/file/handlers/delete_file.d.mts +17 -0
  98. package/dist/file/handlers/delete_file.d.ts +17 -0
  99. package/dist/{route/api/files/[fileId]/route.js → file/handlers/delete_file.js} +15 -15
  100. package/dist/{route/api/files/[fileId]/route.mjs → file/handlers/delete_file.mjs} +10 -10
  101. package/dist/file/handlers/upload_file.d.mts +16 -0
  102. package/dist/file/handlers/upload_file.d.ts +16 -0
  103. package/dist/{route/api/files/route.js → file/handlers/upload_file.js} +13 -13
  104. package/dist/{route/api/files/route.mjs → file/handlers/upload_file.mjs} +8 -8
  105. package/dist/{file-kit → file}/object_storage.d.mts +3 -1
  106. package/dist/{file-kit → file}/object_storage.d.ts +3 -1
  107. package/dist/{file-kit → file}/object_storage.js +2 -2
  108. package/dist/{file-kit → file}/object_storage.mjs +2 -2
  109. package/dist/{file-kit → file}/responsive_image.d.mts +4 -4
  110. package/dist/{file-kit → file}/responsive_image.d.ts +4 -4
  111. package/dist/{file-kit → file}/responsive_image.js +18 -9
  112. package/dist/{file-kit → file}/responsive_image.mjs +18 -9
  113. package/dist/{http-kit → http}/index.js +5 -5
  114. package/dist/{http-kit → http}/index.mjs +1 -1
  115. package/dist/{http-kit → http}/response.js +1 -1
  116. package/dist/{http-kit → http}/response.mjs +1 -1
  117. package/dist/index.d.mts +1 -0
  118. package/dist/index.d.ts +1 -0
  119. package/dist/index.js +2 -0
  120. package/dist/index.mjs +1 -0
  121. package/dist/route/api.d.mts +15 -25
  122. package/dist/route/api.d.ts +15 -25
  123. package/dist/route/api.js +325 -178
  124. package/dist/route/api.mjs +314 -177
  125. package/dist/{seo-kit → seo}/seo.js +1 -1
  126. package/dist/{seo-kit → seo}/seo.mjs +1 -1
  127. package/package.json +74 -74
  128. package/dist/auth-kit/apple_auth.d.mts +0 -24
  129. package/dist/auth-kit/apple_auth.d.ts +0 -24
  130. package/dist/auth-kit/apple_auth.mjs +0 -50
  131. package/dist/auth-kit/client/google_login_button.d.mts +0 -9
  132. package/dist/auth-kit/client/google_login_button.d.ts +0 -9
  133. package/dist/auth-kit/client/google_login_button.mjs +0 -32
  134. package/dist/auth-kit/client/logout.d.mts +0 -3
  135. package/dist/auth-kit/client/logout.d.ts +0 -3
  136. package/dist/auth-kit/client/logout.js +0 -49
  137. package/dist/auth-kit/client/logout.mjs +0 -24
  138. package/dist/auth-kit/google_auth.d.mts +0 -27
  139. package/dist/auth-kit/google_auth.d.ts +0 -27
  140. package/dist/auth-kit/kakao_auth.d.mts +0 -24
  141. package/dist/auth-kit/kakao_auth.d.ts +0 -24
  142. package/dist/auth-kit/with_auth.mjs +0 -67
  143. package/dist/file-kit/file_service.d.mts +0 -26
  144. package/dist/file-kit/file_service.d.ts +0 -26
  145. package/dist/file-kit/file_service.mjs +0 -35
  146. package/dist/route/api/auth/login/_provider_/route.d.mts +0 -20
  147. package/dist/route/api/auth/login/_provider_/route.d.ts +0 -20
  148. package/dist/route/api/auth/login/route.d.mts +0 -14
  149. package/dist/route/api/auth/login/route.d.ts +0 -14
  150. package/dist/route/api/auth/logout/route.d.mts +0 -14
  151. package/dist/route/api/auth/logout/route.d.ts +0 -14
  152. package/dist/route/api/auth/refresh/route.d.mts +0 -13
  153. package/dist/route/api/auth/refresh/route.d.ts +0 -13
  154. package/dist/route/api/auth/route.d.mts +0 -13
  155. package/dist/route/api/auth/route.d.ts +0 -13
  156. package/dist/route/api/files/_fileId_/route.d.mts +0 -17
  157. package/dist/route/api/files/_fileId_/route.d.ts +0 -17
  158. package/dist/route/api/files/route.d.mts +0 -16
  159. package/dist/route/api/files/route.d.ts +0 -16
  160. package/dist/route/auth/callback/_provider_/route.d.mts +0 -20
  161. package/dist/route/auth/callback/_provider_/route.d.ts +0 -20
  162. /package/dist/{auth-kit/repository.mjs → auth/auth_repository.mjs} +0 -0
  163. /package/dist/{auth-kit → auth}/client/redirect_page.d.mts +0 -0
  164. /package/dist/{auth-kit → auth}/client/redirect_page.d.ts +0 -0
  165. /package/dist/{file-kit → file}/cdn.d.mts +0 -0
  166. /package/dist/{file-kit → file}/cdn.d.ts +0 -0
  167. /package/dist/{file-kit → file}/client/drop_file_input.d.mts +0 -0
  168. /package/dist/{file-kit → file}/client/drop_file_input.d.ts +0 -0
  169. /package/dist/{file-kit → file}/client/file_upload_button.d.mts +0 -0
  170. /package/dist/{file-kit → file}/client/file_upload_button.d.ts +0 -0
  171. /package/dist/{file-kit → file}/client/file_uploader.d.mts +0 -0
  172. /package/dist/{file-kit → file}/client/file_uploader.d.ts +0 -0
  173. /package/dist/{file-kit → file}/client/format_size.d.mts +0 -0
  174. /package/dist/{file-kit → file}/client/format_size.d.ts +0 -0
  175. /package/dist/{file-kit → file}/client/metadata.d.mts +0 -0
  176. /package/dist/{file-kit → file}/client/metadata.d.ts +0 -0
  177. /package/dist/{file-kit/repository.mjs → file/file_repository.mjs} +0 -0
  178. /package/dist/{http-kit → http}/index.d.mts +0 -0
  179. /package/dist/{http-kit → http}/index.d.ts +0 -0
  180. /package/dist/{http-kit → http}/response.d.mts +0 -0
  181. /package/dist/{http-kit → http}/response.d.ts +0 -0
  182. /package/dist/{seo-kit → seo}/seo.d.mts +0 -0
  183. /package/dist/{seo-kit → seo}/seo.d.ts +0 -0
@@ -17,14 +17,14 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // src/route/api/auth/logout/route.ts
21
- var route_exports = {};
22
- __export(route_exports, {
20
+ // src/auth/handlers/logout.ts
21
+ var logout_exports = {};
22
+ __export(logout_exports, {
23
23
  logoutHandler: () => logoutHandler
24
24
  });
25
- module.exports = __toCommonJS(route_exports);
25
+ module.exports = __toCommonJS(logout_exports);
26
26
 
27
- // src/http-kit/response.ts
27
+ // src/http/response.ts
28
28
  var createJsonResponse = (status) => {
29
29
  return (data = {}, init) => {
30
30
  return Response.json(data, { status, ...init });
@@ -74,17 +74,21 @@ var INTERNAL_SERVER_ERROR = createException(
74
74
  "\uC608\uAE30\uCE58 \uBABB\uD55C \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."
75
75
  );
76
76
 
77
- // src/route/api/auth/logout/route.ts
78
- var logoutHandler = async (request, { AUTH, repository }) => {
79
- const auth = await AUTH.verifyOrRefresh(request);
77
+ // src/auth/handlers/logout.ts
78
+ var logoutHandler = async (request, { authService }) => {
79
+ const auth = await authService.verifyOrRefresh(request);
80
80
  if (!auth) {
81
81
  return UNAUTHORIZED();
82
82
  }
83
- await repository.updateUserRefreshToken(auth.userId, null);
83
+ await authService.authRepository.updateUserRefreshToken(auth.userId, null);
84
+ const type = new URL(request.url).searchParams.get("type");
85
+ if (type === "json") {
86
+ return NO_CONTENT();
87
+ }
84
88
  const headers = new Headers();
85
89
  const [accessTokenSetCookie, refreshTokenSetCookie] = await Promise.all([
86
- AUTH.getAccessTokenSetCookie(null),
87
- AUTH.getRefreshTokenSetCookie(null)
90
+ authService.getAccessTokenSetCookie(null),
91
+ authService.getRefreshTokenSetCookie(null)
88
92
  ]);
89
93
  headers.append("Set-Cookie", accessTokenSetCookie);
90
94
  headers.append("Set-Cookie", refreshTokenSetCookie);
@@ -1,4 +1,4 @@
1
- // src/http-kit/response.ts
1
+ // src/http/response.ts
2
2
  var createJsonResponse = (status) => {
3
3
  return (data = {}, init) => {
4
4
  return Response.json(data, { status, ...init });
@@ -48,17 +48,21 @@ var INTERNAL_SERVER_ERROR = createException(
48
48
  "\uC608\uAE30\uCE58 \uBABB\uD55C \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."
49
49
  );
50
50
 
51
- // src/route/api/auth/logout/route.ts
52
- var logoutHandler = async (request, { AUTH, repository }) => {
53
- const auth = await AUTH.verifyOrRefresh(request);
51
+ // src/auth/handlers/logout.ts
52
+ var logoutHandler = async (request, { authService }) => {
53
+ const auth = await authService.verifyOrRefresh(request);
54
54
  if (!auth) {
55
55
  return UNAUTHORIZED();
56
56
  }
57
- await repository.updateUserRefreshToken(auth.userId, null);
57
+ await authService.authRepository.updateUserRefreshToken(auth.userId, null);
58
+ const type = new URL(request.url).searchParams.get("type");
59
+ if (type === "json") {
60
+ return NO_CONTENT();
61
+ }
58
62
  const headers = new Headers();
59
63
  const [accessTokenSetCookie, refreshTokenSetCookie] = await Promise.all([
60
- AUTH.getAccessTokenSetCookie(null),
61
- AUTH.getRefreshTokenSetCookie(null)
64
+ authService.getAccessTokenSetCookie(null),
65
+ authService.getRefreshTokenSetCookie(null)
62
66
  ]);
63
67
  headers.append("Set-Cookie", accessTokenSetCookie);
64
68
  headers.append("Set-Cookie", refreshTokenSetCookie);
@@ -0,0 +1,13 @@
1
+ import { AuthService } from '../auth_service.mjs';
2
+ import 'jose';
3
+ import 'react-router';
4
+ import '../jwt_manager.mjs';
5
+ import '../../file/object_storage.mjs';
6
+ import '@aws-sdk/client-s3';
7
+ import '../auth_repository.mjs';
8
+
9
+ declare const refreshHandler: (request: Request, { authService, }: {
10
+ authService: AuthService;
11
+ }) => Promise<Response>;
12
+
13
+ export { refreshHandler };
@@ -0,0 +1,13 @@
1
+ import { AuthService } from '../auth_service.js';
2
+ import 'jose';
3
+ import 'react-router';
4
+ import '../jwt_manager.js';
5
+ import '../../file/object_storage.js';
6
+ import '@aws-sdk/client-s3';
7
+ import '../auth_repository.js';
8
+
9
+ declare const refreshHandler: (request: Request, { authService, }: {
10
+ authService: AuthService;
11
+ }) => Promise<Response>;
12
+
13
+ export { refreshHandler };
@@ -17,14 +17,14 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // src/route/api/auth/refresh/route.ts
21
- var route_exports = {};
22
- __export(route_exports, {
23
- authRefreshHandler: () => authRefreshHandler
20
+ // src/auth/handlers/refresh.ts
21
+ var refresh_exports = {};
22
+ __export(refresh_exports, {
23
+ refreshHandler: () => refreshHandler
24
24
  });
25
- module.exports = __toCommonJS(route_exports);
25
+ module.exports = __toCommonJS(refresh_exports);
26
26
 
27
- // src/http-kit/response.ts
27
+ // src/http/response.ts
28
28
  var createJsonResponse = (status) => {
29
29
  return (data = {}, init) => {
30
30
  return Response.json(data, { status, ...init });
@@ -68,16 +68,16 @@ var INTERNAL_SERVER_ERROR = createException(
68
68
  "\uC608\uAE30\uCE58 \uBABB\uD55C \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."
69
69
  );
70
70
 
71
- // src/route/api/auth/refresh/route.ts
72
- var authRefreshHandler = async (request, {
73
- AUTH
71
+ // src/auth/handlers/refresh.ts
72
+ var refreshHandler = async (request, {
73
+ authService
74
74
  }) => {
75
- const refreshToken = request?.headers.get("Authorization")?.replace("Bearer ", "") || await AUTH.getRefreshTokenFromCookies(request);
75
+ const refreshToken = request?.headers.get("Authorization")?.replace("Bearer ", "") || await authService.getRefreshTokenFromCookies(request);
76
76
  if (!refreshToken) {
77
77
  return BAD_REQUEST();
78
78
  }
79
79
  try {
80
- const accessToken = await AUTH.refreshAccessToken(refreshToken);
80
+ const accessToken = await authService.refreshAccessToken(refreshToken);
81
81
  return CREATED({ accessToken });
82
82
  } catch (e) {
83
83
  if (e instanceof Error) {
@@ -88,5 +88,5 @@ var authRefreshHandler = async (request, {
88
88
  };
89
89
  // Annotate the CommonJS export names for ESM import in node:
90
90
  0 && (module.exports = {
91
- authRefreshHandler
91
+ refreshHandler
92
92
  });
@@ -1,4 +1,4 @@
1
- // src/http-kit/response.ts
1
+ // src/http/response.ts
2
2
  var createJsonResponse = (status) => {
3
3
  return (data = {}, init) => {
4
4
  return Response.json(data, { status, ...init });
@@ -42,16 +42,16 @@ var INTERNAL_SERVER_ERROR = createException(
42
42
  "\uC608\uAE30\uCE58 \uBABB\uD55C \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."
43
43
  );
44
44
 
45
- // src/route/api/auth/refresh/route.ts
46
- var authRefreshHandler = async (request, {
47
- AUTH
45
+ // src/auth/handlers/refresh.ts
46
+ var refreshHandler = async (request, {
47
+ authService
48
48
  }) => {
49
- const refreshToken = request?.headers.get("Authorization")?.replace("Bearer ", "") || await AUTH.getRefreshTokenFromCookies(request);
49
+ const refreshToken = request?.headers.get("Authorization")?.replace("Bearer ", "") || await authService.getRefreshTokenFromCookies(request);
50
50
  if (!refreshToken) {
51
51
  return BAD_REQUEST();
52
52
  }
53
53
  try {
54
- const accessToken = await AUTH.refreshAccessToken(refreshToken);
54
+ const accessToken = await authService.refreshAccessToken(refreshToken);
55
55
  return CREATED({ accessToken });
56
56
  } catch (e) {
57
57
  if (e instanceof Error) {
@@ -61,5 +61,5 @@ var authRefreshHandler = async (request, {
61
61
  }
62
62
  };
63
63
  export {
64
- authRefreshHandler
64
+ refreshHandler
65
65
  };
@@ -0,0 +1,15 @@
1
+ import { AuthService } from '../auth_service.mjs';
2
+ import { FileRepository } from '../../file/file_repository.mjs';
3
+ import 'jose';
4
+ import 'react-router';
5
+ import '../jwt_manager.mjs';
6
+ import '../../file/object_storage.mjs';
7
+ import '@aws-sdk/client-s3';
8
+ import '../auth_repository.mjs';
9
+
10
+ declare const signupHandler: <TFile>(request: Request, { authService, fileRepository, }: {
11
+ authService: AuthService<TFile>;
12
+ fileRepository: FileRepository<TFile>;
13
+ }) => Promise<Response>;
14
+
15
+ export { signupHandler };
@@ -0,0 +1,15 @@
1
+ import { AuthService } from '../auth_service.js';
2
+ import { FileRepository } from '../../file/file_repository.js';
3
+ import 'jose';
4
+ import 'react-router';
5
+ import '../jwt_manager.js';
6
+ import '../../file/object_storage.js';
7
+ import '@aws-sdk/client-s3';
8
+ import '../auth_repository.js';
9
+
10
+ declare const signupHandler: <TFile>(request: Request, { authService, fileRepository, }: {
11
+ authService: AuthService<TFile>;
12
+ fileRepository: FileRepository<TFile>;
13
+ }) => Promise<Response>;
14
+
15
+ export { signupHandler };
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/auth/handlers/signup.ts
31
+ var signup_exports = {};
32
+ __export(signup_exports, {
33
+ signupHandler: () => signupHandler
34
+ });
35
+ module.exports = __toCommonJS(signup_exports);
36
+ var import_uuid = require("uuid");
37
+ var bcrypt = __toESM(require("bcryptjs"));
38
+
39
+ // src/http/response.ts
40
+ var createJsonResponse = (status) => {
41
+ return (data = {}, init) => {
42
+ return Response.json(data, { status, ...init });
43
+ };
44
+ };
45
+ var OK = createJsonResponse(200);
46
+ var CREATED = createJsonResponse(201);
47
+ var ACCEPTED = createJsonResponse(202);
48
+ var createException = (status, defaultMessage = "\uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4.") => {
49
+ return (message = defaultMessage, init) => {
50
+ return createJsonResponse(status)({ message }, init);
51
+ };
52
+ };
53
+ var BAD_REQUEST = createException(400, "\uC694\uCCAD\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.");
54
+ var UNAUTHORIZED = createException(401, "\uC778\uC99D\uC774 \uD544\uC694\uD569\uB2C8\uB2E4.");
55
+ var FORBIDDEN = createException(403, "\uAD8C\uD55C\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.");
56
+ var NOT_FOUND = createException(
57
+ 404,
58
+ "\uC694\uCCAD\uD55C \uB9AC\uC18C\uC2A4\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."
59
+ );
60
+ var METHOD_NOT_ALLOWED = createException(
61
+ 405,
62
+ "\uBA54\uC11C\uB4DC\uB97C \uC0AC\uC6A9\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."
63
+ );
64
+ var NOT_ACCEPTABLE = createException(
65
+ 406,
66
+ "\uC694\uCCAD\uD55C \uD615\uC2DD\uC744 \uC0AC\uC6A9\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."
67
+ );
68
+ var REQUEST_TIMEOUT = createException(
69
+ 408,
70
+ "\uC694\uCCAD \uC2DC\uAC04\uC774 \uCD08\uACFC\uB418\uC5C8\uC2B5\uB2C8\uB2E4."
71
+ );
72
+ var CONFLICT = createException(409, "\uC694\uCCAD\uC774 \uCDA9\uB3CC\uD588\uC2B5\uB2C8\uB2E4.");
73
+ var UNPROCESSABLE_ENTITY = createException(
74
+ 422,
75
+ "\uCC98\uB9AC\uD560 \uC218 \uC5C6\uB294 \uC5D4\uD2F0\uD2F0\uC785\uB2C8\uB2E4."
76
+ );
77
+ var TOO_MANY_REQUESTS = createException(429, "\uC694\uCCAD\uC774 \uB108\uBB34 \uB9CE\uC2B5\uB2C8\uB2E4.");
78
+ var INTERNAL_SERVER_ERROR = createException(
79
+ 500,
80
+ "\uC608\uAE30\uCE58 \uBABB\uD55C \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."
81
+ );
82
+
83
+ // src/auth/handlers/signup.ts
84
+ var signupHandler = async (request, {
85
+ authService,
86
+ fileRepository
87
+ }) => {
88
+ const body = await request.json();
89
+ const {
90
+ email,
91
+ password,
92
+ passwordConfirm,
93
+ name,
94
+ profileImageId
95
+ } = body;
96
+ if (!email) {
97
+ return BAD_REQUEST("\uC774\uBA54\uC77C\uC744 \uC785\uB825\uD574\uC8FC\uC138\uC694.");
98
+ }
99
+ if (!password) {
100
+ return BAD_REQUEST("\uBE44\uBC00\uBC88\uD638\uB97C \uC785\uB825\uD574\uC8FC\uC138\uC694.");
101
+ }
102
+ if (!passwordConfirm) {
103
+ return BAD_REQUEST("\uBE44\uBC00\uBC88\uD638 \uD655\uC778\uC744 \uC785\uB825\uD574\uC8FC\uC138\uC694.");
104
+ }
105
+ if (!name) {
106
+ return BAD_REQUEST("\uC774\uB984\uC744 \uC785\uB825\uD574\uC8FC\uC138\uC694.");
107
+ }
108
+ const existing = await authService.authRepository.findCredentialById(email);
109
+ if (existing) {
110
+ return CONFLICT("\uC774\uBA54\uC77C\uC774 \uC774\uBBF8 \uC874\uC7AC\uD569\uB2C8\uB2E4.");
111
+ }
112
+ if (password !== passwordConfirm) {
113
+ return BAD_REQUEST("\uBE44\uBC00\uBC88\uD638\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.");
114
+ }
115
+ const profileImage = profileImageId ? await fileRepository.findFileById(profileImageId) : void 0;
116
+ const userId = (0, import_uuid.v5)(email, import_uuid.v5.DNS);
117
+ const user = await authService.authRepository.createUser({
118
+ id: userId,
119
+ name,
120
+ role: "user",
121
+ email,
122
+ profileImage
123
+ });
124
+ await authService.authRepository.createCredential({
125
+ id: email,
126
+ userId,
127
+ password: bcrypt.hashSync(password, 10)
128
+ });
129
+ const { accessToken, refreshToken } = await authService.issueTokenPair(user);
130
+ return CREATED({ accessToken, refreshToken });
131
+ };
132
+ // Annotate the CommonJS export names for ESM import in node:
133
+ 0 && (module.exports = {
134
+ signupHandler
135
+ });
@@ -0,0 +1,100 @@
1
+ // src/auth/handlers/signup.ts
2
+ import { v5 } from "uuid";
3
+ import * as bcrypt from "bcryptjs";
4
+
5
+ // src/http/response.ts
6
+ var createJsonResponse = (status) => {
7
+ return (data = {}, init) => {
8
+ return Response.json(data, { status, ...init });
9
+ };
10
+ };
11
+ var OK = createJsonResponse(200);
12
+ var CREATED = createJsonResponse(201);
13
+ var ACCEPTED = createJsonResponse(202);
14
+ var createException = (status, defaultMessage = "\uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4.") => {
15
+ return (message = defaultMessage, init) => {
16
+ return createJsonResponse(status)({ message }, init);
17
+ };
18
+ };
19
+ var BAD_REQUEST = createException(400, "\uC694\uCCAD\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.");
20
+ var UNAUTHORIZED = createException(401, "\uC778\uC99D\uC774 \uD544\uC694\uD569\uB2C8\uB2E4.");
21
+ var FORBIDDEN = createException(403, "\uAD8C\uD55C\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.");
22
+ var NOT_FOUND = createException(
23
+ 404,
24
+ "\uC694\uCCAD\uD55C \uB9AC\uC18C\uC2A4\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."
25
+ );
26
+ var METHOD_NOT_ALLOWED = createException(
27
+ 405,
28
+ "\uBA54\uC11C\uB4DC\uB97C \uC0AC\uC6A9\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."
29
+ );
30
+ var NOT_ACCEPTABLE = createException(
31
+ 406,
32
+ "\uC694\uCCAD\uD55C \uD615\uC2DD\uC744 \uC0AC\uC6A9\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."
33
+ );
34
+ var REQUEST_TIMEOUT = createException(
35
+ 408,
36
+ "\uC694\uCCAD \uC2DC\uAC04\uC774 \uCD08\uACFC\uB418\uC5C8\uC2B5\uB2C8\uB2E4."
37
+ );
38
+ var CONFLICT = createException(409, "\uC694\uCCAD\uC774 \uCDA9\uB3CC\uD588\uC2B5\uB2C8\uB2E4.");
39
+ var UNPROCESSABLE_ENTITY = createException(
40
+ 422,
41
+ "\uCC98\uB9AC\uD560 \uC218 \uC5C6\uB294 \uC5D4\uD2F0\uD2F0\uC785\uB2C8\uB2E4."
42
+ );
43
+ var TOO_MANY_REQUESTS = createException(429, "\uC694\uCCAD\uC774 \uB108\uBB34 \uB9CE\uC2B5\uB2C8\uB2E4.");
44
+ var INTERNAL_SERVER_ERROR = createException(
45
+ 500,
46
+ "\uC608\uAE30\uCE58 \uBABB\uD55C \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."
47
+ );
48
+
49
+ // src/auth/handlers/signup.ts
50
+ var signupHandler = async (request, {
51
+ authService,
52
+ fileRepository
53
+ }) => {
54
+ const body = await request.json();
55
+ const {
56
+ email,
57
+ password,
58
+ passwordConfirm,
59
+ name,
60
+ profileImageId
61
+ } = body;
62
+ if (!email) {
63
+ return BAD_REQUEST("\uC774\uBA54\uC77C\uC744 \uC785\uB825\uD574\uC8FC\uC138\uC694.");
64
+ }
65
+ if (!password) {
66
+ return BAD_REQUEST("\uBE44\uBC00\uBC88\uD638\uB97C \uC785\uB825\uD574\uC8FC\uC138\uC694.");
67
+ }
68
+ if (!passwordConfirm) {
69
+ return BAD_REQUEST("\uBE44\uBC00\uBC88\uD638 \uD655\uC778\uC744 \uC785\uB825\uD574\uC8FC\uC138\uC694.");
70
+ }
71
+ if (!name) {
72
+ return BAD_REQUEST("\uC774\uB984\uC744 \uC785\uB825\uD574\uC8FC\uC138\uC694.");
73
+ }
74
+ const existing = await authService.authRepository.findCredentialById(email);
75
+ if (existing) {
76
+ return CONFLICT("\uC774\uBA54\uC77C\uC774 \uC774\uBBF8 \uC874\uC7AC\uD569\uB2C8\uB2E4.");
77
+ }
78
+ if (password !== passwordConfirm) {
79
+ return BAD_REQUEST("\uBE44\uBC00\uBC88\uD638\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.");
80
+ }
81
+ const profileImage = profileImageId ? await fileRepository.findFileById(profileImageId) : void 0;
82
+ const userId = v5(email, v5.DNS);
83
+ const user = await authService.authRepository.createUser({
84
+ id: userId,
85
+ name,
86
+ role: "user",
87
+ email,
88
+ profileImage
89
+ });
90
+ await authService.authRepository.createCredential({
91
+ id: email,
92
+ userId,
93
+ password: bcrypt.hashSync(password, 10)
94
+ });
95
+ const { accessToken, refreshToken } = await authService.issueTokenPair(user);
96
+ return CREATED({ accessToken, refreshToken });
97
+ };
98
+ export {
99
+ signupHandler
100
+ };
@@ -0,0 +1,17 @@
1
+ import { AuthService } from '../auth_service.mjs';
2
+ import { FileService } from '../../file/file_service.mjs';
3
+ import 'jose';
4
+ import 'react-router';
5
+ import '../jwt_manager.mjs';
6
+ import '../../file/object_storage.mjs';
7
+ import '@aws-sdk/client-s3';
8
+ import '../auth_repository.mjs';
9
+ import '../../file/file_repository.mjs';
10
+
11
+ declare const signUpWithThirdpartyHandler: <TFile>(request: Request, { authService, fileService, signupTokenSecret, }: {
12
+ authService: AuthService<TFile>;
13
+ fileService: FileService<TFile>;
14
+ signupTokenSecret: string;
15
+ }) => Promise<Response>;
16
+
17
+ export { signUpWithThirdpartyHandler };
@@ -0,0 +1,17 @@
1
+ import { AuthService } from '../auth_service.js';
2
+ import { FileService } from '../../file/file_service.js';
3
+ import 'jose';
4
+ import 'react-router';
5
+ import '../jwt_manager.js';
6
+ import '../../file/object_storage.js';
7
+ import '@aws-sdk/client-s3';
8
+ import '../auth_repository.js';
9
+ import '../../file/file_repository.js';
10
+
11
+ declare const signUpWithThirdpartyHandler: <TFile>(request: Request, { authService, fileService, signupTokenSecret, }: {
12
+ authService: AuthService<TFile>;
13
+ fileService: FileService<TFile>;
14
+ signupTokenSecret: string;
15
+ }) => Promise<Response>;
16
+
17
+ export { signUpWithThirdpartyHandler };
@@ -0,0 +1,123 @@
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/auth/handlers/signup_with_thirdparty.ts
21
+ var signup_with_thirdparty_exports = {};
22
+ __export(signup_with_thirdparty_exports, {
23
+ signUpWithThirdpartyHandler: () => signUpWithThirdpartyHandler
24
+ });
25
+ module.exports = __toCommonJS(signup_with_thirdparty_exports);
26
+ var import_uuid = require("uuid");
27
+
28
+ // src/http/response.ts
29
+ var createJsonResponse = (status) => {
30
+ return (data = {}, init) => {
31
+ return Response.json(data, { status, ...init });
32
+ };
33
+ };
34
+ var OK = createJsonResponse(200);
35
+ var CREATED = createJsonResponse(201);
36
+ var ACCEPTED = createJsonResponse(202);
37
+ var createException = (status, defaultMessage = "\uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4.") => {
38
+ return (message = defaultMessage, init) => {
39
+ return createJsonResponse(status)({ message }, init);
40
+ };
41
+ };
42
+ var BAD_REQUEST = createException(400, "\uC694\uCCAD\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.");
43
+ var UNAUTHORIZED = createException(401, "\uC778\uC99D\uC774 \uD544\uC694\uD569\uB2C8\uB2E4.");
44
+ var FORBIDDEN = createException(403, "\uAD8C\uD55C\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.");
45
+ var NOT_FOUND = createException(
46
+ 404,
47
+ "\uC694\uCCAD\uD55C \uB9AC\uC18C\uC2A4\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."
48
+ );
49
+ var METHOD_NOT_ALLOWED = createException(
50
+ 405,
51
+ "\uBA54\uC11C\uB4DC\uB97C \uC0AC\uC6A9\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."
52
+ );
53
+ var NOT_ACCEPTABLE = createException(
54
+ 406,
55
+ "\uC694\uCCAD\uD55C \uD615\uC2DD\uC744 \uC0AC\uC6A9\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."
56
+ );
57
+ var REQUEST_TIMEOUT = createException(
58
+ 408,
59
+ "\uC694\uCCAD \uC2DC\uAC04\uC774 \uCD08\uACFC\uB418\uC5C8\uC2B5\uB2C8\uB2E4."
60
+ );
61
+ var CONFLICT = createException(409, "\uC694\uCCAD\uC774 \uCDA9\uB3CC\uD588\uC2B5\uB2C8\uB2E4.");
62
+ var UNPROCESSABLE_ENTITY = createException(
63
+ 422,
64
+ "\uCC98\uB9AC\uD560 \uC218 \uC5C6\uB294 \uC5D4\uD2F0\uD2F0\uC785\uB2C8\uB2E4."
65
+ );
66
+ var TOO_MANY_REQUESTS = createException(429, "\uC694\uCCAD\uC774 \uB108\uBB34 \uB9CE\uC2B5\uB2C8\uB2E4.");
67
+ var INTERNAL_SERVER_ERROR = createException(
68
+ 500,
69
+ "\uC608\uAE30\uCE58 \uBABB\uD55C \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."
70
+ );
71
+
72
+ // src/auth/handlers/signup_with_thirdparty.ts
73
+ var signUpWithThirdpartyHandler = async (request, {
74
+ authService,
75
+ fileService,
76
+ signupTokenSecret
77
+ }) => {
78
+ const body = await request.json();
79
+ const {
80
+ token
81
+ } = body;
82
+ const payload = await authService.jwtManager.verify(token, signupTokenSecret);
83
+ const { provider, id: thirdpartyId, email, name, picture } = payload;
84
+ const existing = await authService.authRepository.findThirdPartyAuth(
85
+ provider,
86
+ thirdpartyId
87
+ );
88
+ if (existing) {
89
+ return CONFLICT("\uC774\uBBF8 \uAC00\uC785\uB41C \uC81C3\uC790 \uC778\uC99D \uC815\uBCF4\uC785\uB2C8\uB2E4.");
90
+ }
91
+ const userId = (0, import_uuid.v5)(thirdpartyId, import_uuid.v5.DNS);
92
+ const profileImage = await (async () => {
93
+ if (!picture) {
94
+ return;
95
+ }
96
+ const arrayBuffer = await fetch(picture).then((res) => res.arrayBuffer());
97
+ const { file } = await fileService.putFile(Buffer.from(arrayBuffer), {
98
+ userId,
99
+ name: "profile.jpg",
100
+ type: "image/jpeg",
101
+ size: arrayBuffer.byteLength
102
+ });
103
+ return file;
104
+ })();
105
+ const user = await authService.authRepository.createUser({
106
+ id: userId,
107
+ name,
108
+ role: "user",
109
+ email,
110
+ profileImage
111
+ });
112
+ await authService.authRepository.createThirdPartyAuth({
113
+ id: thirdpartyId,
114
+ provider,
115
+ userId
116
+ });
117
+ const { accessToken, refreshToken } = await authService.issueTokenPair(user);
118
+ return CREATED({ accessToken, refreshToken });
119
+ };
120
+ // Annotate the CommonJS export names for ESM import in node:
121
+ 0 && (module.exports = {
122
+ signUpWithThirdpartyHandler
123
+ });