dn-react-router-toolkit 0.1.12 → 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.
- package/dist/auth/apple_auth.d.mts +38 -0
- package/dist/auth/apple_auth.d.ts +38 -0
- package/dist/{auth-kit → auth}/apple_auth.js +31 -18
- package/dist/auth/apple_auth.mjs +63 -0
- package/dist/{auth-kit/repository.d.mts → auth/auth_repository.d.mts} +6 -9
- package/dist/{auth-kit/repository.d.ts → auth/auth_repository.d.ts} +6 -9
- package/dist/{file-kit/repository.js → auth/auth_repository.js} +3 -3
- package/dist/{auth-kit → auth}/auth_service.d.mts +11 -22
- package/dist/{auth-kit → auth}/auth_service.d.ts +11 -22
- package/dist/{auth-kit → auth}/auth_service.js +23 -76
- package/dist/{auth-kit → auth}/auth_service.mjs +23 -76
- package/dist/auth/client/google_login_button.d.mts +7 -0
- package/dist/auth/client/google_login_button.d.ts +7 -0
- package/dist/{auth-kit → auth}/client/google_login_button.js +24 -19
- package/dist/auth/client/google_login_button.mjs +37 -0
- package/dist/auth/client/provider.d.mts +23 -0
- package/dist/auth/client/provider.d.ts +23 -0
- package/dist/auth/client/provider.js +137 -0
- package/dist/auth/client/provider.mjs +101 -0
- package/dist/{auth-kit → auth}/client/redirect_page.js +1 -1
- package/dist/{auth-kit → auth}/client/redirect_page.mjs +1 -1
- package/dist/auth/google_auth.d.mts +33 -0
- package/dist/auth/google_auth.d.ts +33 -0
- package/dist/{auth-kit → auth}/google_auth.js +23 -32
- package/dist/{auth-kit → auth}/google_auth.mjs +22 -31
- package/dist/auth/handlers/find_auth.d.mts +13 -0
- package/dist/auth/handlers/find_auth.d.ts +13 -0
- package/dist/{route/api/auth/route.js → auth/handlers/find_auth.js} +10 -10
- package/dist/{route/api/auth/route.mjs → auth/handlers/find_auth.mjs} +5 -5
- package/dist/auth/handlers/login.d.mts +13 -0
- package/dist/auth/handlers/login.d.ts +13 -0
- package/dist/{route/api/auth/login/route.js → auth/handlers/login.js} +17 -17
- package/dist/{route/api/auth/login/route.mjs → auth/handlers/login.mjs} +12 -12
- package/dist/auth/handlers/login_with_thirdparty.d.mts +15 -0
- package/dist/auth/handlers/login_with_thirdparty.d.ts +15 -0
- package/dist/{route/api/auth/login/[provider]/route.js → auth/handlers/login_with_thirdparty.js} +12 -27
- package/dist/{route/api/auth/login/[provider]/route.mjs → auth/handlers/login_with_thirdparty.mjs} +7 -22
- package/dist/auth/handlers/logout.d.mts +13 -0
- package/dist/auth/handlers/logout.d.ts +13 -0
- package/dist/{route/api/auth/logout/route.js → auth/handlers/logout.js} +15 -11
- package/dist/{route/api/auth/logout/route.mjs → auth/handlers/logout.mjs} +11 -7
- package/dist/auth/handlers/refresh.d.mts +13 -0
- package/dist/auth/handlers/refresh.d.ts +13 -0
- package/dist/{route/api/auth/refresh/route.js → auth/handlers/refresh.js} +12 -12
- package/dist/{route/api/auth/refresh/route.mjs → auth/handlers/refresh.mjs} +7 -7
- package/dist/auth/handlers/signup.d.mts +15 -0
- package/dist/auth/handlers/signup.d.ts +15 -0
- package/dist/auth/handlers/signup.js +135 -0
- package/dist/auth/handlers/signup.mjs +100 -0
- package/dist/auth/handlers/signup_with_thirdparty.d.mts +17 -0
- package/dist/auth/handlers/signup_with_thirdparty.d.ts +17 -0
- package/dist/auth/handlers/signup_with_thirdparty.js +123 -0
- package/dist/auth/handlers/signup_with_thirdparty.mjs +98 -0
- package/dist/auth/handlers/thirdparty_auth_callback.d.mts +16 -0
- package/dist/auth/handlers/thirdparty_auth_callback.d.ts +16 -0
- package/dist/{route/auth/callback/[provider]/route.js → auth/handlers/thirdparty_auth_callback.js} +54 -45
- package/dist/{route/auth/callback/[provider]/route.mjs → auth/handlers/thirdparty_auth_callback.mjs} +49 -40
- package/dist/{auth-kit/jwt.d.mts → auth/jwt_manager.d.mts} +11 -1
- package/dist/{auth-kit/jwt.d.ts → auth/jwt_manager.d.ts} +11 -1
- package/dist/{auth-kit/jwt.js → auth/jwt_manager.js} +25 -11
- package/dist/{auth-kit/jwt.mjs → auth/jwt_manager.mjs} +22 -8
- package/dist/auth/kakao_auth.d.mts +27 -0
- package/dist/auth/kakao_auth.d.ts +27 -0
- package/dist/auth/kakao_auth.js +56 -0
- package/dist/auth/kakao_auth.mjs +31 -0
- package/dist/auth/thirdparty_auth.d.mts +41 -0
- package/dist/auth/thirdparty_auth.d.ts +41 -0
- package/dist/{auth-kit/kakao_auth.js → auth/thirdparty_auth.js} +31 -33
- package/dist/{auth-kit/kakao_auth.mjs → auth/thirdparty_auth.mjs} +26 -28
- package/dist/{auth-kit → auth}/with_auth.d.mts +5 -6
- package/dist/{auth-kit → auth}/with_auth.d.ts +5 -6
- package/dist/{auth-kit → auth}/with_auth.js +26 -10
- package/dist/auth/with_auth.mjs +63 -0
- package/dist/date.d.mts +2 -0
- package/dist/date.d.ts +2 -0
- package/dist/date.js +4 -2
- package/dist/date.mjs +2 -1
- package/dist/{file-kit → file}/cdn.js +1 -1
- package/dist/{file-kit → file}/cdn.mjs +1 -1
- package/dist/{file-kit → file}/client/drop_file_input.js +3 -3
- package/dist/{file-kit → file}/client/drop_file_input.mjs +3 -3
- package/dist/{file-kit → file}/client/file_upload_button.js +1 -1
- package/dist/{file-kit → file}/client/file_upload_button.mjs +1 -1
- package/dist/{file-kit → file}/client/file_uploader.js +3 -3
- package/dist/{file-kit → file}/client/file_uploader.mjs +2 -2
- package/dist/{file-kit → file}/client/format_size.js +1 -1
- package/dist/{file-kit → file}/client/format_size.mjs +1 -1
- package/dist/{file-kit → file}/client/metadata.js +1 -1
- package/dist/{file-kit → file}/client/metadata.mjs +1 -1
- package/dist/{file-kit/repository.d.mts → file/file_repository.d.mts} +4 -4
- package/dist/{file-kit/repository.d.ts → file/file_repository.d.ts} +4 -4
- package/dist/{auth-kit/repository.js → file/file_repository.js} +3 -3
- package/dist/file/file_service.d.mts +32 -0
- package/dist/file/file_service.d.ts +32 -0
- package/dist/{file-kit → file}/file_service.js +27 -21
- package/dist/file/file_service.mjs +41 -0
- package/dist/file/handlers/delete_file.d.mts +17 -0
- package/dist/file/handlers/delete_file.d.ts +17 -0
- package/dist/{route/api/files/[fileId]/route.js → file/handlers/delete_file.js} +15 -15
- package/dist/{route/api/files/[fileId]/route.mjs → file/handlers/delete_file.mjs} +10 -10
- package/dist/file/handlers/upload_file.d.mts +16 -0
- package/dist/file/handlers/upload_file.d.ts +16 -0
- package/dist/{route/api/files/route.js → file/handlers/upload_file.js} +13 -13
- package/dist/{route/api/files/route.mjs → file/handlers/upload_file.mjs} +8 -8
- package/dist/{file-kit → file}/object_storage.d.mts +3 -1
- package/dist/{file-kit → file}/object_storage.d.ts +3 -1
- package/dist/{file-kit → file}/object_storage.js +2 -2
- package/dist/{file-kit → file}/object_storage.mjs +2 -2
- package/dist/{file-kit → file}/responsive_image.d.mts +4 -4
- package/dist/{file-kit → file}/responsive_image.d.ts +4 -4
- package/dist/{file-kit → file}/responsive_image.js +18 -9
- package/dist/{file-kit → file}/responsive_image.mjs +18 -9
- package/dist/{http-kit → http}/index.js +5 -5
- package/dist/{http-kit → http}/index.mjs +1 -1
- package/dist/{http-kit → http}/response.js +1 -1
- package/dist/{http-kit → http}/response.mjs +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.mjs +1 -0
- package/dist/route/api.d.mts +15 -25
- package/dist/route/api.d.ts +15 -25
- package/dist/route/api.js +325 -178
- package/dist/route/api.mjs +314 -177
- package/dist/{seo-kit → seo}/seo.js +1 -1
- package/dist/{seo-kit → seo}/seo.mjs +1 -1
- package/package.json +74 -74
- package/dist/auth-kit/apple_auth.d.mts +0 -24
- package/dist/auth-kit/apple_auth.d.ts +0 -24
- package/dist/auth-kit/apple_auth.mjs +0 -50
- package/dist/auth-kit/client/google_login_button.d.mts +0 -9
- package/dist/auth-kit/client/google_login_button.d.ts +0 -9
- package/dist/auth-kit/client/google_login_button.mjs +0 -32
- package/dist/auth-kit/client/logout.d.mts +0 -3
- package/dist/auth-kit/client/logout.d.ts +0 -3
- package/dist/auth-kit/client/logout.js +0 -49
- package/dist/auth-kit/client/logout.mjs +0 -24
- package/dist/auth-kit/google_auth.d.mts +0 -27
- package/dist/auth-kit/google_auth.d.ts +0 -27
- package/dist/auth-kit/kakao_auth.d.mts +0 -24
- package/dist/auth-kit/kakao_auth.d.ts +0 -24
- package/dist/auth-kit/with_auth.mjs +0 -47
- package/dist/file-kit/file_service.d.mts +0 -26
- package/dist/file-kit/file_service.d.ts +0 -26
- package/dist/file-kit/file_service.mjs +0 -35
- package/dist/route/api/auth/login/_provider_/route.d.mts +0 -20
- package/dist/route/api/auth/login/_provider_/route.d.ts +0 -20
- package/dist/route/api/auth/login/route.d.mts +0 -14
- package/dist/route/api/auth/login/route.d.ts +0 -14
- package/dist/route/api/auth/logout/route.d.mts +0 -14
- package/dist/route/api/auth/logout/route.d.ts +0 -14
- package/dist/route/api/auth/refresh/route.d.mts +0 -13
- package/dist/route/api/auth/refresh/route.d.ts +0 -13
- package/dist/route/api/auth/route.d.mts +0 -13
- package/dist/route/api/auth/route.d.ts +0 -13
- package/dist/route/api/files/_fileId_/route.d.mts +0 -17
- package/dist/route/api/files/_fileId_/route.d.ts +0 -17
- package/dist/route/api/files/route.d.mts +0 -16
- package/dist/route/api/files/route.d.ts +0 -16
- package/dist/route/auth/callback/_provider_/route.d.mts +0 -20
- package/dist/route/auth/callback/_provider_/route.d.ts +0 -20
- /package/dist/{auth-kit/repository.mjs → auth/auth_repository.mjs} +0 -0
- /package/dist/{auth-kit → auth}/client/redirect_page.d.mts +0 -0
- /package/dist/{auth-kit → auth}/client/redirect_page.d.ts +0 -0
- /package/dist/{file-kit → file}/cdn.d.mts +0 -0
- /package/dist/{file-kit → file}/cdn.d.ts +0 -0
- /package/dist/{file-kit → file}/client/drop_file_input.d.mts +0 -0
- /package/dist/{file-kit → file}/client/drop_file_input.d.ts +0 -0
- /package/dist/{file-kit → file}/client/file_upload_button.d.mts +0 -0
- /package/dist/{file-kit → file}/client/file_upload_button.d.ts +0 -0
- /package/dist/{file-kit → file}/client/file_uploader.d.mts +0 -0
- /package/dist/{file-kit → file}/client/file_uploader.d.ts +0 -0
- /package/dist/{file-kit → file}/client/format_size.d.mts +0 -0
- /package/dist/{file-kit → file}/client/format_size.d.ts +0 -0
- /package/dist/{file-kit → file}/client/metadata.d.mts +0 -0
- /package/dist/{file-kit → file}/client/metadata.d.ts +0 -0
- /package/dist/{file-kit/repository.mjs → file/file_repository.mjs} +0 -0
- /package/dist/{http-kit → http}/index.d.mts +0 -0
- /package/dist/{http-kit → http}/index.d.ts +0 -0
- /package/dist/{http-kit → http}/response.d.mts +0 -0
- /package/dist/{http-kit → http}/response.d.ts +0 -0
- /package/dist/{seo-kit → seo}/seo.d.mts +0 -0
- /package/dist/{seo-kit → seo}/seo.d.ts +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AuthService } from '../auth_service.mjs';
|
|
2
|
+
import { ThirdpartyAuth } from '../thirdparty_auth.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 thirdpartyAuthCallbackHandler: (request: Request, { provider, authService, getThirdPartyAuth, }: {
|
|
11
|
+
provider: string;
|
|
12
|
+
authService: AuthService;
|
|
13
|
+
getThirdPartyAuth: (provider: string) => ThirdpartyAuth;
|
|
14
|
+
}) => Promise<Response>;
|
|
15
|
+
|
|
16
|
+
export { thirdpartyAuthCallbackHandler };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AuthService } from '../auth_service.js';
|
|
2
|
+
import { ThirdpartyAuth } from '../thirdparty_auth.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 thirdpartyAuthCallbackHandler: (request: Request, { provider, authService, getThirdPartyAuth, }: {
|
|
11
|
+
provider: string;
|
|
12
|
+
authService: AuthService;
|
|
13
|
+
getThirdPartyAuth: (provider: string) => ThirdpartyAuth;
|
|
14
|
+
}) => Promise<Response>;
|
|
15
|
+
|
|
16
|
+
export { thirdpartyAuthCallbackHandler };
|
package/dist/{route/auth/callback/[provider]/route.js → auth/handlers/thirdparty_auth_callback.js}
RENAMED
|
@@ -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/
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
23
|
-
|
|
20
|
+
// src/auth/handlers/thirdparty_auth_callback.tsx
|
|
21
|
+
var thirdparty_auth_callback_exports = {};
|
|
22
|
+
__export(thirdparty_auth_callback_exports, {
|
|
23
|
+
thirdpartyAuthCallbackHandler: () => thirdpartyAuthCallbackHandler
|
|
24
24
|
});
|
|
25
|
-
module.exports = __toCommonJS(
|
|
25
|
+
module.exports = __toCommonJS(thirdparty_auth_callback_exports);
|
|
26
26
|
|
|
27
|
-
// src/http
|
|
27
|
+
// src/http/response.ts
|
|
28
28
|
var createJsonResponse = (status) => {
|
|
29
29
|
return (data = {}, init) => {
|
|
30
30
|
return Response.json(data, { status, ...init });
|
|
@@ -68,53 +68,62 @@ 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/
|
|
72
|
-
var
|
|
73
|
-
provider
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
GOOGLE_AUTH,
|
|
77
|
-
APPLE_AUTH,
|
|
78
|
-
SITE_ORIGIN
|
|
71
|
+
// src/auth/handlers/thirdparty_auth_callback.tsx
|
|
72
|
+
var thirdpartyAuthCallbackHandler = async (request, {
|
|
73
|
+
provider,
|
|
74
|
+
authService,
|
|
75
|
+
getThirdPartyAuth
|
|
79
76
|
}) => {
|
|
80
77
|
const url = new URL(request.url);
|
|
81
78
|
const code = url.searchParams.get("code");
|
|
82
79
|
if (!code) {
|
|
83
80
|
throw BAD_REQUEST("\uCF54\uB4DC\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
84
81
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
82
|
+
try {
|
|
83
|
+
const { accessToken, refreshToken } = await getThirdPartyAuth(
|
|
84
|
+
provider
|
|
85
|
+
).login(code);
|
|
86
|
+
const [accessTokenSetCookie, refreshTokenSetCookie] = await Promise.all([
|
|
87
|
+
authService.getAccessTokenSetCookie(accessToken),
|
|
88
|
+
authService.getRefreshTokenSetCookie(refreshToken)
|
|
89
|
+
]);
|
|
90
|
+
const headers = new Headers();
|
|
91
|
+
headers.append("Set-Cookie", accessTokenSetCookie);
|
|
92
|
+
headers.append("Set-Cookie", refreshTokenSetCookie);
|
|
93
|
+
const redirectUrl = url.searchParams.get("state") || "/";
|
|
94
|
+
return new Response("Temporary Redirect", {
|
|
95
|
+
status: 307,
|
|
96
|
+
headers: {
|
|
97
|
+
...headers,
|
|
98
|
+
Location: new URL(
|
|
99
|
+
`/r?redirectUrl=${encodeURIComponent(redirectUrl)}`,
|
|
100
|
+
request.url
|
|
101
|
+
).toString()
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
} catch (error) {
|
|
105
|
+
if (error instanceof Response) {
|
|
106
|
+
if (error.status == 404) {
|
|
107
|
+
const body = await error.json();
|
|
108
|
+
const token = body.token;
|
|
109
|
+
return new Response(
|
|
110
|
+
"Temporary Redirect",
|
|
111
|
+
{
|
|
112
|
+
status: 307,
|
|
113
|
+
headers: {
|
|
114
|
+
Location: new URL(
|
|
115
|
+
`/signup?token=${token}`,
|
|
116
|
+
request.url
|
|
117
|
+
).toString()
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
}
|
|
93
122
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
provider
|
|
97
|
-
).signIn(code);
|
|
98
|
-
const [accessTokenSetCookie, refreshTokenSetCookie] = await Promise.all([
|
|
99
|
-
AUTH.getAccessTokenSetCookie(accessToken),
|
|
100
|
-
AUTH.getRefreshTokenSetCookie(refreshToken)
|
|
101
|
-
]);
|
|
102
|
-
const headers = new Headers();
|
|
103
|
-
headers.append("Set-Cookie", accessTokenSetCookie);
|
|
104
|
-
headers.append("Set-Cookie", refreshTokenSetCookie);
|
|
105
|
-
const redirectUrl = url.searchParams.get("state") || SITE_ORIGIN;
|
|
106
|
-
return new Response("Temporary Redirect", {
|
|
107
|
-
status: 307,
|
|
108
|
-
headers: {
|
|
109
|
-
...headers,
|
|
110
|
-
Location: new URL(
|
|
111
|
-
`/r?redirectUrl=${encodeURIComponent(redirectUrl)}`,
|
|
112
|
-
request.url
|
|
113
|
-
).toString()
|
|
114
|
-
}
|
|
115
|
-
});
|
|
123
|
+
throw error;
|
|
124
|
+
}
|
|
116
125
|
};
|
|
117
126
|
// Annotate the CommonJS export names for ESM import in node:
|
|
118
127
|
0 && (module.exports = {
|
|
119
|
-
|
|
128
|
+
thirdpartyAuthCallbackHandler
|
|
120
129
|
});
|
package/dist/{route/auth/callback/[provider]/route.mjs → auth/handlers/thirdparty_auth_callback.mjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/http
|
|
1
|
+
// src/http/response.ts
|
|
2
2
|
var createJsonResponse = (status) => {
|
|
3
3
|
return (data = {}, init) => {
|
|
4
4
|
return Response.json(data, { status, ...init });
|
|
@@ -42,52 +42,61 @@ 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/
|
|
46
|
-
var
|
|
47
|
-
provider
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
GOOGLE_AUTH,
|
|
51
|
-
APPLE_AUTH,
|
|
52
|
-
SITE_ORIGIN
|
|
45
|
+
// src/auth/handlers/thirdparty_auth_callback.tsx
|
|
46
|
+
var thirdpartyAuthCallbackHandler = async (request, {
|
|
47
|
+
provider,
|
|
48
|
+
authService,
|
|
49
|
+
getThirdPartyAuth
|
|
53
50
|
}) => {
|
|
54
51
|
const url = new URL(request.url);
|
|
55
52
|
const code = url.searchParams.get("code");
|
|
56
53
|
if (!code) {
|
|
57
54
|
throw BAD_REQUEST("\uCF54\uB4DC\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
58
55
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
56
|
+
try {
|
|
57
|
+
const { accessToken, refreshToken } = await getThirdPartyAuth(
|
|
58
|
+
provider
|
|
59
|
+
).login(code);
|
|
60
|
+
const [accessTokenSetCookie, refreshTokenSetCookie] = await Promise.all([
|
|
61
|
+
authService.getAccessTokenSetCookie(accessToken),
|
|
62
|
+
authService.getRefreshTokenSetCookie(refreshToken)
|
|
63
|
+
]);
|
|
64
|
+
const headers = new Headers();
|
|
65
|
+
headers.append("Set-Cookie", accessTokenSetCookie);
|
|
66
|
+
headers.append("Set-Cookie", refreshTokenSetCookie);
|
|
67
|
+
const redirectUrl = url.searchParams.get("state") || "/";
|
|
68
|
+
return new Response("Temporary Redirect", {
|
|
69
|
+
status: 307,
|
|
70
|
+
headers: {
|
|
71
|
+
...headers,
|
|
72
|
+
Location: new URL(
|
|
73
|
+
`/r?redirectUrl=${encodeURIComponent(redirectUrl)}`,
|
|
74
|
+
request.url
|
|
75
|
+
).toString()
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
} catch (error) {
|
|
79
|
+
if (error instanceof Response) {
|
|
80
|
+
if (error.status == 404) {
|
|
81
|
+
const body = await error.json();
|
|
82
|
+
const token = body.token;
|
|
83
|
+
return new Response(
|
|
84
|
+
"Temporary Redirect",
|
|
85
|
+
{
|
|
86
|
+
status: 307,
|
|
87
|
+
headers: {
|
|
88
|
+
Location: new URL(
|
|
89
|
+
`/signup?token=${token}`,
|
|
90
|
+
request.url
|
|
91
|
+
).toString()
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
}
|
|
67
96
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
provider
|
|
71
|
-
).signIn(code);
|
|
72
|
-
const [accessTokenSetCookie, refreshTokenSetCookie] = await Promise.all([
|
|
73
|
-
AUTH.getAccessTokenSetCookie(accessToken),
|
|
74
|
-
AUTH.getRefreshTokenSetCookie(refreshToken)
|
|
75
|
-
]);
|
|
76
|
-
const headers = new Headers();
|
|
77
|
-
headers.append("Set-Cookie", accessTokenSetCookie);
|
|
78
|
-
headers.append("Set-Cookie", refreshTokenSetCookie);
|
|
79
|
-
const redirectUrl = url.searchParams.get("state") || SITE_ORIGIN;
|
|
80
|
-
return new Response("Temporary Redirect", {
|
|
81
|
-
status: 307,
|
|
82
|
-
headers: {
|
|
83
|
-
...headers,
|
|
84
|
-
Location: new URL(
|
|
85
|
-
`/r?redirectUrl=${encodeURIComponent(redirectUrl)}`,
|
|
86
|
-
request.url
|
|
87
|
-
).toString()
|
|
88
|
-
}
|
|
89
|
-
});
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
90
99
|
};
|
|
91
100
|
export {
|
|
92
|
-
|
|
101
|
+
thirdpartyAuthCallbackHandler
|
|
93
102
|
};
|
|
@@ -2,7 +2,17 @@ import { JWTPayload } from 'jose';
|
|
|
2
2
|
|
|
3
3
|
declare class JWTManager {
|
|
4
4
|
siteOrigin?: string;
|
|
5
|
-
|
|
5
|
+
accessTokenSecret: string;
|
|
6
|
+
accessTokenExpiresIn: string;
|
|
7
|
+
refreshTokenSecret: string;
|
|
8
|
+
refreshTokenExpiresIn: string;
|
|
9
|
+
constructor({ siteOrigin, accessTokenSecret, accessTokenExpiresIn, refreshTokenSecret, refreshTokenExpiresIn, }: {
|
|
10
|
+
siteOrigin?: string;
|
|
11
|
+
accessTokenSecret: string;
|
|
12
|
+
accessTokenExpiresIn?: string;
|
|
13
|
+
refreshTokenSecret: string;
|
|
14
|
+
refreshTokenExpiresIn?: string;
|
|
15
|
+
});
|
|
6
16
|
verify(token: string, secret: string): Promise<JWTPayload | undefined>;
|
|
7
17
|
verifyAccessToken(token: string): Promise<JWTPayload | undefined>;
|
|
8
18
|
verifyRefreshToken(token: string): Promise<JWTPayload | undefined>;
|
|
@@ -2,7 +2,17 @@ import { JWTPayload } from 'jose';
|
|
|
2
2
|
|
|
3
3
|
declare class JWTManager {
|
|
4
4
|
siteOrigin?: string;
|
|
5
|
-
|
|
5
|
+
accessTokenSecret: string;
|
|
6
|
+
accessTokenExpiresIn: string;
|
|
7
|
+
refreshTokenSecret: string;
|
|
8
|
+
refreshTokenExpiresIn: string;
|
|
9
|
+
constructor({ siteOrigin, accessTokenSecret, accessTokenExpiresIn, refreshTokenSecret, refreshTokenExpiresIn, }: {
|
|
10
|
+
siteOrigin?: string;
|
|
11
|
+
accessTokenSecret: string;
|
|
12
|
+
accessTokenExpiresIn?: string;
|
|
13
|
+
refreshTokenSecret: string;
|
|
14
|
+
refreshTokenExpiresIn?: string;
|
|
15
|
+
});
|
|
6
16
|
verify(token: string, secret: string): Promise<JWTPayload | undefined>;
|
|
7
17
|
verifyAccessToken(token: string): Promise<JWTPayload | undefined>;
|
|
8
18
|
verifyRefreshToken(token: string): Promise<JWTPayload | undefined>;
|
|
@@ -17,17 +17,31 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// src/auth
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
20
|
+
// src/auth/jwt_manager.ts
|
|
21
|
+
var jwt_manager_exports = {};
|
|
22
|
+
__export(jwt_manager_exports, {
|
|
23
23
|
JWTManager: () => JWTManager
|
|
24
24
|
});
|
|
25
|
-
module.exports = __toCommonJS(
|
|
25
|
+
module.exports = __toCommonJS(jwt_manager_exports);
|
|
26
26
|
var import_jose = require("jose");
|
|
27
27
|
var JWTManager = class {
|
|
28
28
|
siteOrigin;
|
|
29
|
-
|
|
29
|
+
accessTokenSecret;
|
|
30
|
+
accessTokenExpiresIn;
|
|
31
|
+
refreshTokenSecret;
|
|
32
|
+
refreshTokenExpiresIn;
|
|
33
|
+
constructor({
|
|
34
|
+
siteOrigin,
|
|
35
|
+
accessTokenSecret,
|
|
36
|
+
accessTokenExpiresIn = "10s",
|
|
37
|
+
refreshTokenSecret,
|
|
38
|
+
refreshTokenExpiresIn = "1h"
|
|
39
|
+
}) {
|
|
30
40
|
this.siteOrigin = siteOrigin;
|
|
41
|
+
this.accessTokenSecret = accessTokenSecret;
|
|
42
|
+
this.accessTokenExpiresIn = accessTokenExpiresIn;
|
|
43
|
+
this.refreshTokenSecret = refreshTokenSecret;
|
|
44
|
+
this.refreshTokenExpiresIn = refreshTokenExpiresIn;
|
|
31
45
|
}
|
|
32
46
|
async verify(token, secret) {
|
|
33
47
|
try {
|
|
@@ -38,10 +52,10 @@ var JWTManager = class {
|
|
|
38
52
|
}
|
|
39
53
|
}
|
|
40
54
|
async verifyAccessToken(token) {
|
|
41
|
-
return this.verify(token,
|
|
55
|
+
return this.verify(token, this.accessTokenSecret);
|
|
42
56
|
}
|
|
43
57
|
async verifyRefreshToken(token) {
|
|
44
|
-
return this.verify(token,
|
|
58
|
+
return this.verify(token, this.refreshTokenSecret);
|
|
45
59
|
}
|
|
46
60
|
async sign(payload, secret, { expiresIn } = {}) {
|
|
47
61
|
let builder = new import_jose.SignJWT(payload).setProtectedHeader({ alg: "HS256", typ: "JWT" }).setIssuedAt();
|
|
@@ -54,13 +68,13 @@ var JWTManager = class {
|
|
|
54
68
|
return builder.sign(new TextEncoder().encode(secret));
|
|
55
69
|
}
|
|
56
70
|
async signAccessToken(payload) {
|
|
57
|
-
return this.sign(payload,
|
|
58
|
-
expiresIn:
|
|
71
|
+
return this.sign(payload, this.accessTokenSecret, {
|
|
72
|
+
expiresIn: this.accessTokenExpiresIn
|
|
59
73
|
});
|
|
60
74
|
}
|
|
61
75
|
async signRefreshToken(payload) {
|
|
62
|
-
return this.sign(payload,
|
|
63
|
-
expiresIn:
|
|
76
|
+
return this.sign(payload, this.refreshTokenSecret, {
|
|
77
|
+
expiresIn: this.refreshTokenExpiresIn
|
|
64
78
|
});
|
|
65
79
|
}
|
|
66
80
|
decode(token) {
|
|
@@ -1,9 +1,23 @@
|
|
|
1
|
-
// src/auth
|
|
1
|
+
// src/auth/jwt_manager.ts
|
|
2
2
|
import { SignJWT, decodeJwt, jwtVerify } from "jose";
|
|
3
3
|
var JWTManager = class {
|
|
4
4
|
siteOrigin;
|
|
5
|
-
|
|
5
|
+
accessTokenSecret;
|
|
6
|
+
accessTokenExpiresIn;
|
|
7
|
+
refreshTokenSecret;
|
|
8
|
+
refreshTokenExpiresIn;
|
|
9
|
+
constructor({
|
|
10
|
+
siteOrigin,
|
|
11
|
+
accessTokenSecret,
|
|
12
|
+
accessTokenExpiresIn = "10s",
|
|
13
|
+
refreshTokenSecret,
|
|
14
|
+
refreshTokenExpiresIn = "1h"
|
|
15
|
+
}) {
|
|
6
16
|
this.siteOrigin = siteOrigin;
|
|
17
|
+
this.accessTokenSecret = accessTokenSecret;
|
|
18
|
+
this.accessTokenExpiresIn = accessTokenExpiresIn;
|
|
19
|
+
this.refreshTokenSecret = refreshTokenSecret;
|
|
20
|
+
this.refreshTokenExpiresIn = refreshTokenExpiresIn;
|
|
7
21
|
}
|
|
8
22
|
async verify(token, secret) {
|
|
9
23
|
try {
|
|
@@ -14,10 +28,10 @@ var JWTManager = class {
|
|
|
14
28
|
}
|
|
15
29
|
}
|
|
16
30
|
async verifyAccessToken(token) {
|
|
17
|
-
return this.verify(token,
|
|
31
|
+
return this.verify(token, this.accessTokenSecret);
|
|
18
32
|
}
|
|
19
33
|
async verifyRefreshToken(token) {
|
|
20
|
-
return this.verify(token,
|
|
34
|
+
return this.verify(token, this.refreshTokenSecret);
|
|
21
35
|
}
|
|
22
36
|
async sign(payload, secret, { expiresIn } = {}) {
|
|
23
37
|
let builder = new SignJWT(payload).setProtectedHeader({ alg: "HS256", typ: "JWT" }).setIssuedAt();
|
|
@@ -30,13 +44,13 @@ var JWTManager = class {
|
|
|
30
44
|
return builder.sign(new TextEncoder().encode(secret));
|
|
31
45
|
}
|
|
32
46
|
async signAccessToken(payload) {
|
|
33
|
-
return this.sign(payload,
|
|
34
|
-
expiresIn:
|
|
47
|
+
return this.sign(payload, this.accessTokenSecret, {
|
|
48
|
+
expiresIn: this.accessTokenExpiresIn
|
|
35
49
|
});
|
|
36
50
|
}
|
|
37
51
|
async signRefreshToken(payload) {
|
|
38
|
-
return this.sign(payload,
|
|
39
|
-
expiresIn:
|
|
52
|
+
return this.sign(payload, this.refreshTokenSecret, {
|
|
53
|
+
expiresIn: this.refreshTokenExpiresIn
|
|
40
54
|
});
|
|
41
55
|
}
|
|
42
56
|
decode(token) {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ThirdpartyAuth, ThirdpartyAuthService } from './thirdparty_auth.mjs';
|
|
2
|
+
import './auth_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
|
+
|
|
10
|
+
declare class KakaoAuth implements ThirdpartyAuth {
|
|
11
|
+
thirdpartyAuth: ThirdpartyAuthService;
|
|
12
|
+
constructor({ thirdpartyAuth, }: {
|
|
13
|
+
thirdpartyAuth: ThirdpartyAuthService;
|
|
14
|
+
});
|
|
15
|
+
login(kakaoAccessToken: string): Promise<{
|
|
16
|
+
user: {
|
|
17
|
+
id: string;
|
|
18
|
+
role: string;
|
|
19
|
+
name: string;
|
|
20
|
+
refreshToken: string | null;
|
|
21
|
+
};
|
|
22
|
+
accessToken: string;
|
|
23
|
+
refreshToken: string;
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { KakaoAuth };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ThirdpartyAuth, ThirdpartyAuthService } from './thirdparty_auth.js';
|
|
2
|
+
import './auth_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
|
+
|
|
10
|
+
declare class KakaoAuth implements ThirdpartyAuth {
|
|
11
|
+
thirdpartyAuth: ThirdpartyAuthService;
|
|
12
|
+
constructor({ thirdpartyAuth, }: {
|
|
13
|
+
thirdpartyAuth: ThirdpartyAuthService;
|
|
14
|
+
});
|
|
15
|
+
login(kakaoAccessToken: string): Promise<{
|
|
16
|
+
user: {
|
|
17
|
+
id: string;
|
|
18
|
+
role: string;
|
|
19
|
+
name: string;
|
|
20
|
+
refreshToken: string | null;
|
|
21
|
+
};
|
|
22
|
+
accessToken: string;
|
|
23
|
+
refreshToken: string;
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { KakaoAuth };
|
|
@@ -0,0 +1,56 @@
|
|
|
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/kakao_auth.ts
|
|
21
|
+
var kakao_auth_exports = {};
|
|
22
|
+
__export(kakao_auth_exports, {
|
|
23
|
+
KakaoAuth: () => KakaoAuth
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(kakao_auth_exports);
|
|
26
|
+
var KakaoAuth = class {
|
|
27
|
+
thirdpartyAuth;
|
|
28
|
+
constructor({
|
|
29
|
+
thirdpartyAuth
|
|
30
|
+
}) {
|
|
31
|
+
this.thirdpartyAuth = thirdpartyAuth;
|
|
32
|
+
}
|
|
33
|
+
async login(kakaoAccessToken) {
|
|
34
|
+
const userRes = await fetch("https://kapi.kakao.com/v2/user/me", {
|
|
35
|
+
headers: {
|
|
36
|
+
Authorization: `Bearer ${kakaoAccessToken}`
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
if (!userRes.ok) {
|
|
40
|
+
throw new Error("\uC720\uC800 \uC815\uBCF4\uB97C \uAC00\uC838\uC624\uB294\uB370 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4.");
|
|
41
|
+
}
|
|
42
|
+
const { id, kakao_account } = await userRes.json();
|
|
43
|
+
const { email, profile } = kakao_account;
|
|
44
|
+
const payload = {
|
|
45
|
+
id,
|
|
46
|
+
email,
|
|
47
|
+
name: profile.nickname,
|
|
48
|
+
picture: profile.thumbnail_image_url
|
|
49
|
+
};
|
|
50
|
+
return this.thirdpartyAuth.issueTokensIfUserFound("kakao", payload);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
+
0 && (module.exports = {
|
|
55
|
+
KakaoAuth
|
|
56
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/auth/kakao_auth.ts
|
|
2
|
+
var KakaoAuth = class {
|
|
3
|
+
thirdpartyAuth;
|
|
4
|
+
constructor({
|
|
5
|
+
thirdpartyAuth
|
|
6
|
+
}) {
|
|
7
|
+
this.thirdpartyAuth = thirdpartyAuth;
|
|
8
|
+
}
|
|
9
|
+
async login(kakaoAccessToken) {
|
|
10
|
+
const userRes = await fetch("https://kapi.kakao.com/v2/user/me", {
|
|
11
|
+
headers: {
|
|
12
|
+
Authorization: `Bearer ${kakaoAccessToken}`
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
if (!userRes.ok) {
|
|
16
|
+
throw new Error("\uC720\uC800 \uC815\uBCF4\uB97C \uAC00\uC838\uC624\uB294\uB370 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4.");
|
|
17
|
+
}
|
|
18
|
+
const { id, kakao_account } = await userRes.json();
|
|
19
|
+
const { email, profile } = kakao_account;
|
|
20
|
+
const payload = {
|
|
21
|
+
id,
|
|
22
|
+
email,
|
|
23
|
+
name: profile.nickname,
|
|
24
|
+
picture: profile.thumbnail_image_url
|
|
25
|
+
};
|
|
26
|
+
return this.thirdpartyAuth.issueTokensIfUserFound("kakao", payload);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
KakaoAuth
|
|
31
|
+
};
|
|
@@ -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 };
|