@secure-exec/core 0.1.1-rc.3 → 0.2.0-rc.2
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/esm-compiler.d.ts +5 -1
- package/dist/esm-compiler.js +5 -1
- package/dist/fs-helpers.d.ts +1 -1
- package/dist/generated/isolate-runtime.d.ts +15 -15
- package/dist/generated/isolate-runtime.js +15 -15
- package/dist/index.d.ts +24 -5
- package/dist/index.js +23 -3
- package/dist/isolate-runtime/apply-custom-global-policy.js +3 -3
- package/dist/isolate-runtime/apply-timing-mitigation-freeze.js +2 -2
- package/dist/isolate-runtime/apply-timing-mitigation-off.js +2 -2
- package/dist/isolate-runtime/bridge-attach.js +2 -2
- package/dist/isolate-runtime/bridge-initial-globals.js +145 -6
- package/dist/isolate-runtime/eval-script-result.js +1 -1
- package/dist/isolate-runtime/global-exposure-helpers.js +2 -2
- package/dist/isolate-runtime/init-commonjs-module-globals.js +2 -2
- package/dist/isolate-runtime/override-process-cwd.js +1 -1
- package/dist/isolate-runtime/override-process-env.js +1 -1
- package/dist/isolate-runtime/require-setup.js +2868 -494
- package/dist/isolate-runtime/set-commonjs-file-globals.js +2 -2
- package/dist/isolate-runtime/set-stdin-data.js +1 -1
- package/dist/isolate-runtime/setup-dynamic-import.js +78 -19
- package/dist/isolate-runtime/setup-fs-facade.js +62 -23
- package/dist/kernel/command-registry.d.ts +44 -0
- package/dist/kernel/command-registry.js +114 -0
- package/dist/kernel/device-layer.d.ts +12 -0
- package/dist/kernel/device-layer.js +262 -0
- package/dist/kernel/dns-cache.d.ts +29 -0
- package/dist/kernel/dns-cache.js +52 -0
- package/dist/kernel/fd-table.d.ts +84 -0
- package/dist/kernel/fd-table.js +278 -0
- package/dist/kernel/file-lock.d.ts +34 -0
- package/dist/kernel/file-lock.js +122 -0
- package/dist/kernel/host-adapter.d.ts +50 -0
- package/dist/kernel/host-adapter.js +8 -0
- package/dist/kernel/index.d.ts +36 -0
- package/dist/kernel/index.js +34 -0
- package/dist/kernel/inode-table.d.ts +43 -0
- package/dist/kernel/inode-table.js +85 -0
- package/dist/kernel/kernel.d.ts +9 -0
- package/dist/kernel/kernel.js +1393 -0
- package/dist/kernel/permissions.d.ts +27 -0
- package/dist/kernel/permissions.js +118 -0
- package/dist/kernel/pipe-manager.d.ts +64 -0
- package/dist/kernel/pipe-manager.js +267 -0
- package/dist/kernel/proc-layer.d.ts +11 -0
- package/dist/kernel/proc-layer.js +501 -0
- package/dist/kernel/process-table.d.ts +124 -0
- package/dist/kernel/process-table.js +631 -0
- package/dist/kernel/pty.d.ts +108 -0
- package/dist/kernel/pty.js +541 -0
- package/dist/kernel/socket-table.d.ts +312 -0
- package/dist/kernel/socket-table.js +1188 -0
- package/dist/kernel/timer-table.d.ts +54 -0
- package/dist/kernel/timer-table.js +108 -0
- package/dist/kernel/types.d.ts +500 -0
- package/dist/kernel/types.js +89 -0
- package/dist/kernel/user.d.ts +29 -0
- package/dist/kernel/user.js +35 -0
- package/dist/kernel/vfs.d.ts +54 -0
- package/dist/kernel/vfs.js +8 -0
- package/dist/kernel/wait.d.ts +45 -0
- package/dist/kernel/wait.js +112 -0
- package/dist/kernel/wstatus.d.ts +21 -0
- package/dist/kernel/wstatus.js +33 -0
- package/dist/module-resolver.d.ts +4 -0
- package/dist/module-resolver.js +4 -0
- package/dist/package-bundler.d.ts +6 -1
- package/dist/runtime-driver.d.ts +3 -1
- package/dist/shared/bridge-contract.d.ts +349 -22
- package/dist/shared/bridge-contract.js +62 -5
- package/dist/shared/console-formatter.js +8 -4
- package/dist/shared/global-exposure.js +364 -19
- package/dist/shared/in-memory-fs.d.ts +33 -11
- package/dist/shared/in-memory-fs.js +439 -130
- package/dist/shared/permissions.d.ts +4 -6
- package/dist/shared/permissions.js +19 -39
- package/dist/types.d.ts +8 -159
- package/dist/types.js +5 -0
- package/package.json +12 -22
- package/dist/bridge/active-handles.d.ts +0 -22
- package/dist/bridge/active-handles.js +0 -55
- package/dist/bridge/child-process.d.ts +0 -99
- package/dist/bridge/child-process.js +0 -670
- package/dist/bridge/fs.d.ts +0 -281
- package/dist/bridge/fs.js +0 -2235
- package/dist/bridge/index.d.ts +0 -10
- package/dist/bridge/index.js +0 -41
- package/dist/bridge/module.d.ts +0 -75
- package/dist/bridge/module.js +0 -308
- package/dist/bridge/network.d.ts +0 -350
- package/dist/bridge/network.js +0 -2050
- package/dist/bridge/os.d.ts +0 -13
- package/dist/bridge/os.js +0 -256
- package/dist/bridge/polyfills.d.ts +0 -2
- package/dist/bridge/polyfills.js +0 -11
- package/dist/bridge/process.d.ts +0 -89
- package/dist/bridge/process.js +0 -1015
- package/dist/bridge.js +0 -12496
- package/dist/python-runtime.d.ts +0 -16
- package/dist/python-runtime.js +0 -45
- package/dist/runtime.d.ts +0 -31
- package/dist/runtime.js +0 -69
|
@@ -1,31 +1,96 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
(() => {
|
|
3
|
-
// isolate-runtime/src/inject/require-setup.ts
|
|
4
|
-
var
|
|
5
|
-
|
|
3
|
+
// ../core/isolate-runtime/src/inject/require-setup.ts
|
|
4
|
+
var REQUIRE_TRANSFORM_MARKER = "/*__secure_exec_require_esm__*/";
|
|
5
|
+
var __requireExposeCustomGlobal = typeof globalThis.__runtimeExposeCustomGlobal === "function" ? globalThis.__runtimeExposeCustomGlobal : function exposeCustomGlobal(name, value) {
|
|
6
|
+
Object.defineProperty(globalThis, name, {
|
|
6
7
|
value,
|
|
7
8
|
writable: false,
|
|
8
9
|
configurable: false,
|
|
9
10
|
enumerable: true
|
|
10
11
|
});
|
|
11
12
|
};
|
|
12
|
-
if (typeof globalThis.
|
|
13
|
+
if (typeof globalThis.global === "undefined") {
|
|
14
|
+
globalThis.global = globalThis;
|
|
15
|
+
}
|
|
16
|
+
if (typeof globalThis.RegExp === "function" && !globalThis.RegExp.__secureExecRgiEmojiCompat) {
|
|
17
|
+
const NativeRegExp = globalThis.RegExp;
|
|
18
|
+
const RGI_EMOJI_PATTERN = "^\\p{RGI_Emoji}$";
|
|
19
|
+
const RGI_EMOJI_BASE_CLASS = "[\\u{00A9}\\u{00AE}\\u{203C}\\u{2049}\\u{2122}\\u{2139}\\u{2194}-\\u{21AA}\\u{231A}-\\u{23FF}\\u{24C2}\\u{25AA}-\\u{27BF}\\u{2934}-\\u{2935}\\u{2B05}-\\u{2B55}\\u{3030}\\u{303D}\\u{3297}\\u{3299}\\u{1F000}-\\u{1FAFF}]";
|
|
20
|
+
const RGI_EMOJI_KEYCAP = "[#*0-9]\\uFE0F?\\u20E3";
|
|
21
|
+
const RGI_EMOJI_FALLBACK_SOURCE = "^(?:" + RGI_EMOJI_KEYCAP + "|\\p{Regional_Indicator}{2}|" + RGI_EMOJI_BASE_CLASS + "(?:\\uFE0F|\\u200D(?:" + RGI_EMOJI_KEYCAP + "|" + RGI_EMOJI_BASE_CLASS + ")|[\\u{1F3FB}-\\u{1F3FF}])*)$";
|
|
22
|
+
try {
|
|
23
|
+
new NativeRegExp(RGI_EMOJI_PATTERN, "v");
|
|
24
|
+
} catch (error) {
|
|
25
|
+
if (String(error && error.message || error).includes("RGI_Emoji")) {
|
|
26
|
+
let CompatRegExp = function(pattern, flags) {
|
|
27
|
+
const normalizedPattern = pattern instanceof NativeRegExp && flags === void 0 ? pattern.source : String(pattern);
|
|
28
|
+
const normalizedFlags = flags === void 0 ? pattern instanceof NativeRegExp ? pattern.flags : "" : String(flags);
|
|
29
|
+
try {
|
|
30
|
+
return new NativeRegExp(pattern, flags);
|
|
31
|
+
} catch (innerError) {
|
|
32
|
+
if (normalizedPattern === RGI_EMOJI_PATTERN && normalizedFlags === "v") {
|
|
33
|
+
return new NativeRegExp(RGI_EMOJI_FALLBACK_SOURCE, "u");
|
|
34
|
+
}
|
|
35
|
+
throw innerError;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
CompatRegExp2 = CompatRegExp;
|
|
39
|
+
Object.setPrototypeOf(CompatRegExp, NativeRegExp);
|
|
40
|
+
CompatRegExp.prototype = NativeRegExp.prototype;
|
|
41
|
+
Object.defineProperty(CompatRegExp.prototype, "constructor", {
|
|
42
|
+
value: CompatRegExp,
|
|
43
|
+
writable: true,
|
|
44
|
+
configurable: true
|
|
45
|
+
});
|
|
46
|
+
CompatRegExp.__secureExecRgiEmojiCompat = true;
|
|
47
|
+
globalThis.RegExp = CompatRegExp;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
var CompatRegExp2;
|
|
52
|
+
if (typeof globalThis.AbortController === "undefined" || typeof globalThis.AbortSignal === "undefined" || typeof globalThis.AbortSignal?.prototype?.addEventListener !== "function" || typeof globalThis.AbortSignal?.prototype?.removeEventListener !== "function") {
|
|
53
|
+
let getAbortSignalState = function(signal) {
|
|
54
|
+
const state = abortSignalState.get(signal);
|
|
55
|
+
if (!state) {
|
|
56
|
+
throw new Error("Invalid AbortSignal");
|
|
57
|
+
}
|
|
58
|
+
return state;
|
|
59
|
+
};
|
|
60
|
+
getAbortSignalState2 = getAbortSignalState;
|
|
61
|
+
const abortSignalState = /* @__PURE__ */ new WeakMap();
|
|
13
62
|
class AbortSignal {
|
|
14
63
|
constructor() {
|
|
15
|
-
this.aborted = false;
|
|
16
|
-
this.reason = void 0;
|
|
17
64
|
this.onabort = null;
|
|
18
|
-
this
|
|
65
|
+
abortSignalState.set(this, {
|
|
66
|
+
aborted: false,
|
|
67
|
+
reason: void 0,
|
|
68
|
+
listeners: []
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
get aborted() {
|
|
72
|
+
return getAbortSignalState(this).aborted;
|
|
73
|
+
}
|
|
74
|
+
get reason() {
|
|
75
|
+
return getAbortSignalState(this).reason;
|
|
76
|
+
}
|
|
77
|
+
get _listeners() {
|
|
78
|
+
return getAbortSignalState(this).listeners.slice();
|
|
79
|
+
}
|
|
80
|
+
getEventListeners(type) {
|
|
81
|
+
if (type !== "abort") return [];
|
|
82
|
+
return getAbortSignalState(this).listeners.slice();
|
|
19
83
|
}
|
|
20
84
|
addEventListener(type, listener) {
|
|
21
85
|
if (type !== "abort" || typeof listener !== "function") return;
|
|
22
|
-
this.
|
|
86
|
+
getAbortSignalState(this).listeners.push(listener);
|
|
23
87
|
}
|
|
24
88
|
removeEventListener(type, listener) {
|
|
25
89
|
if (type !== "abort" || typeof listener !== "function") return;
|
|
26
|
-
const
|
|
90
|
+
const listeners = getAbortSignalState(this).listeners;
|
|
91
|
+
const index = listeners.indexOf(listener);
|
|
27
92
|
if (index !== -1) {
|
|
28
|
-
|
|
93
|
+
listeners.splice(index, 1);
|
|
29
94
|
}
|
|
30
95
|
}
|
|
31
96
|
dispatchEvent(event) {
|
|
@@ -36,7 +101,7 @@
|
|
|
36
101
|
} catch {
|
|
37
102
|
}
|
|
38
103
|
}
|
|
39
|
-
const listeners = this.
|
|
104
|
+
const listeners = getAbortSignalState(this).listeners.slice();
|
|
40
105
|
for (const listener of listeners) {
|
|
41
106
|
try {
|
|
42
107
|
listener.call(this, event);
|
|
@@ -51,15 +116,78 @@
|
|
|
51
116
|
this.signal = new AbortSignal();
|
|
52
117
|
}
|
|
53
118
|
abort(reason) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
119
|
+
const state = getAbortSignalState(this.signal);
|
|
120
|
+
if (state.aborted) return;
|
|
121
|
+
state.aborted = true;
|
|
122
|
+
state.reason = reason;
|
|
57
123
|
this.signal.dispatchEvent({ type: "abort" });
|
|
58
124
|
}
|
|
59
125
|
}
|
|
60
126
|
__requireExposeCustomGlobal("AbortSignal", AbortSignal);
|
|
61
127
|
__requireExposeCustomGlobal("AbortController", AbortController);
|
|
62
128
|
}
|
|
129
|
+
var getAbortSignalState2;
|
|
130
|
+
if (typeof globalThis.AbortSignal === "function" && typeof globalThis.AbortController === "function" && typeof globalThis.AbortSignal.abort !== "function") {
|
|
131
|
+
globalThis.AbortSignal.abort = function abort(reason) {
|
|
132
|
+
const controller = new globalThis.AbortController();
|
|
133
|
+
controller.abort(reason);
|
|
134
|
+
return controller.signal;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
if (typeof globalThis.AbortSignal === "function" && typeof globalThis.AbortController === "function" && typeof globalThis.AbortSignal.timeout !== "function") {
|
|
138
|
+
globalThis.AbortSignal.timeout = function timeout(milliseconds) {
|
|
139
|
+
var delay = Number(milliseconds);
|
|
140
|
+
if (!Number.isFinite(delay) || delay < 0) {
|
|
141
|
+
throw new RangeError('The value of "milliseconds" is out of range. It must be a finite, non-negative number.');
|
|
142
|
+
}
|
|
143
|
+
var controller = new globalThis.AbortController();
|
|
144
|
+
var timer = setTimeout(function() {
|
|
145
|
+
controller.abort(
|
|
146
|
+
new globalThis.DOMException(
|
|
147
|
+
"The operation was aborted due to timeout",
|
|
148
|
+
"TimeoutError"
|
|
149
|
+
)
|
|
150
|
+
);
|
|
151
|
+
}, delay);
|
|
152
|
+
if (timer && typeof timer.unref === "function") {
|
|
153
|
+
timer.unref();
|
|
154
|
+
}
|
|
155
|
+
return controller.signal;
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
if (typeof globalThis.AbortSignal === "function" && typeof globalThis.AbortController === "function" && typeof globalThis.AbortSignal.any !== "function") {
|
|
159
|
+
globalThis.AbortSignal.any = function any(signals) {
|
|
160
|
+
if (signals === null || signals === void 0 || typeof signals[Symbol.iterator] !== "function") {
|
|
161
|
+
throw new TypeError('The "signals" argument must be an iterable.');
|
|
162
|
+
}
|
|
163
|
+
var controller = new globalThis.AbortController();
|
|
164
|
+
var cleanup = [];
|
|
165
|
+
var abortFromSignal = function abortFromSignal2(signal) {
|
|
166
|
+
for (var index = 0; index < cleanup.length; index += 1) {
|
|
167
|
+
cleanup[index]();
|
|
168
|
+
}
|
|
169
|
+
cleanup.length = 0;
|
|
170
|
+
controller.abort(signal.reason);
|
|
171
|
+
};
|
|
172
|
+
for (const signal of signals) {
|
|
173
|
+
if (!signal || typeof signal.aborted !== "boolean" || typeof signal.addEventListener !== "function" || typeof signal.removeEventListener !== "function") {
|
|
174
|
+
throw new TypeError('The "signals" argument must contain only AbortSignal instances.');
|
|
175
|
+
}
|
|
176
|
+
if (signal.aborted) {
|
|
177
|
+
abortFromSignal(signal);
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
var listener = function() {
|
|
181
|
+
abortFromSignal(signal);
|
|
182
|
+
};
|
|
183
|
+
signal.addEventListener("abort", listener, { once: true });
|
|
184
|
+
cleanup.push(function() {
|
|
185
|
+
signal.removeEventListener("abort", listener);
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
return controller.signal;
|
|
189
|
+
};
|
|
190
|
+
}
|
|
63
191
|
if (typeof globalThis.structuredClone !== "function") {
|
|
64
192
|
let structuredClonePolyfill = function(value) {
|
|
65
193
|
if (value === null || typeof value !== "object") {
|
|
@@ -80,6 +208,10 @@
|
|
|
80
208
|
__requireExposeCustomGlobal("structuredClone", structuredClonePolyfill);
|
|
81
209
|
}
|
|
82
210
|
var structuredClonePolyfill2;
|
|
211
|
+
if (typeof globalThis.SharedArrayBuffer === "undefined") {
|
|
212
|
+
globalThis.SharedArrayBuffer = ArrayBuffer;
|
|
213
|
+
__requireExposeCustomGlobal("SharedArrayBuffer", ArrayBuffer);
|
|
214
|
+
}
|
|
83
215
|
if (typeof globalThis.btoa !== "function") {
|
|
84
216
|
__requireExposeCustomGlobal("btoa", function btoa(input) {
|
|
85
217
|
return Buffer.from(String(input), "binary").toString("base64");
|
|
@@ -96,58 +228,851 @@
|
|
|
96
228
|
if (lastSlash === 0) return "/";
|
|
97
229
|
return p.slice(0, lastSlash);
|
|
98
230
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
"
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
231
|
+
(function installWhatwgEncodingAndEvents() {
|
|
232
|
+
function _withCode(error, code) {
|
|
233
|
+
error.code = code;
|
|
234
|
+
return error;
|
|
235
|
+
}
|
|
236
|
+
function _trimAsciiWhitespace(value) {
|
|
237
|
+
return value.replace(/^[\t\n\f\r ]+|[\t\n\f\r ]+$/g, "");
|
|
238
|
+
}
|
|
239
|
+
function _normalizeEncodingLabel(label) {
|
|
240
|
+
var normalized = _trimAsciiWhitespace(
|
|
241
|
+
label === void 0 ? "utf-8" : String(label)
|
|
242
|
+
).toLowerCase();
|
|
243
|
+
switch (normalized) {
|
|
244
|
+
case "utf-8":
|
|
245
|
+
case "utf8":
|
|
246
|
+
case "unicode-1-1-utf-8":
|
|
247
|
+
case "unicode11utf8":
|
|
248
|
+
case "unicode20utf8":
|
|
249
|
+
case "x-unicode20utf8":
|
|
250
|
+
return "utf-8";
|
|
251
|
+
case "utf-16":
|
|
252
|
+
case "utf-16le":
|
|
253
|
+
case "ucs-2":
|
|
254
|
+
case "ucs2":
|
|
255
|
+
case "csunicode":
|
|
256
|
+
case "iso-10646-ucs-2":
|
|
257
|
+
case "unicode":
|
|
258
|
+
case "unicodefeff":
|
|
259
|
+
return "utf-16le";
|
|
260
|
+
case "utf-16be":
|
|
261
|
+
case "unicodefffe":
|
|
262
|
+
return "utf-16be";
|
|
263
|
+
default:
|
|
264
|
+
throw _withCode(
|
|
265
|
+
new RangeError('The "' + normalized + '" encoding is not supported'),
|
|
266
|
+
"ERR_ENCODING_NOT_SUPPORTED"
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function _toUint8Array(input) {
|
|
271
|
+
if (input === void 0) {
|
|
272
|
+
return new Uint8Array(0);
|
|
273
|
+
}
|
|
274
|
+
if (ArrayBuffer.isView(input)) {
|
|
275
|
+
return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
|
|
276
|
+
}
|
|
277
|
+
if (input instanceof ArrayBuffer) {
|
|
278
|
+
return new Uint8Array(input);
|
|
279
|
+
}
|
|
280
|
+
if (typeof SharedArrayBuffer !== "undefined" && input instanceof SharedArrayBuffer) {
|
|
281
|
+
return new Uint8Array(input);
|
|
282
|
+
}
|
|
283
|
+
throw _withCode(
|
|
284
|
+
new TypeError(
|
|
285
|
+
'The "input" argument must be an instance of ArrayBuffer, SharedArrayBuffer, or ArrayBufferView.'
|
|
286
|
+
),
|
|
287
|
+
"ERR_INVALID_ARG_TYPE"
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
function _encodeUtf8ScalarValue(codePoint, bytes) {
|
|
291
|
+
if (codePoint <= 127) {
|
|
292
|
+
bytes.push(codePoint);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
if (codePoint <= 2047) {
|
|
296
|
+
bytes.push(192 | codePoint >> 6, 128 | codePoint & 63);
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
if (codePoint <= 65535) {
|
|
300
|
+
bytes.push(
|
|
301
|
+
224 | codePoint >> 12,
|
|
302
|
+
128 | codePoint >> 6 & 63,
|
|
303
|
+
128 | codePoint & 63
|
|
304
|
+
);
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
bytes.push(
|
|
308
|
+
240 | codePoint >> 18,
|
|
309
|
+
128 | codePoint >> 12 & 63,
|
|
310
|
+
128 | codePoint >> 6 & 63,
|
|
311
|
+
128 | codePoint & 63
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
function _encodeUtf8(input) {
|
|
315
|
+
var value = String(input === void 0 ? "" : input);
|
|
316
|
+
var bytes = [];
|
|
317
|
+
for (var index = 0; index < value.length; index += 1) {
|
|
318
|
+
var codeUnit = value.charCodeAt(index);
|
|
319
|
+
if (codeUnit >= 55296 && codeUnit <= 56319) {
|
|
320
|
+
var nextIndex = index + 1;
|
|
321
|
+
if (nextIndex < value.length) {
|
|
322
|
+
var nextCodeUnit = value.charCodeAt(nextIndex);
|
|
323
|
+
if (nextCodeUnit >= 56320 && nextCodeUnit <= 57343) {
|
|
324
|
+
_encodeUtf8ScalarValue(
|
|
325
|
+
65536 + (codeUnit - 55296 << 10) + (nextCodeUnit - 56320),
|
|
326
|
+
bytes
|
|
327
|
+
);
|
|
328
|
+
index = nextIndex;
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
_encodeUtf8ScalarValue(65533, bytes);
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
if (codeUnit >= 56320 && codeUnit <= 57343) {
|
|
336
|
+
_encodeUtf8ScalarValue(65533, bytes);
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
_encodeUtf8ScalarValue(codeUnit, bytes);
|
|
340
|
+
}
|
|
341
|
+
return new Uint8Array(bytes);
|
|
342
|
+
}
|
|
343
|
+
function _appendCodePoint(output, codePoint) {
|
|
344
|
+
if (codePoint <= 65535) {
|
|
345
|
+
output.push(String.fromCharCode(codePoint));
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
var adjusted = codePoint - 65536;
|
|
349
|
+
output.push(
|
|
350
|
+
String.fromCharCode(55296 + (adjusted >> 10)),
|
|
351
|
+
String.fromCharCode(56320 + (adjusted & 1023))
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
function _isContinuationByte(value) {
|
|
355
|
+
return value >= 128 && value <= 191;
|
|
356
|
+
}
|
|
357
|
+
function _createInvalidDataError(encoding) {
|
|
358
|
+
return _withCode(
|
|
359
|
+
new TypeError("The encoded data was not valid for encoding " + encoding),
|
|
360
|
+
"ERR_ENCODING_INVALID_ENCODED_DATA"
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
function _decodeUtf8(bytes, fatal, stream, encoding) {
|
|
364
|
+
var output = [];
|
|
365
|
+
for (var index = 0; index < bytes.length; ) {
|
|
366
|
+
var first = bytes[index];
|
|
367
|
+
if (first <= 127) {
|
|
368
|
+
output.push(String.fromCharCode(first));
|
|
369
|
+
index += 1;
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
var needed = 0;
|
|
373
|
+
var codePoint = 0;
|
|
374
|
+
if (first >= 194 && first <= 223) {
|
|
375
|
+
needed = 1;
|
|
376
|
+
codePoint = first & 31;
|
|
377
|
+
} else if (first >= 224 && first <= 239) {
|
|
378
|
+
needed = 2;
|
|
379
|
+
codePoint = first & 15;
|
|
380
|
+
} else if (first >= 240 && first <= 244) {
|
|
381
|
+
needed = 3;
|
|
382
|
+
codePoint = first & 7;
|
|
383
|
+
} else {
|
|
384
|
+
if (fatal) throw _createInvalidDataError(encoding);
|
|
385
|
+
output.push("\uFFFD");
|
|
386
|
+
index += 1;
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
389
|
+
if (index + needed >= bytes.length) {
|
|
390
|
+
if (stream) {
|
|
391
|
+
return { text: output.join(""), pending: Array.from(bytes.slice(index)) };
|
|
392
|
+
}
|
|
393
|
+
if (fatal) throw _createInvalidDataError(encoding);
|
|
394
|
+
output.push("\uFFFD");
|
|
395
|
+
break;
|
|
396
|
+
}
|
|
397
|
+
var second = bytes[index + 1];
|
|
398
|
+
if (!_isContinuationByte(second)) {
|
|
399
|
+
if (fatal) throw _createInvalidDataError(encoding);
|
|
400
|
+
output.push("\uFFFD");
|
|
401
|
+
index += 1;
|
|
402
|
+
continue;
|
|
403
|
+
}
|
|
404
|
+
if (first === 224 && second < 160 || first === 237 && second > 159 || first === 240 && second < 144 || first === 244 && second > 143) {
|
|
405
|
+
if (fatal) throw _createInvalidDataError(encoding);
|
|
406
|
+
output.push("\uFFFD");
|
|
407
|
+
index += 1;
|
|
408
|
+
continue;
|
|
409
|
+
}
|
|
410
|
+
codePoint = codePoint << 6 | second & 63;
|
|
411
|
+
if (needed >= 2) {
|
|
412
|
+
var third = bytes[index + 2];
|
|
413
|
+
if (!_isContinuationByte(third)) {
|
|
414
|
+
if (fatal) throw _createInvalidDataError(encoding);
|
|
415
|
+
output.push("\uFFFD");
|
|
416
|
+
index += 1;
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
codePoint = codePoint << 6 | third & 63;
|
|
420
|
+
}
|
|
421
|
+
if (needed === 3) {
|
|
422
|
+
var fourth = bytes[index + 3];
|
|
423
|
+
if (!_isContinuationByte(fourth)) {
|
|
424
|
+
if (fatal) throw _createInvalidDataError(encoding);
|
|
425
|
+
output.push("\uFFFD");
|
|
426
|
+
index += 1;
|
|
427
|
+
continue;
|
|
428
|
+
}
|
|
429
|
+
codePoint = codePoint << 6 | fourth & 63;
|
|
430
|
+
}
|
|
431
|
+
if (codePoint >= 55296 && codePoint <= 57343) {
|
|
432
|
+
if (fatal) throw _createInvalidDataError(encoding);
|
|
433
|
+
output.push("\uFFFD");
|
|
434
|
+
index += needed + 1;
|
|
435
|
+
continue;
|
|
436
|
+
}
|
|
437
|
+
_appendCodePoint(output, codePoint);
|
|
438
|
+
index += needed + 1;
|
|
439
|
+
}
|
|
440
|
+
return { text: output.join(""), pending: [] };
|
|
441
|
+
}
|
|
442
|
+
function _decodeUtf16(bytes, encoding, fatal, stream, bomSeen) {
|
|
443
|
+
var output = [];
|
|
444
|
+
var endian = encoding === "utf-16be" ? "be" : "le";
|
|
445
|
+
if (!bomSeen && encoding === "utf-16le" && bytes.length >= 2) {
|
|
446
|
+
if (bytes[0] === 254 && bytes[1] === 255) {
|
|
447
|
+
endian = "be";
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
for (var index = 0; index < bytes.length; ) {
|
|
451
|
+
if (index + 1 >= bytes.length) {
|
|
452
|
+
if (stream) {
|
|
453
|
+
return { text: output.join(""), pending: Array.from(bytes.slice(index)) };
|
|
454
|
+
}
|
|
455
|
+
if (fatal) throw _createInvalidDataError(encoding);
|
|
456
|
+
output.push("\uFFFD");
|
|
457
|
+
break;
|
|
458
|
+
}
|
|
459
|
+
var first = bytes[index];
|
|
460
|
+
var second = bytes[index + 1];
|
|
461
|
+
var codeUnit = endian === "le" ? first | second << 8 : first << 8 | second;
|
|
462
|
+
index += 2;
|
|
463
|
+
if (codeUnit >= 55296 && codeUnit <= 56319) {
|
|
464
|
+
if (index + 1 >= bytes.length) {
|
|
465
|
+
if (stream) {
|
|
466
|
+
return { text: output.join(""), pending: Array.from(bytes.slice(index - 2)) };
|
|
467
|
+
}
|
|
468
|
+
if (fatal) throw _createInvalidDataError(encoding);
|
|
469
|
+
output.push("\uFFFD");
|
|
470
|
+
continue;
|
|
471
|
+
}
|
|
472
|
+
var nextFirst = bytes[index];
|
|
473
|
+
var nextSecond = bytes[index + 1];
|
|
474
|
+
var nextCodeUnit = endian === "le" ? nextFirst | nextSecond << 8 : nextFirst << 8 | nextSecond;
|
|
475
|
+
if (nextCodeUnit >= 56320 && nextCodeUnit <= 57343) {
|
|
476
|
+
_appendCodePoint(
|
|
477
|
+
output,
|
|
478
|
+
65536 + (codeUnit - 55296 << 10) + (nextCodeUnit - 56320)
|
|
479
|
+
);
|
|
480
|
+
index += 2;
|
|
481
|
+
continue;
|
|
482
|
+
}
|
|
483
|
+
if (fatal) throw _createInvalidDataError(encoding);
|
|
484
|
+
output.push("\uFFFD");
|
|
485
|
+
continue;
|
|
486
|
+
}
|
|
487
|
+
if (codeUnit >= 56320 && codeUnit <= 57343) {
|
|
488
|
+
if (fatal) throw _createInvalidDataError(encoding);
|
|
489
|
+
output.push("\uFFFD");
|
|
490
|
+
continue;
|
|
491
|
+
}
|
|
492
|
+
output.push(String.fromCharCode(codeUnit));
|
|
493
|
+
}
|
|
494
|
+
return { text: output.join(""), pending: [] };
|
|
495
|
+
}
|
|
496
|
+
function TextEncoder() {
|
|
497
|
+
}
|
|
498
|
+
TextEncoder.prototype.encode = function encode(input) {
|
|
499
|
+
return _encodeUtf8(input === void 0 ? "" : input);
|
|
115
500
|
};
|
|
116
|
-
|
|
117
|
-
var
|
|
118
|
-
|
|
119
|
-
|
|
501
|
+
TextEncoder.prototype.encodeInto = function encodeInto(input, destination) {
|
|
502
|
+
var value = String(input);
|
|
503
|
+
var read = 0;
|
|
504
|
+
var written = 0;
|
|
505
|
+
for (var index = 0; index < value.length; index += 1) {
|
|
506
|
+
var codeUnit = value.charCodeAt(index);
|
|
507
|
+
var chunk = value[index] || "";
|
|
508
|
+
if (codeUnit >= 55296 && codeUnit <= 56319 && index + 1 < value.length) {
|
|
509
|
+
var nextCodeUnit = value.charCodeAt(index + 1);
|
|
510
|
+
if (nextCodeUnit >= 56320 && nextCodeUnit <= 57343) {
|
|
511
|
+
chunk = value.slice(index, index + 2);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
var encoded = _encodeUtf8(chunk);
|
|
515
|
+
if (written + encoded.length > destination.length) break;
|
|
516
|
+
destination.set(encoded, written);
|
|
517
|
+
written += encoded.length;
|
|
518
|
+
read += chunk.length;
|
|
519
|
+
if (chunk.length === 2) index += 1;
|
|
120
520
|
}
|
|
121
|
-
return
|
|
521
|
+
return { read, written };
|
|
122
522
|
};
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
523
|
+
Object.defineProperty(TextEncoder.prototype, "encoding", {
|
|
524
|
+
get: function() {
|
|
525
|
+
return "utf-8";
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
function TextDecoder(label, options) {
|
|
529
|
+
var normalizedOptions = options == null ? {} : Object(options);
|
|
530
|
+
this._encoding = _normalizeEncodingLabel(label);
|
|
531
|
+
this._fatal = Boolean(normalizedOptions.fatal);
|
|
532
|
+
this._ignoreBOM = Boolean(normalizedOptions.ignoreBOM);
|
|
533
|
+
this._pendingBytes = [];
|
|
534
|
+
this._bomSeen = false;
|
|
130
535
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
536
|
+
Object.defineProperty(TextDecoder.prototype, "encoding", {
|
|
537
|
+
get: function() {
|
|
538
|
+
return this._encoding;
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
Object.defineProperty(TextDecoder.prototype, "fatal", {
|
|
542
|
+
get: function() {
|
|
543
|
+
return this._fatal;
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
Object.defineProperty(TextDecoder.prototype, "ignoreBOM", {
|
|
547
|
+
get: function() {
|
|
548
|
+
return this._ignoreBOM;
|
|
136
549
|
}
|
|
137
|
-
|
|
138
|
-
|
|
550
|
+
});
|
|
551
|
+
TextDecoder.prototype.decode = function decode(input, options) {
|
|
552
|
+
var normalizedOptions = options == null ? {} : Object(options);
|
|
553
|
+
var stream = Boolean(normalizedOptions.stream);
|
|
554
|
+
var incoming = _toUint8Array(input);
|
|
555
|
+
var merged = new Uint8Array(this._pendingBytes.length + incoming.length);
|
|
556
|
+
merged.set(this._pendingBytes, 0);
|
|
557
|
+
merged.set(incoming, this._pendingBytes.length);
|
|
558
|
+
var decoded = this._encoding === "utf-8" ? _decodeUtf8(merged, this._fatal, stream, this._encoding) : _decodeUtf16(merged, this._encoding, this._fatal, stream, this._bomSeen);
|
|
559
|
+
this._pendingBytes = decoded.pending;
|
|
560
|
+
var text = decoded.text;
|
|
561
|
+
if (!this._bomSeen && text.length > 0) {
|
|
562
|
+
if (!this._ignoreBOM && text.charCodeAt(0) === 65279) {
|
|
563
|
+
text = text.slice(1);
|
|
564
|
+
}
|
|
565
|
+
this._bomSeen = true;
|
|
139
566
|
}
|
|
140
|
-
if (
|
|
141
|
-
|
|
567
|
+
if (!stream && this._pendingBytes.length > 0) {
|
|
568
|
+
var pendingLength = this._pendingBytes.length;
|
|
569
|
+
this._pendingBytes = [];
|
|
570
|
+
if (this._fatal) throw _createInvalidDataError(this._encoding);
|
|
571
|
+
return text + "\uFFFD".repeat(Math.ceil(pendingLength / 2));
|
|
142
572
|
}
|
|
143
|
-
|
|
144
|
-
|
|
573
|
+
return text;
|
|
574
|
+
};
|
|
575
|
+
function _normalizeAddEventListenerOptions(options) {
|
|
576
|
+
if (typeof options === "boolean") {
|
|
577
|
+
return { capture: options, once: false, passive: false };
|
|
145
578
|
}
|
|
146
|
-
if (
|
|
147
|
-
|
|
579
|
+
if (options == null) {
|
|
580
|
+
return { capture: false, once: false, passive: false };
|
|
581
|
+
}
|
|
582
|
+
var normalized = Object(options);
|
|
583
|
+
return {
|
|
584
|
+
capture: Boolean(normalized.capture),
|
|
585
|
+
once: Boolean(normalized.once),
|
|
586
|
+
passive: Boolean(normalized.passive),
|
|
587
|
+
signal: normalized.signal
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
function _normalizeRemoveEventListenerOptions(options) {
|
|
591
|
+
if (typeof options === "boolean") return options;
|
|
592
|
+
if (options == null) return false;
|
|
593
|
+
return Boolean(Object(options).capture);
|
|
594
|
+
}
|
|
595
|
+
function _isAbortSignalLike(value) {
|
|
596
|
+
return typeof value === "object" && value !== null && "aborted" in value && typeof value.addEventListener === "function" && typeof value.removeEventListener === "function";
|
|
597
|
+
}
|
|
598
|
+
function Event(type, init) {
|
|
599
|
+
if (arguments.length === 0) {
|
|
600
|
+
throw new TypeError("The event type must be provided");
|
|
601
|
+
}
|
|
602
|
+
var normalizedInit = init == null ? {} : Object(init);
|
|
603
|
+
this.type = String(type);
|
|
604
|
+
this.bubbles = Boolean(normalizedInit.bubbles);
|
|
605
|
+
this.cancelable = Boolean(normalizedInit.cancelable);
|
|
606
|
+
this.composed = Boolean(normalizedInit.composed);
|
|
607
|
+
this.detail = null;
|
|
608
|
+
this.defaultPrevented = false;
|
|
609
|
+
this.target = null;
|
|
610
|
+
this.currentTarget = null;
|
|
611
|
+
this.eventPhase = 0;
|
|
612
|
+
this.returnValue = true;
|
|
613
|
+
this.cancelBubble = false;
|
|
614
|
+
this.timeStamp = Date.now();
|
|
615
|
+
this.isTrusted = false;
|
|
616
|
+
this.srcElement = null;
|
|
617
|
+
this._inPassiveListener = false;
|
|
618
|
+
this._propagationStopped = false;
|
|
619
|
+
this._immediatePropagationStopped = false;
|
|
620
|
+
}
|
|
621
|
+
Event.NONE = 0;
|
|
622
|
+
Event.CAPTURING_PHASE = 1;
|
|
623
|
+
Event.AT_TARGET = 2;
|
|
624
|
+
Event.BUBBLING_PHASE = 3;
|
|
625
|
+
Event.prototype.preventDefault = function preventDefault() {
|
|
626
|
+
if (this.cancelable && !this._inPassiveListener) {
|
|
627
|
+
this.defaultPrevented = true;
|
|
628
|
+
this.returnValue = false;
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
Event.prototype.stopPropagation = function stopPropagation() {
|
|
632
|
+
this._propagationStopped = true;
|
|
633
|
+
this.cancelBubble = true;
|
|
634
|
+
};
|
|
635
|
+
Event.prototype.stopImmediatePropagation = function stopImmediatePropagation() {
|
|
636
|
+
this._propagationStopped = true;
|
|
637
|
+
this._immediatePropagationStopped = true;
|
|
638
|
+
this.cancelBubble = true;
|
|
639
|
+
};
|
|
640
|
+
Event.prototype.composedPath = function composedPath() {
|
|
641
|
+
return this.target ? [this.target] : [];
|
|
642
|
+
};
|
|
643
|
+
function CustomEvent(type, init) {
|
|
644
|
+
Event.call(this, type, init);
|
|
645
|
+
var normalizedInit = init == null ? null : Object(init);
|
|
646
|
+
this.detail = normalizedInit && "detail" in normalizedInit ? normalizedInit.detail : null;
|
|
647
|
+
}
|
|
648
|
+
CustomEvent.prototype = Object.create(Event.prototype);
|
|
649
|
+
CustomEvent.prototype.constructor = CustomEvent;
|
|
650
|
+
function EventTarget() {
|
|
651
|
+
this._listeners = /* @__PURE__ */ new Map();
|
|
652
|
+
}
|
|
653
|
+
EventTarget.prototype.addEventListener = function addEventListener(type, listener, options) {
|
|
654
|
+
var normalized = _normalizeAddEventListenerOptions(options);
|
|
655
|
+
if (normalized.signal !== void 0 && !_isAbortSignalLike(normalized.signal)) {
|
|
656
|
+
throw new TypeError('The "signal" option must be an instance of AbortSignal.');
|
|
657
|
+
}
|
|
658
|
+
if (listener == null) return void 0;
|
|
659
|
+
if (typeof listener !== "function" && (typeof listener !== "object" || listener === null)) {
|
|
660
|
+
return void 0;
|
|
661
|
+
}
|
|
662
|
+
if (normalized.signal && normalized.signal.aborted) return void 0;
|
|
663
|
+
var records = this._listeners.get(type) || [];
|
|
664
|
+
for (var i = 0; i < records.length; i += 1) {
|
|
665
|
+
if (records[i].listener === listener && records[i].capture === normalized.capture) {
|
|
666
|
+
return void 0;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
var record = {
|
|
670
|
+
listener,
|
|
671
|
+
capture: normalized.capture,
|
|
672
|
+
once: normalized.once,
|
|
673
|
+
passive: normalized.passive,
|
|
674
|
+
kind: typeof listener === "function" ? "function" : "object",
|
|
675
|
+
signal: normalized.signal,
|
|
676
|
+
abortListener: void 0
|
|
677
|
+
};
|
|
678
|
+
if (normalized.signal) {
|
|
679
|
+
var self = this;
|
|
680
|
+
record.abortListener = function() {
|
|
681
|
+
self.removeEventListener(type, listener, normalized.capture);
|
|
682
|
+
};
|
|
683
|
+
normalized.signal.addEventListener("abort", record.abortListener, { once: true });
|
|
684
|
+
}
|
|
685
|
+
records.push(record);
|
|
686
|
+
this._listeners.set(type, records);
|
|
687
|
+
return void 0;
|
|
688
|
+
};
|
|
689
|
+
EventTarget.prototype.removeEventListener = function removeEventListener(type, listener, options) {
|
|
690
|
+
if (listener == null) return;
|
|
691
|
+
var capture = _normalizeRemoveEventListenerOptions(options);
|
|
692
|
+
var records = this._listeners.get(type);
|
|
693
|
+
if (!records) return;
|
|
694
|
+
var nextRecords = [];
|
|
695
|
+
for (var i = 0; i < records.length; i += 1) {
|
|
696
|
+
var record = records[i];
|
|
697
|
+
var match = record.listener === listener && record.capture === capture;
|
|
698
|
+
if (match) {
|
|
699
|
+
if (record.signal && record.abortListener) {
|
|
700
|
+
record.signal.removeEventListener("abort", record.abortListener);
|
|
701
|
+
}
|
|
702
|
+
} else {
|
|
703
|
+
nextRecords.push(record);
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
if (nextRecords.length === 0) {
|
|
707
|
+
this._listeners.delete(type);
|
|
708
|
+
} else {
|
|
709
|
+
this._listeners.set(type, nextRecords);
|
|
710
|
+
}
|
|
711
|
+
};
|
|
712
|
+
EventTarget.prototype.dispatchEvent = function dispatchEvent(event) {
|
|
713
|
+
if (!event || typeof event !== "object" || typeof event.type !== "string") {
|
|
714
|
+
throw new TypeError("Argument 1 must be an Event");
|
|
715
|
+
}
|
|
716
|
+
var records = (this._listeners.get(event.type) || []).slice();
|
|
717
|
+
event.target = this;
|
|
718
|
+
event.currentTarget = this;
|
|
719
|
+
event.eventPhase = 2;
|
|
720
|
+
for (var i = 0; i < records.length; i += 1) {
|
|
721
|
+
var record = records[i];
|
|
722
|
+
var active = this._listeners.get(event.type);
|
|
723
|
+
if (!active || active.indexOf(record) === -1) continue;
|
|
724
|
+
if (record.once) {
|
|
725
|
+
this.removeEventListener(event.type, record.listener, record.capture);
|
|
726
|
+
}
|
|
727
|
+
event._inPassiveListener = record.passive;
|
|
728
|
+
if (record.kind === "function") {
|
|
729
|
+
record.listener.call(this, event);
|
|
730
|
+
} else {
|
|
731
|
+
var handleEvent = record.listener.handleEvent;
|
|
732
|
+
if (typeof handleEvent === "function") {
|
|
733
|
+
handleEvent.call(record.listener, event);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
event._inPassiveListener = false;
|
|
737
|
+
if (event._immediatePropagationStopped || event._propagationStopped) {
|
|
738
|
+
break;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
event.currentTarget = null;
|
|
742
|
+
event.eventPhase = 0;
|
|
743
|
+
return !event.defaultPrevented;
|
|
744
|
+
};
|
|
745
|
+
globalThis.TextEncoder = TextEncoder;
|
|
746
|
+
globalThis.TextDecoder = TextDecoder;
|
|
747
|
+
globalThis.Event = Event;
|
|
748
|
+
globalThis.CustomEvent = CustomEvent;
|
|
749
|
+
globalThis.EventTarget = EventTarget;
|
|
750
|
+
if (typeof globalThis.DOMException === "undefined") {
|
|
751
|
+
let DOMException3 = function(message, name) {
|
|
752
|
+
if (!(this instanceof DOMException3)) {
|
|
753
|
+
throw new TypeError("Class constructor DOMException cannot be invoked without 'new'");
|
|
754
|
+
}
|
|
755
|
+
Error.call(this, message);
|
|
756
|
+
this.message = message === void 0 ? "" : String(message);
|
|
757
|
+
this.name = name === void 0 ? "Error" : String(name);
|
|
758
|
+
this.code = DOM_EXCEPTION_LEGACY_CODES[this.name] || 0;
|
|
759
|
+
if (typeof Error.captureStackTrace === "function") {
|
|
760
|
+
Error.captureStackTrace(this, DOMException3);
|
|
761
|
+
}
|
|
762
|
+
};
|
|
763
|
+
var DOMException2 = DOMException3;
|
|
764
|
+
var DOM_EXCEPTION_LEGACY_CODES = {
|
|
765
|
+
IndexSizeError: 1,
|
|
766
|
+
DOMStringSizeError: 2,
|
|
767
|
+
HierarchyRequestError: 3,
|
|
768
|
+
WrongDocumentError: 4,
|
|
769
|
+
InvalidCharacterError: 5,
|
|
770
|
+
NoDataAllowedError: 6,
|
|
771
|
+
NoModificationAllowedError: 7,
|
|
772
|
+
NotFoundError: 8,
|
|
773
|
+
NotSupportedError: 9,
|
|
774
|
+
InUseAttributeError: 10,
|
|
775
|
+
InvalidStateError: 11,
|
|
776
|
+
SyntaxError: 12,
|
|
777
|
+
InvalidModificationError: 13,
|
|
778
|
+
NamespaceError: 14,
|
|
779
|
+
InvalidAccessError: 15,
|
|
780
|
+
ValidationError: 16,
|
|
781
|
+
TypeMismatchError: 17,
|
|
782
|
+
SecurityError: 18,
|
|
783
|
+
NetworkError: 19,
|
|
784
|
+
AbortError: 20,
|
|
785
|
+
URLMismatchError: 21,
|
|
786
|
+
QuotaExceededError: 22,
|
|
787
|
+
TimeoutError: 23,
|
|
788
|
+
InvalidNodeTypeError: 24,
|
|
789
|
+
DataCloneError: 25
|
|
790
|
+
};
|
|
791
|
+
DOMException3.prototype = Object.create(Error.prototype);
|
|
792
|
+
Object.defineProperty(DOMException3.prototype, "constructor", {
|
|
793
|
+
value: DOMException3,
|
|
794
|
+
writable: true,
|
|
795
|
+
configurable: true
|
|
796
|
+
});
|
|
797
|
+
Object.defineProperty(DOMException3.prototype, Symbol.toStringTag, {
|
|
798
|
+
value: "DOMException",
|
|
799
|
+
writable: false,
|
|
800
|
+
enumerable: false,
|
|
801
|
+
configurable: true
|
|
802
|
+
});
|
|
803
|
+
for (var codeName in DOM_EXCEPTION_LEGACY_CODES) {
|
|
804
|
+
if (!Object.prototype.hasOwnProperty.call(DOM_EXCEPTION_LEGACY_CODES, codeName)) {
|
|
805
|
+
continue;
|
|
806
|
+
}
|
|
807
|
+
var codeValue = DOM_EXCEPTION_LEGACY_CODES[codeName];
|
|
808
|
+
var constantName = codeName.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toUpperCase();
|
|
809
|
+
Object.defineProperty(DOMException3, constantName, {
|
|
810
|
+
value: codeValue,
|
|
811
|
+
writable: false,
|
|
812
|
+
enumerable: true,
|
|
813
|
+
configurable: false
|
|
814
|
+
});
|
|
815
|
+
Object.defineProperty(DOMException3.prototype, constantName, {
|
|
816
|
+
value: codeValue,
|
|
817
|
+
writable: false,
|
|
818
|
+
enumerable: true,
|
|
819
|
+
configurable: false
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
__requireExposeCustomGlobal("DOMException", DOMException3);
|
|
823
|
+
}
|
|
824
|
+
if (typeof globalThis.Blob === "undefined") {
|
|
825
|
+
let Blob2 = function(parts, options) {
|
|
826
|
+
if (!(this instanceof Blob2)) {
|
|
827
|
+
throw new TypeError("Class constructor Blob cannot be invoked without 'new'");
|
|
828
|
+
}
|
|
829
|
+
this._parts = Array.isArray(parts) ? parts.slice() : [];
|
|
830
|
+
this.type = options && options.type ? String(options.type).toLowerCase() : "";
|
|
831
|
+
var size = 0;
|
|
832
|
+
for (var index = 0; index < this._parts.length; index += 1) {
|
|
833
|
+
var part = this._parts[index];
|
|
834
|
+
if (typeof part === "string") {
|
|
835
|
+
size += part.length;
|
|
836
|
+
} else if (part && typeof part.byteLength === "number") {
|
|
837
|
+
size += part.byteLength;
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
this.size = size;
|
|
841
|
+
};
|
|
842
|
+
var Blob = Blob2;
|
|
843
|
+
Blob2.prototype.arrayBuffer = function arrayBuffer() {
|
|
844
|
+
return Promise.resolve(new ArrayBuffer(0));
|
|
845
|
+
};
|
|
846
|
+
Blob2.prototype.text = function text() {
|
|
847
|
+
return Promise.resolve("");
|
|
848
|
+
};
|
|
849
|
+
Blob2.prototype.slice = function slice() {
|
|
850
|
+
return new Blob2();
|
|
851
|
+
};
|
|
852
|
+
Blob2.prototype.stream = function stream() {
|
|
853
|
+
throw new Error("Blob.stream is not supported in sandbox");
|
|
854
|
+
};
|
|
855
|
+
Object.defineProperty(Blob2.prototype, Symbol.toStringTag, {
|
|
856
|
+
value: "Blob",
|
|
857
|
+
writable: false,
|
|
858
|
+
enumerable: false,
|
|
859
|
+
configurable: true
|
|
860
|
+
});
|
|
861
|
+
__requireExposeCustomGlobal("Blob", Blob2);
|
|
862
|
+
}
|
|
863
|
+
if (typeof globalThis.File === "undefined") {
|
|
864
|
+
let File2 = function(parts, name, options) {
|
|
865
|
+
if (!(this instanceof File2)) {
|
|
866
|
+
throw new TypeError("Class constructor File cannot be invoked without 'new'");
|
|
867
|
+
}
|
|
868
|
+
globalThis.Blob.call(this, parts, options);
|
|
869
|
+
this.name = String(name);
|
|
870
|
+
this.lastModified = options && typeof options.lastModified === "number" ? options.lastModified : Date.now();
|
|
871
|
+
this.webkitRelativePath = "";
|
|
872
|
+
};
|
|
873
|
+
var File = File2;
|
|
874
|
+
File2.prototype = Object.create(globalThis.Blob.prototype);
|
|
875
|
+
Object.defineProperty(File2.prototype, "constructor", {
|
|
876
|
+
value: File2,
|
|
877
|
+
writable: true,
|
|
878
|
+
configurable: true
|
|
879
|
+
});
|
|
880
|
+
Object.defineProperty(File2.prototype, Symbol.toStringTag, {
|
|
881
|
+
value: "File",
|
|
882
|
+
writable: false,
|
|
883
|
+
enumerable: false,
|
|
884
|
+
configurable: true
|
|
885
|
+
});
|
|
886
|
+
__requireExposeCustomGlobal("File", File2);
|
|
887
|
+
}
|
|
888
|
+
if (typeof globalThis.FormData === "undefined") {
|
|
889
|
+
let FormData2 = function() {
|
|
890
|
+
if (!(this instanceof FormData2)) {
|
|
891
|
+
throw new TypeError("Class constructor FormData cannot be invoked without 'new'");
|
|
892
|
+
}
|
|
893
|
+
this._entries = [];
|
|
894
|
+
};
|
|
895
|
+
var FormData = FormData2;
|
|
896
|
+
FormData2.prototype.append = function append(name, value) {
|
|
897
|
+
this._entries.push([String(name), value]);
|
|
898
|
+
};
|
|
899
|
+
FormData2.prototype.get = function get(name) {
|
|
900
|
+
var key = String(name);
|
|
901
|
+
for (var index = 0; index < this._entries.length; index += 1) {
|
|
902
|
+
if (this._entries[index][0] === key) {
|
|
903
|
+
return this._entries[index][1];
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
return null;
|
|
907
|
+
};
|
|
908
|
+
FormData2.prototype.getAll = function getAll(name) {
|
|
909
|
+
var key = String(name);
|
|
910
|
+
var values = [];
|
|
911
|
+
for (var index = 0; index < this._entries.length; index += 1) {
|
|
912
|
+
if (this._entries[index][0] === key) {
|
|
913
|
+
values.push(this._entries[index][1]);
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
return values;
|
|
917
|
+
};
|
|
918
|
+
FormData2.prototype.has = function has(name) {
|
|
919
|
+
return this.get(name) !== null;
|
|
920
|
+
};
|
|
921
|
+
FormData2.prototype.delete = function del(name) {
|
|
922
|
+
var key = String(name);
|
|
923
|
+
this._entries = this._entries.filter(function(entry) {
|
|
924
|
+
return entry[0] !== key;
|
|
925
|
+
});
|
|
926
|
+
};
|
|
927
|
+
FormData2.prototype.entries = function entries() {
|
|
928
|
+
return this._entries[Symbol.iterator]();
|
|
929
|
+
};
|
|
930
|
+
FormData2.prototype[Symbol.iterator] = function iterator() {
|
|
931
|
+
return this.entries();
|
|
932
|
+
};
|
|
933
|
+
Object.defineProperty(FormData2.prototype, Symbol.toStringTag, {
|
|
934
|
+
value: "FormData",
|
|
935
|
+
writable: false,
|
|
936
|
+
enumerable: false,
|
|
937
|
+
configurable: true
|
|
938
|
+
});
|
|
939
|
+
__requireExposeCustomGlobal("FormData", FormData2);
|
|
940
|
+
}
|
|
941
|
+
if (typeof globalThis.MessageEvent === "undefined") {
|
|
942
|
+
let MessageEvent2 = function(type, options) {
|
|
943
|
+
if (!(this instanceof MessageEvent2)) {
|
|
944
|
+
throw new TypeError("Class constructor MessageEvent cannot be invoked without 'new'");
|
|
945
|
+
}
|
|
946
|
+
globalThis.Event.call(this, type, options);
|
|
947
|
+
this.data = options && "data" in options ? options.data : void 0;
|
|
948
|
+
};
|
|
949
|
+
var MessageEvent = MessageEvent2;
|
|
950
|
+
MessageEvent2.prototype = Object.create(globalThis.Event.prototype);
|
|
951
|
+
Object.defineProperty(MessageEvent2.prototype, "constructor", {
|
|
952
|
+
value: MessageEvent2,
|
|
953
|
+
writable: true,
|
|
954
|
+
configurable: true
|
|
955
|
+
});
|
|
956
|
+
globalThis.MessageEvent = MessageEvent2;
|
|
957
|
+
}
|
|
958
|
+
if (typeof globalThis.MessagePort === "undefined") {
|
|
959
|
+
let MessagePort2 = function() {
|
|
960
|
+
if (!(this instanceof MessagePort2)) {
|
|
961
|
+
throw new TypeError("Class constructor MessagePort cannot be invoked without 'new'");
|
|
962
|
+
}
|
|
963
|
+
globalThis.EventTarget.call(this);
|
|
964
|
+
this.onmessage = null;
|
|
965
|
+
this._pairedPort = null;
|
|
966
|
+
};
|
|
967
|
+
var MessagePort = MessagePort2;
|
|
968
|
+
MessagePort2.prototype = Object.create(globalThis.EventTarget.prototype);
|
|
969
|
+
Object.defineProperty(MessagePort2.prototype, "constructor", {
|
|
970
|
+
value: MessagePort2,
|
|
971
|
+
writable: true,
|
|
972
|
+
configurable: true
|
|
973
|
+
});
|
|
974
|
+
MessagePort2.prototype.postMessage = function postMessage(data) {
|
|
975
|
+
var target = this._pairedPort;
|
|
976
|
+
if (!target) {
|
|
977
|
+
return;
|
|
978
|
+
}
|
|
979
|
+
var event = new globalThis.MessageEvent("message", { data });
|
|
980
|
+
target.dispatchEvent(event);
|
|
981
|
+
if (typeof target.onmessage === "function") {
|
|
982
|
+
target.onmessage.call(target, event);
|
|
983
|
+
}
|
|
984
|
+
};
|
|
985
|
+
MessagePort2.prototype.start = function start() {
|
|
986
|
+
};
|
|
987
|
+
MessagePort2.prototype.close = function close() {
|
|
988
|
+
this._pairedPort = null;
|
|
989
|
+
};
|
|
990
|
+
globalThis.MessagePort = MessagePort2;
|
|
991
|
+
}
|
|
992
|
+
if (typeof globalThis.MessageChannel === "undefined") {
|
|
993
|
+
let MessageChannel2 = function() {
|
|
994
|
+
if (!(this instanceof MessageChannel2)) {
|
|
995
|
+
throw new TypeError("Class constructor MessageChannel cannot be invoked without 'new'");
|
|
996
|
+
}
|
|
997
|
+
this.port1 = new globalThis.MessagePort();
|
|
998
|
+
this.port2 = new globalThis.MessagePort();
|
|
999
|
+
this.port1._pairedPort = this.port2;
|
|
1000
|
+
this.port2._pairedPort = this.port1;
|
|
1001
|
+
};
|
|
1002
|
+
var MessageChannel = MessageChannel2;
|
|
1003
|
+
globalThis.MessageChannel = MessageChannel2;
|
|
1004
|
+
}
|
|
1005
|
+
})();
|
|
1006
|
+
(function installWebStreamsGlobals() {
|
|
1007
|
+
if (typeof globalThis.ReadableStream !== "undefined") {
|
|
1008
|
+
return;
|
|
1009
|
+
}
|
|
1010
|
+
if (typeof _loadPolyfill === "undefined") {
|
|
1011
|
+
return;
|
|
1012
|
+
}
|
|
1013
|
+
const polyfillCode = _loadPolyfill.applySyncPromise(void 0, ["stream/web"]);
|
|
1014
|
+
if (polyfillCode === null) {
|
|
1015
|
+
return;
|
|
1016
|
+
}
|
|
1017
|
+
const webStreams = Function('"use strict"; return (' + polyfillCode + ");")();
|
|
1018
|
+
const names = [
|
|
1019
|
+
"ReadableStream",
|
|
1020
|
+
"ReadableStreamDefaultReader",
|
|
1021
|
+
"ReadableStreamBYOBReader",
|
|
1022
|
+
"ReadableStreamBYOBRequest",
|
|
1023
|
+
"ReadableByteStreamController",
|
|
1024
|
+
"ReadableStreamDefaultController",
|
|
1025
|
+
"TransformStream",
|
|
1026
|
+
"TransformStreamDefaultController",
|
|
1027
|
+
"WritableStream",
|
|
1028
|
+
"WritableStreamDefaultWriter",
|
|
1029
|
+
"WritableStreamDefaultController",
|
|
1030
|
+
"ByteLengthQueuingStrategy",
|
|
1031
|
+
"CountQueuingStrategy",
|
|
1032
|
+
"TextEncoderStream",
|
|
1033
|
+
"TextDecoderStream",
|
|
1034
|
+
"CompressionStream",
|
|
1035
|
+
"DecompressionStream"
|
|
1036
|
+
];
|
|
1037
|
+
for (const name of names) {
|
|
1038
|
+
if (typeof webStreams?.[name] !== "undefined") {
|
|
1039
|
+
globalThis[name] = webStreams[name];
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
})();
|
|
1043
|
+
function _patchPolyfill(name, result) {
|
|
1044
|
+
if (typeof result !== "object" && typeof result !== "function" || result === null) {
|
|
1045
|
+
return result;
|
|
1046
|
+
}
|
|
1047
|
+
if (name === "buffer") {
|
|
1048
|
+
const maxLength = typeof result.kMaxLength === "number" ? result.kMaxLength : 2147483647;
|
|
1049
|
+
const maxStringLength = typeof result.kStringMaxLength === "number" ? result.kStringMaxLength : 536870888;
|
|
1050
|
+
if (typeof result.constants !== "object" || result.constants === null) {
|
|
1051
|
+
result.constants = {};
|
|
1052
|
+
}
|
|
1053
|
+
if (typeof result.constants.MAX_LENGTH !== "number") {
|
|
1054
|
+
result.constants.MAX_LENGTH = maxLength;
|
|
1055
|
+
}
|
|
1056
|
+
if (typeof result.constants.MAX_STRING_LENGTH !== "number") {
|
|
1057
|
+
result.constants.MAX_STRING_LENGTH = maxStringLength;
|
|
1058
|
+
}
|
|
1059
|
+
if (typeof result.kMaxLength !== "number") {
|
|
1060
|
+
result.kMaxLength = maxLength;
|
|
1061
|
+
}
|
|
1062
|
+
if (typeof result.kStringMaxLength !== "number") {
|
|
1063
|
+
result.kStringMaxLength = maxStringLength;
|
|
1064
|
+
}
|
|
1065
|
+
var BufferCtor = result.Buffer;
|
|
1066
|
+
if (typeof globalThis.Buffer === "function" && globalThis.Buffer !== BufferCtor) {
|
|
1067
|
+
BufferCtor = globalThis.Buffer;
|
|
1068
|
+
result.Buffer = BufferCtor;
|
|
1069
|
+
} else if (typeof globalThis.Buffer !== "function" && typeof BufferCtor === "function") {
|
|
1070
|
+
globalThis.Buffer = BufferCtor;
|
|
148
1071
|
}
|
|
149
|
-
const BufferCtor = result2.Buffer;
|
|
150
1072
|
if ((typeof BufferCtor === "function" || typeof BufferCtor === "object") && BufferCtor !== null) {
|
|
1073
|
+
if (typeof result.SlowBuffer !== "function") {
|
|
1074
|
+
result.SlowBuffer = BufferCtor;
|
|
1075
|
+
}
|
|
151
1076
|
if (typeof BufferCtor.kMaxLength !== "number") {
|
|
152
1077
|
BufferCtor.kMaxLength = maxLength;
|
|
153
1078
|
}
|
|
@@ -155,39 +1080,292 @@
|
|
|
155
1080
|
BufferCtor.kStringMaxLength = maxStringLength;
|
|
156
1081
|
}
|
|
157
1082
|
if (typeof BufferCtor.constants !== "object" || BufferCtor.constants === null) {
|
|
158
|
-
BufferCtor.constants =
|
|
1083
|
+
BufferCtor.constants = result.constants;
|
|
159
1084
|
}
|
|
160
|
-
var
|
|
161
|
-
if (
|
|
162
|
-
var
|
|
163
|
-
for (var ei = 0; ei <
|
|
1085
|
+
var proto = BufferCtor.prototype;
|
|
1086
|
+
if (proto && typeof proto.utf8Slice !== "function") {
|
|
1087
|
+
var encodings = ["utf8", "latin1", "ascii", "hex", "base64", "ucs2", "utf16le"];
|
|
1088
|
+
for (var ei = 0; ei < encodings.length; ei++) {
|
|
1089
|
+
var enc = encodings[ei];
|
|
164
1090
|
(function(e) {
|
|
165
|
-
if (typeof
|
|
166
|
-
|
|
1091
|
+
if (typeof proto[e + "Slice"] !== "function") {
|
|
1092
|
+
proto[e + "Slice"] = function(start, end) {
|
|
167
1093
|
return this.toString(e, start, end);
|
|
168
1094
|
};
|
|
169
1095
|
}
|
|
170
|
-
if (typeof
|
|
171
|
-
|
|
172
|
-
return this.write(
|
|
1096
|
+
if (typeof proto[e + "Write"] !== "function") {
|
|
1097
|
+
proto[e + "Write"] = function(string, offset, length) {
|
|
1098
|
+
return this.write(string, offset, length, e);
|
|
173
1099
|
};
|
|
174
1100
|
}
|
|
175
|
-
})(
|
|
1101
|
+
})(enc);
|
|
176
1102
|
}
|
|
177
1103
|
}
|
|
1104
|
+
if (typeof BufferCtor.allocUnsafe === "function" && !BufferCtor.allocUnsafe._secureExecPatched) {
|
|
1105
|
+
var _origAllocUnsafe = BufferCtor.allocUnsafe;
|
|
1106
|
+
BufferCtor.allocUnsafe = function(size) {
|
|
1107
|
+
try {
|
|
1108
|
+
return _origAllocUnsafe.apply(this, arguments);
|
|
1109
|
+
} catch (error) {
|
|
1110
|
+
if (error && error.name === "RangeError" && typeof size === "number" && size > maxLength) {
|
|
1111
|
+
throw new Error("Array buffer allocation failed");
|
|
1112
|
+
}
|
|
1113
|
+
throw error;
|
|
1114
|
+
}
|
|
1115
|
+
};
|
|
1116
|
+
BufferCtor.allocUnsafe._secureExecPatched = true;
|
|
1117
|
+
}
|
|
178
1118
|
}
|
|
179
|
-
return
|
|
1119
|
+
return result;
|
|
180
1120
|
}
|
|
181
|
-
if (
|
|
182
|
-
|
|
183
|
-
return
|
|
1121
|
+
if (name === "util" && typeof result.formatWithOptions === "undefined" && typeof result.format === "function") {
|
|
1122
|
+
result.formatWithOptions = function formatWithOptions(inspectOptions, ...args) {
|
|
1123
|
+
return result.format.apply(null, args);
|
|
184
1124
|
};
|
|
185
|
-
return result2;
|
|
186
1125
|
}
|
|
187
|
-
if (
|
|
188
|
-
|
|
1126
|
+
if (name === "util") {
|
|
1127
|
+
if (typeof result.types === "undefined" && typeof _requireFrom === "function") {
|
|
1128
|
+
try {
|
|
1129
|
+
result.types = _requireFrom("util/types", "/");
|
|
1130
|
+
} catch {
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
if ((typeof result.MIMEType === "undefined" || typeof result.MIMEParams === "undefined") && typeof _requireFrom === "function") {
|
|
1134
|
+
try {
|
|
1135
|
+
const mimeModule = _requireFrom("internal/mime", "/");
|
|
1136
|
+
if (typeof result.MIMEType === "undefined") {
|
|
1137
|
+
result.MIMEType = mimeModule.MIMEType;
|
|
1138
|
+
}
|
|
1139
|
+
if (typeof result.MIMEParams === "undefined") {
|
|
1140
|
+
result.MIMEParams = mimeModule.MIMEParams;
|
|
1141
|
+
}
|
|
1142
|
+
} catch {
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
if (typeof result.inspect === "function" && typeof result.inspect.custom === "undefined") {
|
|
1146
|
+
result.inspect.custom = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
1147
|
+
}
|
|
1148
|
+
if (typeof result.inspect === "function" && !result.inspect._secureExecPatchedCustomInspect) {
|
|
1149
|
+
const customInspectSymbol = result.inspect.custom || /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
1150
|
+
const originalInspect = result.inspect;
|
|
1151
|
+
const formatObjectKey = function(key) {
|
|
1152
|
+
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? key : originalInspect(key);
|
|
1153
|
+
};
|
|
1154
|
+
const containsCustomInspectable = function(value, depth, seen) {
|
|
1155
|
+
if (value === null) {
|
|
1156
|
+
return false;
|
|
1157
|
+
}
|
|
1158
|
+
if (typeof value !== "object" && typeof value !== "function") {
|
|
1159
|
+
return false;
|
|
1160
|
+
}
|
|
1161
|
+
if (typeof value[customInspectSymbol] === "function") {
|
|
1162
|
+
return true;
|
|
1163
|
+
}
|
|
1164
|
+
if (depth < 0 || seen.has(value)) {
|
|
1165
|
+
return false;
|
|
1166
|
+
}
|
|
1167
|
+
seen.add(value);
|
|
1168
|
+
if (Array.isArray(value)) {
|
|
1169
|
+
for (const entry of value) {
|
|
1170
|
+
if (containsCustomInspectable(entry, depth - 1, seen)) {
|
|
1171
|
+
seen.delete(value);
|
|
1172
|
+
return true;
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
seen.delete(value);
|
|
1176
|
+
return false;
|
|
1177
|
+
}
|
|
1178
|
+
for (const key of Object.keys(value)) {
|
|
1179
|
+
if (containsCustomInspectable(value[key], depth - 1, seen)) {
|
|
1180
|
+
seen.delete(value);
|
|
1181
|
+
return true;
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
seen.delete(value);
|
|
1185
|
+
return false;
|
|
1186
|
+
};
|
|
1187
|
+
const inspectWithCustom = function(value, depth, options, seen) {
|
|
1188
|
+
if (value === null || typeof value !== "object" && typeof value !== "function") {
|
|
1189
|
+
return originalInspect(value, options);
|
|
1190
|
+
}
|
|
1191
|
+
if (seen.has(value)) {
|
|
1192
|
+
return "[Circular]";
|
|
1193
|
+
}
|
|
1194
|
+
if (typeof value[customInspectSymbol] === "function") {
|
|
1195
|
+
return value[customInspectSymbol](depth, options, result.inspect);
|
|
1196
|
+
}
|
|
1197
|
+
if (depth < 0) {
|
|
1198
|
+
return originalInspect(value, options);
|
|
1199
|
+
}
|
|
1200
|
+
seen.add(value);
|
|
1201
|
+
if (Array.isArray(value)) {
|
|
1202
|
+
const items = value.map((entry) => inspectWithCustom(entry, depth - 1, options, seen));
|
|
1203
|
+
seen.delete(value);
|
|
1204
|
+
return `[ ${items.join(", ")} ]`;
|
|
1205
|
+
}
|
|
1206
|
+
const proto2 = Object.getPrototypeOf(value);
|
|
1207
|
+
if (proto2 === Object.prototype || proto2 === null) {
|
|
1208
|
+
const entries = Object.keys(value).map(
|
|
1209
|
+
(key) => `${formatObjectKey(key)}: ${inspectWithCustom(value[key], depth - 1, options, seen)}`
|
|
1210
|
+
);
|
|
1211
|
+
seen.delete(value);
|
|
1212
|
+
return `{ ${entries.join(", ")} }`;
|
|
1213
|
+
}
|
|
1214
|
+
seen.delete(value);
|
|
1215
|
+
return originalInspect(value, options);
|
|
1216
|
+
};
|
|
1217
|
+
result.inspect = function inspect(value, options) {
|
|
1218
|
+
const inspectOptions = typeof options === "object" && options !== null ? options : {};
|
|
1219
|
+
const depth = typeof inspectOptions.depth === "number" ? inspectOptions.depth : 2;
|
|
1220
|
+
if (typeof value === "symbol") {
|
|
1221
|
+
return value.toString();
|
|
1222
|
+
}
|
|
1223
|
+
if (!containsCustomInspectable(value, depth, /* @__PURE__ */ new Set())) {
|
|
1224
|
+
return originalInspect.call(this, value, options);
|
|
1225
|
+
}
|
|
1226
|
+
return inspectWithCustom(value, depth, inspectOptions, /* @__PURE__ */ new Set());
|
|
1227
|
+
};
|
|
1228
|
+
result.inspect.custom = customInspectSymbol;
|
|
1229
|
+
result.inspect._secureExecPatchedCustomInspect = true;
|
|
1230
|
+
}
|
|
1231
|
+
return result;
|
|
1232
|
+
}
|
|
1233
|
+
if (name === "events") {
|
|
1234
|
+
if (typeof result.getEventListeners !== "function") {
|
|
1235
|
+
result.getEventListeners = function getEventListeners(target, eventName) {
|
|
1236
|
+
if (target && typeof target.listeners === "function") {
|
|
1237
|
+
return target.listeners(eventName);
|
|
1238
|
+
}
|
|
1239
|
+
if (target && typeof target.getEventListeners === "function") {
|
|
1240
|
+
return target.getEventListeners(eventName);
|
|
1241
|
+
}
|
|
1242
|
+
if (target && eventName === "abort" && Array.isArray(target._listeners)) {
|
|
1243
|
+
return target._listeners.slice();
|
|
1244
|
+
}
|
|
1245
|
+
return [];
|
|
1246
|
+
};
|
|
1247
|
+
}
|
|
1248
|
+
return result;
|
|
1249
|
+
}
|
|
1250
|
+
if (name === "stream" || name === "node:stream") {
|
|
1251
|
+
const getWebStreamsState2 = function() {
|
|
1252
|
+
return globalThis.__secureExecWebStreams || null;
|
|
1253
|
+
};
|
|
1254
|
+
const webStreamsState2 = getWebStreamsState2();
|
|
1255
|
+
if (typeof result.isReadable !== "function") {
|
|
1256
|
+
result.isReadable = function(stream) {
|
|
1257
|
+
const stateKey = getWebStreamsState2() && getWebStreamsState2().kState;
|
|
1258
|
+
return Boolean(stateKey && stream && stream[stateKey] && stream[stateKey].state === "readable");
|
|
1259
|
+
};
|
|
1260
|
+
}
|
|
1261
|
+
if (typeof result.isErrored !== "function") {
|
|
1262
|
+
result.isErrored = function(stream) {
|
|
1263
|
+
const stateKey = getWebStreamsState2() && getWebStreamsState2().kState;
|
|
1264
|
+
return Boolean(stateKey && stream && stream[stateKey] && stream[stateKey].state === "errored");
|
|
1265
|
+
};
|
|
1266
|
+
}
|
|
1267
|
+
if (typeof result.isDisturbed !== "function") {
|
|
1268
|
+
result.isDisturbed = function(stream) {
|
|
1269
|
+
const stateKey = getWebStreamsState2() && getWebStreamsState2().kState;
|
|
1270
|
+
return Boolean(stateKey && stream && stream[stateKey] && stream[stateKey].disturbed === true);
|
|
1271
|
+
};
|
|
1272
|
+
}
|
|
1273
|
+
const ReadableCtor = result.Readable;
|
|
1274
|
+
const WritableCtor = result.Writable;
|
|
1275
|
+
const readableFrom = typeof ReadableCtor === "function" ? ReadableCtor.from : void 0;
|
|
1276
|
+
const readableFromSource = typeof readableFrom === "function" ? Function.prototype.toString.call(readableFrom) : "";
|
|
1277
|
+
const hasBrowserReadableFromStub = readableFromSource.indexOf(
|
|
1278
|
+
"Readable.from is not available in the browser"
|
|
1279
|
+
) !== -1 || readableFromSource.indexOf("require_from_browser") !== -1;
|
|
1280
|
+
if (typeof ReadableCtor === "function" && (typeof readableFrom !== "function" || hasBrowserReadableFromStub)) {
|
|
1281
|
+
ReadableCtor.from = function from(iterable, options) {
|
|
1282
|
+
const readable = new ReadableCtor(Object.assign({ read() {
|
|
1283
|
+
} }, options || {}));
|
|
1284
|
+
Promise.resolve().then(async function() {
|
|
1285
|
+
try {
|
|
1286
|
+
if (iterable && typeof iterable[Symbol.asyncIterator] === "function") {
|
|
1287
|
+
for await (const chunk of iterable) {
|
|
1288
|
+
readable.push(chunk);
|
|
1289
|
+
}
|
|
1290
|
+
} else if (iterable && typeof iterable[Symbol.iterator] === "function") {
|
|
1291
|
+
for (const chunk of iterable) {
|
|
1292
|
+
readable.push(chunk);
|
|
1293
|
+
}
|
|
1294
|
+
} else {
|
|
1295
|
+
readable.push(iterable);
|
|
1296
|
+
}
|
|
1297
|
+
readable.push(null);
|
|
1298
|
+
} catch (error) {
|
|
1299
|
+
if (typeof readable.destroy === "function") {
|
|
1300
|
+
readable.destroy(error);
|
|
1301
|
+
} else {
|
|
1302
|
+
readable.emit("error", error);
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
});
|
|
1306
|
+
return readable;
|
|
1307
|
+
};
|
|
1308
|
+
}
|
|
1309
|
+
if (webStreamsState2 && typeof ReadableCtor === "function") {
|
|
1310
|
+
if (typeof ReadableCtor.fromWeb !== "function" && typeof webStreamsState2.newStreamReadableFromReadableStream === "function") {
|
|
1311
|
+
ReadableCtor.fromWeb = function fromWeb(readableStream, options) {
|
|
1312
|
+
return webStreamsState2.newStreamReadableFromReadableStream(readableStream, options);
|
|
1313
|
+
};
|
|
1314
|
+
}
|
|
1315
|
+
if (typeof ReadableCtor.toWeb !== "function" && typeof webStreamsState2.newReadableStreamFromStreamReadable === "function") {
|
|
1316
|
+
ReadableCtor.toWeb = function toWeb(readable) {
|
|
1317
|
+
return webStreamsState2.newReadableStreamFromStreamReadable(readable);
|
|
1318
|
+
};
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
if (webStreamsState2 && typeof WritableCtor === "function") {
|
|
1322
|
+
if (typeof WritableCtor.fromWeb !== "function" && typeof webStreamsState2.newStreamWritableFromWritableStream === "function") {
|
|
1323
|
+
WritableCtor.fromWeb = function fromWeb(writableStream, options) {
|
|
1324
|
+
return webStreamsState2.newStreamWritableFromWritableStream(writableStream, options);
|
|
1325
|
+
};
|
|
1326
|
+
}
|
|
1327
|
+
if (typeof WritableCtor.toWeb !== "function" && typeof webStreamsState2.newWritableStreamFromStreamWritable === "function") {
|
|
1328
|
+
WritableCtor.toWeb = function toWeb(writable) {
|
|
1329
|
+
return webStreamsState2.newWritableStreamFromStreamWritable(writable);
|
|
1330
|
+
};
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
if (webStreamsState2 && typeof result.Duplex === "function") {
|
|
1334
|
+
if (typeof result.Duplex.fromWeb !== "function" && typeof webStreamsState2.newStreamDuplexFromReadableWritablePair === "function") {
|
|
1335
|
+
result.Duplex.fromWeb = function fromWeb(pair, options) {
|
|
1336
|
+
return webStreamsState2.newStreamDuplexFromReadableWritablePair(pair, options);
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1339
|
+
if (typeof result.Duplex.toWeb !== "function" && typeof webStreamsState2.newReadableWritablePairFromDuplex === "function") {
|
|
1340
|
+
result.Duplex.toWeb = function toWeb(duplex) {
|
|
1341
|
+
return webStreamsState2.newReadableWritablePairFromDuplex(duplex);
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
if (typeof ReadableCtor === "function" && !Object.getOwnPropertyDescriptor(ReadableCtor.prototype, "readableObjectMode")) {
|
|
1346
|
+
Object.defineProperty(ReadableCtor.prototype, "readableObjectMode", {
|
|
1347
|
+
configurable: true,
|
|
1348
|
+
enumerable: false,
|
|
1349
|
+
get() {
|
|
1350
|
+
return Boolean(this?._readableState?.objectMode);
|
|
1351
|
+
}
|
|
1352
|
+
});
|
|
1353
|
+
}
|
|
1354
|
+
if (typeof WritableCtor === "function" && !Object.getOwnPropertyDescriptor(WritableCtor.prototype, "writableObjectMode")) {
|
|
1355
|
+
Object.defineProperty(WritableCtor.prototype, "writableObjectMode", {
|
|
1356
|
+
configurable: true,
|
|
1357
|
+
enumerable: false,
|
|
1358
|
+
get() {
|
|
1359
|
+
return Boolean(this?._writableState?.objectMode);
|
|
1360
|
+
}
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1363
|
+
return result;
|
|
1364
|
+
}
|
|
1365
|
+
if (name === "url") {
|
|
1366
|
+
const OriginalURL = result.URL;
|
|
189
1367
|
if (typeof OriginalURL !== "function" || OriginalURL._patched) {
|
|
190
|
-
return
|
|
1368
|
+
return result;
|
|
191
1369
|
}
|
|
192
1370
|
const PatchedURL = function PatchedURL2(url, base) {
|
|
193
1371
|
if (typeof url === "string" && url.startsWith("file:") && !url.startsWith("file://") && base === void 0) {
|
|
@@ -212,15 +1390,15 @@
|
|
|
212
1390
|
Object.setPrototypeOf(PatchedURL, OriginalURL);
|
|
213
1391
|
PatchedURL.prototype = OriginalURL.prototype;
|
|
214
1392
|
PatchedURL._patched = true;
|
|
215
|
-
const descriptor = Object.getOwnPropertyDescriptor(
|
|
1393
|
+
const descriptor = Object.getOwnPropertyDescriptor(result, "URL");
|
|
216
1394
|
if (descriptor && descriptor.configurable !== true && descriptor.writable !== true && typeof descriptor.set !== "function") {
|
|
217
|
-
return
|
|
1395
|
+
return result;
|
|
218
1396
|
}
|
|
219
1397
|
try {
|
|
220
|
-
|
|
1398
|
+
result.URL = PatchedURL;
|
|
221
1399
|
} catch {
|
|
222
1400
|
try {
|
|
223
|
-
Object.defineProperty(
|
|
1401
|
+
Object.defineProperty(result, "URL", {
|
|
224
1402
|
value: PatchedURL,
|
|
225
1403
|
writable: true,
|
|
226
1404
|
configurable: true,
|
|
@@ -229,16 +1407,16 @@
|
|
|
229
1407
|
} catch {
|
|
230
1408
|
}
|
|
231
1409
|
}
|
|
232
|
-
return
|
|
1410
|
+
return result;
|
|
233
1411
|
}
|
|
234
|
-
if (
|
|
235
|
-
if (typeof
|
|
1412
|
+
if (name === "zlib") {
|
|
1413
|
+
if (typeof result.constants !== "object" || result.constants === null) {
|
|
236
1414
|
var zlibConstants = {};
|
|
237
|
-
var constKeys = Object.keys(
|
|
1415
|
+
var constKeys = Object.keys(result);
|
|
238
1416
|
for (var ci = 0; ci < constKeys.length; ci++) {
|
|
239
1417
|
var ck = constKeys[ci];
|
|
240
|
-
if (ck.indexOf("Z_") === 0 && typeof
|
|
241
|
-
zlibConstants[ck] =
|
|
1418
|
+
if (ck.indexOf("Z_") === 0 && typeof result[ck] === "number") {
|
|
1419
|
+
zlibConstants[ck] = result[ck];
|
|
242
1420
|
}
|
|
243
1421
|
}
|
|
244
1422
|
if (typeof zlibConstants.DEFLATE !== "number") zlibConstants.DEFLATE = 1;
|
|
@@ -248,51 +1426,168 @@
|
|
|
248
1426
|
if (typeof zlibConstants.INFLATERAW !== "number") zlibConstants.INFLATERAW = 5;
|
|
249
1427
|
if (typeof zlibConstants.UNZIP !== "number") zlibConstants.UNZIP = 6;
|
|
250
1428
|
if (typeof zlibConstants.GUNZIP !== "number") zlibConstants.GUNZIP = 7;
|
|
251
|
-
|
|
1429
|
+
result.constants = zlibConstants;
|
|
252
1430
|
}
|
|
253
|
-
return
|
|
1431
|
+
return result;
|
|
254
1432
|
}
|
|
255
|
-
if (
|
|
1433
|
+
if (name === "crypto") {
|
|
1434
|
+
let createCryptoRangeError2 = function(name2, message) {
|
|
1435
|
+
var error = new RangeError(message);
|
|
1436
|
+
error.code = "ERR_OUT_OF_RANGE";
|
|
1437
|
+
error.name = "RangeError";
|
|
1438
|
+
return error;
|
|
1439
|
+
}, createCryptoError2 = function(code, message) {
|
|
1440
|
+
var error = new Error(message);
|
|
1441
|
+
error.code = code;
|
|
1442
|
+
return error;
|
|
1443
|
+
}, encodeCryptoResult2 = function(buffer, encoding) {
|
|
1444
|
+
if (!encoding || encoding === "buffer") return buffer;
|
|
1445
|
+
return buffer.toString(encoding);
|
|
1446
|
+
}, isSharedArrayBufferInstance2 = function(value) {
|
|
1447
|
+
return typeof SharedArrayBuffer !== "undefined" && value instanceof SharedArrayBuffer;
|
|
1448
|
+
}, isBinaryLike2 = function(value) {
|
|
1449
|
+
return Buffer.isBuffer(value) || ArrayBuffer.isView(value) || value instanceof ArrayBuffer || isSharedArrayBufferInstance2(value);
|
|
1450
|
+
}, normalizeByteSource2 = function(value, name2, options) {
|
|
1451
|
+
var allowNull = options && options.allowNull;
|
|
1452
|
+
if (allowNull && value === null) {
|
|
1453
|
+
return null;
|
|
1454
|
+
}
|
|
1455
|
+
if (typeof value === "string") {
|
|
1456
|
+
return Buffer.from(value, "utf8");
|
|
1457
|
+
}
|
|
1458
|
+
if (Buffer.isBuffer(value)) {
|
|
1459
|
+
return Buffer.from(value);
|
|
1460
|
+
}
|
|
1461
|
+
if (ArrayBuffer.isView(value)) {
|
|
1462
|
+
return Buffer.from(value.buffer, value.byteOffset, value.byteLength);
|
|
1463
|
+
}
|
|
1464
|
+
if (value instanceof ArrayBuffer || isSharedArrayBufferInstance2(value)) {
|
|
1465
|
+
return Buffer.from(value);
|
|
1466
|
+
}
|
|
1467
|
+
throw createInvalidArgTypeError(
|
|
1468
|
+
name2,
|
|
1469
|
+
"of type string or an instance of ArrayBuffer, Buffer, TypedArray, or DataView",
|
|
1470
|
+
value
|
|
1471
|
+
);
|
|
1472
|
+
}, serializeCipherBridgeOptions2 = function(options) {
|
|
1473
|
+
if (!options) {
|
|
1474
|
+
return "";
|
|
1475
|
+
}
|
|
1476
|
+
var serialized = {};
|
|
1477
|
+
if (options.authTagLength !== void 0) {
|
|
1478
|
+
serialized.authTagLength = options.authTagLength;
|
|
1479
|
+
}
|
|
1480
|
+
if (options.authTag) {
|
|
1481
|
+
serialized.authTag = options.authTag.toString("base64");
|
|
1482
|
+
}
|
|
1483
|
+
if (options.aad) {
|
|
1484
|
+
serialized.aad = options.aad.toString("base64");
|
|
1485
|
+
}
|
|
1486
|
+
if (options.aadOptions !== void 0) {
|
|
1487
|
+
serialized.aadOptions = options.aadOptions;
|
|
1488
|
+
}
|
|
1489
|
+
if (options.autoPadding !== void 0) {
|
|
1490
|
+
serialized.autoPadding = options.autoPadding;
|
|
1491
|
+
}
|
|
1492
|
+
if (options.validateOnly !== void 0) {
|
|
1493
|
+
serialized.validateOnly = options.validateOnly;
|
|
1494
|
+
}
|
|
1495
|
+
return JSON.stringify(serialized);
|
|
1496
|
+
};
|
|
1497
|
+
var createCryptoRangeError = createCryptoRangeError2, createCryptoError = createCryptoError2, encodeCryptoResult = encodeCryptoResult2, isSharedArrayBufferInstance = isSharedArrayBufferInstance2, isBinaryLike = isBinaryLike2, normalizeByteSource = normalizeByteSource2, serializeCipherBridgeOptions = serializeCipherBridgeOptions2;
|
|
1498
|
+
var _runtimeRequire = globalThis.require;
|
|
1499
|
+
var _streamModule = _runtimeRequire && _runtimeRequire("stream");
|
|
1500
|
+
var _utilModule = _runtimeRequire && _runtimeRequire("util");
|
|
1501
|
+
var _Transform = _streamModule && _streamModule.Transform;
|
|
1502
|
+
var _inherits = _utilModule && _utilModule.inherits;
|
|
256
1503
|
if (typeof _cryptoHashDigest !== "undefined") {
|
|
257
|
-
let SandboxHash2 = function(algorithm) {
|
|
1504
|
+
let SandboxHash2 = function(algorithm, options) {
|
|
1505
|
+
if (!(this instanceof SandboxHash2)) {
|
|
1506
|
+
return new SandboxHash2(algorithm, options);
|
|
1507
|
+
}
|
|
1508
|
+
if (!_Transform || !_inherits) {
|
|
1509
|
+
throw new Error("stream.Transform is required for crypto.Hash");
|
|
1510
|
+
}
|
|
1511
|
+
if (typeof algorithm !== "string") {
|
|
1512
|
+
throw createInvalidArgTypeError("algorithm", "of type string", algorithm);
|
|
1513
|
+
}
|
|
1514
|
+
_Transform.call(this, options);
|
|
258
1515
|
this._algorithm = algorithm;
|
|
259
1516
|
this._chunks = [];
|
|
1517
|
+
this._finalized = false;
|
|
1518
|
+
this._cachedDigest = null;
|
|
1519
|
+
this._allowCachedDigest = false;
|
|
260
1520
|
};
|
|
261
1521
|
var SandboxHash = SandboxHash2;
|
|
1522
|
+
_inherits(SandboxHash2, _Transform);
|
|
262
1523
|
SandboxHash2.prototype.update = function update(data, inputEncoding) {
|
|
1524
|
+
if (this._finalized) {
|
|
1525
|
+
throw createCryptoError2("ERR_CRYPTO_HASH_FINALIZED", "Digest already called");
|
|
1526
|
+
}
|
|
263
1527
|
if (typeof data === "string") {
|
|
264
1528
|
this._chunks.push(Buffer.from(data, inputEncoding || "utf8"));
|
|
265
|
-
} else {
|
|
1529
|
+
} else if (isBinaryLike2(data)) {
|
|
266
1530
|
this._chunks.push(Buffer.from(data));
|
|
1531
|
+
} else {
|
|
1532
|
+
throw createInvalidArgTypeError(
|
|
1533
|
+
"data",
|
|
1534
|
+
"one of type string, Buffer, TypedArray, or DataView",
|
|
1535
|
+
data
|
|
1536
|
+
);
|
|
267
1537
|
}
|
|
268
1538
|
return this;
|
|
269
1539
|
};
|
|
270
|
-
SandboxHash2.prototype.
|
|
1540
|
+
SandboxHash2.prototype._finishDigest = function _finishDigest() {
|
|
1541
|
+
if (this._cachedDigest) {
|
|
1542
|
+
return this._cachedDigest;
|
|
1543
|
+
}
|
|
271
1544
|
var combined = Buffer.concat(this._chunks);
|
|
272
1545
|
var resultBase64 = _cryptoHashDigest.applySync(void 0, [
|
|
273
1546
|
this._algorithm,
|
|
274
1547
|
combined.toString("base64")
|
|
275
1548
|
]);
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
return
|
|
1549
|
+
this._cachedDigest = Buffer.from(resultBase64, "base64");
|
|
1550
|
+
this._finalized = true;
|
|
1551
|
+
return this._cachedDigest;
|
|
1552
|
+
};
|
|
1553
|
+
SandboxHash2.prototype.digest = function digest(encoding) {
|
|
1554
|
+
if (this._finalized && !this._allowCachedDigest) {
|
|
1555
|
+
throw createCryptoError2("ERR_CRYPTO_HASH_FINALIZED", "Digest already called");
|
|
1556
|
+
}
|
|
1557
|
+
var resultBuffer = this._finishDigest();
|
|
1558
|
+
this._allowCachedDigest = false;
|
|
1559
|
+
return encodeCryptoResult2(resultBuffer, encoding);
|
|
279
1560
|
};
|
|
280
1561
|
SandboxHash2.prototype.copy = function copy() {
|
|
1562
|
+
if (this._finalized) {
|
|
1563
|
+
throw createCryptoError2("ERR_CRYPTO_HASH_FINALIZED", "Digest already called");
|
|
1564
|
+
}
|
|
281
1565
|
var c = new SandboxHash2(this._algorithm);
|
|
282
1566
|
c._chunks = this._chunks.slice();
|
|
283
1567
|
return c;
|
|
284
1568
|
};
|
|
285
|
-
SandboxHash2.prototype.
|
|
286
|
-
|
|
287
|
-
|
|
1569
|
+
SandboxHash2.prototype._transform = function _transform(chunk, encoding, callback) {
|
|
1570
|
+
try {
|
|
1571
|
+
this.update(chunk, encoding === "buffer" ? void 0 : encoding);
|
|
1572
|
+
callback();
|
|
1573
|
+
} catch (error) {
|
|
1574
|
+
callback(normalizeCryptoBridgeError(error));
|
|
1575
|
+
}
|
|
288
1576
|
};
|
|
289
|
-
SandboxHash2.prototype.
|
|
290
|
-
|
|
1577
|
+
SandboxHash2.prototype._flush = function _flush(callback) {
|
|
1578
|
+
try {
|
|
1579
|
+
var output = this._finishDigest();
|
|
1580
|
+
this._allowCachedDigest = true;
|
|
1581
|
+
this.push(output);
|
|
1582
|
+
callback();
|
|
1583
|
+
} catch (error) {
|
|
1584
|
+
callback(normalizeCryptoBridgeError(error));
|
|
1585
|
+
}
|
|
291
1586
|
};
|
|
292
|
-
|
|
293
|
-
return new SandboxHash2(algorithm);
|
|
1587
|
+
result.createHash = function createHash(algorithm, options) {
|
|
1588
|
+
return new SandboxHash2(algorithm, options);
|
|
294
1589
|
};
|
|
295
|
-
|
|
1590
|
+
result.Hash = SandboxHash2;
|
|
296
1591
|
}
|
|
297
1592
|
if (typeof _cryptoHmacDigest !== "undefined") {
|
|
298
1593
|
let SandboxHmac2 = function(algorithm, key) {
|
|
@@ -338,13 +1633,13 @@
|
|
|
338
1633
|
SandboxHmac2.prototype.end = function end(data, encoding) {
|
|
339
1634
|
if (data) this.update(data, encoding);
|
|
340
1635
|
};
|
|
341
|
-
|
|
1636
|
+
result.createHmac = function createHmac(algorithm, key) {
|
|
342
1637
|
return new SandboxHmac2(algorithm, key);
|
|
343
1638
|
};
|
|
344
|
-
|
|
1639
|
+
result.Hmac = SandboxHmac2;
|
|
345
1640
|
}
|
|
346
1641
|
if (typeof _cryptoRandomFill !== "undefined") {
|
|
347
|
-
|
|
1642
|
+
result.randomBytes = function randomBytes(size, callback) {
|
|
348
1643
|
if (typeof size !== "number" || size < 0 || size !== (size | 0)) {
|
|
349
1644
|
var err = new TypeError('The "size" argument must be of type number. Received type ' + typeof size);
|
|
350
1645
|
if (typeof callback === "function") {
|
|
@@ -376,7 +1671,7 @@
|
|
|
376
1671
|
}
|
|
377
1672
|
return buf;
|
|
378
1673
|
};
|
|
379
|
-
|
|
1674
|
+
result.randomFillSync = function randomFillSync(buffer, offset, size) {
|
|
380
1675
|
if (offset === void 0) offset = 0;
|
|
381
1676
|
var byteLength = buffer.byteLength !== void 0 ? buffer.byteLength : buffer.length;
|
|
382
1677
|
if (size === void 0) size = byteLength - offset;
|
|
@@ -394,7 +1689,7 @@
|
|
|
394
1689
|
}
|
|
395
1690
|
return buffer;
|
|
396
1691
|
};
|
|
397
|
-
|
|
1692
|
+
result.randomFill = function randomFill(buffer, offsetOrCb, sizeOrCb, callback) {
|
|
398
1693
|
var offset = 0;
|
|
399
1694
|
var size;
|
|
400
1695
|
var cb;
|
|
@@ -412,13 +1707,13 @@
|
|
|
412
1707
|
throw new TypeError("Callback must be a function");
|
|
413
1708
|
}
|
|
414
1709
|
try {
|
|
415
|
-
|
|
1710
|
+
result.randomFillSync(buffer, offset, size);
|
|
416
1711
|
cb(null, buffer);
|
|
417
1712
|
} catch (e) {
|
|
418
1713
|
cb(e);
|
|
419
1714
|
}
|
|
420
1715
|
};
|
|
421
|
-
|
|
1716
|
+
result.randomInt = function randomInt(minOrMax, maxOrCb, callback) {
|
|
422
1717
|
var min, max, cb;
|
|
423
1718
|
if (typeof maxOrCb === "function" || maxOrCb === void 0) {
|
|
424
1719
|
min = 0;
|
|
@@ -462,38 +1757,124 @@
|
|
|
462
1757
|
var buf = Buffer.from(base64, "base64");
|
|
463
1758
|
val = buf.readUIntBE(0, bytes);
|
|
464
1759
|
} while (val >= maxValid);
|
|
465
|
-
var
|
|
1760
|
+
var result2 = min + val % range;
|
|
466
1761
|
if (typeof cb === "function") {
|
|
467
|
-
cb(null,
|
|
1762
|
+
cb(null, result2);
|
|
468
1763
|
return;
|
|
469
1764
|
}
|
|
470
|
-
return
|
|
1765
|
+
return result2;
|
|
1766
|
+
};
|
|
1767
|
+
}
|
|
1768
|
+
if (typeof _cryptoRandomUUID !== "undefined" && typeof result.randomUUID !== "function") {
|
|
1769
|
+
result.randomUUID = function randomUUID(options) {
|
|
1770
|
+
if (options !== void 0) {
|
|
1771
|
+
if (options === null || typeof options !== "object") {
|
|
1772
|
+
throw createInvalidArgTypeError("options", "of type object", options);
|
|
1773
|
+
}
|
|
1774
|
+
if (Object.prototype.hasOwnProperty.call(options, "disableEntropyCache") && typeof options.disableEntropyCache !== "boolean") {
|
|
1775
|
+
throw createInvalidArgTypeError(
|
|
1776
|
+
"options.disableEntropyCache",
|
|
1777
|
+
"of type boolean",
|
|
1778
|
+
options.disableEntropyCache
|
|
1779
|
+
);
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
var uuid = _cryptoRandomUUID.applySync(void 0, []);
|
|
1783
|
+
if (typeof uuid !== "string") {
|
|
1784
|
+
throw new Error("invalid host uuid");
|
|
1785
|
+
}
|
|
1786
|
+
return uuid;
|
|
471
1787
|
};
|
|
472
1788
|
}
|
|
473
1789
|
if (typeof _cryptoPbkdf2 !== "undefined") {
|
|
474
|
-
|
|
475
|
-
var
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
1790
|
+
let createPbkdf2ArgTypeError2 = function(name2, value) {
|
|
1791
|
+
var received;
|
|
1792
|
+
if (value == null) {
|
|
1793
|
+
received = " Received " + value;
|
|
1794
|
+
} else if (typeof value === "object") {
|
|
1795
|
+
received = value.constructor && value.constructor.name ? " Received an instance of " + value.constructor.name : " Received [object Object]";
|
|
1796
|
+
} else {
|
|
1797
|
+
var inspected = typeof value === "string" ? "'" + value + "'" : String(value);
|
|
1798
|
+
received = " Received type " + typeof value + " (" + inspected + ")";
|
|
1799
|
+
}
|
|
1800
|
+
var error = new TypeError('The "' + name2 + '" argument must be of type number.' + received);
|
|
1801
|
+
error.code = "ERR_INVALID_ARG_TYPE";
|
|
1802
|
+
return error;
|
|
1803
|
+
}, validatePbkdf2Args2 = function(password, salt, iterations, keylen, digest) {
|
|
1804
|
+
var pwBuf = normalizeByteSource2(password, "password");
|
|
1805
|
+
var saltBuf = normalizeByteSource2(salt, "salt");
|
|
1806
|
+
if (typeof iterations !== "number") {
|
|
1807
|
+
throw createPbkdf2ArgTypeError2("iterations", iterations);
|
|
1808
|
+
}
|
|
1809
|
+
if (!Number.isInteger(iterations)) {
|
|
1810
|
+
throw createCryptoRangeError2(
|
|
1811
|
+
"iterations",
|
|
1812
|
+
'The value of "iterations" is out of range. It must be an integer. Received ' + iterations
|
|
1813
|
+
);
|
|
1814
|
+
}
|
|
1815
|
+
if (iterations < 1 || iterations > 2147483647) {
|
|
1816
|
+
throw createCryptoRangeError2(
|
|
1817
|
+
"iterations",
|
|
1818
|
+
'The value of "iterations" is out of range. It must be >= 1 && <= 2147483647. Received ' + iterations
|
|
1819
|
+
);
|
|
1820
|
+
}
|
|
1821
|
+
if (typeof keylen !== "number") {
|
|
1822
|
+
throw createPbkdf2ArgTypeError2("keylen", keylen);
|
|
1823
|
+
}
|
|
1824
|
+
if (!Number.isInteger(keylen)) {
|
|
1825
|
+
throw createCryptoRangeError2(
|
|
1826
|
+
"keylen",
|
|
1827
|
+
'The value of "keylen" is out of range. It must be an integer. Received ' + keylen
|
|
1828
|
+
);
|
|
1829
|
+
}
|
|
1830
|
+
if (keylen < 0 || keylen > 2147483647) {
|
|
1831
|
+
throw createCryptoRangeError2(
|
|
1832
|
+
"keylen",
|
|
1833
|
+
'The value of "keylen" is out of range. It must be >= 0 && <= 2147483647. Received ' + keylen
|
|
1834
|
+
);
|
|
1835
|
+
}
|
|
1836
|
+
if (typeof digest !== "string") {
|
|
1837
|
+
throw createInvalidArgTypeError("digest", "of type string", digest);
|
|
1838
|
+
}
|
|
1839
|
+
return {
|
|
1840
|
+
password: pwBuf,
|
|
1841
|
+
salt: saltBuf
|
|
1842
|
+
};
|
|
1843
|
+
};
|
|
1844
|
+
var createPbkdf2ArgTypeError = createPbkdf2ArgTypeError2, validatePbkdf2Args = validatePbkdf2Args2;
|
|
1845
|
+
result.pbkdf2Sync = function pbkdf2Sync(password, salt, iterations, keylen, digest) {
|
|
1846
|
+
var normalized = validatePbkdf2Args2(password, salt, iterations, keylen, digest);
|
|
1847
|
+
try {
|
|
1848
|
+
var resultBase64 = _cryptoPbkdf2.applySync(void 0, [
|
|
1849
|
+
normalized.password.toString("base64"),
|
|
1850
|
+
normalized.salt.toString("base64"),
|
|
1851
|
+
iterations,
|
|
1852
|
+
keylen,
|
|
1853
|
+
digest
|
|
1854
|
+
]);
|
|
1855
|
+
return Buffer.from(resultBase64, "base64");
|
|
1856
|
+
} catch (error) {
|
|
1857
|
+
throw normalizeCryptoBridgeError(error);
|
|
1858
|
+
}
|
|
485
1859
|
};
|
|
486
|
-
|
|
1860
|
+
result.pbkdf2 = function pbkdf2(password, salt, iterations, keylen, digest, callback) {
|
|
1861
|
+
if (typeof digest === "function" && callback === void 0) {
|
|
1862
|
+
callback = digest;
|
|
1863
|
+
digest = void 0;
|
|
1864
|
+
}
|
|
1865
|
+
if (typeof callback !== "function") {
|
|
1866
|
+
throw createInvalidArgTypeError("callback", "of type function", callback);
|
|
1867
|
+
}
|
|
487
1868
|
try {
|
|
488
|
-
var derived =
|
|
489
|
-
callback
|
|
1869
|
+
var derived = result.pbkdf2Sync(password, salt, iterations, keylen, digest);
|
|
1870
|
+
scheduleCryptoCallback(callback, [null, derived]);
|
|
490
1871
|
} catch (e) {
|
|
491
|
-
|
|
1872
|
+
throw normalizeCryptoBridgeError(e);
|
|
492
1873
|
}
|
|
493
1874
|
};
|
|
494
1875
|
}
|
|
495
1876
|
if (typeof _cryptoScrypt !== "undefined") {
|
|
496
|
-
|
|
1877
|
+
result.scryptSync = function scryptSync(password, salt, keylen, options) {
|
|
497
1878
|
var pwBuf = typeof password === "string" ? Buffer.from(password, "utf8") : Buffer.from(password);
|
|
498
1879
|
var saltBuf = typeof salt === "string" ? Buffer.from(salt, "utf8") : Buffer.from(salt);
|
|
499
1880
|
var opts = {};
|
|
@@ -514,7 +1895,7 @@
|
|
|
514
1895
|
]);
|
|
515
1896
|
return Buffer.from(resultBase64, "base64");
|
|
516
1897
|
};
|
|
517
|
-
|
|
1898
|
+
result.scrypt = function scrypt(password, salt, keylen, optionsOrCb, callback) {
|
|
518
1899
|
var opts = optionsOrCb;
|
|
519
1900
|
var cb = callback;
|
|
520
1901
|
if (typeof optionsOrCb === "function") {
|
|
@@ -522,239 +1903,936 @@
|
|
|
522
1903
|
cb = optionsOrCb;
|
|
523
1904
|
}
|
|
524
1905
|
try {
|
|
525
|
-
var derived =
|
|
1906
|
+
var derived = result.scryptSync(password, salt, keylen, opts);
|
|
526
1907
|
cb(null, derived);
|
|
527
1908
|
} catch (e) {
|
|
528
1909
|
cb(e);
|
|
529
1910
|
}
|
|
530
1911
|
};
|
|
531
1912
|
}
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
1913
|
+
if (typeof _cryptoCipheriv !== "undefined") {
|
|
1914
|
+
let SandboxCipher2 = function(algorithm, key, iv, options) {
|
|
1915
|
+
if (!(this instanceof SandboxCipher2)) {
|
|
1916
|
+
return new SandboxCipher2(algorithm, key, iv, options);
|
|
1917
|
+
}
|
|
1918
|
+
if (typeof algorithm !== "string") {
|
|
1919
|
+
throw createInvalidArgTypeError("cipher", "of type string", algorithm);
|
|
1920
|
+
}
|
|
1921
|
+
_Transform.call(this);
|
|
535
1922
|
this._algorithm = algorithm;
|
|
536
|
-
this._key =
|
|
537
|
-
this._iv =
|
|
1923
|
+
this._key = normalizeByteSource2(key, "key");
|
|
1924
|
+
this._iv = normalizeByteSource2(iv, "iv", { allowNull: true });
|
|
1925
|
+
this._options = options || void 0;
|
|
538
1926
|
this._authTag = null;
|
|
539
1927
|
this._finalized = false;
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
1928
|
+
this._sessionCreated = false;
|
|
1929
|
+
this._sessionId = void 0;
|
|
1930
|
+
this._aad = null;
|
|
1931
|
+
this._aadOptions = void 0;
|
|
1932
|
+
this._autoPadding = void 0;
|
|
1933
|
+
this._chunks = [];
|
|
1934
|
+
this._bufferedMode = !_useSessionCipher || !!options;
|
|
1935
|
+
if (!this._bufferedMode) {
|
|
1936
|
+
this._ensureSession();
|
|
1937
|
+
} else if (!options) {
|
|
1938
|
+
_cryptoCipheriv.applySync(void 0, [
|
|
1939
|
+
this._algorithm,
|
|
544
1940
|
this._key.toString("base64"),
|
|
545
|
-
this._iv.toString("base64")
|
|
1941
|
+
this._iv === null ? null : this._iv.toString("base64"),
|
|
1942
|
+
"",
|
|
1943
|
+
serializeCipherBridgeOptions2({ validateOnly: true })
|
|
546
1944
|
]);
|
|
547
|
-
} else {
|
|
548
|
-
this._sessionId = -1;
|
|
549
|
-
this._chunks = [];
|
|
550
1945
|
}
|
|
551
1946
|
};
|
|
552
1947
|
var SandboxCipher = SandboxCipher2;
|
|
1948
|
+
var _useSessionCipher = typeof _cryptoCipherivCreate !== "undefined";
|
|
1949
|
+
_inherits(SandboxCipher2, _Transform);
|
|
1950
|
+
SandboxCipher2.prototype._ensureSession = function _ensureSession() {
|
|
1951
|
+
if (this._bufferedMode || this._sessionCreated) {
|
|
1952
|
+
return;
|
|
1953
|
+
}
|
|
1954
|
+
this._sessionCreated = true;
|
|
1955
|
+
this._sessionId = _cryptoCipherivCreate.applySync(void 0, [
|
|
1956
|
+
"cipher",
|
|
1957
|
+
this._algorithm,
|
|
1958
|
+
this._key.toString("base64"),
|
|
1959
|
+
this._iv === null ? null : this._iv.toString("base64"),
|
|
1960
|
+
serializeCipherBridgeOptions2(this._getBridgeOptions())
|
|
1961
|
+
]);
|
|
1962
|
+
};
|
|
1963
|
+
SandboxCipher2.prototype._getBridgeOptions = function _getBridgeOptions() {
|
|
1964
|
+
var options = {};
|
|
1965
|
+
if (this._options && this._options.authTagLength !== void 0) {
|
|
1966
|
+
options.authTagLength = this._options.authTagLength;
|
|
1967
|
+
}
|
|
1968
|
+
if (this._aad) {
|
|
1969
|
+
options.aad = this._aad;
|
|
1970
|
+
}
|
|
1971
|
+
if (this._aadOptions !== void 0) {
|
|
1972
|
+
options.aadOptions = this._aadOptions;
|
|
1973
|
+
}
|
|
1974
|
+
if (this._autoPadding !== void 0) {
|
|
1975
|
+
options.autoPadding = this._autoPadding;
|
|
1976
|
+
}
|
|
1977
|
+
return Object.keys(options).length === 0 ? null : options;
|
|
1978
|
+
};
|
|
553
1979
|
SandboxCipher2.prototype.update = function update(data, inputEncoding, outputEncoding) {
|
|
1980
|
+
if (this._finalized) {
|
|
1981
|
+
throw new Error("Attempting to call update() after final()");
|
|
1982
|
+
}
|
|
554
1983
|
var buf;
|
|
555
1984
|
if (typeof data === "string") {
|
|
556
1985
|
buf = Buffer.from(data, inputEncoding || "utf8");
|
|
557
1986
|
} else {
|
|
558
|
-
buf =
|
|
1987
|
+
buf = normalizeByteSource2(data, "data");
|
|
559
1988
|
}
|
|
560
|
-
if (this.
|
|
1989
|
+
if (!this._bufferedMode) {
|
|
1990
|
+
this._ensureSession();
|
|
561
1991
|
var resultBase64 = _cryptoCipherivUpdate.applySync(void 0, [this._sessionId, buf.toString("base64")]);
|
|
562
1992
|
var resultBuffer = Buffer.from(resultBase64, "base64");
|
|
563
|
-
|
|
564
|
-
return resultBuffer;
|
|
1993
|
+
return encodeCryptoResult2(resultBuffer, outputEncoding);
|
|
565
1994
|
}
|
|
566
1995
|
this._chunks.push(buf);
|
|
567
|
-
|
|
568
|
-
return Buffer.alloc(0);
|
|
1996
|
+
return encodeCryptoResult2(Buffer.alloc(0), outputEncoding);
|
|
569
1997
|
};
|
|
570
1998
|
SandboxCipher2.prototype.final = function final(outputEncoding) {
|
|
571
1999
|
if (this._finalized) throw new Error("Attempting to call final() after already finalized");
|
|
572
2000
|
this._finalized = true;
|
|
573
|
-
|
|
2001
|
+
var parsed;
|
|
2002
|
+
if (!this._bufferedMode) {
|
|
2003
|
+
this._ensureSession();
|
|
574
2004
|
var resultJson = _cryptoCipherivFinal.applySync(void 0, [this._sessionId]);
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
var
|
|
578
|
-
|
|
579
|
-
|
|
2005
|
+
parsed = JSON.parse(resultJson);
|
|
2006
|
+
} else {
|
|
2007
|
+
var combined = Buffer.concat(this._chunks);
|
|
2008
|
+
var resultJson2 = _cryptoCipheriv.applySync(void 0, [
|
|
2009
|
+
this._algorithm,
|
|
2010
|
+
this._key.toString("base64"),
|
|
2011
|
+
this._iv === null ? null : this._iv.toString("base64"),
|
|
2012
|
+
combined.toString("base64"),
|
|
2013
|
+
serializeCipherBridgeOptions2(this._getBridgeOptions())
|
|
2014
|
+
]);
|
|
2015
|
+
parsed = JSON.parse(resultJson2);
|
|
580
2016
|
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
combined.toString("base64")
|
|
587
|
-
]);
|
|
588
|
-
var parsed2 = JSON.parse(resultJson2);
|
|
589
|
-
if (parsed2.authTag) this._authTag = Buffer.from(parsed2.authTag, "base64");
|
|
590
|
-
var resultBuffer2 = Buffer.from(parsed2.data, "base64");
|
|
591
|
-
if (outputEncoding && outputEncoding !== "buffer") return resultBuffer2.toString(outputEncoding);
|
|
592
|
-
return resultBuffer2;
|
|
2017
|
+
if (parsed.authTag) {
|
|
2018
|
+
this._authTag = Buffer.from(parsed.authTag, "base64");
|
|
2019
|
+
}
|
|
2020
|
+
var resultBuffer = Buffer.from(parsed.data, "base64");
|
|
2021
|
+
return encodeCryptoResult2(resultBuffer, outputEncoding);
|
|
593
2022
|
};
|
|
594
2023
|
SandboxCipher2.prototype.getAuthTag = function getAuthTag() {
|
|
595
2024
|
if (!this._finalized) throw new Error("Cannot call getAuthTag before final()");
|
|
596
|
-
if (!this._authTag) throw new Error("Auth tag is
|
|
2025
|
+
if (!this._authTag) throw new Error("Auth tag is not available");
|
|
597
2026
|
return this._authTag;
|
|
598
2027
|
};
|
|
599
|
-
SandboxCipher2.prototype.setAAD = function setAAD(
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
}
|
|
2028
|
+
SandboxCipher2.prototype.setAAD = function setAAD(aad, options) {
|
|
2029
|
+
this._bufferedMode = true;
|
|
2030
|
+
this._aad = normalizeByteSource2(aad, "buffer");
|
|
2031
|
+
this._aadOptions = options;
|
|
604
2032
|
return this;
|
|
605
2033
|
};
|
|
606
2034
|
SandboxCipher2.prototype.setAutoPadding = function setAutoPadding(autoPadding) {
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
}
|
|
2035
|
+
this._bufferedMode = true;
|
|
2036
|
+
this._autoPadding = autoPadding !== false;
|
|
610
2037
|
return this;
|
|
611
2038
|
};
|
|
612
|
-
|
|
613
|
-
|
|
2039
|
+
SandboxCipher2.prototype._transform = function _transform(chunk, encoding, callback) {
|
|
2040
|
+
try {
|
|
2041
|
+
var output = this.update(chunk, encoding === "buffer" ? void 0 : encoding);
|
|
2042
|
+
if (output.length) {
|
|
2043
|
+
this.push(output);
|
|
2044
|
+
}
|
|
2045
|
+
callback();
|
|
2046
|
+
} catch (error) {
|
|
2047
|
+
callback(normalizeCryptoBridgeError(error));
|
|
2048
|
+
}
|
|
2049
|
+
};
|
|
2050
|
+
SandboxCipher2.prototype._flush = function _flush(callback) {
|
|
2051
|
+
try {
|
|
2052
|
+
var output = this.final();
|
|
2053
|
+
if (output.length) {
|
|
2054
|
+
this.push(output);
|
|
2055
|
+
}
|
|
2056
|
+
callback();
|
|
2057
|
+
} catch (error) {
|
|
2058
|
+
callback(normalizeCryptoBridgeError(error));
|
|
2059
|
+
}
|
|
2060
|
+
};
|
|
2061
|
+
result.createCipheriv = function createCipheriv(algorithm, key, iv, options) {
|
|
2062
|
+
return new SandboxCipher2(algorithm, key, iv, options);
|
|
614
2063
|
};
|
|
615
|
-
|
|
2064
|
+
result.Cipheriv = SandboxCipher2;
|
|
616
2065
|
}
|
|
617
|
-
if (typeof _cryptoDecipheriv !== "undefined"
|
|
618
|
-
let SandboxDecipher2 = function(algorithm, key, iv) {
|
|
2066
|
+
if (typeof _cryptoDecipheriv !== "undefined") {
|
|
2067
|
+
let SandboxDecipher2 = function(algorithm, key, iv, options) {
|
|
2068
|
+
if (!(this instanceof SandboxDecipher2)) {
|
|
2069
|
+
return new SandboxDecipher2(algorithm, key, iv, options);
|
|
2070
|
+
}
|
|
2071
|
+
if (typeof algorithm !== "string") {
|
|
2072
|
+
throw createInvalidArgTypeError("cipher", "of type string", algorithm);
|
|
2073
|
+
}
|
|
2074
|
+
_Transform.call(this);
|
|
619
2075
|
this._algorithm = algorithm;
|
|
620
|
-
this._key =
|
|
621
|
-
this._iv =
|
|
2076
|
+
this._key = normalizeByteSource2(key, "key");
|
|
2077
|
+
this._iv = normalizeByteSource2(iv, "iv", { allowNull: true });
|
|
2078
|
+
this._options = options || void 0;
|
|
622
2079
|
this._authTag = null;
|
|
623
2080
|
this._finalized = false;
|
|
624
|
-
|
|
2081
|
+
this._sessionCreated = false;
|
|
2082
|
+
this._aad = null;
|
|
2083
|
+
this._aadOptions = void 0;
|
|
2084
|
+
this._autoPadding = void 0;
|
|
2085
|
+
this._chunks = [];
|
|
2086
|
+
this._bufferedMode = !_useSessionCipher || !!options;
|
|
2087
|
+
if (!this._bufferedMode) {
|
|
2088
|
+
this._ensureSession();
|
|
2089
|
+
} else if (!options) {
|
|
2090
|
+
_cryptoDecipheriv.applySync(void 0, [
|
|
2091
|
+
this._algorithm,
|
|
2092
|
+
this._key.toString("base64"),
|
|
2093
|
+
this._iv === null ? null : this._iv.toString("base64"),
|
|
2094
|
+
"",
|
|
2095
|
+
serializeCipherBridgeOptions2({ validateOnly: true })
|
|
2096
|
+
]);
|
|
2097
|
+
}
|
|
2098
|
+
};
|
|
2099
|
+
var SandboxDecipher = SandboxDecipher2;
|
|
2100
|
+
_inherits(SandboxDecipher2, _Transform);
|
|
2101
|
+
SandboxDecipher2.prototype._ensureSession = function _ensureSession() {
|
|
2102
|
+
if (!this._bufferedMode && !this._sessionCreated) {
|
|
2103
|
+
this._sessionCreated = true;
|
|
625
2104
|
this._sessionId = _cryptoCipherivCreate.applySync(void 0, [
|
|
626
2105
|
"decipher",
|
|
627
|
-
|
|
2106
|
+
this._algorithm,
|
|
628
2107
|
this._key.toString("base64"),
|
|
629
|
-
this._iv.toString("base64")
|
|
2108
|
+
this._iv === null ? null : this._iv.toString("base64"),
|
|
2109
|
+
serializeCipherBridgeOptions2(this._getBridgeOptions())
|
|
630
2110
|
]);
|
|
631
|
-
} else {
|
|
632
|
-
this._sessionId = -1;
|
|
633
|
-
this._chunks = [];
|
|
634
2111
|
}
|
|
635
2112
|
};
|
|
636
|
-
|
|
2113
|
+
SandboxDecipher2.prototype._getBridgeOptions = function _getBridgeOptions() {
|
|
2114
|
+
var options = {};
|
|
2115
|
+
if (this._options && this._options.authTagLength !== void 0) {
|
|
2116
|
+
options.authTagLength = this._options.authTagLength;
|
|
2117
|
+
}
|
|
2118
|
+
if (this._authTag) {
|
|
2119
|
+
options.authTag = this._authTag;
|
|
2120
|
+
}
|
|
2121
|
+
if (this._aad) {
|
|
2122
|
+
options.aad = this._aad;
|
|
2123
|
+
}
|
|
2124
|
+
if (this._aadOptions !== void 0) {
|
|
2125
|
+
options.aadOptions = this._aadOptions;
|
|
2126
|
+
}
|
|
2127
|
+
if (this._autoPadding !== void 0) {
|
|
2128
|
+
options.autoPadding = this._autoPadding;
|
|
2129
|
+
}
|
|
2130
|
+
return Object.keys(options).length === 0 ? null : options;
|
|
2131
|
+
};
|
|
637
2132
|
SandboxDecipher2.prototype.update = function update(data, inputEncoding, outputEncoding) {
|
|
2133
|
+
if (this._finalized) {
|
|
2134
|
+
throw new Error("Attempting to call update() after final()");
|
|
2135
|
+
}
|
|
638
2136
|
var buf;
|
|
639
2137
|
if (typeof data === "string") {
|
|
640
2138
|
buf = Buffer.from(data, inputEncoding || "utf8");
|
|
641
2139
|
} else {
|
|
642
|
-
buf =
|
|
2140
|
+
buf = normalizeByteSource2(data, "data");
|
|
2141
|
+
}
|
|
2142
|
+
if (!this._bufferedMode) {
|
|
2143
|
+
this._ensureSession();
|
|
2144
|
+
var resultBase64 = _cryptoCipherivUpdate.applySync(void 0, [this._sessionId, buf.toString("base64")]);
|
|
2145
|
+
var resultBuffer = Buffer.from(resultBase64, "base64");
|
|
2146
|
+
return encodeCryptoResult2(resultBuffer, outputEncoding);
|
|
2147
|
+
}
|
|
2148
|
+
this._chunks.push(buf);
|
|
2149
|
+
return encodeCryptoResult2(Buffer.alloc(0), outputEncoding);
|
|
2150
|
+
};
|
|
2151
|
+
SandboxDecipher2.prototype.final = function final(outputEncoding) {
|
|
2152
|
+
if (this._finalized) throw new Error("Attempting to call final() after already finalized");
|
|
2153
|
+
this._finalized = true;
|
|
2154
|
+
var resultBuffer;
|
|
2155
|
+
if (!this._bufferedMode) {
|
|
2156
|
+
this._ensureSession();
|
|
2157
|
+
var resultJson = _cryptoCipherivFinal.applySync(void 0, [this._sessionId]);
|
|
2158
|
+
var parsed = JSON.parse(resultJson);
|
|
2159
|
+
resultBuffer = Buffer.from(parsed.data, "base64");
|
|
2160
|
+
} else {
|
|
2161
|
+
var combined = Buffer.concat(this._chunks);
|
|
2162
|
+
var options = {};
|
|
2163
|
+
var resultBase64 = _cryptoDecipheriv.applySync(void 0, [
|
|
2164
|
+
this._algorithm,
|
|
2165
|
+
this._key.toString("base64"),
|
|
2166
|
+
this._iv === null ? null : this._iv.toString("base64"),
|
|
2167
|
+
combined.toString("base64"),
|
|
2168
|
+
serializeCipherBridgeOptions2(this._getBridgeOptions())
|
|
2169
|
+
]);
|
|
2170
|
+
resultBuffer = Buffer.from(resultBase64, "base64");
|
|
2171
|
+
}
|
|
2172
|
+
return encodeCryptoResult2(resultBuffer, outputEncoding);
|
|
2173
|
+
};
|
|
2174
|
+
SandboxDecipher2.prototype.setAuthTag = function setAuthTag(tag) {
|
|
2175
|
+
this._bufferedMode = true;
|
|
2176
|
+
this._authTag = typeof tag === "string" ? Buffer.from(tag, "base64") : normalizeByteSource2(tag, "buffer");
|
|
2177
|
+
return this;
|
|
2178
|
+
};
|
|
2179
|
+
SandboxDecipher2.prototype.setAAD = function setAAD(aad, options) {
|
|
2180
|
+
this._bufferedMode = true;
|
|
2181
|
+
this._aad = normalizeByteSource2(aad, "buffer");
|
|
2182
|
+
this._aadOptions = options;
|
|
2183
|
+
return this;
|
|
2184
|
+
};
|
|
2185
|
+
SandboxDecipher2.prototype.setAutoPadding = function setAutoPadding(autoPadding) {
|
|
2186
|
+
this._bufferedMode = true;
|
|
2187
|
+
this._autoPadding = autoPadding !== false;
|
|
2188
|
+
return this;
|
|
2189
|
+
};
|
|
2190
|
+
SandboxDecipher2.prototype._transform = function _transform(chunk, encoding, callback) {
|
|
2191
|
+
try {
|
|
2192
|
+
var output = this.update(chunk, encoding === "buffer" ? void 0 : encoding);
|
|
2193
|
+
if (output.length) {
|
|
2194
|
+
this.push(output);
|
|
2195
|
+
}
|
|
2196
|
+
callback();
|
|
2197
|
+
} catch (error) {
|
|
2198
|
+
callback(normalizeCryptoBridgeError(error));
|
|
2199
|
+
}
|
|
2200
|
+
};
|
|
2201
|
+
SandboxDecipher2.prototype._flush = function _flush(callback) {
|
|
2202
|
+
try {
|
|
2203
|
+
var output = this.final();
|
|
2204
|
+
if (output.length) {
|
|
2205
|
+
this.push(output);
|
|
2206
|
+
}
|
|
2207
|
+
callback();
|
|
2208
|
+
} catch (error) {
|
|
2209
|
+
callback(normalizeCryptoBridgeError(error));
|
|
2210
|
+
}
|
|
2211
|
+
};
|
|
2212
|
+
result.createDecipheriv = function createDecipheriv(algorithm, key, iv, options) {
|
|
2213
|
+
return new SandboxDecipher2(algorithm, key, iv, options);
|
|
2214
|
+
};
|
|
2215
|
+
result.Decipheriv = SandboxDecipher2;
|
|
2216
|
+
}
|
|
2217
|
+
if (typeof _cryptoSign !== "undefined") {
|
|
2218
|
+
result.sign = function sign(algorithm, data, key) {
|
|
2219
|
+
var dataBuf = typeof data === "string" ? Buffer.from(data, "utf8") : Buffer.from(data);
|
|
2220
|
+
var sigBase64;
|
|
2221
|
+
try {
|
|
2222
|
+
sigBase64 = _cryptoSign.applySync(void 0, [
|
|
2223
|
+
algorithm === void 0 ? null : algorithm,
|
|
2224
|
+
dataBuf.toString("base64"),
|
|
2225
|
+
JSON.stringify(serializeBridgeValue(key))
|
|
2226
|
+
]);
|
|
2227
|
+
} catch (error) {
|
|
2228
|
+
throw normalizeCryptoBridgeError(error);
|
|
2229
|
+
}
|
|
2230
|
+
return Buffer.from(sigBase64, "base64");
|
|
2231
|
+
};
|
|
2232
|
+
}
|
|
2233
|
+
if (typeof _cryptoVerify !== "undefined") {
|
|
2234
|
+
result.verify = function verify(algorithm, data, key, signature) {
|
|
2235
|
+
var dataBuf = typeof data === "string" ? Buffer.from(data, "utf8") : Buffer.from(data);
|
|
2236
|
+
var sigBuf = typeof signature === "string" ? Buffer.from(signature, "base64") : Buffer.from(signature);
|
|
2237
|
+
try {
|
|
2238
|
+
return _cryptoVerify.applySync(void 0, [
|
|
2239
|
+
algorithm === void 0 ? null : algorithm,
|
|
2240
|
+
dataBuf.toString("base64"),
|
|
2241
|
+
JSON.stringify(serializeBridgeValue(key)),
|
|
2242
|
+
sigBuf.toString("base64")
|
|
2243
|
+
]);
|
|
2244
|
+
} catch (error) {
|
|
2245
|
+
throw normalizeCryptoBridgeError(error);
|
|
2246
|
+
}
|
|
2247
|
+
};
|
|
2248
|
+
}
|
|
2249
|
+
if (typeof _cryptoAsymmetricOp !== "undefined") {
|
|
2250
|
+
let asymmetricBridgeCall2 = function(operation, key, data) {
|
|
2251
|
+
var dataBuf = toRawBuffer(data);
|
|
2252
|
+
var resultBase64;
|
|
2253
|
+
try {
|
|
2254
|
+
resultBase64 = _cryptoAsymmetricOp.applySync(void 0, [
|
|
2255
|
+
operation,
|
|
2256
|
+
JSON.stringify(serializeBridgeValue(key)),
|
|
2257
|
+
dataBuf.toString("base64")
|
|
2258
|
+
]);
|
|
2259
|
+
} catch (error) {
|
|
2260
|
+
throw normalizeCryptoBridgeError(error);
|
|
2261
|
+
}
|
|
2262
|
+
return Buffer.from(resultBase64, "base64");
|
|
2263
|
+
};
|
|
2264
|
+
var asymmetricBridgeCall = asymmetricBridgeCall2;
|
|
2265
|
+
result.publicEncrypt = function publicEncrypt(key, data) {
|
|
2266
|
+
return asymmetricBridgeCall2("publicEncrypt", key, data);
|
|
2267
|
+
};
|
|
2268
|
+
result.privateDecrypt = function privateDecrypt(key, data) {
|
|
2269
|
+
return asymmetricBridgeCall2("privateDecrypt", key, data);
|
|
2270
|
+
};
|
|
2271
|
+
result.privateEncrypt = function privateEncrypt(key, data) {
|
|
2272
|
+
return asymmetricBridgeCall2("privateEncrypt", key, data);
|
|
2273
|
+
};
|
|
2274
|
+
result.publicDecrypt = function publicDecrypt(key, data) {
|
|
2275
|
+
return asymmetricBridgeCall2("publicDecrypt", key, data);
|
|
2276
|
+
};
|
|
2277
|
+
}
|
|
2278
|
+
if (typeof _cryptoDiffieHellmanSessionCreate !== "undefined" && typeof _cryptoDiffieHellmanSessionCall !== "undefined") {
|
|
2279
|
+
let serializeDhKeyObject2 = function(value) {
|
|
2280
|
+
if (value.type === "secret") {
|
|
2281
|
+
return {
|
|
2282
|
+
type: "secret",
|
|
2283
|
+
raw: Buffer.from(value.export()).toString("base64")
|
|
2284
|
+
};
|
|
2285
|
+
}
|
|
2286
|
+
return {
|
|
2287
|
+
type: value.type,
|
|
2288
|
+
pem: value._pem || value.export({
|
|
2289
|
+
type: value.type === "private" ? "pkcs8" : "spki",
|
|
2290
|
+
format: "pem"
|
|
2291
|
+
})
|
|
2292
|
+
};
|
|
2293
|
+
}, serializeDhValue2 = function(value) {
|
|
2294
|
+
if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
2295
|
+
return value;
|
|
2296
|
+
}
|
|
2297
|
+
if (Buffer.isBuffer(value)) {
|
|
2298
|
+
return {
|
|
2299
|
+
__type: "buffer",
|
|
2300
|
+
value: Buffer.from(value).toString("base64")
|
|
2301
|
+
};
|
|
2302
|
+
}
|
|
2303
|
+
if (value instanceof ArrayBuffer) {
|
|
2304
|
+
return {
|
|
2305
|
+
__type: "buffer",
|
|
2306
|
+
value: Buffer.from(new Uint8Array(value)).toString("base64")
|
|
2307
|
+
};
|
|
2308
|
+
}
|
|
2309
|
+
if (ArrayBuffer.isView(value)) {
|
|
2310
|
+
return {
|
|
2311
|
+
__type: "buffer",
|
|
2312
|
+
value: Buffer.from(value.buffer, value.byteOffset, value.byteLength).toString("base64")
|
|
2313
|
+
};
|
|
2314
|
+
}
|
|
2315
|
+
if (typeof value === "bigint") {
|
|
2316
|
+
return {
|
|
2317
|
+
__type: "bigint",
|
|
2318
|
+
value: value.toString()
|
|
2319
|
+
};
|
|
2320
|
+
}
|
|
2321
|
+
if (value && typeof value === "object" && (value.type === "public" || value.type === "private" || value.type === "secret") && typeof value.export === "function") {
|
|
2322
|
+
return {
|
|
2323
|
+
__type: "keyObject",
|
|
2324
|
+
value: serializeDhKeyObject2(value)
|
|
2325
|
+
};
|
|
2326
|
+
}
|
|
2327
|
+
if (Array.isArray(value)) {
|
|
2328
|
+
return value.map(serializeDhValue2);
|
|
2329
|
+
}
|
|
2330
|
+
if (value && typeof value === "object") {
|
|
2331
|
+
var output = {};
|
|
2332
|
+
var keys = Object.keys(value);
|
|
2333
|
+
for (var i = 0; i < keys.length; i++) {
|
|
2334
|
+
if (value[keys[i]] !== void 0) {
|
|
2335
|
+
output[keys[i]] = serializeDhValue2(value[keys[i]]);
|
|
2336
|
+
}
|
|
2337
|
+
}
|
|
2338
|
+
return output;
|
|
2339
|
+
}
|
|
2340
|
+
return String(value);
|
|
2341
|
+
}, restoreDhValue2 = function(value) {
|
|
2342
|
+
if (!value || typeof value !== "object") {
|
|
2343
|
+
return value;
|
|
2344
|
+
}
|
|
2345
|
+
if (value.__type === "buffer") {
|
|
2346
|
+
return Buffer.from(value.value, "base64");
|
|
2347
|
+
}
|
|
2348
|
+
if (value.__type === "bigint") {
|
|
2349
|
+
return BigInt(value.value);
|
|
2350
|
+
}
|
|
2351
|
+
if (Array.isArray(value)) {
|
|
2352
|
+
return value.map(restoreDhValue2);
|
|
2353
|
+
}
|
|
2354
|
+
var output = {};
|
|
2355
|
+
var keys = Object.keys(value);
|
|
2356
|
+
for (var i = 0; i < keys.length; i++) {
|
|
2357
|
+
output[keys[i]] = restoreDhValue2(value[keys[i]]);
|
|
2358
|
+
}
|
|
2359
|
+
return output;
|
|
2360
|
+
}, createDhSession2 = function(type, name2, argsLike) {
|
|
2361
|
+
var args = [];
|
|
2362
|
+
for (var i = 0; i < argsLike.length; i++) {
|
|
2363
|
+
args.push(serializeDhValue2(argsLike[i]));
|
|
2364
|
+
}
|
|
2365
|
+
return _cryptoDiffieHellmanSessionCreate.applySync(void 0, [
|
|
2366
|
+
JSON.stringify({
|
|
2367
|
+
type,
|
|
2368
|
+
name: name2,
|
|
2369
|
+
args
|
|
2370
|
+
})
|
|
2371
|
+
]);
|
|
2372
|
+
}, callDhSession2 = function(sessionId, method, argsLike) {
|
|
2373
|
+
var args = [];
|
|
2374
|
+
for (var i = 0; i < argsLike.length; i++) {
|
|
2375
|
+
args.push(serializeDhValue2(argsLike[i]));
|
|
2376
|
+
}
|
|
2377
|
+
var response = JSON.parse(_cryptoDiffieHellmanSessionCall.applySync(void 0, [
|
|
2378
|
+
sessionId,
|
|
2379
|
+
JSON.stringify({
|
|
2380
|
+
method,
|
|
2381
|
+
args
|
|
2382
|
+
})
|
|
2383
|
+
]));
|
|
2384
|
+
if (response && response.hasResult === false) {
|
|
2385
|
+
return void 0;
|
|
2386
|
+
}
|
|
2387
|
+
return restoreDhValue2(response && response.result);
|
|
2388
|
+
}, SandboxDiffieHellman2 = function(sessionId) {
|
|
2389
|
+
this._sessionId = sessionId;
|
|
2390
|
+
}, SandboxECDH2 = function(sessionId) {
|
|
2391
|
+
SandboxDiffieHellman2.call(this, sessionId);
|
|
2392
|
+
};
|
|
2393
|
+
var serializeDhKeyObject = serializeDhKeyObject2, serializeDhValue = serializeDhValue2, restoreDhValue = restoreDhValue2, createDhSession = createDhSession2, callDhSession = callDhSession2, SandboxDiffieHellman = SandboxDiffieHellman2, SandboxECDH = SandboxECDH2;
|
|
2394
|
+
Object.defineProperty(SandboxDiffieHellman2.prototype, "verifyError", {
|
|
2395
|
+
get: function getVerifyError() {
|
|
2396
|
+
return callDhSession2(this._sessionId, "verifyError", []);
|
|
2397
|
+
}
|
|
2398
|
+
});
|
|
2399
|
+
SandboxDiffieHellman2.prototype.generateKeys = function generateKeys(encoding) {
|
|
2400
|
+
if (arguments.length === 0) return callDhSession2(this._sessionId, "generateKeys", []);
|
|
2401
|
+
return callDhSession2(this._sessionId, "generateKeys", [encoding]);
|
|
2402
|
+
};
|
|
2403
|
+
SandboxDiffieHellman2.prototype.computeSecret = function computeSecret(key, inputEncoding, outputEncoding) {
|
|
2404
|
+
return callDhSession2(this._sessionId, "computeSecret", Array.prototype.slice.call(arguments));
|
|
2405
|
+
};
|
|
2406
|
+
SandboxDiffieHellman2.prototype.getPrime = function getPrime(encoding) {
|
|
2407
|
+
if (arguments.length === 0) return callDhSession2(this._sessionId, "getPrime", []);
|
|
2408
|
+
return callDhSession2(this._sessionId, "getPrime", [encoding]);
|
|
2409
|
+
};
|
|
2410
|
+
SandboxDiffieHellman2.prototype.getGenerator = function getGenerator(encoding) {
|
|
2411
|
+
if (arguments.length === 0) return callDhSession2(this._sessionId, "getGenerator", []);
|
|
2412
|
+
return callDhSession2(this._sessionId, "getGenerator", [encoding]);
|
|
2413
|
+
};
|
|
2414
|
+
SandboxDiffieHellman2.prototype.getPublicKey = function getPublicKey(encoding) {
|
|
2415
|
+
if (arguments.length === 0) return callDhSession2(this._sessionId, "getPublicKey", []);
|
|
2416
|
+
return callDhSession2(this._sessionId, "getPublicKey", [encoding]);
|
|
2417
|
+
};
|
|
2418
|
+
SandboxDiffieHellman2.prototype.getPrivateKey = function getPrivateKey(encoding) {
|
|
2419
|
+
if (arguments.length === 0) return callDhSession2(this._sessionId, "getPrivateKey", []);
|
|
2420
|
+
return callDhSession2(this._sessionId, "getPrivateKey", [encoding]);
|
|
2421
|
+
};
|
|
2422
|
+
SandboxDiffieHellman2.prototype.setPublicKey = function setPublicKey(key, encoding) {
|
|
2423
|
+
return callDhSession2(this._sessionId, "setPublicKey", Array.prototype.slice.call(arguments));
|
|
2424
|
+
};
|
|
2425
|
+
SandboxDiffieHellman2.prototype.setPrivateKey = function setPrivateKey(key, encoding) {
|
|
2426
|
+
return callDhSession2(this._sessionId, "setPrivateKey", Array.prototype.slice.call(arguments));
|
|
2427
|
+
};
|
|
2428
|
+
SandboxECDH2.prototype = Object.create(SandboxDiffieHellman2.prototype);
|
|
2429
|
+
SandboxECDH2.prototype.constructor = SandboxECDH2;
|
|
2430
|
+
SandboxECDH2.prototype.getPublicKey = function getPublicKey(encoding, format) {
|
|
2431
|
+
return callDhSession2(this._sessionId, "getPublicKey", Array.prototype.slice.call(arguments));
|
|
2432
|
+
};
|
|
2433
|
+
result.createDiffieHellman = function createDiffieHellman() {
|
|
2434
|
+
return new SandboxDiffieHellman2(createDhSession2("dh", void 0, arguments));
|
|
2435
|
+
};
|
|
2436
|
+
result.getDiffieHellman = function getDiffieHellman(name2) {
|
|
2437
|
+
return new SandboxDiffieHellman2(createDhSession2("group", name2, []));
|
|
2438
|
+
};
|
|
2439
|
+
result.createDiffieHellmanGroup = result.getDiffieHellman;
|
|
2440
|
+
result.createECDH = function createECDH(curve) {
|
|
2441
|
+
return new SandboxECDH2(createDhSession2("ecdh", curve, []));
|
|
2442
|
+
};
|
|
2443
|
+
if (typeof _cryptoDiffieHellman !== "undefined") {
|
|
2444
|
+
result.diffieHellman = function diffieHellman(options) {
|
|
2445
|
+
var resultJson = _cryptoDiffieHellman.applySync(void 0, [
|
|
2446
|
+
JSON.stringify(serializeDhValue2(options))
|
|
2447
|
+
]);
|
|
2448
|
+
return restoreDhValue2(JSON.parse(resultJson));
|
|
2449
|
+
};
|
|
2450
|
+
}
|
|
2451
|
+
result.DiffieHellman = SandboxDiffieHellman2;
|
|
2452
|
+
result.DiffieHellmanGroup = SandboxDiffieHellman2;
|
|
2453
|
+
result.ECDH = SandboxECDH2;
|
|
2454
|
+
}
|
|
2455
|
+
if (typeof _cryptoGenerateKeyPairSync !== "undefined") {
|
|
2456
|
+
let restoreBridgeValue2 = function(value) {
|
|
2457
|
+
if (!value || typeof value !== "object") {
|
|
2458
|
+
return value;
|
|
2459
|
+
}
|
|
2460
|
+
if (value.__type === "buffer") {
|
|
2461
|
+
return Buffer.from(value.value, "base64");
|
|
2462
|
+
}
|
|
2463
|
+
if (value.__type === "bigint") {
|
|
2464
|
+
return BigInt(value.value);
|
|
2465
|
+
}
|
|
2466
|
+
if (Array.isArray(value)) {
|
|
2467
|
+
return value.map(restoreBridgeValue2);
|
|
2468
|
+
}
|
|
2469
|
+
var output = {};
|
|
2470
|
+
var keys = Object.keys(value);
|
|
2471
|
+
for (var i = 0; i < keys.length; i++) {
|
|
2472
|
+
output[keys[i]] = restoreBridgeValue2(value[keys[i]]);
|
|
2473
|
+
}
|
|
2474
|
+
return output;
|
|
2475
|
+
}, cloneObject2 = function(value) {
|
|
2476
|
+
if (!value || typeof value !== "object") {
|
|
2477
|
+
return value;
|
|
2478
|
+
}
|
|
2479
|
+
if (Array.isArray(value)) {
|
|
2480
|
+
return value.map(cloneObject2);
|
|
2481
|
+
}
|
|
2482
|
+
var output = {};
|
|
2483
|
+
var keys = Object.keys(value);
|
|
2484
|
+
for (var i = 0; i < keys.length; i++) {
|
|
2485
|
+
output[keys[i]] = cloneObject2(value[keys[i]]);
|
|
2486
|
+
}
|
|
2487
|
+
return output;
|
|
2488
|
+
}, createDomException2 = function(message, name2) {
|
|
2489
|
+
if (typeof DOMException === "function") {
|
|
2490
|
+
return new DOMException(message, name2);
|
|
2491
|
+
}
|
|
2492
|
+
var error = new Error(message);
|
|
2493
|
+
error.name = name2;
|
|
2494
|
+
return error;
|
|
2495
|
+
}, toRawBuffer2 = function(data, encoding) {
|
|
2496
|
+
if (Buffer.isBuffer(data)) {
|
|
2497
|
+
return Buffer.from(data);
|
|
2498
|
+
}
|
|
2499
|
+
if (data instanceof ArrayBuffer) {
|
|
2500
|
+
return Buffer.from(new Uint8Array(data));
|
|
2501
|
+
}
|
|
2502
|
+
if (ArrayBuffer.isView(data)) {
|
|
2503
|
+
return Buffer.from(data.buffer, data.byteOffset, data.byteLength);
|
|
2504
|
+
}
|
|
2505
|
+
if (typeof data === "string") {
|
|
2506
|
+
return Buffer.from(data, encoding || "utf8");
|
|
2507
|
+
}
|
|
2508
|
+
return Buffer.from(data);
|
|
2509
|
+
}, serializeBridgeValue2 = function(value) {
|
|
2510
|
+
if (value === null) {
|
|
2511
|
+
return null;
|
|
2512
|
+
}
|
|
2513
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
2514
|
+
return value;
|
|
2515
|
+
}
|
|
2516
|
+
if (typeof value === "bigint") {
|
|
2517
|
+
return {
|
|
2518
|
+
__type: "bigint",
|
|
2519
|
+
value: value.toString()
|
|
2520
|
+
};
|
|
2521
|
+
}
|
|
2522
|
+
if (Buffer.isBuffer(value)) {
|
|
2523
|
+
return {
|
|
2524
|
+
__type: "buffer",
|
|
2525
|
+
value: Buffer.from(value).toString("base64")
|
|
2526
|
+
};
|
|
2527
|
+
}
|
|
2528
|
+
if (value instanceof ArrayBuffer) {
|
|
2529
|
+
return {
|
|
2530
|
+
__type: "buffer",
|
|
2531
|
+
value: Buffer.from(new Uint8Array(value)).toString("base64")
|
|
2532
|
+
};
|
|
2533
|
+
}
|
|
2534
|
+
if (ArrayBuffer.isView(value)) {
|
|
2535
|
+
return {
|
|
2536
|
+
__type: "buffer",
|
|
2537
|
+
value: Buffer.from(value.buffer, value.byteOffset, value.byteLength).toString("base64")
|
|
2538
|
+
};
|
|
2539
|
+
}
|
|
2540
|
+
if (Array.isArray(value)) {
|
|
2541
|
+
return value.map(serializeBridgeValue2);
|
|
2542
|
+
}
|
|
2543
|
+
if (value && typeof value === "object" && (value.type === "public" || value.type === "private" || value.type === "secret") && typeof value.export === "function") {
|
|
2544
|
+
if (value.type === "secret") {
|
|
2545
|
+
return {
|
|
2546
|
+
__type: "keyObject",
|
|
2547
|
+
value: {
|
|
2548
|
+
type: "secret",
|
|
2549
|
+
raw: Buffer.from(value.export()).toString("base64")
|
|
2550
|
+
}
|
|
2551
|
+
};
|
|
2552
|
+
}
|
|
2553
|
+
return {
|
|
2554
|
+
__type: "keyObject",
|
|
2555
|
+
value: {
|
|
2556
|
+
type: value.type,
|
|
2557
|
+
pem: value._pem
|
|
2558
|
+
}
|
|
2559
|
+
};
|
|
2560
|
+
}
|
|
2561
|
+
if (value && typeof value === "object") {
|
|
2562
|
+
var output = {};
|
|
2563
|
+
var keys = Object.keys(value);
|
|
2564
|
+
for (var i = 0; i < keys.length; i++) {
|
|
2565
|
+
var entry = value[keys[i]];
|
|
2566
|
+
if (entry !== void 0) {
|
|
2567
|
+
output[keys[i]] = serializeBridgeValue2(entry);
|
|
2568
|
+
}
|
|
2569
|
+
}
|
|
2570
|
+
return output;
|
|
2571
|
+
}
|
|
2572
|
+
return String(value);
|
|
2573
|
+
}, normalizeCryptoBridgeError2 = function(error) {
|
|
2574
|
+
if (!error || typeof error !== "object") {
|
|
2575
|
+
return error;
|
|
2576
|
+
}
|
|
2577
|
+
if (error.code === void 0 && error.message === "error:07880109:common libcrypto routines::interrupted or cancelled") {
|
|
2578
|
+
error.code = "ERR_OSSL_CRYPTO_INTERRUPTED_OR_CANCELLED";
|
|
2579
|
+
}
|
|
2580
|
+
return error;
|
|
2581
|
+
}, deserializeGeneratedKeyValue2 = function(value) {
|
|
2582
|
+
if (!value || typeof value !== "object") {
|
|
2583
|
+
return value;
|
|
2584
|
+
}
|
|
2585
|
+
if (value.kind === "string") {
|
|
2586
|
+
return value.value;
|
|
2587
|
+
}
|
|
2588
|
+
if (value.kind === "buffer") {
|
|
2589
|
+
return Buffer.from(value.value, "base64");
|
|
2590
|
+
}
|
|
2591
|
+
if (value.kind === "keyObject") {
|
|
2592
|
+
return createGeneratedKeyObject2(value.value);
|
|
2593
|
+
}
|
|
2594
|
+
if (value.kind === "object") {
|
|
2595
|
+
return value.value;
|
|
2596
|
+
}
|
|
2597
|
+
return value;
|
|
2598
|
+
}, serializeBridgeOptions2 = function(options) {
|
|
2599
|
+
return JSON.stringify({
|
|
2600
|
+
hasOptions: options !== void 0,
|
|
2601
|
+
options: options === void 0 ? null : serializeBridgeValue2(options)
|
|
2602
|
+
});
|
|
2603
|
+
}, createInvalidArgTypeError2 = function(name2, expected, value) {
|
|
2604
|
+
var received;
|
|
2605
|
+
if (value == null) {
|
|
2606
|
+
received = " Received " + value;
|
|
2607
|
+
} else if (typeof value === "function") {
|
|
2608
|
+
received = " Received function " + (value.name || "anonymous");
|
|
2609
|
+
} else if (typeof value === "object") {
|
|
2610
|
+
if (value.constructor && value.constructor.name) {
|
|
2611
|
+
received = " Received an instance of " + value.constructor.name;
|
|
2612
|
+
} else {
|
|
2613
|
+
received = " Received [object Object]";
|
|
2614
|
+
}
|
|
2615
|
+
} else {
|
|
2616
|
+
var inspected = typeof value === "string" ? "'" + value + "'" : String(value);
|
|
2617
|
+
if (inspected.length > 28) {
|
|
2618
|
+
inspected = inspected.slice(0, 25) + "...";
|
|
2619
|
+
}
|
|
2620
|
+
received = " Received type " + typeof value + " (" + inspected + ")";
|
|
2621
|
+
}
|
|
2622
|
+
var error = new TypeError('The "' + name2 + '" argument must be ' + expected + "." + received);
|
|
2623
|
+
error.code = "ERR_INVALID_ARG_TYPE";
|
|
2624
|
+
return error;
|
|
2625
|
+
}, scheduleCryptoCallback2 = function(callback, args) {
|
|
2626
|
+
setTimeout(function() {
|
|
2627
|
+
callback.apply(void 0, args);
|
|
2628
|
+
}, 0);
|
|
2629
|
+
}, shouldThrowCryptoValidationError2 = function(error) {
|
|
2630
|
+
if (!error || typeof error !== "object") {
|
|
2631
|
+
return false;
|
|
2632
|
+
}
|
|
2633
|
+
if (error.name === "TypeError" || error.name === "RangeError") {
|
|
2634
|
+
return true;
|
|
2635
|
+
}
|
|
2636
|
+
var code = error.code;
|
|
2637
|
+
return code === "ERR_MISSING_OPTION" || code === "ERR_CRYPTO_UNKNOWN_DH_GROUP" || code === "ERR_OUT_OF_RANGE" || typeof code === "string" && code.indexOf("ERR_INVALID_ARG_") === 0;
|
|
2638
|
+
}, ensureCryptoCallback2 = function(callback, syncValidator) {
|
|
2639
|
+
if (typeof callback === "function") {
|
|
2640
|
+
return callback;
|
|
2641
|
+
}
|
|
2642
|
+
if (typeof syncValidator === "function") {
|
|
2643
|
+
syncValidator();
|
|
2644
|
+
}
|
|
2645
|
+
throw createInvalidArgTypeError2("callback", "of type function", callback);
|
|
2646
|
+
}, SandboxKeyObject2 = function(type, handle) {
|
|
2647
|
+
this.type = type;
|
|
2648
|
+
this._pem = handle && handle.pem !== void 0 ? handle.pem : void 0;
|
|
2649
|
+
this._raw = handle && handle.raw !== void 0 ? handle.raw : void 0;
|
|
2650
|
+
this._jwk = handle && handle.jwk !== void 0 ? cloneObject2(handle.jwk) : void 0;
|
|
2651
|
+
this.asymmetricKeyType = handle && handle.asymmetricKeyType !== void 0 ? handle.asymmetricKeyType : void 0;
|
|
2652
|
+
this.asymmetricKeyDetails = handle && handle.asymmetricKeyDetails !== void 0 ? restoreBridgeValue2(handle.asymmetricKeyDetails) : void 0;
|
|
2653
|
+
this.symmetricKeySize = type === "secret" && handle && handle.raw !== void 0 ? Buffer.from(handle.raw, "base64").byteLength : void 0;
|
|
2654
|
+
}, normalizeNamedCurve2 = function(namedCurve) {
|
|
2655
|
+
if (!namedCurve) {
|
|
2656
|
+
return namedCurve;
|
|
2657
|
+
}
|
|
2658
|
+
var upper = String(namedCurve).toUpperCase();
|
|
2659
|
+
if (upper === "PRIME256V1" || upper === "SECP256R1") return "P-256";
|
|
2660
|
+
if (upper === "SECP384R1") return "P-384";
|
|
2661
|
+
if (upper === "SECP521R1") return "P-521";
|
|
2662
|
+
return namedCurve;
|
|
2663
|
+
}, normalizeAlgorithmInput2 = function(algorithm) {
|
|
2664
|
+
if (typeof algorithm === "string") {
|
|
2665
|
+
return { name: algorithm };
|
|
2666
|
+
}
|
|
2667
|
+
return Object.assign({}, algorithm);
|
|
2668
|
+
}, createCompatibleCryptoKey2 = function(keyData) {
|
|
2669
|
+
var key;
|
|
2670
|
+
if (globalThis.CryptoKey && globalThis.CryptoKey.prototype && globalThis.CryptoKey.prototype !== SandboxCryptoKey.prototype) {
|
|
2671
|
+
key = Object.create(globalThis.CryptoKey.prototype);
|
|
2672
|
+
key.type = keyData.type;
|
|
2673
|
+
key.extractable = keyData.extractable;
|
|
2674
|
+
key.algorithm = keyData.algorithm;
|
|
2675
|
+
key.usages = keyData.usages;
|
|
2676
|
+
key._keyData = keyData;
|
|
2677
|
+
key._pem = keyData._pem;
|
|
2678
|
+
key._jwk = keyData._jwk;
|
|
2679
|
+
key._raw = keyData._raw;
|
|
2680
|
+
key._sourceKeyObjectData = keyData._sourceKeyObjectData;
|
|
2681
|
+
return key;
|
|
2682
|
+
}
|
|
2683
|
+
return new SandboxCryptoKey(keyData);
|
|
2684
|
+
}, buildCryptoKeyFromKeyObject2 = function(keyObject, algorithm, extractable, usages) {
|
|
2685
|
+
var algo = normalizeAlgorithmInput2(algorithm);
|
|
2686
|
+
var name2 = algo.name;
|
|
2687
|
+
if (keyObject.type === "secret") {
|
|
2688
|
+
var secretBytes = Buffer.from(keyObject._raw || "", "base64");
|
|
2689
|
+
if (name2 === "PBKDF2") {
|
|
2690
|
+
if (extractable) {
|
|
2691
|
+
throw new SyntaxError("PBKDF2 keys are not extractable");
|
|
2692
|
+
}
|
|
2693
|
+
if (usages.some(function(usage) {
|
|
2694
|
+
return usage !== "deriveBits" && usage !== "deriveKey";
|
|
2695
|
+
})) {
|
|
2696
|
+
throw new SyntaxError("Unsupported key usage for a PBKDF2 key");
|
|
2697
|
+
}
|
|
2698
|
+
return createCompatibleCryptoKey2({
|
|
2699
|
+
type: "secret",
|
|
2700
|
+
extractable,
|
|
2701
|
+
algorithm: { name: name2 },
|
|
2702
|
+
usages: Array.from(usages),
|
|
2703
|
+
_raw: keyObject._raw,
|
|
2704
|
+
_sourceKeyObjectData: {
|
|
2705
|
+
type: "secret",
|
|
2706
|
+
raw: keyObject._raw
|
|
2707
|
+
}
|
|
2708
|
+
});
|
|
2709
|
+
}
|
|
2710
|
+
if (name2 === "HMAC") {
|
|
2711
|
+
if (!secretBytes.byteLength || algo.length === 0) {
|
|
2712
|
+
throw createDomException2("Zero-length key is not supported", "DataError");
|
|
2713
|
+
}
|
|
2714
|
+
if (!usages.length) {
|
|
2715
|
+
throw new SyntaxError("Usages cannot be empty when importing a secret key.");
|
|
2716
|
+
}
|
|
2717
|
+
return createCompatibleCryptoKey2({
|
|
2718
|
+
type: "secret",
|
|
2719
|
+
extractable,
|
|
2720
|
+
algorithm: {
|
|
2721
|
+
name: name2,
|
|
2722
|
+
hash: typeof algo.hash === "string" ? { name: algo.hash } : cloneObject2(algo.hash),
|
|
2723
|
+
length: secretBytes.byteLength * 8
|
|
2724
|
+
},
|
|
2725
|
+
usages: Array.from(usages),
|
|
2726
|
+
_raw: keyObject._raw,
|
|
2727
|
+
_sourceKeyObjectData: {
|
|
2728
|
+
type: "secret",
|
|
2729
|
+
raw: keyObject._raw
|
|
2730
|
+
}
|
|
2731
|
+
});
|
|
2732
|
+
}
|
|
2733
|
+
return createCompatibleCryptoKey2({
|
|
2734
|
+
type: "secret",
|
|
2735
|
+
extractable,
|
|
2736
|
+
algorithm: {
|
|
2737
|
+
name: name2,
|
|
2738
|
+
length: secretBytes.byteLength * 8
|
|
2739
|
+
},
|
|
2740
|
+
usages: Array.from(usages),
|
|
2741
|
+
_raw: keyObject._raw,
|
|
2742
|
+
_sourceKeyObjectData: {
|
|
2743
|
+
type: "secret",
|
|
2744
|
+
raw: keyObject._raw
|
|
2745
|
+
}
|
|
2746
|
+
});
|
|
643
2747
|
}
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
return resultBuffer;
|
|
2748
|
+
var keyType = String(keyObject.asymmetricKeyType || "").toLowerCase();
|
|
2749
|
+
var algorithmName = String(name2 || "");
|
|
2750
|
+
if ((keyType === "ed25519" || keyType === "ed448" || keyType === "x25519" || keyType === "x448") && keyType !== algorithmName.toLowerCase()) {
|
|
2751
|
+
throw createDomException2("Invalid key type", "DataError");
|
|
649
2752
|
}
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
_cryptoCipherivUpdate.applySync(void 0, [this._sessionId, "", JSON.stringify({ setAuthTag: this._authTag.toString("base64") })]);
|
|
2753
|
+
if (algorithmName === "ECDH") {
|
|
2754
|
+
if (keyObject.type === "private" && !usages.length) {
|
|
2755
|
+
throw new SyntaxError("Usages cannot be empty when importing a private key.");
|
|
2756
|
+
}
|
|
2757
|
+
var actualCurve = normalizeNamedCurve2(
|
|
2758
|
+
keyObject.asymmetricKeyDetails && keyObject.asymmetricKeyDetails.namedCurve
|
|
2759
|
+
);
|
|
2760
|
+
if (algo.namedCurve && actualCurve && normalizeNamedCurve2(algo.namedCurve) !== actualCurve) {
|
|
2761
|
+
throw createDomException2("Named curve mismatch", "DataError");
|
|
660
2762
|
}
|
|
661
|
-
var resultJson = _cryptoCipherivFinal.applySync(void 0, [this._sessionId]);
|
|
662
|
-
var parsed = JSON.parse(resultJson);
|
|
663
|
-
var resultBuffer = Buffer.from(parsed.data, "base64");
|
|
664
|
-
if (outputEncoding && outputEncoding !== "buffer") return resultBuffer.toString(outputEncoding);
|
|
665
|
-
return resultBuffer;
|
|
666
|
-
}
|
|
667
|
-
var combined = Buffer.concat(this._chunks);
|
|
668
|
-
var options = {};
|
|
669
|
-
if (this._authTag) options.authTag = this._authTag.toString("base64");
|
|
670
|
-
var resultBase64 = _cryptoDecipheriv.applySync(void 0, [
|
|
671
|
-
this._algorithm,
|
|
672
|
-
this._key.toString("base64"),
|
|
673
|
-
this._iv.toString("base64"),
|
|
674
|
-
combined.toString("base64"),
|
|
675
|
-
JSON.stringify(options)
|
|
676
|
-
]);
|
|
677
|
-
var resultBuffer2 = Buffer.from(resultBase64, "base64");
|
|
678
|
-
if (outputEncoding && outputEncoding !== "buffer") return resultBuffer2.toString(outputEncoding);
|
|
679
|
-
return resultBuffer2;
|
|
680
|
-
};
|
|
681
|
-
SandboxDecipher2.prototype.setAuthTag = function setAuthTag(tag) {
|
|
682
|
-
this._authTag = typeof tag === "string" ? Buffer.from(tag, "base64") : Buffer.from(tag);
|
|
683
|
-
return this;
|
|
684
|
-
};
|
|
685
|
-
SandboxDecipher2.prototype.setAAD = function setAAD(data) {
|
|
686
|
-
if (this._sessionId >= 0) {
|
|
687
|
-
var buf = typeof data === "string" ? Buffer.from(data, "utf8") : Buffer.from(data);
|
|
688
|
-
_cryptoCipherivUpdate.applySync(void 0, [this._sessionId, "", JSON.stringify({ setAAD: buf.toString("base64") })]);
|
|
689
2763
|
}
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
if (this._sessionId >= 0) {
|
|
694
|
-
_cryptoCipherivUpdate.applySync(void 0, [this._sessionId, "", JSON.stringify({ setAutoPadding: autoPadding !== false })]);
|
|
2764
|
+
var normalizedAlgo = cloneObject2(algo);
|
|
2765
|
+
if (typeof normalizedAlgo.hash === "string") {
|
|
2766
|
+
normalizedAlgo.hash = { name: normalizedAlgo.hash };
|
|
695
2767
|
}
|
|
696
|
-
return
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
2768
|
+
return createCompatibleCryptoKey2({
|
|
2769
|
+
type: keyObject.type,
|
|
2770
|
+
extractable,
|
|
2771
|
+
algorithm: normalizedAlgo,
|
|
2772
|
+
usages: Array.from(usages),
|
|
2773
|
+
_pem: keyObject._pem,
|
|
2774
|
+
_jwk: cloneObject2(keyObject._jwk),
|
|
2775
|
+
_sourceKeyObjectData: {
|
|
2776
|
+
type: keyObject.type,
|
|
2777
|
+
pem: keyObject._pem,
|
|
2778
|
+
jwk: cloneObject2(keyObject._jwk),
|
|
2779
|
+
asymmetricKeyType: keyObject.asymmetricKeyType,
|
|
2780
|
+
asymmetricKeyDetails: cloneObject2(keyObject.asymmetricKeyDetails)
|
|
2781
|
+
}
|
|
2782
|
+
});
|
|
2783
|
+
}, createAsymmetricKeyObject2 = function(type, key) {
|
|
707
2784
|
if (typeof key === "string") {
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
keyPem = key.toString("utf8");
|
|
713
|
-
} else {
|
|
714
|
-
keyPem = String(key);
|
|
2785
|
+
if (key.indexOf("-----BEGIN") === -1) {
|
|
2786
|
+
throw new TypeError("error:0900006e:PEM routines:OPENSSL_internal:NO_START_LINE");
|
|
2787
|
+
}
|
|
2788
|
+
return new SandboxKeyObject2(type, { pem: key });
|
|
715
2789
|
}
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
}
|
|
724
|
-
if (typeof _cryptoVerify !== "undefined") {
|
|
725
|
-
result2.verify = function verify(algorithm, data, key, signature) {
|
|
726
|
-
var dataBuf = typeof data === "string" ? Buffer.from(data, "utf8") : Buffer.from(data);
|
|
727
|
-
var keyPem;
|
|
728
|
-
if (typeof key === "string") {
|
|
729
|
-
keyPem = key;
|
|
730
|
-
} else if (key && typeof key === "object" && key._pem) {
|
|
731
|
-
keyPem = key._pem;
|
|
732
|
-
} else if (Buffer.isBuffer(key)) {
|
|
733
|
-
keyPem = key.toString("utf8");
|
|
734
|
-
} else {
|
|
735
|
-
keyPem = String(key);
|
|
2790
|
+
if (key && typeof key === "object" && key._pem) {
|
|
2791
|
+
return new SandboxKeyObject2(type, {
|
|
2792
|
+
pem: key._pem,
|
|
2793
|
+
jwk: key._jwk,
|
|
2794
|
+
asymmetricKeyType: key.asymmetricKeyType,
|
|
2795
|
+
asymmetricKeyDetails: key.asymmetricKeyDetails
|
|
2796
|
+
});
|
|
736
2797
|
}
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
2798
|
+
if (key && typeof key === "object" && key.key) {
|
|
2799
|
+
var keyData = typeof key.key === "string" ? key.key : key.key.toString("utf8");
|
|
2800
|
+
return new SandboxKeyObject2(type, { pem: keyData });
|
|
2801
|
+
}
|
|
2802
|
+
if (Buffer.isBuffer(key)) {
|
|
2803
|
+
var keyStr = key.toString("utf8");
|
|
2804
|
+
if (keyStr.indexOf("-----BEGIN") === -1) {
|
|
2805
|
+
throw new TypeError("error:0900006e:PEM routines:OPENSSL_internal:NO_START_LINE");
|
|
2806
|
+
}
|
|
2807
|
+
return new SandboxKeyObject2(type, { pem: keyStr });
|
|
2808
|
+
}
|
|
2809
|
+
return new SandboxKeyObject2(type, { pem: String(key) });
|
|
2810
|
+
}, createGeneratedKeyObject2 = function(value) {
|
|
2811
|
+
return new SandboxKeyObject2(value.type, {
|
|
2812
|
+
pem: value.pem,
|
|
2813
|
+
raw: value.raw,
|
|
2814
|
+
jwk: value.jwk,
|
|
2815
|
+
asymmetricKeyType: value.asymmetricKeyType,
|
|
2816
|
+
asymmetricKeyDetails: value.asymmetricKeyDetails
|
|
2817
|
+
});
|
|
750
2818
|
};
|
|
751
|
-
var SandboxKeyObject = SandboxKeyObject2;
|
|
2819
|
+
var restoreBridgeValue = restoreBridgeValue2, cloneObject = cloneObject2, createDomException = createDomException2, toRawBuffer = toRawBuffer2, serializeBridgeValue = serializeBridgeValue2, normalizeCryptoBridgeError = normalizeCryptoBridgeError2, deserializeGeneratedKeyValue = deserializeGeneratedKeyValue2, serializeBridgeOptions = serializeBridgeOptions2, createInvalidArgTypeError = createInvalidArgTypeError2, scheduleCryptoCallback = scheduleCryptoCallback2, shouldThrowCryptoValidationError = shouldThrowCryptoValidationError2, ensureCryptoCallback = ensureCryptoCallback2, SandboxKeyObject = SandboxKeyObject2, normalizeNamedCurve = normalizeNamedCurve2, normalizeAlgorithmInput = normalizeAlgorithmInput2, createCompatibleCryptoKey = createCompatibleCryptoKey2, buildCryptoKeyFromKeyObject = buildCryptoKeyFromKeyObject2, createAsymmetricKeyObject = createAsymmetricKeyObject2, createGeneratedKeyObject = createGeneratedKeyObject2;
|
|
2820
|
+
Object.defineProperty(SandboxKeyObject2.prototype, Symbol.toStringTag, {
|
|
2821
|
+
value: "KeyObject",
|
|
2822
|
+
configurable: true
|
|
2823
|
+
});
|
|
752
2824
|
SandboxKeyObject2.prototype.export = function exportKey(options) {
|
|
753
|
-
if (
|
|
754
|
-
return this.
|
|
2825
|
+
if (this.type === "secret") {
|
|
2826
|
+
return Buffer.from(this._raw || "", "base64");
|
|
2827
|
+
}
|
|
2828
|
+
if (!options || typeof options !== "object") {
|
|
2829
|
+
throw new TypeError('The "options" argument must be of type object.');
|
|
2830
|
+
}
|
|
2831
|
+
if (options.format === "jwk") {
|
|
2832
|
+
return cloneObject2(this._jwk);
|
|
755
2833
|
}
|
|
756
2834
|
if (options.format === "der") {
|
|
757
|
-
var lines = this._pem.split("\n").filter(function(l) {
|
|
2835
|
+
var lines = String(this._pem || "").split("\n").filter(function(l) {
|
|
758
2836
|
return l && l.indexOf("-----") !== 0;
|
|
759
2837
|
});
|
|
760
2838
|
return Buffer.from(lines.join(""), "base64");
|
|
@@ -762,97 +2840,170 @@
|
|
|
762
2840
|
return this._pem;
|
|
763
2841
|
};
|
|
764
2842
|
SandboxKeyObject2.prototype.toString = function() {
|
|
765
|
-
return
|
|
2843
|
+
return "[object KeyObject]";
|
|
766
2844
|
};
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
if (options.divisorLength !== void 0) opts.divisorLength = options.divisorLength;
|
|
774
|
-
if (options.primeLength !== void 0) opts.primeLength = options.primeLength;
|
|
2845
|
+
SandboxKeyObject2.prototype.equals = function equals(other) {
|
|
2846
|
+
if (!(other instanceof SandboxKeyObject2)) {
|
|
2847
|
+
return false;
|
|
2848
|
+
}
|
|
2849
|
+
if (this.type !== other.type) {
|
|
2850
|
+
return false;
|
|
775
2851
|
}
|
|
2852
|
+
if (this.type === "secret") {
|
|
2853
|
+
return (this._raw || "") === (other._raw || "");
|
|
2854
|
+
}
|
|
2855
|
+
return (this._pem || "") === (other._pem || "") && this.asymmetricKeyType === other.asymmetricKeyType;
|
|
2856
|
+
};
|
|
2857
|
+
SandboxKeyObject2.prototype.toCryptoKey = function toCryptoKey(algorithm, extractable, usages) {
|
|
2858
|
+
return buildCryptoKeyFromKeyObject2(this, algorithm, extractable, Array.from(usages || []));
|
|
2859
|
+
};
|
|
2860
|
+
result.generateKeyPairSync = function generateKeyPairSync(type, options) {
|
|
776
2861
|
var resultJson = _cryptoGenerateKeyPairSync.applySync(void 0, [
|
|
777
2862
|
type,
|
|
778
|
-
|
|
2863
|
+
serializeBridgeOptions2(options)
|
|
779
2864
|
]);
|
|
780
2865
|
var parsed = JSON.parse(resultJson);
|
|
781
|
-
if (
|
|
782
|
-
return {
|
|
2866
|
+
if (parsed.publicKey && parsed.publicKey.kind) {
|
|
2867
|
+
return {
|
|
2868
|
+
publicKey: deserializeGeneratedKeyValue2(parsed.publicKey),
|
|
2869
|
+
privateKey: deserializeGeneratedKeyValue2(parsed.privateKey)
|
|
2870
|
+
};
|
|
783
2871
|
}
|
|
784
2872
|
return {
|
|
785
|
-
publicKey:
|
|
786
|
-
privateKey:
|
|
2873
|
+
publicKey: createGeneratedKeyObject2(parsed.publicKey),
|
|
2874
|
+
privateKey: createGeneratedKeyObject2(parsed.privateKey)
|
|
787
2875
|
};
|
|
788
2876
|
};
|
|
789
|
-
|
|
2877
|
+
result.generateKeyPair = function generateKeyPair(type, options, callback) {
|
|
2878
|
+
if (typeof options === "function") {
|
|
2879
|
+
callback = options;
|
|
2880
|
+
options = void 0;
|
|
2881
|
+
}
|
|
2882
|
+
callback = ensureCryptoCallback2(callback, function() {
|
|
2883
|
+
result.generateKeyPairSync(type, options);
|
|
2884
|
+
});
|
|
790
2885
|
try {
|
|
791
|
-
var pair =
|
|
792
|
-
callback
|
|
2886
|
+
var pair = result.generateKeyPairSync(type, options);
|
|
2887
|
+
scheduleCryptoCallback2(callback, [null, pair.publicKey, pair.privateKey]);
|
|
793
2888
|
} catch (e) {
|
|
794
|
-
|
|
2889
|
+
if (shouldThrowCryptoValidationError2(e)) {
|
|
2890
|
+
throw e;
|
|
2891
|
+
}
|
|
2892
|
+
scheduleCryptoCallback2(callback, [e]);
|
|
795
2893
|
}
|
|
796
2894
|
};
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
2895
|
+
if (typeof _cryptoGenerateKeySync !== "undefined") {
|
|
2896
|
+
result.generateKeySync = function generateKeySync(type, options) {
|
|
2897
|
+
var resultJson;
|
|
2898
|
+
try {
|
|
2899
|
+
resultJson = _cryptoGenerateKeySync.applySync(void 0, [
|
|
2900
|
+
type,
|
|
2901
|
+
serializeBridgeOptions2(options)
|
|
2902
|
+
]);
|
|
2903
|
+
} catch (error) {
|
|
2904
|
+
throw normalizeCryptoBridgeError2(error);
|
|
801
2905
|
}
|
|
802
|
-
return
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
if (keyStr.indexOf("-----BEGIN") === -1) {
|
|
817
|
-
throw new TypeError("error:0900006e:PEM routines:OPENSSL_internal:NO_START_LINE");
|
|
2906
|
+
return createGeneratedKeyObject2(JSON.parse(resultJson));
|
|
2907
|
+
};
|
|
2908
|
+
result.generateKey = function generateKey(type, options, callback) {
|
|
2909
|
+
callback = ensureCryptoCallback2(callback, function() {
|
|
2910
|
+
result.generateKeySync(type, options);
|
|
2911
|
+
});
|
|
2912
|
+
try {
|
|
2913
|
+
var key = result.generateKeySync(type, options);
|
|
2914
|
+
scheduleCryptoCallback2(callback, [null, key]);
|
|
2915
|
+
} catch (e) {
|
|
2916
|
+
if (shouldThrowCryptoValidationError2(e)) {
|
|
2917
|
+
throw e;
|
|
2918
|
+
}
|
|
2919
|
+
scheduleCryptoCallback2(callback, [e]);
|
|
818
2920
|
}
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
2921
|
+
};
|
|
2922
|
+
}
|
|
2923
|
+
if (typeof _cryptoGeneratePrimeSync !== "undefined") {
|
|
2924
|
+
result.generatePrimeSync = function generatePrimeSync(size, options) {
|
|
2925
|
+
var resultJson;
|
|
2926
|
+
try {
|
|
2927
|
+
resultJson = _cryptoGeneratePrimeSync.applySync(void 0, [
|
|
2928
|
+
size,
|
|
2929
|
+
serializeBridgeOptions2(options)
|
|
2930
|
+
]);
|
|
2931
|
+
} catch (error) {
|
|
2932
|
+
throw normalizeCryptoBridgeError2(error);
|
|
827
2933
|
}
|
|
828
|
-
return
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
2934
|
+
return restoreBridgeValue2(JSON.parse(resultJson));
|
|
2935
|
+
};
|
|
2936
|
+
result.generatePrime = function generatePrime(size, options, callback) {
|
|
2937
|
+
if (typeof options === "function") {
|
|
2938
|
+
callback = options;
|
|
2939
|
+
options = void 0;
|
|
2940
|
+
}
|
|
2941
|
+
callback = ensureCryptoCallback2(callback, function() {
|
|
2942
|
+
result.generatePrimeSync(size, options);
|
|
2943
|
+
});
|
|
2944
|
+
try {
|
|
2945
|
+
var prime = result.generatePrimeSync(size, options);
|
|
2946
|
+
scheduleCryptoCallback2(callback, [null, prime]);
|
|
2947
|
+
} catch (e) {
|
|
2948
|
+
if (shouldThrowCryptoValidationError2(e)) {
|
|
2949
|
+
throw e;
|
|
2950
|
+
}
|
|
2951
|
+
scheduleCryptoCallback2(callback, [e]);
|
|
2952
|
+
}
|
|
2953
|
+
};
|
|
2954
|
+
}
|
|
2955
|
+
result.createPublicKey = function createPublicKey(key) {
|
|
2956
|
+
if (typeof _cryptoCreateKeyObject !== "undefined") {
|
|
2957
|
+
var resultJson;
|
|
2958
|
+
try {
|
|
2959
|
+
resultJson = _cryptoCreateKeyObject.applySync(void 0, [
|
|
2960
|
+
"createPublicKey",
|
|
2961
|
+
JSON.stringify(serializeBridgeValue2(key))
|
|
2962
|
+
]);
|
|
2963
|
+
} catch (error) {
|
|
2964
|
+
throw normalizeCryptoBridgeError2(error);
|
|
2965
|
+
}
|
|
2966
|
+
return createGeneratedKeyObject2(JSON.parse(resultJson));
|
|
836
2967
|
}
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
2968
|
+
return createAsymmetricKeyObject2("public", key);
|
|
2969
|
+
};
|
|
2970
|
+
result.createPrivateKey = function createPrivateKey(key) {
|
|
2971
|
+
if (typeof _cryptoCreateKeyObject !== "undefined") {
|
|
2972
|
+
var resultJson;
|
|
2973
|
+
try {
|
|
2974
|
+
resultJson = _cryptoCreateKeyObject.applySync(void 0, [
|
|
2975
|
+
"createPrivateKey",
|
|
2976
|
+
JSON.stringify(serializeBridgeValue2(key))
|
|
2977
|
+
]);
|
|
2978
|
+
} catch (error) {
|
|
2979
|
+
throw normalizeCryptoBridgeError2(error);
|
|
841
2980
|
}
|
|
842
|
-
return
|
|
2981
|
+
return createGeneratedKeyObject2(JSON.parse(resultJson));
|
|
843
2982
|
}
|
|
844
|
-
return
|
|
2983
|
+
return createAsymmetricKeyObject2("private", key);
|
|
845
2984
|
};
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
2985
|
+
result.createSecretKey = function createSecretKey(key, encoding) {
|
|
2986
|
+
return new SandboxKeyObject2("secret", {
|
|
2987
|
+
raw: toRawBuffer2(key, encoding).toString("base64")
|
|
2988
|
+
});
|
|
2989
|
+
};
|
|
2990
|
+
SandboxKeyObject2.from = function from(key) {
|
|
2991
|
+
if (!key || typeof key !== "object" || key[Symbol.toStringTag] !== "CryptoKey") {
|
|
2992
|
+
throw new TypeError('The "key" argument must be an instance of CryptoKey.');
|
|
849
2993
|
}
|
|
850
|
-
if (
|
|
851
|
-
return new SandboxKeyObject2("secret",
|
|
2994
|
+
if (key._sourceKeyObjectData && key._sourceKeyObjectData.type === "secret") {
|
|
2995
|
+
return new SandboxKeyObject2("secret", {
|
|
2996
|
+
raw: key._sourceKeyObjectData.raw
|
|
2997
|
+
});
|
|
852
2998
|
}
|
|
853
|
-
return new SandboxKeyObject2(
|
|
2999
|
+
return new SandboxKeyObject2(key.type, {
|
|
3000
|
+
pem: key._pem,
|
|
3001
|
+
jwk: key._jwk,
|
|
3002
|
+
asymmetricKeyType: key._sourceKeyObjectData && key._sourceKeyObjectData.asymmetricKeyType,
|
|
3003
|
+
asymmetricKeyDetails: key._sourceKeyObjectData && key._sourceKeyObjectData.asymmetricKeyDetails
|
|
3004
|
+
});
|
|
854
3005
|
};
|
|
855
|
-
|
|
3006
|
+
result.KeyObject = SandboxKeyObject2;
|
|
856
3007
|
}
|
|
857
3008
|
if (typeof _cryptoSubtle !== "undefined") {
|
|
858
3009
|
let SandboxCryptoKey2 = function(keyData) {
|
|
@@ -861,6 +3012,10 @@
|
|
|
861
3012
|
this.algorithm = keyData.algorithm;
|
|
862
3013
|
this.usages = keyData.usages;
|
|
863
3014
|
this._keyData = keyData;
|
|
3015
|
+
this._pem = keyData._pem;
|
|
3016
|
+
this._jwk = keyData._jwk;
|
|
3017
|
+
this._raw = keyData._raw;
|
|
3018
|
+
this._sourceKeyObjectData = keyData._sourceKeyObjectData;
|
|
864
3019
|
}, toBase642 = function(data) {
|
|
865
3020
|
if (typeof data === "string") return Buffer.from(data).toString("base64");
|
|
866
3021
|
if (data instanceof ArrayBuffer) return Buffer.from(new Uint8Array(data)).toString("base64");
|
|
@@ -873,16 +3028,34 @@
|
|
|
873
3028
|
return algorithm;
|
|
874
3029
|
};
|
|
875
3030
|
var SandboxCryptoKey = SandboxCryptoKey2, toBase64 = toBase642, subtleCall = subtleCall2, normalizeAlgo = normalizeAlgo2;
|
|
3031
|
+
Object.defineProperty(SandboxCryptoKey2.prototype, Symbol.toStringTag, {
|
|
3032
|
+
value: "CryptoKey",
|
|
3033
|
+
configurable: true
|
|
3034
|
+
});
|
|
3035
|
+
Object.defineProperty(SandboxCryptoKey2, Symbol.hasInstance, {
|
|
3036
|
+
value: function(candidate) {
|
|
3037
|
+
return !!(candidate && typeof candidate === "object" && (candidate._keyData || candidate[Symbol.toStringTag] === "CryptoKey"));
|
|
3038
|
+
},
|
|
3039
|
+
configurable: true
|
|
3040
|
+
});
|
|
3041
|
+
if (globalThis.CryptoKey && globalThis.CryptoKey.prototype && globalThis.CryptoKey.prototype !== SandboxCryptoKey2.prototype) {
|
|
3042
|
+
Object.setPrototypeOf(SandboxCryptoKey2.prototype, globalThis.CryptoKey.prototype);
|
|
3043
|
+
}
|
|
3044
|
+
if (typeof globalThis.CryptoKey === "undefined") {
|
|
3045
|
+
__requireExposeCustomGlobal("CryptoKey", SandboxCryptoKey2);
|
|
3046
|
+
} else if (globalThis.CryptoKey !== SandboxCryptoKey2) {
|
|
3047
|
+
globalThis.CryptoKey = SandboxCryptoKey2;
|
|
3048
|
+
}
|
|
876
3049
|
var SandboxSubtle = {};
|
|
877
3050
|
SandboxSubtle.digest = function digest(algorithm, data) {
|
|
878
3051
|
return Promise.resolve().then(function() {
|
|
879
3052
|
var algo = normalizeAlgo2(algorithm);
|
|
880
|
-
var
|
|
3053
|
+
var result2 = JSON.parse(subtleCall2({
|
|
881
3054
|
op: "digest",
|
|
882
3055
|
algorithm: algo.name,
|
|
883
3056
|
data: toBase642(data)
|
|
884
3057
|
}));
|
|
885
|
-
var buf = Buffer.from(
|
|
3058
|
+
var buf = Buffer.from(result2.data, "base64");
|
|
886
3059
|
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
|
|
887
3060
|
});
|
|
888
3061
|
};
|
|
@@ -894,19 +3067,19 @@
|
|
|
894
3067
|
if (reqAlgo.publicExponent) {
|
|
895
3068
|
reqAlgo.publicExponent = Buffer.from(new Uint8Array(reqAlgo.publicExponent.buffer || reqAlgo.publicExponent)).toString("base64");
|
|
896
3069
|
}
|
|
897
|
-
var
|
|
3070
|
+
var result2 = JSON.parse(subtleCall2({
|
|
898
3071
|
op: "generateKey",
|
|
899
3072
|
algorithm: reqAlgo,
|
|
900
3073
|
extractable,
|
|
901
3074
|
usages: Array.from(keyUsages)
|
|
902
3075
|
}));
|
|
903
|
-
if (
|
|
3076
|
+
if (result2.publicKey && result2.privateKey) {
|
|
904
3077
|
return {
|
|
905
|
-
publicKey: new SandboxCryptoKey2(
|
|
906
|
-
privateKey: new SandboxCryptoKey2(
|
|
3078
|
+
publicKey: new SandboxCryptoKey2(result2.publicKey),
|
|
3079
|
+
privateKey: new SandboxCryptoKey2(result2.privateKey)
|
|
907
3080
|
};
|
|
908
3081
|
}
|
|
909
|
-
return new SandboxCryptoKey2(
|
|
3082
|
+
return new SandboxCryptoKey2(result2.key);
|
|
910
3083
|
});
|
|
911
3084
|
};
|
|
912
3085
|
SandboxSubtle.importKey = function importKey(format, keyData, algorithm, extractable, keyUsages) {
|
|
@@ -922,7 +3095,7 @@
|
|
|
922
3095
|
} else {
|
|
923
3096
|
serializedKeyData = toBase642(keyData);
|
|
924
3097
|
}
|
|
925
|
-
var
|
|
3098
|
+
var result2 = JSON.parse(subtleCall2({
|
|
926
3099
|
op: "importKey",
|
|
927
3100
|
format,
|
|
928
3101
|
keyData: serializedKeyData,
|
|
@@ -930,18 +3103,18 @@
|
|
|
930
3103
|
extractable,
|
|
931
3104
|
usages: Array.from(keyUsages)
|
|
932
3105
|
}));
|
|
933
|
-
return new SandboxCryptoKey2(
|
|
3106
|
+
return new SandboxCryptoKey2(result2.key);
|
|
934
3107
|
});
|
|
935
3108
|
};
|
|
936
3109
|
SandboxSubtle.exportKey = function exportKey(format, key) {
|
|
937
3110
|
return Promise.resolve().then(function() {
|
|
938
|
-
var
|
|
3111
|
+
var result2 = JSON.parse(subtleCall2({
|
|
939
3112
|
op: "exportKey",
|
|
940
3113
|
format,
|
|
941
3114
|
key: key._keyData
|
|
942
3115
|
}));
|
|
943
|
-
if (format === "jwk") return
|
|
944
|
-
var buf = Buffer.from(
|
|
3116
|
+
if (format === "jwk") return result2.jwk;
|
|
3117
|
+
var buf = Buffer.from(result2.data, "base64");
|
|
945
3118
|
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
|
|
946
3119
|
});
|
|
947
3120
|
};
|
|
@@ -951,13 +3124,13 @@
|
|
|
951
3124
|
var reqAlgo = Object.assign({}, algo);
|
|
952
3125
|
if (reqAlgo.iv) reqAlgo.iv = toBase642(reqAlgo.iv);
|
|
953
3126
|
if (reqAlgo.additionalData) reqAlgo.additionalData = toBase642(reqAlgo.additionalData);
|
|
954
|
-
var
|
|
3127
|
+
var result2 = JSON.parse(subtleCall2({
|
|
955
3128
|
op: "encrypt",
|
|
956
3129
|
algorithm: reqAlgo,
|
|
957
3130
|
key: key._keyData,
|
|
958
3131
|
data: toBase642(data)
|
|
959
3132
|
}));
|
|
960
|
-
var buf = Buffer.from(
|
|
3133
|
+
var buf = Buffer.from(result2.data, "base64");
|
|
961
3134
|
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
|
|
962
3135
|
});
|
|
963
3136
|
};
|
|
@@ -967,61 +3140,82 @@
|
|
|
967
3140
|
var reqAlgo = Object.assign({}, algo);
|
|
968
3141
|
if (reqAlgo.iv) reqAlgo.iv = toBase642(reqAlgo.iv);
|
|
969
3142
|
if (reqAlgo.additionalData) reqAlgo.additionalData = toBase642(reqAlgo.additionalData);
|
|
970
|
-
var
|
|
3143
|
+
var result2 = JSON.parse(subtleCall2({
|
|
971
3144
|
op: "decrypt",
|
|
972
3145
|
algorithm: reqAlgo,
|
|
973
3146
|
key: key._keyData,
|
|
974
3147
|
data: toBase642(data)
|
|
975
3148
|
}));
|
|
976
|
-
var buf = Buffer.from(
|
|
977
|
-
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
|
|
978
|
-
});
|
|
979
|
-
};
|
|
980
|
-
SandboxSubtle.deriveBits = function deriveBits(algorithm, baseKey, length) {
|
|
981
|
-
return Promise.resolve().then(function() {
|
|
982
|
-
var algo = normalizeAlgo2(algorithm);
|
|
983
|
-
var reqAlgo = Object.assign({}, algo);
|
|
984
|
-
if (reqAlgo.hash) reqAlgo.hash = normalizeAlgo2(reqAlgo.hash);
|
|
985
|
-
if (reqAlgo.salt) reqAlgo.salt = toBase642(reqAlgo.salt);
|
|
986
|
-
var result22 = JSON.parse(subtleCall2({
|
|
987
|
-
op: "deriveBits",
|
|
988
|
-
algorithm: reqAlgo,
|
|
989
|
-
key: baseKey._keyData,
|
|
990
|
-
length
|
|
991
|
-
}));
|
|
992
|
-
var buf = Buffer.from(result22.data, "base64");
|
|
3149
|
+
var buf = Buffer.from(result2.data, "base64");
|
|
993
3150
|
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
|
|
994
3151
|
});
|
|
995
3152
|
};
|
|
996
3153
|
SandboxSubtle.sign = function sign(algorithm, key, data) {
|
|
997
3154
|
return Promise.resolve().then(function() {
|
|
998
|
-
var
|
|
3155
|
+
var result2 = JSON.parse(subtleCall2({
|
|
999
3156
|
op: "sign",
|
|
1000
3157
|
algorithm: normalizeAlgo2(algorithm),
|
|
1001
3158
|
key: key._keyData,
|
|
1002
3159
|
data: toBase642(data)
|
|
1003
3160
|
}));
|
|
1004
|
-
var buf = Buffer.from(
|
|
3161
|
+
var buf = Buffer.from(result2.data, "base64");
|
|
1005
3162
|
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
|
|
1006
3163
|
});
|
|
1007
3164
|
};
|
|
1008
3165
|
SandboxSubtle.verify = function verify(algorithm, key, signature, data) {
|
|
1009
3166
|
return Promise.resolve().then(function() {
|
|
1010
|
-
var
|
|
3167
|
+
var result2 = JSON.parse(subtleCall2({
|
|
1011
3168
|
op: "verify",
|
|
1012
3169
|
algorithm: normalizeAlgo2(algorithm),
|
|
1013
3170
|
key: key._keyData,
|
|
1014
3171
|
signature: toBase642(signature),
|
|
1015
3172
|
data: toBase642(data)
|
|
1016
3173
|
}));
|
|
1017
|
-
return
|
|
3174
|
+
return result2.result;
|
|
3175
|
+
});
|
|
3176
|
+
};
|
|
3177
|
+
SandboxSubtle.deriveBits = function deriveBits(algorithm, baseKey, length) {
|
|
3178
|
+
return Promise.resolve().then(function() {
|
|
3179
|
+
var algo = normalizeAlgo2(algorithm);
|
|
3180
|
+
var reqAlgo = Object.assign({}, algo);
|
|
3181
|
+
if (reqAlgo.salt) reqAlgo.salt = toBase642(reqAlgo.salt);
|
|
3182
|
+
if (reqAlgo.info) reqAlgo.info = toBase642(reqAlgo.info);
|
|
3183
|
+
var result2 = JSON.parse(subtleCall2({
|
|
3184
|
+
op: "deriveBits",
|
|
3185
|
+
algorithm: reqAlgo,
|
|
3186
|
+
baseKey: baseKey._keyData,
|
|
3187
|
+
length
|
|
3188
|
+
}));
|
|
3189
|
+
return Buffer.from(result2.data, "base64").buffer;
|
|
3190
|
+
});
|
|
3191
|
+
};
|
|
3192
|
+
SandboxSubtle.deriveKey = function deriveKey(algorithm, baseKey, derivedKeyAlgorithm, extractable, keyUsages) {
|
|
3193
|
+
return Promise.resolve().then(function() {
|
|
3194
|
+
var algo = normalizeAlgo2(algorithm);
|
|
3195
|
+
var reqAlgo = Object.assign({}, algo);
|
|
3196
|
+
if (reqAlgo.salt) reqAlgo.salt = toBase642(reqAlgo.salt);
|
|
3197
|
+
if (reqAlgo.info) reqAlgo.info = toBase642(reqAlgo.info);
|
|
3198
|
+
var result2 = JSON.parse(subtleCall2({
|
|
3199
|
+
op: "deriveKey",
|
|
3200
|
+
algorithm: reqAlgo,
|
|
3201
|
+
baseKey: baseKey._keyData,
|
|
3202
|
+
derivedKeyAlgorithm: normalizeAlgo2(derivedKeyAlgorithm),
|
|
3203
|
+
extractable,
|
|
3204
|
+
usages: keyUsages
|
|
3205
|
+
}));
|
|
3206
|
+
return new SandboxCryptoKey2(result2.key);
|
|
1018
3207
|
});
|
|
1019
3208
|
};
|
|
1020
|
-
|
|
1021
|
-
|
|
3209
|
+
if (globalThis.crypto && globalThis.crypto.subtle && typeof globalThis.crypto.subtle.importKey === "function") {
|
|
3210
|
+
result.subtle = globalThis.crypto.subtle;
|
|
3211
|
+
result.webcrypto = globalThis.crypto;
|
|
3212
|
+
} else {
|
|
3213
|
+
result.subtle = SandboxSubtle;
|
|
3214
|
+
result.webcrypto = { subtle: SandboxSubtle, getRandomValues: result.randomFillSync };
|
|
3215
|
+
}
|
|
1022
3216
|
}
|
|
1023
|
-
if (typeof
|
|
1024
|
-
|
|
3217
|
+
if (typeof result.getCurves !== "function") {
|
|
3218
|
+
result.getCurves = function getCurves() {
|
|
1025
3219
|
return [
|
|
1026
3220
|
"prime256v1",
|
|
1027
3221
|
"secp256r1",
|
|
@@ -1033,8 +3227,8 @@
|
|
|
1033
3227
|
];
|
|
1034
3228
|
};
|
|
1035
3229
|
}
|
|
1036
|
-
if (typeof
|
|
1037
|
-
|
|
3230
|
+
if (typeof result.getCiphers !== "function") {
|
|
3231
|
+
result.getCiphers = function getCiphers() {
|
|
1038
3232
|
return [
|
|
1039
3233
|
"aes-128-cbc",
|
|
1040
3234
|
"aes-128-gcm",
|
|
@@ -1048,13 +3242,13 @@
|
|
|
1048
3242
|
];
|
|
1049
3243
|
};
|
|
1050
3244
|
}
|
|
1051
|
-
if (typeof
|
|
1052
|
-
|
|
3245
|
+
if (typeof result.getHashes !== "function") {
|
|
3246
|
+
result.getHashes = function getHashes() {
|
|
1053
3247
|
return ["md5", "sha1", "sha256", "sha384", "sha512"];
|
|
1054
3248
|
};
|
|
1055
3249
|
}
|
|
1056
|
-
if (typeof
|
|
1057
|
-
|
|
3250
|
+
if (typeof result.timingSafeEqual !== "function") {
|
|
3251
|
+
result.timingSafeEqual = function timingSafeEqual(a, b) {
|
|
1058
3252
|
if (a.length !== b.length) {
|
|
1059
3253
|
throw new RangeError("Input buffers must have the same byte length");
|
|
1060
3254
|
}
|
|
@@ -1065,26 +3259,112 @@
|
|
|
1065
3259
|
return out === 0;
|
|
1066
3260
|
};
|
|
1067
3261
|
}
|
|
1068
|
-
|
|
3262
|
+
if (typeof result.getFips !== "function") {
|
|
3263
|
+
result.getFips = function getFips() {
|
|
3264
|
+
return 0;
|
|
3265
|
+
};
|
|
3266
|
+
}
|
|
3267
|
+
if (typeof result.setFips !== "function") {
|
|
3268
|
+
result.setFips = function setFips() {
|
|
3269
|
+
throw new Error("FIPS mode is not supported in sandbox");
|
|
3270
|
+
};
|
|
3271
|
+
}
|
|
3272
|
+
return result;
|
|
1069
3273
|
}
|
|
1070
|
-
if (
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
3274
|
+
if (name === "stream") {
|
|
3275
|
+
var getWebStreamsState = function() {
|
|
3276
|
+
return globalThis.__secureExecWebStreams || null;
|
|
3277
|
+
};
|
|
3278
|
+
var webStreamsState = getWebStreamsState();
|
|
3279
|
+
if (typeof result.isReadable !== "function") {
|
|
3280
|
+
result.isReadable = function(stream) {
|
|
3281
|
+
var stateKey = getWebStreamsState() && getWebStreamsState().kState;
|
|
3282
|
+
return Boolean(stateKey && stream && stream[stateKey] && stream[stateKey].state === "readable");
|
|
3283
|
+
};
|
|
3284
|
+
}
|
|
3285
|
+
if (typeof result.isErrored !== "function") {
|
|
3286
|
+
result.isErrored = function(stream) {
|
|
3287
|
+
var stateKey = getWebStreamsState() && getWebStreamsState().kState;
|
|
3288
|
+
return Boolean(stateKey && stream && stream[stateKey] && stream[stateKey].state === "errored");
|
|
3289
|
+
};
|
|
3290
|
+
}
|
|
3291
|
+
if (typeof result.isDisturbed !== "function") {
|
|
3292
|
+
result.isDisturbed = function(stream) {
|
|
3293
|
+
var stateKey = getWebStreamsState() && getWebStreamsState().kState;
|
|
3294
|
+
return Boolean(stateKey && stream && stream[stateKey] && stream[stateKey].disturbed === true);
|
|
3295
|
+
};
|
|
3296
|
+
}
|
|
3297
|
+
if (typeof result === "function" && result.prototype && typeof result.Readable === "function") {
|
|
3298
|
+
var readableProto = result.Readable.prototype;
|
|
3299
|
+
var streamProto = result.prototype;
|
|
3300
|
+
if (readableProto && streamProto && !(readableProto instanceof result)) {
|
|
1075
3301
|
var currentParent = Object.getPrototypeOf(readableProto);
|
|
1076
3302
|
Object.setPrototypeOf(streamProto, currentParent);
|
|
1077
3303
|
Object.setPrototypeOf(readableProto, streamProto);
|
|
1078
3304
|
}
|
|
1079
3305
|
}
|
|
1080
|
-
|
|
3306
|
+
if (typeof result.Readable === "function" && !Object.getOwnPropertyDescriptor(result.Readable.prototype, "readableObjectMode")) {
|
|
3307
|
+
Object.defineProperty(result.Readable.prototype, "readableObjectMode", {
|
|
3308
|
+
configurable: true,
|
|
3309
|
+
enumerable: false,
|
|
3310
|
+
get: function() {
|
|
3311
|
+
return Boolean(this && this._readableState && this._readableState.objectMode);
|
|
3312
|
+
}
|
|
3313
|
+
});
|
|
3314
|
+
}
|
|
3315
|
+
if (typeof result.Writable === "function" && !Object.getOwnPropertyDescriptor(result.Writable.prototype, "writableObjectMode")) {
|
|
3316
|
+
Object.defineProperty(result.Writable.prototype, "writableObjectMode", {
|
|
3317
|
+
configurable: true,
|
|
3318
|
+
enumerable: false,
|
|
3319
|
+
get: function() {
|
|
3320
|
+
return Boolean(this && this._writableState && this._writableState.objectMode);
|
|
3321
|
+
}
|
|
3322
|
+
});
|
|
3323
|
+
}
|
|
3324
|
+
if (webStreamsState && typeof result.Readable === "function") {
|
|
3325
|
+
if (typeof result.Readable.fromWeb !== "function" && typeof webStreamsState.newStreamReadableFromReadableStream === "function") {
|
|
3326
|
+
result.Readable.fromWeb = function fromWeb(readableStream, options) {
|
|
3327
|
+
return webStreamsState.newStreamReadableFromReadableStream(readableStream, options);
|
|
3328
|
+
};
|
|
3329
|
+
}
|
|
3330
|
+
if (typeof result.Readable.toWeb !== "function" && typeof webStreamsState.newReadableStreamFromStreamReadable === "function") {
|
|
3331
|
+
result.Readable.toWeb = function toWeb(readable) {
|
|
3332
|
+
return webStreamsState.newReadableStreamFromStreamReadable(readable);
|
|
3333
|
+
};
|
|
3334
|
+
}
|
|
3335
|
+
}
|
|
3336
|
+
if (webStreamsState && typeof result.Writable === "function") {
|
|
3337
|
+
if (typeof result.Writable.fromWeb !== "function" && typeof webStreamsState.newStreamWritableFromWritableStream === "function") {
|
|
3338
|
+
result.Writable.fromWeb = function fromWeb(writableStream, options) {
|
|
3339
|
+
return webStreamsState.newStreamWritableFromWritableStream(writableStream, options);
|
|
3340
|
+
};
|
|
3341
|
+
}
|
|
3342
|
+
if (typeof result.Writable.toWeb !== "function" && typeof webStreamsState.newWritableStreamFromStreamWritable === "function") {
|
|
3343
|
+
result.Writable.toWeb = function toWeb(writable) {
|
|
3344
|
+
return webStreamsState.newWritableStreamFromStreamWritable(writable);
|
|
3345
|
+
};
|
|
3346
|
+
}
|
|
3347
|
+
}
|
|
3348
|
+
if (webStreamsState && typeof result.Duplex === "function") {
|
|
3349
|
+
if (typeof result.Duplex.fromWeb !== "function" && typeof webStreamsState.newStreamDuplexFromReadableWritablePair === "function") {
|
|
3350
|
+
result.Duplex.fromWeb = function fromWeb(pair, options) {
|
|
3351
|
+
return webStreamsState.newStreamDuplexFromReadableWritablePair(pair, options);
|
|
3352
|
+
};
|
|
3353
|
+
}
|
|
3354
|
+
if (typeof result.Duplex.toWeb !== "function" && typeof webStreamsState.newReadableWritablePairFromDuplex === "function") {
|
|
3355
|
+
result.Duplex.toWeb = function toWeb(duplex) {
|
|
3356
|
+
return webStreamsState.newReadableWritablePairFromDuplex(duplex);
|
|
3357
|
+
};
|
|
3358
|
+
}
|
|
3359
|
+
}
|
|
3360
|
+
return result;
|
|
1081
3361
|
}
|
|
1082
|
-
if (
|
|
1083
|
-
if (
|
|
1084
|
-
|
|
3362
|
+
if (name === "path") {
|
|
3363
|
+
if (result.win32 === null || result.win32 === void 0) {
|
|
3364
|
+
result.win32 = result.posix || result;
|
|
1085
3365
|
}
|
|
1086
|
-
if (
|
|
1087
|
-
|
|
3366
|
+
if (result.posix === null || result.posix === void 0) {
|
|
3367
|
+
result.posix = result;
|
|
1088
3368
|
}
|
|
1089
3369
|
const hasAbsoluteSegment = function(args) {
|
|
1090
3370
|
return args.some(function(arg) {
|
|
@@ -1100,7 +3380,7 @@
|
|
|
1100
3380
|
}
|
|
1101
3381
|
}
|
|
1102
3382
|
};
|
|
1103
|
-
const originalResolve =
|
|
3383
|
+
const originalResolve = result.resolve;
|
|
1104
3384
|
if (typeof originalResolve === "function" && !originalResolve._patchedForCwd) {
|
|
1105
3385
|
const patchedResolve = function resolve2() {
|
|
1106
3386
|
const args = Array.from(arguments);
|
|
@@ -1108,23 +3388,22 @@
|
|
|
1108
3388
|
return originalResolve.apply(this, args);
|
|
1109
3389
|
};
|
|
1110
3390
|
patchedResolve._patchedForCwd = true;
|
|
1111
|
-
|
|
3391
|
+
result.resolve = patchedResolve;
|
|
1112
3392
|
}
|
|
1113
|
-
if (
|
|
1114
|
-
const originalPosixResolve =
|
|
3393
|
+
if (result.posix && typeof result.posix.resolve === "function" && !result.posix.resolve._patchedForCwd) {
|
|
3394
|
+
const originalPosixResolve = result.posix.resolve;
|
|
1115
3395
|
const patchedPosixResolve = function resolve2() {
|
|
1116
3396
|
const args = Array.from(arguments);
|
|
1117
3397
|
prependCwd(args);
|
|
1118
3398
|
return originalPosixResolve.apply(this, args);
|
|
1119
3399
|
};
|
|
1120
3400
|
patchedPosixResolve._patchedForCwd = true;
|
|
1121
|
-
|
|
3401
|
+
result.posix.resolve = patchedPosixResolve;
|
|
1122
3402
|
}
|
|
1123
3403
|
}
|
|
1124
|
-
return
|
|
3404
|
+
return result;
|
|
1125
3405
|
}
|
|
1126
3406
|
var _deferredCoreModules = /* @__PURE__ */ new Set([
|
|
1127
|
-
"tls",
|
|
1128
3407
|
"readline",
|
|
1129
3408
|
"perf_hooks",
|
|
1130
3409
|
"async_hooks",
|
|
@@ -1132,7 +3411,6 @@
|
|
|
1132
3411
|
"diagnostics_channel"
|
|
1133
3412
|
]);
|
|
1134
3413
|
var _unsupportedCoreModules = /* @__PURE__ */ new Set([
|
|
1135
|
-
"dgram",
|
|
1136
3414
|
"cluster",
|
|
1137
3415
|
"wasi",
|
|
1138
3416
|
"inspector",
|
|
@@ -1140,11 +3418,29 @@
|
|
|
1140
3418
|
"trace_events",
|
|
1141
3419
|
"domain"
|
|
1142
3420
|
]);
|
|
1143
|
-
function _unsupportedApiError(
|
|
1144
|
-
return new Error(
|
|
3421
|
+
function _unsupportedApiError(moduleName, apiName) {
|
|
3422
|
+
return new Error(moduleName + "." + apiName + " is not supported in sandbox");
|
|
1145
3423
|
}
|
|
1146
|
-
function _createDeferredModuleStub(
|
|
3424
|
+
function _createDeferredModuleStub(moduleName) {
|
|
1147
3425
|
const methodCache = {};
|
|
3426
|
+
const workerThreadsCompat = {
|
|
3427
|
+
markAsUncloneable: function markAsUncloneable(value) {
|
|
3428
|
+
return value;
|
|
3429
|
+
},
|
|
3430
|
+
markAsUntransferable: function markAsUntransferable(value) {
|
|
3431
|
+
return value;
|
|
3432
|
+
},
|
|
3433
|
+
isMarkedAsUntransferable: function isMarkedAsUntransferable() {
|
|
3434
|
+
return false;
|
|
3435
|
+
},
|
|
3436
|
+
MessagePort: globalThis.MessagePort,
|
|
3437
|
+
MessageChannel: globalThis.MessageChannel,
|
|
3438
|
+
MessageEvent: globalThis.MessageEvent
|
|
3439
|
+
};
|
|
3440
|
+
const moduleCompat = {
|
|
3441
|
+
worker_threads: workerThreadsCompat,
|
|
3442
|
+
"node:worker_threads": workerThreadsCompat
|
|
3443
|
+
};
|
|
1148
3444
|
let stub = null;
|
|
1149
3445
|
stub = new Proxy({}, {
|
|
1150
3446
|
get(_target, prop) {
|
|
@@ -1153,9 +3449,12 @@
|
|
|
1153
3449
|
if (prop === Symbol.toStringTag) return "Module";
|
|
1154
3450
|
if (prop === "then") return void 0;
|
|
1155
3451
|
if (typeof prop !== "string") return void 0;
|
|
3452
|
+
if (moduleCompat[moduleName] && Object.prototype.hasOwnProperty.call(moduleCompat[moduleName], prop)) {
|
|
3453
|
+
return moduleCompat[moduleName][prop];
|
|
3454
|
+
}
|
|
1156
3455
|
if (!methodCache[prop]) {
|
|
1157
3456
|
methodCache[prop] = function deferredApiStub() {
|
|
1158
|
-
throw _unsupportedApiError(
|
|
3457
|
+
throw _unsupportedApiError(moduleName, prop);
|
|
1159
3458
|
};
|
|
1160
3459
|
}
|
|
1161
3460
|
return methodCache[prop];
|
|
@@ -1164,49 +3463,38 @@
|
|
|
1164
3463
|
return stub;
|
|
1165
3464
|
}
|
|
1166
3465
|
var __internalModuleCache = _moduleCache;
|
|
1167
|
-
var __require = function require2(
|
|
1168
|
-
return _requireFrom(
|
|
3466
|
+
var __require = function require2(moduleName) {
|
|
3467
|
+
return _requireFrom(moduleName, _currentModule.dirname);
|
|
1169
3468
|
};
|
|
1170
3469
|
__requireExposeCustomGlobal("require", __require);
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
const cacheKey2 = fromDir2 + "\0" + moduleName2;
|
|
1174
|
-
if (cacheKey2 in _resolveCache) {
|
|
1175
|
-
const cached = _resolveCache[cacheKey2];
|
|
1176
|
-
if (cached === null) {
|
|
1177
|
-
const err = new Error("Cannot find module '" + moduleName2 + "'");
|
|
1178
|
-
err.code = "MODULE_NOT_FOUND";
|
|
1179
|
-
throw err;
|
|
1180
|
-
}
|
|
1181
|
-
return cached;
|
|
1182
|
-
}
|
|
1183
|
-
let resolved2;
|
|
3470
|
+
function _resolveFrom(moduleName, fromDir) {
|
|
3471
|
+
var resolved;
|
|
1184
3472
|
if (typeof _resolveModuleSync !== "undefined") {
|
|
1185
|
-
|
|
1186
|
-
}
|
|
1187
|
-
|
|
3473
|
+
resolved = _resolveModuleSync.applySync(void 0, [moduleName, fromDir]);
|
|
3474
|
+
}
|
|
3475
|
+
if (resolved === null || resolved === void 0) {
|
|
3476
|
+
resolved = _resolveModule.applySyncPromise(void 0, [moduleName, fromDir, "require"]);
|
|
1188
3477
|
}
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
const err = new Error("Cannot find module '" + moduleName2 + "'");
|
|
3478
|
+
if (resolved === null) {
|
|
3479
|
+
const err = new Error("Cannot find module '" + moduleName + "'");
|
|
1192
3480
|
err.code = "MODULE_NOT_FOUND";
|
|
1193
3481
|
throw err;
|
|
1194
3482
|
}
|
|
1195
|
-
return
|
|
3483
|
+
return resolved;
|
|
1196
3484
|
}
|
|
1197
|
-
globalThis.require.resolve = function resolve(
|
|
1198
|
-
return _resolveFrom(
|
|
3485
|
+
globalThis.require.resolve = function resolve(moduleName) {
|
|
3486
|
+
return _resolveFrom(moduleName, _currentModule.dirname);
|
|
1199
3487
|
};
|
|
1200
|
-
function _debugRequire(phase,
|
|
3488
|
+
function _debugRequire(phase, moduleName, extra) {
|
|
1201
3489
|
if (globalThis.__sandboxRequireDebug !== true) {
|
|
1202
3490
|
return;
|
|
1203
3491
|
}
|
|
1204
|
-
if (
|
|
3492
|
+
if (moduleName !== "rivetkit" && moduleName !== "@rivetkit/traces" && moduleName !== "@rivetkit/on-change" && moduleName !== "async_hooks" && !moduleName.startsWith("rivetkit/") && !moduleName.startsWith("@rivetkit/")) {
|
|
1205
3493
|
return;
|
|
1206
3494
|
}
|
|
1207
3495
|
if (typeof console !== "undefined" && typeof console.log === "function") {
|
|
1208
3496
|
console.log(
|
|
1209
|
-
"[sandbox.require] " + phase + " " +
|
|
3497
|
+
"[sandbox.require] " + phase + " " + moduleName + (extra ? " " + extra : "")
|
|
1210
3498
|
);
|
|
1211
3499
|
}
|
|
1212
3500
|
}
|
|
@@ -1285,18 +3573,99 @@
|
|
|
1285
3573
|
_debugRequire("loaded", name, "stream-promises-special");
|
|
1286
3574
|
return promisesModule;
|
|
1287
3575
|
}
|
|
3576
|
+
if (name === "stream/consumers") {
|
|
3577
|
+
if (__internalModuleCache["stream/consumers"]) return __internalModuleCache["stream/consumers"];
|
|
3578
|
+
const consumersModule = {};
|
|
3579
|
+
consumersModule.buffer = async function buffer(stream) {
|
|
3580
|
+
const chunks = [];
|
|
3581
|
+
const pushChunk = function(chunk) {
|
|
3582
|
+
if (typeof chunk === "string") {
|
|
3583
|
+
chunks.push(Buffer.from(chunk));
|
|
3584
|
+
} else if (Buffer.isBuffer(chunk)) {
|
|
3585
|
+
chunks.push(chunk);
|
|
3586
|
+
} else if (ArrayBuffer.isView(chunk)) {
|
|
3587
|
+
chunks.push(Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength));
|
|
3588
|
+
} else if (chunk instanceof ArrayBuffer) {
|
|
3589
|
+
chunks.push(Buffer.from(new Uint8Array(chunk)));
|
|
3590
|
+
} else {
|
|
3591
|
+
chunks.push(Buffer.from(String(chunk)));
|
|
3592
|
+
}
|
|
3593
|
+
};
|
|
3594
|
+
if (stream && typeof stream[Symbol.asyncIterator] === "function") {
|
|
3595
|
+
for await (const chunk of stream) {
|
|
3596
|
+
pushChunk(chunk);
|
|
3597
|
+
}
|
|
3598
|
+
return Buffer.concat(chunks);
|
|
3599
|
+
}
|
|
3600
|
+
return new Promise(function(resolve2, reject) {
|
|
3601
|
+
stream.on("data", pushChunk);
|
|
3602
|
+
stream.on("end", function() {
|
|
3603
|
+
resolve2(Buffer.concat(chunks));
|
|
3604
|
+
});
|
|
3605
|
+
stream.on("error", reject);
|
|
3606
|
+
});
|
|
3607
|
+
};
|
|
3608
|
+
consumersModule.text = async function text(stream) {
|
|
3609
|
+
return (await consumersModule.buffer(stream)).toString("utf8");
|
|
3610
|
+
};
|
|
3611
|
+
consumersModule.json = async function json(stream) {
|
|
3612
|
+
return JSON.parse(await consumersModule.text(stream));
|
|
3613
|
+
};
|
|
3614
|
+
consumersModule.arrayBuffer = async function arrayBuffer(stream) {
|
|
3615
|
+
const buffer = await consumersModule.buffer(stream);
|
|
3616
|
+
return buffer.buffer.slice(
|
|
3617
|
+
buffer.byteOffset,
|
|
3618
|
+
buffer.byteOffset + buffer.byteLength
|
|
3619
|
+
);
|
|
3620
|
+
};
|
|
3621
|
+
__internalModuleCache["stream/consumers"] = consumersModule;
|
|
3622
|
+
_debugRequire("loaded", name, "stream-consumers-special");
|
|
3623
|
+
return consumersModule;
|
|
3624
|
+
}
|
|
1288
3625
|
if (name === "child_process") {
|
|
1289
3626
|
if (__internalModuleCache["child_process"]) return __internalModuleCache["child_process"];
|
|
1290
3627
|
__internalModuleCache["child_process"] = _childProcessModule;
|
|
1291
3628
|
_debugRequire("loaded", name, "child-process-special");
|
|
1292
3629
|
return _childProcessModule;
|
|
1293
3630
|
}
|
|
3631
|
+
if (name === "net") {
|
|
3632
|
+
if (__internalModuleCache["net"]) return __internalModuleCache["net"];
|
|
3633
|
+
__internalModuleCache["net"] = _netModule;
|
|
3634
|
+
_debugRequire("loaded", name, "net-special");
|
|
3635
|
+
return _netModule;
|
|
3636
|
+
}
|
|
3637
|
+
if (name === "tls") {
|
|
3638
|
+
if (__internalModuleCache["tls"]) return __internalModuleCache["tls"];
|
|
3639
|
+
__internalModuleCache["tls"] = _tlsModule;
|
|
3640
|
+
_debugRequire("loaded", name, "tls-special");
|
|
3641
|
+
return _tlsModule;
|
|
3642
|
+
}
|
|
1294
3643
|
if (name === "http") {
|
|
1295
3644
|
if (__internalModuleCache["http"]) return __internalModuleCache["http"];
|
|
1296
3645
|
__internalModuleCache["http"] = _httpModule;
|
|
1297
3646
|
_debugRequire("loaded", name, "http-special");
|
|
1298
3647
|
return _httpModule;
|
|
1299
3648
|
}
|
|
3649
|
+
if (name === "_http_agent") {
|
|
3650
|
+
if (__internalModuleCache["_http_agent"]) return __internalModuleCache["_http_agent"];
|
|
3651
|
+
const httpAgentModule = {
|
|
3652
|
+
Agent: _httpModule.Agent,
|
|
3653
|
+
globalAgent: _httpModule.globalAgent
|
|
3654
|
+
};
|
|
3655
|
+
__internalModuleCache["_http_agent"] = httpAgentModule;
|
|
3656
|
+
_debugRequire("loaded", name, "http-agent-special");
|
|
3657
|
+
return httpAgentModule;
|
|
3658
|
+
}
|
|
3659
|
+
if (name === "_http_common") {
|
|
3660
|
+
if (__internalModuleCache["_http_common"]) return __internalModuleCache["_http_common"];
|
|
3661
|
+
const httpCommonModule = {
|
|
3662
|
+
_checkIsHttpToken: _httpModule._checkIsHttpToken,
|
|
3663
|
+
_checkInvalidHeaderChar: _httpModule._checkInvalidHeaderChar
|
|
3664
|
+
};
|
|
3665
|
+
__internalModuleCache["_http_common"] = httpCommonModule;
|
|
3666
|
+
_debugRequire("loaded", name, "http-common-special");
|
|
3667
|
+
return httpCommonModule;
|
|
3668
|
+
}
|
|
1300
3669
|
if (name === "https") {
|
|
1301
3670
|
if (__internalModuleCache["https"]) return __internalModuleCache["https"];
|
|
1302
3671
|
__internalModuleCache["https"] = _httpsModule;
|
|
@@ -1309,23 +3678,35 @@
|
|
|
1309
3678
|
_debugRequire("loaded", name, "http2-special");
|
|
1310
3679
|
return _http2Module;
|
|
1311
3680
|
}
|
|
3681
|
+
if (name === "internal/http2/util") {
|
|
3682
|
+
if (__internalModuleCache[name]) return __internalModuleCache[name];
|
|
3683
|
+
const sharedNghttpError = _http2Module?.NghttpError;
|
|
3684
|
+
const NghttpError = typeof sharedNghttpError === "function" ? sharedNghttpError : class NghttpError extends Error {
|
|
3685
|
+
constructor(message) {
|
|
3686
|
+
super(message);
|
|
3687
|
+
this.name = "Error";
|
|
3688
|
+
this.code = "ERR_HTTP2_ERROR";
|
|
3689
|
+
}
|
|
3690
|
+
};
|
|
3691
|
+
const utilModule = {
|
|
3692
|
+
kSocket: /* @__PURE__ */ Symbol.for("secure-exec.http2.kSocket"),
|
|
3693
|
+
NghttpError
|
|
3694
|
+
};
|
|
3695
|
+
__internalModuleCache[name] = utilModule;
|
|
3696
|
+
_debugRequire("loaded", name, "http2-util-special");
|
|
3697
|
+
return utilModule;
|
|
3698
|
+
}
|
|
1312
3699
|
if (name === "dns") {
|
|
1313
3700
|
if (__internalModuleCache["dns"]) return __internalModuleCache["dns"];
|
|
1314
3701
|
__internalModuleCache["dns"] = _dnsModule;
|
|
1315
3702
|
_debugRequire("loaded", name, "dns-special");
|
|
1316
3703
|
return _dnsModule;
|
|
1317
3704
|
}
|
|
1318
|
-
if (name === "
|
|
1319
|
-
if (__internalModuleCache["
|
|
1320
|
-
__internalModuleCache["
|
|
1321
|
-
_debugRequire("loaded", name, "
|
|
1322
|
-
return
|
|
1323
|
-
}
|
|
1324
|
-
if (name === "tls") {
|
|
1325
|
-
if (__internalModuleCache["tls"]) return __internalModuleCache["tls"];
|
|
1326
|
-
__internalModuleCache["tls"] = _tlsModule;
|
|
1327
|
-
_debugRequire("loaded", name, "tls-special");
|
|
1328
|
-
return _tlsModule;
|
|
3705
|
+
if (name === "dgram") {
|
|
3706
|
+
if (__internalModuleCache["dgram"]) return __internalModuleCache["dgram"];
|
|
3707
|
+
__internalModuleCache["dgram"] = _dgramModule;
|
|
3708
|
+
_debugRequire("loaded", name, "dgram-special");
|
|
3709
|
+
return _dgramModule;
|
|
1329
3710
|
}
|
|
1330
3711
|
if (name === "os") {
|
|
1331
3712
|
if (__internalModuleCache["os"]) return __internalModuleCache["os"];
|
|
@@ -1343,6 +3724,13 @@
|
|
|
1343
3724
|
_debugRequire("loaded", name, "process-special");
|
|
1344
3725
|
return globalThis.process;
|
|
1345
3726
|
}
|
|
3727
|
+
if (name === "v8") {
|
|
3728
|
+
if (__internalModuleCache["v8"]) return __internalModuleCache["v8"];
|
|
3729
|
+
const v8Module = globalThis._moduleCache?.v8 || {};
|
|
3730
|
+
__internalModuleCache["v8"] = v8Module;
|
|
3731
|
+
_debugRequire("loaded", name, "v8-special");
|
|
3732
|
+
return v8Module;
|
|
3733
|
+
}
|
|
1346
3734
|
if (name === "async_hooks") {
|
|
1347
3735
|
if (__internalModuleCache["async_hooks"]) return __internalModuleCache["async_hooks"];
|
|
1348
3736
|
class AsyncLocalStorage {
|
|
@@ -1483,17 +3871,12 @@
|
|
|
1483
3871
|
if (_unsupportedCoreModules.has(name)) {
|
|
1484
3872
|
throw new Error(name + " is not supported in sandbox");
|
|
1485
3873
|
}
|
|
1486
|
-
|
|
1487
|
-
_debugRequire("name-cache-hit", name, name);
|
|
1488
|
-
return __internalModuleCache[name];
|
|
1489
|
-
}
|
|
1490
|
-
const isPath = name[0] === "." || name[0] === "/";
|
|
1491
|
-
const polyfillCode = isPath ? null : _loadPolyfill.applySyncPromise(void 0, [name]);
|
|
3874
|
+
const polyfillCode = _loadPolyfill.applySyncPromise(void 0, [name]);
|
|
1492
3875
|
if (polyfillCode !== null) {
|
|
1493
3876
|
if (__internalModuleCache[name]) return __internalModuleCache[name];
|
|
1494
3877
|
const moduleObj = { exports: {} };
|
|
1495
3878
|
_pendingModules[name] = moduleObj;
|
|
1496
|
-
let result =
|
|
3879
|
+
let result = Function('"use strict"; return (' + polyfillCode + ");")();
|
|
1497
3880
|
result = _patchPolyfill(name, result);
|
|
1498
3881
|
if (typeof result === "object" && result !== null) {
|
|
1499
3882
|
Object.assign(moduleObj.exports, result);
|
|
@@ -1505,14 +3888,6 @@
|
|
|
1505
3888
|
_debugRequire("loaded", name, "polyfill");
|
|
1506
3889
|
return __internalModuleCache[name];
|
|
1507
3890
|
}
|
|
1508
|
-
const resolveCacheKey = fromDir + "\0" + name;
|
|
1509
|
-
if (resolveCacheKey in _resolveCache) {
|
|
1510
|
-
const cachedPath = _resolveCache[resolveCacheKey];
|
|
1511
|
-
if (cachedPath !== null && __internalModuleCache[cachedPath]) {
|
|
1512
|
-
_debugRequire("resolve-cache-hit", name, cachedPath);
|
|
1513
|
-
return __internalModuleCache[cachedPath];
|
|
1514
|
-
}
|
|
1515
|
-
}
|
|
1516
3891
|
resolved = _resolveFrom(name, fromDir);
|
|
1517
3892
|
cacheKey = resolved;
|
|
1518
3893
|
if (__internalModuleCache[cacheKey]) {
|
|
@@ -1523,11 +3898,12 @@
|
|
|
1523
3898
|
_debugRequire("pending-hit", name, cacheKey);
|
|
1524
3899
|
return _pendingModules[cacheKey].exports;
|
|
1525
3900
|
}
|
|
1526
|
-
|
|
3901
|
+
var source;
|
|
1527
3902
|
if (typeof _loadFileSync !== "undefined") {
|
|
1528
3903
|
source = _loadFileSync.applySync(void 0, [resolved]);
|
|
1529
|
-
}
|
|
1530
|
-
|
|
3904
|
+
}
|
|
3905
|
+
if (source === null || source === void 0) {
|
|
3906
|
+
source = _loadFile.applySyncPromise(void 0, [resolved, "require"]);
|
|
1531
3907
|
}
|
|
1532
3908
|
if (source === null) {
|
|
1533
3909
|
const err = new Error("Cannot find module '" + resolved + "'");
|
|
@@ -1539,7 +3915,6 @@
|
|
|
1539
3915
|
__internalModuleCache[cacheKey] = parsed;
|
|
1540
3916
|
return parsed;
|
|
1541
3917
|
}
|
|
1542
|
-
const normalizedSource = typeof source === "string" ? source.replace(/import\.meta\.url/g, "__filename").replace(/fileURLToPath\(__filename\)/g, "__filename").replace(/url\.fileURLToPath\(__filename\)/g, "__filename").replace(/fileURLToPath\.call\(void 0, __filename\)/g, "__filename") : source;
|
|
1543
3918
|
const module = {
|
|
1544
3919
|
exports: {},
|
|
1545
3920
|
filename: resolved,
|
|
@@ -1552,15 +3927,17 @@
|
|
|
1552
3927
|
_currentModule = module;
|
|
1553
3928
|
try {
|
|
1554
3929
|
let wrapper;
|
|
3930
|
+
const isRequireTransformedEsm = typeof source === "string" && source.startsWith(REQUIRE_TRANSFORM_MARKER);
|
|
3931
|
+
const wrapperPrologue = isRequireTransformedEsm ? "" : "var __filename = __secureExecFilename;\nvar __dirname = __secureExecDirname;\n";
|
|
1555
3932
|
try {
|
|
1556
3933
|
wrapper = new Function(
|
|
1557
3934
|
"exports",
|
|
1558
3935
|
"require",
|
|
1559
3936
|
"module",
|
|
1560
|
-
"
|
|
1561
|
-
"
|
|
3937
|
+
"__secureExecFilename",
|
|
3938
|
+
"__secureExecDirname",
|
|
1562
3939
|
"__dynamicImport",
|
|
1563
|
-
|
|
3940
|
+
wrapperPrologue + source + "\n//# sourceURL=" + resolved
|
|
1564
3941
|
);
|
|
1565
3942
|
} catch (error) {
|
|
1566
3943
|
const details = error && error.stack ? error.stack : String(error);
|
|
@@ -1594,9 +3971,6 @@
|
|
|
1594
3971
|
_currentModule = prevModule;
|
|
1595
3972
|
}
|
|
1596
3973
|
__internalModuleCache[cacheKey] = module.exports;
|
|
1597
|
-
if (!isPath && name !== cacheKey) {
|
|
1598
|
-
__internalModuleCache[name] = module.exports;
|
|
1599
|
-
}
|
|
1600
3974
|
delete _pendingModules[cacheKey];
|
|
1601
3975
|
_debugRequire("loaded", name, cacheKey);
|
|
1602
3976
|
return module.exports;
|