@nocobase/utils 2.1.0-alpha.1 → 2.1.0-alpha.3

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/lib/client.d.ts CHANGED
@@ -23,6 +23,7 @@ export * from './notification';
23
23
  export * from './number';
24
24
  export * from './parse-filter';
25
25
  export * from './registry';
26
+ export * from './ses';
26
27
  export * from './i18n';
27
28
  export * from './isPortalInBody';
28
29
  export * from './parseHTML';
package/lib/client.js CHANGED
@@ -60,6 +60,7 @@ __reExport(client_exports, require("./notification"), module.exports);
60
60
  __reExport(client_exports, require("./number"), module.exports);
61
61
  __reExport(client_exports, require("./parse-filter"), module.exports);
62
62
  __reExport(client_exports, require("./registry"), module.exports);
63
+ __reExport(client_exports, require("./ses"), module.exports);
63
64
  __reExport(client_exports, require("./i18n"), module.exports);
64
65
  __reExport(client_exports, require("./isPortalInBody"), module.exports);
65
66
  __reExport(client_exports, require("./parseHTML"), module.exports);
@@ -90,6 +91,7 @@ __reExport(client_exports, require("./liquidjs"), module.exports);
90
91
  ...require("./number"),
91
92
  ...require("./parse-filter"),
92
93
  ...require("./registry"),
94
+ ...require("./ses"),
93
95
  ...require("./i18n"),
94
96
  ...require("./isPortalInBody"),
95
97
  ...require("./parseHTML"),
package/lib/index.d.ts CHANGED
@@ -36,6 +36,7 @@ export * from './parsedValue';
36
36
  export * from './perf-hooks';
37
37
  export * from './registry';
38
38
  export * from './requireModule';
39
+ export * from './ses';
39
40
  export * from './toposort';
40
41
  export * from './uid';
41
42
  export * from './url';
package/lib/index.js CHANGED
@@ -72,6 +72,7 @@ __reExport(src_exports, require("./parsedValue"), module.exports);
72
72
  __reExport(src_exports, require("./perf-hooks"), module.exports);
73
73
  __reExport(src_exports, require("./registry"), module.exports);
74
74
  __reExport(src_exports, require("./requireModule"), module.exports);
75
+ __reExport(src_exports, require("./ses"), module.exports);
75
76
  __reExport(src_exports, require("./toposort"), module.exports);
76
77
  __reExport(src_exports, require("./uid"), module.exports);
77
78
  __reExport(src_exports, require("./url"), module.exports);
@@ -111,6 +112,7 @@ __reExport(src_exports, require("./liquidjs"), module.exports);
111
112
  ...require("./perf-hooks"),
112
113
  ...require("./registry"),
113
114
  ...require("./requireModule"),
115
+ ...require("./ses"),
114
116
  ...require("./toposort"),
115
117
  ...require("./uid"),
116
118
  ...require("./url"),
@@ -79,7 +79,7 @@ async function importModule(m) {
79
79
  m = (0, import_url.pathToFileURL)(m).href;
80
80
  }
81
81
  const r = (await import(m)).default;
82
- return r.__esModule ? r.default : r;
82
+ return (r == null ? void 0 : r.__esModule) ? r.default : r;
83
83
  }
84
84
  __name(importModule, "importModule");
85
85
  // Annotate the CommonJS export names for ESM import in node:
package/lib/ses.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import type { LockdownOptions } from 'ses';
10
+ import 'ses';
11
+ export declare const BASE_BLOCKED_IDENTIFIERS: string[];
12
+ export declare function lockdownSes(options?: LockdownOptions): void;
package/lib/ses.js ADDED
@@ -0,0 +1,127 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
15
+ var __export = (target, all) => {
16
+ for (var name in all)
17
+ __defProp(target, name, { get: all[name], enumerable: true });
18
+ };
19
+ var __copyProps = (to, from, except, desc) => {
20
+ if (from && typeof from === "object" || typeof from === "function") {
21
+ for (let key of __getOwnPropNames(from))
22
+ if (!__hasOwnProp.call(to, key) && key !== except)
23
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
24
+ }
25
+ return to;
26
+ };
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var ses_exports = {};
29
+ __export(ses_exports, {
30
+ BASE_BLOCKED_IDENTIFIERS: () => BASE_BLOCKED_IDENTIFIERS,
31
+ lockdownSes: () => lockdownSes
32
+ });
33
+ module.exports = __toCommonJS(ses_exports);
34
+ var import_ses = require("ses");
35
+ const SES_LOCK_FLAG = Symbol.for("nocobase.utils.sesLockdown");
36
+ const BUFFER_OVERRIDE_FLAG = Symbol.for("nocobase.utils.bufferOverrides");
37
+ const BASE_BLOCKED_IDENTIFIERS = [
38
+ "globalThis",
39
+ "global",
40
+ "self",
41
+ "Function",
42
+ "AsyncFunction",
43
+ "GeneratorFunction",
44
+ "eval",
45
+ "Compartment",
46
+ "lockdown",
47
+ "harden",
48
+ "assert"
49
+ ];
50
+ function isAlreadyLockedError(error) {
51
+ if (!error || typeof error !== "object") {
52
+ return false;
53
+ }
54
+ const message = error.message || "";
55
+ return message.includes("(SES_ALREADY_LOCKED_DOWN)");
56
+ }
57
+ __name(isAlreadyLockedError, "isAlreadyLockedError");
58
+ function enableBufferPrototypeOverrides() {
59
+ const globalRef = globalThis;
60
+ if (globalRef[BUFFER_OVERRIDE_FLAG]) {
61
+ return;
62
+ }
63
+ const bufferCtor = globalRef.Buffer;
64
+ if (!bufferCtor || !bufferCtor.prototype) {
65
+ return;
66
+ }
67
+ const bufferPrototype = bufferCtor.prototype;
68
+ for (const key of Reflect.ownKeys(bufferPrototype)) {
69
+ const descriptor = Object.getOwnPropertyDescriptor(bufferPrototype, key);
70
+ if (!descriptor || typeof descriptor.value !== "function" || !descriptor.configurable) {
71
+ continue;
72
+ }
73
+ const original = descriptor.value;
74
+ const getter = /* @__PURE__ */ __name(function() {
75
+ return original;
76
+ }, "getter");
77
+ const setter = /* @__PURE__ */ __name(function(value) {
78
+ if (this === bufferPrototype) {
79
+ throw new TypeError(`Cannot assign to read only property '${String(key)}' of object 'Buffer.prototype'`);
80
+ }
81
+ Object.defineProperty(this, key, {
82
+ configurable: true,
83
+ enumerable: true,
84
+ writable: true,
85
+ value
86
+ });
87
+ }, "setter");
88
+ Object.defineProperty(getter, "originalValue", {
89
+ configurable: false,
90
+ enumerable: false,
91
+ writable: false,
92
+ value: original
93
+ });
94
+ Object.defineProperty(bufferPrototype, key, {
95
+ configurable: descriptor.configurable,
96
+ enumerable: descriptor.enumerable,
97
+ get: getter,
98
+ set: setter
99
+ });
100
+ }
101
+ globalRef[BUFFER_OVERRIDE_FLAG] = true;
102
+ }
103
+ __name(enableBufferPrototypeOverrides, "enableBufferPrototypeOverrides");
104
+ function lockdownSes(options) {
105
+ enableBufferPrototypeOverrides();
106
+ const globalRef = globalThis;
107
+ if (globalRef[SES_LOCK_FLAG]) {
108
+ return;
109
+ }
110
+ if (typeof lockdown !== "function") {
111
+ throw new Error("SES lockdown is unavailable in the current runtime environment.");
112
+ }
113
+ try {
114
+ lockdown(options);
115
+ } catch (error) {
116
+ if (!isAlreadyLockedError(error)) {
117
+ throw error;
118
+ }
119
+ }
120
+ globalRef[SES_LOCK_FLAG] = true;
121
+ }
122
+ __name(lockdownSes, "lockdownSes");
123
+ // Annotate the CommonJS export names for ESM import in node:
124
+ 0 && (module.exports = {
125
+ BASE_BLOCKED_IDENTIFIERS,
126
+ lockdownSes
127
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/utils",
3
- "version": "2.1.0-alpha.1",
3
+ "version": "2.1.0-alpha.3",
4
4
  "main": "lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "license": "AGPL-3.0",
@@ -16,7 +16,8 @@
16
16
  "handlebars": "^4.7.8",
17
17
  "liquidjs": "^10.23.0",
18
18
  "multer": "^1.4.5-lts.2",
19
- "object-path": "^0.11.8"
19
+ "object-path": "^0.11.8",
20
+ "ses": "^1.14.0"
20
21
  },
21
- "gitHead": "d27baf21569643d6fa83f882233f4e90eb5b89f1"
22
+ "gitHead": "b4d7448b938c1c3be8b2299ad32c6cbe012dd4ea"
22
23
  }
package/plugin-symlink.js CHANGED
@@ -93,6 +93,14 @@ async function createPluginSymLink(pluginName, sourcePath, nodeModulesPath, plug
93
93
  return;
94
94
  }
95
95
 
96
+ const distClientIndexPath = resolve(sourcePath, pluginName, 'dist', 'client', 'index.js');
97
+
98
+ if (await fs.pathExists(distClientIndexPath)) {
99
+ // Update the mtime of distClientIndexPath
100
+ const now = new Date();
101
+ await fs.utimes(distClientIndexPath, now, now);
102
+ }
103
+
96
104
  try {
97
105
  const targetPath = resolve(sourcePath, pluginName);
98
106