@secure-exec/nodejs 0.2.0-rc.1
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/LICENSE +191 -0
- package/README.md +7 -0
- package/dist/bindings.d.ts +31 -0
- package/dist/bindings.js +67 -0
- package/dist/bridge/active-handles.d.ts +22 -0
- package/dist/bridge/active-handles.js +112 -0
- package/dist/bridge/child-process.d.ts +99 -0
- package/dist/bridge/child-process.js +672 -0
- package/dist/bridge/dispatch.d.ts +2 -0
- package/dist/bridge/dispatch.js +40 -0
- package/dist/bridge/fs.d.ts +502 -0
- package/dist/bridge/fs.js +3307 -0
- package/dist/bridge/index.d.ts +10 -0
- package/dist/bridge/index.js +41 -0
- package/dist/bridge/module.d.ts +75 -0
- package/dist/bridge/module.js +325 -0
- package/dist/bridge/network.d.ts +1093 -0
- package/dist/bridge/network.js +8651 -0
- package/dist/bridge/os.d.ts +13 -0
- package/dist/bridge/os.js +256 -0
- package/dist/bridge/polyfills.d.ts +9 -0
- package/dist/bridge/polyfills.js +67 -0
- package/dist/bridge/process.d.ts +121 -0
- package/dist/bridge/process.js +1382 -0
- package/dist/bridge/whatwg-url.d.ts +67 -0
- package/dist/bridge/whatwg-url.js +712 -0
- package/dist/bridge-contract.d.ts +774 -0
- package/dist/bridge-contract.js +172 -0
- package/dist/bridge-handlers.d.ts +199 -0
- package/dist/bridge-handlers.js +4263 -0
- package/dist/bridge-loader.d.ts +9 -0
- package/dist/bridge-loader.js +87 -0
- package/dist/bridge-setup.d.ts +1 -0
- package/dist/bridge-setup.js +3 -0
- package/dist/bridge.js +21652 -0
- package/dist/builtin-modules.d.ts +25 -0
- package/dist/builtin-modules.js +312 -0
- package/dist/default-network-adapter.d.ts +13 -0
- package/dist/default-network-adapter.js +351 -0
- package/dist/driver.d.ts +87 -0
- package/dist/driver.js +191 -0
- package/dist/esm-compiler.d.ts +14 -0
- package/dist/esm-compiler.js +68 -0
- package/dist/execution-driver.d.ts +37 -0
- package/dist/execution-driver.js +977 -0
- package/dist/host-network-adapter.d.ts +7 -0
- package/dist/host-network-adapter.js +279 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +23 -0
- package/dist/isolate-bootstrap.d.ts +86 -0
- package/dist/isolate-bootstrap.js +125 -0
- package/dist/ivm-compat.d.ts +7 -0
- package/dist/ivm-compat.js +31 -0
- package/dist/kernel-runtime.d.ts +58 -0
- package/dist/kernel-runtime.js +535 -0
- package/dist/module-access.d.ts +75 -0
- package/dist/module-access.js +606 -0
- package/dist/module-resolver.d.ts +8 -0
- package/dist/module-resolver.js +150 -0
- package/dist/os-filesystem.d.ts +42 -0
- package/dist/os-filesystem.js +161 -0
- package/dist/package-bundler.d.ts +36 -0
- package/dist/package-bundler.js +497 -0
- package/dist/polyfills.d.ts +17 -0
- package/dist/polyfills.js +97 -0
- package/dist/worker-adapter.d.ts +21 -0
- package/dist/worker-adapter.js +34 -0
- package/package.json +123 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type * as nodeOs from "os";
|
|
2
|
+
export interface OSConfig {
|
|
3
|
+
platform?: string;
|
|
4
|
+
arch?: string;
|
|
5
|
+
type?: string;
|
|
6
|
+
release?: string;
|
|
7
|
+
version?: string;
|
|
8
|
+
homedir?: string;
|
|
9
|
+
tmpdir?: string;
|
|
10
|
+
hostname?: string;
|
|
11
|
+
}
|
|
12
|
+
declare const os: typeof nodeOs;
|
|
13
|
+
export default os;
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
// OS module polyfill for the sandbox
|
|
2
|
+
// Provides Node.js os module emulation for sandbox compatibility
|
|
3
|
+
import { exposeCustomGlobal } from "@secure-exec/core/internal/shared/global-exposure";
|
|
4
|
+
// Get config with defaults
|
|
5
|
+
const config = {
|
|
6
|
+
platform: (typeof _osConfig !== "undefined" && _osConfig.platform) || "linux",
|
|
7
|
+
arch: (typeof _osConfig !== "undefined" && _osConfig.arch) || "x64",
|
|
8
|
+
type: (typeof _osConfig !== "undefined" && _osConfig.type) || "Linux",
|
|
9
|
+
release: (typeof _osConfig !== "undefined" && _osConfig.release) || "5.15.0",
|
|
10
|
+
version: (typeof _osConfig !== "undefined" && _osConfig.version) || "#1 SMP",
|
|
11
|
+
homedir: (typeof _osConfig !== "undefined" && _osConfig.homedir) || "/root",
|
|
12
|
+
tmpdir: (typeof _osConfig !== "undefined" && _osConfig.tmpdir) || "/tmp",
|
|
13
|
+
hostname: (typeof _osConfig !== "undefined" && _osConfig.hostname) || "sandbox",
|
|
14
|
+
};
|
|
15
|
+
// Signal constants (subset — sandbox only emulates Linux signals)
|
|
16
|
+
const signals = {
|
|
17
|
+
SIGHUP: 1,
|
|
18
|
+
SIGINT: 2,
|
|
19
|
+
SIGQUIT: 3,
|
|
20
|
+
SIGILL: 4,
|
|
21
|
+
SIGTRAP: 5,
|
|
22
|
+
SIGABRT: 6,
|
|
23
|
+
SIGIOT: 6,
|
|
24
|
+
SIGBUS: 7,
|
|
25
|
+
SIGFPE: 8,
|
|
26
|
+
SIGKILL: 9,
|
|
27
|
+
SIGUSR1: 10,
|
|
28
|
+
SIGSEGV: 11,
|
|
29
|
+
SIGUSR2: 12,
|
|
30
|
+
SIGPIPE: 13,
|
|
31
|
+
SIGALRM: 14,
|
|
32
|
+
SIGTERM: 15,
|
|
33
|
+
SIGSTKFLT: 16,
|
|
34
|
+
SIGCHLD: 17,
|
|
35
|
+
SIGCONT: 18,
|
|
36
|
+
SIGSTOP: 19,
|
|
37
|
+
SIGTSTP: 20,
|
|
38
|
+
SIGTTIN: 21,
|
|
39
|
+
SIGTTOU: 22,
|
|
40
|
+
SIGURG: 23,
|
|
41
|
+
SIGXCPU: 24,
|
|
42
|
+
SIGXFSZ: 25,
|
|
43
|
+
SIGVTALRM: 26,
|
|
44
|
+
SIGPROF: 27,
|
|
45
|
+
SIGWINCH: 28,
|
|
46
|
+
SIGIO: 29,
|
|
47
|
+
SIGPOLL: 29,
|
|
48
|
+
SIGPWR: 30,
|
|
49
|
+
SIGSYS: 31,
|
|
50
|
+
};
|
|
51
|
+
// Errno constants
|
|
52
|
+
const errno = {
|
|
53
|
+
E2BIG: 7,
|
|
54
|
+
EACCES: 13,
|
|
55
|
+
EADDRINUSE: 98,
|
|
56
|
+
EADDRNOTAVAIL: 99,
|
|
57
|
+
EAFNOSUPPORT: 97,
|
|
58
|
+
EAGAIN: 11,
|
|
59
|
+
EALREADY: 114,
|
|
60
|
+
EBADF: 9,
|
|
61
|
+
EBADMSG: 74,
|
|
62
|
+
EBUSY: 16,
|
|
63
|
+
ECANCELED: 125,
|
|
64
|
+
ECHILD: 10,
|
|
65
|
+
ECONNABORTED: 103,
|
|
66
|
+
ECONNREFUSED: 111,
|
|
67
|
+
ECONNRESET: 104,
|
|
68
|
+
EDEADLK: 35,
|
|
69
|
+
EDESTADDRREQ: 89,
|
|
70
|
+
EDOM: 33,
|
|
71
|
+
EDQUOT: 122,
|
|
72
|
+
EEXIST: 17,
|
|
73
|
+
EFAULT: 14,
|
|
74
|
+
EFBIG: 27,
|
|
75
|
+
EHOSTUNREACH: 113,
|
|
76
|
+
EIDRM: 43,
|
|
77
|
+
EILSEQ: 84,
|
|
78
|
+
EINPROGRESS: 115,
|
|
79
|
+
EINTR: 4,
|
|
80
|
+
EINVAL: 22,
|
|
81
|
+
EIO: 5,
|
|
82
|
+
EISCONN: 106,
|
|
83
|
+
EISDIR: 21,
|
|
84
|
+
ELOOP: 40,
|
|
85
|
+
EMFILE: 24,
|
|
86
|
+
EMLINK: 31,
|
|
87
|
+
EMSGSIZE: 90,
|
|
88
|
+
EMULTIHOP: 72,
|
|
89
|
+
ENAMETOOLONG: 36,
|
|
90
|
+
ENETDOWN: 100,
|
|
91
|
+
ENETRESET: 102,
|
|
92
|
+
ENETUNREACH: 101,
|
|
93
|
+
ENFILE: 23,
|
|
94
|
+
ENOBUFS: 105,
|
|
95
|
+
ENODATA: 61,
|
|
96
|
+
ENODEV: 19,
|
|
97
|
+
ENOENT: 2,
|
|
98
|
+
ENOEXEC: 8,
|
|
99
|
+
ENOLCK: 37,
|
|
100
|
+
ENOLINK: 67,
|
|
101
|
+
ENOMEM: 12,
|
|
102
|
+
ENOMSG: 42,
|
|
103
|
+
ENOPROTOOPT: 92,
|
|
104
|
+
ENOSPC: 28,
|
|
105
|
+
ENOSR: 63,
|
|
106
|
+
ENOSTR: 60,
|
|
107
|
+
ENOSYS: 38,
|
|
108
|
+
ENOTCONN: 107,
|
|
109
|
+
ENOTDIR: 20,
|
|
110
|
+
ENOTEMPTY: 39,
|
|
111
|
+
ENOTSOCK: 88,
|
|
112
|
+
ENOTSUP: 95,
|
|
113
|
+
ENOTTY: 25,
|
|
114
|
+
ENXIO: 6,
|
|
115
|
+
EOPNOTSUPP: 95,
|
|
116
|
+
EOVERFLOW: 75,
|
|
117
|
+
EPERM: 1,
|
|
118
|
+
EPIPE: 32,
|
|
119
|
+
EPROTO: 71,
|
|
120
|
+
EPROTONOSUPPORT: 93,
|
|
121
|
+
EPROTOTYPE: 91,
|
|
122
|
+
ERANGE: 34,
|
|
123
|
+
EROFS: 30,
|
|
124
|
+
ESPIPE: 29,
|
|
125
|
+
ESRCH: 3,
|
|
126
|
+
ESTALE: 116,
|
|
127
|
+
ETIME: 62,
|
|
128
|
+
ETIMEDOUT: 110,
|
|
129
|
+
ETXTBSY: 26,
|
|
130
|
+
EWOULDBLOCK: 11,
|
|
131
|
+
EXDEV: 18,
|
|
132
|
+
};
|
|
133
|
+
// Priority constants
|
|
134
|
+
const priority = {
|
|
135
|
+
PRIORITY_LOW: 19,
|
|
136
|
+
PRIORITY_BELOW_NORMAL: 10,
|
|
137
|
+
PRIORITY_NORMAL: 0,
|
|
138
|
+
PRIORITY_ABOVE_NORMAL: -7,
|
|
139
|
+
PRIORITY_HIGH: -14,
|
|
140
|
+
PRIORITY_HIGHEST: -20,
|
|
141
|
+
};
|
|
142
|
+
// OS module implementation (polyfill — partial coverage of Node.js os types)
|
|
143
|
+
const os = {
|
|
144
|
+
// Platform information
|
|
145
|
+
platform() {
|
|
146
|
+
return config.platform;
|
|
147
|
+
},
|
|
148
|
+
arch() {
|
|
149
|
+
return config.arch;
|
|
150
|
+
},
|
|
151
|
+
type() {
|
|
152
|
+
return config.type;
|
|
153
|
+
},
|
|
154
|
+
release() {
|
|
155
|
+
return config.release;
|
|
156
|
+
},
|
|
157
|
+
version() {
|
|
158
|
+
return config.version;
|
|
159
|
+
},
|
|
160
|
+
// Directory information
|
|
161
|
+
homedir() {
|
|
162
|
+
return config.homedir;
|
|
163
|
+
},
|
|
164
|
+
tmpdir() {
|
|
165
|
+
return config.tmpdir;
|
|
166
|
+
},
|
|
167
|
+
// System information
|
|
168
|
+
hostname() {
|
|
169
|
+
return config.hostname;
|
|
170
|
+
},
|
|
171
|
+
// User information
|
|
172
|
+
userInfo(_options) {
|
|
173
|
+
return {
|
|
174
|
+
username: "root",
|
|
175
|
+
uid: 0,
|
|
176
|
+
gid: 0,
|
|
177
|
+
shell: "/bin/bash",
|
|
178
|
+
homedir: config.homedir,
|
|
179
|
+
};
|
|
180
|
+
},
|
|
181
|
+
// CPU information
|
|
182
|
+
cpus() {
|
|
183
|
+
return [
|
|
184
|
+
{
|
|
185
|
+
model: "Virtual CPU",
|
|
186
|
+
speed: 2000,
|
|
187
|
+
times: {
|
|
188
|
+
user: 100000,
|
|
189
|
+
nice: 0,
|
|
190
|
+
sys: 50000,
|
|
191
|
+
idle: 800000,
|
|
192
|
+
irq: 0,
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
];
|
|
196
|
+
},
|
|
197
|
+
// Memory information
|
|
198
|
+
totalmem() {
|
|
199
|
+
return 1073741824; // 1GB
|
|
200
|
+
},
|
|
201
|
+
freemem() {
|
|
202
|
+
return 536870912; // 512MB
|
|
203
|
+
},
|
|
204
|
+
// System load
|
|
205
|
+
loadavg() {
|
|
206
|
+
return [0.1, 0.1, 0.1];
|
|
207
|
+
},
|
|
208
|
+
// System uptime
|
|
209
|
+
uptime() {
|
|
210
|
+
return 3600; // 1 hour
|
|
211
|
+
},
|
|
212
|
+
// Network interfaces (empty - not supported in sandbox)
|
|
213
|
+
networkInterfaces() {
|
|
214
|
+
return {};
|
|
215
|
+
},
|
|
216
|
+
// System endianness
|
|
217
|
+
endianness() {
|
|
218
|
+
return "LE";
|
|
219
|
+
},
|
|
220
|
+
// Line endings
|
|
221
|
+
EOL: "\n",
|
|
222
|
+
// Dev null path
|
|
223
|
+
devNull: "/dev/null",
|
|
224
|
+
// Machine type
|
|
225
|
+
machine() {
|
|
226
|
+
return config.arch;
|
|
227
|
+
},
|
|
228
|
+
// Constants (partial — Linux subset, no Windows WSA* or RTLD_DEEPBIND)
|
|
229
|
+
constants: {
|
|
230
|
+
signals: signals,
|
|
231
|
+
errno: errno,
|
|
232
|
+
priority,
|
|
233
|
+
dlopen: {
|
|
234
|
+
RTLD_LAZY: 1,
|
|
235
|
+
RTLD_NOW: 2,
|
|
236
|
+
RTLD_GLOBAL: 256,
|
|
237
|
+
RTLD_LOCAL: 0,
|
|
238
|
+
},
|
|
239
|
+
UV_UDP_REUSEADDR: 4,
|
|
240
|
+
},
|
|
241
|
+
// Priority getters/setters (stubs)
|
|
242
|
+
getPriority(_pid) {
|
|
243
|
+
return 0;
|
|
244
|
+
},
|
|
245
|
+
setPriority(pid, priority) {
|
|
246
|
+
void pid;
|
|
247
|
+
void priority;
|
|
248
|
+
},
|
|
249
|
+
// Parallelism hint
|
|
250
|
+
availableParallelism() {
|
|
251
|
+
return 1;
|
|
252
|
+
},
|
|
253
|
+
};
|
|
254
|
+
// Expose to global for require() to use.
|
|
255
|
+
exposeCustomGlobal("_osModule", os);
|
|
256
|
+
export default os;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Early polyfills - this file must be imported FIRST before any other modules
|
|
2
|
+
// that might use TextEncoder/TextDecoder (like whatwg-url)
|
|
3
|
+
import { TextDecoder as PolyfillTextDecoder, } from "text-encoding-utf-8";
|
|
4
|
+
function encodeUtf8ScalarValue(codePoint, bytes) {
|
|
5
|
+
if (codePoint <= 0x7f) {
|
|
6
|
+
bytes.push(codePoint);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (codePoint <= 0x7ff) {
|
|
10
|
+
bytes.push(0xc0 | (codePoint >> 6), 0x80 | (codePoint & 0x3f));
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (codePoint <= 0xffff) {
|
|
14
|
+
bytes.push(0xe0 | (codePoint >> 12), 0x80 | ((codePoint >> 6) & 0x3f), 0x80 | (codePoint & 0x3f));
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
bytes.push(0xf0 | (codePoint >> 18), 0x80 | ((codePoint >> 12) & 0x3f), 0x80 | ((codePoint >> 6) & 0x3f), 0x80 | (codePoint & 0x3f));
|
|
18
|
+
}
|
|
19
|
+
function encodeUtf8(input = "") {
|
|
20
|
+
const value = String(input);
|
|
21
|
+
const bytes = [];
|
|
22
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
23
|
+
const codeUnit = value.charCodeAt(index);
|
|
24
|
+
if (codeUnit >= 0xd800 && codeUnit <= 0xdbff) {
|
|
25
|
+
const nextIndex = index + 1;
|
|
26
|
+
if (nextIndex < value.length) {
|
|
27
|
+
const nextCodeUnit = value.charCodeAt(nextIndex);
|
|
28
|
+
if (nextCodeUnit >= 0xdc00 && nextCodeUnit <= 0xdfff) {
|
|
29
|
+
const codePoint = 0x10000 + ((codeUnit - 0xd800) << 10) + (nextCodeUnit - 0xdc00);
|
|
30
|
+
encodeUtf8ScalarValue(codePoint, bytes);
|
|
31
|
+
index = nextIndex;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
encodeUtf8ScalarValue(0xfffd, bytes);
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (codeUnit >= 0xdc00 && codeUnit <= 0xdfff) {
|
|
39
|
+
encodeUtf8ScalarValue(0xfffd, bytes);
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
encodeUtf8ScalarValue(codeUnit, bytes);
|
|
43
|
+
}
|
|
44
|
+
return new Uint8Array(bytes);
|
|
45
|
+
}
|
|
46
|
+
class PatchedTextEncoder {
|
|
47
|
+
encode(input = "") {
|
|
48
|
+
return encodeUtf8(input);
|
|
49
|
+
}
|
|
50
|
+
get encoding() {
|
|
51
|
+
return "utf-8";
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const TextEncoder = typeof globalThis.TextEncoder === "function"
|
|
55
|
+
? globalThis.TextEncoder
|
|
56
|
+
: PatchedTextEncoder;
|
|
57
|
+
const TextDecoder = typeof globalThis.TextDecoder === "function"
|
|
58
|
+
? globalThis.TextDecoder
|
|
59
|
+
: PolyfillTextDecoder;
|
|
60
|
+
// Install on globalThis so other modules can use them
|
|
61
|
+
if (typeof globalThis.TextEncoder === "undefined") {
|
|
62
|
+
globalThis.TextEncoder = TextEncoder;
|
|
63
|
+
}
|
|
64
|
+
if (typeof globalThis.TextDecoder === "undefined") {
|
|
65
|
+
globalThis.TextDecoder = TextDecoder;
|
|
66
|
+
}
|
|
67
|
+
export { TextEncoder, TextDecoder };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type * as nodeProcess from "process";
|
|
2
|
+
import { TextEncoder, TextDecoder } from "./polyfills.js";
|
|
3
|
+
import { URL, URLSearchParams } from "./whatwg-url.js";
|
|
4
|
+
/**
|
|
5
|
+
* Process configuration injected by the host before the bridge bundle loads.
|
|
6
|
+
* Values default to sensible Linux/x64 stubs when unset.
|
|
7
|
+
*/
|
|
8
|
+
export interface ProcessConfig {
|
|
9
|
+
platform?: string;
|
|
10
|
+
arch?: string;
|
|
11
|
+
version?: string;
|
|
12
|
+
cwd?: string;
|
|
13
|
+
env?: Record<string, string>;
|
|
14
|
+
argv?: string[];
|
|
15
|
+
execPath?: string;
|
|
16
|
+
pid?: number;
|
|
17
|
+
ppid?: number;
|
|
18
|
+
uid?: number;
|
|
19
|
+
gid?: number;
|
|
20
|
+
stdin?: string;
|
|
21
|
+
timingMitigation?: "off" | "freeze";
|
|
22
|
+
frozenTimeMs?: number;
|
|
23
|
+
stdinIsTTY?: boolean;
|
|
24
|
+
stdoutIsTTY?: boolean;
|
|
25
|
+
stderrIsTTY?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Thrown by `process.exit()` to unwind the sandbox call stack. The host
|
|
29
|
+
* catches this to extract the exit code without killing the isolate.
|
|
30
|
+
*/
|
|
31
|
+
export declare class ProcessExitError extends Error {
|
|
32
|
+
code: number;
|
|
33
|
+
constructor(code: number);
|
|
34
|
+
}
|
|
35
|
+
declare const _default: typeof nodeProcess;
|
|
36
|
+
export default _default;
|
|
37
|
+
/**
|
|
38
|
+
* Timer handle that mimics Node.js Timeout (ref/unref/Symbol.toPrimitive).
|
|
39
|
+
* Timers with delay > 0 use the host's `_scheduleTimer` bridge to sleep
|
|
40
|
+
* without blocking the isolate's event loop.
|
|
41
|
+
*/
|
|
42
|
+
declare class TimerHandle {
|
|
43
|
+
_id: number;
|
|
44
|
+
_destroyed: boolean;
|
|
45
|
+
constructor(id: number);
|
|
46
|
+
ref(): this;
|
|
47
|
+
unref(): this;
|
|
48
|
+
hasRef(): boolean;
|
|
49
|
+
refresh(): this;
|
|
50
|
+
[Symbol.toPrimitive](): number;
|
|
51
|
+
}
|
|
52
|
+
export declare function setTimeout(callback: (...args: unknown[]) => void, delay?: number, ...args: unknown[]): TimerHandle;
|
|
53
|
+
export declare function clearTimeout(timer: TimerHandle | number | undefined): void;
|
|
54
|
+
export declare function setInterval(callback: (...args: unknown[]) => void, delay?: number, ...args: unknown[]): TimerHandle;
|
|
55
|
+
export declare function clearInterval(timer: TimerHandle | number | undefined): void;
|
|
56
|
+
export declare function setImmediate(callback: (...args: unknown[]) => void, ...args: unknown[]): TimerHandle;
|
|
57
|
+
export declare function clearImmediate(id: TimerHandle | number | undefined): void;
|
|
58
|
+
export { URL, URLSearchParams };
|
|
59
|
+
export { TextEncoder, TextDecoder };
|
|
60
|
+
export declare const Buffer: BufferConstructor;
|
|
61
|
+
interface SandboxCryptoKeyData {
|
|
62
|
+
type: "public" | "private" | "secret";
|
|
63
|
+
extractable: boolean;
|
|
64
|
+
algorithm: Record<string, unknown>;
|
|
65
|
+
usages: string[];
|
|
66
|
+
_pem?: string;
|
|
67
|
+
_jwk?: Record<string, unknown>;
|
|
68
|
+
_raw?: string;
|
|
69
|
+
_sourceKeyObjectData?: Record<string, unknown>;
|
|
70
|
+
}
|
|
71
|
+
declare const kCryptoKeyToken: unique symbol;
|
|
72
|
+
declare class SandboxCryptoKey {
|
|
73
|
+
readonly type: "public" | "private" | "secret";
|
|
74
|
+
readonly extractable: boolean;
|
|
75
|
+
readonly algorithm: Record<string, unknown>;
|
|
76
|
+
readonly usages: string[];
|
|
77
|
+
readonly _keyData: SandboxCryptoKeyData;
|
|
78
|
+
readonly _pem?: string;
|
|
79
|
+
readonly _jwk?: Record<string, unknown>;
|
|
80
|
+
readonly _raw?: string;
|
|
81
|
+
readonly _sourceKeyObjectData?: Record<string, unknown>;
|
|
82
|
+
readonly [kCryptoKeyToken]: true;
|
|
83
|
+
constructor(keyData?: SandboxCryptoKeyData, token?: symbol);
|
|
84
|
+
}
|
|
85
|
+
declare class SandboxSubtleCrypto {
|
|
86
|
+
readonly _token: symbol;
|
|
87
|
+
constructor(token?: symbol);
|
|
88
|
+
digest(algorithm: unknown, data: BufferSource): Promise<ArrayBuffer>;
|
|
89
|
+
generateKey(algorithm: unknown, extractable: boolean, keyUsages: Iterable<string>): Promise<SandboxCryptoKey | {
|
|
90
|
+
publicKey: SandboxCryptoKey;
|
|
91
|
+
privateKey: SandboxCryptoKey;
|
|
92
|
+
}>;
|
|
93
|
+
importKey(format: string, keyData: BufferSource | JsonWebKey, algorithm: unknown, extractable: boolean, keyUsages: Iterable<string>): Promise<SandboxCryptoKey>;
|
|
94
|
+
exportKey(format: string, key: SandboxCryptoKey): Promise<ArrayBuffer | JsonWebKey>;
|
|
95
|
+
encrypt(algorithm: unknown, key: SandboxCryptoKey, data: BufferSource): Promise<ArrayBuffer>;
|
|
96
|
+
decrypt(algorithm: unknown, key: SandboxCryptoKey, data: BufferSource): Promise<ArrayBuffer>;
|
|
97
|
+
sign(algorithm: unknown, key: SandboxCryptoKey, data: BufferSource): Promise<ArrayBuffer>;
|
|
98
|
+
verify(algorithm: unknown, key: SandboxCryptoKey, signature: BufferSource, data: BufferSource): Promise<boolean>;
|
|
99
|
+
deriveBits(algorithm: unknown, baseKey: SandboxCryptoKey, length: number): Promise<ArrayBuffer>;
|
|
100
|
+
deriveKey(algorithm: unknown, baseKey: SandboxCryptoKey, derivedKeyAlgorithm: unknown, extractable: boolean, keyUsages: Iterable<string>): Promise<SandboxCryptoKey>;
|
|
101
|
+
wrapKey(format: string, key: SandboxCryptoKey, wrappingKey: SandboxCryptoKey, wrapAlgorithm: unknown): Promise<ArrayBuffer>;
|
|
102
|
+
unwrapKey(format: string, wrappedKey: BufferSource, unwrappingKey: SandboxCryptoKey, unwrapAlgorithm: unknown, unwrappedKeyAlgorithm: unknown, extractable: boolean, keyUsages: Iterable<string>): Promise<SandboxCryptoKey>;
|
|
103
|
+
}
|
|
104
|
+
declare class SandboxCrypto {
|
|
105
|
+
readonly _token: symbol;
|
|
106
|
+
constructor(token?: symbol);
|
|
107
|
+
get subtle(): SandboxSubtleCrypto;
|
|
108
|
+
getRandomValues<T extends ArrayBufferView>(array: T): T;
|
|
109
|
+
randomUUID(): string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Crypto polyfill that delegates to the host for entropy. `getRandomValues`
|
|
113
|
+
* calls the host's `_cryptoRandomFill` bridge to get cryptographically secure
|
|
114
|
+
* random bytes. Subtle crypto operations route through the host WebCrypto bridge.
|
|
115
|
+
*/
|
|
116
|
+
export declare const cryptoPolyfill: SandboxCrypto;
|
|
117
|
+
/**
|
|
118
|
+
* Install all process/timer/URL/Buffer/crypto polyfills onto `globalThis`.
|
|
119
|
+
* Called once during bridge initialization before user code runs.
|
|
120
|
+
*/
|
|
121
|
+
export declare function setupGlobals(): void;
|