module-develop-kit 1.2.1 → 1.2.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/commonjs-virtual-dir/browser.js +2 -5
- package/dist/commonjs-virtual-dir/browser2.js +5 -2
- package/dist/main.d.ts +11 -0
- package/dist/main.js +33 -31
- package/dist/src/shield/file-detection.js +62 -56
- package/dist/vendor/@tokenizer/inflate/lib/ZipHandler.js +1 -1
- package/dist/vendor/debug/src/browser.js +1 -1
- package/package.json +1 -1
package/dist/main.d.ts
CHANGED
|
@@ -2,6 +2,12 @@ import { Ref } from 'vue';
|
|
|
2
2
|
import { supportedExtensions } from 'file-type';
|
|
3
3
|
import { supportedMimeTypes } from 'file-type';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* 支持的文件 MIME 类型配置
|
|
7
|
+
* 从 file-type 库导出,可用于UI展示或额外验证
|
|
8
|
+
*/
|
|
9
|
+
export declare const ALLOWED_FILE_MIMES: string[];
|
|
10
|
+
|
|
5
11
|
/**
|
|
6
12
|
* 支持的文件类型配置
|
|
7
13
|
* 基于 file-type 库的 supportedMimeTypes 动态生成
|
|
@@ -334,6 +340,11 @@ export declare function isUrlSafe(url: unknown, options?: IUrlSanitizeOptions):
|
|
|
334
340
|
*/
|
|
335
341
|
export declare function isValidDocument(file: File, maxSize?: number): Promise<IFileDetectionResult>;
|
|
336
342
|
|
|
343
|
+
/**
|
|
344
|
+
* 便捷方法: 检测是否为常规支持的文件类型(基于 MIME 类型)
|
|
345
|
+
*/
|
|
346
|
+
export declare function isValidFile(file: File, maxSize?: number): Promise<IFileDetectionResult>;
|
|
347
|
+
|
|
337
348
|
/**
|
|
338
349
|
* 便捷方法: 检测是否为图片文件(基于 MIME 类型)
|
|
339
350
|
*/
|
package/dist/main.js
CHANGED
|
@@ -1,37 +1,39 @@
|
|
|
1
1
|
import { useCall as o } from "./src/outside-call/index.js";
|
|
2
|
-
import { antiReplyAttackStrategy as i, requestDataEncryption as s, responseDataEncryption as
|
|
3
|
-
import { ALLOWED_FILE_TYPES as
|
|
4
|
-
import { htmlSanitize as
|
|
5
|
-
import { startNoDebugger as
|
|
6
|
-
import { isUrlSafe as
|
|
7
|
-
import { EventBus as
|
|
8
|
-
import { CallLogger as
|
|
9
|
-
import { ECallStatus as
|
|
10
|
-
import { supportedExtensions as
|
|
2
|
+
import { antiReplyAttackStrategy as i, requestDataEncryption as s, responseDataEncryption as E } from "./src/shield/crypto/index.js";
|
|
3
|
+
import { ALLOWED_FILE_MIMES as l, ALLOWED_FILE_TYPES as n, detectFileByExtension as p, detectFileByMime as m, detectionFilesByExtension as x, detectionFilesByMime as S, isValidDocument as d, isValidFile as f, isValidImage as _, isValidVideo as y } from "./src/shield/file-detection.js";
|
|
4
|
+
import { htmlSanitize as u } from "./src/shield/html-sanitize.js";
|
|
5
|
+
import { startNoDebugger as D } from "./src/shield/no-debugger.js";
|
|
6
|
+
import { isUrlSafe as I, sanitizeUrl as L, sanitizeUrls as g } from "./src/shield/url-sanitize.js";
|
|
7
|
+
import { EventBus as V } from "./src/utils/eventBus.js";
|
|
8
|
+
import { CallLogger as C } from "./src/outside-call/utils.js";
|
|
9
|
+
import { ECallStatus as R, EMIT_EVENT_NAME as T, SIP_CODE_MESSAGE as U, SIP_ERROR_CAUSES as z } from "./src/outside-call/constants.js";
|
|
10
|
+
import { supportedExtensions as P, supportedMimeTypes as W } from "./vendor/file-type/source/index.js";
|
|
11
11
|
export {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
R as
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
U as
|
|
12
|
+
l as ALLOWED_FILE_MIMES,
|
|
13
|
+
n as ALLOWED_FILE_TYPES,
|
|
14
|
+
C as CallLogger,
|
|
15
|
+
R as ECallStatus,
|
|
16
|
+
T as EMIT_EVENT_NAME,
|
|
17
|
+
V as EventBus,
|
|
18
|
+
U as SIP_CODE_MESSAGE,
|
|
19
|
+
z as SIP_ERROR_CAUSES,
|
|
19
20
|
i as antiReplyAttackStrategy,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
p as detectFileByExtension,
|
|
22
|
+
m as detectFileByMime,
|
|
23
|
+
x as detectionFilesByExtension,
|
|
24
|
+
S as detectionFilesByMime,
|
|
25
|
+
u as htmlSanitize,
|
|
26
|
+
I as isUrlSafe,
|
|
27
|
+
d as isValidDocument,
|
|
28
|
+
f as isValidFile,
|
|
29
|
+
_ as isValidImage,
|
|
30
|
+
y as isValidVideo,
|
|
29
31
|
s as requestDataEncryption,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
E as responseDataEncryption,
|
|
33
|
+
L as sanitizeUrl,
|
|
34
|
+
g as sanitizeUrls,
|
|
35
|
+
D as startNoDebugger,
|
|
36
|
+
P as supportedExtensions,
|
|
37
|
+
W as supportedMimeTypes,
|
|
36
38
|
o as useCall
|
|
37
39
|
};
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { supportedMimeTypes as
|
|
2
|
-
import { supportedExtensions as
|
|
1
|
+
import { supportedMimeTypes as f, fileTypeFromStream as y } from "../../vendor/file-type/source/index.js";
|
|
2
|
+
import { supportedExtensions as L } from "../../vendor/file-type/source/index.js";
|
|
3
3
|
function d(e) {
|
|
4
4
|
const t = /* @__PURE__ */ new Set();
|
|
5
|
-
for (const
|
|
6
|
-
|
|
5
|
+
for (const i of f)
|
|
6
|
+
i.startsWith(`${e}/`) && t.add(i);
|
|
7
7
|
return t;
|
|
8
8
|
}
|
|
9
|
-
const
|
|
9
|
+
const l = {
|
|
10
10
|
// 图片类型 - 从 supportedMimeTypes 中过滤 image/*
|
|
11
11
|
image: d("image"),
|
|
12
12
|
// 文档类型 - 包含常见办公文档
|
|
13
13
|
document: /* @__PURE__ */ new Set([
|
|
14
|
-
...Array.from(
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
...Array.from(f).filter((e) => {
|
|
15
|
+
const t = e.includes("pdf") || e.includes("msword") || e.includes("officedocument") || e.includes("ms-excel") || e.includes("ms-powerpoint") || e.includes("opendocument") || e === "text/plain", i = e.includes("macroenabled");
|
|
16
|
+
return t && !i;
|
|
17
|
+
})
|
|
17
18
|
]),
|
|
18
19
|
// 视频类型 - 从 supportedMimeTypes 中过滤 video/*
|
|
19
20
|
video: d("video"),
|
|
@@ -21,7 +22,7 @@ const f = {
|
|
|
21
22
|
audio: d("audio"),
|
|
22
23
|
// 压缩文件
|
|
23
24
|
archive: /* @__PURE__ */ new Set([
|
|
24
|
-
...Array.from(
|
|
25
|
+
...Array.from(f).filter(
|
|
25
26
|
(e) => e.includes("zip") || e.includes("rar") || e.includes("7z") || e.includes("tar") || e.includes("gzip") || e.includes("compress")
|
|
26
27
|
)
|
|
27
28
|
]),
|
|
@@ -29,37 +30,37 @@ const f = {
|
|
|
29
30
|
font: d("font"),
|
|
30
31
|
// 模型文件
|
|
31
32
|
model: d("model")
|
|
32
|
-
};
|
|
33
|
-
function
|
|
34
|
-
return t.some((
|
|
35
|
-
const
|
|
36
|
-
if (!
|
|
33
|
+
}, M = Object.values(l).reduce((e, t) => (e.push(...Array.from(t)), e), []);
|
|
34
|
+
function v(e, t) {
|
|
35
|
+
return t.some((i) => {
|
|
36
|
+
const r = i.trim();
|
|
37
|
+
if (!r)
|
|
37
38
|
return !1;
|
|
38
|
-
if (
|
|
39
|
+
if (r === e)
|
|
39
40
|
return !0;
|
|
40
|
-
if (
|
|
41
|
-
const n =
|
|
41
|
+
if (r.endsWith("/*")) {
|
|
42
|
+
const n = r.slice(0, r.indexOf("/"));
|
|
42
43
|
return e.startsWith(`${n}/`);
|
|
43
44
|
}
|
|
44
45
|
return !1;
|
|
45
46
|
});
|
|
46
47
|
}
|
|
47
48
|
async function p(e, t) {
|
|
48
|
-
const { maxSize:
|
|
49
|
-
if (
|
|
49
|
+
const { maxSize: i } = t;
|
|
50
|
+
if (i && e.size > i)
|
|
50
51
|
return {
|
|
51
52
|
valid: !1,
|
|
52
|
-
error: `上传文件大小不能超过 ${(
|
|
53
|
+
error: `上传文件大小不能超过 ${(i / 1024 / 1024).toFixed(2)}MB`,
|
|
53
54
|
claimedMime: e.type
|
|
54
55
|
};
|
|
55
|
-
const
|
|
56
|
-
if (!
|
|
56
|
+
const r = await y(e.stream());
|
|
57
|
+
if (!r)
|
|
57
58
|
return {
|
|
58
59
|
valid: !1,
|
|
59
60
|
error: "无法检测文件类型,可能是不支持的格式或文件已损坏",
|
|
60
61
|
claimedMime: e.type
|
|
61
62
|
};
|
|
62
|
-
const n =
|
|
63
|
+
const n = r.mime, o = r.ext, c = e.type, s = n === c;
|
|
63
64
|
return !s && c && console.warn("文件MIME类型不匹配", {
|
|
64
65
|
claimed: c,
|
|
65
66
|
detected: n,
|
|
@@ -71,12 +72,12 @@ async function p(e, t) {
|
|
|
71
72
|
mimeMatches: s
|
|
72
73
|
};
|
|
73
74
|
}
|
|
74
|
-
async function
|
|
75
|
-
const
|
|
76
|
-
if ("valid" in
|
|
77
|
-
return
|
|
78
|
-
const { detectedMime: n, detectedExt: o, claimedMime: c, mimeMatches: s } =
|
|
79
|
-
return !n || !
|
|
75
|
+
async function a(e, t, i = {}) {
|
|
76
|
+
const r = await p(e, i);
|
|
77
|
+
if ("valid" in r && !r.valid)
|
|
78
|
+
return r;
|
|
79
|
+
const { detectedMime: n, detectedExt: o, claimedMime: c, mimeMatches: s } = r, m = Array.isArray(t) ? t : t.split(",");
|
|
80
|
+
return !n || !v(n, m) ? {
|
|
80
81
|
valid: !1,
|
|
81
82
|
error: `不支持的文件类型: ${n || "未知"}`,
|
|
82
83
|
detectedMime: n,
|
|
@@ -91,12 +92,12 @@ async function u(e, t, r = {}) {
|
|
|
91
92
|
mimeMatches: s
|
|
92
93
|
};
|
|
93
94
|
}
|
|
94
|
-
async function
|
|
95
|
-
const
|
|
96
|
-
if ("valid" in
|
|
97
|
-
return
|
|
98
|
-
const { detectedMime: n, detectedExt: o, claimedMime: c, mimeMatches: s } =
|
|
99
|
-
return !o || !m.some((
|
|
95
|
+
async function A(e, t, i = {}) {
|
|
96
|
+
const r = await p(e, i);
|
|
97
|
+
if ("valid" in r && !r.valid)
|
|
98
|
+
return r;
|
|
99
|
+
const { detectedMime: n, detectedExt: o, claimedMime: c, mimeMatches: s } = r, m = Array.isArray(t) ? t : t.split(",").map((u) => u.trim());
|
|
100
|
+
return !o || !m.some((u) => o === u || `.${o}` === u) ? {
|
|
100
101
|
valid: !1,
|
|
101
102
|
error: `不支持的文件扩展名: .${o || "未知"}`,
|
|
102
103
|
detectedMime: n,
|
|
@@ -111,33 +112,38 @@ async function v(e, t, r = {}) {
|
|
|
111
112
|
mimeMatches: s
|
|
112
113
|
};
|
|
113
114
|
}
|
|
114
|
-
function
|
|
115
|
-
return Promise.all(e.map((
|
|
115
|
+
function x(e, t, i = {}) {
|
|
116
|
+
return Promise.all(e.map((r) => a(r, t, i)));
|
|
116
117
|
}
|
|
117
|
-
function
|
|
118
|
-
return Promise.all(e.map((
|
|
118
|
+
function F(e, t, i = {}) {
|
|
119
|
+
return Promise.all(e.map((r) => A(r, t, i)));
|
|
119
120
|
}
|
|
120
|
-
function
|
|
121
|
-
const
|
|
122
|
-
return
|
|
121
|
+
function g(e, t) {
|
|
122
|
+
const i = Array.from(l.image);
|
|
123
|
+
return a(e, i, { maxSize: t });
|
|
123
124
|
}
|
|
124
125
|
function w(e, t) {
|
|
125
|
-
const
|
|
126
|
-
return
|
|
126
|
+
const i = Array.from(l.document);
|
|
127
|
+
return a(e, i, { maxSize: t });
|
|
128
|
+
}
|
|
129
|
+
function h(e, t) {
|
|
130
|
+
const i = Array.from(l.video);
|
|
131
|
+
return a(e, i, { maxSize: t });
|
|
127
132
|
}
|
|
128
|
-
function
|
|
129
|
-
|
|
130
|
-
return u(e, r, { maxSize: t });
|
|
133
|
+
function S(e, t) {
|
|
134
|
+
return a(e, M, { maxSize: t });
|
|
131
135
|
}
|
|
132
136
|
export {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
137
|
+
M as ALLOWED_FILE_MIMES,
|
|
138
|
+
l as ALLOWED_FILE_TYPES,
|
|
139
|
+
A as detectFileByExtension,
|
|
140
|
+
a as detectFileByMime,
|
|
141
|
+
F as detectionFilesByExtension,
|
|
142
|
+
x as detectionFilesByMime,
|
|
138
143
|
w as isValidDocument,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
144
|
+
S as isValidFile,
|
|
145
|
+
g as isValidImage,
|
|
146
|
+
h as isValidVideo,
|
|
147
|
+
L as supportedExtensions,
|
|
148
|
+
f as supportedMimeTypes
|
|
143
149
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UINT32_LE as h, StringType as k } from "../../../token-types/lib/index.js";
|
|
2
|
-
import D from "../../../../commonjs-virtual-dir/
|
|
2
|
+
import D from "../../../../commonjs-virtual-dir/browser2.js";
|
|
3
3
|
import { Signature as c, EndOfCentralDirectoryRecordToken as L, FileHeader as E, DataDescriptor as y, LocalFileHeaderToken as S } from "./ZipToken.js";
|
|
4
4
|
function m(s) {
|
|
5
5
|
const t = new Uint8Array(h.len);
|