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
@@ -0,0 +1,41 @@
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
+ interface ThirdpartyAuth {
10
+ login(code: string): Promise<{
11
+ accessToken: string;
12
+ refreshToken: string;
13
+ }>;
14
+ }
15
+ declare class ThirdpartyAuthService {
16
+ authService: AuthService;
17
+ signupTokenSecret: string;
18
+ signupTokenExpiresIn: string;
19
+ constructor({ authService, signupTokenSecret, signupTokenExpiresIn, }: {
20
+ authService: AuthService;
21
+ signupTokenSecret: string;
22
+ signupTokenExpiresIn?: string;
23
+ });
24
+ issueTokensIfUserFound(provider: string, payload: {
25
+ id: string;
26
+ email: string;
27
+ name?: string;
28
+ picture?: string;
29
+ }): Promise<{
30
+ user: {
31
+ id: string;
32
+ role: string;
33
+ name: string;
34
+ refreshToken: string | null;
35
+ };
36
+ accessToken: string;
37
+ refreshToken: string;
38
+ }>;
39
+ }
40
+
41
+ export { type ThirdpartyAuth, ThirdpartyAuthService };
@@ -0,0 +1,41 @@
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
+ interface ThirdpartyAuth {
10
+ login(code: string): Promise<{
11
+ accessToken: string;
12
+ refreshToken: string;
13
+ }>;
14
+ }
15
+ declare class ThirdpartyAuthService {
16
+ authService: AuthService;
17
+ signupTokenSecret: string;
18
+ signupTokenExpiresIn: string;
19
+ constructor({ authService, signupTokenSecret, signupTokenExpiresIn, }: {
20
+ authService: AuthService;
21
+ signupTokenSecret: string;
22
+ signupTokenExpiresIn?: string;
23
+ });
24
+ issueTokensIfUserFound(provider: string, payload: {
25
+ id: string;
26
+ email: string;
27
+ name?: string;
28
+ picture?: string;
29
+ }): Promise<{
30
+ user: {
31
+ id: string;
32
+ role: string;
33
+ name: string;
34
+ refreshToken: string | null;
35
+ };
36
+ accessToken: string;
37
+ refreshToken: string;
38
+ }>;
39
+ }
40
+
41
+ export { type ThirdpartyAuth, ThirdpartyAuthService };
@@ -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/auth-kit/kakao_auth.ts
21
- var kakao_auth_exports = {};
22
- __export(kakao_auth_exports, {
23
- KakaoAuth: () => KakaoAuth
20
+ // src/auth/thirdparty_auth.ts
21
+ var thirdparty_auth_exports = {};
22
+ __export(thirdparty_auth_exports, {
23
+ ThirdpartyAuthService: () => ThirdpartyAuthService
24
24
  });
25
- module.exports = __toCommonJS(kakao_auth_exports);
25
+ module.exports = __toCommonJS(thirdparty_auth_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,38 +68,36 @@ 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/auth-kit/kakao_auth.ts
72
- var KakaoAuth = class {
73
- AUTH;
74
- constructor(AUTH) {
75
- this.AUTH = AUTH;
71
+ // src/auth/thirdparty_auth.ts
72
+ var ThirdpartyAuthService = class {
73
+ authService;
74
+ signupTokenSecret;
75
+ signupTokenExpiresIn;
76
+ constructor({
77
+ authService,
78
+ signupTokenSecret,
79
+ signupTokenExpiresIn = "1d"
80
+ }) {
81
+ this.authService = authService;
82
+ this.signupTokenSecret = signupTokenSecret;
83
+ this.signupTokenExpiresIn = signupTokenExpiresIn;
76
84
  }
77
- async signIn(kakaoAccessToken) {
78
- const userRes = await fetch("https://kapi.kakao.com/v2/user/me", {
79
- headers: {
80
- Authorization: `Bearer ${kakaoAccessToken}`
81
- }
82
- });
83
- if (!userRes.ok) {
84
- throw new Error("\uC720\uC800 \uC815\uBCF4\uB97C \uAC00\uC838\uC624\uB294\uB370 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4.");
85
- }
86
- const { id, kakao_account } = await userRes.json();
87
- const { email, profile } = kakao_account;
88
- const payload = {
89
- id,
90
- email,
91
- name: profile.nickname,
92
- picture: profile.thumbnail_image_url
93
- };
94
- const user = await this.AUTH.findUser("kakao", payload);
85
+ async issueTokensIfUserFound(provider, payload) {
86
+ const user = await this.authService.findUser(provider, payload);
95
87
  if (!user) {
88
+ const token = await this.authService.jwtManager.sign(
89
+ { provider, ...payload },
90
+ this.signupTokenSecret,
91
+ {
92
+ expiresIn: this.signupTokenExpiresIn
93
+ }
94
+ );
96
95
  throw createJsonResponse(404)({
97
- provider: "kakao",
98
- ...payload,
96
+ token,
99
97
  message: "\uC0AC\uC6A9\uC790\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."
100
98
  });
101
99
  }
102
- const { accessToken, refreshToken } = await this.AUTH.issueTokenPair(
100
+ const { accessToken, refreshToken } = await this.authService.issueTokenPair(
103
101
  user
104
102
  );
105
103
  return {
@@ -111,5 +109,5 @@ var KakaoAuth = class {
111
109
  };
112
110
  // Annotate the CommonJS export names for ESM import in node:
113
111
  0 && (module.exports = {
114
- KakaoAuth
112
+ ThirdpartyAuthService
115
113
  });
@@ -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,38 +42,36 @@ 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/auth-kit/kakao_auth.ts
46
- var KakaoAuth = class {
47
- AUTH;
48
- constructor(AUTH) {
49
- this.AUTH = AUTH;
45
+ // src/auth/thirdparty_auth.ts
46
+ var ThirdpartyAuthService = class {
47
+ authService;
48
+ signupTokenSecret;
49
+ signupTokenExpiresIn;
50
+ constructor({
51
+ authService,
52
+ signupTokenSecret,
53
+ signupTokenExpiresIn = "1d"
54
+ }) {
55
+ this.authService = authService;
56
+ this.signupTokenSecret = signupTokenSecret;
57
+ this.signupTokenExpiresIn = signupTokenExpiresIn;
50
58
  }
51
- async signIn(kakaoAccessToken) {
52
- const userRes = await fetch("https://kapi.kakao.com/v2/user/me", {
53
- headers: {
54
- Authorization: `Bearer ${kakaoAccessToken}`
55
- }
56
- });
57
- if (!userRes.ok) {
58
- throw new Error("\uC720\uC800 \uC815\uBCF4\uB97C \uAC00\uC838\uC624\uB294\uB370 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4.");
59
- }
60
- const { id, kakao_account } = await userRes.json();
61
- const { email, profile } = kakao_account;
62
- const payload = {
63
- id,
64
- email,
65
- name: profile.nickname,
66
- picture: profile.thumbnail_image_url
67
- };
68
- const user = await this.AUTH.findUser("kakao", payload);
59
+ async issueTokensIfUserFound(provider, payload) {
60
+ const user = await this.authService.findUser(provider, payload);
69
61
  if (!user) {
62
+ const token = await this.authService.jwtManager.sign(
63
+ { provider, ...payload },
64
+ this.signupTokenSecret,
65
+ {
66
+ expiresIn: this.signupTokenExpiresIn
67
+ }
68
+ );
70
69
  throw createJsonResponse(404)({
71
- provider: "kakao",
72
- ...payload,
70
+ token,
73
71
  message: "\uC0AC\uC6A9\uC790\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."
74
72
  });
75
73
  }
76
- const { accessToken, refreshToken } = await this.AUTH.issueTokenPair(
74
+ const { accessToken, refreshToken } = await this.authService.issueTokenPair(
77
75
  user
78
76
  );
79
77
  return {
@@ -84,5 +82,5 @@ var KakaoAuth = class {
84
82
  }
85
83
  };
86
84
  export {
87
- KakaoAuth
85
+ ThirdpartyAuthService
88
86
  };
@@ -1,17 +1,16 @@
1
1
  import { LoaderFunctionArgs, ActionFunctionArgs } from 'react-router';
2
2
  import { AuthService } from './auth_service.mjs';
3
- import { JWTManager } from './jwt.mjs';
4
3
  import { JWTPayload } from 'jose';
5
- import '../file-kit/object_storage.mjs';
4
+ import './jwt_manager.mjs';
5
+ import '../file/object_storage.mjs';
6
6
  import '@aws-sdk/client-s3';
7
- import './repository.mjs';
7
+ import './auth_repository.mjs';
8
8
 
9
9
  type Handler<T extends LoaderFunctionArgs | ActionFunctionArgs> = (arg: T) => Promise<unknown> | unknown;
10
10
  type InputFN = (auth?: JWTPayload) => Handler<LoaderFunctionArgs> | Handler<ActionFunctionArgs>;
11
11
  type WithAuthHandler<T extends LoaderFunctionArgs | ActionFunctionArgs> = (fn: InputFN) => Handler<T>;
12
- declare function createWithAuthHandler<T extends LoaderFunctionArgs | ActionFunctionArgs>({ JWT_MANAGER, AUTH }: {
13
- JWT_MANAGER: JWTManager;
14
- AUTH: AuthService;
12
+ declare function createWithAuthHandler<T extends LoaderFunctionArgs | ActionFunctionArgs>({ authService }: {
13
+ authService: AuthService;
15
14
  }): <THandler extends Handler<T>>(fn: (auth?: JWTPayload) => THandler) => THandler;
16
15
 
17
16
  export { type WithAuthHandler, createWithAuthHandler };
@@ -1,17 +1,16 @@
1
1
  import { LoaderFunctionArgs, ActionFunctionArgs } from 'react-router';
2
2
  import { AuthService } from './auth_service.js';
3
- import { JWTManager } from './jwt.js';
4
3
  import { JWTPayload } from 'jose';
5
- import '../file-kit/object_storage.js';
4
+ import './jwt_manager.js';
5
+ import '../file/object_storage.js';
6
6
  import '@aws-sdk/client-s3';
7
- import './repository.js';
7
+ import './auth_repository.js';
8
8
 
9
9
  type Handler<T extends LoaderFunctionArgs | ActionFunctionArgs> = (arg: T) => Promise<unknown> | unknown;
10
10
  type InputFN = (auth?: JWTPayload) => Handler<LoaderFunctionArgs> | Handler<ActionFunctionArgs>;
11
11
  type WithAuthHandler<T extends LoaderFunctionArgs | ActionFunctionArgs> = (fn: InputFN) => Handler<T>;
12
- declare function createWithAuthHandler<T extends LoaderFunctionArgs | ActionFunctionArgs>({ JWT_MANAGER, AUTH }: {
13
- JWT_MANAGER: JWTManager;
14
- AUTH: AuthService;
12
+ declare function createWithAuthHandler<T extends LoaderFunctionArgs | ActionFunctionArgs>({ authService }: {
13
+ authService: AuthService;
15
14
  }): <THandler extends Handler<T>>(fn: (auth?: JWTPayload) => THandler) => THandler;
16
15
 
17
16
  export { type WithAuthHandler, createWithAuthHandler };
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,59 +15,45 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
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
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
- // src/auth-kit/with_auth.ts
20
+ // src/auth/with_auth.ts
31
21
  var with_auth_exports = {};
32
22
  __export(with_auth_exports, {
33
23
  createWithAuthHandler: () => createWithAuthHandler
34
24
  });
35
25
  module.exports = __toCommonJS(with_auth_exports);
36
-
37
- // src/auth-kit/auth_service.ts
38
- var import_bcryptjs = __toESM(require("bcryptjs"));
39
- var import_uuid = require("uuid");
40
- var import_react_router = require("react-router");
41
- var ACCESS_TOKEN_KEY = "access_token";
42
- var REFRESH_TOKEN_KEY = "refresh_token";
43
- var ACCESS_TOKEN_COOKIE = (0, import_react_router.createCookie)(ACCESS_TOKEN_KEY, {
44
- path: "/",
45
- httpOnly: process.env.NODE_ENV === "production",
46
- secure: process.env.NODE_ENV === "production",
47
- sameSite: "strict"
48
- });
49
- var REFRESH_TOKEN_COOKIE = (0, import_react_router.createCookie)(REFRESH_TOKEN_KEY, {
50
- path: "/",
51
- httpOnly: process.env.NODE_ENV === "production",
52
- secure: process.env.NODE_ENV === "production",
53
- sameSite: "strict"
54
- });
55
-
56
- // src/auth-kit/with_auth.ts
57
- function createWithAuthHandler({ JWT_MANAGER, AUTH }) {
26
+ function createWithAuthHandler({ authService }) {
58
27
  return function(fn) {
59
28
  const handler = async function(arg) {
60
- const cookie = arg.request.headers.get("cookie");
61
- const accessToken = await ACCESS_TOKEN_COOKIE.parse(cookie);
29
+ const respond = async (auth) => {
30
+ const res = await fn(auth)(arg);
31
+ if (typeof res === "object" && res !== null && !Array.isArray(res)) {
32
+ if (res instanceof Response) {
33
+ if (res.status < 300 && res.body) {
34
+ console.log(res.body);
35
+ return res;
36
+ }
37
+ }
38
+ return {
39
+ AUTH: auth,
40
+ ...res
41
+ };
42
+ }
43
+ return res;
44
+ };
45
+ const accessToken = await authService.getAccessTokenFromRequest(arg.request);
62
46
  if (accessToken) {
63
- const payload = await JWT_MANAGER.verifyAccessToken(accessToken);
47
+ const payload = await authService.jwtManager.verifyAccessToken(accessToken);
64
48
  if (payload) {
65
- return fn(payload)(arg);
49
+ return respond(payload);
66
50
  }
67
51
  }
68
- const refreshToken = await REFRESH_TOKEN_COOKIE.parse(cookie);
52
+ const refreshToken = await authService.getRefreshTokenFromCookies(arg.request);
69
53
  if (refreshToken) {
70
54
  try {
71
- const newAccessToken = await AUTH.refreshAccessToken(refreshToken);
72
- const setCookieHeader = await AUTH.getAccessTokenSetCookie(
55
+ const newAccessToken = await authService.refreshAccessToken(refreshToken);
56
+ const setCookieHeader = await authService.getAccessTokenSetCookie(
73
57
  newAccessToken
74
58
  );
75
59
  const headers = new Headers();
@@ -83,7 +67,7 @@ function createWithAuthHandler({ JWT_MANAGER, AUTH }) {
83
67
  if (e instanceof Error) {
84
68
  console.log(e.message);
85
69
  }
86
- const setCookieHeader = await AUTH.getRefreshTokenSetCookie(null);
70
+ const setCookieHeader = await authService.getRefreshTokenSetCookie(null);
87
71
  const headers = new Headers();
88
72
  headers.append("Set-Cookie", setCookieHeader);
89
73
  headers.append("Location", arg.request.url);
@@ -93,7 +77,7 @@ function createWithAuthHandler({ JWT_MANAGER, AUTH }) {
93
77
  });
94
78
  }
95
79
  }
96
- return fn(void 0)(arg);
80
+ return respond(void 0);
97
81
  };
98
82
  return handler;
99
83
  };
@@ -0,0 +1,63 @@
1
+ // src/auth/with_auth.ts
2
+ function createWithAuthHandler({ authService }) {
3
+ return function(fn) {
4
+ const handler = async function(arg) {
5
+ const respond = async (auth) => {
6
+ const res = await fn(auth)(arg);
7
+ if (typeof res === "object" && res !== null && !Array.isArray(res)) {
8
+ if (res instanceof Response) {
9
+ if (res.status < 300 && res.body) {
10
+ console.log(res.body);
11
+ return res;
12
+ }
13
+ }
14
+ return {
15
+ AUTH: auth,
16
+ ...res
17
+ };
18
+ }
19
+ return res;
20
+ };
21
+ const accessToken = await authService.getAccessTokenFromRequest(arg.request);
22
+ if (accessToken) {
23
+ const payload = await authService.jwtManager.verifyAccessToken(accessToken);
24
+ if (payload) {
25
+ return respond(payload);
26
+ }
27
+ }
28
+ const refreshToken = await authService.getRefreshTokenFromCookies(arg.request);
29
+ if (refreshToken) {
30
+ try {
31
+ const newAccessToken = await authService.refreshAccessToken(refreshToken);
32
+ const setCookieHeader = await authService.getAccessTokenSetCookie(
33
+ newAccessToken
34
+ );
35
+ const headers = new Headers();
36
+ headers.append("Set-Cookie", setCookieHeader);
37
+ headers.append("Location", arg.request.url);
38
+ return new Response("Temporary Redirect", {
39
+ status: 307,
40
+ headers
41
+ });
42
+ } catch (e) {
43
+ if (e instanceof Error) {
44
+ console.log(e.message);
45
+ }
46
+ const setCookieHeader = await authService.getRefreshTokenSetCookie(null);
47
+ const headers = new Headers();
48
+ headers.append("Set-Cookie", setCookieHeader);
49
+ headers.append("Location", arg.request.url);
50
+ return new Response("Temporary Redirect", {
51
+ status: 307,
52
+ headers
53
+ });
54
+ }
55
+ }
56
+ return respond(void 0);
57
+ };
58
+ return handler;
59
+ };
60
+ }
61
+ export {
62
+ createWithAuthHandler
63
+ };
package/dist/date.d.mts CHANGED
@@ -1,3 +1,5 @@
1
+ export { default as moment } from 'moment-timezone';
2
+
1
3
  declare const formatHumanDateTime: (value: string | Date) => string;
2
4
 
3
5
  export { formatHumanDateTime };
package/dist/date.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export { default as moment } from 'moment-timezone';
2
+
1
3
  declare const formatHumanDateTime: (value: string | Date) => string;
2
4
 
3
5
  export { formatHumanDateTime };
package/dist/date.js CHANGED
@@ -30,7 +30,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/date.ts
31
31
  var date_exports = {};
32
32
  __export(date_exports, {
33
- formatHumanDateTime: () => formatHumanDateTime
33
+ formatHumanDateTime: () => formatHumanDateTime,
34
+ moment: () => import_moment_timezone.default
34
35
  });
35
36
  module.exports = __toCommonJS(date_exports);
36
37
  var import_moment_timezone = __toESM(require("moment-timezone"));
@@ -59,5 +60,6 @@ var formatHumanDateTime = (value) => {
59
60
  };
60
61
  // Annotate the CommonJS export names for ESM import in node:
61
62
  0 && (module.exports = {
62
- formatHumanDateTime
63
+ formatHumanDateTime,
64
+ moment
63
65
  });
package/dist/date.mjs CHANGED
@@ -24,5 +24,6 @@ var formatHumanDateTime = (value) => {
24
24
  return date.format("YYYY\uB144 M\uC6D4 D\uC77C");
25
25
  };
26
26
  export {
27
- formatHumanDateTime
27
+ formatHumanDateTime,
28
+ moment
28
29
  };
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // src/file-kit/cdn.ts
20
+ // src/file/cdn.ts
21
21
  var cdn_exports = {};
22
22
  __export(cdn_exports, {
23
23
  createCDN: () => createCDN
@@ -1,4 +1,4 @@
1
- // src/file-kit/cdn.ts
1
+ // src/file/cdn.ts
2
2
  var createCDN = (origin) => {
3
3
  return (key, { width } = {}) => {
4
4
  return key ? `${origin}/${key}${width ? `?w=${width}` : ""}` : void 0;
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
- // src/file-kit/client/drop_file_input.tsx
30
+ // src/file/client/drop_file_input.tsx
31
31
  var drop_file_input_exports = {};
32
32
  __export(drop_file_input_exports, {
33
33
  DropFileMessageBox: () => DropFileMessageBox,
@@ -42,7 +42,7 @@ function cn(...classes) {
42
42
  return classes.filter(Boolean).join(" ").trim();
43
43
  }
44
44
 
45
- // src/file-kit/client/metadata.ts
45
+ // src/file/client/metadata.ts
46
46
  function generateMetadata(blob) {
47
47
  return new Promise((resolve, reject) => {
48
48
  if (blob.type.startsWith("image/")) {
@@ -74,7 +74,7 @@ function generateMetadata(blob) {
74
74
  });
75
75
  }
76
76
 
77
- // src/file-kit/client/drop_file_input.tsx
77
+ // src/file/client/drop_file_input.tsx
78
78
  function createUseDropFileInput({
79
79
  uploadFile
80
80
  }) {
@@ -1,4 +1,4 @@
1
- // src/file-kit/client/drop_file_input.tsx
1
+ // src/file/client/drop_file_input.tsx
2
2
  import React, {
3
3
  useState,
4
4
  useCallback,
@@ -13,7 +13,7 @@ function cn(...classes) {
13
13
  return classes.filter(Boolean).join(" ").trim();
14
14
  }
15
15
 
16
- // src/file-kit/client/metadata.ts
16
+ // src/file/client/metadata.ts
17
17
  function generateMetadata(blob) {
18
18
  return new Promise((resolve, reject) => {
19
19
  if (blob.type.startsWith("image/")) {
@@ -45,7 +45,7 @@ function generateMetadata(blob) {
45
45
  });
46
46
  }
47
47
 
48
- // src/file-kit/client/drop_file_input.tsx
48
+ // src/file/client/drop_file_input.tsx
49
49
  function createUseDropFileInput({
50
50
  uploadFile
51
51
  }) {
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
- // src/file-kit/client/file_upload_button.tsx
30
+ // src/file/client/file_upload_button.tsx
31
31
  var file_upload_button_exports = {};
32
32
  __export(file_upload_button_exports, {
33
33
  default: () => createFileUploadButton
@@ -1,4 +1,4 @@
1
- // src/file-kit/client/file_upload_button.tsx
1
+ // src/file/client/file_upload_button.tsx
2
2
  import React from "react";
3
3
  import { useRef } from "react";
4
4
  function createFileUploadButton({
@@ -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/file-kit/client/file_uploader.ts
20
+ // src/file/client/file_uploader.ts
21
21
  var file_uploader_exports = {};
22
22
  __export(file_uploader_exports, {
23
23
  FileUploader: () => FileUploader
24
24
  });
25
25
  module.exports = __toCommonJS(file_uploader_exports);
26
26
 
27
- // src/file-kit/client/metadata.ts
27
+ // src/file/client/metadata.ts
28
28
  function generateMetadata(blob) {
29
29
  return new Promise((resolve, reject) => {
30
30
  if (blob.type.startsWith("image/")) {
@@ -56,7 +56,7 @@ function generateMetadata(blob) {
56
56
  });
57
57
  }
58
58
 
59
- // src/file-kit/client/file_uploader.ts
59
+ // src/file/client/file_uploader.ts
60
60
  var FileUploader = class {
61
61
  endpoint;
62
62
  constructor(endpoint = "/api/files") {
@@ -1,4 +1,4 @@
1
- // src/file-kit/client/metadata.ts
1
+ // src/file/client/metadata.ts
2
2
  function generateMetadata(blob) {
3
3
  return new Promise((resolve, reject) => {
4
4
  if (blob.type.startsWith("image/")) {
@@ -30,7 +30,7 @@ function generateMetadata(blob) {
30
30
  });
31
31
  }
32
32
 
33
- // src/file-kit/client/file_uploader.ts
33
+ // src/file/client/file_uploader.ts
34
34
  var FileUploader = class {
35
35
  endpoint;
36
36
  constructor(endpoint = "/api/files") {
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // src/file-kit/client/format_size.ts
20
+ // src/file/client/format_size.ts
21
21
  var format_size_exports = {};
22
22
  __export(format_size_exports, {
23
23
  formatSize: () => formatSize
@@ -1,4 +1,4 @@
1
- // src/file-kit/client/format_size.ts
1
+ // src/file/client/format_size.ts
2
2
  function formatSize(size) {
3
3
  if (size < 1024) {
4
4
  return `${size} B`;
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // src/file-kit/client/metadata.ts
20
+ // src/file/client/metadata.ts
21
21
  var metadata_exports = {};
22
22
  __export(metadata_exports, {
23
23
  generateMetadata: () => generateMetadata