@serveryyswys/node.operit 0.0.0-stage → 0.1.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.
Files changed (123) hide show
  1. package/BUILTINS.json +233 -0
  2. package/DESIGN.md +513 -0
  3. package/LICENSE +674 -0
  4. package/README.md +301 -2
  5. package/dist/assert/strict.d.ts +2 -0
  6. package/dist/assert/strict.js +7 -0
  7. package/dist/assert.d.ts +3 -0
  8. package/dist/assert.js +483 -0
  9. package/dist/buffer.d.ts +60 -0
  10. package/dist/buffer.js +524 -0
  11. package/dist/child_process.d.ts +56 -0
  12. package/dist/child_process.js +371 -0
  13. package/dist/constants.d.ts +2 -0
  14. package/dist/constants.js +19 -0
  15. package/dist/crypto.d.ts +76 -0
  16. package/dist/crypto.js +312 -0
  17. package/dist/dns/promises.d.ts +34 -0
  18. package/dist/dns/promises.js +190 -0
  19. package/dist/dns.d.ts +88 -0
  20. package/dist/dns.js +259 -0
  21. package/dist/events.d.ts +40 -0
  22. package/dist/events.js +237 -0
  23. package/dist/fs/promises.d.ts +159 -0
  24. package/dist/fs/promises.js +129 -0
  25. package/dist/fs.d.ts +221 -0
  26. package/dist/fs.js +944 -0
  27. package/dist/http.d.ts +92 -0
  28. package/dist/http.js +319 -0
  29. package/dist/https.d.ts +296 -0
  30. package/dist/https.js +50 -0
  31. package/dist/index.d.ts +2422 -0
  32. package/dist/index.js +57 -0
  33. package/dist/lib/bridge.d.ts +60 -0
  34. package/dist/lib/bridge.js +205 -0
  35. package/dist/lib/bytes.d.ts +20 -0
  36. package/dist/lib/bytes.js +239 -0
  37. package/dist/lib/child-process-types.d.ts +45 -0
  38. package/dist/lib/child-process-types.js +2 -0
  39. package/dist/lib/cwd.d.ts +2 -0
  40. package/dist/lib/cwd.js +32 -0
  41. package/dist/lib/deep-equal.d.ts +3 -0
  42. package/dist/lib/deep-equal.js +223 -0
  43. package/dist/lib/deflate.d.ts +2 -0
  44. package/dist/lib/deflate.js +234 -0
  45. package/dist/lib/dns-driver.d.ts +14 -0
  46. package/dist/lib/dns-driver.js +85 -0
  47. package/dist/lib/dns-types.d.ts +22 -0
  48. package/dist/lib/dns-types.js +2 -0
  49. package/dist/lib/errors.d.ts +48 -0
  50. package/dist/lib/errors.js +424 -0
  51. package/dist/lib/fs-driver.d.ts +70 -0
  52. package/dist/lib/fs-driver.js +364 -0
  53. package/dist/lib/fs-env.d.ts +30 -0
  54. package/dist/lib/fs-env.js +157 -0
  55. package/dist/lib/fs-types.d.ts +19 -0
  56. package/dist/lib/fs-types.js +2 -0
  57. package/dist/lib/hashes.d.ts +27 -0
  58. package/dist/lib/hashes.js +432 -0
  59. package/dist/lib/http-driver.d.ts +30 -0
  60. package/dist/lib/http-driver.js +72 -0
  61. package/dist/lib/http-types.d.ts +18 -0
  62. package/dist/lib/http-types.js +2 -0
  63. package/dist/lib/inflate.d.ts +6 -0
  64. package/dist/lib/inflate.js +284 -0
  65. package/dist/lib/path-types.d.ts +37 -0
  66. package/dist/lib/path-types.js +2 -0
  67. package/dist/lib/paths.d.ts +8 -0
  68. package/dist/lib/paths.js +106 -0
  69. package/dist/lib/perf-hooks-types.d.ts +18 -0
  70. package/dist/lib/perf-hooks-types.js +2 -0
  71. package/dist/lib/process-driver.d.ts +31 -0
  72. package/dist/lib/process-driver.js +102 -0
  73. package/dist/lib/punycode.d.ts +8 -0
  74. package/dist/lib/punycode.js +179 -0
  75. package/dist/lib/stream-types.d.ts +29 -0
  76. package/dist/lib/stream-types.js +2 -0
  77. package/dist/lib/timers-types.d.ts +18 -0
  78. package/dist/lib/timers-types.js +2 -0
  79. package/dist/lib/url-search-params.d.ts +26 -0
  80. package/dist/lib/url-search-params.js +281 -0
  81. package/dist/lib/url-types.d.ts +44 -0
  82. package/dist/lib/url-types.js +2 -0
  83. package/dist/lib/url-whatwg.d.ts +78 -0
  84. package/dist/lib/url-whatwg.js +857 -0
  85. package/dist/lib/zlib-types.d.ts +12 -0
  86. package/dist/lib/zlib-types.js +2 -0
  87. package/dist/module.d.ts +8 -0
  88. package/dist/module.js +72 -0
  89. package/dist/os.d.ts +80 -0
  90. package/dist/os.js +247 -0
  91. package/dist/path/posix.d.ts +2 -0
  92. package/dist/path/posix.js +7 -0
  93. package/dist/path/win32.d.ts +2 -0
  94. package/dist/path/win32.js +10 -0
  95. package/dist/path.d.ts +3 -0
  96. package/dist/path.js +1222 -0
  97. package/dist/perf_hooks.d.ts +36 -0
  98. package/dist/perf_hooks.js +144 -0
  99. package/dist/process.d.ts +69 -0
  100. package/dist/process.js +230 -0
  101. package/dist/querystring.d.ts +15 -0
  102. package/dist/querystring.js +209 -0
  103. package/dist/stream/promises.d.ts +5 -0
  104. package/dist/stream/promises.js +10 -0
  105. package/dist/stream.d.ts +84 -0
  106. package/dist/stream.js +875 -0
  107. package/dist/string_decoder.d.ts +15 -0
  108. package/dist/string_decoder.js +237 -0
  109. package/dist/timers/promises.d.ts +19 -0
  110. package/dist/timers/promises.js +74 -0
  111. package/dist/timers.d.ts +21 -0
  112. package/dist/timers.js +41 -0
  113. package/dist/tty.d.ts +9 -0
  114. package/dist/tty.js +25 -0
  115. package/dist/unsupported.d.ts +12 -0
  116. package/dist/unsupported.js +17 -0
  117. package/dist/url.d.ts +28 -0
  118. package/dist/url.js +486 -0
  119. package/dist/util.d.ts +74 -0
  120. package/dist/util.js +515 -0
  121. package/dist/zlib.d.ts +88 -0
  122. package/dist/zlib.js +371 -0
  123. package/package.json +29 -4
@@ -0,0 +1,371 @@
1
+ 'use strict';
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ /**
36
+ * Node child_process 模块的移植。
37
+ *
38
+ * 覆盖:exec / execSync / execFile / execFileSync / spawn / spawnSync,
39
+ * ChildProcess 的 spawn/exit/close/error 事件与 stdout/stderr/stdin、pid、exitCode、kill。
40
+ * 不覆盖:fork(需要 Node 运行时本身)。
41
+ *
42
+ * 时序上的重要差异:宿主只有 Java bridge 这一条同步通道,
43
+ * 所以 spawn 是「先同步跑完、再异步发事件」—— 接口是异步的,执行是同步的,
44
+ * 拿不到真正的并发与背压。需要真并发请用终端工具(Tools 层)。
45
+ *
46
+ * 输出按 UTF-8 解码(驱动层的选择,见 lib/process-driver.ts),二进制输出会有损。
47
+ */
48
+ const EventEmitter = require("./events");
49
+ const streamModule = require("./stream");
50
+ const buffer_1 = require("./buffer");
51
+ const driverModule = __importStar(require("./lib/process-driver"));
52
+ const errors_1 = require("./lib/errors");
53
+ /** Operit 上的 shell;exec 与 shell:true 都走它。 */
54
+ const SHELL = '/system/bin/sh';
55
+ const DEFAULT_MAX_BUFFER = 1024 * 1024;
56
+ function schedule(task) {
57
+ queueMicrotask(task);
58
+ }
59
+ function run(argv, options) {
60
+ let raw;
61
+ try {
62
+ raw = driverModule.getDriver().run(argv, {
63
+ cwd: options.cwd,
64
+ env: options.env
65
+ });
66
+ }
67
+ catch (failure) {
68
+ const mapped = failure;
69
+ const spawnError = (0, errors_1.createError)(mapped.code === undefined ? 'EIO' : mapped.code, 'spawn', argv[0]);
70
+ spawnError.message = mapped.message === undefined ? spawnError.message : mapped.message;
71
+ spawnError.errno = mapped.errno === undefined ? -1 : mapped.errno;
72
+ return {
73
+ pid: 0,
74
+ status: null,
75
+ signal: null,
76
+ stdout: buffer_1.Buffer.alloc(0),
77
+ stderr: buffer_1.Buffer.alloc(0),
78
+ error: spawnError
79
+ };
80
+ }
81
+ return {
82
+ pid: raw.pid,
83
+ status: raw.status,
84
+ signal: null,
85
+ stdout: buffer_1.Buffer.from(raw.stdout, 'utf8'),
86
+ stderr: buffer_1.Buffer.from(raw.stderr, 'utf8')
87
+ };
88
+ }
89
+ function asText(buffer, encoding) {
90
+ if (encoding === undefined || encoding === 'buffer') {
91
+ return buffer;
92
+ }
93
+ return buffer.toString(encoding);
94
+ }
95
+ function maxBufferFailure(outcome) {
96
+ const error = new Error('stdout maxBuffer length exceeded');
97
+ error.code = 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER';
98
+ error.status = outcome.status;
99
+ error.signal = outcome.signal;
100
+ error.stdout = outcome.stdout;
101
+ error.stderr = outcome.stderr;
102
+ return error;
103
+ }
104
+ function commandFailed(command, outcome, cwd) {
105
+ const prefix = cwd === undefined ? '' : cwd + '\n';
106
+ const error = new Error(prefix + 'Command failed: ' + command + '\n' + outcome.stderr.toString('utf8'));
107
+ error.status = outcome.status;
108
+ error.signal = outcome.signal;
109
+ error.stdout = outcome.stdout;
110
+ error.stderr = outcome.stderr;
111
+ error.pid = outcome.pid;
112
+ return error;
113
+ }
114
+ function exceedsMaxBuffer(outcome, options) {
115
+ const limit = options.maxBuffer === undefined ? DEFAULT_MAX_BUFFER : options.maxBuffer;
116
+ return outcome.stdout.length > limit || outcome.stderr.length > limit;
117
+ }
118
+ /** 同步执行并返回 stdout;失败按 Node 语义抛异常。 */
119
+ function runSync(command, argv, options) {
120
+ const outcome = run(argv, options);
121
+ if (outcome.error !== undefined) {
122
+ throw outcome.error;
123
+ }
124
+ if (exceedsMaxBuffer(outcome, options)) {
125
+ throw maxBufferFailure(outcome);
126
+ }
127
+ if (outcome.status !== 0) {
128
+ throw commandFailed(command, outcome, options.cwd);
129
+ }
130
+ return asText(outcome.stdout, options.encoding);
131
+ }
132
+ function shellArgv(command) {
133
+ return [SHELL, '-c', command];
134
+ }
135
+ function execSync(command, options) {
136
+ const text = String(command);
137
+ return runSync(text, shellArgv(text), options === undefined ? {} : options);
138
+ }
139
+ function execFileSync(file, args, options) {
140
+ let list = [];
141
+ let opts = options;
142
+ if (Array.isArray(args)) {
143
+ list = args.map(function (item) { return String(item); });
144
+ }
145
+ else if (args !== undefined && args !== null) {
146
+ opts = args;
147
+ }
148
+ const target = String(file);
149
+ return runSync(target, [target].concat(list), opts === undefined ? {} : opts);
150
+ }
151
+ function spawnSync(command, args, options) {
152
+ let list = [];
153
+ let opts = {};
154
+ if (Array.isArray(args)) {
155
+ list = args.map(function (item) { return String(item); });
156
+ if (options !== undefined && options !== null) {
157
+ opts = options;
158
+ }
159
+ }
160
+ else if (args !== undefined && args !== null) {
161
+ opts = args;
162
+ }
163
+ const useShell = opts.shell !== undefined && opts.shell !== false;
164
+ const target = String(command);
165
+ const argv = useShell
166
+ ? shellArgv([target].concat(list).join(' '))
167
+ : [target].concat(list);
168
+ const outcome = run(argv, opts);
169
+ const stdout = asText(outcome.stdout, opts.encoding);
170
+ const stderr = asText(outcome.stderr, opts.encoding);
171
+ const result = {
172
+ pid: outcome.pid,
173
+ output: [null, stdout, stderr],
174
+ stdout: stdout,
175
+ stderr: stderr,
176
+ status: outcome.status,
177
+ signal: outcome.signal
178
+ };
179
+ if (outcome.error !== undefined) {
180
+ result.error = outcome.error;
181
+ }
182
+ return result;
183
+ }
184
+ function readStreamOf(buffer) {
185
+ const pending = buffer.length > 0 ? [buffer] : [];
186
+ return new streamModule.Readable({
187
+ read: function () {
188
+ const self = this;
189
+ if (pending.length > 0) {
190
+ self.push(pending.shift());
191
+ return;
192
+ }
193
+ self.push(null);
194
+ }
195
+ });
196
+ }
197
+ function sinkStream() {
198
+ return new streamModule.Writable({
199
+ write: function (chunk, encoding, callback) {
200
+ void chunk;
201
+ void encoding;
202
+ callback(null);
203
+ }
204
+ });
205
+ }
206
+ class ChildProcess extends EventEmitter {
207
+ constructor(argv, outcome) {
208
+ super();
209
+ this.killed = false;
210
+ if (outcome.error !== undefined) {
211
+ this.spawnError = outcome.error;
212
+ }
213
+ this.spawnfile = argv[0];
214
+ this.spawnargs = argv.slice();
215
+ this.pid = outcome.pid;
216
+ this.exitCode = outcome.status;
217
+ this.signalCode = outcome.signal;
218
+ this.stdout = readStreamOf(outcome.stdout);
219
+ this.stderr = readStreamOf(outcome.stderr);
220
+ this.stdin = sinkStream();
221
+ schedule(() => {
222
+ if (outcome.error !== undefined) {
223
+ this.emit('error', outcome.error);
224
+ this.emit('close', null, null);
225
+ return;
226
+ }
227
+ this.emit('spawn');
228
+ this.emit('exit', outcome.status, outcome.signal);
229
+ this.emit('close', outcome.status, outcome.signal);
230
+ });
231
+ }
232
+ /** 进程在本实现里已经跑完了,所以 kill 总是返回 false。 */
233
+ kill() {
234
+ return false;
235
+ }
236
+ ref() {
237
+ return this;
238
+ }
239
+ unref() {
240
+ return this;
241
+ }
242
+ }
243
+ function spawnOf(argv, opts) {
244
+ return new ChildProcess(argv, run(argv, opts));
245
+ }
246
+ function exec(command, options, callback) {
247
+ let opts = {};
248
+ let done = callback;
249
+ if (typeof options === 'function') {
250
+ done = options;
251
+ }
252
+ else if (options !== undefined && options !== null) {
253
+ opts = options;
254
+ }
255
+ if (typeof done !== 'function') {
256
+ throw new TypeError('The "callback" argument must be of type function.');
257
+ }
258
+ const text = String(command);
259
+ const child = spawnOf(shellArgv(text), opts);
260
+ // 与 spawn 的事件时序一致:同步跑完,异步回调
261
+ schedule(function () {
262
+ collect(text, child, opts, done);
263
+ });
264
+ return child;
265
+ }
266
+ /**
267
+ * 从已经跑完的 child 上取回输出并按 Node 语义决定是否报错。
268
+ * 本实现是同步执行完再发事件,所以这里直接读 exitCode 与 spawnError 即可。
269
+ */
270
+ function collect(command, child, opts, callback) {
271
+ const stdout = readBuffered(child.stdout);
272
+ const stderr = readBuffered(child.stderr);
273
+ if (child.spawnError !== undefined) {
274
+ callback(child.spawnError, asText(stdout, opts.encoding), asText(stderr, opts.encoding));
275
+ return;
276
+ }
277
+ const limit = opts.maxBuffer === undefined ? DEFAULT_MAX_BUFFER : opts.maxBuffer;
278
+ if (stdout.length > limit || stderr.length > limit) {
279
+ callback(maxBufferFailure({
280
+ pid: child.pid,
281
+ status: child.exitCode,
282
+ signal: child.signalCode,
283
+ stdout: stdout,
284
+ stderr: stderr
285
+ }), asText(stdout, opts.encoding), asText(stderr, opts.encoding));
286
+ return;
287
+ }
288
+ if (child.exitCode !== 0) {
289
+ callback(commandFailed(command, {
290
+ pid: child.pid,
291
+ status: child.exitCode,
292
+ signal: child.signalCode,
293
+ stdout: stdout,
294
+ stderr: stderr
295
+ }, opts.cwd), asText(stdout, opts.encoding), asText(stderr, opts.encoding));
296
+ return;
297
+ }
298
+ callback(null, asText(stdout, opts.encoding), asText(stderr, opts.encoding));
299
+ }
300
+ /** Readable 已经把整块数据 push 进去了,这里同步取回。 */
301
+ function readBuffered(stream) {
302
+ const target = stream;
303
+ const value = target.read();
304
+ if (value === null || value === undefined) {
305
+ return buffer_1.Buffer.alloc(0);
306
+ }
307
+ return buffer_1.Buffer.from(value);
308
+ }
309
+ function execFile(file, args, options, callback) {
310
+ let list = [];
311
+ let opts = {};
312
+ let done = callback;
313
+ if (Array.isArray(args)) {
314
+ list = args.map(function (item) { return String(item); });
315
+ if (typeof options === 'function') {
316
+ done = options;
317
+ }
318
+ else if (options !== undefined && options !== null) {
319
+ opts = options;
320
+ }
321
+ }
322
+ else if (typeof args === 'function') {
323
+ done = args;
324
+ }
325
+ else if (args !== undefined && args !== null) {
326
+ opts = args;
327
+ if (typeof options === 'function') {
328
+ done = options;
329
+ }
330
+ }
331
+ if (typeof done !== 'function') {
332
+ throw new TypeError('The "callback" argument must be of type function.');
333
+ }
334
+ const target = String(file);
335
+ const child = spawnOf([target].concat(list), opts);
336
+ schedule(function () {
337
+ collect(target, child, opts, done);
338
+ });
339
+ return child;
340
+ }
341
+ function spawn(command, args, options) {
342
+ let list = [];
343
+ let opts = {};
344
+ if (Array.isArray(args)) {
345
+ list = args.map(function (item) { return String(item); });
346
+ if (options !== undefined && options !== null) {
347
+ opts = options;
348
+ }
349
+ }
350
+ else if (args !== undefined && args !== null) {
351
+ opts = args;
352
+ }
353
+ const target = String(command);
354
+ const useShell = opts.shell !== undefined && opts.shell !== false;
355
+ const argv = useShell ? shellArgv([target].concat(list).join(' ')) : [target].concat(list);
356
+ return spawnOf(argv, opts);
357
+ }
358
+ function fork() {
359
+ throw (0, errors_1.onjError)('ONJ_UNSUPPORTED', 'child_process.fork() 需要 Node 运行时本身,node.operit 不提供。');
360
+ }
361
+ const childProcess = {
362
+ exec: exec,
363
+ execSync: execSync,
364
+ execFile: execFile,
365
+ execFileSync: execFileSync,
366
+ spawn: spawn,
367
+ spawnSync: spawnSync,
368
+ fork: fork,
369
+ ChildProcess: ChildProcess
370
+ };
371
+ module.exports = childProcess;
@@ -0,0 +1,2 @@
1
+ declare const constants: Record<string, number>;
2
+ export = constants;
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+ /**
3
+ * constants 模块(Node 的遗留模块)。
4
+ *
5
+ * Node 把它做成 fs / crypto / os / zlib 四处常量的合并,并且把 os.constants 的
6
+ * signals / errno / priority 摊平到顶层(所以 require('constants').EACCES 是 13)。
7
+ * 这里照做。
8
+ *
9
+ * 注意平台:给出的是 **Linux/Android** 的数值,与 Node 在 Windows 上给的那一套
10
+ * (WSA* 等)不同。本库面向前者。
11
+ */
12
+ const fsModule = require("./fs");
13
+ const osModule = require("./os");
14
+ const zlibModule = require("./zlib");
15
+ const cryptoModule = require("./crypto");
16
+ const osConstants = osModule.constants;
17
+ // 类型写成 Record<string, number>:直接导出合并结果会让 .d.ts 引用各处不可命名的推断类型
18
+ const constants = Object.assign({}, fsModule.constants, cryptoModule.constants, zlibModule.constants, osConstants.signals, osConstants.errno, osConstants.priority, osConstants.dlopen, { UV_UDP_REUSEADDR: osConstants.UV_UDP_REUSEADDR });
19
+ module.exports = constants;
@@ -0,0 +1,76 @@
1
+ import { Buffer } from './buffer';
2
+ import type { HashSpec } from './lib/hashes';
3
+ declare class Hash {
4
+ readonly spec: HashSpec;
5
+ chunks: Uint8Array[];
6
+ total: number;
7
+ finalized: boolean;
8
+ constructor(algorithm: string);
9
+ update(data: unknown, inputEncoding?: string): this;
10
+ digest(encoding?: string): string | Buffer;
11
+ copy(): Hash;
12
+ }
13
+ declare class Hmac {
14
+ readonly spec: HashSpec;
15
+ readonly key: Uint8Array;
16
+ chunks: Uint8Array[];
17
+ total: number;
18
+ finalized: boolean;
19
+ constructor(algorithm: string, key: unknown, keyEncoding?: string);
20
+ update(data: unknown, inputEncoding?: string): this;
21
+ digest(encoding?: string): string | Buffer;
22
+ }
23
+ declare function createHash(algorithm: string, options?: {
24
+ outputLength?: number;
25
+ }): Hash;
26
+ declare function createHmac(algorithm: string, key: unknown, options?: {
27
+ encoding?: string;
28
+ }): Hmac;
29
+ declare function randomBytes(size: number, callback?: (error: Error | null, buffer: Buffer) => void): Buffer | void;
30
+ declare function randomFillSync(buffer: Uint8Array): Uint8Array;
31
+ declare function randomUUID(): string;
32
+ declare function randomInt(min: number, max?: number | ((error: Error | null, value: number) => void), callback?: (error: Error | null, value: number) => void): number | void;
33
+ declare function timingSafeEqual(left: unknown, right: unknown): boolean;
34
+ declare function pbkdf2Sync(password: unknown, salt: unknown, iterations: number, keylen: number, digest: string): Buffer;
35
+ declare function pbkdf2(password: unknown, salt: unknown, iterations: number, keylen: number, digest: string, callback: (error: Error | null, derivedKey: Buffer) => void): void;
36
+ declare function getHashes(): string[];
37
+ declare function getCiphers(): string[];
38
+ declare function createCipheriv(): never;
39
+ declare function createDecipheriv(): never;
40
+ declare function createSign(): never;
41
+ declare function createVerify(): never;
42
+ declare function generateKeyPairSync(): never;
43
+ declare function createDiffieHellman(): never;
44
+ declare const crypto: {
45
+ createHash: typeof createHash;
46
+ createHmac: typeof createHmac;
47
+ randomBytes: typeof randomBytes;
48
+ randomFillSync: typeof randomFillSync;
49
+ randomUUID: typeof randomUUID;
50
+ randomInt: typeof randomInt;
51
+ timingSafeEqual: typeof timingSafeEqual;
52
+ pbkdf2Sync: typeof pbkdf2Sync;
53
+ pbkdf2: typeof pbkdf2;
54
+ getHashes: typeof getHashes;
55
+ getCiphers: typeof getCiphers;
56
+ createCipheriv: typeof createCipheriv;
57
+ createDecipheriv: typeof createDecipheriv;
58
+ createSign: typeof createSign;
59
+ createVerify: typeof createVerify;
60
+ generateKeyPairSync: typeof generateKeyPairSync;
61
+ createDiffieHellman: typeof createDiffieHellman;
62
+ constants: {
63
+ RSA_PKCS1_PADDING: number;
64
+ RSA_NO_PADDING: number;
65
+ RSA_PKCS1_OAEP_PADDING: number;
66
+ RSA_X931_PADDING: number;
67
+ RSA_PKCS1_PSS_PADDING: number;
68
+ SSL_OP_ALL: number;
69
+ SSL_OP_NO_SSLv2: number;
70
+ SSL_OP_NO_SSLv3: number;
71
+ SSL_OP_NO_TLSv1: number;
72
+ };
73
+ Hash: typeof Hash;
74
+ Hmac: typeof Hmac;
75
+ };
76
+ export = crypto;