dn-react-router-toolkit 0.1.1 → 0.1.3
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-kit/apple_auth.d.mts +24 -0
- package/dist/{esm/auth-kit → auth-kit}/apple_auth.d.ts +11 -2
- package/dist/auth-kit/apple_auth.js +75 -0
- package/dist/auth-kit/apple_auth.mjs +50 -0
- package/dist/auth-kit/auth_service.d.mts +73 -0
- package/dist/{esm/auth-kit → auth-kit}/auth_service.d.ts +17 -11
- package/dist/auth-kit/auth_service.js +257 -0
- package/dist/auth-kit/auth_service.mjs +218 -0
- package/dist/auth-kit/client/google_login_button.d.mts +9 -0
- package/dist/auth-kit/client/google_login_button.d.ts +9 -0
- package/dist/auth-kit/client/google_login_button.js +67 -0
- package/dist/auth-kit/client/google_login_button.mjs +32 -0
- package/dist/auth-kit/client/redirect_page.d.mts +5 -0
- package/dist/auth-kit/client/redirect_page.d.ts +5 -0
- package/dist/auth-kit/client/redirect_page.js +53 -0
- package/dist/auth-kit/client/redirect_page.mjs +18 -0
- package/dist/auth-kit/google_auth.d.mts +27 -0
- package/dist/{esm/auth-kit → auth-kit}/google_auth.d.ts +11 -2
- package/dist/auth-kit/google_auth.js +144 -0
- package/dist/auth-kit/google_auth.mjs +117 -0
- package/dist/auth-kit/jwt.d.mts +18 -0
- package/dist/{esm/auth-kit → auth-kit}/jwt.d.ts +5 -2
- package/dist/auth-kit/jwt.js +76 -0
- package/dist/auth-kit/jwt.mjs +51 -0
- package/dist/auth-kit/kakao_auth.d.mts +24 -0
- package/dist/{esm/auth-kit → auth-kit}/kakao_auth.d.ts +11 -2
- package/dist/auth-kit/kakao_auth.js +115 -0
- package/dist/auth-kit/kakao_auth.mjs +88 -0
- package/dist/auth-kit/repository.d.mts +42 -0
- package/dist/{esm/auth-kit → auth-kit}/repository.d.ts +3 -1
- package/dist/auth-kit/repository.js +18 -0
- package/dist/auth-kit/repository.mjs +0 -0
- package/dist/auth-kit/with_auth.d.mts +17 -0
- package/dist/auth-kit/with_auth.d.ts +17 -0
- package/dist/auth-kit/with_auth.js +106 -0
- package/dist/auth-kit/with_auth.mjs +69 -0
- package/dist/cn.d.mts +3 -0
- package/dist/cn.d.ts +3 -0
- package/dist/cn.js +32 -0
- package/dist/cn.mjs +7 -0
- package/dist/components/index.d.mts +5 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.js +261 -0
- package/dist/components/index.mjs +219 -0
- package/dist/components/modal/fullscreen_container.d.mts +7 -0
- package/dist/components/modal/fullscreen_container.d.ts +7 -0
- package/dist/components/modal/fullscreen_container.js +102 -0
- package/dist/components/modal/fullscreen_container.mjs +68 -0
- package/dist/components/modal/hooks.d.mts +18 -0
- package/dist/components/modal/hooks.d.ts +18 -0
- package/dist/components/modal/hooks.js +236 -0
- package/dist/components/modal/hooks.mjs +204 -0
- package/dist/components/modal/index.d.mts +4 -0
- package/dist/components/modal/index.d.ts +4 -0
- package/dist/components/modal/index.js +238 -0
- package/dist/components/modal/index.mjs +203 -0
- package/dist/components/modal/modal.d.mts +13 -0
- package/dist/components/modal/modal.d.ts +13 -0
- package/dist/components/modal/modal.js +155 -0
- package/dist/components/modal/modal.mjs +130 -0
- package/dist/components/styles.d.mts +9 -0
- package/dist/components/styles.d.ts +9 -0
- package/dist/components/styles.js +48 -0
- package/dist/components/styles.mjs +17 -0
- package/dist/date.d.mts +3 -0
- package/dist/date.d.ts +3 -0
- package/dist/date.js +63 -0
- package/dist/date.mjs +28 -0
- package/dist/file-kit/cdn.d.mts +5 -0
- package/dist/file-kit/cdn.d.ts +5 -0
- package/dist/file-kit/cdn.js +34 -0
- package/dist/file-kit/cdn.mjs +9 -0
- package/dist/file-kit/client/drop_file_input.d.mts +33 -0
- package/dist/{esm/file-kit → file-kit}/client/drop_file_input.d.ts +10 -8
- package/dist/file-kit/client/drop_file_input.js +235 -0
- package/dist/file-kit/client/drop_file_input.mjs +205 -0
- package/dist/file-kit/client/file_uploader.d.mts +13 -0
- package/dist/{esm/file-kit → file-kit}/client/file_uploader.d.ts +4 -2
- package/dist/file-kit/client/file_uploader.js +115 -0
- package/dist/file-kit/client/file_uploader.mjs +90 -0
- package/dist/file-kit/file_service.d.mts +26 -0
- package/dist/{esm/file-kit → file-kit}/file_service.d.ts +7 -4
- package/dist/file-kit/file_service.js +60 -0
- package/dist/file-kit/file_service.mjs +35 -0
- package/dist/file-kit/object_storage.d.mts +17 -0
- package/dist/{esm/file-kit → file-kit}/object_storage.d.ts +6 -2
- package/dist/file-kit/object_storage.js +78 -0
- package/dist/file-kit/object_storage.mjs +57 -0
- package/dist/file-kit/repository.d.mts +16 -0
- package/dist/{esm/file-kit → file-kit}/repository.d.ts +3 -1
- package/dist/file-kit/repository.js +18 -0
- package/dist/file-kit/repository.mjs +0 -0
- package/dist/file-kit/responsive_image.d.mts +20 -0
- package/dist/file-kit/responsive_image.d.ts +20 -0
- package/dist/file-kit/responsive_image.js +123 -0
- package/dist/file-kit/responsive_image.mjs +87 -0
- package/dist/http-kit/index.d.mts +1 -0
- package/dist/http-kit/index.d.ts +1 -0
- package/dist/http-kit/index.js +111 -0
- package/dist/http-kit/index.mjs +68 -0
- package/dist/http-kit/response.d.mts +19 -0
- package/dist/http-kit/response.d.ts +19 -0
- package/dist/http-kit/response.js +109 -0
- package/dist/http-kit/response.mjs +68 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +91 -0
- package/dist/index.mjs +51 -0
- package/dist/route/api/auth/login/[provider]/route.js +113 -0
- package/dist/route/api/auth/login/[provider]/route.mjs +86 -0
- package/dist/route/api/auth/login/_provider_/route.d.mts +20 -0
- package/dist/route/api/auth/login/_provider_/route.d.ts +20 -0
- package/dist/route/api/auth/login/route.d.mts +14 -0
- package/dist/route/api/auth/login/route.d.ts +14 -0
- package/dist/route/api/auth/login/route.js +107 -0
- package/dist/route/api/auth/login/route.mjs +80 -0
- package/dist/route/api/auth/logout/route.d.mts +14 -0
- package/dist/route/api/auth/logout/route.d.ts +14 -0
- package/dist/route/api/auth/logout/route.js +98 -0
- package/dist/route/api/auth/logout/route.mjs +71 -0
- package/dist/route/api/auth/refresh/route.d.mts +13 -0
- package/dist/route/api/auth/refresh/route.d.ts +13 -0
- package/dist/route/api/auth/refresh/route.js +92 -0
- package/dist/route/api/auth/refresh/route.mjs +65 -0
- package/dist/route/api/auth/route.d.mts +13 -0
- package/dist/route/api/auth/route.d.ts +13 -0
- package/dist/route/api/auth/route.js +82 -0
- package/dist/route/api/auth/route.mjs +55 -0
- package/dist/route/api/files/[fileId]/route.js +99 -0
- package/dist/route/api/files/[fileId]/route.mjs +72 -0
- package/dist/route/api/files/_fileId_/route.d.mts +17 -0
- package/dist/route/api/files/_fileId_/route.d.ts +17 -0
- package/dist/route/api/files/route.d.mts +16 -0
- package/dist/route/api/files/route.d.ts +16 -0
- package/dist/route/api/files/route.js +106 -0
- package/dist/route/api/files/route.mjs +79 -0
- package/dist/route/api.d.mts +29 -0
- package/dist/route/api.d.ts +29 -0
- package/dist/route/api.js +395 -0
- package/dist/route/api.mjs +368 -0
- package/dist/route/auth/callback/[provider]/route.js +120 -0
- package/dist/route/auth/callback/[provider]/route.mjs +93 -0
- package/dist/route/auth/callback/_provider_/route.d.mts +20 -0
- package/dist/route/auth/callback/_provider_/route.d.ts +20 -0
- package/dist/seo-kit/index.d.mts +6 -0
- package/dist/seo-kit/index.d.ts +6 -0
- package/dist/seo-kit/index.js +321 -0
- package/dist/seo-kit/index.mjs +282 -0
- package/dist/seo-kit/loader.d.mts +7 -0
- package/dist/seo-kit/loader.d.ts +7 -0
- package/dist/seo-kit/loader.js +43 -0
- package/dist/seo-kit/loader.mjs +18 -0
- package/dist/seo-kit/seo.d.mts +103 -0
- package/dist/{esm/seo-kit → seo-kit}/seo.d.ts +10 -6
- package/dist/seo-kit/seo.js +286 -0
- package/dist/seo-kit/seo.mjs +251 -0
- package/dist/seo-kit/seo_loader.d.mts +16 -0
- package/dist/seo-kit/seo_loader.d.ts +16 -0
- package/dist/seo-kit/seo_loader.js +68 -0
- package/dist/seo-kit/seo_loader.mjs +31 -0
- package/dist/singleton.d.mts +3 -0
- package/dist/singleton.d.ts +3 -0
- package/dist/singleton.js +37 -0
- package/dist/singleton.mjs +12 -0
- package/dist/slug.d.mts +3 -0
- package/dist/slug.d.ts +3 -0
- package/dist/slug.js +32 -0
- package/dist/slug.mjs +7 -0
- package/package.json +36 -34
- package/tsup.config.ts +9 -0
- package/dist/cjs/auth-kit/apple_auth.js +0 -61
- package/dist/cjs/auth-kit/auth_service.js +0 -204
- package/dist/cjs/auth-kit/client/google_login_button.js +0 -19
- package/dist/cjs/auth-kit/client/redirect_page.js +0 -18
- package/dist/cjs/auth-kit/google_auth.js +0 -69
- package/dist/cjs/auth-kit/jwt.js +0 -54
- package/dist/cjs/auth-kit/kakao_auth.js +0 -43
- package/dist/cjs/auth-kit/repository.js +0 -2
- package/dist/cjs/auth-kit/with_auth.js +0 -46
- package/dist/cjs/cn.js +0 -6
- package/dist/cjs/components/index.js +0 -18
- package/dist/cjs/components/modal/fullscreen_container.js +0 -49
- package/dist/cjs/components/modal/hooks.js +0 -76
- package/dist/cjs/components/modal/index.js +0 -19
- package/dist/cjs/components/modal/modal.js +0 -79
- package/dist/cjs/components/styles.js +0 -10
- package/dist/cjs/date.js +0 -31
- package/dist/cjs/file-kit/cdn.js +0 -9
- package/dist/cjs/file-kit/client/drop_file_input.js +0 -148
- package/dist/cjs/file-kit/client/file_uploader.js +0 -88
- package/dist/cjs/file-kit/file_service.js +0 -32
- package/dist/cjs/file-kit/object_storage.js +0 -51
- package/dist/cjs/file-kit/repository.js +0 -2
- package/dist/cjs/file-kit/responsive_image.js +0 -63
- package/dist/cjs/http-kit/index.js +0 -17
- package/dist/cjs/http-kit/response.js +0 -37
- package/dist/cjs/index.js +0 -20
- package/dist/cjs/route/api/auth/login/[provider]/route.js +0 -36
- package/dist/cjs/route/api/auth/login/route.js +0 -35
- package/dist/cjs/route/api/auth/logout/route.js +0 -22
- package/dist/cjs/route/api/auth/refresh/route.js +0 -22
- package/dist/cjs/route/api/auth/route.js +0 -12
- package/dist/cjs/route/api/files/[fileId]/route.js +0 -20
- package/dist/cjs/route/api/files/route.js +0 -34
- package/dist/cjs/route/auth/callback/[provider]/route.js +0 -38
- package/dist/cjs/route/index.js +0 -80
- package/dist/cjs/seo-kit/index.js +0 -19
- package/dist/cjs/seo-kit/loader.js +0 -17
- package/dist/cjs/seo-kit/seo.js +0 -278
- package/dist/cjs/seo-kit/seo_loader.js +0 -15
- package/dist/cjs/singleton.js +0 -12
- package/dist/cjs/slug.js +0 -10
- package/dist/esm/auth-kit/apple_auth.js +0 -57
- package/dist/esm/auth-kit/auth_service.js +0 -197
- package/dist/esm/auth-kit/client/google_login_button.d.ts +0 -5
- package/dist/esm/auth-kit/client/google_login_button.js +0 -16
- package/dist/esm/auth-kit/client/redirect_page.d.ts +0 -1
- package/dist/esm/auth-kit/client/redirect_page.js +0 -15
- package/dist/esm/auth-kit/google_auth.js +0 -65
- package/dist/esm/auth-kit/jwt.js +0 -50
- package/dist/esm/auth-kit/kakao_auth.js +0 -39
- package/dist/esm/auth-kit/repository.js +0 -1
- package/dist/esm/auth-kit/with_auth.d.ts +0 -12
- package/dist/esm/auth-kit/with_auth.js +0 -43
- package/dist/esm/cn.d.ts +0 -1
- package/dist/esm/cn.js +0 -3
- package/dist/esm/components/index.d.ts +0 -2
- package/dist/esm/components/index.js +0 -2
- package/dist/esm/components/modal/fullscreen_container.d.ts +0 -5
- package/dist/esm/components/modal/fullscreen_container.js +0 -45
- package/dist/esm/components/modal/hooks.d.ts +0 -15
- package/dist/esm/components/modal/hooks.js +0 -67
- package/dist/esm/components/modal/index.d.ts +0 -3
- package/dist/esm/components/modal/index.js +0 -3
- package/dist/esm/components/modal/modal.d.ts +0 -10
- package/dist/esm/components/modal/modal.js +0 -43
- package/dist/esm/components/styles.d.ts +0 -7
- package/dist/esm/components/styles.js +0 -7
- package/dist/esm/date.d.ts +0 -1
- package/dist/esm/date.js +0 -24
- package/dist/esm/file-kit/cdn.d.ts +0 -3
- package/dist/esm/file-kit/cdn.js +0 -5
- package/dist/esm/file-kit/client/drop_file_input.js +0 -144
- package/dist/esm/file-kit/client/file_uploader.js +0 -84
- package/dist/esm/file-kit/file_service.js +0 -28
- package/dist/esm/file-kit/object_storage.js +0 -47
- package/dist/esm/file-kit/repository.js +0 -1
- package/dist/esm/file-kit/responsive_image.d.ts +0 -17
- package/dist/esm/file-kit/responsive_image.js +0 -58
- package/dist/esm/http-kit/index.d.ts +0 -1
- package/dist/esm/http-kit/index.js +0 -1
- package/dist/esm/http-kit/response.d.ts +0 -17
- package/dist/esm/http-kit/response.js +0 -31
- package/dist/esm/index.d.ts +0 -4
- package/dist/esm/index.js +0 -4
- package/dist/esm/route/api/auth/login/[provider]/route.d.ts +0 -10
- package/dist/esm/route/api/auth/login/[provider]/route.js +0 -32
- package/dist/esm/route/api/auth/login/route.d.ts +0 -6
- package/dist/esm/route/api/auth/login/route.js +0 -31
- package/dist/esm/route/api/auth/logout/route.d.ts +0 -6
- package/dist/esm/route/api/auth/logout/route.js +0 -18
- package/dist/esm/route/api/auth/refresh/route.d.ts +0 -4
- package/dist/esm/route/api/auth/refresh/route.js +0 -18
- package/dist/esm/route/api/auth/route.d.ts +0 -4
- package/dist/esm/route/api/auth/route.js +0 -8
- package/dist/esm/route/api/files/[fileId]/route.d.ts +0 -8
- package/dist/esm/route/api/files/[fileId]/route.js +0 -16
- package/dist/esm/route/api/files/route.d.ts +0 -6
- package/dist/esm/route/api/files/route.js +0 -30
- package/dist/esm/route/auth/callback/[provider]/route.d.ts +0 -11
- package/dist/esm/route/auth/callback/[provider]/route.js +0 -34
- package/dist/esm/route/index.d.ts +0 -22
- package/dist/esm/route/index.js +0 -76
- package/dist/esm/seo-kit/index.d.ts +0 -3
- package/dist/esm/seo-kit/index.js +0 -3
- package/dist/esm/seo-kit/loader.d.ts +0 -5
- package/dist/esm/seo-kit/loader.js +0 -14
- package/dist/esm/seo-kit/seo.js +0 -275
- package/dist/esm/seo-kit/seo_loader.d.ts +0 -12
- package/dist/esm/seo-kit/seo_loader.js +0 -12
- package/dist/esm/singleton.d.ts +0 -1
- package/dist/esm/singleton.js +0 -9
- package/dist/esm/slug.d.ts +0 -1
- package/dist/esm/slug.js +0 -6
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AuthService } from '../auth-kit/auth_service.mjs';
|
|
2
|
+
import { GoogleAuth } from '../auth-kit/google_auth.mjs';
|
|
3
|
+
import { AppleAuth } from '../auth-kit/apple_auth.mjs';
|
|
4
|
+
import { FileRepository } from '../file-kit/repository.mjs';
|
|
5
|
+
import { FileService } from '../file-kit/file_service.mjs';
|
|
6
|
+
import { JWTManager } from '../auth-kit/jwt.mjs';
|
|
7
|
+
import { AuthRepository } from '../auth-kit/repository.mjs';
|
|
8
|
+
import { KakaoAuth } from '../auth-kit/kakao_auth.mjs';
|
|
9
|
+
import 'jose';
|
|
10
|
+
import 'react-router';
|
|
11
|
+
import '../file-kit/object_storage.mjs';
|
|
12
|
+
import '@aws-sdk/client-s3';
|
|
13
|
+
|
|
14
|
+
declare const createAuthAPIHandler: <TFile>({ AUTH, GOOGLE_AUTH, APPLE_AUTH, KAKAO_AUTH, JWT_MANAGER, FILE_SERVICE, SITE_ORIGIN, authRepository, fileRepository, }: {
|
|
15
|
+
SITE_ORIGIN: string;
|
|
16
|
+
JWT_MANAGER: JWTManager;
|
|
17
|
+
AUTH: AuthService;
|
|
18
|
+
GOOGLE_AUTH: GoogleAuth;
|
|
19
|
+
APPLE_AUTH: AppleAuth;
|
|
20
|
+
KAKAO_AUTH: KakaoAuth;
|
|
21
|
+
FILE_SERVICE: FileService<TFile>;
|
|
22
|
+
authRepository: AuthRepository;
|
|
23
|
+
fileRepository: FileRepository<TFile>;
|
|
24
|
+
}) => ({ request, params, }: {
|
|
25
|
+
request: Request;
|
|
26
|
+
params: any;
|
|
27
|
+
}) => Promise<Response>;
|
|
28
|
+
|
|
29
|
+
export { createAuthAPIHandler };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AuthService } from '../auth-kit/auth_service.js';
|
|
2
|
+
import { GoogleAuth } from '../auth-kit/google_auth.js';
|
|
3
|
+
import { AppleAuth } from '../auth-kit/apple_auth.js';
|
|
4
|
+
import { FileRepository } from '../file-kit/repository.js';
|
|
5
|
+
import { FileService } from '../file-kit/file_service.js';
|
|
6
|
+
import { JWTManager } from '../auth-kit/jwt.js';
|
|
7
|
+
import { AuthRepository } from '../auth-kit/repository.js';
|
|
8
|
+
import { KakaoAuth } from '../auth-kit/kakao_auth.js';
|
|
9
|
+
import 'jose';
|
|
10
|
+
import 'react-router';
|
|
11
|
+
import '../file-kit/object_storage.js';
|
|
12
|
+
import '@aws-sdk/client-s3';
|
|
13
|
+
|
|
14
|
+
declare const createAuthAPIHandler: <TFile>({ AUTH, GOOGLE_AUTH, APPLE_AUTH, KAKAO_AUTH, JWT_MANAGER, FILE_SERVICE, SITE_ORIGIN, authRepository, fileRepository, }: {
|
|
15
|
+
SITE_ORIGIN: string;
|
|
16
|
+
JWT_MANAGER: JWTManager;
|
|
17
|
+
AUTH: AuthService;
|
|
18
|
+
GOOGLE_AUTH: GoogleAuth;
|
|
19
|
+
APPLE_AUTH: AppleAuth;
|
|
20
|
+
KAKAO_AUTH: KakaoAuth;
|
|
21
|
+
FILE_SERVICE: FileService<TFile>;
|
|
22
|
+
authRepository: AuthRepository;
|
|
23
|
+
fileRepository: FileRepository<TFile>;
|
|
24
|
+
}) => ({ request, params, }: {
|
|
25
|
+
request: Request;
|
|
26
|
+
params: any;
|
|
27
|
+
}) => Promise<Response>;
|
|
28
|
+
|
|
29
|
+
export { createAuthAPIHandler };
|
|
@@ -0,0 +1,395 @@
|
|
|
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/route/api.ts
|
|
21
|
+
var api_exports = {};
|
|
22
|
+
__export(api_exports, {
|
|
23
|
+
createAuthAPIHandler: () => createAuthAPIHandler
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(api_exports);
|
|
26
|
+
|
|
27
|
+
// src/http-kit/response.ts
|
|
28
|
+
var createJsonResponse = (status) => {
|
|
29
|
+
return (data = {}, init) => {
|
|
30
|
+
return Response.json(data, { status, ...init });
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
var OK = createJsonResponse(200);
|
|
34
|
+
var CREATED = createJsonResponse(201);
|
|
35
|
+
var ACCEPTED = createJsonResponse(202);
|
|
36
|
+
var NO_CONTENT = (init) => {
|
|
37
|
+
return new Response(null, {
|
|
38
|
+
...init,
|
|
39
|
+
status: 204
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
var createException = (status, defaultMessage = "\uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4.") => {
|
|
43
|
+
return (message = defaultMessage, init) => {
|
|
44
|
+
return createJsonResponse(status)({ message }, init);
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
var BAD_REQUEST = createException(400, "\uC694\uCCAD\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.");
|
|
48
|
+
var UNAUTHORIZED = createException(401, "\uC778\uC99D\uC774 \uD544\uC694\uD569\uB2C8\uB2E4.");
|
|
49
|
+
var FORBIDDEN = createException(403, "\uAD8C\uD55C\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
50
|
+
var NOT_FOUND = createException(
|
|
51
|
+
404,
|
|
52
|
+
"\uC694\uCCAD\uD55C \uB9AC\uC18C\uC2A4\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."
|
|
53
|
+
);
|
|
54
|
+
var METHOD_NOT_ALLOWED = createException(
|
|
55
|
+
405,
|
|
56
|
+
"\uBA54\uC11C\uB4DC\uB97C \uC0AC\uC6A9\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."
|
|
57
|
+
);
|
|
58
|
+
var NOT_ACCEPTABLE = createException(
|
|
59
|
+
406,
|
|
60
|
+
"\uC694\uCCAD\uD55C \uD615\uC2DD\uC744 \uC0AC\uC6A9\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."
|
|
61
|
+
);
|
|
62
|
+
var REQUEST_TIMEOUT = createException(
|
|
63
|
+
408,
|
|
64
|
+
"\uC694\uCCAD \uC2DC\uAC04\uC774 \uCD08\uACFC\uB418\uC5C8\uC2B5\uB2C8\uB2E4."
|
|
65
|
+
);
|
|
66
|
+
var CONFLICT = createException(409, "\uC694\uCCAD\uC774 \uCDA9\uB3CC\uD588\uC2B5\uB2C8\uB2E4.");
|
|
67
|
+
var UNPROCESSABLE_ENTITY = createException(
|
|
68
|
+
422,
|
|
69
|
+
"\uCC98\uB9AC\uD560 \uC218 \uC5C6\uB294 \uC5D4\uD2F0\uD2F0\uC785\uB2C8\uB2E4."
|
|
70
|
+
);
|
|
71
|
+
var TOO_MANY_REQUESTS = createException(429, "\uC694\uCCAD\uC774 \uB108\uBB34 \uB9CE\uC2B5\uB2C8\uB2E4.");
|
|
72
|
+
var INTERNAL_SERVER_ERROR = createException(
|
|
73
|
+
500,
|
|
74
|
+
"\uC608\uAE30\uCE58 \uBABB\uD55C \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
// src/route/auth/callback/[provider]/route.tsx
|
|
78
|
+
var thirdPartyAuthCallbackHandler = async (request, {
|
|
79
|
+
provider
|
|
80
|
+
}, {
|
|
81
|
+
AUTH,
|
|
82
|
+
GOOGLE_AUTH,
|
|
83
|
+
APPLE_AUTH,
|
|
84
|
+
SITE_ORIGIN
|
|
85
|
+
}) => {
|
|
86
|
+
const url = new URL(request.url);
|
|
87
|
+
const code = url.searchParams.get("code");
|
|
88
|
+
if (!code) {
|
|
89
|
+
throw BAD_REQUEST("\uCF54\uB4DC\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
90
|
+
}
|
|
91
|
+
const getThirdPartyAuth = (provider2) => {
|
|
92
|
+
switch (provider2) {
|
|
93
|
+
case "google":
|
|
94
|
+
return GOOGLE_AUTH;
|
|
95
|
+
case "apple":
|
|
96
|
+
return APPLE_AUTH;
|
|
97
|
+
default:
|
|
98
|
+
throw BAD_REQUEST("\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC778\uC99D \uC81C\uACF5\uC790\uC785\uB2C8\uB2E4.");
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const { accessToken, refreshToken } = await getThirdPartyAuth(
|
|
102
|
+
provider
|
|
103
|
+
).signIn(code);
|
|
104
|
+
const [accessTokenSetCookie, refreshTokenSetCookie] = await Promise.all([
|
|
105
|
+
AUTH.getAccessTokenSetCookie(accessToken),
|
|
106
|
+
AUTH.getRefreshTokenSetCookie(refreshToken)
|
|
107
|
+
]);
|
|
108
|
+
const headers = new Headers();
|
|
109
|
+
headers.append("Set-Cookie", accessTokenSetCookie);
|
|
110
|
+
headers.append("Set-Cookie", refreshTokenSetCookie);
|
|
111
|
+
const redirectUrl = url.searchParams.get("state") || SITE_ORIGIN;
|
|
112
|
+
return new Response("Temporary Redirect", {
|
|
113
|
+
status: 307,
|
|
114
|
+
headers: {
|
|
115
|
+
...headers,
|
|
116
|
+
Location: new URL(
|
|
117
|
+
`/r?redirectUrl=${encodeURIComponent(redirectUrl)}`,
|
|
118
|
+
request.url
|
|
119
|
+
).toString()
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// src/route/api/files/route.ts
|
|
125
|
+
var fileUploadHandler = async (request, {
|
|
126
|
+
AUTH,
|
|
127
|
+
FILE_SERVICE
|
|
128
|
+
}) => {
|
|
129
|
+
const auth = await AUTH.verifyOrRefresh(request);
|
|
130
|
+
const { name, type, size, metadata } = await request.json();
|
|
131
|
+
const headers = {
|
|
132
|
+
"Access-Control-Allow-Origin": "*"
|
|
133
|
+
};
|
|
134
|
+
if (typeof name !== "string") {
|
|
135
|
+
return BAD_REQUEST("\uD30C\uC77C \uC774\uB984\uC774 \uD544\uC694\uD574\uC694.", { headers });
|
|
136
|
+
}
|
|
137
|
+
if (typeof type !== "string") {
|
|
138
|
+
return BAD_REQUEST("\uD30C\uC77C \uD0C0\uC785\uC774 \uD544\uC694\uD574\uC694.", { headers });
|
|
139
|
+
}
|
|
140
|
+
try {
|
|
141
|
+
const result = await FILE_SERVICE.generateSignedUrl({
|
|
142
|
+
userId: auth?.userId,
|
|
143
|
+
name,
|
|
144
|
+
type,
|
|
145
|
+
size,
|
|
146
|
+
metadata
|
|
147
|
+
});
|
|
148
|
+
return CREATED(result, { headers });
|
|
149
|
+
} catch (e) {
|
|
150
|
+
if (e instanceof Error) {
|
|
151
|
+
return INTERNAL_SERVER_ERROR(e.message, { headers });
|
|
152
|
+
}
|
|
153
|
+
return INTERNAL_SERVER_ERROR(e, { headers });
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
// src/route/api/files/[fileId]/route.ts
|
|
158
|
+
var fileDeleteHandler = async (request, { fileId }, {
|
|
159
|
+
AUTH,
|
|
160
|
+
repository
|
|
161
|
+
}) => {
|
|
162
|
+
const auth = await AUTH.verifyOrRefresh(request);
|
|
163
|
+
const file = await repository.findFileById(fileId);
|
|
164
|
+
const headers = {
|
|
165
|
+
"Access-Control-Allow-Origin": "*"
|
|
166
|
+
};
|
|
167
|
+
if (!file) {
|
|
168
|
+
return NOT_FOUND("\uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.", { headers });
|
|
169
|
+
}
|
|
170
|
+
if (!repository.hasPermission(file, auth?.userId)) {
|
|
171
|
+
return FORBIDDEN("\uD30C\uC77C\uC744 \uC0AD\uC81C\uD560 \uAD8C\uD55C\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.", { headers });
|
|
172
|
+
}
|
|
173
|
+
await repository.deleteFile(fileId);
|
|
174
|
+
return NO_CONTENT({ headers });
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
// src/route/api/auth/route.ts
|
|
178
|
+
var getAuthHandler = async (request, { AUTH }) => {
|
|
179
|
+
const auth = await AUTH.verifyOrRefresh(request);
|
|
180
|
+
if (!auth) {
|
|
181
|
+
return UNAUTHORIZED();
|
|
182
|
+
}
|
|
183
|
+
return OK(auth);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
// src/route/api/auth/login/[provider]/route.ts
|
|
187
|
+
var loginThirdPartyHandler = async (request, {
|
|
188
|
+
provider
|
|
189
|
+
}, {
|
|
190
|
+
GOOGLE_AUTH,
|
|
191
|
+
APPLE_AUTH,
|
|
192
|
+
KAKAO_AUTH
|
|
193
|
+
}) => {
|
|
194
|
+
const { code } = await request.json();
|
|
195
|
+
if (!code) {
|
|
196
|
+
return BAD_REQUEST("\uCF54\uB4DC\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
197
|
+
}
|
|
198
|
+
const getThirdPartyAuth = (provider2) => {
|
|
199
|
+
switch (provider2) {
|
|
200
|
+
case "google":
|
|
201
|
+
return GOOGLE_AUTH;
|
|
202
|
+
case "apple":
|
|
203
|
+
return APPLE_AUTH;
|
|
204
|
+
case "kakao":
|
|
205
|
+
return KAKAO_AUTH;
|
|
206
|
+
default:
|
|
207
|
+
throw BAD_REQUEST("\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC778\uC99D \uC81C\uACF5\uC790\uC785\uB2C8\uB2E4.");
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
try {
|
|
211
|
+
const { accessToken, refreshToken } = await getThirdPartyAuth(
|
|
212
|
+
provider
|
|
213
|
+
).signIn(code);
|
|
214
|
+
return CREATED({
|
|
215
|
+
accessToken,
|
|
216
|
+
refreshToken
|
|
217
|
+
});
|
|
218
|
+
} catch (error) {
|
|
219
|
+
if (error instanceof Response) {
|
|
220
|
+
return error;
|
|
221
|
+
}
|
|
222
|
+
throw INTERNAL_SERVER_ERROR();
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
// src/route/api/auth/login/route.ts
|
|
227
|
+
var loginCredentialHandler = async (request, {
|
|
228
|
+
AUTH,
|
|
229
|
+
JWT_MANAGER
|
|
230
|
+
}) => {
|
|
231
|
+
const searchParams = new URL(request.url).searchParams;
|
|
232
|
+
const { id, password } = await request.json();
|
|
233
|
+
try {
|
|
234
|
+
const { accessToken, refreshToken } = await AUTH.signIn({
|
|
235
|
+
id,
|
|
236
|
+
password
|
|
237
|
+
});
|
|
238
|
+
if (searchParams.get("type") === "json") {
|
|
239
|
+
return CREATED({ accessToken, refreshToken });
|
|
240
|
+
}
|
|
241
|
+
const [accessTokenSetCookie, refreshTokenSetCookie] = await Promise.all([
|
|
242
|
+
AUTH.getAccessTokenSetCookie(accessToken),
|
|
243
|
+
AUTH.getRefreshTokenSetCookie(refreshToken)
|
|
244
|
+
]);
|
|
245
|
+
const payload = JWT_MANAGER.decode(accessToken);
|
|
246
|
+
const headers = new Headers();
|
|
247
|
+
headers.append("Set-Cookie", accessTokenSetCookie);
|
|
248
|
+
headers.append("Set-Cookie", refreshTokenSetCookie);
|
|
249
|
+
return CREATED(payload, {
|
|
250
|
+
headers
|
|
251
|
+
});
|
|
252
|
+
} catch (e) {
|
|
253
|
+
if (e instanceof Error) {
|
|
254
|
+
return UNAUTHORIZED(e.message);
|
|
255
|
+
}
|
|
256
|
+
throw e;
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
// src/route/api/auth/logout/route.ts
|
|
261
|
+
var logoutHandler = async (request, { AUTH, repository }) => {
|
|
262
|
+
const auth = await AUTH.verifyOrRefresh(request);
|
|
263
|
+
if (!auth) {
|
|
264
|
+
return UNAUTHORIZED();
|
|
265
|
+
}
|
|
266
|
+
await repository.updateUserRefreshToken(auth.userId, null);
|
|
267
|
+
const headers = new Headers();
|
|
268
|
+
const [accessTokenSetCookie, refreshTokenSetCookie] = await Promise.all([
|
|
269
|
+
AUTH.getAccessTokenSetCookie(null),
|
|
270
|
+
AUTH.getRefreshTokenSetCookie(null)
|
|
271
|
+
]);
|
|
272
|
+
headers.append("Set-Cookie", accessTokenSetCookie);
|
|
273
|
+
headers.append("Set-Cookie", refreshTokenSetCookie);
|
|
274
|
+
return NO_CONTENT({
|
|
275
|
+
headers
|
|
276
|
+
});
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
// src/route/api/auth/refresh/route.ts
|
|
280
|
+
var authRefreshHandler = async (request, {
|
|
281
|
+
AUTH
|
|
282
|
+
}) => {
|
|
283
|
+
const refreshToken = request?.headers.get("Authorization")?.replace("Bearer ", "") || await AUTH.getRefreshTokenFromCookies(request);
|
|
284
|
+
if (!refreshToken) {
|
|
285
|
+
return BAD_REQUEST();
|
|
286
|
+
}
|
|
287
|
+
try {
|
|
288
|
+
const accessToken = await AUTH.refreshAccessToken(refreshToken);
|
|
289
|
+
return CREATED({ accessToken });
|
|
290
|
+
} catch (e) {
|
|
291
|
+
if (e instanceof Error) {
|
|
292
|
+
return UNAUTHORIZED(e.message);
|
|
293
|
+
}
|
|
294
|
+
throw e;
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
// src/route/api.ts
|
|
299
|
+
var createAuthAPIHandler = ({
|
|
300
|
+
AUTH,
|
|
301
|
+
GOOGLE_AUTH,
|
|
302
|
+
APPLE_AUTH,
|
|
303
|
+
KAKAO_AUTH,
|
|
304
|
+
JWT_MANAGER,
|
|
305
|
+
FILE_SERVICE,
|
|
306
|
+
SITE_ORIGIN,
|
|
307
|
+
authRepository,
|
|
308
|
+
fileRepository
|
|
309
|
+
}) => {
|
|
310
|
+
const handler = async ({
|
|
311
|
+
request,
|
|
312
|
+
params
|
|
313
|
+
}) => {
|
|
314
|
+
const method = request.method.toUpperCase();
|
|
315
|
+
const slug = params["*"].split("/");
|
|
316
|
+
if (slug[0] === "auth") {
|
|
317
|
+
if (!slug[1]) {
|
|
318
|
+
if (method === "GET") {
|
|
319
|
+
return getAuthHandler(request, { AUTH });
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
if (slug[1] === "login") {
|
|
323
|
+
if (slug[2]) {
|
|
324
|
+
const provider = slug[2];
|
|
325
|
+
if (method === "POST") {
|
|
326
|
+
return loginThirdPartyHandler(
|
|
327
|
+
request,
|
|
328
|
+
{ provider },
|
|
329
|
+
{ GOOGLE_AUTH, KAKAO_AUTH, APPLE_AUTH }
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
if (method === "POST") {
|
|
334
|
+
return loginCredentialHandler(request, {
|
|
335
|
+
AUTH,
|
|
336
|
+
JWT_MANAGER
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
if (slug[1] === "logout") {
|
|
341
|
+
if (method === "POST") {
|
|
342
|
+
return logoutHandler(request, {
|
|
343
|
+
AUTH,
|
|
344
|
+
repository: authRepository
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
if (slug[1] === "refresh") {
|
|
349
|
+
if (method === "GET") {
|
|
350
|
+
return authRefreshHandler(request, { AUTH });
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
if (slug[1] === "callback") {
|
|
354
|
+
if (slug[2]) {
|
|
355
|
+
const provider = slug[2];
|
|
356
|
+
if (method === "GET") {
|
|
357
|
+
return thirdPartyAuthCallbackHandler(
|
|
358
|
+
request,
|
|
359
|
+
{ provider },
|
|
360
|
+
{
|
|
361
|
+
AUTH,
|
|
362
|
+
GOOGLE_AUTH,
|
|
363
|
+
APPLE_AUTH,
|
|
364
|
+
SITE_ORIGIN
|
|
365
|
+
}
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
if (slug[0] === "files") {
|
|
372
|
+
if (!slug[1]) {
|
|
373
|
+
if (method === "POST") {
|
|
374
|
+
return fileUploadHandler(request, { AUTH, FILE_SERVICE });
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
if (slug[1]) {
|
|
378
|
+
if (method === "DELETE") {
|
|
379
|
+
const fileId = slug[1];
|
|
380
|
+
return fileDeleteHandler(
|
|
381
|
+
request,
|
|
382
|
+
{ fileId },
|
|
383
|
+
{ AUTH, repository: fileRepository }
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return new Response("Not Found", { status: 404 });
|
|
389
|
+
};
|
|
390
|
+
return handler;
|
|
391
|
+
};
|
|
392
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
393
|
+
0 && (module.exports = {
|
|
394
|
+
createAuthAPIHandler
|
|
395
|
+
});
|