@volter/tabnode 0.4.1 → 0.5.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/dist/__sw__.js +259 -5
- package/dist/assets/{runtime-worker-LWfW6VWE.js → runtime-worker-DBZ2flHK.js} +4000 -2944
- package/dist/fetch-transport.d.ts +20 -0
- package/dist/guest-timers.d.ts +15 -0
- package/dist/http-client-transport.d.ts +19 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.mjs +5196 -3062
- package/dist/native-stream-binding.d.ts +57 -0
- package/dist/native-stream-owner.d.ts +121 -0
- package/dist/node-lib/binding/duplex_stream.d.ts +26 -0
- package/dist/node-lib/binding/fds.d.ts +8 -0
- package/dist/node-lib/binding/fs.d.ts +311 -78
- package/dist/node-lib/binding/misc.d.ts +1 -0
- package/dist/node-lib/binding/pipe_wrap.d.ts +4 -4
- package/dist/node-lib/binding/process_wrap.d.ts +12 -1
- package/dist/node-lib/binding/stream_wrap.d.ts +27 -18
- package/dist/node-lib/binding/tcp_wrap.d.ts +0 -1
- package/dist/node-lib/binding/tty_wrap.d.ts +43 -2
- package/dist/node-lib/binding/util.d.ts +83 -0
- package/dist/node-lib/binding/uv.d.ts +4 -0
- package/dist/node-lib/fs-module.d.ts +1 -0
- package/dist/node-lib/internals/buffer-and-streams.d.ts +30 -17
- package/dist/node-lib/internals/index.d.ts +1 -1
- package/dist/node-lib/load.d.ts +17 -3
- package/dist/node-lib/module-hooks.d.ts +1 -0
- package/dist/node-lib/public-modules.d.ts +1 -1
- package/dist/node-lib/timers.d.ts +38 -0
- package/dist/node-process-host.d.ts +41 -0
- package/dist/process-registry.d.ts +39 -0
- package/dist/process-tokens.d.ts +11 -0
- package/dist/promise-ownership.d.ts +3 -0
- package/dist/runtime.d.ts +10 -9
- package/dist/shims/child_process.d.ts +2 -0
- package/dist/shims/crypto.d.ts +660 -119
- package/dist/shims/dns.d.ts +76 -2
- package/dist/shims/process.d.ts +1 -0
- package/dist/shims/string_decoder.d.ts +19 -3
- package/dist/shims/tls.d.ts +853 -31
- package/dist/source-edits.d.ts +7 -0
- package/package.json +1 -1
- package/src/code-transforms.ts +2 -3
- package/src/fetch-transport.ts +98 -0
- package/src/guest-timers.ts +89 -0
- package/src/http-client-transport.ts +169 -0
- package/src/index.ts +18 -0
- package/src/native-stream-binding.ts +393 -0
- package/src/native-stream-owner.ts +317 -0
- package/src/node-lib/binding/duplex_stream.ts +95 -0
- package/src/node-lib/binding/fds.ts +18 -1
- package/src/node-lib/binding/fs.ts +45 -17
- package/src/node-lib/binding/misc.ts +2 -0
- package/src/node-lib/binding/pipe_wrap.ts +35 -12
- package/src/node-lib/binding/process_wrap.ts +50 -9
- package/src/node-lib/binding/stream_wrap.ts +196 -72
- package/src/node-lib/binding/tcp_wrap.ts +43 -8
- package/src/node-lib/binding/tty_wrap.ts +135 -8
- package/src/node-lib/binding/util.ts +24 -15
- package/src/node-lib/binding/uv.ts +4 -0
- package/src/node-lib/fs-module.ts +2 -18
- package/src/node-lib/internal/navigator.js +149 -0
- package/src/node-lib/internals/buffer-and-streams.ts +50 -11
- package/src/node-lib/internals/events-util.ts +5 -0
- package/src/node-lib/internals/index.ts +12 -2
- package/src/node-lib/load.ts +170 -62
- package/src/node-lib/module-hooks.ts +5 -2
- package/src/node-lib/public-modules.ts +12 -48
- package/src/node-lib/sources.ts +4 -0
- package/src/node-lib/timers.ts +93 -0
- package/src/node-process-host.ts +124 -0
- package/src/process-registry.ts +144 -0
- package/src/process-tokens.ts +55 -6
- package/src/promise-ownership.ts +28 -0
- package/src/runtime.ts +90 -214
- package/src/shims/child_process.ts +310 -80
- package/src/shims/crypto.ts +115 -100
- package/src/shims/dns.ts +17 -1
- package/src/shims/process.ts +33 -11
- package/src/shims/string_decoder.ts +10 -6
- package/src/shims/tls.ts +49 -19
- package/src/source-edits.ts +20 -0
|
@@ -33,10 +33,6 @@ interface BufferClass {
|
|
|
33
33
|
from(value: unknown, offset?: unknown, length?: number): Buffer;
|
|
34
34
|
alloc(size: number): Buffer;
|
|
35
35
|
}
|
|
36
|
-
let bufferClass: BufferClass | undefined;
|
|
37
|
-
function Bytes(): BufferClass {
|
|
38
|
-
return bufferClass ??= (loadNodeLib('buffer') as { Buffer: BufferClass }).Buffer;
|
|
39
|
-
}
|
|
40
36
|
import {
|
|
41
37
|
ERR_INVALID_ARG_TYPE,
|
|
42
38
|
ERR_INVALID_THIS,
|
|
@@ -66,6 +62,8 @@ interface StringDecoderConstructor {
|
|
|
66
62
|
prototype: StringDecoder;
|
|
67
63
|
}
|
|
68
64
|
|
|
65
|
+
/** A decoder's constructors and held bytes belong to one builtin graph. */
|
|
66
|
+
export function createStringDecoderModule(Bytes: () => BufferClass) {
|
|
69
67
|
/** lib/internal/util.js normalizeEncoding, with Node's aliases. */
|
|
70
68
|
const kEncodingAliases: Record<string, string> = {
|
|
71
69
|
utf8: 'utf8', 'utf-8': 'utf8',
|
|
@@ -391,6 +389,12 @@ decoderPrototype.fillLast = function fillLast(this: unknown, buf: Buffer): strin
|
|
|
391
389
|
return undefined;
|
|
392
390
|
};
|
|
393
391
|
|
|
394
|
-
|
|
392
|
+
const StringDecoder = StringDecoderImpl as unknown as StringDecoderConstructor;
|
|
393
|
+
|
|
394
|
+
return { StringDecoder };
|
|
395
395
|
|
|
396
|
-
|
|
396
|
+
}
|
|
397
|
+
let bufferClass: BufferClass | undefined;
|
|
398
|
+
const decoder = createStringDecoderModule(() => bufferClass ??= (loadNodeLib('buffer') as { Buffer: BufferClass }).Buffer);
|
|
399
|
+
export const StringDecoder = decoder.StringDecoder;
|
|
400
|
+
export default decoder;
|
package/src/shims/tls.ts
CHANGED
|
@@ -1,16 +1,40 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* tls shim - TLS/SSL is not available in browser
|
|
3
|
-
*
|
|
3
|
+
* No TLS transport is installed. A connection must fail asynchronously rather
|
|
4
|
+
* than pretending to connect and leaving Node's HTTPS client waiting forever.
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
7
|
import { EventEmitter } from '../node-lib/events-module';
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
import { lazyExport } from '../node-lib/lazy';
|
|
9
|
+
import type { Socket } from '../node-lib/net-module';
|
|
10
|
+
|
|
11
|
+
// Keep the ordinary stream lifecycle (error, close, destroy) from Node's own
|
|
12
|
+
// Socket. Resolve it lazily, like the other builtin classes, to avoid a loader
|
|
13
|
+
// cycle while the engine is being imported.
|
|
14
|
+
/** Native TLS refusal keeps the requesting graph's Socket identity. */
|
|
15
|
+
export function createTlsModule(require?: (name: string) => any) {
|
|
16
|
+
const NetSocket = require ? require('net').Socket as new (options?: object) => Socket
|
|
17
|
+
: lazyExport<new (options?: object) => Socket>('net', 'Socket');
|
|
18
|
+
const Events = require ? require('events').EventEmitter as typeof EventEmitter : EventEmitter;
|
|
19
|
+
|
|
20
|
+
class TLSSocket extends NetSocket {
|
|
9
21
|
authorized = false;
|
|
10
22
|
encrypted = true;
|
|
11
23
|
|
|
12
24
|
constructor(_socket?: unknown, _options?: unknown) {
|
|
13
|
-
super();
|
|
25
|
+
super({ allowHalfOpen: false });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
connect(..._args: unknown[]): this {
|
|
29
|
+
this.connecting = true;
|
|
30
|
+
// Never inherit a plain TCP connect while advertising an encrypted socket.
|
|
31
|
+
// Agent assigns its socket on nextTick after connect returns, so failure
|
|
32
|
+
// follows that assignment and reaches ClientRequest's error listener.
|
|
33
|
+
queueMicrotask(() => queueMicrotask(() => this.destroy(Object.assign(
|
|
34
|
+
new Error('TLS transport is unavailable in this runtime; HTTPS requires an admitted HTTP transport.'),
|
|
35
|
+
{ code: 'ERR_TLS_UNAVAILABLE' },
|
|
36
|
+
))));
|
|
37
|
+
return this;
|
|
14
38
|
}
|
|
15
39
|
|
|
16
40
|
getPeerCertificate(_detailed?: boolean): object {
|
|
@@ -32,7 +56,7 @@ export class TLSSocket extends EventEmitter {
|
|
|
32
56
|
}
|
|
33
57
|
}
|
|
34
58
|
|
|
35
|
-
|
|
59
|
+
class Server extends Events {
|
|
36
60
|
constructor(_options?: unknown, _connectionListener?: (socket: TLSSocket) => void) {
|
|
37
61
|
super();
|
|
38
62
|
}
|
|
@@ -50,7 +74,7 @@ export class Server extends EventEmitter {
|
|
|
50
74
|
}
|
|
51
75
|
|
|
52
76
|
getTicketKeys(): Buffer {
|
|
53
|
-
return Buffer.from('');
|
|
77
|
+
return (require ? require('buffer').Buffer : Buffer).from('');
|
|
54
78
|
}
|
|
55
79
|
|
|
56
80
|
setTicketKeys(_keys: Buffer): void {}
|
|
@@ -58,29 +82,27 @@ export class Server extends EventEmitter {
|
|
|
58
82
|
setSecureContext(_options: unknown): void {}
|
|
59
83
|
}
|
|
60
84
|
|
|
61
|
-
|
|
85
|
+
function createServer(_options?: unknown, _connectionListener?: (socket: TLSSocket) => void): Server {
|
|
62
86
|
return new Server(_options, _connectionListener);
|
|
63
87
|
}
|
|
64
88
|
|
|
65
|
-
|
|
89
|
+
function connect(_options: unknown, _callback?: () => void): TLSSocket {
|
|
66
90
|
const socket = new TLSSocket();
|
|
67
|
-
if (_callback)
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
return socket;
|
|
91
|
+
if (_callback) socket.once('secureConnect', _callback);
|
|
92
|
+
return socket.connect();
|
|
71
93
|
}
|
|
72
94
|
|
|
73
|
-
|
|
95
|
+
const createSecureContext = (_options?: unknown) => ({});
|
|
74
96
|
|
|
75
|
-
|
|
97
|
+
const getCiphers = () => ['TLS_AES_256_GCM_SHA384', 'TLS_AES_128_GCM_SHA256'];
|
|
76
98
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
99
|
+
const DEFAULT_ECDH_CURVE = 'auto';
|
|
100
|
+
const DEFAULT_MAX_VERSION = 'TLSv1.3';
|
|
101
|
+
const DEFAULT_MIN_VERSION = 'TLSv1.2';
|
|
80
102
|
|
|
81
|
-
|
|
103
|
+
const rootCertificates: string[] = [];
|
|
82
104
|
|
|
83
|
-
|
|
105
|
+
return {
|
|
84
106
|
TLSSocket,
|
|
85
107
|
Server,
|
|
86
108
|
createServer,
|
|
@@ -92,3 +114,11 @@ export default {
|
|
|
92
114
|
DEFAULT_MIN_VERSION,
|
|
93
115
|
rootCertificates,
|
|
94
116
|
};
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
const tls = createTlsModule();
|
|
120
|
+
export const { TLSSocket, Server, createServer, connect, createSecureContext, getCiphers,
|
|
121
|
+
DEFAULT_ECDH_CURVE, DEFAULT_MAX_VERSION, DEFAULT_MIN_VERSION, rootCertificates } = tls;
|
|
122
|
+
export type TLSSocket = InstanceType<typeof TLSSocket>;
|
|
123
|
+
export type Server = InstanceType<typeof Server>;
|
|
124
|
+
export default tls;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apply non-overlapping edits in descending source order. The AST visitors
|
|
3
|
+
* decide the replacements; assembly must not copy a large module once per
|
|
4
|
+
* reference. For equal-position insertions, later edits appear before earlier
|
|
5
|
+
* ones, matching the former repeated slice/concatenate operation.
|
|
6
|
+
*/
|
|
7
|
+
export function applySourceEdits(
|
|
8
|
+
source: string,
|
|
9
|
+
edits: readonly (readonly [start: number, end: number, text: string])[],
|
|
10
|
+
): string {
|
|
11
|
+
if (edits.length === 0) return source;
|
|
12
|
+
const chunks: string[] = [];
|
|
13
|
+
let cursor = source.length;
|
|
14
|
+
for (const [start, end, text] of edits) {
|
|
15
|
+
chunks.push(source.slice(end, cursor), text);
|
|
16
|
+
cursor = start;
|
|
17
|
+
}
|
|
18
|
+
chunks.push(source.slice(0, cursor));
|
|
19
|
+
return chunks.reverse().join('');
|
|
20
|
+
}
|