module-develop-kit 1.0.6 → 1.1.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/index2.js +3 -5
- package/dist/commonjs-virtual-dir/index3.js +5 -3
- package/dist/main.d.ts +50 -0
- package/dist/main.js +15 -11
- package/dist/src/outside-call/utils.js +1 -1
- package/dist/src/shield/crypto/sm4.js +1 -1
- package/dist/src/shield/url-sanitize.js +59 -0
- package/package.json +1 -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
|
@@ -231,6 +231,14 @@ export declare interface ISm4Params {
|
|
|
231
231
|
key: string;
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
+
/**
|
|
235
|
+
* 检测 URL 是否包含 XSS 攻击
|
|
236
|
+
* @param url - 需要检测的 URL
|
|
237
|
+
* @param options - 配置选项
|
|
238
|
+
* @returns 是否安全
|
|
239
|
+
*/
|
|
240
|
+
export declare function isUrlSafe(url: unknown, options?: UrlSanitizeOptions): boolean;
|
|
241
|
+
|
|
234
242
|
/**
|
|
235
243
|
* 请求数据加密
|
|
236
244
|
* @param publicKey 公钥
|
|
@@ -254,6 +262,22 @@ export declare function responseDataEncryption<T>(stepCb: (_headers: {
|
|
|
254
262
|
[EHeaderKey.publicKey]: string;
|
|
255
263
|
}) => Promise<IResponseDataEncryptionStep>): Promise<T>;
|
|
256
264
|
|
|
265
|
+
/**
|
|
266
|
+
* 消毒 URL,返回安全的 URL 或替代 URL
|
|
267
|
+
* @param url - 需要消毒的 URL
|
|
268
|
+
* @param options - 配置选项
|
|
269
|
+
* @returns 安全的 URL
|
|
270
|
+
*/
|
|
271
|
+
export declare function sanitizeUrl(url: unknown, options?: UrlSanitizeOptions): string;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* 批量消毒 URL 列表
|
|
275
|
+
* @param urls - URL 列表
|
|
276
|
+
* @param options - 配置选项
|
|
277
|
+
* @returns 消毒后的 URL 列表
|
|
278
|
+
*/
|
|
279
|
+
export declare function sanitizeUrls(urls: string[], options?: UrlSanitizeOptions): string[];
|
|
280
|
+
|
|
257
281
|
/**
|
|
258
282
|
* sip code对应的的状态,优先处理 code 对应的提示文案,如果不存在则按照 causes 状态去处理
|
|
259
283
|
*/
|
|
@@ -324,6 +348,32 @@ export declare type TObj<K extends keyof any = string, T = any> = Record<K, T>;
|
|
|
324
348
|
|
|
325
349
|
export declare type TUndefinable<T> = T | undefined;
|
|
326
350
|
|
|
351
|
+
/**
|
|
352
|
+
* URL XSS 防护工具
|
|
353
|
+
* 用于检测和拦截包含 XSS 攻击的 URL
|
|
354
|
+
*/
|
|
355
|
+
/**
|
|
356
|
+
* URL 消毒选项
|
|
357
|
+
*/
|
|
358
|
+
export declare interface UrlSanitizeOptions {
|
|
359
|
+
/**
|
|
360
|
+
* 是否允许相对路径 URL,默认 true
|
|
361
|
+
*/
|
|
362
|
+
allowRelative?: boolean;
|
|
363
|
+
/**
|
|
364
|
+
* 额外的安全协议
|
|
365
|
+
*/
|
|
366
|
+
extraSafeProtocols?: string[];
|
|
367
|
+
/**
|
|
368
|
+
* 当检测到 XSS 时的替代 URL,默认 '#'
|
|
369
|
+
*/
|
|
370
|
+
fallbackUrl?: string;
|
|
371
|
+
/**
|
|
372
|
+
* 是否严格模式,严格模式下只允许 http/https,默认 false
|
|
373
|
+
*/
|
|
374
|
+
strictMode?: boolean;
|
|
375
|
+
}
|
|
376
|
+
|
|
327
377
|
/**
|
|
328
378
|
* 打电话
|
|
329
379
|
* FIXME: callBack 为什么存在?zyy 中通过 useCall 拿到的变量无法实现响应式,所以通过 callback 的方式更新外部依赖。
|
package/dist/main.js
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import { useCall as e } from "./src/outside-call/index.js";
|
|
2
2
|
import { antiReplyAttackStrategy as a, requestDataEncryption as E, responseDataEncryption as p } from "./src/shield/crypto/index.js";
|
|
3
|
-
import { htmlSanitize as
|
|
3
|
+
import { htmlSanitize as s } from "./src/shield/html-sanitize.js";
|
|
4
4
|
import { startNoDebugger as n } from "./src/shield/no-debugger.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { isUrlSafe as f, sanitizeUrl as m, sanitizeUrls as x } from "./src/shield/url-sanitize.js";
|
|
6
|
+
import { EventBus as g } from "./src/utils/eventBus.js";
|
|
7
|
+
import { CallLogger as C } from "./src/outside-call/utils.js";
|
|
8
|
+
import { ECallStatus as A, EMIT_EVENT_NAME as D, SIP_CODE_MESSAGE as R, SIP_ERROR_CAUSES as U } from "./src/outside-call/constants.js";
|
|
8
9
|
export {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
C as CallLogger,
|
|
11
|
+
A as ECallStatus,
|
|
12
|
+
D as EMIT_EVENT_NAME,
|
|
13
|
+
g as EventBus,
|
|
14
|
+
R as SIP_CODE_MESSAGE,
|
|
15
|
+
U as SIP_ERROR_CAUSES,
|
|
15
16
|
a as antiReplyAttackStrategy,
|
|
16
|
-
|
|
17
|
+
s as htmlSanitize,
|
|
18
|
+
f as isUrlSafe,
|
|
17
19
|
E as requestDataEncryption,
|
|
18
20
|
p as responseDataEncryption,
|
|
21
|
+
m as sanitizeUrl,
|
|
22
|
+
x as sanitizeUrls,
|
|
19
23
|
n as startNoDebugger,
|
|
20
24
|
e as useCall
|
|
21
25
|
};
|
|
@@ -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
|
+
};
|