module-develop-kit 1.0.6 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs-virtual-dir/browser2.js +7 -0
- package/dist/commonjs-virtual-dir/index4.js +2 -4
- package/dist/commonjs-virtual-dir/index5.js +2 -2
- package/dist/commonjs-virtual-dir/index6.js +2 -2
- package/dist/commonjs-virtual-dir/index7.js +4 -0
- package/dist/commonjs-virtual-dir/index8.js +4 -0
- package/dist/main.d.ts +161 -0
- package/dist/main.js +35 -19
- package/dist/src/shield/file-detection.js +143 -0
- package/dist/src/shield/url-sanitize.js +59 -0
- package/dist/vendor/@borewit/text-codec/lib/index.js +181 -0
- package/dist/vendor/@tokenizer/inflate/lib/GzipHandler.js +21 -0
- package/dist/vendor/@tokenizer/inflate/lib/ZipHandler.js +156 -0
- package/dist/vendor/@tokenizer/inflate/lib/ZipToken.js +71 -0
- package/dist/vendor/base64-js/index.js +1 -1
- package/dist/vendor/file-type/source/detectors/asf.js +74 -0
- package/dist/vendor/file-type/source/detectors/ebml.js +61 -0
- package/dist/vendor/file-type/source/detectors/png.js +64 -0
- package/dist/vendor/file-type/source/detectors/zip.js +344 -0
- package/dist/vendor/file-type/source/index.js +1135 -0
- package/dist/vendor/file-type/source/parser.js +49 -0
- package/dist/vendor/file-type/source/supported.js +372 -0
- package/dist/vendor/file-type/source/tokens.js +40 -0
- package/dist/vendor/ieee754/index.js +30 -0
- package/dist/vendor/jsbn/index.js +1 -1
- package/dist/vendor/sdp-transform/lib/index.js +1 -1
- package/dist/vendor/strtok3/lib/AbstractTokenizer.js +92 -0
- package/dist/vendor/strtok3/lib/BlobTokenizer.js +48 -0
- package/dist/vendor/strtok3/lib/BufferTokenizer.js +47 -0
- package/dist/vendor/strtok3/lib/ReadStreamTokenizer.js +91 -0
- package/dist/vendor/strtok3/lib/core.js +22 -0
- package/dist/vendor/strtok3/lib/stream/AbstractStreamReader.js +51 -0
- package/dist/vendor/strtok3/lib/stream/Errors.js +16 -0
- package/dist/vendor/strtok3/lib/stream/WebStreamByobReader.js +18 -0
- package/dist/vendor/strtok3/lib/stream/WebStreamDefaultReader.js +45 -0
- package/dist/vendor/strtok3/lib/stream/WebStreamReader.js +15 -0
- package/dist/vendor/strtok3/lib/stream/WebStreamReaderFactory.js +15 -0
- package/dist/vendor/token-types/lib/index.js +81 -0
- package/dist/vendor/uint8array-extras/index.js +45 -0
- package/package.json +2 -1
package/dist/main.d.ts
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
import { Ref } from 'vue';
|
|
2
|
+
import { supportedExtensions } from 'file-type';
|
|
3
|
+
import { supportedMimeTypes } from 'file-type';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 支持的文件类型配置
|
|
7
|
+
* 基于 file-type 库的 supportedMimeTypes 动态生成
|
|
8
|
+
*/
|
|
9
|
+
export declare const ALLOWED_FILE_TYPES: {
|
|
10
|
+
readonly image: Set<string>;
|
|
11
|
+
readonly document: Set<string>;
|
|
12
|
+
readonly video: Set<string>;
|
|
13
|
+
readonly audio: Set<string>;
|
|
14
|
+
readonly archive: Set<string>;
|
|
15
|
+
readonly font: Set<string>;
|
|
16
|
+
readonly model: Set<string>;
|
|
17
|
+
};
|
|
2
18
|
|
|
3
19
|
/**
|
|
4
20
|
* 防重放攻击策略
|
|
@@ -23,6 +39,46 @@ export declare const CallLogger: {
|
|
|
23
39
|
error(message: unknown, ...args: unknown[]): void;
|
|
24
40
|
};
|
|
25
41
|
|
|
42
|
+
/**
|
|
43
|
+
* 检测文件真实类型并验证扩展名
|
|
44
|
+
*
|
|
45
|
+
* @param file 要检测的文件
|
|
46
|
+
* @param _allowedExtensions 允许的扩展名列表(不含点),如 ['jpg', 'png'],或者 'jpg,png' 或者 'jpg'
|
|
47
|
+
* @param options 检测选项
|
|
48
|
+
* @returns 检测结果
|
|
49
|
+
*/
|
|
50
|
+
export declare function detectFileByExtension(file: File, _allowedExtensions: TMaybeArray<string>, options?: FileDetectionOptions): Promise<FileDetectionResult>;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 检测文件真实类型并验证 MIME 类型
|
|
54
|
+
*
|
|
55
|
+
* @param file 要检测的文件
|
|
56
|
+
* @param _allowedMimes 允许的MIME类型列表 支持单个或者数组。单个支持使用,分割
|
|
57
|
+
* @param options 检测选项
|
|
58
|
+
* @returns 检测结果
|
|
59
|
+
*/
|
|
60
|
+
export declare function detectFileByMime(file: File, _allowedMimes: TMaybeArray<string>, options?: FileDetectionOptions): Promise<FileDetectionResult>;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 批量检测文件扩展名
|
|
64
|
+
*
|
|
65
|
+
* @param files 要检测的文件列表
|
|
66
|
+
* @param allowedExtensions 允许的扩展名列表
|
|
67
|
+
* @param options 检测选项
|
|
68
|
+
* @returns 检测结果列表
|
|
69
|
+
*/
|
|
70
|
+
export declare function detectionFilesByExtension(files: File[], allowedExtensions: TMaybeArray<string>, options?: FileDetectionOptions): Promise<FileDetectionResult[]>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 批量检测文件 MIME 类型
|
|
74
|
+
*
|
|
75
|
+
* @param files 要检测的文件列表
|
|
76
|
+
* @param allowedMimes 允许的MIME类型列表
|
|
77
|
+
* @param options 检测选项
|
|
78
|
+
* @returns 检测结果列表
|
|
79
|
+
*/
|
|
80
|
+
export declare function detectionFilesByMime(files: File[], allowedMimes: TMaybeArray<string>, options?: FileDetectionOptions): Promise<FileDetectionResult[]>;
|
|
81
|
+
|
|
26
82
|
export declare enum ECallStatus {
|
|
27
83
|
/**
|
|
28
84
|
* 正在接听中
|
|
@@ -106,6 +162,40 @@ export declare interface EventBusProps {
|
|
|
106
162
|
|
|
107
163
|
declare type EventFnc = (...args: any) => void;
|
|
108
164
|
|
|
165
|
+
export declare interface FileDetectionOptions {
|
|
166
|
+
/**
|
|
167
|
+
* 最大文件大小(字节)
|
|
168
|
+
*/
|
|
169
|
+
maxSize?: number;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export declare interface FileDetectionResult {
|
|
173
|
+
/**
|
|
174
|
+
* 是否通过检测
|
|
175
|
+
*/
|
|
176
|
+
valid: boolean;
|
|
177
|
+
/**
|
|
178
|
+
* 检测到的真实MIME类型
|
|
179
|
+
*/
|
|
180
|
+
detectedMime?: string;
|
|
181
|
+
/**
|
|
182
|
+
* 检测到的文件扩展名
|
|
183
|
+
*/
|
|
184
|
+
detectedExt?: string;
|
|
185
|
+
/**
|
|
186
|
+
* 错误信息
|
|
187
|
+
*/
|
|
188
|
+
error?: string;
|
|
189
|
+
/**
|
|
190
|
+
* 文件声称的MIME类型(来自File对象)
|
|
191
|
+
*/
|
|
192
|
+
claimedMime?: string;
|
|
193
|
+
/**
|
|
194
|
+
* MIME类型是否匹配(真实vs声称)
|
|
195
|
+
*/
|
|
196
|
+
mimeMatches?: boolean;
|
|
197
|
+
}
|
|
198
|
+
|
|
109
199
|
/**
|
|
110
200
|
* 安全的解析html内容 防止xss攻击
|
|
111
201
|
* @param input 输入的html内容
|
|
@@ -231,6 +321,29 @@ export declare interface ISm4Params {
|
|
|
231
321
|
key: string;
|
|
232
322
|
}
|
|
233
323
|
|
|
324
|
+
/**
|
|
325
|
+
* 检测 URL 是否包含 XSS 攻击
|
|
326
|
+
* @param url - 需要检测的 URL
|
|
327
|
+
* @param options - 配置选项
|
|
328
|
+
* @returns 是否安全
|
|
329
|
+
*/
|
|
330
|
+
export declare function isUrlSafe(url: unknown, options?: UrlSanitizeOptions): boolean;
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* 便捷方法: 检测是否为文档文件(基于 MIME 类型)
|
|
334
|
+
*/
|
|
335
|
+
export declare function isValidDocument(file: File, maxSize?: number): Promise<FileDetectionResult>;
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* 便捷方法: 检测是否为图片文件(基于 MIME 类型)
|
|
339
|
+
*/
|
|
340
|
+
export declare function isValidImage(file: File, maxSize?: number): Promise<FileDetectionResult>;
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* 便捷方法: 检测是否为视频文件(基于 MIME 类型)
|
|
344
|
+
*/
|
|
345
|
+
export declare function isValidVideo(file: File, maxSize?: number): Promise<FileDetectionResult>;
|
|
346
|
+
|
|
234
347
|
/**
|
|
235
348
|
* 请求数据加密
|
|
236
349
|
* @param publicKey 公钥
|
|
@@ -254,6 +367,22 @@ export declare function responseDataEncryption<T>(stepCb: (_headers: {
|
|
|
254
367
|
[EHeaderKey.publicKey]: string;
|
|
255
368
|
}) => Promise<IResponseDataEncryptionStep>): Promise<T>;
|
|
256
369
|
|
|
370
|
+
/**
|
|
371
|
+
* 消毒 URL,返回安全的 URL 或替代 URL
|
|
372
|
+
* @param url - 需要消毒的 URL
|
|
373
|
+
* @param options - 配置选项
|
|
374
|
+
* @returns 安全的 URL
|
|
375
|
+
*/
|
|
376
|
+
export declare function sanitizeUrl(url: unknown, options?: UrlSanitizeOptions): string;
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* 批量消毒 URL 列表
|
|
380
|
+
* @param urls - URL 列表
|
|
381
|
+
* @param options - 配置选项
|
|
382
|
+
* @returns 消毒后的 URL 列表
|
|
383
|
+
*/
|
|
384
|
+
export declare function sanitizeUrls(urls: string[], options?: UrlSanitizeOptions): string[];
|
|
385
|
+
|
|
257
386
|
/**
|
|
258
387
|
* sip code对应的的状态,优先处理 code 对应的提示文案,如果不存在则按照 causes 状态去处理
|
|
259
388
|
*/
|
|
@@ -314,16 +443,48 @@ declare interface SipAccount {
|
|
|
314
443
|
*/
|
|
315
444
|
export declare const startNoDebugger: () => void;
|
|
316
445
|
|
|
446
|
+
export { supportedExtensions }
|
|
447
|
+
|
|
448
|
+
export { supportedMimeTypes }
|
|
449
|
+
|
|
317
450
|
export declare type TData = _TData | _TData[];
|
|
318
451
|
|
|
319
452
|
declare type _TData = null | undefined | number | string | Record<string, any>;
|
|
320
453
|
|
|
454
|
+
export declare type TMaybeArray<T> = T[] | T;
|
|
455
|
+
|
|
321
456
|
export declare type TNullable<T> = T | null;
|
|
322
457
|
|
|
323
458
|
export declare type TObj<K extends keyof any = string, T = any> = Record<K, T>;
|
|
324
459
|
|
|
325
460
|
export declare type TUndefinable<T> = T | undefined;
|
|
326
461
|
|
|
462
|
+
/**
|
|
463
|
+
* URL XSS 防护工具
|
|
464
|
+
* 用于检测和拦截包含 XSS 攻击的 URL
|
|
465
|
+
*/
|
|
466
|
+
/**
|
|
467
|
+
* URL 消毒选项
|
|
468
|
+
*/
|
|
469
|
+
export declare interface UrlSanitizeOptions {
|
|
470
|
+
/**
|
|
471
|
+
* 是否允许相对路径 URL,默认 true
|
|
472
|
+
*/
|
|
473
|
+
allowRelative?: boolean;
|
|
474
|
+
/**
|
|
475
|
+
* 额外的安全协议
|
|
476
|
+
*/
|
|
477
|
+
extraSafeProtocols?: string[];
|
|
478
|
+
/**
|
|
479
|
+
* 当检测到 XSS 时的替代 URL,默认 '#'
|
|
480
|
+
*/
|
|
481
|
+
fallbackUrl?: string;
|
|
482
|
+
/**
|
|
483
|
+
* 是否严格模式,严格模式下只允许 http/https,默认 false
|
|
484
|
+
*/
|
|
485
|
+
strictMode?: boolean;
|
|
486
|
+
}
|
|
487
|
+
|
|
327
488
|
/**
|
|
328
489
|
* 打电话
|
|
329
490
|
* FIXME: callBack 为什么存在?zyy 中通过 useCall 拿到的变量无法实现响应式,所以通过 callback 的方式更新外部依赖。
|
package/dist/main.js
CHANGED
|
@@ -1,21 +1,37 @@
|
|
|
1
|
-
import { useCall as
|
|
2
|
-
import { antiReplyAttackStrategy as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { useCall as o } from "./src/outside-call/index.js";
|
|
2
|
+
import { antiReplyAttackStrategy as i, requestDataEncryption as s, responseDataEncryption as a } from "./src/shield/crypto/index.js";
|
|
3
|
+
import { ALLOWED_FILE_TYPES as p, detectFileByExtension as E, detectFileByMime as l, detectionFilesByExtension as m, detectionFilesByMime as x, isValidDocument as f, isValidImage as S, isValidVideo as d } from "./src/shield/file-detection.js";
|
|
4
|
+
import { htmlSanitize as c } from "./src/shield/html-sanitize.js";
|
|
5
|
+
import { startNoDebugger as _ } from "./src/shield/no-debugger.js";
|
|
6
|
+
import { isUrlSafe as D, sanitizeUrl as M, sanitizeUrls as A } from "./src/shield/url-sanitize.js";
|
|
7
|
+
import { EventBus as C } from "./src/utils/eventBus.js";
|
|
8
|
+
import { CallLogger as I } from "./src/outside-call/utils.js";
|
|
9
|
+
import { ECallStatus as L, EMIT_EVENT_NAME as R, SIP_CODE_MESSAGE as T, SIP_ERROR_CAUSES as U } from "./src/outside-call/constants.js";
|
|
10
|
+
import { supportedExtensions as N, supportedMimeTypes as O } from "./vendor/file-type/source/index.js";
|
|
8
11
|
export {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
C as
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
E as
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
p as ALLOWED_FILE_TYPES,
|
|
13
|
+
I as CallLogger,
|
|
14
|
+
L as ECallStatus,
|
|
15
|
+
R as EMIT_EVENT_NAME,
|
|
16
|
+
C as EventBus,
|
|
17
|
+
T as SIP_CODE_MESSAGE,
|
|
18
|
+
U as SIP_ERROR_CAUSES,
|
|
19
|
+
i as antiReplyAttackStrategy,
|
|
20
|
+
E as detectFileByExtension,
|
|
21
|
+
l as detectFileByMime,
|
|
22
|
+
m as detectionFilesByExtension,
|
|
23
|
+
x as detectionFilesByMime,
|
|
24
|
+
c as htmlSanitize,
|
|
25
|
+
D as isUrlSafe,
|
|
26
|
+
f as isValidDocument,
|
|
27
|
+
S as isValidImage,
|
|
28
|
+
d as isValidVideo,
|
|
29
|
+
s as requestDataEncryption,
|
|
30
|
+
a as responseDataEncryption,
|
|
31
|
+
M as sanitizeUrl,
|
|
32
|
+
A as sanitizeUrls,
|
|
33
|
+
_ as startNoDebugger,
|
|
34
|
+
N as supportedExtensions,
|
|
35
|
+
O as supportedMimeTypes,
|
|
36
|
+
o as useCall
|
|
21
37
|
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { supportedMimeTypes as l, fileTypeFromStream as y } from "../../vendor/file-type/source/index.js";
|
|
2
|
+
import { supportedExtensions as z } from "../../vendor/file-type/source/index.js";
|
|
3
|
+
function d(e) {
|
|
4
|
+
const t = /* @__PURE__ */ new Set();
|
|
5
|
+
for (const r of l)
|
|
6
|
+
r.startsWith(`${e}/`) && t.add(r);
|
|
7
|
+
return t;
|
|
8
|
+
}
|
|
9
|
+
const f = {
|
|
10
|
+
// 图片类型 - 从 supportedMimeTypes 中过滤 image/*
|
|
11
|
+
image: d("image"),
|
|
12
|
+
// 文档类型 - 包含常见办公文档
|
|
13
|
+
document: /* @__PURE__ */ new Set([
|
|
14
|
+
...Array.from(l).filter(
|
|
15
|
+
(e) => e.includes("pdf") || e.includes("msword") || e.includes("officedocument") || e.includes("ms-excel") || e.includes("ms-powerpoint") || e.includes("opendocument") || e === "text/plain"
|
|
16
|
+
)
|
|
17
|
+
]),
|
|
18
|
+
// 视频类型 - 从 supportedMimeTypes 中过滤 video/*
|
|
19
|
+
video: d("video"),
|
|
20
|
+
// 音频类型 - 从 supportedMimeTypes 中过滤 audio/*
|
|
21
|
+
audio: d("audio"),
|
|
22
|
+
// 压缩文件
|
|
23
|
+
archive: /* @__PURE__ */ new Set([
|
|
24
|
+
...Array.from(l).filter(
|
|
25
|
+
(e) => e.includes("zip") || e.includes("rar") || e.includes("7z") || e.includes("tar") || e.includes("gzip") || e.includes("compress")
|
|
26
|
+
)
|
|
27
|
+
]),
|
|
28
|
+
// 字体文件
|
|
29
|
+
font: d("font"),
|
|
30
|
+
// 模型文件
|
|
31
|
+
model: d("model")
|
|
32
|
+
};
|
|
33
|
+
function M(e, t) {
|
|
34
|
+
return t.some((r) => {
|
|
35
|
+
const i = r.trim();
|
|
36
|
+
if (!i)
|
|
37
|
+
return !1;
|
|
38
|
+
if (i === e)
|
|
39
|
+
return !0;
|
|
40
|
+
if (i.endsWith("/*")) {
|
|
41
|
+
const n = i.slice(0, i.indexOf("/"));
|
|
42
|
+
return e.startsWith(`${n}/`);
|
|
43
|
+
}
|
|
44
|
+
return !1;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
async function p(e, t) {
|
|
48
|
+
const { maxSize: r } = t;
|
|
49
|
+
if (r && e.size > r)
|
|
50
|
+
return {
|
|
51
|
+
valid: !1,
|
|
52
|
+
error: `上传文件大小不能超过 ${(r / 1024 / 1024).toFixed(2)}MB`,
|
|
53
|
+
claimedMime: e.type
|
|
54
|
+
};
|
|
55
|
+
const i = await y(e.stream());
|
|
56
|
+
if (!i)
|
|
57
|
+
return {
|
|
58
|
+
valid: !1,
|
|
59
|
+
error: "无法检测文件类型,可能是不支持的格式或文件已损坏",
|
|
60
|
+
claimedMime: e.type
|
|
61
|
+
};
|
|
62
|
+
const n = i.mime, o = i.ext, c = e.type, s = n === c;
|
|
63
|
+
return !s && c && console.warn("文件MIME类型不匹配", {
|
|
64
|
+
claimed: c,
|
|
65
|
+
detected: n,
|
|
66
|
+
fileName: e.name
|
|
67
|
+
}), {
|
|
68
|
+
detectedMime: n,
|
|
69
|
+
detectedExt: o,
|
|
70
|
+
claimedMime: c,
|
|
71
|
+
mimeMatches: s
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
async function u(e, t, r = {}) {
|
|
75
|
+
const i = await p(e, r);
|
|
76
|
+
if ("valid" in i && !i.valid)
|
|
77
|
+
return i;
|
|
78
|
+
const { detectedMime: n, detectedExt: o, claimedMime: c, mimeMatches: s } = i, m = Array.isArray(t) ? t : t.split(",");
|
|
79
|
+
return !n || !M(n, m) ? {
|
|
80
|
+
valid: !1,
|
|
81
|
+
error: `不支持的文件类型: ${n || "未知"}`,
|
|
82
|
+
detectedMime: n,
|
|
83
|
+
detectedExt: o,
|
|
84
|
+
claimedMime: c,
|
|
85
|
+
mimeMatches: s
|
|
86
|
+
} : {
|
|
87
|
+
valid: !0,
|
|
88
|
+
detectedMime: n,
|
|
89
|
+
detectedExt: o,
|
|
90
|
+
claimedMime: c,
|
|
91
|
+
mimeMatches: s
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
async function v(e, t, r = {}) {
|
|
95
|
+
const i = await p(e, r);
|
|
96
|
+
if ("valid" in i && !i.valid)
|
|
97
|
+
return i;
|
|
98
|
+
const { detectedMime: n, detectedExt: o, claimedMime: c, mimeMatches: s } = i, m = Array.isArray(t) ? t : t.split(",").map((a) => a.trim());
|
|
99
|
+
return !o || !m.some((a) => o === a || `.${o}` === a) ? {
|
|
100
|
+
valid: !1,
|
|
101
|
+
error: `不支持的文件扩展名: .${o || "未知"}`,
|
|
102
|
+
detectedMime: n,
|
|
103
|
+
detectedExt: o,
|
|
104
|
+
claimedMime: c,
|
|
105
|
+
mimeMatches: s
|
|
106
|
+
} : {
|
|
107
|
+
valid: !0,
|
|
108
|
+
detectedMime: n,
|
|
109
|
+
detectedExt: o,
|
|
110
|
+
claimedMime: c,
|
|
111
|
+
mimeMatches: s
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function A(e, t, r = {}) {
|
|
115
|
+
return Promise.all(e.map((i) => u(i, t, r)));
|
|
116
|
+
}
|
|
117
|
+
function g(e, t, r = {}) {
|
|
118
|
+
return Promise.all(e.map((i) => v(i, t, r)));
|
|
119
|
+
}
|
|
120
|
+
function E(e, t) {
|
|
121
|
+
const r = Array.from(f.image);
|
|
122
|
+
return u(e, r, { maxSize: t });
|
|
123
|
+
}
|
|
124
|
+
function w(e, t) {
|
|
125
|
+
const r = Array.from(f.document);
|
|
126
|
+
return u(e, r, { maxSize: t });
|
|
127
|
+
}
|
|
128
|
+
function F(e, t) {
|
|
129
|
+
const r = Array.from(f.video);
|
|
130
|
+
return u(e, r, { maxSize: t });
|
|
131
|
+
}
|
|
132
|
+
export {
|
|
133
|
+
f as ALLOWED_FILE_TYPES,
|
|
134
|
+
v as detectFileByExtension,
|
|
135
|
+
u as detectFileByMime,
|
|
136
|
+
g as detectionFilesByExtension,
|
|
137
|
+
A as detectionFilesByMime,
|
|
138
|
+
w as isValidDocument,
|
|
139
|
+
E as isValidImage,
|
|
140
|
+
F as isValidVideo,
|
|
141
|
+
z as supportedExtensions,
|
|
142
|
+
l as supportedMimeTypes
|
|
143
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const i = ["http:", "https:", "mailto:", "tel:", "sms:", "ftp:", "ftps:"], o = [
|
|
2
|
+
// eslint-disable-next-line no-script-url
|
|
3
|
+
"javascript:",
|
|
4
|
+
"data:",
|
|
5
|
+
"vbscript:",
|
|
6
|
+
"file:",
|
|
7
|
+
"about:",
|
|
8
|
+
"blob:"
|
|
9
|
+
];
|
|
10
|
+
function l(t) {
|
|
11
|
+
return t.replace(/[-]/g, "").replace(/\s+/g, "").trim();
|
|
12
|
+
}
|
|
13
|
+
function n(t) {
|
|
14
|
+
const e = t.toLowerCase();
|
|
15
|
+
return [
|
|
16
|
+
/javascript:/i,
|
|
17
|
+
/data:text\/html/i,
|
|
18
|
+
/vbscript:/i,
|
|
19
|
+
/on\w+\s*=/i,
|
|
20
|
+
// HTML 事件处理器,如 onclick=, onload=
|
|
21
|
+
/<script/i,
|
|
22
|
+
/&#/i,
|
|
23
|
+
// HTML 实体编码
|
|
24
|
+
/%6a%61%76%61%73%63%72%69%70%74/i,
|
|
25
|
+
// URL 编码的 javascript
|
|
26
|
+
/\\u006a\\u0061\\u0076\\u0061/i
|
|
27
|
+
// Unicode 编码
|
|
28
|
+
].some((s) => s.test(e) || s.test(t));
|
|
29
|
+
}
|
|
30
|
+
function c(t, e = {}) {
|
|
31
|
+
if (!t || typeof t != "string")
|
|
32
|
+
return !1;
|
|
33
|
+
const r = t.trim();
|
|
34
|
+
if (!r)
|
|
35
|
+
return !1;
|
|
36
|
+
if (r.startsWith("/") || r.startsWith("./") || r.startsWith("../"))
|
|
37
|
+
return e.allowRelative === !1 ? !1 : !n(r);
|
|
38
|
+
const s = l(r);
|
|
39
|
+
if (n(s))
|
|
40
|
+
return !1;
|
|
41
|
+
try {
|
|
42
|
+
const a = new URL(s, "http://example.com").protocol.toLowerCase();
|
|
43
|
+
return e.strictMode ? a === "http:" || a === "https:" : o.includes(a) ? !1 : [...i, ...e.extraSafeProtocols || []].includes(a);
|
|
44
|
+
} catch {
|
|
45
|
+
return !1;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function f(t, e = {}) {
|
|
49
|
+
const r = e.fallbackUrl || "#";
|
|
50
|
+
return c(t, e) ? t.trim() : r;
|
|
51
|
+
}
|
|
52
|
+
function m(t, e = {}) {
|
|
53
|
+
return t.map((r) => f(r, e));
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
c as isUrlSafe,
|
|
57
|
+
f as sanitizeUrl,
|
|
58
|
+
m as sanitizeUrls
|
|
59
|
+
};
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
const g = {
|
|
2
|
+
128: "€",
|
|
3
|
+
130: "‚",
|
|
4
|
+
131: "ƒ",
|
|
5
|
+
132: "„",
|
|
6
|
+
133: "…",
|
|
7
|
+
134: "†",
|
|
8
|
+
135: "‡",
|
|
9
|
+
136: "ˆ",
|
|
10
|
+
137: "‰",
|
|
11
|
+
138: "Š",
|
|
12
|
+
139: "‹",
|
|
13
|
+
140: "Œ",
|
|
14
|
+
142: "Ž",
|
|
15
|
+
145: "‘",
|
|
16
|
+
146: "’",
|
|
17
|
+
147: "“",
|
|
18
|
+
148: "”",
|
|
19
|
+
149: "•",
|
|
20
|
+
150: "–",
|
|
21
|
+
151: "—",
|
|
22
|
+
152: "˜",
|
|
23
|
+
153: "™",
|
|
24
|
+
154: "š",
|
|
25
|
+
155: "›",
|
|
26
|
+
156: "œ",
|
|
27
|
+
158: "ž",
|
|
28
|
+
159: "Ÿ"
|
|
29
|
+
};
|
|
30
|
+
for (const [e, o] of Object.entries(g))
|
|
31
|
+
;
|
|
32
|
+
let a;
|
|
33
|
+
function w() {
|
|
34
|
+
if (!(typeof globalThis.TextDecoder > "u"))
|
|
35
|
+
return a ?? (a = new globalThis.TextDecoder("utf-8"));
|
|
36
|
+
}
|
|
37
|
+
const d = 32 * 1024, r = 65533;
|
|
38
|
+
function L(e, o = "utf-8") {
|
|
39
|
+
switch (o.toLowerCase()) {
|
|
40
|
+
case "utf-8":
|
|
41
|
+
case "utf8": {
|
|
42
|
+
const n = w();
|
|
43
|
+
return n ? n.decode(e) : T(e);
|
|
44
|
+
}
|
|
45
|
+
case "utf-16le":
|
|
46
|
+
return E(e);
|
|
47
|
+
case "us-ascii":
|
|
48
|
+
case "ascii":
|
|
49
|
+
return m(e);
|
|
50
|
+
case "latin1":
|
|
51
|
+
case "iso-8859-1":
|
|
52
|
+
return v(e);
|
|
53
|
+
case "windows-1252":
|
|
54
|
+
return D(e);
|
|
55
|
+
default:
|
|
56
|
+
throw new RangeError(`Encoding '${o}' not supported`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function s(e, o) {
|
|
60
|
+
o.length !== 0 && (e.push(String.fromCharCode.apply(null, o)), o.length = 0);
|
|
61
|
+
}
|
|
62
|
+
function i(e, o, n) {
|
|
63
|
+
o.push(n), o.length >= d && s(e, o);
|
|
64
|
+
}
|
|
65
|
+
function j(e, o, n) {
|
|
66
|
+
if (n <= 65535) {
|
|
67
|
+
i(e, o, n);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
n -= 65536, i(e, o, 55296 + (n >> 10)), i(e, o, 56320 + (n & 1023));
|
|
71
|
+
}
|
|
72
|
+
function T(e) {
|
|
73
|
+
const o = [], n = [];
|
|
74
|
+
let t = 0;
|
|
75
|
+
for (e.length >= 3 && e[0] === 239 && e[1] === 187 && e[2] === 191 && (t = 3); t < e.length; ) {
|
|
76
|
+
const f = e[t];
|
|
77
|
+
if (f <= 127) {
|
|
78
|
+
i(o, n, f), t++;
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (f < 194 || f > 244) {
|
|
82
|
+
i(o, n, r), t++;
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (f <= 223) {
|
|
86
|
+
if (t + 1 >= e.length) {
|
|
87
|
+
i(o, n, r), t++;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const u = e[t + 1];
|
|
91
|
+
if ((u & 192) !== 128) {
|
|
92
|
+
i(o, n, r), t++;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const l = (f & 31) << 6 | u & 63;
|
|
96
|
+
i(o, n, l), t += 2;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (f <= 239) {
|
|
100
|
+
if (t + 2 >= e.length) {
|
|
101
|
+
i(o, n, r), t++;
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const u = e[t + 1], l = e[t + 2];
|
|
105
|
+
if (!((u & 192) === 128 && (l & 192) === 128 && !(f === 224 && u < 160) && // overlong
|
|
106
|
+
!(f === 237 && u >= 160))) {
|
|
107
|
+
i(o, n, r), t++;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const C = (f & 15) << 12 | (u & 63) << 6 | l & 63;
|
|
111
|
+
i(o, n, C), t += 3;
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (t + 3 >= e.length) {
|
|
115
|
+
i(o, n, r), t++;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const c = e[t + 1], x = e[t + 2], h = e[t + 3];
|
|
119
|
+
if (!((c & 192) === 128 && (x & 192) === 128 && (h & 192) === 128 && !(f === 240 && c < 144) && // overlong
|
|
120
|
+
!(f === 244 && c > 143))) {
|
|
121
|
+
i(o, n, r), t++;
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const p = (f & 7) << 18 | (c & 63) << 12 | (x & 63) << 6 | h & 63;
|
|
125
|
+
j(o, n, p), t += 4;
|
|
126
|
+
}
|
|
127
|
+
return s(o, n), o.join("");
|
|
128
|
+
}
|
|
129
|
+
function E(e) {
|
|
130
|
+
const o = [], n = [], t = e.length;
|
|
131
|
+
let f = 0;
|
|
132
|
+
for (; f + 1 < t; ) {
|
|
133
|
+
const c = e[f] | e[f + 1] << 8;
|
|
134
|
+
if (f += 2, c >= 55296 && c <= 56319) {
|
|
135
|
+
if (f + 1 < t) {
|
|
136
|
+
const x = e[f] | e[f + 1] << 8;
|
|
137
|
+
x >= 56320 && x <= 57343 ? (i(o, n, c), i(o, n, x), f += 2) : i(o, n, r);
|
|
138
|
+
} else
|
|
139
|
+
i(o, n, r);
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
if (c >= 56320 && c <= 57343) {
|
|
143
|
+
i(o, n, r);
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
i(o, n, c);
|
|
147
|
+
}
|
|
148
|
+
return f < t && i(o, n, r), s(o, n), o.join("");
|
|
149
|
+
}
|
|
150
|
+
function m(e) {
|
|
151
|
+
const o = [];
|
|
152
|
+
for (let n = 0; n < e.length; n += d) {
|
|
153
|
+
const t = Math.min(e.length, n + d), f = new Array(t - n);
|
|
154
|
+
for (let c = n, x = 0; c < t; c++, x++)
|
|
155
|
+
f[x] = e[c] & 127;
|
|
156
|
+
o.push(String.fromCharCode.apply(null, f));
|
|
157
|
+
}
|
|
158
|
+
return o.join("");
|
|
159
|
+
}
|
|
160
|
+
function v(e) {
|
|
161
|
+
const o = [];
|
|
162
|
+
for (let n = 0; n < e.length; n += d) {
|
|
163
|
+
const t = Math.min(e.length, n + d), f = new Array(t - n);
|
|
164
|
+
for (let c = n, x = 0; c < t; c++, x++)
|
|
165
|
+
f[x] = e[c];
|
|
166
|
+
o.push(String.fromCharCode.apply(null, f));
|
|
167
|
+
}
|
|
168
|
+
return o.join("");
|
|
169
|
+
}
|
|
170
|
+
function D(e) {
|
|
171
|
+
const o = [];
|
|
172
|
+
let n = "";
|
|
173
|
+
for (let t = 0; t < e.length; t++) {
|
|
174
|
+
const f = e[t], c = f >= 128 && f <= 159 ? g[f] : void 0;
|
|
175
|
+
n += c ?? String.fromCharCode(f), n.length >= d && (o.push(n), n = "");
|
|
176
|
+
}
|
|
177
|
+
return n && o.push(n), o.join("");
|
|
178
|
+
}
|
|
179
|
+
export {
|
|
180
|
+
L as textDecode
|
|
181
|
+
};
|