@nocobase/utils 1.9.46 → 1.9.47
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 +1 -0
- package/lib/client.js +2 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -0
- package/lib/ses.d.ts +12 -0
- package/lib/ses.js +127 -0
- package/package.json +4 -3
package/lib/client.d.ts
CHANGED
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);
|
|
@@ -86,6 +87,7 @@ __reExport(client_exports, require("./transformMultiColumnToSingleColumn"), modu
|
|
|
86
87
|
...require("./number"),
|
|
87
88
|
...require("./parse-filter"),
|
|
88
89
|
...require("./registry"),
|
|
90
|
+
...require("./ses"),
|
|
89
91
|
...require("./i18n"),
|
|
90
92
|
...require("./isPortalInBody"),
|
|
91
93
|
...require("./parseHTML"),
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -66,6 +66,7 @@ __reExport(src_exports, require("./parse-filter"), module.exports);
|
|
|
66
66
|
__reExport(src_exports, require("./perf-hooks"), module.exports);
|
|
67
67
|
__reExport(src_exports, require("./registry"), module.exports);
|
|
68
68
|
__reExport(src_exports, require("./requireModule"), module.exports);
|
|
69
|
+
__reExport(src_exports, require("./ses"), module.exports);
|
|
69
70
|
__reExport(src_exports, require("./toposort"), module.exports);
|
|
70
71
|
__reExport(src_exports, require("./uid"), module.exports);
|
|
71
72
|
__reExport(src_exports, require("./url"), module.exports);
|
|
@@ -103,6 +104,7 @@ var import_json_schema = require("@formily/json-schema");
|
|
|
103
104
|
...require("./perf-hooks"),
|
|
104
105
|
...require("./registry"),
|
|
105
106
|
...require("./requireModule"),
|
|
107
|
+
...require("./ses"),
|
|
106
108
|
...require("./toposort"),
|
|
107
109
|
...require("./uid"),
|
|
108
110
|
...require("./url"),
|
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": "1.9.
|
|
3
|
+
"version": "1.9.47",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"graphlib": "^2.1.8",
|
|
16
16
|
"handlebars": "^4.7.8",
|
|
17
17
|
"multer": "^1.4.5-lts.2",
|
|
18
|
-
"object-path": "^0.11.8"
|
|
18
|
+
"object-path": "^0.11.8",
|
|
19
|
+
"ses": "^1.14.0"
|
|
19
20
|
},
|
|
20
|
-
"gitHead": "
|
|
21
|
+
"gitHead": "bc3787003d581cc1453444de53d23c7c41b862d8"
|
|
21
22
|
}
|