module-develop-kit 0.5.13 → 1.0.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.
Files changed (100) hide show
  1. package/dist/commonjs-virtual-dir/_commonjsHelpers.js +4 -6
  2. package/dist/commonjs-virtual-dir/_virtual_mobile-compatibility-detection.js +1 -1
  3. package/dist/commonjs-virtual-dir/index.js +3 -3
  4. package/dist/commonjs-virtual-dir/index2.js +5 -3
  5. package/dist/commonjs-virtual-dir/index3.js +3 -5
  6. package/dist/commonjs-virtual-dir/index4.js +2 -5
  7. package/dist/commonjs-virtual-dir/index5.js +2 -2
  8. package/dist/commonjs-virtual-dir/index6.js +2 -2
  9. package/dist/main.d.ts +74 -104
  10. package/dist/main.js +16 -20
  11. package/dist/src/outside-call/utils.js +1 -1
  12. package/dist/src/shield/crypto/const.js +4 -0
  13. package/dist/src/shield/crypto/index.js +53 -0
  14. package/dist/src/shield/crypto/sm2.js +7 -0
  15. package/dist/src/shield/crypto/sm4.js +15 -0
  16. package/dist/src/shield/crypto/util.js +29 -0
  17. package/dist/src/shield/html-sanitize.js +21 -0
  18. package/dist/src/vite-plugins/getCompatibilityPlugins.js +19 -8
  19. package/dist/src/vite-plugins/vitePluginCompatibilityDetection.js +8 -10
  20. package/dist/vendor/base64-js/index.js +1 -1
  21. package/dist/vendor/jsbn/index.js +1 -1
  22. package/dist/vendor/sdp-transform/lib/index.js +1 -1
  23. package/dist/vite-plugins/index.d.ts +5 -5
  24. package/package.json +3 -3
  25. package/dist/commonjs-virtual-dir/_commonjs-dynamic-modules.js +0 -6
  26. package/dist/commonjs-virtual-dir/aes.js +0 -4
  27. package/dist/commonjs-virtual-dir/blowfish.js +0 -4
  28. package/dist/commonjs-virtual-dir/cipher-core.js +0 -4
  29. package/dist/commonjs-virtual-dir/core.js +0 -4
  30. package/dist/commonjs-virtual-dir/enc-base64.js +0 -4
  31. package/dist/commonjs-virtual-dir/enc-base64url.js +0 -4
  32. package/dist/commonjs-virtual-dir/enc-utf16.js +0 -4
  33. package/dist/commonjs-virtual-dir/evpkdf.js +0 -4
  34. package/dist/commonjs-virtual-dir/format-hex.js +0 -4
  35. package/dist/commonjs-virtual-dir/hmac.js +0 -4
  36. package/dist/commonjs-virtual-dir/index7.js +0 -4
  37. package/dist/commonjs-virtual-dir/index8.js +0 -4
  38. package/dist/commonjs-virtual-dir/lib-typedarrays.js +0 -4
  39. package/dist/commonjs-virtual-dir/md5.js +0 -4
  40. package/dist/commonjs-virtual-dir/mode-cfb.js +0 -4
  41. package/dist/commonjs-virtual-dir/mode-ctr-gladman.js +0 -4
  42. package/dist/commonjs-virtual-dir/mode-ctr.js +0 -4
  43. package/dist/commonjs-virtual-dir/mode-ecb.js +0 -4
  44. package/dist/commonjs-virtual-dir/mode-ofb.js +0 -4
  45. package/dist/commonjs-virtual-dir/pad-ansix923.js +0 -4
  46. package/dist/commonjs-virtual-dir/pad-iso10126.js +0 -4
  47. package/dist/commonjs-virtual-dir/pad-iso97971.js +0 -4
  48. package/dist/commonjs-virtual-dir/pad-nopadding.js +0 -4
  49. package/dist/commonjs-virtual-dir/pad-zeropadding.js +0 -4
  50. package/dist/commonjs-virtual-dir/pbkdf2.js +0 -4
  51. package/dist/commonjs-virtual-dir/rabbit-legacy.js +0 -4
  52. package/dist/commonjs-virtual-dir/rabbit.js +0 -4
  53. package/dist/commonjs-virtual-dir/rc4.js +0 -4
  54. package/dist/commonjs-virtual-dir/ripemd160.js +0 -4
  55. package/dist/commonjs-virtual-dir/sha1.js +0 -4
  56. package/dist/commonjs-virtual-dir/sha224.js +0 -4
  57. package/dist/commonjs-virtual-dir/sha256.js +0 -4
  58. package/dist/commonjs-virtual-dir/sha3.js +0 -4
  59. package/dist/commonjs-virtual-dir/sha384.js +0 -4
  60. package/dist/commonjs-virtual-dir/sha512.js +0 -4
  61. package/dist/commonjs-virtual-dir/tripledes.js +0 -4
  62. package/dist/commonjs-virtual-dir/x64-core.js +0 -4
  63. package/dist/src/shield/crypto.js +0 -28
  64. package/dist/src/shield/index.js +0 -59
  65. package/dist/vendor/crypto-js/aes.js +0 -69
  66. package/dist/vendor/crypto-js/blowfish.js +0 -1131
  67. package/dist/vendor/crypto-js/cipher-core.js +0 -544
  68. package/dist/vendor/crypto-js/core.js +0 -508
  69. package/dist/vendor/crypto-js/enc-base64.js +0 -80
  70. package/dist/vendor/crypto-js/enc-base64url.js +0 -87
  71. package/dist/vendor/crypto-js/enc-utf16.js +0 -99
  72. package/dist/vendor/crypto-js/evpkdf.js +0 -70
  73. package/dist/vendor/crypto-js/format-hex.js +0 -53
  74. package/dist/vendor/crypto-js/hmac.js +0 -83
  75. package/dist/vendor/crypto-js/index.js +0 -49
  76. package/dist/vendor/crypto-js/lib-typedarrays.js +0 -27
  77. package/dist/vendor/crypto-js/md5.js +0 -71
  78. package/dist/vendor/crypto-js/mode-cfb.js +0 -36
  79. package/dist/vendor/crypto-js/mode-ctr-gladman.js +0 -45
  80. package/dist/vendor/crypto-js/mode-ctr.js +0 -28
  81. package/dist/vendor/crypto-js/mode-ecb.js +0 -27
  82. package/dist/vendor/crypto-js/mode-ofb.js +0 -26
  83. package/dist/vendor/crypto-js/pad-ansix923.js +0 -25
  84. package/dist/vendor/crypto-js/pad-iso10126.js +0 -25
  85. package/dist/vendor/crypto-js/pad-iso97971.js +0 -23
  86. package/dist/vendor/crypto-js/pad-nopadding.js +0 -21
  87. package/dist/vendor/crypto-js/pad-zeropadding.js +0 -28
  88. package/dist/vendor/crypto-js/pbkdf2.js +0 -74
  89. package/dist/vendor/crypto-js/rabbit-legacy.js +0 -73
  90. package/dist/vendor/crypto-js/rabbit.js +0 -75
  91. package/dist/vendor/crypto-js/rc4.js +0 -63
  92. package/dist/vendor/crypto-js/ripemd160.js +0 -398
  93. package/dist/vendor/crypto-js/sha1.js +0 -49
  94. package/dist/vendor/crypto-js/sha224.js +0 -36
  95. package/dist/vendor/crypto-js/sha256.js +0 -57
  96. package/dist/vendor/crypto-js/sha3.js +0 -116
  97. package/dist/vendor/crypto-js/sha384.js +0 -37
  98. package/dist/vendor/crypto-js/sha512.js +0 -147
  99. package/dist/vendor/crypto-js/tripledes.js +0 -729
  100. package/dist/vendor/crypto-js/x64-core.js +0 -235
@@ -1,8 +1,7 @@
1
- var u = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
2
- function f(e) {
1
+ function u(e) {
3
2
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
4
3
  }
5
- function l(e) {
4
+ function c(e) {
6
5
  if (Object.prototype.hasOwnProperty.call(e, "__esModule")) return e;
7
6
  var n = e.default;
8
7
  if (typeof n == "function") {
@@ -27,7 +26,6 @@ function l(e) {
27
26
  }), t;
28
27
  }
29
28
  export {
30
- u as commonjsGlobal,
31
- l as getAugmentedNamespace,
32
- f as getDefaultExportFromCjs
29
+ c as getAugmentedNamespace,
30
+ u as getDefaultExportFromCjs
33
31
  };
@@ -1,4 +1,4 @@
1
- const t = '"use strict";try{import.meta.url,import("_").catch(()=>1),async function*(){}().next()}catch(t){console.log("not support")}';
1
+ const t = `(()=>{function t(){var t;t=()=>{document.body.innerHTML='<div style="width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); position: fixed; left: 0; top: 0"><div style="width: 80%; background-color: #fff; margin: 200px auto; padding: 18px 22px 18px 16px; border-radius: 12px;"><div style="color: #4e5969; font-size: 14px; margin: 24px 0 26px 0">推荐使用谷歌浏览器访问系统,以获得更优操作体验,减少兼容问题</div><div style="display: flex; justify-content: center"><a href="https://www.google.cn/chrome/" target="_blank" class="know-btn" style="width: 146px;height: 32px;color: #fff;background-color: #2954ff;text-align: center;font-size: 14px;cursor: pointer;border-radius: 4px;text-decoration: none;display: flex;align-items: center;justify-content: center;">下载谷歌浏览器</a></div></div></div>',document.title="不支持该浏览器"},document.body?t():window.addEventListener("load",t,{once:!0})}try{(function(){try{return new Function('9007199254740991n === BigInt("12345678901234567890");2 ?? 1;3 || 4;window?.a?.b?.c;Promise.allSettled([1, 2, 3]);"a?.b".matchAll(/./g);import("___").catch(() => 1);\\n if(!window.globalThis){throw new Error("no globalThis");}')(),!0}catch(t){return!1}})()||t()}catch(o){console.log("检测脚本执行失败",o),t()}})();`;
2
2
  export {
3
3
  t as default
4
4
  };
@@ -1,5 +1,5 @@
1
- import { __require as r } from "../vendor/gm-crypt/index.js";
2
- var p = r();
1
+ import { __require as r } from "../vendor/sm-crypto/src/index.js";
2
+ var s = r();
3
3
  export {
4
- p as g
4
+ s
5
5
  };
@@ -1,5 +1,7 @@
1
- import { __require as r } from "../vendor/sm-crypto/src/index.js";
2
- var s = r();
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
- s
6
+ a as default
5
7
  };
@@ -1,7 +1,5 @@
1
- import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
2
- import { __require as o } from "../vendor/crypto-js/index.js";
3
- var t = o();
4
- const s = /* @__PURE__ */ r(t);
1
+ import { __require as r } from "../vendor/gm-crypt/index.js";
2
+ var p = r();
5
3
  export {
6
- s as default
4
+ p as g
7
5
  };
@@ -1,7 +1,4 @@
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);
1
+ var r = {};
5
2
  export {
6
- a as default
3
+ r as __exports
7
4
  };
@@ -1,4 +1,4 @@
1
- var o = { exports: {} };
1
+ var e = { exports: {} };
2
2
  export {
3
- o as __module
3
+ e as __module
4
4
  };
@@ -1,4 +1,4 @@
1
- var r = {};
1
+ var s = {};
2
2
  export {
3
- r as __exports
3
+ s as __exports
4
4
  };
package/dist/main.d.ts CHANGED
@@ -1,31 +1,18 @@
1
- import { default as default_2 } from 'crypto-js';
2
1
  import { Ref } from 'vue';
3
2
 
4
3
  /**
5
- * 使用AES算法对字符串进行解密。
6
- * 该函数接收一个密钥、待解密的字符串或CipherParams对象以及初始化向量(IV),并返回解密后的字符串。
7
- * 解密过程使用CBC模式和Pkcs7填充方式。
8
- * 待解密的字符串或CipherParams对象将通过CryptoJS库处理。
9
- * 初始化向量会被解析为UTF-8格式以确保正确解密。
10
- *
11
- * @param {string} key - AES解密所需的密钥,作为字符串提供。
12
- * @param {string | CryptoJS.lib.CipherParams} str - 待解密的字符串或CipherParams对象。
13
- * @param {string} iv - 初始化向量,用于AES解密,作为字符串提供。
14
- * @returns {string} 返回解密后的字符串,结果将以UTF-8编码格式呈现。
4
+ * 防重放攻击策略
5
+ * @param uid
6
+ * @param salt
7
+ * @param ts
8
+ * @param data
9
+ * @param headers
15
10
  */
16
- export declare const aesDecryptString: (key: string, str: string | default_2.lib.CipherParams, iv: string) => string;
17
-
18
- /**
19
- * 使用AES加密算法对字符串或WordArray进行加密。
20
- * 该函数基于CryptoJS库实现,采用CBC模式和Pkcs7填充方式。
21
- * 加密时需要提供密钥、待加密的数据以及初始化向量(IV)。
22
- *
23
- * @param {string} key - 用于加密的密钥,必须为字符串类型。
24
- * @param {string | CryptoJS.lib.WordArray} str - 待加密的字符串或WordArray对象。
25
- * @param {string} iv - 初始化向量,必须为字符串类型,用于增强加密的安全性。
26
- * @returns {string} 返回加密后的字符串,结果为Base64编码格式。
27
- */
28
- export declare const aesEncryptString: (key: string, str: string | default_2.lib.WordArray, iv: string) => string;
11
+ export declare function antiReplyAttackStrategy({ uid, salt, ts, data, ...headers }: IAntiReplyAttackStrategy): {
12
+ "X-Sign-Timestamp": string;
13
+ "X-Sign-Nonce": string;
14
+ "X-Sign-Client": string;
15
+ };
29
16
 
30
17
  /**
31
18
  * 用于格式化输出会话过程中的日志信息
@@ -36,18 +23,6 @@ export declare const CallLogger: {
36
23
  error(message: unknown, ...args: unknown[]): void;
37
24
  };
38
25
 
39
- /**
40
- * 创建带有签名信息的请求头对象。
41
- * 该方法根据传入的参数生成时间戳、随机数和签名,并将它们添加到自定义请求头中。
42
- *
43
- * @return 包含签名信息和自定义请求头的完整请求头对象。
44
- */
45
- export declare function createHeaders({ uid, salt, ts, data, ...headers }: ICreateHeaders): {
46
- "X-Sign-Timestamp": string;
47
- "X-Sign-Nonce": string;
48
- "X-Sign-Client": string;
49
- };
50
-
51
26
  export declare enum ECallStatus {
52
27
  /**
53
28
  * 正在接听中
@@ -79,6 +54,14 @@ export declare enum ECallStatus {
79
54
  RECONNECT = "reconnect"
80
55
  }
81
56
 
57
+ declare enum EHeaderKey {
58
+ publicKey = "X-Public-Key",
59
+ encryptIv = "X-Encrypted-Iv",
60
+ encryptKey = "X-Encrypted-Key",
61
+ encryptIvLow = "x-encrypted-iv",
62
+ encryptKeyLow = "x-encrypted-key"
63
+ }
64
+
82
65
  export declare const EMIT_EVENT_NAME: {
83
66
  UPDATE_STATUS: string;
84
67
  };
@@ -123,21 +106,35 @@ export declare interface EventBusProps {
123
106
 
124
107
  declare type EventFnc = (...args: any) => void;
125
108
 
126
- /**
127
- * 生成指定长度的随机字符串。
128
- * 该函数通过从包含大小写字母和数字的字符集合中随机选取字符,拼接成所需长度的字符串。
129
- * 参数 length 必须为正整数,表示生成的随机字符串的长度。
130
- * 返回值是一个由大小写字母和数字组成的随机字符串。
131
- * 如果传入的 length 小于等于 0,则返回的字符串可能为空。
132
- */
133
- export declare const generateRandomString: (length: number) => string;
134
-
135
109
  /**
136
110
  * 安全的解析html内容 防止xss攻击
137
111
  * @param input 输入的html内容
138
112
  */
139
113
  export declare function htmlSanitize(input: string): string;
140
114
 
115
+ export declare interface IAntiReplyAttackStrategy {
116
+ /**
117
+ * 用户唯一标识符,用于参与签名的生成
118
+ */
119
+ uid: string;
120
+ /**
121
+ * 加密盐值,用于增强签名的安全性
122
+ */
123
+ salt: string;
124
+ /**
125
+ * 时间戳偏移量,用于调整当前时间戳的值
126
+ */
127
+ ts: number;
128
+ /**
129
+ * 待传输的数据对象,非必填
130
+ */
131
+ data?: TData;
132
+ /**
133
+ * 其他header的内容
134
+ */
135
+ [key: string]: TData;
136
+ }
137
+
141
138
  /**
142
139
  * jssip、音频播放相关配置信息
143
140
  */
@@ -205,30 +202,12 @@ export declare interface ICallOptions {
205
202
  call: string;
206
203
  }
207
204
 
208
- declare interface ICreateHeaders {
209
- /**
210
- * 用户唯一标识符,用于参与签名的生成
211
- */
212
- uid: string;
213
- /**
214
- * 加密盐值,用于增强签名的安全性
215
- */
216
- salt: string;
217
- /**
218
- * 时间戳偏移量,用于调整当前时间戳的值
219
- */
220
- ts: number;
221
- /**
222
- * 待传输的数据对象,非必填
223
- */
224
- data?: TData;
225
- /**
226
- * 其他header的内容
227
- */
228
- [key: string]: TData;
205
+ export declare interface IResponseDataEncryptionStep {
206
+ data: string;
207
+ headers: Record<EHeaderKey, string>;
229
208
  }
230
209
 
231
- declare interface ISm4Params {
210
+ export declare interface ISm4Params {
232
211
  /**
233
212
  * 解密向量
234
213
  */
@@ -237,13 +216,31 @@ declare interface ISm4Params {
237
216
  * 解密密钥
238
217
  */
239
218
  key: string;
240
- /**
241
- * 解密模式
242
- * @default cbc
243
- */
244
- mode?: "cbc" | "ecb";
245
219
  }
246
220
 
221
+ /**
222
+ * 请求数据加密
223
+ * @param publicKey 公钥
224
+ * @param _data 数据
225
+ */
226
+ export declare function requestDataEncryption(publicKey: string, _data?: TData): {
227
+ headers: {
228
+ "X-Encrypted-Iv": string;
229
+ "X-Encrypted-Key": string;
230
+ };
231
+ data: {
232
+ body: string;
233
+ };
234
+ };
235
+
236
+ /**
237
+ * 响应数据解密
238
+ * @param stepCb
239
+ */
240
+ export declare function responseDataEncryption<T>(stepCb: (_headers: {
241
+ [EHeaderKey.publicKey]: string;
242
+ }) => Promise<IResponseDataEncryptionStep>): Promise<T>;
243
+
247
244
  /**
248
245
  * sip code对应的的状态,优先处理 code 对应的提示文案,如果不存在则按照 causes 状态去处理
249
246
  */
@@ -299,47 +296,20 @@ declare interface SipAccount {
299
296
  password: string;
300
297
  }
301
298
 
302
- /**
303
- * SM4解密
304
- * @param data 解密数据
305
- * @param params 解密参数
306
- */
307
- export declare const sm4Decrypt: (data: string, params: ISm4Params) => string;
308
-
309
- /**
310
- * SM4加密
311
- * @param data 加密数据
312
- * @param params 加密参数
313
- */
314
- export declare const sm4Encrypt: (data: string, params: ISm4Params) => string;
315
-
316
299
  /**
317
300
  * 禁用用户debugger
318
301
  */
319
302
  export declare const startNoDebugger: () => void;
320
303
 
321
- declare type TData = _TData | _TData[];
304
+ export declare type TData = _TData | _TData[];
322
305
 
323
306
  declare type _TData = null | undefined | number | string | Record<string, any>;
324
307
 
325
- declare type TEncryptionType = "sm4" | "ase";
308
+ export declare type TNullable<T> = T | null;
326
309
 
327
- /**
328
- * 传输数据加密方法,用于在发送数据前对其进行加密。
329
- * @param key - 加密使用的密钥字符串。
330
- * @param _data - 待加密的数据对象,默认为undefined。
331
- * @param type - 加密算法类型,可选值包括"sm4"和"ase",默认使用"ase"。
332
- * @returns 返回一个对象,包含headers(含有初始化向量iv及Content-Type)和data(含有加密后的body),适用于HTTP请求的格式。
333
- */
334
- export declare function transmissionDataEncryption(key: string, _data?: TData, type?: TEncryptionType): {
335
- headers: {
336
- iv: string;
337
- "Content-Type": string;
338
- };
339
- data: {
340
- body: string;
341
- };
342
- };
310
+ export declare type TObj<K extends keyof any = string, T = any> = Record<K, T>;
311
+
312
+ export declare type TUndefinable<T> = T | undefined;
343
313
 
344
314
  /**
345
315
  * 打电话
package/dist/main.js CHANGED
@@ -1,25 +1,21 @@
1
1
  import { useCall as e } from "./src/outside-call/index.js";
2
- import { createHeaders as a, htmlSanitize as E, transmissionDataEncryption as n } from "./src/shield/index.js";
3
- import { aesDecryptString as p, aesEncryptString as s, generateRandomString as S, sm4Decrypt as g, sm4Encrypt as i } from "./src/shield/crypto.js";
4
- import { startNoDebugger as l } from "./src/shield/no-debugger.js";
5
- import { EventBus as c } from "./src/utils/eventBus.js";
6
- import { CallLogger as y } from "./src/outside-call/utils.js";
7
- import { ECallStatus as D, EMIT_EVENT_NAME as u, SIP_CODE_MESSAGE as R, SIP_ERROR_CAUSES as A } from "./src/outside-call/constants.js";
2
+ import { antiReplyAttackStrategy as a, requestDataEncryption as E, responseDataEncryption as p } from "./src/shield/crypto/index.js";
3
+ import { htmlSanitize as l } from "./src/shield/html-sanitize.js";
4
+ import { startNoDebugger as n } from "./src/shield/no-debugger.js";
5
+ import { EventBus as s } from "./src/utils/eventBus.js";
6
+ import { CallLogger as _ } from "./src/outside-call/utils.js";
7
+ import { ECallStatus as i, EMIT_EVENT_NAME as u, SIP_CODE_MESSAGE as C, SIP_ERROR_CAUSES as y } from "./src/outside-call/constants.js";
8
8
  export {
9
- y as CallLogger,
10
- D as ECallStatus,
9
+ _ as CallLogger,
10
+ i as ECallStatus,
11
11
  u as EMIT_EVENT_NAME,
12
- c as EventBus,
13
- R as SIP_CODE_MESSAGE,
14
- A as SIP_ERROR_CAUSES,
15
- p as aesDecryptString,
16
- s as aesEncryptString,
17
- a as createHeaders,
18
- S as generateRandomString,
19
- E as htmlSanitize,
20
- g as sm4Decrypt,
21
- i as sm4Encrypt,
22
- l as startNoDebugger,
23
- n as transmissionDataEncryption,
12
+ s as EventBus,
13
+ C as SIP_CODE_MESSAGE,
14
+ y as SIP_ERROR_CAUSES,
15
+ a as antiReplyAttackStrategy,
16
+ l as htmlSanitize,
17
+ E as requestDataEncryption,
18
+ p as responseDataEncryption,
19
+ n as startNoDebugger,
24
20
  e as useCall
25
21
  };
@@ -1,4 +1,4 @@
1
- import a from "../../commonjs-virtual-dir/index4.js";
1
+ import a from "../../commonjs-virtual-dir/index2.js";
2
2
  const u = {
3
3
  log(e, ...r) {
4
4
  console.log(`%c【${(/* @__PURE__ */ new Date()).toLocaleString()}】`, "color: green; font-weight: bold;", e, ...r);
@@ -0,0 +1,4 @@
1
+ var p = /* @__PURE__ */ ((c) => (c.publicKey = "X-Public-Key", c.encryptIv = "X-Encrypted-Iv", c.encryptKey = "X-Encrypted-Key", c.encryptIvLow = "x-encrypted-iv", c.encryptKeyLow = "x-encrypted-key", c))(p || {});
2
+ export {
3
+ p as EHeaderKey
4
+ };
@@ -0,0 +1,53 @@
1
+ import { s as m } from "../../../commonjs-virtual-dir/index.js";
2
+ import { EHeaderKey as a } from "./const.js";
3
+ import { sm2Encrypt as d, generateKeyPairHex as g, sm2Decrypt as u } from "./sm2.js";
4
+ import { sm4Encrypt as K, sm4Decrypt as S } from "./sm4.js";
5
+ import { hexToBase64 as f, generateRandomString as p, base64ToHex as E, dataToStr as v } from "./util.js";
6
+ function $(o, c) {
7
+ const e = p(), n = p(), t = {
8
+ body: K(
9
+ {
10
+ key: e,
11
+ iv: n
12
+ },
13
+ c
14
+ )
15
+ }, r = f(d(o, e));
16
+ return {
17
+ headers: {
18
+ "X-Encrypted-Iv": n,
19
+ "X-Encrypted-Key": r
20
+ },
21
+ data: t
22
+ };
23
+ }
24
+ async function h(o) {
25
+ const { publicKey: c, privateKey: e } = g(), { data: n, headers: t } = await o({ "X-Public-Key": c }), r = t[a.encryptIv] || t[a.encryptIvLow], s = t[a.encryptKey] || t[a.encryptKeyLow], y = u(e, E(s)), i = S(
26
+ {
27
+ iv: r,
28
+ key: y
29
+ },
30
+ n
31
+ );
32
+ return JSON.parse(i);
33
+ }
34
+ function k({
35
+ uid: o = "",
36
+ salt: c = "",
37
+ ts: e = 0,
38
+ data: n = "",
39
+ ...t
40
+ }) {
41
+ const r = Date.now() + e, s = Math.random().toString(36).substring(2, 15), y = `${r}${o}${s}${v(n)}${c}`, i = m.sm3(y);
42
+ return {
43
+ ...t,
44
+ "X-Sign-Timestamp": String(r),
45
+ "X-Sign-Nonce": s,
46
+ "X-Sign-Client": i
47
+ };
48
+ }
49
+ export {
50
+ k as antiReplyAttackStrategy,
51
+ $ as requestDataEncryption,
52
+ h as responseDataEncryption
53
+ };
@@ -0,0 +1,7 @@
1
+ import { s as o } from "../../../commonjs-virtual-dir/index.js";
2
+ const c = o.sm2.generateKeyPairHex, s = 1, a = (e, r) => `04${o.sm2.doEncrypt(r, e.toLowerCase(), s)}`, p = (e, r) => o.sm2.doDecrypt(r.toLowerCase().replace(/^04/, ""), e.toLowerCase(), s);
3
+ export {
4
+ c as generateKeyPairHex,
5
+ p as sm2Decrypt,
6
+ a as sm2Encrypt
7
+ };
@@ -0,0 +1,15 @@
1
+ import { g as o } from "../../../commonjs-virtual-dir/index3.js";
2
+ import { dataToStr as r } from "./util.js";
3
+ const c = "cbc", n = (t, e) => new o.sm4({
4
+ key: t.key,
5
+ iv: t.iv,
6
+ mode: c
7
+ }).decrypt(r(e)), p = (t, e) => new o.sm4({
8
+ key: t.key,
9
+ iv: t.iv,
10
+ mode: c
11
+ }).encrypt(r(e));
12
+ export {
13
+ n as sm4Decrypt,
14
+ p as sm4Encrypt
15
+ };
@@ -0,0 +1,29 @@
1
+ function o(n) {
2
+ return typeof n == "object" ? JSON.stringify(n ?? {}) : typeof n == "number" ? String(n) : n ?? "";
3
+ }
4
+ const i = (n = 16) => {
5
+ const r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
6
+ let e = "";
7
+ for (let t = 0; t < n; t++)
8
+ e += r.charAt(Math.floor(Math.random() * r.length));
9
+ return e;
10
+ };
11
+ function a(n) {
12
+ const r = new Uint8Array(n.length / 2);
13
+ for (let t = 0; t < n.length; t += 2)
14
+ r[t / 2] = parseInt(n.slice(t, t + 2), 16);
15
+ const e = String.fromCharCode(...r);
16
+ return btoa(e);
17
+ }
18
+ function g(n) {
19
+ const r = atob(n), e = new Uint8Array(r.length);
20
+ for (let t = 0; t < r.length; t++)
21
+ e[t] = r.charCodeAt(t);
22
+ return Array.from(e, (t) => t.toString(16).padStart(2, "0")).join("");
23
+ }
24
+ export {
25
+ g as base64ToHex,
26
+ o as dataToStr,
27
+ i as generateRandomString,
28
+ a as hexToBase64
29
+ };
@@ -0,0 +1,21 @@
1
+ function h(c) {
2
+ const i = ["script", "iframe", "object", "embed", "link", "meta", "style"], d = ["onerror", "onload", "onclick", "onmouseover", "onfocus", "onmouseenter", "onmouseleave"], l = (t) => /^javascript:/i.test(t) || /^data:text\/html/i.test(t), r = new DOMParser().parseFromString(`<div>${c}</div>`, "text/html"), s = r.body.firstChild;
3
+ function a(t) {
4
+ if (t.nodeType === Node.ELEMENT_NODE) {
5
+ const e = t, u = e.tagName.toLowerCase();
6
+ if (i.includes(u)) {
7
+ const o = e.outerHTML, n = r.createTextNode(o);
8
+ e.replaceWith(n);
9
+ return;
10
+ }
11
+ [...e.attributes].forEach((o) => {
12
+ const n = o.name.toLowerCase(), m = o.value;
13
+ (d.includes(n) || l(m)) && e.removeAttribute(o.name);
14
+ }), [...e.childNodes].forEach(a);
15
+ }
16
+ }
17
+ return [...s.childNodes].forEach(a), s.innerHTML;
18
+ }
19
+ export {
20
+ h as htmlSanitize
21
+ };
@@ -1,12 +1,23 @@
1
- import p from "@vitejs/plugin-legacy";
2
- import { vitePluginCompatibilityDetection as c } from "./vitePluginCompatibilityDetection.js";
3
- const g = (i) => {
1
+ import c from "@vitejs/plugin-legacy";
2
+ import { vitePluginCompatibilityDetection as l } from "./vitePluginCompatibilityDetection.js";
3
+ const f = {
4
+ targets: "since 2021 and > 0.1% in CN",
5
+ renderModernChunks: !1,
6
+ modernPolyfills: !1
7
+ }, g = (o) => {
4
8
  const e = {
5
- start: !0,
6
- startDetection: !0,
7
- ...i || {}
8
- }, t = [], { start: o, startDetection: n, detectionConfig: r, ...s } = e;
9
- return o && (t.push(p(s)), n && t.push(c(r))), t;
9
+ open: !0,
10
+ openDetection: !0,
11
+ ...o || {}
12
+ }, i = e.detectionConfig?.platform === "h5", t = [], { open: s, openDetection: r, detectionConfig: p, ...n } = e;
13
+ return s && (t.push(
14
+ c(
15
+ i ? {
16
+ ...f,
17
+ ...n || {}
18
+ } : n
19
+ )
20
+ ), r && t.push(l(p))), t;
10
21
  };
11
22
  export {
12
23
  g as getCompatibilityPlugins
@@ -1,22 +1,20 @@
1
- import p from "../../commonjs-virtual-dir/_virtual_mobile-compatibility-detection.js";
1
+ import r from "../../commonjs-virtual-dir/_virtual_mobile-compatibility-detection.js";
2
2
  import n from "../../commonjs-virtual-dir/_virtual_pc-compatibility-detection.js";
3
- const a = (e) => {
4
- const t = e || { platform: "pc" };
5
- t.platform === "mobile" && (t.attrs || (t.attrs = {}), t.attrs.type = "module");
6
- const { platform: i, ...o } = t;
3
+ const m = (t) => {
4
+ const { platform: i, ...e } = t || { platform: "pc" };
7
5
  return {
8
6
  name: "vite-plugin-compatibility-detection",
9
7
  enforce: "post",
10
- transformIndexHtml(r) {
8
+ transformIndexHtml(o) {
11
9
  return {
12
- html: r,
10
+ html: o,
13
11
  tags: [
14
12
  {
15
13
  tag: "script",
16
- children: i === "mobile" ? p : n,
14
+ children: i === "h5" ? r : n,
17
15
  // default head-prepend
18
16
  injectTo: "head-prepend",
19
- ...o || {}
17
+ ...e || {}
20
18
  }
21
19
  ]
22
20
  };
@@ -24,5 +22,5 @@ const a = (e) => {
24
22
  };
25
23
  };
26
24
  export {
27
- a as vitePluginCompatibilityDetection
25
+ m as vitePluginCompatibilityDetection
28
26
  };
@@ -1,4 +1,4 @@
1
- import { __exports as F } from "../../commonjs-virtual-dir/index8.js";
1
+ import { __exports as F } from "../../commonjs-virtual-dir/index6.js";
2
2
  var A;
3
3
  function _() {
4
4
  if (A) return F;
@@ -1,4 +1,4 @@
1
- import { __module as C } from "../../commonjs-virtual-dir/index7.js";
1
+ import { __module as C } from "../../commonjs-virtual-dir/index5.js";
2
2
  var $i = C.exports, Y;
3
3
  function Qi() {
4
4
  return Y ? C.exports : (Y = 1, function(x, Hi) {
@@ -1,4 +1,4 @@
1
- import { __exports as r } from "../../../commonjs-virtual-dir/index6.js";
1
+ import { __exports as r } from "../../../commonjs-virtual-dir/index4.js";
2
2
  import { __require as t } from "./parser.js";
3
3
  import { __require as m } from "./writer.js";
4
4
  import { __require as p } from "./grammar.js";
@@ -14,20 +14,20 @@ export declare interface IVitePluginCompatibilityDetectionOptions extends Partia
14
14
  * 检测平台
15
15
  * @default pc
16
16
  */
17
- platform?: "pc" | "mobile";
17
+ platform?: "pc" | "h5";
18
18
  }
19
19
 
20
20
  export declare interface IVitePluginLegacyOptions extends Options {
21
21
  /**
22
- * 是否开启
22
+ * 是否开启检测/legacy的加载。开发环境可以关闭,加快启动速度。
23
23
  * @default true
24
24
  */
25
- start?: boolean;
25
+ open?: boolean;
26
26
  /**
27
- * 是否开启检测
27
+ * 是否开启兼容性检测
28
28
  * @default true
29
29
  */
30
- startDetection?: boolean;
30
+ openDetection?: boolean;
31
31
  /**
32
32
  * 兼容性检测配置
33
33
  */