dn-react-router-toolkit 0.1.12 → 0.2.1
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} +10 -11
- package/dist/{auth-kit/repository.d.ts → auth/auth_repository.d.ts} +10 -11
- package/dist/{file-kit/repository.js → auth/auth_repository.js} +3 -3
- package/dist/{auth-kit → auth}/auth_service.d.mts +12 -23
- package/dist/{auth-kit → auth}/auth_service.d.ts +12 -23
- package/dist/{auth-kit → auth}/auth_service.js +24 -77
- package/dist/{auth-kit → auth}/auth_service.mjs +24 -77
- 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 +26 -0
- package/dist/auth/client/provider.d.ts +26 -0
- package/dist/auth/client/provider.js +152 -0
- package/dist/auth/client/provider.mjs +116 -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/request_password_reset.d.mts +10 -0
- package/dist/auth/handlers/request_password_reset.d.ts +10 -0
- package/dist/auth/handlers/request_password_reset.js +87 -0
- package/dist/auth/handlers/request_password_reset.mjs +60 -0
- package/dist/auth/handlers/reset_password.d.mts +10 -0
- package/dist/auth/handlers/reset_password.d.ts +10 -0
- package/dist/auth/handlers/reset_password.js +88 -0
- package/dist/auth/handlers/reset_password.mjs +61 -0
- package/dist/auth/handlers/signup.d.mts +15 -0
- package/dist/auth/handlers/signup.d.ts +15 -0
- package/dist/auth/handlers/signup.js +147 -0
- package/dist/auth/handlers/signup.mjs +112 -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/password_recovery.d.mts +34 -0
- package/dist/auth/password_recovery.d.ts +34 -0
- package/dist/auth/password_recovery.js +169 -0
- package/dist/auth/password_recovery.mjs +134 -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 +17 -25
- package/dist/route/api.d.ts +17 -25
- package/dist/route/api.js +367 -178
- package/dist/route/api.mjs +356 -177
- package/dist/{seo-kit → seo}/seo.js +1 -1
- package/dist/{seo-kit → seo}/seo.mjs +1 -1
- package/package.json +76 -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,134 @@
|
|
|
1
|
+
// src/auth/password_recovery.ts
|
|
2
|
+
import nodemailer from "nodemailer";
|
|
3
|
+
|
|
4
|
+
// src/http/response.ts
|
|
5
|
+
var createJsonResponse = (status) => {
|
|
6
|
+
return (data = {}, init) => {
|
|
7
|
+
return Response.json(data, { status, ...init });
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
var OK = createJsonResponse(200);
|
|
11
|
+
var CREATED = createJsonResponse(201);
|
|
12
|
+
var ACCEPTED = createJsonResponse(202);
|
|
13
|
+
var createException = (status, defaultMessage = "\uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4.") => {
|
|
14
|
+
return (message = defaultMessage, init) => {
|
|
15
|
+
return createJsonResponse(status)({ message }, init);
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
var BAD_REQUEST = createException(400, "\uC694\uCCAD\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.");
|
|
19
|
+
var UNAUTHORIZED = createException(401, "\uC778\uC99D\uC774 \uD544\uC694\uD569\uB2C8\uB2E4.");
|
|
20
|
+
var FORBIDDEN = createException(403, "\uAD8C\uD55C\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
21
|
+
var NOT_FOUND = createException(
|
|
22
|
+
404,
|
|
23
|
+
"\uC694\uCCAD\uD55C \uB9AC\uC18C\uC2A4\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."
|
|
24
|
+
);
|
|
25
|
+
var METHOD_NOT_ALLOWED = createException(
|
|
26
|
+
405,
|
|
27
|
+
"\uBA54\uC11C\uB4DC\uB97C \uC0AC\uC6A9\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."
|
|
28
|
+
);
|
|
29
|
+
var NOT_ACCEPTABLE = createException(
|
|
30
|
+
406,
|
|
31
|
+
"\uC694\uCCAD\uD55C \uD615\uC2DD\uC744 \uC0AC\uC6A9\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."
|
|
32
|
+
);
|
|
33
|
+
var REQUEST_TIMEOUT = createException(
|
|
34
|
+
408,
|
|
35
|
+
"\uC694\uCCAD \uC2DC\uAC04\uC774 \uCD08\uACFC\uB418\uC5C8\uC2B5\uB2C8\uB2E4."
|
|
36
|
+
);
|
|
37
|
+
var CONFLICT = createException(409, "\uC694\uCCAD\uC774 \uCDA9\uB3CC\uD588\uC2B5\uB2C8\uB2E4.");
|
|
38
|
+
var UNPROCESSABLE_ENTITY = createException(
|
|
39
|
+
422,
|
|
40
|
+
"\uCC98\uB9AC\uD560 \uC218 \uC5C6\uB294 \uC5D4\uD2F0\uD2F0\uC785\uB2C8\uB2E4."
|
|
41
|
+
);
|
|
42
|
+
var TOO_MANY_REQUESTS = createException(429, "\uC694\uCCAD\uC774 \uB108\uBB34 \uB9CE\uC2B5\uB2C8\uB2E4.");
|
|
43
|
+
var INTERNAL_SERVER_ERROR = createException(
|
|
44
|
+
500,
|
|
45
|
+
"\uC608\uAE30\uCE58 \uBABB\uD55C \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
// src/auth/password_recovery.ts
|
|
49
|
+
import bcrypt from "bcryptjs";
|
|
50
|
+
var PasswordRecoveryService = class {
|
|
51
|
+
siteOrigin;
|
|
52
|
+
siteName;
|
|
53
|
+
jwtManager;
|
|
54
|
+
authRepository;
|
|
55
|
+
emailCredentials;
|
|
56
|
+
resetPasswordTokenSecret;
|
|
57
|
+
resetPasswordTokenExpiresIn;
|
|
58
|
+
constructor({
|
|
59
|
+
siteOrigin,
|
|
60
|
+
siteName,
|
|
61
|
+
jwtManager,
|
|
62
|
+
authRepository,
|
|
63
|
+
emailCredentials,
|
|
64
|
+
resetPasswordTokenSecret,
|
|
65
|
+
resetPasswordTokenExpiresIn = "1h"
|
|
66
|
+
}) {
|
|
67
|
+
this.siteOrigin = siteOrigin;
|
|
68
|
+
this.siteName = siteName;
|
|
69
|
+
this.jwtManager = jwtManager;
|
|
70
|
+
this.authRepository = authRepository;
|
|
71
|
+
this.emailCredentials = emailCredentials;
|
|
72
|
+
this.resetPasswordTokenSecret = resetPasswordTokenSecret;
|
|
73
|
+
this.resetPasswordTokenExpiresIn = resetPasswordTokenExpiresIn;
|
|
74
|
+
}
|
|
75
|
+
async requestPasswordReset(email) {
|
|
76
|
+
const credential = await this.authRepository.findCredentialById(email);
|
|
77
|
+
if (!credential) {
|
|
78
|
+
throw NOT_FOUND("\uAC00\uC785\uB418\uC9C0 \uC54A\uC740 \uC774\uBA54\uC77C\uC785\uB2C8\uB2E4.");
|
|
79
|
+
}
|
|
80
|
+
const transporter = nodemailer.createTransport({
|
|
81
|
+
service: this.emailCredentials.service,
|
|
82
|
+
auth: {
|
|
83
|
+
user: this.emailCredentials.user,
|
|
84
|
+
pass: this.emailCredentials.pass
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
const token = await this.jwtManager.sign(
|
|
88
|
+
{
|
|
89
|
+
id: credential.id
|
|
90
|
+
},
|
|
91
|
+
this.resetPasswordTokenSecret,
|
|
92
|
+
{
|
|
93
|
+
expiresIn: this.resetPasswordTokenExpiresIn
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
const link = `${this.siteOrigin}/reset-password?token=${token}`;
|
|
97
|
+
const mailOptions = {
|
|
98
|
+
from: process.env.EMAIL_USER,
|
|
99
|
+
to: email,
|
|
100
|
+
subject: `${this.siteName} \uBE44\uBC00\uBC88\uD638 \uC7AC\uC124\uC815`,
|
|
101
|
+
html: `<main>
|
|
102
|
+
<p>\uBE44\uBC00\uBC88\uD638 \uC7AC\uC124\uC815\uC744 \uC704\uD574 \uC544\uB798 \uB9C1\uD06C\uB97C \uD074\uB9AD\uD574 \uC8FC\uC138\uC694. \uB9C1\uD06C\uB294 \uD55C \uC2DC\uAC04 \uB3D9\uC548 \uC720\uD6A8\uD569\uB2C8\uB2E4. \uB2E4\uB978 \uC0AC\uB78C\uC5D0\uAC8C \uACF5\uC720\uD558\uC9C0 \uB9C8\uC138\uC694.</p>
|
|
103
|
+
<a href="${link}" target="_blank">${link}</a>
|
|
104
|
+
</main>`
|
|
105
|
+
};
|
|
106
|
+
await transporter.sendMail(mailOptions);
|
|
107
|
+
}
|
|
108
|
+
async resetPassword(token, password, passwordConfirm) {
|
|
109
|
+
const payload = await this.jwtManager.verify(
|
|
110
|
+
token,
|
|
111
|
+
this.resetPasswordTokenSecret
|
|
112
|
+
);
|
|
113
|
+
if (!payload) {
|
|
114
|
+
throw UNAUTHORIZED("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 \uD1A0\uD070\uC785\uB2C8\uB2E4.");
|
|
115
|
+
}
|
|
116
|
+
if (typeof payload.id !== "string") {
|
|
117
|
+
throw UNAUTHORIZED("\uD1A0\uD070\uC774 \uC704\uC870\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
|
|
118
|
+
}
|
|
119
|
+
const credential = await this.authRepository.findCredentialById(payload.id);
|
|
120
|
+
if (!credential) {
|
|
121
|
+
throw NOT_FOUND("\uC874\uC7AC\uD558\uC9C0 \uC54A\uB294 \uACC4\uC815\uC785\uB2C8\uB2E4.");
|
|
122
|
+
}
|
|
123
|
+
if (typeof password !== "string" || !password.trim()) {
|
|
124
|
+
throw BAD_REQUEST("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 \uBE44\uBC00\uBC88\uD638\uC785\uB2C8\uB2E4.");
|
|
125
|
+
}
|
|
126
|
+
if (password !== passwordConfirm) {
|
|
127
|
+
throw BAD_REQUEST("\uBE44\uBC00\uBC88\uD638\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.");
|
|
128
|
+
}
|
|
129
|
+
await this.authRepository.updatePassword(credential.id, bcrypt.hashSync(password, 10));
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
export {
|
|
133
|
+
PasswordRecoveryService
|
|
134
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { AuthService } from './auth_service.mjs';
|
|
2
|
+
import 'jose';
|
|
3
|
+
import 'react-router';
|
|
4
|
+
import './jwt_manager.mjs';
|
|
5
|
+
import '../file/object_storage.mjs';
|
|
6
|
+
import '@aws-sdk/client-s3';
|
|
7
|
+
import './auth_repository.mjs';
|
|
8
|
+
|
|
9
|
+
interface ThirdpartyAuth {
|
|
10
|
+
login(code: string): Promise<{
|
|
11
|
+
accessToken: string;
|
|
12
|
+
refreshToken: string;
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
15
|
+
declare class ThirdpartyAuthService {
|
|
16
|
+
authService: AuthService;
|
|
17
|
+
signupTokenSecret: string;
|
|
18
|
+
signupTokenExpiresIn: string;
|
|
19
|
+
constructor({ authService, signupTokenSecret, signupTokenExpiresIn, }: {
|
|
20
|
+
authService: AuthService;
|
|
21
|
+
signupTokenSecret: string;
|
|
22
|
+
signupTokenExpiresIn?: string;
|
|
23
|
+
});
|
|
24
|
+
issueTokensIfUserFound(provider: string, payload: {
|
|
25
|
+
id: string;
|
|
26
|
+
email: string;
|
|
27
|
+
name?: string;
|
|
28
|
+
picture?: string;
|
|
29
|
+
}): Promise<{
|
|
30
|
+
user: {
|
|
31
|
+
id: string;
|
|
32
|
+
role: string;
|
|
33
|
+
name: string;
|
|
34
|
+
refreshToken: string | null;
|
|
35
|
+
};
|
|
36
|
+
accessToken: string;
|
|
37
|
+
refreshToken: string;
|
|
38
|
+
}>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { type ThirdpartyAuth, ThirdpartyAuthService };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { AuthService } from './auth_service.js';
|
|
2
|
+
import 'jose';
|
|
3
|
+
import 'react-router';
|
|
4
|
+
import './jwt_manager.js';
|
|
5
|
+
import '../file/object_storage.js';
|
|
6
|
+
import '@aws-sdk/client-s3';
|
|
7
|
+
import './auth_repository.js';
|
|
8
|
+
|
|
9
|
+
interface ThirdpartyAuth {
|
|
10
|
+
login(code: string): Promise<{
|
|
11
|
+
accessToken: string;
|
|
12
|
+
refreshToken: string;
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
15
|
+
declare class ThirdpartyAuthService {
|
|
16
|
+
authService: AuthService;
|
|
17
|
+
signupTokenSecret: string;
|
|
18
|
+
signupTokenExpiresIn: string;
|
|
19
|
+
constructor({ authService, signupTokenSecret, signupTokenExpiresIn, }: {
|
|
20
|
+
authService: AuthService;
|
|
21
|
+
signupTokenSecret: string;
|
|
22
|
+
signupTokenExpiresIn?: string;
|
|
23
|
+
});
|
|
24
|
+
issueTokensIfUserFound(provider: string, payload: {
|
|
25
|
+
id: string;
|
|
26
|
+
email: string;
|
|
27
|
+
name?: string;
|
|
28
|
+
picture?: string;
|
|
29
|
+
}): Promise<{
|
|
30
|
+
user: {
|
|
31
|
+
id: string;
|
|
32
|
+
role: string;
|
|
33
|
+
name: string;
|
|
34
|
+
refreshToken: string | null;
|
|
35
|
+
};
|
|
36
|
+
accessToken: string;
|
|
37
|
+
refreshToken: string;
|
|
38
|
+
}>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { type ThirdpartyAuth, ThirdpartyAuthService };
|
|
@@ -17,14 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// src/auth
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
23
|
-
|
|
20
|
+
// src/auth/thirdparty_auth.ts
|
|
21
|
+
var thirdparty_auth_exports = {};
|
|
22
|
+
__export(thirdparty_auth_exports, {
|
|
23
|
+
ThirdpartyAuthService: () => ThirdpartyAuthService
|
|
24
24
|
});
|
|
25
|
-
module.exports = __toCommonJS(
|
|
25
|
+
module.exports = __toCommonJS(thirdparty_auth_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,38 +68,36 @@ var INTERNAL_SERVER_ERROR = createException(
|
|
|
68
68
|
"\uC608\uAE30\uCE58 \uBABB\uD55C \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."
|
|
69
69
|
);
|
|
70
70
|
|
|
71
|
-
// src/auth
|
|
72
|
-
var
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
// src/auth/thirdparty_auth.ts
|
|
72
|
+
var ThirdpartyAuthService = class {
|
|
73
|
+
authService;
|
|
74
|
+
signupTokenSecret;
|
|
75
|
+
signupTokenExpiresIn;
|
|
76
|
+
constructor({
|
|
77
|
+
authService,
|
|
78
|
+
signupTokenSecret,
|
|
79
|
+
signupTokenExpiresIn = "1d"
|
|
80
|
+
}) {
|
|
81
|
+
this.authService = authService;
|
|
82
|
+
this.signupTokenSecret = signupTokenSecret;
|
|
83
|
+
this.signupTokenExpiresIn = signupTokenExpiresIn;
|
|
76
84
|
}
|
|
77
|
-
async
|
|
78
|
-
const
|
|
79
|
-
headers: {
|
|
80
|
-
Authorization: `Bearer ${kakaoAccessToken}`
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
if (!userRes.ok) {
|
|
84
|
-
throw new Error("\uC720\uC800 \uC815\uBCF4\uB97C \uAC00\uC838\uC624\uB294\uB370 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4.");
|
|
85
|
-
}
|
|
86
|
-
const { id, kakao_account } = await userRes.json();
|
|
87
|
-
const { email, profile } = kakao_account;
|
|
88
|
-
const payload = {
|
|
89
|
-
id,
|
|
90
|
-
email,
|
|
91
|
-
name: profile.nickname,
|
|
92
|
-
picture: profile.thumbnail_image_url
|
|
93
|
-
};
|
|
94
|
-
const user = await this.AUTH.findUser("kakao", payload);
|
|
85
|
+
async issueTokensIfUserFound(provider, payload) {
|
|
86
|
+
const user = await this.authService.findUser(provider, payload);
|
|
95
87
|
if (!user) {
|
|
88
|
+
const token = await this.authService.jwtManager.sign(
|
|
89
|
+
{ provider, ...payload },
|
|
90
|
+
this.signupTokenSecret,
|
|
91
|
+
{
|
|
92
|
+
expiresIn: this.signupTokenExpiresIn
|
|
93
|
+
}
|
|
94
|
+
);
|
|
96
95
|
throw createJsonResponse(404)({
|
|
97
|
-
|
|
98
|
-
...payload,
|
|
96
|
+
token,
|
|
99
97
|
message: "\uC0AC\uC6A9\uC790\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."
|
|
100
98
|
});
|
|
101
99
|
}
|
|
102
|
-
const { accessToken, refreshToken } = await this.
|
|
100
|
+
const { accessToken, refreshToken } = await this.authService.issueTokenPair(
|
|
103
101
|
user
|
|
104
102
|
);
|
|
105
103
|
return {
|
|
@@ -111,5 +109,5 @@ var KakaoAuth = class {
|
|
|
111
109
|
};
|
|
112
110
|
// Annotate the CommonJS export names for ESM import in node:
|
|
113
111
|
0 && (module.exports = {
|
|
114
|
-
|
|
112
|
+
ThirdpartyAuthService
|
|
115
113
|
});
|
|
@@ -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,38 +42,36 @@ var INTERNAL_SERVER_ERROR = createException(
|
|
|
42
42
|
"\uC608\uAE30\uCE58 \uBABB\uD55C \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."
|
|
43
43
|
);
|
|
44
44
|
|
|
45
|
-
// src/auth
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
// src/auth/thirdparty_auth.ts
|
|
46
|
+
var ThirdpartyAuthService = class {
|
|
47
|
+
authService;
|
|
48
|
+
signupTokenSecret;
|
|
49
|
+
signupTokenExpiresIn;
|
|
50
|
+
constructor({
|
|
51
|
+
authService,
|
|
52
|
+
signupTokenSecret,
|
|
53
|
+
signupTokenExpiresIn = "1d"
|
|
54
|
+
}) {
|
|
55
|
+
this.authService = authService;
|
|
56
|
+
this.signupTokenSecret = signupTokenSecret;
|
|
57
|
+
this.signupTokenExpiresIn = signupTokenExpiresIn;
|
|
50
58
|
}
|
|
51
|
-
async
|
|
52
|
-
const
|
|
53
|
-
headers: {
|
|
54
|
-
Authorization: `Bearer ${kakaoAccessToken}`
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
if (!userRes.ok) {
|
|
58
|
-
throw new Error("\uC720\uC800 \uC815\uBCF4\uB97C \uAC00\uC838\uC624\uB294\uB370 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4.");
|
|
59
|
-
}
|
|
60
|
-
const { id, kakao_account } = await userRes.json();
|
|
61
|
-
const { email, profile } = kakao_account;
|
|
62
|
-
const payload = {
|
|
63
|
-
id,
|
|
64
|
-
email,
|
|
65
|
-
name: profile.nickname,
|
|
66
|
-
picture: profile.thumbnail_image_url
|
|
67
|
-
};
|
|
68
|
-
const user = await this.AUTH.findUser("kakao", payload);
|
|
59
|
+
async issueTokensIfUserFound(provider, payload) {
|
|
60
|
+
const user = await this.authService.findUser(provider, payload);
|
|
69
61
|
if (!user) {
|
|
62
|
+
const token = await this.authService.jwtManager.sign(
|
|
63
|
+
{ provider, ...payload },
|
|
64
|
+
this.signupTokenSecret,
|
|
65
|
+
{
|
|
66
|
+
expiresIn: this.signupTokenExpiresIn
|
|
67
|
+
}
|
|
68
|
+
);
|
|
70
69
|
throw createJsonResponse(404)({
|
|
71
|
-
|
|
72
|
-
...payload,
|
|
70
|
+
token,
|
|
73
71
|
message: "\uC0AC\uC6A9\uC790\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."
|
|
74
72
|
});
|
|
75
73
|
}
|
|
76
|
-
const { accessToken, refreshToken } = await this.
|
|
74
|
+
const { accessToken, refreshToken } = await this.authService.issueTokenPair(
|
|
77
75
|
user
|
|
78
76
|
);
|
|
79
77
|
return {
|
|
@@ -84,5 +82,5 @@ var KakaoAuth = class {
|
|
|
84
82
|
}
|
|
85
83
|
};
|
|
86
84
|
export {
|
|
87
|
-
|
|
85
|
+
ThirdpartyAuthService
|
|
88
86
|
};
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { LoaderFunctionArgs, ActionFunctionArgs } from 'react-router';
|
|
2
2
|
import { AuthService } from './auth_service.mjs';
|
|
3
|
-
import { JWTManager } from './jwt.mjs';
|
|
4
3
|
import { JWTPayload } from 'jose';
|
|
5
|
-
import '
|
|
4
|
+
import './jwt_manager.mjs';
|
|
5
|
+
import '../file/object_storage.mjs';
|
|
6
6
|
import '@aws-sdk/client-s3';
|
|
7
|
-
import './
|
|
7
|
+
import './auth_repository.mjs';
|
|
8
8
|
|
|
9
9
|
type Handler<T extends LoaderFunctionArgs | ActionFunctionArgs> = (arg: T) => Promise<unknown> | unknown;
|
|
10
10
|
type InputFN = (auth?: JWTPayload) => Handler<LoaderFunctionArgs> | Handler<ActionFunctionArgs>;
|
|
11
11
|
type WithAuthHandler<T extends LoaderFunctionArgs | ActionFunctionArgs> = (fn: InputFN) => Handler<T>;
|
|
12
|
-
declare function createWithAuthHandler<T extends LoaderFunctionArgs | ActionFunctionArgs>({
|
|
13
|
-
|
|
14
|
-
AUTH: AuthService;
|
|
12
|
+
declare function createWithAuthHandler<T extends LoaderFunctionArgs | ActionFunctionArgs>({ authService }: {
|
|
13
|
+
authService: AuthService;
|
|
15
14
|
}): <THandler extends Handler<T>>(fn: (auth?: JWTPayload) => THandler) => THandler;
|
|
16
15
|
|
|
17
16
|
export { type WithAuthHandler, createWithAuthHandler };
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { LoaderFunctionArgs, ActionFunctionArgs } from 'react-router';
|
|
2
2
|
import { AuthService } from './auth_service.js';
|
|
3
|
-
import { JWTManager } from './jwt.js';
|
|
4
3
|
import { JWTPayload } from 'jose';
|
|
5
|
-
import '
|
|
4
|
+
import './jwt_manager.js';
|
|
5
|
+
import '../file/object_storage.js';
|
|
6
6
|
import '@aws-sdk/client-s3';
|
|
7
|
-
import './
|
|
7
|
+
import './auth_repository.js';
|
|
8
8
|
|
|
9
9
|
type Handler<T extends LoaderFunctionArgs | ActionFunctionArgs> = (arg: T) => Promise<unknown> | unknown;
|
|
10
10
|
type InputFN = (auth?: JWTPayload) => Handler<LoaderFunctionArgs> | Handler<ActionFunctionArgs>;
|
|
11
11
|
type WithAuthHandler<T extends LoaderFunctionArgs | ActionFunctionArgs> = (fn: InputFN) => Handler<T>;
|
|
12
|
-
declare function createWithAuthHandler<T extends LoaderFunctionArgs | ActionFunctionArgs>({
|
|
13
|
-
|
|
14
|
-
AUTH: AuthService;
|
|
12
|
+
declare function createWithAuthHandler<T extends LoaderFunctionArgs | ActionFunctionArgs>({ authService }: {
|
|
13
|
+
authService: AuthService;
|
|
15
14
|
}): <THandler extends Handler<T>>(fn: (auth?: JWTPayload) => THandler) => THandler;
|
|
16
15
|
|
|
17
16
|
export { type WithAuthHandler, createWithAuthHandler };
|
|
@@ -17,27 +17,43 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// src/auth
|
|
20
|
+
// src/auth/with_auth.ts
|
|
21
21
|
var with_auth_exports = {};
|
|
22
22
|
__export(with_auth_exports, {
|
|
23
23
|
createWithAuthHandler: () => createWithAuthHandler
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(with_auth_exports);
|
|
26
|
-
function createWithAuthHandler({
|
|
26
|
+
function createWithAuthHandler({ authService }) {
|
|
27
27
|
return function(fn) {
|
|
28
28
|
const handler = async function(arg) {
|
|
29
|
-
const
|
|
29
|
+
const respond = async (auth) => {
|
|
30
|
+
const res = await fn(auth)(arg);
|
|
31
|
+
if (typeof res === "object" && res !== null && !Array.isArray(res)) {
|
|
32
|
+
if (res instanceof Response) {
|
|
33
|
+
if (res.status < 300 && res.body) {
|
|
34
|
+
console.log(res.body);
|
|
35
|
+
return res;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
AUTH: auth,
|
|
40
|
+
...res
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return res;
|
|
44
|
+
};
|
|
45
|
+
const accessToken = await authService.getAccessTokenFromRequest(arg.request);
|
|
30
46
|
if (accessToken) {
|
|
31
|
-
const payload = await
|
|
47
|
+
const payload = await authService.jwtManager.verifyAccessToken(accessToken);
|
|
32
48
|
if (payload) {
|
|
33
|
-
return
|
|
49
|
+
return respond(payload);
|
|
34
50
|
}
|
|
35
51
|
}
|
|
36
|
-
const refreshToken = await
|
|
52
|
+
const refreshToken = await authService.getRefreshTokenFromCookies(arg.request);
|
|
37
53
|
if (refreshToken) {
|
|
38
54
|
try {
|
|
39
|
-
const newAccessToken = await
|
|
40
|
-
const setCookieHeader = await
|
|
55
|
+
const newAccessToken = await authService.refreshAccessToken(refreshToken);
|
|
56
|
+
const setCookieHeader = await authService.getAccessTokenSetCookie(
|
|
41
57
|
newAccessToken
|
|
42
58
|
);
|
|
43
59
|
const headers = new Headers();
|
|
@@ -51,7 +67,7 @@ function createWithAuthHandler({ JWT_MANAGER, AUTH }) {
|
|
|
51
67
|
if (e instanceof Error) {
|
|
52
68
|
console.log(e.message);
|
|
53
69
|
}
|
|
54
|
-
const setCookieHeader = await
|
|
70
|
+
const setCookieHeader = await authService.getRefreshTokenSetCookie(null);
|
|
55
71
|
const headers = new Headers();
|
|
56
72
|
headers.append("Set-Cookie", setCookieHeader);
|
|
57
73
|
headers.append("Location", arg.request.url);
|
|
@@ -61,7 +77,7 @@ function createWithAuthHandler({ JWT_MANAGER, AUTH }) {
|
|
|
61
77
|
});
|
|
62
78
|
}
|
|
63
79
|
}
|
|
64
|
-
return
|
|
80
|
+
return respond(void 0);
|
|
65
81
|
};
|
|
66
82
|
return handler;
|
|
67
83
|
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// src/auth/with_auth.ts
|
|
2
|
+
function createWithAuthHandler({ authService }) {
|
|
3
|
+
return function(fn) {
|
|
4
|
+
const handler = async function(arg) {
|
|
5
|
+
const respond = async (auth) => {
|
|
6
|
+
const res = await fn(auth)(arg);
|
|
7
|
+
if (typeof res === "object" && res !== null && !Array.isArray(res)) {
|
|
8
|
+
if (res instanceof Response) {
|
|
9
|
+
if (res.status < 300 && res.body) {
|
|
10
|
+
console.log(res.body);
|
|
11
|
+
return res;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
AUTH: auth,
|
|
16
|
+
...res
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
return res;
|
|
20
|
+
};
|
|
21
|
+
const accessToken = await authService.getAccessTokenFromRequest(arg.request);
|
|
22
|
+
if (accessToken) {
|
|
23
|
+
const payload = await authService.jwtManager.verifyAccessToken(accessToken);
|
|
24
|
+
if (payload) {
|
|
25
|
+
return respond(payload);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const refreshToken = await authService.getRefreshTokenFromCookies(arg.request);
|
|
29
|
+
if (refreshToken) {
|
|
30
|
+
try {
|
|
31
|
+
const newAccessToken = await authService.refreshAccessToken(refreshToken);
|
|
32
|
+
const setCookieHeader = await authService.getAccessTokenSetCookie(
|
|
33
|
+
newAccessToken
|
|
34
|
+
);
|
|
35
|
+
const headers = new Headers();
|
|
36
|
+
headers.append("Set-Cookie", setCookieHeader);
|
|
37
|
+
headers.append("Location", arg.request.url);
|
|
38
|
+
return new Response("Temporary Redirect", {
|
|
39
|
+
status: 307,
|
|
40
|
+
headers
|
|
41
|
+
});
|
|
42
|
+
} catch (e) {
|
|
43
|
+
if (e instanceof Error) {
|
|
44
|
+
console.log(e.message);
|
|
45
|
+
}
|
|
46
|
+
const setCookieHeader = await authService.getRefreshTokenSetCookie(null);
|
|
47
|
+
const headers = new Headers();
|
|
48
|
+
headers.append("Set-Cookie", setCookieHeader);
|
|
49
|
+
headers.append("Location", arg.request.url);
|
|
50
|
+
return new Response("Temporary Redirect", {
|
|
51
|
+
status: 307,
|
|
52
|
+
headers
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return respond(void 0);
|
|
57
|
+
};
|
|
58
|
+
return handler;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
createWithAuthHandler
|
|
63
|
+
};
|
package/dist/date.d.mts
CHANGED
package/dist/date.d.ts
CHANGED
package/dist/date.js
CHANGED
|
@@ -30,7 +30,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/date.ts
|
|
31
31
|
var date_exports = {};
|
|
32
32
|
__export(date_exports, {
|
|
33
|
-
formatHumanDateTime: () => formatHumanDateTime
|
|
33
|
+
formatHumanDateTime: () => formatHumanDateTime,
|
|
34
|
+
moment: () => import_moment_timezone.default
|
|
34
35
|
});
|
|
35
36
|
module.exports = __toCommonJS(date_exports);
|
|
36
37
|
var import_moment_timezone = __toESM(require("moment-timezone"));
|
|
@@ -59,5 +60,6 @@ var formatHumanDateTime = (value) => {
|
|
|
59
60
|
};
|
|
60
61
|
// Annotate the CommonJS export names for ESM import in node:
|
|
61
62
|
0 && (module.exports = {
|
|
62
|
-
formatHumanDateTime
|
|
63
|
+
formatHumanDateTime,
|
|
64
|
+
moment
|
|
63
65
|
});
|
package/dist/date.mjs
CHANGED
|
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// src/file
|
|
20
|
+
// src/file/cdn.ts
|
|
21
21
|
var cdn_exports = {};
|
|
22
22
|
__export(cdn_exports, {
|
|
23
23
|
createCDN: () => createCDN
|
|
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
|
-
// src/file
|
|
30
|
+
// src/file/client/drop_file_input.tsx
|
|
31
31
|
var drop_file_input_exports = {};
|
|
32
32
|
__export(drop_file_input_exports, {
|
|
33
33
|
DropFileMessageBox: () => DropFileMessageBox,
|
|
@@ -42,7 +42,7 @@ function cn(...classes) {
|
|
|
42
42
|
return classes.filter(Boolean).join(" ").trim();
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
// src/file
|
|
45
|
+
// src/file/client/metadata.ts
|
|
46
46
|
function generateMetadata(blob) {
|
|
47
47
|
return new Promise((resolve, reject) => {
|
|
48
48
|
if (blob.type.startsWith("image/")) {
|
|
@@ -74,7 +74,7 @@ function generateMetadata(blob) {
|
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
// src/file
|
|
77
|
+
// src/file/client/drop_file_input.tsx
|
|
78
78
|
function createUseDropFileInput({
|
|
79
79
|
uploadFile
|
|
80
80
|
}) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/file
|
|
1
|
+
// src/file/client/drop_file_input.tsx
|
|
2
2
|
import React, {
|
|
3
3
|
useState,
|
|
4
4
|
useCallback,
|
|
@@ -13,7 +13,7 @@ function cn(...classes) {
|
|
|
13
13
|
return classes.filter(Boolean).join(" ").trim();
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
// src/file
|
|
16
|
+
// src/file/client/metadata.ts
|
|
17
17
|
function generateMetadata(blob) {
|
|
18
18
|
return new Promise((resolve, reject) => {
|
|
19
19
|
if (blob.type.startsWith("image/")) {
|
|
@@ -45,7 +45,7 @@ function generateMetadata(blob) {
|
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
// src/file
|
|
48
|
+
// src/file/client/drop_file_input.tsx
|
|
49
49
|
function createUseDropFileInput({
|
|
50
50
|
uploadFile
|
|
51
51
|
}) {
|