@hot-updater/console 0.13.0 → 0.13.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/index.cjs +153 -809
- package/dist/index.js +153 -809
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -5,29 +5,6 @@ import * as __WEBPACK_EXTERNAL_MODULE_url__ from "url";
|
|
|
5
5
|
import * as __WEBPACK_EXTERNAL_MODULE_fs__ from "fs";
|
|
6
6
|
import * as __WEBPACK_EXTERNAL_MODULE__hot_updater_plugin_core_40c1c502__ from "@hot-updater/plugin-core";
|
|
7
7
|
var __webpack_modules__ = {
|
|
8
|
-
"../../node_modules/.pnpm/@hono+typia-validator@0.1.0_hono@4.6.3_typia@8.0.3_@samchon+openapi@3.1.0_typescript@5.6.3_/node_modules/@hono/typia-validator/dist/cjs/index.js": function(__unused_webpack_module, exports, __webpack_require__) {
|
|
9
|
-
exports.typiaValidator = void 0;
|
|
10
|
-
const validator_1 = __webpack_require__("../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/validator/index.js");
|
|
11
|
-
const typiaValidator = (target, validate, hook)=>(0, validator_1.validator)(target, async (value, c)=>{
|
|
12
|
-
const result = validate(value);
|
|
13
|
-
if (hook) {
|
|
14
|
-
const hookResult = await hook({
|
|
15
|
-
...result,
|
|
16
|
-
data: value
|
|
17
|
-
}, c);
|
|
18
|
-
if (hookResult) {
|
|
19
|
-
if (hookResult instanceof Response || hookResult instanceof Promise) return hookResult;
|
|
20
|
-
if ('response' in hookResult) return hookResult.response;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
if (!result.success) return c.json({
|
|
24
|
-
success: false,
|
|
25
|
-
error: result.errors
|
|
26
|
-
}, 400);
|
|
27
|
-
return result.data;
|
|
28
|
-
});
|
|
29
|
-
exports.typiaValidator = typiaValidator;
|
|
30
|
-
},
|
|
31
8
|
"../../node_modules/.pnpm/typia@8.0.3_@samchon+openapi@3.1.0_typescript@5.6.3/node_modules/typia/lib/internal/_validateReport.js": function(__unused_webpack_module, exports) {
|
|
32
9
|
exports._validateReport = void 0;
|
|
33
10
|
const _validateReport = (array)=>{
|
|
@@ -42,788 +19,6 @@ var __webpack_modules__ = {
|
|
|
42
19
|
};
|
|
43
20
|
};
|
|
44
21
|
exports._validateReport = _validateReport;
|
|
45
|
-
},
|
|
46
|
-
"../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/helper/cookie/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
|
|
47
|
-
var __defProp = Object.defineProperty;
|
|
48
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
49
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
50
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
51
|
-
var __export = (target, all)=>{
|
|
52
|
-
for(var name in all)__defProp(target, name, {
|
|
53
|
-
get: all[name],
|
|
54
|
-
enumerable: true
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
var __copyProps = (to, from, except, desc)=>{
|
|
58
|
-
if (from && "object" == typeof from || "function" == typeof from) {
|
|
59
|
-
for (let key of __getOwnPropNames(from))if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
60
|
-
get: ()=>from[key],
|
|
61
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
return to;
|
|
65
|
-
};
|
|
66
|
-
var __toCommonJS = (mod)=>__copyProps(__defProp({}, "__esModule", {
|
|
67
|
-
value: true
|
|
68
|
-
}), mod);
|
|
69
|
-
var cookie_exports = {};
|
|
70
|
-
__export(cookie_exports, {
|
|
71
|
-
deleteCookie: ()=>deleteCookie,
|
|
72
|
-
getCookie: ()=>getCookie,
|
|
73
|
-
getSignedCookie: ()=>getSignedCookie,
|
|
74
|
-
setCookie: ()=>setCookie,
|
|
75
|
-
setSignedCookie: ()=>setSignedCookie
|
|
76
|
-
});
|
|
77
|
-
module.exports = __toCommonJS(cookie_exports);
|
|
78
|
-
var import_cookie = __webpack_require__("../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/utils/cookie.js");
|
|
79
|
-
const getCookie = (c, key, prefix)=>{
|
|
80
|
-
const cookie = c.req.raw.headers.get("Cookie");
|
|
81
|
-
if ("string" == typeof key) {
|
|
82
|
-
if (!cookie) return;
|
|
83
|
-
let finalKey = key;
|
|
84
|
-
if ("secure" === prefix) finalKey = "__Secure-" + key;
|
|
85
|
-
else if ("host" === prefix) finalKey = "__Host-" + key;
|
|
86
|
-
const obj2 = (0, import_cookie.parse)(cookie, finalKey);
|
|
87
|
-
return obj2[finalKey];
|
|
88
|
-
}
|
|
89
|
-
if (!cookie) return {};
|
|
90
|
-
const obj = (0, import_cookie.parse)(cookie);
|
|
91
|
-
return obj;
|
|
92
|
-
};
|
|
93
|
-
const getSignedCookie = async (c, secret, key, prefix)=>{
|
|
94
|
-
const cookie = c.req.raw.headers.get("Cookie");
|
|
95
|
-
if ("string" == typeof key) {
|
|
96
|
-
if (!cookie) return;
|
|
97
|
-
let finalKey = key;
|
|
98
|
-
if ("secure" === prefix) finalKey = "__Secure-" + key;
|
|
99
|
-
else if ("host" === prefix) finalKey = "__Host-" + key;
|
|
100
|
-
const obj2 = await (0, import_cookie.parseSigned)(cookie, secret, finalKey);
|
|
101
|
-
return obj2[finalKey];
|
|
102
|
-
}
|
|
103
|
-
if (!cookie) return {};
|
|
104
|
-
const obj = await (0, import_cookie.parseSigned)(cookie, secret);
|
|
105
|
-
return obj;
|
|
106
|
-
};
|
|
107
|
-
const setCookie = (c, name, value, opt)=>{
|
|
108
|
-
let cookie;
|
|
109
|
-
cookie = opt?.prefix === "secure" ? (0, import_cookie.serialize)("__Secure-" + name, value, {
|
|
110
|
-
path: "/",
|
|
111
|
-
...opt,
|
|
112
|
-
secure: true
|
|
113
|
-
}) : opt?.prefix === "host" ? (0, import_cookie.serialize)("__Host-" + name, value, {
|
|
114
|
-
...opt,
|
|
115
|
-
path: "/",
|
|
116
|
-
secure: true,
|
|
117
|
-
domain: void 0
|
|
118
|
-
}) : (0, import_cookie.serialize)(name, value, {
|
|
119
|
-
path: "/",
|
|
120
|
-
...opt
|
|
121
|
-
});
|
|
122
|
-
c.header("set-cookie", cookie, {
|
|
123
|
-
append: true
|
|
124
|
-
});
|
|
125
|
-
};
|
|
126
|
-
const setSignedCookie = async (c, name, value, secret, opt)=>{
|
|
127
|
-
let cookie;
|
|
128
|
-
cookie = opt?.prefix === "secure" ? await (0, import_cookie.serializeSigned)("__Secure-" + name, value, secret, {
|
|
129
|
-
path: "/",
|
|
130
|
-
...opt,
|
|
131
|
-
secure: true
|
|
132
|
-
}) : opt?.prefix === "host" ? await (0, import_cookie.serializeSigned)("__Host-" + name, value, secret, {
|
|
133
|
-
...opt,
|
|
134
|
-
path: "/",
|
|
135
|
-
secure: true,
|
|
136
|
-
domain: void 0
|
|
137
|
-
}) : await (0, import_cookie.serializeSigned)(name, value, secret, {
|
|
138
|
-
path: "/",
|
|
139
|
-
...opt
|
|
140
|
-
});
|
|
141
|
-
c.header("set-cookie", cookie, {
|
|
142
|
-
append: true
|
|
143
|
-
});
|
|
144
|
-
};
|
|
145
|
-
const deleteCookie = (c, name, opt)=>{
|
|
146
|
-
const deletedCookie = getCookie(c, name);
|
|
147
|
-
setCookie(c, name, "", {
|
|
148
|
-
...opt,
|
|
149
|
-
maxAge: 0
|
|
150
|
-
});
|
|
151
|
-
return deletedCookie;
|
|
152
|
-
};
|
|
153
|
-
},
|
|
154
|
-
"../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/http-exception.js": function(module) {
|
|
155
|
-
var __defProp = Object.defineProperty;
|
|
156
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
157
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
158
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
159
|
-
var __export = (target, all)=>{
|
|
160
|
-
for(var name in all)__defProp(target, name, {
|
|
161
|
-
get: all[name],
|
|
162
|
-
enumerable: true
|
|
163
|
-
});
|
|
164
|
-
};
|
|
165
|
-
var __copyProps = (to, from, except, desc)=>{
|
|
166
|
-
if (from && "object" == typeof from || "function" == typeof from) {
|
|
167
|
-
for (let key of __getOwnPropNames(from))if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
168
|
-
get: ()=>from[key],
|
|
169
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
return to;
|
|
173
|
-
};
|
|
174
|
-
var __toCommonJS = (mod)=>__copyProps(__defProp({}, "__esModule", {
|
|
175
|
-
value: true
|
|
176
|
-
}), mod);
|
|
177
|
-
var http_exception_exports = {};
|
|
178
|
-
__export(http_exception_exports, {
|
|
179
|
-
HTTPException: ()=>HTTPException
|
|
180
|
-
});
|
|
181
|
-
module.exports = __toCommonJS(http_exception_exports);
|
|
182
|
-
class HTTPException extends Error {
|
|
183
|
-
res;
|
|
184
|
-
status;
|
|
185
|
-
constructor(status = 500, options){
|
|
186
|
-
super(options?.message, {
|
|
187
|
-
cause: options?.cause
|
|
188
|
-
});
|
|
189
|
-
this.res = options?.res;
|
|
190
|
-
this.status = status;
|
|
191
|
-
}
|
|
192
|
-
getResponse() {
|
|
193
|
-
if (this.res) {
|
|
194
|
-
const newResponse = new Response(this.res.body, {
|
|
195
|
-
status: this.status,
|
|
196
|
-
headers: this.res.headers
|
|
197
|
-
});
|
|
198
|
-
return newResponse;
|
|
199
|
-
}
|
|
200
|
-
return new Response(this.message, {
|
|
201
|
-
status: this.status
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
},
|
|
206
|
-
"../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/utils/buffer.js": function(module, __unused_webpack_exports, __webpack_require__) {
|
|
207
|
-
var __defProp = Object.defineProperty;
|
|
208
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
209
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
210
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
211
|
-
var __export = (target, all)=>{
|
|
212
|
-
for(var name in all)__defProp(target, name, {
|
|
213
|
-
get: all[name],
|
|
214
|
-
enumerable: true
|
|
215
|
-
});
|
|
216
|
-
};
|
|
217
|
-
var __copyProps = (to, from, except, desc)=>{
|
|
218
|
-
if (from && "object" == typeof from || "function" == typeof from) {
|
|
219
|
-
for (let key of __getOwnPropNames(from))if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
220
|
-
get: ()=>from[key],
|
|
221
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
return to;
|
|
225
|
-
};
|
|
226
|
-
var __toCommonJS = (mod)=>__copyProps(__defProp({}, "__esModule", {
|
|
227
|
-
value: true
|
|
228
|
-
}), mod);
|
|
229
|
-
var buffer_exports = {};
|
|
230
|
-
__export(buffer_exports, {
|
|
231
|
-
bufferToFormData: ()=>bufferToFormData,
|
|
232
|
-
bufferToString: ()=>bufferToString,
|
|
233
|
-
equal: ()=>equal,
|
|
234
|
-
timingSafeEqual: ()=>timingSafeEqual
|
|
235
|
-
});
|
|
236
|
-
module.exports = __toCommonJS(buffer_exports);
|
|
237
|
-
var import_crypto = __webpack_require__("../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/utils/crypto.js");
|
|
238
|
-
const equal = (a, b)=>{
|
|
239
|
-
if (a === b) return true;
|
|
240
|
-
if (a.byteLength !== b.byteLength) return false;
|
|
241
|
-
const va = new DataView(a);
|
|
242
|
-
const vb = new DataView(b);
|
|
243
|
-
let i = va.byteLength;
|
|
244
|
-
while(i--)if (va.getUint8(i) !== vb.getUint8(i)) return false;
|
|
245
|
-
return true;
|
|
246
|
-
};
|
|
247
|
-
const timingSafeEqual = async (a, b, hashFunction)=>{
|
|
248
|
-
if (!hashFunction) hashFunction = import_crypto.sha256;
|
|
249
|
-
const [sa, sb] = await Promise.all([
|
|
250
|
-
hashFunction(a),
|
|
251
|
-
hashFunction(b)
|
|
252
|
-
]);
|
|
253
|
-
if (!sa || !sb) return false;
|
|
254
|
-
return sa === sb && a === b;
|
|
255
|
-
};
|
|
256
|
-
const bufferToString = (buffer)=>{
|
|
257
|
-
if (buffer instanceof ArrayBuffer) {
|
|
258
|
-
const enc = new TextDecoder("utf-8");
|
|
259
|
-
return enc.decode(buffer);
|
|
260
|
-
}
|
|
261
|
-
return buffer;
|
|
262
|
-
};
|
|
263
|
-
const bufferToFormData = (arrayBuffer, contentType)=>{
|
|
264
|
-
const response = new Response(arrayBuffer, {
|
|
265
|
-
headers: {
|
|
266
|
-
"Content-Type": contentType
|
|
267
|
-
}
|
|
268
|
-
});
|
|
269
|
-
return response.formData();
|
|
270
|
-
};
|
|
271
|
-
},
|
|
272
|
-
"../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/utils/cookie.js": function(module, __unused_webpack_exports, __webpack_require__) {
|
|
273
|
-
var __defProp = Object.defineProperty;
|
|
274
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
275
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
276
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
277
|
-
var __export = (target, all)=>{
|
|
278
|
-
for(var name in all)__defProp(target, name, {
|
|
279
|
-
get: all[name],
|
|
280
|
-
enumerable: true
|
|
281
|
-
});
|
|
282
|
-
};
|
|
283
|
-
var __copyProps = (to, from, except, desc)=>{
|
|
284
|
-
if (from && "object" == typeof from || "function" == typeof from) {
|
|
285
|
-
for (let key of __getOwnPropNames(from))if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
286
|
-
get: ()=>from[key],
|
|
287
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
return to;
|
|
291
|
-
};
|
|
292
|
-
var __toCommonJS = (mod)=>__copyProps(__defProp({}, "__esModule", {
|
|
293
|
-
value: true
|
|
294
|
-
}), mod);
|
|
295
|
-
var cookie_exports = {};
|
|
296
|
-
__export(cookie_exports, {
|
|
297
|
-
parse: ()=>parse,
|
|
298
|
-
parseSigned: ()=>parseSigned,
|
|
299
|
-
serialize: ()=>serialize,
|
|
300
|
-
serializeSigned: ()=>serializeSigned
|
|
301
|
-
});
|
|
302
|
-
module.exports = __toCommonJS(cookie_exports);
|
|
303
|
-
var import_url = __webpack_require__("../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/utils/url.js");
|
|
304
|
-
const algorithm = {
|
|
305
|
-
name: "HMAC",
|
|
306
|
-
hash: "SHA-256"
|
|
307
|
-
};
|
|
308
|
-
const getCryptoKey = async (secret)=>{
|
|
309
|
-
const secretBuf = "string" == typeof secret ? new TextEncoder().encode(secret) : secret;
|
|
310
|
-
return await crypto.subtle.importKey("raw", secretBuf, algorithm, false, [
|
|
311
|
-
"sign",
|
|
312
|
-
"verify"
|
|
313
|
-
]);
|
|
314
|
-
};
|
|
315
|
-
const makeSignature = async (value, secret)=>{
|
|
316
|
-
const key = await getCryptoKey(secret);
|
|
317
|
-
const signature = await crypto.subtle.sign(algorithm.name, key, new TextEncoder().encode(value));
|
|
318
|
-
return btoa(String.fromCharCode(...new Uint8Array(signature)));
|
|
319
|
-
};
|
|
320
|
-
const verifySignature = async (base64Signature, value, secret)=>{
|
|
321
|
-
try {
|
|
322
|
-
const signatureBinStr = atob(base64Signature);
|
|
323
|
-
const signature = new Uint8Array(signatureBinStr.length);
|
|
324
|
-
for(let i = 0, len = signatureBinStr.length; i < len; i++)signature[i] = signatureBinStr.charCodeAt(i);
|
|
325
|
-
return await crypto.subtle.verify(algorithm, secret, signature, new TextEncoder().encode(value));
|
|
326
|
-
} catch {
|
|
327
|
-
return false;
|
|
328
|
-
}
|
|
329
|
-
};
|
|
330
|
-
const validCookieNameRegEx = /^[\w!#$%&'*.^`|~+-]+$/;
|
|
331
|
-
const validCookieValueRegEx = /^[ !#-:<-[\]-~]*$/;
|
|
332
|
-
const parse = (cookie, name)=>{
|
|
333
|
-
const pairs = cookie.trim().split(";");
|
|
334
|
-
return pairs.reduce((parsedCookie, pairStr)=>{
|
|
335
|
-
pairStr = pairStr.trim();
|
|
336
|
-
const valueStartPos = pairStr.indexOf("=");
|
|
337
|
-
if (-1 === valueStartPos) return parsedCookie;
|
|
338
|
-
const cookieName = pairStr.substring(0, valueStartPos).trim();
|
|
339
|
-
if (name && name !== cookieName || !validCookieNameRegEx.test(cookieName)) return parsedCookie;
|
|
340
|
-
let cookieValue = pairStr.substring(valueStartPos + 1).trim();
|
|
341
|
-
if (cookieValue.startsWith('"') && cookieValue.endsWith('"')) cookieValue = cookieValue.slice(1, -1);
|
|
342
|
-
if (validCookieValueRegEx.test(cookieValue)) parsedCookie[cookieName] = (0, import_url.decodeURIComponent_)(cookieValue);
|
|
343
|
-
return parsedCookie;
|
|
344
|
-
}, {});
|
|
345
|
-
};
|
|
346
|
-
const parseSigned = async (cookie, secret, name)=>{
|
|
347
|
-
const parsedCookie = {};
|
|
348
|
-
const secretKey = await getCryptoKey(secret);
|
|
349
|
-
for (const [key, value] of Object.entries(parse(cookie, name))){
|
|
350
|
-
const signatureStartPos = value.lastIndexOf(".");
|
|
351
|
-
if (signatureStartPos < 1) continue;
|
|
352
|
-
const signedValue = value.substring(0, signatureStartPos);
|
|
353
|
-
const signature = value.substring(signatureStartPos + 1);
|
|
354
|
-
if (44 !== signature.length || !signature.endsWith("=")) continue;
|
|
355
|
-
const isVerified = await verifySignature(signature, signedValue, secretKey);
|
|
356
|
-
parsedCookie[key] = isVerified ? signedValue : false;
|
|
357
|
-
}
|
|
358
|
-
return parsedCookie;
|
|
359
|
-
};
|
|
360
|
-
const _serialize = (name, value, opt = {})=>{
|
|
361
|
-
let cookie = `${name}=${value}`;
|
|
362
|
-
if (name.startsWith("__Secure-") && !opt.secure) throw new Error("__Secure- Cookie must have Secure attributes");
|
|
363
|
-
if (name.startsWith("__Host-")) {
|
|
364
|
-
if (!opt.secure) throw new Error("__Host- Cookie must have Secure attributes");
|
|
365
|
-
if ("/" !== opt.path) throw new Error('__Host- Cookie must have Path attributes with "/"');
|
|
366
|
-
if (opt.domain) throw new Error("__Host- Cookie must not have Domain attributes");
|
|
367
|
-
}
|
|
368
|
-
if (opt && "number" == typeof opt.maxAge && opt.maxAge >= 0) {
|
|
369
|
-
if (opt.maxAge > 3456e4) throw new Error("Cookies Max-Age SHOULD NOT be greater than 400 days (34560000 seconds) in duration.");
|
|
370
|
-
cookie += `; Max-Age=${Math.floor(opt.maxAge)}`;
|
|
371
|
-
}
|
|
372
|
-
if (opt.domain && "host" !== opt.prefix) cookie += `; Domain=${opt.domain}`;
|
|
373
|
-
if (opt.path) cookie += `; Path=${opt.path}`;
|
|
374
|
-
if (opt.expires) {
|
|
375
|
-
if (opt.expires.getTime() - Date.now() > 3456e7) throw new Error("Cookies Expires SHOULD NOT be greater than 400 days (34560000 seconds) in the future.");
|
|
376
|
-
cookie += `; Expires=${opt.expires.toUTCString()}`;
|
|
377
|
-
}
|
|
378
|
-
if (opt.httpOnly) cookie += "; HttpOnly";
|
|
379
|
-
if (opt.secure) cookie += "; Secure";
|
|
380
|
-
if (opt.sameSite) cookie += `; SameSite=${opt.sameSite.charAt(0).toUpperCase() + opt.sameSite.slice(1)}`;
|
|
381
|
-
if (opt.partitioned) {
|
|
382
|
-
if (!opt.secure) throw new Error("Partitioned Cookie must have Secure attributes");
|
|
383
|
-
cookie += "; Partitioned";
|
|
384
|
-
}
|
|
385
|
-
return cookie;
|
|
386
|
-
};
|
|
387
|
-
const serialize = (name, value, opt)=>{
|
|
388
|
-
value = encodeURIComponent(value);
|
|
389
|
-
return _serialize(name, value, opt);
|
|
390
|
-
};
|
|
391
|
-
const serializeSigned = async (name, value, secret, opt = {})=>{
|
|
392
|
-
const signature = await makeSignature(value, secret);
|
|
393
|
-
value = `${value}.${signature}`;
|
|
394
|
-
value = encodeURIComponent(value);
|
|
395
|
-
return _serialize(name, value, opt);
|
|
396
|
-
};
|
|
397
|
-
},
|
|
398
|
-
"../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/utils/crypto.js": function(module) {
|
|
399
|
-
var __defProp = Object.defineProperty;
|
|
400
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
401
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
402
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
403
|
-
var __export = (target, all)=>{
|
|
404
|
-
for(var name in all)__defProp(target, name, {
|
|
405
|
-
get: all[name],
|
|
406
|
-
enumerable: true
|
|
407
|
-
});
|
|
408
|
-
};
|
|
409
|
-
var __copyProps = (to, from, except, desc)=>{
|
|
410
|
-
if (from && "object" == typeof from || "function" == typeof from) {
|
|
411
|
-
for (let key of __getOwnPropNames(from))if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
412
|
-
get: ()=>from[key],
|
|
413
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
return to;
|
|
417
|
-
};
|
|
418
|
-
var __toCommonJS = (mod)=>__copyProps(__defProp({}, "__esModule", {
|
|
419
|
-
value: true
|
|
420
|
-
}), mod);
|
|
421
|
-
var crypto_exports = {};
|
|
422
|
-
__export(crypto_exports, {
|
|
423
|
-
createHash: ()=>createHash,
|
|
424
|
-
md5: ()=>md5,
|
|
425
|
-
sha1: ()=>sha1,
|
|
426
|
-
sha256: ()=>sha256
|
|
427
|
-
});
|
|
428
|
-
module.exports = __toCommonJS(crypto_exports);
|
|
429
|
-
const sha256 = async (data)=>{
|
|
430
|
-
const algorithm = {
|
|
431
|
-
name: "SHA-256",
|
|
432
|
-
alias: "sha256"
|
|
433
|
-
};
|
|
434
|
-
const hash = await createHash(data, algorithm);
|
|
435
|
-
return hash;
|
|
436
|
-
};
|
|
437
|
-
const sha1 = async (data)=>{
|
|
438
|
-
const algorithm = {
|
|
439
|
-
name: "SHA-1",
|
|
440
|
-
alias: "sha1"
|
|
441
|
-
};
|
|
442
|
-
const hash = await createHash(data, algorithm);
|
|
443
|
-
return hash;
|
|
444
|
-
};
|
|
445
|
-
const md5 = async (data)=>{
|
|
446
|
-
const algorithm = {
|
|
447
|
-
name: "MD5",
|
|
448
|
-
alias: "md5"
|
|
449
|
-
};
|
|
450
|
-
const hash = await createHash(data, algorithm);
|
|
451
|
-
return hash;
|
|
452
|
-
};
|
|
453
|
-
const createHash = async (data, algorithm)=>{
|
|
454
|
-
let sourceBuffer;
|
|
455
|
-
if (data instanceof ReadableStream) {
|
|
456
|
-
let body = "";
|
|
457
|
-
const reader = data.getReader();
|
|
458
|
-
await reader?.read().then(async (chuck)=>{
|
|
459
|
-
const value = await createHash(chuck.value || "", algorithm);
|
|
460
|
-
body += value;
|
|
461
|
-
});
|
|
462
|
-
return body;
|
|
463
|
-
}
|
|
464
|
-
if (ArrayBuffer.isView(data) || data instanceof ArrayBuffer) sourceBuffer = data;
|
|
465
|
-
else {
|
|
466
|
-
if ("object" == typeof data) data = JSON.stringify(data);
|
|
467
|
-
sourceBuffer = new TextEncoder().encode(String(data));
|
|
468
|
-
}
|
|
469
|
-
if (crypto && crypto.subtle) {
|
|
470
|
-
const buffer = await crypto.subtle.digest({
|
|
471
|
-
name: algorithm.name
|
|
472
|
-
}, sourceBuffer);
|
|
473
|
-
const hash = Array.prototype.map.call(new Uint8Array(buffer), (x)=>("00" + x.toString(16)).slice(-2)).join("");
|
|
474
|
-
return hash;
|
|
475
|
-
}
|
|
476
|
-
return null;
|
|
477
|
-
};
|
|
478
|
-
},
|
|
479
|
-
"../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/utils/url.js": function(module) {
|
|
480
|
-
var __defProp = Object.defineProperty;
|
|
481
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
482
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
483
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
484
|
-
var __export = (target, all)=>{
|
|
485
|
-
for(var name in all)__defProp(target, name, {
|
|
486
|
-
get: all[name],
|
|
487
|
-
enumerable: true
|
|
488
|
-
});
|
|
489
|
-
};
|
|
490
|
-
var __copyProps = (to, from, except, desc)=>{
|
|
491
|
-
if (from && "object" == typeof from || "function" == typeof from) {
|
|
492
|
-
for (let key of __getOwnPropNames(from))if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
493
|
-
get: ()=>from[key],
|
|
494
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
495
|
-
});
|
|
496
|
-
}
|
|
497
|
-
return to;
|
|
498
|
-
};
|
|
499
|
-
var __toCommonJS = (mod)=>__copyProps(__defProp({}, "__esModule", {
|
|
500
|
-
value: true
|
|
501
|
-
}), mod);
|
|
502
|
-
var url_exports = {};
|
|
503
|
-
__export(url_exports, {
|
|
504
|
-
checkOptionalParameter: ()=>checkOptionalParameter,
|
|
505
|
-
decodeURIComponent_: ()=>decodeURIComponent_,
|
|
506
|
-
getPath: ()=>getPath,
|
|
507
|
-
getPathNoStrict: ()=>getPathNoStrict,
|
|
508
|
-
getPattern: ()=>getPattern,
|
|
509
|
-
getQueryParam: ()=>getQueryParam,
|
|
510
|
-
getQueryParams: ()=>getQueryParams,
|
|
511
|
-
getQueryStrings: ()=>getQueryStrings,
|
|
512
|
-
mergePath: ()=>mergePath,
|
|
513
|
-
splitPath: ()=>splitPath,
|
|
514
|
-
splitRoutingPath: ()=>splitRoutingPath
|
|
515
|
-
});
|
|
516
|
-
module.exports = __toCommonJS(url_exports);
|
|
517
|
-
const splitPath = (path)=>{
|
|
518
|
-
const paths = path.split("/");
|
|
519
|
-
if ("" === paths[0]) paths.shift();
|
|
520
|
-
return paths;
|
|
521
|
-
};
|
|
522
|
-
const splitRoutingPath = (routePath)=>{
|
|
523
|
-
const { groups, path } = extractGroupsFromPath(routePath);
|
|
524
|
-
const paths = splitPath(path);
|
|
525
|
-
return replaceGroupMarks(paths, groups);
|
|
526
|
-
};
|
|
527
|
-
const extractGroupsFromPath = (path)=>{
|
|
528
|
-
const groups = [];
|
|
529
|
-
path = path.replace(/\{[^}]+\}/g, (match, index)=>{
|
|
530
|
-
const mark = `@${index}`;
|
|
531
|
-
groups.push([
|
|
532
|
-
mark,
|
|
533
|
-
match
|
|
534
|
-
]);
|
|
535
|
-
return mark;
|
|
536
|
-
});
|
|
537
|
-
return {
|
|
538
|
-
groups,
|
|
539
|
-
path
|
|
540
|
-
};
|
|
541
|
-
};
|
|
542
|
-
const replaceGroupMarks = (paths, groups)=>{
|
|
543
|
-
for(let i = groups.length - 1; i >= 0; i--){
|
|
544
|
-
const [mark] = groups[i];
|
|
545
|
-
for(let j = paths.length - 1; j >= 0; j--)if (paths[j].includes(mark)) {
|
|
546
|
-
paths[j] = paths[j].replace(mark, groups[i][1]);
|
|
547
|
-
break;
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
return paths;
|
|
551
|
-
};
|
|
552
|
-
const patternCache = {};
|
|
553
|
-
const getPattern = (label)=>{
|
|
554
|
-
if ("*" === label) return "*";
|
|
555
|
-
const match = label.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
|
|
556
|
-
if (match) {
|
|
557
|
-
if (!patternCache[label]) {
|
|
558
|
-
if (match[2]) patternCache[label] = [
|
|
559
|
-
label,
|
|
560
|
-
match[1],
|
|
561
|
-
new RegExp("^" + match[2] + "$")
|
|
562
|
-
];
|
|
563
|
-
else patternCache[label] = [
|
|
564
|
-
label,
|
|
565
|
-
match[1],
|
|
566
|
-
true
|
|
567
|
-
];
|
|
568
|
-
}
|
|
569
|
-
return patternCache[label];
|
|
570
|
-
}
|
|
571
|
-
return null;
|
|
572
|
-
};
|
|
573
|
-
const tryDecodeURI = (str)=>{
|
|
574
|
-
try {
|
|
575
|
-
return decodeURI(str);
|
|
576
|
-
} catch {
|
|
577
|
-
return str.replace(/(?:%[0-9A-Fa-f]{2})+/g, (match)=>{
|
|
578
|
-
try {
|
|
579
|
-
return decodeURI(match);
|
|
580
|
-
} catch {
|
|
581
|
-
return match;
|
|
582
|
-
}
|
|
583
|
-
});
|
|
584
|
-
}
|
|
585
|
-
};
|
|
586
|
-
const getPath = (request)=>{
|
|
587
|
-
const url = request.url;
|
|
588
|
-
const start = url.indexOf("/", 8);
|
|
589
|
-
let i = start;
|
|
590
|
-
for(; i < url.length; i++){
|
|
591
|
-
const charCode = url.charCodeAt(i);
|
|
592
|
-
if (37 === charCode) {
|
|
593
|
-
const queryIndex = url.indexOf("?", i);
|
|
594
|
-
const path = url.slice(start, -1 === queryIndex ? void 0 : queryIndex);
|
|
595
|
-
return tryDecodeURI(path.includes("%25") ? path.replace(/%25/g, "%2525") : path);
|
|
596
|
-
}
|
|
597
|
-
if (63 === charCode) break;
|
|
598
|
-
}
|
|
599
|
-
return url.slice(start, i);
|
|
600
|
-
};
|
|
601
|
-
const getQueryStrings = (url)=>{
|
|
602
|
-
const queryIndex = url.indexOf("?", 8);
|
|
603
|
-
return -1 === queryIndex ? "" : "?" + url.slice(queryIndex + 1);
|
|
604
|
-
};
|
|
605
|
-
const getPathNoStrict = (request)=>{
|
|
606
|
-
const result = getPath(request);
|
|
607
|
-
return result.length > 1 && "/" === result[result.length - 1] ? result.slice(0, -1) : result;
|
|
608
|
-
};
|
|
609
|
-
const mergePath = (...paths)=>{
|
|
610
|
-
let p = "";
|
|
611
|
-
let endsWithSlash = false;
|
|
612
|
-
for (let path of paths){
|
|
613
|
-
if ("/" === p[p.length - 1]) {
|
|
614
|
-
p = p.slice(0, -1);
|
|
615
|
-
endsWithSlash = true;
|
|
616
|
-
}
|
|
617
|
-
if ("/" !== path[0]) path = `/${path}`;
|
|
618
|
-
if ("/" === path && endsWithSlash) p = `${p}/`;
|
|
619
|
-
else if ("/" !== path) p = `${p}${path}`;
|
|
620
|
-
if ("/" === path && "" === p) p = "/";
|
|
621
|
-
}
|
|
622
|
-
return p;
|
|
623
|
-
};
|
|
624
|
-
const checkOptionalParameter = (path)=>{
|
|
625
|
-
if (!path.match(/\:.+\?$/)) return null;
|
|
626
|
-
const segments = path.split("/");
|
|
627
|
-
const results = [];
|
|
628
|
-
let basePath = "";
|
|
629
|
-
segments.forEach((segment)=>{
|
|
630
|
-
if ("" === segment || /\:/.test(segment)) {
|
|
631
|
-
if (/\:/.test(segment)) {
|
|
632
|
-
if (/\?/.test(segment)) {
|
|
633
|
-
if (0 === results.length && "" === basePath) results.push("/");
|
|
634
|
-
else results.push(basePath);
|
|
635
|
-
const optionalSegment = segment.replace("?", "");
|
|
636
|
-
basePath += "/" + optionalSegment;
|
|
637
|
-
results.push(basePath);
|
|
638
|
-
} else basePath += "/" + segment;
|
|
639
|
-
}
|
|
640
|
-
} else basePath += "/" + segment;
|
|
641
|
-
});
|
|
642
|
-
return results.filter((v, i, a)=>a.indexOf(v) === i);
|
|
643
|
-
};
|
|
644
|
-
const _decodeURI = (value)=>{
|
|
645
|
-
if (!/[%+]/.test(value)) return value;
|
|
646
|
-
if (-1 !== value.indexOf("+")) value = value.replace(/\+/g, " ");
|
|
647
|
-
return /%/.test(value) ? decodeURIComponent_(value) : value;
|
|
648
|
-
};
|
|
649
|
-
const _getQueryParam = (url, key, multiple)=>{
|
|
650
|
-
let encoded;
|
|
651
|
-
if (!multiple && key && !/[%+]/.test(key)) {
|
|
652
|
-
let keyIndex2 = url.indexOf(`?${key}`, 8);
|
|
653
|
-
if (-1 === keyIndex2) keyIndex2 = url.indexOf(`&${key}`, 8);
|
|
654
|
-
while(-1 !== keyIndex2){
|
|
655
|
-
const trailingKeyCode = url.charCodeAt(keyIndex2 + key.length + 1);
|
|
656
|
-
if (61 === trailingKeyCode) {
|
|
657
|
-
const valueIndex = keyIndex2 + key.length + 2;
|
|
658
|
-
const endIndex = url.indexOf("&", valueIndex);
|
|
659
|
-
return _decodeURI(url.slice(valueIndex, -1 === endIndex ? void 0 : endIndex));
|
|
660
|
-
}
|
|
661
|
-
if (38 == trailingKeyCode || isNaN(trailingKeyCode)) return "";
|
|
662
|
-
keyIndex2 = url.indexOf(`&${key}`, keyIndex2 + 1);
|
|
663
|
-
}
|
|
664
|
-
encoded = /[%+]/.test(url);
|
|
665
|
-
if (!encoded) return;
|
|
666
|
-
}
|
|
667
|
-
const results = {};
|
|
668
|
-
encoded ??= /[%+]/.test(url);
|
|
669
|
-
let keyIndex = url.indexOf("?", 8);
|
|
670
|
-
while(-1 !== keyIndex){
|
|
671
|
-
const nextKeyIndex = url.indexOf("&", keyIndex + 1);
|
|
672
|
-
let valueIndex = url.indexOf("=", keyIndex);
|
|
673
|
-
if (valueIndex > nextKeyIndex && -1 !== nextKeyIndex) valueIndex = -1;
|
|
674
|
-
let name = url.slice(keyIndex + 1, -1 === valueIndex ? -1 === nextKeyIndex ? void 0 : nextKeyIndex : valueIndex);
|
|
675
|
-
if (encoded) name = _decodeURI(name);
|
|
676
|
-
keyIndex = nextKeyIndex;
|
|
677
|
-
if ("" === name) continue;
|
|
678
|
-
let value;
|
|
679
|
-
if (-1 === valueIndex) value = "";
|
|
680
|
-
else {
|
|
681
|
-
value = url.slice(valueIndex + 1, -1 === nextKeyIndex ? void 0 : nextKeyIndex);
|
|
682
|
-
if (encoded) value = _decodeURI(value);
|
|
683
|
-
}
|
|
684
|
-
if (multiple) {
|
|
685
|
-
if (!(results[name] && Array.isArray(results[name]))) results[name] = [];
|
|
686
|
-
results[name].push(value);
|
|
687
|
-
} else results[name] ??= value;
|
|
688
|
-
}
|
|
689
|
-
return key ? results[key] : results;
|
|
690
|
-
};
|
|
691
|
-
const getQueryParam = _getQueryParam;
|
|
692
|
-
const getQueryParams = (url, key)=>_getQueryParam(url, key, true);
|
|
693
|
-
const decodeURIComponent_ = decodeURIComponent;
|
|
694
|
-
},
|
|
695
|
-
"../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/validator/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
|
|
696
|
-
var __defProp = Object.defineProperty;
|
|
697
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
698
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
699
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
700
|
-
var __export = (target, all)=>{
|
|
701
|
-
for(var name in all)__defProp(target, name, {
|
|
702
|
-
get: all[name],
|
|
703
|
-
enumerable: true
|
|
704
|
-
});
|
|
705
|
-
};
|
|
706
|
-
var __copyProps = (to, from, except, desc)=>{
|
|
707
|
-
if (from && "object" == typeof from || "function" == typeof from) {
|
|
708
|
-
for (let key of __getOwnPropNames(from))if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
709
|
-
get: ()=>from[key],
|
|
710
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
711
|
-
});
|
|
712
|
-
}
|
|
713
|
-
return to;
|
|
714
|
-
};
|
|
715
|
-
var __toCommonJS = (mod)=>__copyProps(__defProp({}, "__esModule", {
|
|
716
|
-
value: true
|
|
717
|
-
}), mod);
|
|
718
|
-
var validator_exports = {};
|
|
719
|
-
__export(validator_exports, {
|
|
720
|
-
validator: ()=>import_validator.validator
|
|
721
|
-
});
|
|
722
|
-
module.exports = __toCommonJS(validator_exports);
|
|
723
|
-
var import_validator = __webpack_require__("../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/validator/validator.js");
|
|
724
|
-
},
|
|
725
|
-
"../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/validator/validator.js": function(module, __unused_webpack_exports, __webpack_require__) {
|
|
726
|
-
var __defProp = Object.defineProperty;
|
|
727
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
728
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
729
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
730
|
-
var __export = (target, all)=>{
|
|
731
|
-
for(var name in all)__defProp(target, name, {
|
|
732
|
-
get: all[name],
|
|
733
|
-
enumerable: true
|
|
734
|
-
});
|
|
735
|
-
};
|
|
736
|
-
var __copyProps = (to, from, except, desc)=>{
|
|
737
|
-
if (from && "object" == typeof from || "function" == typeof from) {
|
|
738
|
-
for (let key of __getOwnPropNames(from))if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
739
|
-
get: ()=>from[key],
|
|
740
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
741
|
-
});
|
|
742
|
-
}
|
|
743
|
-
return to;
|
|
744
|
-
};
|
|
745
|
-
var __toCommonJS = (mod)=>__copyProps(__defProp({}, "__esModule", {
|
|
746
|
-
value: true
|
|
747
|
-
}), mod);
|
|
748
|
-
var validator_exports = {};
|
|
749
|
-
__export(validator_exports, {
|
|
750
|
-
validator: ()=>validator
|
|
751
|
-
});
|
|
752
|
-
module.exports = __toCommonJS(validator_exports);
|
|
753
|
-
var import_cookie = __webpack_require__("../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/helper/cookie/index.js");
|
|
754
|
-
var import_http_exception = __webpack_require__("../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/http-exception.js");
|
|
755
|
-
var import_buffer = __webpack_require__("../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/utils/buffer.js");
|
|
756
|
-
const jsonRegex = /^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/;
|
|
757
|
-
const multipartRegex = /^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/;
|
|
758
|
-
const urlencodedRegex = /^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/;
|
|
759
|
-
const validator = (target, validationFunc)=>async (c, next)=>{
|
|
760
|
-
let value = {};
|
|
761
|
-
const contentType = c.req.header("Content-Type");
|
|
762
|
-
switch(target){
|
|
763
|
-
case "json":
|
|
764
|
-
if (!contentType || !jsonRegex.test(contentType)) break;
|
|
765
|
-
try {
|
|
766
|
-
value = await c.req.json();
|
|
767
|
-
} catch {
|
|
768
|
-
const message = "Malformed JSON in request body";
|
|
769
|
-
throw new import_http_exception.HTTPException(400, {
|
|
770
|
-
message
|
|
771
|
-
});
|
|
772
|
-
}
|
|
773
|
-
break;
|
|
774
|
-
case "form":
|
|
775
|
-
{
|
|
776
|
-
if (!contentType || !(multipartRegex.test(contentType) || urlencodedRegex.test(contentType))) break;
|
|
777
|
-
let formData;
|
|
778
|
-
if (c.req.bodyCache.formData) formData = await c.req.bodyCache.formData;
|
|
779
|
-
else try {
|
|
780
|
-
const arrayBuffer = await c.req.arrayBuffer();
|
|
781
|
-
formData = await (0, import_buffer.bufferToFormData)(arrayBuffer, contentType);
|
|
782
|
-
c.req.bodyCache.formData = formData;
|
|
783
|
-
} catch (e) {
|
|
784
|
-
let message = "Malformed FormData request.";
|
|
785
|
-
message += e instanceof Error ? ` ${e.message}` : ` ${String(e)}`;
|
|
786
|
-
throw new import_http_exception.HTTPException(400, {
|
|
787
|
-
message
|
|
788
|
-
});
|
|
789
|
-
}
|
|
790
|
-
const form = {};
|
|
791
|
-
formData.forEach((value2, key)=>{
|
|
792
|
-
if (key.endsWith("[]")) (form[key] ??= []).push(value2);
|
|
793
|
-
else if (Array.isArray(form[key])) form[key].push(value2);
|
|
794
|
-
else if (key in form) form[key] = [
|
|
795
|
-
form[key],
|
|
796
|
-
value2
|
|
797
|
-
];
|
|
798
|
-
else form[key] = value2;
|
|
799
|
-
});
|
|
800
|
-
value = form;
|
|
801
|
-
break;
|
|
802
|
-
}
|
|
803
|
-
case "query":
|
|
804
|
-
value = Object.fromEntries(Object.entries(c.req.queries()).map(([k, v])=>1 === v.length ? [
|
|
805
|
-
k,
|
|
806
|
-
v[0]
|
|
807
|
-
] : [
|
|
808
|
-
k,
|
|
809
|
-
v
|
|
810
|
-
]));
|
|
811
|
-
break;
|
|
812
|
-
case "param":
|
|
813
|
-
value = c.req.param();
|
|
814
|
-
break;
|
|
815
|
-
case "header":
|
|
816
|
-
value = c.req.header();
|
|
817
|
-
break;
|
|
818
|
-
case "cookie":
|
|
819
|
-
value = (0, import_cookie.getCookie)(c);
|
|
820
|
-
break;
|
|
821
|
-
}
|
|
822
|
-
const res = await validationFunc(value, c);
|
|
823
|
-
if (res instanceof Response) return res;
|
|
824
|
-
c.req.addValidatedData(target, res);
|
|
825
|
-
await next();
|
|
826
|
-
};
|
|
827
22
|
}
|
|
828
23
|
};
|
|
829
24
|
var __webpack_module_cache__ = {};
|
|
@@ -2385,7 +1580,156 @@ var hono_Hono = class extends Hono {
|
|
|
2385
1580
|
}
|
|
2386
1581
|
};
|
|
2387
1582
|
var _validateReport = __webpack_require__("../../node_modules/.pnpm/typia@8.0.3_@samchon+openapi@3.1.0_typescript@5.6.3/node_modules/typia/lib/internal/_validateReport.js");
|
|
2388
|
-
var
|
|
1583
|
+
var validCookieNameRegEx = /^[\w!#$%&'*.^`|~+-]+$/;
|
|
1584
|
+
var validCookieValueRegEx = /^[ !#-:<-[\]-~]*$/;
|
|
1585
|
+
var parse = (cookie, name)=>{
|
|
1586
|
+
const pairs = cookie.trim().split(";");
|
|
1587
|
+
return pairs.reduce((parsedCookie, pairStr)=>{
|
|
1588
|
+
pairStr = pairStr.trim();
|
|
1589
|
+
const valueStartPos = pairStr.indexOf("=");
|
|
1590
|
+
if (-1 === valueStartPos) return parsedCookie;
|
|
1591
|
+
const cookieName = pairStr.substring(0, valueStartPos).trim();
|
|
1592
|
+
if (name && name !== cookieName || !validCookieNameRegEx.test(cookieName)) return parsedCookie;
|
|
1593
|
+
let cookieValue = pairStr.substring(valueStartPos + 1).trim();
|
|
1594
|
+
if (cookieValue.startsWith('"') && cookieValue.endsWith('"')) cookieValue = cookieValue.slice(1, -1);
|
|
1595
|
+
if (validCookieValueRegEx.test(cookieValue)) parsedCookie[cookieName] = decodeURIComponent_(cookieValue);
|
|
1596
|
+
return parsedCookie;
|
|
1597
|
+
}, {});
|
|
1598
|
+
};
|
|
1599
|
+
var getCookie = (c, key, prefix)=>{
|
|
1600
|
+
const cookie = c.req.raw.headers.get("Cookie");
|
|
1601
|
+
if ("string" == typeof key) {
|
|
1602
|
+
if (!cookie) return;
|
|
1603
|
+
let finalKey = key;
|
|
1604
|
+
if ("secure" === prefix) finalKey = "__Secure-" + key;
|
|
1605
|
+
else if ("host" === prefix) finalKey = "__Host-" + key;
|
|
1606
|
+
const obj2 = parse(cookie, finalKey);
|
|
1607
|
+
return obj2[finalKey];
|
|
1608
|
+
}
|
|
1609
|
+
if (!cookie) return {};
|
|
1610
|
+
const obj = parse(cookie);
|
|
1611
|
+
return obj;
|
|
1612
|
+
};
|
|
1613
|
+
var HTTPException = class extends Error {
|
|
1614
|
+
res;
|
|
1615
|
+
status;
|
|
1616
|
+
constructor(status = 500, options){
|
|
1617
|
+
super(options?.message, {
|
|
1618
|
+
cause: options?.cause
|
|
1619
|
+
});
|
|
1620
|
+
this.res = options?.res;
|
|
1621
|
+
this.status = status;
|
|
1622
|
+
}
|
|
1623
|
+
getResponse() {
|
|
1624
|
+
if (this.res) {
|
|
1625
|
+
const newResponse = new Response(this.res.body, {
|
|
1626
|
+
status: this.status,
|
|
1627
|
+
headers: this.res.headers
|
|
1628
|
+
});
|
|
1629
|
+
return newResponse;
|
|
1630
|
+
}
|
|
1631
|
+
return new Response(this.message, {
|
|
1632
|
+
status: this.status
|
|
1633
|
+
});
|
|
1634
|
+
}
|
|
1635
|
+
};
|
|
1636
|
+
var bufferToFormData = (arrayBuffer, contentType)=>{
|
|
1637
|
+
const response = new Response(arrayBuffer, {
|
|
1638
|
+
headers: {
|
|
1639
|
+
"Content-Type": contentType
|
|
1640
|
+
}
|
|
1641
|
+
});
|
|
1642
|
+
return response.formData();
|
|
1643
|
+
};
|
|
1644
|
+
var jsonRegex = /^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/;
|
|
1645
|
+
var multipartRegex = /^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/;
|
|
1646
|
+
var urlencodedRegex = /^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/;
|
|
1647
|
+
var validator = (target, validationFunc)=>async (c, next)=>{
|
|
1648
|
+
let value = {};
|
|
1649
|
+
const contentType = c.req.header("Content-Type");
|
|
1650
|
+
switch(target){
|
|
1651
|
+
case "json":
|
|
1652
|
+
if (!contentType || !jsonRegex.test(contentType)) break;
|
|
1653
|
+
try {
|
|
1654
|
+
value = await c.req.json();
|
|
1655
|
+
} catch {
|
|
1656
|
+
const message = "Malformed JSON in request body";
|
|
1657
|
+
throw new HTTPException(400, {
|
|
1658
|
+
message
|
|
1659
|
+
});
|
|
1660
|
+
}
|
|
1661
|
+
break;
|
|
1662
|
+
case "form":
|
|
1663
|
+
{
|
|
1664
|
+
if (!contentType || !(multipartRegex.test(contentType) || urlencodedRegex.test(contentType))) break;
|
|
1665
|
+
let formData;
|
|
1666
|
+
if (c.req.bodyCache.formData) formData = await c.req.bodyCache.formData;
|
|
1667
|
+
else try {
|
|
1668
|
+
const arrayBuffer = await c.req.arrayBuffer();
|
|
1669
|
+
formData = await bufferToFormData(arrayBuffer, contentType);
|
|
1670
|
+
c.req.bodyCache.formData = formData;
|
|
1671
|
+
} catch (e) {
|
|
1672
|
+
let message = "Malformed FormData request.";
|
|
1673
|
+
message += e instanceof Error ? ` ${e.message}` : ` ${String(e)}`;
|
|
1674
|
+
throw new HTTPException(400, {
|
|
1675
|
+
message
|
|
1676
|
+
});
|
|
1677
|
+
}
|
|
1678
|
+
const form = {};
|
|
1679
|
+
formData.forEach((value2, key)=>{
|
|
1680
|
+
if (key.endsWith("[]")) (form[key] ??= []).push(value2);
|
|
1681
|
+
else if (Array.isArray(form[key])) form[key].push(value2);
|
|
1682
|
+
else if (key in form) form[key] = [
|
|
1683
|
+
form[key],
|
|
1684
|
+
value2
|
|
1685
|
+
];
|
|
1686
|
+
else form[key] = value2;
|
|
1687
|
+
});
|
|
1688
|
+
value = form;
|
|
1689
|
+
break;
|
|
1690
|
+
}
|
|
1691
|
+
case "query":
|
|
1692
|
+
value = Object.fromEntries(Object.entries(c.req.queries()).map(([k, v])=>1 === v.length ? [
|
|
1693
|
+
k,
|
|
1694
|
+
v[0]
|
|
1695
|
+
] : [
|
|
1696
|
+
k,
|
|
1697
|
+
v
|
|
1698
|
+
]));
|
|
1699
|
+
break;
|
|
1700
|
+
case "param":
|
|
1701
|
+
value = c.req.param();
|
|
1702
|
+
break;
|
|
1703
|
+
case "header":
|
|
1704
|
+
value = c.req.header();
|
|
1705
|
+
break;
|
|
1706
|
+
case "cookie":
|
|
1707
|
+
value = getCookie(c);
|
|
1708
|
+
break;
|
|
1709
|
+
}
|
|
1710
|
+
const res = await validationFunc(value, c);
|
|
1711
|
+
if (res instanceof Response) return res;
|
|
1712
|
+
c.req.addValidatedData(target, res);
|
|
1713
|
+
await next();
|
|
1714
|
+
};
|
|
1715
|
+
const typiaValidator = (target, validate, hook)=>validator(target, async (value, c)=>{
|
|
1716
|
+
const result = validate(value);
|
|
1717
|
+
if (hook) {
|
|
1718
|
+
const hookResult = await hook({
|
|
1719
|
+
...result,
|
|
1720
|
+
data: value
|
|
1721
|
+
}, c);
|
|
1722
|
+
if (hookResult) {
|
|
1723
|
+
if (hookResult instanceof Response || hookResult instanceof Promise) return hookResult;
|
|
1724
|
+
if ('response' in hookResult) return hookResult.response;
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
if (!result.success) return c.json({
|
|
1728
|
+
success: false,
|
|
1729
|
+
error: result.errors
|
|
1730
|
+
}, 400);
|
|
1731
|
+
return result.data;
|
|
1732
|
+
});
|
|
2389
1733
|
const queryBundlesSchema = (()=>{
|
|
2390
1734
|
const _io0 = (input)=>(void 0 === input.channel || "string" == typeof input.channel) && (void 0 === input.platform || "ios" === input.platform || "android" === input.platform) && (void 0 === input.limit || "string" == typeof input.limit) && (void 0 === input.offset || "string" == typeof input.offset);
|
|
2391
1735
|
const _vo0 = (input, _path, _exceptionable = true)=>[
|
|
@@ -2613,7 +1957,7 @@ const rpc = new hono_Hono().get("/config", async (c)=>{
|
|
|
2613
1957
|
console.error("Error during config loaded retrieval:", error);
|
|
2614
1958
|
throw error;
|
|
2615
1959
|
}
|
|
2616
|
-
}).get("/bundles",
|
|
1960
|
+
}).get("/bundles", typiaValidator("query", queryBundlesSchema), async (c)=>{
|
|
2617
1961
|
try {
|
|
2618
1962
|
const query = c.req.valid("query");
|
|
2619
1963
|
const { databasePlugin } = await prepareConfig();
|
|
@@ -2630,7 +1974,7 @@ const rpc = new hono_Hono().get("/config", async (c)=>{
|
|
|
2630
1974
|
console.error("Error during bundle retrieval:", error);
|
|
2631
1975
|
throw error;
|
|
2632
1976
|
}
|
|
2633
|
-
}).get("/bundles/:bundleId",
|
|
1977
|
+
}).get("/bundles/:bundleId", typiaValidator("param", paramBundleIdSchema), async (c)=>{
|
|
2634
1978
|
try {
|
|
2635
1979
|
const { bundleId } = c.req.valid("param");
|
|
2636
1980
|
const { databasePlugin } = await prepareConfig();
|
|
@@ -2640,7 +1984,7 @@ const rpc = new hono_Hono().get("/config", async (c)=>{
|
|
|
2640
1984
|
console.error("Error during bundle retrieval:", error);
|
|
2641
1985
|
throw error;
|
|
2642
1986
|
}
|
|
2643
|
-
}).patch("/bundles/:bundleId",
|
|
1987
|
+
}).patch("/bundles/:bundleId", typiaValidator("json", updateBundleSchema), async (c)=>{
|
|
2644
1988
|
try {
|
|
2645
1989
|
const bundleId = c.req.param("bundleId");
|
|
2646
1990
|
const partialBundle = c.req.valid("json");
|