dn-react-router-toolkit 0.1.0 → 0.1.2
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 +108 -0
- package/dist/auth-kit/with_auth.mjs +71 -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 +9 -7
- 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 +9 -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 -60
- package/dist/cjs/auth-kit/auth_service.js +0 -204
- package/dist/cjs/auth-kit/client/google_login_button.js +0 -25
- package/dist/cjs/auth-kit/client/redirect_page.js +0 -21
- package/dist/cjs/auth-kit/google_auth.js +0 -65
- package/dist/cjs/auth-kit/jwt.js +0 -53
- package/dist/cjs/auth-kit/kakao_auth.js +0 -38
- 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 -64
- package/dist/cjs/components/modal/hooks.js +0 -78
- package/dist/cjs/components/modal/index.js +0 -19
- package/dist/cjs/components/modal/modal.js +0 -91
- 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 -195
- package/dist/cjs/file-kit/client/file_uploader.js +0 -78
- package/dist/cjs/file-kit/file_service.js +0 -29
- package/dist/cjs/file-kit/object_storage.js +0 -50
- package/dist/cjs/file-kit/repository.js +0 -2
- package/dist/cjs/file-kit/responsive_image.js +0 -78
- package/dist/cjs/http-kit/index.js +0 -17
- package/dist/cjs/http-kit/response.js +0 -34
- 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 -23
- 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 -35
- 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 -286
- package/dist/cjs/seo-kit/seo_loader.js +0 -19
- package/dist/cjs/singleton.js +0 -12
- package/dist/cjs/slug.js +0 -10
- package/dist/esm/auth-kit/apple_auth.js +0 -56
- package/dist/esm/auth-kit/auth_service.js +0 -197
- package/dist/esm/auth-kit/client/google_login_button.d.ts +0 -6
- package/dist/esm/auth-kit/client/google_login_button.js +0 -19
- package/dist/esm/auth-kit/client/redirect_page.d.ts +0 -2
- package/dist/esm/auth-kit/client/redirect_page.js +0 -15
- package/dist/esm/auth-kit/google_auth.js +0 -61
- package/dist/esm/auth-kit/jwt.js +0 -49
- package/dist/esm/auth-kit/kakao_auth.js +0 -34
- 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 -57
- package/dist/esm/components/modal/hooks.d.ts +0 -15
- package/dist/esm/components/modal/hooks.js +0 -69
- 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 -55
- 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 -158
- package/dist/esm/file-kit/client/file_uploader.js +0 -74
- package/dist/esm/file-kit/file_service.js +0 -25
- package/dist/esm/file-kit/object_storage.js +0 -46
- 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 -70
- 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 -28
- 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 -19
- 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 -31
- 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 -280
- package/dist/esm/seo-kit/seo_loader.d.ts +0 -12
- package/dist/esm/seo-kit/seo_loader.js +0 -13
- 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
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
36
|
-
var t = {};
|
|
37
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
38
|
-
t[p] = s[p];
|
|
39
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
40
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
41
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
42
|
-
t[p[i]] = s[p[i]];
|
|
43
|
-
}
|
|
44
|
-
return t;
|
|
45
|
-
};
|
|
46
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
-
exports.useDropFileInput = useDropFileInput;
|
|
48
|
-
exports.DropFileMessageBox = DropFileMessageBox;
|
|
49
|
-
const react_1 = __importStar(require("react"));
|
|
50
|
-
const uuid_1 = require("uuid");
|
|
51
|
-
const cn_1 = require("../../cn");
|
|
52
|
-
function useDropFileInput({ defaultValue, options, uploadFile, onFileInput, onFileUploaded, limit, } = {}) {
|
|
53
|
-
const [files, setFiles] = (0, react_1.useState)(defaultValue
|
|
54
|
-
? (Array.isArray(defaultValue) ? defaultValue : [defaultValue])
|
|
55
|
-
.map((v) => {
|
|
56
|
-
return {
|
|
57
|
-
key: (0, uuid_1.v4)(),
|
|
58
|
-
item: v,
|
|
59
|
-
};
|
|
60
|
-
})
|
|
61
|
-
.slice(0, limit ? limit : Infinity)
|
|
62
|
-
: []);
|
|
63
|
-
const fileRef = (0, react_1.useRef)([]);
|
|
64
|
-
(0, react_1.useEffect)(() => {
|
|
65
|
-
fileRef.current = files;
|
|
66
|
-
}, [files]);
|
|
67
|
-
const Component = (0, react_1.useCallback)(function Component(_a) {
|
|
68
|
-
var { className, container = "border border-dashed border-neutral-300 rounded flex items-center justify-center", draggingClassName, name, hideMessage = false, children } = _a, props = __rest(_a, ["className", "container", "draggingClassName", "name", "hideMessage", "children"]);
|
|
69
|
-
const [isDragging, setIsDragging] = (0, react_1.useState)(false);
|
|
70
|
-
const handleDragEnter = (0, react_1.useCallback)((e) => {
|
|
71
|
-
e.preventDefault();
|
|
72
|
-
e.stopPropagation();
|
|
73
|
-
setIsDragging(true);
|
|
74
|
-
}, []);
|
|
75
|
-
const handleDragLeave = (0, react_1.useCallback)((e) => {
|
|
76
|
-
e.preventDefault();
|
|
77
|
-
e.stopPropagation();
|
|
78
|
-
setIsDragging(false);
|
|
79
|
-
}, []);
|
|
80
|
-
const handleDragOver = (0, react_1.useCallback)((e) => {
|
|
81
|
-
e.preventDefault();
|
|
82
|
-
e.stopPropagation();
|
|
83
|
-
}, []);
|
|
84
|
-
const handleFiles = (0, react_1.useCallback)(async (files) => {
|
|
85
|
-
if (limit && fileRef.current.length >= limit) {
|
|
86
|
-
alert(`파일은 최대 ${limit}개 업로드할 수 있습니다.`);
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
const filteredFiles = files.filter((file) => {
|
|
90
|
-
// if (!props.accept) {
|
|
91
|
-
// return true;
|
|
92
|
-
// }
|
|
93
|
-
// const accepts = props.accept.split(",");
|
|
94
|
-
// for (const accept of accepts) {
|
|
95
|
-
// if (file.type.startsWith(accept)) {
|
|
96
|
-
// return true;
|
|
97
|
-
// }
|
|
98
|
-
// if (file.name.endsWith(accept)) {
|
|
99
|
-
// return true;
|
|
100
|
-
// }
|
|
101
|
-
// }
|
|
102
|
-
// return false;
|
|
103
|
-
return true;
|
|
104
|
-
});
|
|
105
|
-
if (files.length !== filteredFiles.length) {
|
|
106
|
-
alert(`${props.accept} 형식의 파일만 업로드할 수 있습니다.`);
|
|
107
|
-
}
|
|
108
|
-
const limitedFiles = filteredFiles.slice(0, limit ? limit - fileRef.current.length : Infinity);
|
|
109
|
-
if (limitedFiles.length === 0) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
if (onFileInput) {
|
|
113
|
-
onFileInput(limitedFiles);
|
|
114
|
-
}
|
|
115
|
-
for (const file of limitedFiles) {
|
|
116
|
-
const fileItem = {
|
|
117
|
-
key: (0, uuid_1.v4)(),
|
|
118
|
-
};
|
|
119
|
-
setFiles((prevFiles) => [...prevFiles, fileItem]);
|
|
120
|
-
uploadFile === null || uploadFile === void 0 ? void 0 : uploadFile(file, options).then(async (item) => {
|
|
121
|
-
await (onFileUploaded === null || onFileUploaded === void 0 ? void 0 : onFileUploaded(item));
|
|
122
|
-
setFiles((prevFiles) => prevFiles.map((f) => {
|
|
123
|
-
if (f.key === fileItem.key) {
|
|
124
|
-
return Object.assign(Object.assign({}, f), { item });
|
|
125
|
-
}
|
|
126
|
-
return f;
|
|
127
|
-
}));
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
}, [props.accept]);
|
|
131
|
-
const handleDrop = (0, react_1.useCallback)((e) => {
|
|
132
|
-
e.preventDefault();
|
|
133
|
-
e.stopPropagation();
|
|
134
|
-
setIsDragging(false);
|
|
135
|
-
if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {
|
|
136
|
-
handleFiles(Array.from(e.dataTransfer.files));
|
|
137
|
-
e.dataTransfer.clearData();
|
|
138
|
-
}
|
|
139
|
-
}, [handleFiles]);
|
|
140
|
-
const inputRef = (0, react_1.useRef)(null);
|
|
141
|
-
const handleClick = (0, react_1.useCallback)(() => {
|
|
142
|
-
var _a;
|
|
143
|
-
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
144
|
-
}, []);
|
|
145
|
-
const handleKeyDown = (0, react_1.useCallback)((e) => {
|
|
146
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
147
|
-
handleClick();
|
|
148
|
-
}
|
|
149
|
-
}, [handleClick]);
|
|
150
|
-
const handleChange = (0, react_1.useCallback)((e) => {
|
|
151
|
-
if (e.target.files && e.target.files.length > 0) {
|
|
152
|
-
handleFiles(Array.from(e.target.files));
|
|
153
|
-
e.target.value = "";
|
|
154
|
-
}
|
|
155
|
-
}, [handleFiles]);
|
|
156
|
-
return (react_1.default.createElement("div", { className: (0, cn_1.cn)(className, container, (draggingClassName === null || draggingClassName === void 0 ? void 0 : draggingClassName(isDragging)) ||
|
|
157
|
-
(isDragging ? "bg-neutral-300/25" : "hover:bg-neutral-300/25"), "transition-colors cursor-pointer"), onDragEnter: handleDragEnter, onDragLeave: handleDragLeave, onDragOver: handleDragOver, onDrop: handleDrop, onClick: handleClick, onChange: handleChange, onKeyDown: handleKeyDown, tabIndex: 0, role: "button" },
|
|
158
|
-
react_1.default.createElement("input", Object.assign({}, props, { defaultValue: "", type: "file", hidden: true, ref: inputRef })),
|
|
159
|
-
react_1.default.createElement("input", { name: name, hidden: true, readOnly: true, value: files
|
|
160
|
-
.map((file) => {
|
|
161
|
-
if (file.item &&
|
|
162
|
-
typeof file.item === "object" &&
|
|
163
|
-
"id" in file.item) {
|
|
164
|
-
return file.item.id;
|
|
165
|
-
}
|
|
166
|
-
return null;
|
|
167
|
-
})
|
|
168
|
-
.filter(Boolean)
|
|
169
|
-
.join(",") }),
|
|
170
|
-
children ||
|
|
171
|
-
(!(hideMessage && !isDragging) && react_1.default.createElement(DropFileMessageBox, null))));
|
|
172
|
-
}, [limit, fileRef, files, options, uploadFile, onFileInput, onFileUploaded]);
|
|
173
|
-
const loadedFileIds = files
|
|
174
|
-
.map((file) => {
|
|
175
|
-
if (file.item && typeof file.item === "object" && "id" in file.item) {
|
|
176
|
-
return file.item.id;
|
|
177
|
-
}
|
|
178
|
-
return null;
|
|
179
|
-
})
|
|
180
|
-
.filter(Boolean);
|
|
181
|
-
const loadedFileIdsString = loadedFileIds.join(",");
|
|
182
|
-
const fileIds = (0, react_1.useMemo)(() => loadedFileIdsString.split(",").filter(Boolean), [loadedFileIdsString]);
|
|
183
|
-
return {
|
|
184
|
-
fileIds,
|
|
185
|
-
files,
|
|
186
|
-
setFiles,
|
|
187
|
-
Component,
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
function DropFileMessageBox() {
|
|
191
|
-
return (react_1.default.createElement("div", { className: "text-sm pointer-events-none flex justify-center items-center" },
|
|
192
|
-
react_1.default.createElement("div", { className: "flex flex-col items-center" },
|
|
193
|
-
react_1.default.createElement("span", null, "\uD30C\uC77C\uC744 \uC5EC\uAE30\uB85C \uB04C\uC5B4\uB2E4 \uB193\uAC70\uB098 \uD074\uB9AD\uD574\uC11C \uC120\uD0DD\uD574 \uC8FC\uC138\uC694"))));
|
|
194
|
-
}
|
|
195
|
-
exports.default = useDropFileInput;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FileUploader = void 0;
|
|
4
|
-
class FileUploader {
|
|
5
|
-
constructor(endpoint = "/api/files") {
|
|
6
|
-
this.formatSize = (size) => {
|
|
7
|
-
if (size < 1024) {
|
|
8
|
-
return `${size} B`;
|
|
9
|
-
}
|
|
10
|
-
if (size < 1024 * 1024) {
|
|
11
|
-
return `${(size / 1024).toFixed(2)} KB`;
|
|
12
|
-
}
|
|
13
|
-
return `${(size / (1024 * 1024)).toFixed(2)} MB`;
|
|
14
|
-
};
|
|
15
|
-
this.endpoint = endpoint;
|
|
16
|
-
}
|
|
17
|
-
uploadFile(file, options = {}) {
|
|
18
|
-
return this.uploadBlob(file, file.name, options);
|
|
19
|
-
}
|
|
20
|
-
async uploadBlob(blob, name = "blob", options = {}) {
|
|
21
|
-
const { type, size } = blob;
|
|
22
|
-
const metadataForMedia = await new Promise((resolve, reject) => {
|
|
23
|
-
if (blob.type.startsWith("image/")) {
|
|
24
|
-
const img = new Image();
|
|
25
|
-
img.src = URL.createObjectURL(blob);
|
|
26
|
-
img.onload = () => {
|
|
27
|
-
resolve(Object.assign(Object.assign({}, options.metadata), { width: img.width, height: img.height }));
|
|
28
|
-
};
|
|
29
|
-
img.onerror = reject;
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
if (blob.type.startsWith("video/")) {
|
|
33
|
-
const video = document.createElement("video");
|
|
34
|
-
video.src = URL.createObjectURL(blob);
|
|
35
|
-
video.onloadedmetadata = () => {
|
|
36
|
-
resolve(Object.assign(Object.assign({}, options.metadata), { width: video.videoWidth, height: video.videoHeight, duration: video.duration }));
|
|
37
|
-
};
|
|
38
|
-
video.onerror = reject;
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
resolve(options.metadata || {});
|
|
42
|
-
});
|
|
43
|
-
const res1 = await fetch(this.endpoint, {
|
|
44
|
-
method: "POST",
|
|
45
|
-
body: JSON.stringify({
|
|
46
|
-
name: name.replace(/ /g, "_"),
|
|
47
|
-
type,
|
|
48
|
-
size,
|
|
49
|
-
metadata: metadataForMedia,
|
|
50
|
-
}),
|
|
51
|
-
});
|
|
52
|
-
if (!res1.ok) {
|
|
53
|
-
const message = await res1.json();
|
|
54
|
-
throw new Error(message);
|
|
55
|
-
}
|
|
56
|
-
const result = await res1.json();
|
|
57
|
-
const { signedUrl, file } = result;
|
|
58
|
-
const res2 = await fetch(signedUrl, {
|
|
59
|
-
method: "PUT",
|
|
60
|
-
body: blob,
|
|
61
|
-
});
|
|
62
|
-
if (!res2.ok) {
|
|
63
|
-
throw new Error(await res2.text());
|
|
64
|
-
}
|
|
65
|
-
return file;
|
|
66
|
-
}
|
|
67
|
-
async deleteFile(fileId) {
|
|
68
|
-
const res = await fetch(`${this.endpoint}/${fileId}`, {
|
|
69
|
-
method: "DELETE",
|
|
70
|
-
});
|
|
71
|
-
if (!res.ok) {
|
|
72
|
-
const { message } = await res.json();
|
|
73
|
-
throw new Error(message);
|
|
74
|
-
}
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
exports.FileUploader = FileUploader;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FileService = void 0;
|
|
4
|
-
const uuid_1 = require("uuid");
|
|
5
|
-
class FileService {
|
|
6
|
-
constructor(prefix = "user", { repository, OBJECT_STORAGE, }) {
|
|
7
|
-
this.prefix = prefix;
|
|
8
|
-
this.repository = repository;
|
|
9
|
-
this.OBJECT_STORAGE = OBJECT_STORAGE;
|
|
10
|
-
}
|
|
11
|
-
async generateSignedUrl({ userId, name, type, size, metadata = {} }) {
|
|
12
|
-
const id = (0, uuid_1.v4)();
|
|
13
|
-
const key = `${this.prefix}/${id}/${name}`;
|
|
14
|
-
const file = await this.repository.createFile({
|
|
15
|
-
id,
|
|
16
|
-
userId,
|
|
17
|
-
name,
|
|
18
|
-
type,
|
|
19
|
-
size,
|
|
20
|
-
metadata,
|
|
21
|
-
key,
|
|
22
|
-
});
|
|
23
|
-
const signedUrl = await this.OBJECT_STORAGE.generateSignedUrl(key, {
|
|
24
|
-
contentType: type,
|
|
25
|
-
});
|
|
26
|
-
return { file, signedUrl };
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.FileService = FileService;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ObjectStorage = void 0;
|
|
4
|
-
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
5
|
-
const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
|
|
6
|
-
class ObjectStorage {
|
|
7
|
-
constructor(bucketName) {
|
|
8
|
-
this.client = new client_s3_1.S3Client({
|
|
9
|
-
region: "ap-northeast-2",
|
|
10
|
-
});
|
|
11
|
-
this.bucketName = bucketName;
|
|
12
|
-
}
|
|
13
|
-
async generateSignedUrl(key, { contentType, expiresIn = 3600, } = {}) {
|
|
14
|
-
const command = new client_s3_1.PutObjectCommand({
|
|
15
|
-
Bucket: this.bucketName,
|
|
16
|
-
Key: key,
|
|
17
|
-
ContentType: contentType,
|
|
18
|
-
});
|
|
19
|
-
const signedUrl = await (0, s3_request_presigner_1.getSignedUrl)(this.client, command, {
|
|
20
|
-
expiresIn,
|
|
21
|
-
});
|
|
22
|
-
return signedUrl;
|
|
23
|
-
}
|
|
24
|
-
async find(key) {
|
|
25
|
-
try {
|
|
26
|
-
const command = new client_s3_1.GetObjectCommand({
|
|
27
|
-
Bucket: this.bucketName,
|
|
28
|
-
Key: key,
|
|
29
|
-
});
|
|
30
|
-
const { Body } = await this.client.send(command);
|
|
31
|
-
if (!Body) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
return Body.transformToByteArray();
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
async put(key, buffer, { contentType } = {}) {
|
|
41
|
-
const command = new client_s3_1.PutObjectCommand({
|
|
42
|
-
Bucket: this.bucketName,
|
|
43
|
-
Key: key,
|
|
44
|
-
ContentType: contentType,
|
|
45
|
-
Body: buffer,
|
|
46
|
-
});
|
|
47
|
-
return await this.client.send(command);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.ObjectStorage = ObjectStorage;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.createResponsiveImage = void 0;
|
|
18
|
-
exports.generateSrcSet = generateSrcSet;
|
|
19
|
-
const react_1 = __importDefault(require("react"));
|
|
20
|
-
const sizes = [
|
|
21
|
-
64, 128, 256, 320, 480, 640, 768, 1080, 1200, 1536, 1920, 2560, 3840,
|
|
22
|
-
];
|
|
23
|
-
const createResponsiveImage = (cdn) => {
|
|
24
|
-
const Component = (_a) => {
|
|
25
|
-
var { alt, file, ratio } = _a, props = __rest(_a, ["alt", "file", "ratio"]);
|
|
26
|
-
const src = cdn(file === null || file === void 0 ? void 0 : file.key) || props.src || "#";
|
|
27
|
-
return (react_1.default.createElement("img", Object.assign({}, props, { src: src, alt: alt, srcSet: generateSrcSet(src, ratio, props) })));
|
|
28
|
-
};
|
|
29
|
-
return Component;
|
|
30
|
-
};
|
|
31
|
-
exports.createResponsiveImage = createResponsiveImage;
|
|
32
|
-
exports.default = exports.createResponsiveImage;
|
|
33
|
-
const generateSrc = (src, width, height, ratio, image = {}) => {
|
|
34
|
-
const searchParams = new URLSearchParams();
|
|
35
|
-
if (image.width) {
|
|
36
|
-
searchParams.set("w", image.width.toString());
|
|
37
|
-
}
|
|
38
|
-
if (width) {
|
|
39
|
-
searchParams.set("w", width.toString());
|
|
40
|
-
if (ratio) {
|
|
41
|
-
searchParams.set("h", Math.round(width / ratio).toString());
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (image.height) {
|
|
45
|
-
searchParams.set("h", image.height.toString());
|
|
46
|
-
}
|
|
47
|
-
if (height) {
|
|
48
|
-
searchParams.set("h", height.toString());
|
|
49
|
-
}
|
|
50
|
-
const search = searchParams.toString() ? `?${searchParams.toString()}` : "";
|
|
51
|
-
const origin = process.env.NEXT_PUBLIC_CDN_ORIGIN || "";
|
|
52
|
-
if (!src.includes(origin)) {
|
|
53
|
-
return src;
|
|
54
|
-
}
|
|
55
|
-
return `${encodeURI(decodeURI(src))}${search}`;
|
|
56
|
-
};
|
|
57
|
-
function generateSrcSet(image, ratio, props = {}) {
|
|
58
|
-
const src = typeof image === "string" ? image : image.src;
|
|
59
|
-
const isGif = src.endsWith(".gif");
|
|
60
|
-
if (isGif) {
|
|
61
|
-
return undefined;
|
|
62
|
-
}
|
|
63
|
-
if (props.width) {
|
|
64
|
-
return [1, 2, 3]
|
|
65
|
-
.map((scale) => {
|
|
66
|
-
const genWidth = Number(props.width) * scale;
|
|
67
|
-
return `${generateSrc(src, genWidth, props.height
|
|
68
|
-
? Number(props.height) * scale
|
|
69
|
-
: ratio
|
|
70
|
-
? Math.round(genWidth / ratio)
|
|
71
|
-
: undefined)} ${scale}x`;
|
|
72
|
-
})
|
|
73
|
-
.join(", ");
|
|
74
|
-
}
|
|
75
|
-
return sizes
|
|
76
|
-
.map((size) => `${generateSrc(src, size, undefined, ratio, props)} ${size}w`)
|
|
77
|
-
.join(", ");
|
|
78
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./response"), exports);
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.INTERNAL_SERVER_ERROR = exports.TOO_MANY_REQUESTS = exports.UNPROCESSABLE_ENTITY = exports.CONFLICT = exports.REQUEST_TIMEOUT = exports.NOT_ACCEPTABLE = exports.METHOD_NOT_ALLOWED = exports.NOT_FOUND = exports.FORBIDDEN = exports.UNAUTHORIZED = exports.BAD_REQUEST = exports.createException = exports.NO_CONTENT = exports.ACCEPTED = exports.CREATED = exports.OK = exports.createJsonResponse = void 0;
|
|
4
|
-
const createJsonResponse = (status) => {
|
|
5
|
-
return (data = {}, init) => {
|
|
6
|
-
return Response.json(data, Object.assign({ status }, init));
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
|
-
exports.createJsonResponse = createJsonResponse;
|
|
10
|
-
Response;
|
|
11
|
-
exports.OK = (0, exports.createJsonResponse)(200);
|
|
12
|
-
exports.CREATED = (0, exports.createJsonResponse)(201);
|
|
13
|
-
exports.ACCEPTED = (0, exports.createJsonResponse)(202);
|
|
14
|
-
const NO_CONTENT = (init) => {
|
|
15
|
-
return new Response(null, Object.assign(Object.assign({}, init), { status: 204 }));
|
|
16
|
-
};
|
|
17
|
-
exports.NO_CONTENT = NO_CONTENT;
|
|
18
|
-
const createException = (status, defaultMessage = "오류가 발생했습니다.") => {
|
|
19
|
-
return (message = defaultMessage, init) => {
|
|
20
|
-
return (0, exports.createJsonResponse)(status)({ message }, init);
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
exports.createException = createException;
|
|
24
|
-
exports.BAD_REQUEST = (0, exports.createException)(400, "요청이 올바르지 않습니다.");
|
|
25
|
-
exports.UNAUTHORIZED = (0, exports.createException)(401, "인증이 필요합니다.");
|
|
26
|
-
exports.FORBIDDEN = (0, exports.createException)(403, "권한이 없습니다.");
|
|
27
|
-
exports.NOT_FOUND = (0, exports.createException)(404, "요청한 리소스를 찾을 수 없습니다.");
|
|
28
|
-
exports.METHOD_NOT_ALLOWED = (0, exports.createException)(405, "메서드를 사용할 수 없습니다.");
|
|
29
|
-
exports.NOT_ACCEPTABLE = (0, exports.createException)(406, "요청한 형식을 사용할 수 없습니다.");
|
|
30
|
-
exports.REQUEST_TIMEOUT = (0, exports.createException)(408, "요청 시간이 초과되었습니다.");
|
|
31
|
-
exports.CONFLICT = (0, exports.createException)(409, "요청이 충돌했습니다.");
|
|
32
|
-
exports.UNPROCESSABLE_ENTITY = (0, exports.createException)(422, "처리할 수 없는 엔티티입니다.");
|
|
33
|
-
exports.TOO_MANY_REQUESTS = (0, exports.createException)(429, "요청이 너무 많습니다.");
|
|
34
|
-
exports.INTERNAL_SERVER_ERROR = (0, exports.createException)(500, "예기치 못한 오류가 발생했습니다.");
|
package/dist/cjs/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./cn"), exports);
|
|
18
|
-
__exportStar(require("./date"), exports);
|
|
19
|
-
__exportStar(require("./singleton"), exports);
|
|
20
|
-
__exportStar(require("./slug"), exports);
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loginThirdPartyHandler = void 0;
|
|
4
|
-
const http_kit_1 = require("../../../../../http-kit");
|
|
5
|
-
const loginThirdPartyHandler = async (request, { provider, }, { GOOGLE_AUTH, APPLE_AUTH, KAKAO_AUTH, }) => {
|
|
6
|
-
const { code } = await request.json();
|
|
7
|
-
if (!code) {
|
|
8
|
-
return (0, http_kit_1.BAD_REQUEST)("코드가 없습니다.");
|
|
9
|
-
}
|
|
10
|
-
const getThirdPartyAuth = (provider) => {
|
|
11
|
-
switch (provider) {
|
|
12
|
-
case "google":
|
|
13
|
-
return GOOGLE_AUTH;
|
|
14
|
-
case "apple":
|
|
15
|
-
return APPLE_AUTH;
|
|
16
|
-
case "kakao":
|
|
17
|
-
return KAKAO_AUTH;
|
|
18
|
-
default:
|
|
19
|
-
throw (0, http_kit_1.BAD_REQUEST)("지원하지 않는 인증 제공자입니다.");
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
try {
|
|
23
|
-
const { accessToken, refreshToken } = await getThirdPartyAuth(provider).signIn(code);
|
|
24
|
-
return (0, http_kit_1.CREATED)({
|
|
25
|
-
accessToken,
|
|
26
|
-
refreshToken,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
if (error instanceof Response) {
|
|
31
|
-
return error;
|
|
32
|
-
}
|
|
33
|
-
throw (0, http_kit_1.INTERNAL_SERVER_ERROR)();
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
exports.loginThirdPartyHandler = loginThirdPartyHandler;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loginCredentialHandler = void 0;
|
|
4
|
-
const http_kit_1 = require("../../../../http-kit");
|
|
5
|
-
const loginCredentialHandler = async (request, { AUTH, JWT_MANAGER, }) => {
|
|
6
|
-
const searchParams = new URL(request.url).searchParams;
|
|
7
|
-
const { id, password } = await request.json();
|
|
8
|
-
try {
|
|
9
|
-
const { accessToken, refreshToken } = await AUTH.signIn({
|
|
10
|
-
id,
|
|
11
|
-
password,
|
|
12
|
-
});
|
|
13
|
-
if (searchParams.get("type") === "json") {
|
|
14
|
-
return (0, http_kit_1.CREATED)({ accessToken, refreshToken });
|
|
15
|
-
}
|
|
16
|
-
const [accessTokenSetCookie, refreshTokenSetCookie] = await Promise.all([
|
|
17
|
-
AUTH.getAccessTokenSetCookie(accessToken),
|
|
18
|
-
AUTH.getRefreshTokenSetCookie(refreshToken),
|
|
19
|
-
]);
|
|
20
|
-
const payload = JWT_MANAGER.decode(accessToken);
|
|
21
|
-
const headers = new Headers();
|
|
22
|
-
headers.append("Set-Cookie", accessTokenSetCookie);
|
|
23
|
-
headers.append("Set-Cookie", refreshTokenSetCookie);
|
|
24
|
-
return (0, http_kit_1.CREATED)(payload, {
|
|
25
|
-
headers,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
catch (e) {
|
|
29
|
-
if (e instanceof Error) {
|
|
30
|
-
return (0, http_kit_1.UNAUTHORIZED)(e.message);
|
|
31
|
-
}
|
|
32
|
-
throw e;
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
exports.loginCredentialHandler = loginCredentialHandler;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.logoutHandler = void 0;
|
|
4
|
-
const http_kit_1 = require("../../../../http-kit");
|
|
5
|
-
const logoutHandler = async (request, { AUTH, repository }) => {
|
|
6
|
-
const auth = await AUTH.verifyOrRefresh(request);
|
|
7
|
-
if (!auth) {
|
|
8
|
-
return (0, http_kit_1.UNAUTHORIZED)();
|
|
9
|
-
}
|
|
10
|
-
await repository.updateUserRefreshToken(auth.userId, null);
|
|
11
|
-
const headers = new Headers();
|
|
12
|
-
const [accessTokenSetCookie, refreshTokenSetCookie] = await Promise.all([
|
|
13
|
-
AUTH.getAccessTokenSetCookie(null),
|
|
14
|
-
AUTH.getRefreshTokenSetCookie(null),
|
|
15
|
-
]);
|
|
16
|
-
headers.append("Set-Cookie", accessTokenSetCookie);
|
|
17
|
-
headers.append("Set-Cookie", refreshTokenSetCookie);
|
|
18
|
-
return (0, http_kit_1.NO_CONTENT)({
|
|
19
|
-
headers,
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
exports.logoutHandler = logoutHandler;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.authRefreshHandler = void 0;
|
|
4
|
-
const http_kit_1 = require("../../../../http-kit");
|
|
5
|
-
const authRefreshHandler = async (request, { AUTH, }) => {
|
|
6
|
-
var _a;
|
|
7
|
-
const refreshToken = ((_a = request === null || request === void 0 ? void 0 : request.headers.get("Authorization")) === null || _a === void 0 ? void 0 : _a.replace("Bearer ", "")) ||
|
|
8
|
-
(await AUTH.getRefreshTokenFromCookies(request));
|
|
9
|
-
if (!refreshToken) {
|
|
10
|
-
return (0, http_kit_1.BAD_REQUEST)();
|
|
11
|
-
}
|
|
12
|
-
try {
|
|
13
|
-
const accessToken = await AUTH.refreshAccessToken(refreshToken);
|
|
14
|
-
return (0, http_kit_1.CREATED)({ accessToken });
|
|
15
|
-
}
|
|
16
|
-
catch (e) {
|
|
17
|
-
if (e instanceof Error) {
|
|
18
|
-
return (0, http_kit_1.UNAUTHORIZED)(e.message);
|
|
19
|
-
}
|
|
20
|
-
throw e;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
exports.authRefreshHandler = authRefreshHandler;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAuthHandler = void 0;
|
|
4
|
-
const http_kit_1 = require("../../../http-kit");
|
|
5
|
-
const getAuthHandler = async (request, { AUTH }) => {
|
|
6
|
-
const auth = await AUTH.verifyOrRefresh(request);
|
|
7
|
-
if (!auth) {
|
|
8
|
-
return (0, http_kit_1.UNAUTHORIZED)();
|
|
9
|
-
}
|
|
10
|
-
return (0, http_kit_1.OK)(auth);
|
|
11
|
-
};
|
|
12
|
-
exports.getAuthHandler = getAuthHandler;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fileDeleteHandler = void 0;
|
|
4
|
-
const http_kit_1 = require("../../../../http-kit");
|
|
5
|
-
const fileDeleteHandler = async (request, { fileId }, { AUTH, repository, }) => {
|
|
6
|
-
const auth = await AUTH.verifyOrRefresh(request);
|
|
7
|
-
const file = await repository.findFileById(fileId);
|
|
8
|
-
const headers = {
|
|
9
|
-
"Access-Control-Allow-Origin": "*",
|
|
10
|
-
};
|
|
11
|
-
if (!file) {
|
|
12
|
-
return (0, http_kit_1.NOT_FOUND)("파일을 찾을 수 없습니다.", { headers });
|
|
13
|
-
}
|
|
14
|
-
if (!repository.hasPermission(file, auth === null || auth === void 0 ? void 0 : auth.userId)) {
|
|
15
|
-
return (0, http_kit_1.FORBIDDEN)("파일을 삭제할 권한이 없습니다.", { headers });
|
|
16
|
-
}
|
|
17
|
-
await repository.deleteFile(fileId);
|
|
18
|
-
return (0, http_kit_1.NO_CONTENT)({ headers });
|
|
19
|
-
};
|
|
20
|
-
exports.fileDeleteHandler = fileDeleteHandler;
|