module-develop-kit 1.2.2 → 1.2.4
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/index2.js +3 -5
- package/dist/commonjs-virtual-dir/index3.js +5 -3
- package/dist/main.d.ts +9 -3
- package/dist/main.js +37 -35
- package/dist/src/outside-call/utils.js +1 -1
- package/dist/src/shield/create-cos-file-name.js +8 -0
- package/dist/src/shield/crypto/sm4.js +1 -1
- package/dist/src/shield/url-sanitize.js +21 -21
- package/dist/vendor/nanoid/index.browser.js +11 -0
- package/dist/vendor/nanoid/url-alphabet/index.js +4 -0
- package/package.json +2 -1
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
var t = o();
|
|
4
|
-
const a = /* @__PURE__ */ r(t);
|
|
1
|
+
import { __require as r } from "../vendor/gm-crypt/index.js";
|
|
2
|
+
var p = r();
|
|
5
3
|
export {
|
|
6
|
-
|
|
4
|
+
p as g
|
|
7
5
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
|
|
2
|
+
import { __require as o } from "../vendor/sdp-transform/lib/index.js";
|
|
3
|
+
var t = o();
|
|
4
|
+
const a = /* @__PURE__ */ r(t);
|
|
3
5
|
export {
|
|
4
|
-
|
|
6
|
+
a as default
|
|
5
7
|
};
|
package/dist/main.d.ts
CHANGED
|
@@ -45,6 +45,11 @@ export declare const CallLogger: {
|
|
|
45
45
|
error(message: unknown, ...args: unknown[]): void;
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
+
/**
|
|
49
|
+
* 基于原始文件后缀生成新的上传文件名
|
|
50
|
+
*/
|
|
51
|
+
export declare const createCosFileName: (file: File, prefix?: string) => string;
|
|
52
|
+
|
|
48
53
|
/**
|
|
49
54
|
* 检测文件真实类型并验证扩展名
|
|
50
55
|
*
|
|
@@ -57,9 +62,8 @@ export declare function detectFileByExtension(file: File, _allowedExtensions: TM
|
|
|
57
62
|
|
|
58
63
|
/**
|
|
59
64
|
* 检测文件真实类型并验证 MIME 类型
|
|
60
|
-
*
|
|
61
65
|
* @param file 要检测的文件
|
|
62
|
-
* @param _allowedMimes 允许的MIME类型列表
|
|
66
|
+
* @param _allowedMimes 允许的MIME类型列表 支持单个或者数组。单个支持使用,分割,支持通配符
|
|
63
67
|
* @param options 检测选项
|
|
64
68
|
* @returns 检测结果
|
|
65
69
|
*/
|
|
@@ -347,6 +351,8 @@ export declare function isValidFile(file: File, maxSize?: number): Promise<IFile
|
|
|
347
351
|
|
|
348
352
|
/**
|
|
349
353
|
* 便捷方法: 检测是否为图片文件(基于 MIME 类型)
|
|
354
|
+
* @file 要检测的文件
|
|
355
|
+
* @maxSize 文件最大尺寸
|
|
350
356
|
*/
|
|
351
357
|
export declare function isValidImage(file: File, maxSize?: number): Promise<IFileDetectionResult>;
|
|
352
358
|
|
|
@@ -376,7 +382,7 @@ export declare interface IUrlSanitizeOptions {
|
|
|
376
382
|
*/
|
|
377
383
|
fallbackUrl?: string;
|
|
378
384
|
/**
|
|
379
|
-
* 是否严格模式,严格模式下只允许 http/https,默认
|
|
385
|
+
* 是否严格模式,严格模式下只允许 http/https,默认 true
|
|
380
386
|
*/
|
|
381
387
|
strictMode?: boolean;
|
|
382
388
|
}
|
package/dist/main.js
CHANGED
|
@@ -1,39 +1,41 @@
|
|
|
1
1
|
import { useCall as o } from "./src/outside-call/index.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
2
|
+
import { createCosFileName as i } from "./src/shield/create-cos-file-name.js";
|
|
3
|
+
import { antiReplyAttackStrategy as a, requestDataEncryption as E, responseDataEncryption as l } from "./src/shield/crypto/index.js";
|
|
4
|
+
import { ALLOWED_FILE_MIMES as n, ALLOWED_FILE_TYPES as m, detectFileByExtension as x, detectFileByMime as f, detectionFilesByExtension as S, detectionFilesByMime as d, isValidDocument as _, isValidFile as c, isValidImage as y, isValidVideo as u } from "./src/shield/file-detection.js";
|
|
5
|
+
import { htmlSanitize as M } from "./src/shield/html-sanitize.js";
|
|
6
|
+
import { startNoDebugger as I } from "./src/shield/no-debugger.js";
|
|
7
|
+
import { isUrlSafe as g, sanitizeUrl as A, sanitizeUrls as C } from "./src/shield/url-sanitize.js";
|
|
8
|
+
import { EventBus as B } from "./src/utils/eventBus.js";
|
|
9
|
+
import { CallLogger as O } from "./src/outside-call/utils.js";
|
|
10
|
+
import { ECallStatus as T, EMIT_EVENT_NAME as U, SIP_CODE_MESSAGE as z, SIP_ERROR_CAUSES as P } from "./src/outside-call/constants.js";
|
|
11
|
+
import { supportedExtensions as b, supportedMimeTypes as h } from "./vendor/file-type/source/index.js";
|
|
11
12
|
export {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
S as
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
y as
|
|
31
|
-
|
|
32
|
-
E as
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
13
|
+
n as ALLOWED_FILE_MIMES,
|
|
14
|
+
m as ALLOWED_FILE_TYPES,
|
|
15
|
+
O as CallLogger,
|
|
16
|
+
T as ECallStatus,
|
|
17
|
+
U as EMIT_EVENT_NAME,
|
|
18
|
+
B as EventBus,
|
|
19
|
+
z as SIP_CODE_MESSAGE,
|
|
20
|
+
P as SIP_ERROR_CAUSES,
|
|
21
|
+
a as antiReplyAttackStrategy,
|
|
22
|
+
i as createCosFileName,
|
|
23
|
+
x as detectFileByExtension,
|
|
24
|
+
f as detectFileByMime,
|
|
25
|
+
S as detectionFilesByExtension,
|
|
26
|
+
d as detectionFilesByMime,
|
|
27
|
+
M as htmlSanitize,
|
|
28
|
+
g as isUrlSafe,
|
|
29
|
+
_ as isValidDocument,
|
|
30
|
+
c as isValidFile,
|
|
31
|
+
y as isValidImage,
|
|
32
|
+
u as isValidVideo,
|
|
33
|
+
E as requestDataEncryption,
|
|
34
|
+
l as responseDataEncryption,
|
|
35
|
+
A as sanitizeUrl,
|
|
36
|
+
C as sanitizeUrls,
|
|
37
|
+
I as startNoDebugger,
|
|
38
|
+
b as supportedExtensions,
|
|
39
|
+
h as supportedMimeTypes,
|
|
38
40
|
o as useCall
|
|
39
41
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { nanoid as s } from "../../vendor/nanoid/index.browser.js";
|
|
2
|
+
const p = (t, n = "") => {
|
|
3
|
+
const e = t.name.lastIndexOf("."), o = e > -1 ? t.name.slice(e) : t.type.split("/").pop() || "";
|
|
4
|
+
return `${n}${s()}${o}`;
|
|
5
|
+
};
|
|
6
|
+
export {
|
|
7
|
+
p as createCosFileName
|
|
8
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const i = ["http:", "https:", "mailto:", "tel:", "sms:", "ftp:", "ftps:"],
|
|
1
|
+
const i = ["http:", "https:", "mailto:", "tel:", "sms:", "ftp:", "ftps:"], n = [
|
|
2
2
|
// eslint-disable-next-line no-script-url
|
|
3
3
|
"javascript:",
|
|
4
4
|
"data:",
|
|
@@ -7,11 +7,11 @@ const i = ["http:", "https:", "mailto:", "tel:", "sms:", "ftp:", "ftps:"], o = [
|
|
|
7
7
|
"about:",
|
|
8
8
|
"blob:"
|
|
9
9
|
];
|
|
10
|
-
function
|
|
10
|
+
function c(t) {
|
|
11
11
|
return t.replace(/[-]/g, "").replace(/\s+/g, "").trim();
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
const
|
|
13
|
+
function a(t) {
|
|
14
|
+
const r = t.toLowerCase();
|
|
15
15
|
return [
|
|
16
16
|
/javascript:/i,
|
|
17
17
|
/data:text\/html/i,
|
|
@@ -25,35 +25,35 @@ function n(t) {
|
|
|
25
25
|
// URL 编码的 javascript
|
|
26
26
|
/\\u006a\\u0061\\u0076\\u0061/i
|
|
27
27
|
// Unicode 编码
|
|
28
|
-
].some((s) => s.test(
|
|
28
|
+
].some((s) => s.test(r) || s.test(t));
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function l(t, r = {}) {
|
|
31
31
|
if (!t || typeof t != "string")
|
|
32
32
|
return !1;
|
|
33
|
-
const
|
|
34
|
-
if (!
|
|
33
|
+
const e = t.trim();
|
|
34
|
+
if (!e)
|
|
35
35
|
return !1;
|
|
36
|
-
if (
|
|
37
|
-
return
|
|
38
|
-
const s =
|
|
39
|
-
if (
|
|
36
|
+
if (e.startsWith("/") || e.startsWith("./") || e.startsWith("../"))
|
|
37
|
+
return r.allowRelative === !1 ? !1 : !a(e);
|
|
38
|
+
const s = c(e);
|
|
39
|
+
if (a(s))
|
|
40
40
|
return !1;
|
|
41
41
|
try {
|
|
42
|
-
const
|
|
43
|
-
return
|
|
42
|
+
const o = new URL(s, "http://example.com").protocol.toLowerCase();
|
|
43
|
+
return r.strictMode ?? !0 ? ["http:", "https:", ...r.extraSafeProtocols || []].includes(o) : n.includes(o) ? !1 : [...i, ...r.extraSafeProtocols || []].includes(o);
|
|
44
44
|
} catch {
|
|
45
45
|
return !1;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
function f(t,
|
|
49
|
-
const
|
|
50
|
-
return
|
|
48
|
+
function f(t, r = {}) {
|
|
49
|
+
const e = r.fallbackUrl || "#";
|
|
50
|
+
return l(t, r) ? t.trim() : e;
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
return t.map((
|
|
52
|
+
function P(t, r = {}) {
|
|
53
|
+
return t.map((e) => f(e, r));
|
|
54
54
|
}
|
|
55
55
|
export {
|
|
56
|
-
|
|
56
|
+
l as isUrlSafe,
|
|
57
57
|
f as sanitizeUrl,
|
|
58
|
-
|
|
58
|
+
P as sanitizeUrls
|
|
59
59
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "module-develop-kit",
|
|
3
3
|
"author": "Front-End team",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "前端项目通用工具包",
|
|
7
7
|
"module": "dist/main.js",
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"file-type": "^22.0.1",
|
|
63
63
|
"gm-crypt": "^0.0.2",
|
|
64
64
|
"jssip": "^3.10.1",
|
|
65
|
+
"nanoid": "^5.1.11",
|
|
65
66
|
"sm-crypto": "^0.3.13"
|
|
66
67
|
}
|
|
67
68
|
}
|