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.
@@ -1,7 +1,5 @@
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
+ import { __require as r } from "../vendor/gm-crypt/index.js";
2
+ var p = r();
5
3
  export {
6
- a as default
4
+ p as g
7
5
  };
@@ -1,5 +1,7 @@
1
- import { __require as r } from "../vendor/gm-crypt/index.js";
2
- var p = 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
- p as g
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,默认 false
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 { 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";
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
- 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,
20
- i as antiReplyAttackStrategy,
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,
31
- s as requestDataEncryption,
32
- E as responseDataEncryption,
33
- L as sanitizeUrl,
34
- g as sanitizeUrls,
35
- D as startNoDebugger,
36
- P as supportedExtensions,
37
- W as supportedMimeTypes,
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
  };
@@ -1,4 +1,4 @@
1
- import c from "../../commonjs-virtual-dir/index2.js";
1
+ import c from "../../commonjs-virtual-dir/index3.js";
2
2
  const g = {
3
3
  log(e, ...r) {
4
4
  console.log(`%c【${(/* @__PURE__ */ new Date()).toLocaleString()}】`, "color: green; font-weight: bold;", e, ...r);
@@ -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
- import { g as o } from "../../../commonjs-virtual-dir/index3.js";
1
+ import { g as o } from "../../../commonjs-virtual-dir/index2.js";
2
2
  import { dataToStr as r } from "./util.js";
3
3
  const c = "cbc", n = (t, e) => new o.sm4({
4
4
  key: t.key,
@@ -1,4 +1,4 @@
1
- const i = ["http:", "https:", "mailto:", "tel:", "sms:", "ftp:", "ftps:"], o = [
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 l(t) {
10
+ function c(t) {
11
11
  return t.replace(/[​-‍]/g, "").replace(/\s+/g, "").trim();
12
12
  }
13
- function n(t) {
14
- const e = t.toLowerCase();
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(e) || s.test(t));
28
+ ].some((s) => s.test(r) || s.test(t));
29
29
  }
30
- function c(t, e = {}) {
30
+ function l(t, r = {}) {
31
31
  if (!t || typeof t != "string")
32
32
  return !1;
33
- const r = t.trim();
34
- if (!r)
33
+ const e = t.trim();
34
+ if (!e)
35
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))
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 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);
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, e = {}) {
49
- const r = e.fallbackUrl || "#";
50
- return c(t, e) ? t.trim() : r;
48
+ function f(t, r = {}) {
49
+ const e = r.fallbackUrl || "#";
50
+ return l(t, r) ? t.trim() : e;
51
51
  }
52
- function m(t, e = {}) {
53
- return t.map((r) => f(r, e));
52
+ function P(t, r = {}) {
53
+ return t.map((e) => f(e, r));
54
54
  }
55
55
  export {
56
- c as isUrlSafe,
56
+ l as isUrlSafe,
57
57
  f as sanitizeUrl,
58
- m as sanitizeUrls
58
+ P as sanitizeUrls
59
59
  };
@@ -0,0 +1,11 @@
1
+ import { urlAlphabet as l } from "./url-alphabet/index.js";
2
+ let o = (t = 21) => {
3
+ let e = "", r = crypto.getRandomValues(new Uint8Array(t |= 0));
4
+ for (; t--; )
5
+ e += l[r[t] & 63];
6
+ return e;
7
+ };
8
+ export {
9
+ o as nanoid,
10
+ l as urlAlphabet
11
+ };
@@ -0,0 +1,4 @@
1
+ let e = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
2
+ export {
3
+ e as urlAlphabet
4
+ };
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.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
  }