agent-web-os 0.3.5 → 0.4.0-beta.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/browser-bash-session-kzgy0g4v.d.cts +122 -0
- package/dist/browser-bash-session-kzgy0g4v.d.ts +122 -0
- package/dist/chunk-L7KW6Y27.js +2750 -0
- package/dist/chunk-L7KW6Y27.js.map +1 -0
- package/dist/chunk-QV36H6BY.js +5325 -0
- package/dist/chunk-QV36H6BY.js.map +1 -0
- package/dist/{chunk-JTZ3QUCT.js → chunk-ZZTRZYH2.js} +1021 -3
- package/dist/chunk-ZZTRZYH2.js.map +1 -0
- package/dist/index.cjs +34202 -75108
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -143
- package/dist/index.d.ts +5 -143
- package/dist/index.js +10 -953
- package/dist/index.js.map +1 -1
- package/dist/node.cjs +63339 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.cts +34 -0
- package/dist/node.d.ts +34 -0
- package/dist/node.js +16709 -0
- package/dist/node.js.map +1 -0
- package/dist/npm-C6N7BGOG.js +14 -0
- package/dist/server-bridge-DZUJDQIT.js +329 -0
- package/dist/server-bridge-DZUJDQIT.js.map +1 -0
- package/package.json +6 -1
- package/dist/almostnode-session-2FPETBKJ.js +0 -2103
- package/dist/almostnode-session-2FPETBKJ.js.map +0 -1
- package/dist/chunk-FNHNA3XU.js +0 -90
- package/dist/chunk-FNHNA3XU.js.map +0 -1
- package/dist/chunk-JTZ3QUCT.js.map +0 -1
- package/dist/chunk-YMOX2CWB.js +0 -38704
- package/dist/chunk-YMOX2CWB.js.map +0 -1
- package/dist/dist-2XQJWZPX.js +0 -98
- /package/dist/{dist-2XQJWZPX.js.map → npm-C6N7BGOG.js.map} +0 -0
|
@@ -0,0 +1,2750 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./chunk-PR4QN5HX.js";
|
|
4
|
+
|
|
5
|
+
// node_modules/almostnode/src/utils/binary-encoding.ts
|
|
6
|
+
var CHUNK = 8192;
|
|
7
|
+
function uint8ToBase64(bytes) {
|
|
8
|
+
const parts = [];
|
|
9
|
+
for (let i = 0; i < bytes.length; i += CHUNK) {
|
|
10
|
+
parts.push(String.fromCharCode.apply(null, Array.from(bytes.subarray(i, i + CHUNK))));
|
|
11
|
+
}
|
|
12
|
+
return btoa(parts.join(""));
|
|
13
|
+
}
|
|
14
|
+
function base64ToUint8(base64) {
|
|
15
|
+
const binary = atob(base64);
|
|
16
|
+
const bytes = new Uint8Array(binary.length);
|
|
17
|
+
for (let i = 0; i < binary.length; i++) {
|
|
18
|
+
bytes[i] = binary.charCodeAt(i);
|
|
19
|
+
}
|
|
20
|
+
return bytes;
|
|
21
|
+
}
|
|
22
|
+
function uint8ToHex(bytes) {
|
|
23
|
+
const hex = new Array(bytes.length);
|
|
24
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
25
|
+
hex[i] = bytes[i].toString(16).padStart(2, "0");
|
|
26
|
+
}
|
|
27
|
+
return hex.join("");
|
|
28
|
+
}
|
|
29
|
+
function uint8ToBinaryString(bytes) {
|
|
30
|
+
const parts = [];
|
|
31
|
+
for (let i = 0; i < bytes.length; i += CHUNK) {
|
|
32
|
+
parts.push(String.fromCharCode.apply(null, Array.from(bytes.subarray(i, i + CHUNK))));
|
|
33
|
+
}
|
|
34
|
+
return parts.join("");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// node_modules/almostnode/src/shims/events.ts
|
|
38
|
+
var kEvents = /* @__PURE__ */ Symbol("events");
|
|
39
|
+
var kMaxListeners = /* @__PURE__ */ Symbol("maxListeners");
|
|
40
|
+
var EventEmitter = class {
|
|
41
|
+
[kEvents];
|
|
42
|
+
[kMaxListeners];
|
|
43
|
+
// Helper to get events map, creating it if needed
|
|
44
|
+
_getEvents() {
|
|
45
|
+
const self = this;
|
|
46
|
+
if (!self[kEvents]) {
|
|
47
|
+
self[kEvents] = /* @__PURE__ */ new Map();
|
|
48
|
+
}
|
|
49
|
+
return self[kEvents];
|
|
50
|
+
}
|
|
51
|
+
on(event, listener) {
|
|
52
|
+
return this.addListener(event, listener);
|
|
53
|
+
}
|
|
54
|
+
addListener(event, listener) {
|
|
55
|
+
const events2 = this._getEvents();
|
|
56
|
+
if (!events2.has(event)) {
|
|
57
|
+
events2.set(event, []);
|
|
58
|
+
}
|
|
59
|
+
events2.get(event).push(listener);
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
once(event, listener) {
|
|
63
|
+
const onceWrapper = (...args) => {
|
|
64
|
+
this.removeListener(event, onceWrapper);
|
|
65
|
+
listener.apply(this, args);
|
|
66
|
+
};
|
|
67
|
+
return this.addListener(event, onceWrapper);
|
|
68
|
+
}
|
|
69
|
+
off(event, listener) {
|
|
70
|
+
return this.removeListener(event, listener);
|
|
71
|
+
}
|
|
72
|
+
removeListener(event, listener) {
|
|
73
|
+
const events2 = this._getEvents();
|
|
74
|
+
const listeners = events2.get(event);
|
|
75
|
+
if (listeners) {
|
|
76
|
+
const index = listeners.indexOf(listener);
|
|
77
|
+
if (index !== -1) {
|
|
78
|
+
listeners.splice(index, 1);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return this;
|
|
82
|
+
}
|
|
83
|
+
removeAllListeners(event) {
|
|
84
|
+
const events2 = this._getEvents();
|
|
85
|
+
if (event) {
|
|
86
|
+
events2.delete(event);
|
|
87
|
+
} else {
|
|
88
|
+
events2.clear();
|
|
89
|
+
}
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
emit(event, ...args) {
|
|
93
|
+
const events2 = this._getEvents();
|
|
94
|
+
const listeners = events2.get(event);
|
|
95
|
+
if (!listeners || listeners.length === 0) {
|
|
96
|
+
if (event === "error") {
|
|
97
|
+
const err = args[0];
|
|
98
|
+
if (err instanceof Error) {
|
|
99
|
+
throw err;
|
|
100
|
+
}
|
|
101
|
+
throw new Error("Unhandled error event");
|
|
102
|
+
}
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
for (const listener of [...listeners]) {
|
|
106
|
+
try {
|
|
107
|
+
listener.apply(this, args);
|
|
108
|
+
} catch (err) {
|
|
109
|
+
console.error("Error in event listener:", err);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
listeners(event) {
|
|
115
|
+
const events2 = this._getEvents();
|
|
116
|
+
return [...events2.get(event) || []];
|
|
117
|
+
}
|
|
118
|
+
rawListeners(event) {
|
|
119
|
+
return this.listeners(event);
|
|
120
|
+
}
|
|
121
|
+
listenerCount(event) {
|
|
122
|
+
const events2 = this._getEvents();
|
|
123
|
+
return events2.get(event)?.length || 0;
|
|
124
|
+
}
|
|
125
|
+
eventNames() {
|
|
126
|
+
const events2 = this._getEvents();
|
|
127
|
+
return [...events2.keys()];
|
|
128
|
+
}
|
|
129
|
+
setMaxListeners(n) {
|
|
130
|
+
this[kMaxListeners] = n;
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
133
|
+
getMaxListeners() {
|
|
134
|
+
return this[kMaxListeners] || 10;
|
|
135
|
+
}
|
|
136
|
+
prependListener(event, listener) {
|
|
137
|
+
const events2 = this._getEvents();
|
|
138
|
+
if (!events2.has(event)) {
|
|
139
|
+
events2.set(event, []);
|
|
140
|
+
}
|
|
141
|
+
events2.get(event).unshift(listener);
|
|
142
|
+
return this;
|
|
143
|
+
}
|
|
144
|
+
prependOnceListener(event, listener) {
|
|
145
|
+
const onceWrapper = (...args) => {
|
|
146
|
+
this.removeListener(event, onceWrapper);
|
|
147
|
+
listener.apply(this, args);
|
|
148
|
+
};
|
|
149
|
+
return this.prependListener(event, onceWrapper);
|
|
150
|
+
}
|
|
151
|
+
// Static methods for compatibility
|
|
152
|
+
static listenerCount(emitter, event) {
|
|
153
|
+
return emitter.listenerCount(event);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
var events = EventEmitter;
|
|
157
|
+
events.EventEmitter = EventEmitter;
|
|
158
|
+
events.once = async (emitter, event) => {
|
|
159
|
+
return new Promise((resolve, reject) => {
|
|
160
|
+
const onEvent = (...args) => {
|
|
161
|
+
emitter.removeListener("error", onError);
|
|
162
|
+
resolve(args);
|
|
163
|
+
};
|
|
164
|
+
const onError = (...args) => {
|
|
165
|
+
emitter.removeListener(event, onEvent);
|
|
166
|
+
reject(args[0]);
|
|
167
|
+
};
|
|
168
|
+
emitter.once(event, onEvent);
|
|
169
|
+
emitter.once("error", onError);
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
events.on = (emitter, event) => {
|
|
173
|
+
const iterator = {
|
|
174
|
+
async next() {
|
|
175
|
+
return new Promise((resolve) => {
|
|
176
|
+
emitter.once(event, (...args) => resolve({ value: args, done: false }));
|
|
177
|
+
});
|
|
178
|
+
},
|
|
179
|
+
[Symbol.asyncIterator]() {
|
|
180
|
+
return this;
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
return iterator;
|
|
184
|
+
};
|
|
185
|
+
events.getEventListeners = (emitter, event) => emitter.listeners(event);
|
|
186
|
+
events.listenerCount = (emitter, event) => emitter.listenerCount(event);
|
|
187
|
+
var events_default = events;
|
|
188
|
+
|
|
189
|
+
// node_modules/almostnode/src/shims/stream.ts
|
|
190
|
+
var _encoder = new TextEncoder();
|
|
191
|
+
var _decoder = new TextDecoder("utf-8");
|
|
192
|
+
var Readable = class _Readable extends EventEmitter {
|
|
193
|
+
_buffer = [];
|
|
194
|
+
_ended = false;
|
|
195
|
+
_flowing = false;
|
|
196
|
+
_endEmitted = false;
|
|
197
|
+
readable = true;
|
|
198
|
+
readableEnded = false;
|
|
199
|
+
readableFlowing = null;
|
|
200
|
+
constructor() {
|
|
201
|
+
super();
|
|
202
|
+
}
|
|
203
|
+
// Internal method to add listener without triggering auto-flow
|
|
204
|
+
_addListenerInternal(event, listener) {
|
|
205
|
+
EventEmitter.prototype.addListener.call(this, event, listener);
|
|
206
|
+
return this;
|
|
207
|
+
}
|
|
208
|
+
// Override on() to auto-flow when 'data' listener is added
|
|
209
|
+
on(event, listener) {
|
|
210
|
+
this._addListenerInternal(event, listener);
|
|
211
|
+
if (event === "data" && !this._flowing) {
|
|
212
|
+
queueMicrotask(() => {
|
|
213
|
+
if (this.listenerCount("data") > 0 && !this._flowing) {
|
|
214
|
+
this.resume();
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
return this;
|
|
219
|
+
}
|
|
220
|
+
// Also handle addListener (alias for on)
|
|
221
|
+
addListener(event, listener) {
|
|
222
|
+
return this.on(event, listener);
|
|
223
|
+
}
|
|
224
|
+
push(chunk) {
|
|
225
|
+
if (chunk === null) {
|
|
226
|
+
this._ended = true;
|
|
227
|
+
this.readableEnded = true;
|
|
228
|
+
this.readable = false;
|
|
229
|
+
if (this._flowing && this._buffer.length === 0 && !this._endEmitted) {
|
|
230
|
+
this._endEmitted = true;
|
|
231
|
+
queueMicrotask(() => this.emit("end"));
|
|
232
|
+
}
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
const buffer = typeof chunk === "string" ? Buffer.from(chunk) : chunk;
|
|
236
|
+
this._buffer.push(buffer);
|
|
237
|
+
if (this._flowing) {
|
|
238
|
+
queueMicrotask(() => {
|
|
239
|
+
this._flushBuffer();
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
_flushBuffer() {
|
|
245
|
+
while (this._buffer.length > 0 && this._flowing) {
|
|
246
|
+
const data = this._buffer.shift();
|
|
247
|
+
this.emit("data", data);
|
|
248
|
+
}
|
|
249
|
+
if (this._ended && this._buffer.length === 0 && !this._endEmitted) {
|
|
250
|
+
this._endEmitted = true;
|
|
251
|
+
this.emit("end");
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
read(size) {
|
|
255
|
+
if (this._buffer.length === 0) {
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
258
|
+
if (size === void 0) {
|
|
259
|
+
const result = Buffer.concat(this._buffer);
|
|
260
|
+
this._buffer = [];
|
|
261
|
+
return result;
|
|
262
|
+
}
|
|
263
|
+
const chunks = [];
|
|
264
|
+
let remaining = size;
|
|
265
|
+
while (remaining > 0 && this._buffer.length > 0) {
|
|
266
|
+
const chunk = this._buffer[0];
|
|
267
|
+
if (chunk.length <= remaining) {
|
|
268
|
+
chunks.push(this._buffer.shift());
|
|
269
|
+
remaining -= chunk.length;
|
|
270
|
+
} else {
|
|
271
|
+
chunks.push(chunk.slice(0, remaining));
|
|
272
|
+
this._buffer[0] = chunk.slice(remaining);
|
|
273
|
+
remaining = 0;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return chunks.length > 0 ? Buffer.concat(chunks) : null;
|
|
277
|
+
}
|
|
278
|
+
resume() {
|
|
279
|
+
this._flowing = true;
|
|
280
|
+
this.readableFlowing = true;
|
|
281
|
+
this._flushBuffer();
|
|
282
|
+
return this;
|
|
283
|
+
}
|
|
284
|
+
pause() {
|
|
285
|
+
this._flowing = false;
|
|
286
|
+
this.readableFlowing = false;
|
|
287
|
+
return this;
|
|
288
|
+
}
|
|
289
|
+
pipe(destination) {
|
|
290
|
+
this.on("data", (chunk) => {
|
|
291
|
+
destination.write(chunk);
|
|
292
|
+
});
|
|
293
|
+
this.on("end", () => {
|
|
294
|
+
destination.end();
|
|
295
|
+
});
|
|
296
|
+
this.resume();
|
|
297
|
+
return destination;
|
|
298
|
+
}
|
|
299
|
+
unpipe(destination) {
|
|
300
|
+
this.removeAllListeners("data");
|
|
301
|
+
this.removeAllListeners("end");
|
|
302
|
+
return this;
|
|
303
|
+
}
|
|
304
|
+
setEncoding(encoding) {
|
|
305
|
+
return this;
|
|
306
|
+
}
|
|
307
|
+
destroy(error) {
|
|
308
|
+
this._buffer = [];
|
|
309
|
+
this._ended = true;
|
|
310
|
+
this.readable = false;
|
|
311
|
+
if (error) {
|
|
312
|
+
this.emit("error", error);
|
|
313
|
+
}
|
|
314
|
+
this.emit("close");
|
|
315
|
+
return this;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Creates a Readable stream from an iterable or async iterable
|
|
319
|
+
* @param iterable - An iterable or async iterable to create the stream from
|
|
320
|
+
* @param options - Optional stream options
|
|
321
|
+
*/
|
|
322
|
+
static from(iterable, options) {
|
|
323
|
+
const readable = new _Readable();
|
|
324
|
+
(async () => {
|
|
325
|
+
try {
|
|
326
|
+
for await (const chunk of iterable) {
|
|
327
|
+
if (chunk !== null && chunk !== void 0) {
|
|
328
|
+
const data = typeof chunk === "string" ? Buffer.from(chunk) : chunk;
|
|
329
|
+
readable.push(data);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
readable.push(null);
|
|
333
|
+
} catch (err) {
|
|
334
|
+
readable.destroy(err);
|
|
335
|
+
}
|
|
336
|
+
})();
|
|
337
|
+
return readable;
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
var Writable = class extends EventEmitter {
|
|
341
|
+
_chunks = [];
|
|
342
|
+
_ended = false;
|
|
343
|
+
writable = true;
|
|
344
|
+
writableEnded = false;
|
|
345
|
+
writableFinished = false;
|
|
346
|
+
constructor() {
|
|
347
|
+
super();
|
|
348
|
+
}
|
|
349
|
+
write(chunk, encodingOrCallback, callback) {
|
|
350
|
+
if (this._ended) {
|
|
351
|
+
const error = new Error("write after end");
|
|
352
|
+
if (typeof encodingOrCallback === "function") {
|
|
353
|
+
encodingOrCallback(error);
|
|
354
|
+
} else if (callback) {
|
|
355
|
+
callback(error);
|
|
356
|
+
}
|
|
357
|
+
return false;
|
|
358
|
+
}
|
|
359
|
+
const buffer = typeof chunk === "string" ? Buffer.from(chunk) : chunk;
|
|
360
|
+
this._chunks.push(buffer);
|
|
361
|
+
const cb = typeof encodingOrCallback === "function" ? encodingOrCallback : callback;
|
|
362
|
+
if (cb) {
|
|
363
|
+
queueMicrotask(() => cb(null));
|
|
364
|
+
}
|
|
365
|
+
return true;
|
|
366
|
+
}
|
|
367
|
+
end(chunkOrCallback, encodingOrCallback, callback) {
|
|
368
|
+
if (typeof chunkOrCallback === "function") {
|
|
369
|
+
callback = chunkOrCallback;
|
|
370
|
+
} else if (chunkOrCallback !== void 0) {
|
|
371
|
+
this.write(chunkOrCallback);
|
|
372
|
+
}
|
|
373
|
+
if (typeof encodingOrCallback === "function") {
|
|
374
|
+
callback = encodingOrCallback;
|
|
375
|
+
}
|
|
376
|
+
this._ended = true;
|
|
377
|
+
this.writable = false;
|
|
378
|
+
this.writableEnded = true;
|
|
379
|
+
queueMicrotask(() => {
|
|
380
|
+
this.writableFinished = true;
|
|
381
|
+
this.emit("finish");
|
|
382
|
+
if (callback) {
|
|
383
|
+
callback();
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
return this;
|
|
387
|
+
}
|
|
388
|
+
getBuffer() {
|
|
389
|
+
return Buffer.concat(this._chunks);
|
|
390
|
+
}
|
|
391
|
+
getBufferAsString(encoding = "utf8") {
|
|
392
|
+
return this.getBuffer().toString(encoding);
|
|
393
|
+
}
|
|
394
|
+
destroy(error) {
|
|
395
|
+
this._chunks = [];
|
|
396
|
+
this._ended = true;
|
|
397
|
+
this.writable = false;
|
|
398
|
+
if (error) {
|
|
399
|
+
this.emit("error", error);
|
|
400
|
+
}
|
|
401
|
+
this.emit("close");
|
|
402
|
+
return this;
|
|
403
|
+
}
|
|
404
|
+
cork() {
|
|
405
|
+
}
|
|
406
|
+
uncork() {
|
|
407
|
+
}
|
|
408
|
+
setDefaultEncoding(encoding) {
|
|
409
|
+
return this;
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
var Duplex = class extends Readable {
|
|
413
|
+
_writeChunks = [];
|
|
414
|
+
_writeEnded = false;
|
|
415
|
+
writable = true;
|
|
416
|
+
writableEnded = false;
|
|
417
|
+
writableFinished = false;
|
|
418
|
+
write(chunk, encodingOrCallback, callback) {
|
|
419
|
+
if (this._writeEnded) {
|
|
420
|
+
return false;
|
|
421
|
+
}
|
|
422
|
+
const buffer = typeof chunk === "string" ? Buffer.from(chunk) : chunk;
|
|
423
|
+
this._writeChunks.push(buffer);
|
|
424
|
+
const cb = typeof encodingOrCallback === "function" ? encodingOrCallback : callback;
|
|
425
|
+
if (cb) {
|
|
426
|
+
queueMicrotask(() => cb(null));
|
|
427
|
+
}
|
|
428
|
+
return true;
|
|
429
|
+
}
|
|
430
|
+
end(chunkOrCallback, encodingOrCallback, callback) {
|
|
431
|
+
if (typeof chunkOrCallback === "function") {
|
|
432
|
+
callback = chunkOrCallback;
|
|
433
|
+
} else if (chunkOrCallback !== void 0) {
|
|
434
|
+
this.write(chunkOrCallback);
|
|
435
|
+
}
|
|
436
|
+
this._writeEnded = true;
|
|
437
|
+
this.writable = false;
|
|
438
|
+
this.writableEnded = true;
|
|
439
|
+
queueMicrotask(() => {
|
|
440
|
+
this.writableFinished = true;
|
|
441
|
+
this.emit("finish");
|
|
442
|
+
if (callback) {
|
|
443
|
+
callback();
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
return this;
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
var PassThrough = class extends Duplex {
|
|
450
|
+
constructor() {
|
|
451
|
+
super();
|
|
452
|
+
}
|
|
453
|
+
write(chunk, encodingOrCallback, callback) {
|
|
454
|
+
const buffer = typeof chunk === "string" ? Buffer.from(chunk) : chunk;
|
|
455
|
+
this.push(buffer);
|
|
456
|
+
const cb = typeof encodingOrCallback === "function" ? encodingOrCallback : callback;
|
|
457
|
+
if (cb) {
|
|
458
|
+
queueMicrotask(() => cb(null));
|
|
459
|
+
}
|
|
460
|
+
return true;
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
var Transform = class extends Duplex {
|
|
464
|
+
constructor() {
|
|
465
|
+
super();
|
|
466
|
+
}
|
|
467
|
+
_transform(chunk, encoding, callback) {
|
|
468
|
+
callback(null, chunk);
|
|
469
|
+
}
|
|
470
|
+
_flush(callback) {
|
|
471
|
+
callback(null);
|
|
472
|
+
}
|
|
473
|
+
write(chunk, encodingOrCallback, callback) {
|
|
474
|
+
const buffer = typeof chunk === "string" ? Buffer.from(chunk) : chunk;
|
|
475
|
+
const encoding = typeof encodingOrCallback === "string" ? encodingOrCallback : "utf8";
|
|
476
|
+
const cb = typeof encodingOrCallback === "function" ? encodingOrCallback : callback;
|
|
477
|
+
this._transform(buffer, encoding, (error, data) => {
|
|
478
|
+
if (error) {
|
|
479
|
+
if (cb) cb(error);
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
if (data) {
|
|
483
|
+
this.push(data);
|
|
484
|
+
}
|
|
485
|
+
if (cb) cb(null);
|
|
486
|
+
});
|
|
487
|
+
return true;
|
|
488
|
+
}
|
|
489
|
+
end(chunkOrCallback, encodingOrCallback, callback) {
|
|
490
|
+
this._flush((error, data) => {
|
|
491
|
+
if (data) {
|
|
492
|
+
this.push(data);
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
return super.end(chunkOrCallback, encodingOrCallback, callback);
|
|
496
|
+
}
|
|
497
|
+
};
|
|
498
|
+
var Stream = class extends EventEmitter {
|
|
499
|
+
pipe(destination) {
|
|
500
|
+
return destination;
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
Stream.Readable = Readable;
|
|
504
|
+
Stream.Writable = Writable;
|
|
505
|
+
Stream.Duplex = Duplex;
|
|
506
|
+
Stream.Transform = Transform;
|
|
507
|
+
Stream.PassThrough = PassThrough;
|
|
508
|
+
Stream.Stream = Stream;
|
|
509
|
+
Stream.from = Readable.from;
|
|
510
|
+
var promises = {
|
|
511
|
+
pipeline: async (...streams) => {
|
|
512
|
+
return Promise.resolve();
|
|
513
|
+
},
|
|
514
|
+
finished: async (stream) => {
|
|
515
|
+
return Promise.resolve();
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
function pipeline(...args) {
|
|
519
|
+
const callback = args[args.length - 1];
|
|
520
|
+
if (typeof callback === "function") {
|
|
521
|
+
setTimeout(() => callback(), 0);
|
|
522
|
+
}
|
|
523
|
+
return args[args.length - 2] || args[0];
|
|
524
|
+
}
|
|
525
|
+
function finished(stream, callback) {
|
|
526
|
+
setTimeout(() => callback(), 0);
|
|
527
|
+
return () => {
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
var BufferPolyfill = class _BufferPolyfill extends Uint8Array {
|
|
531
|
+
// BYTES_PER_ELEMENT for TypedArray compatibility
|
|
532
|
+
static BYTES_PER_ELEMENT = 1;
|
|
533
|
+
static from(value, encodingOrMapfn, thisArg) {
|
|
534
|
+
if (typeof encodingOrMapfn === "function") {
|
|
535
|
+
const arrayLike = value;
|
|
536
|
+
const mapped = Array.from(arrayLike, encodingOrMapfn, thisArg);
|
|
537
|
+
return new _BufferPolyfill(mapped);
|
|
538
|
+
}
|
|
539
|
+
const data = value;
|
|
540
|
+
const encoding = encodingOrMapfn;
|
|
541
|
+
if (Array.isArray(data)) {
|
|
542
|
+
return new _BufferPolyfill(data);
|
|
543
|
+
}
|
|
544
|
+
if (typeof data === "string") {
|
|
545
|
+
const enc = (encoding || "utf8").toLowerCase();
|
|
546
|
+
if (enc === "base64" || enc === "base64url") {
|
|
547
|
+
let base64 = data;
|
|
548
|
+
if (enc === "base64url") {
|
|
549
|
+
base64 = data.replace(/-/g, "+").replace(/_/g, "/");
|
|
550
|
+
while (base64.length % 4 !== 0) {
|
|
551
|
+
base64 += "=";
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
const binary = atob(base64);
|
|
555
|
+
const bytes2 = new Uint8Array(binary.length);
|
|
556
|
+
for (let i = 0; i < binary.length; i++) {
|
|
557
|
+
bytes2[i] = binary.charCodeAt(i);
|
|
558
|
+
}
|
|
559
|
+
return new _BufferPolyfill(bytes2);
|
|
560
|
+
}
|
|
561
|
+
if (enc === "hex") {
|
|
562
|
+
const bytes2 = new Uint8Array(data.length / 2);
|
|
563
|
+
for (let i = 0; i < data.length; i += 2) {
|
|
564
|
+
bytes2[i / 2] = parseInt(data.slice(i, i + 2), 16);
|
|
565
|
+
}
|
|
566
|
+
return new _BufferPolyfill(bytes2);
|
|
567
|
+
}
|
|
568
|
+
if (enc === "latin1" || enc === "binary") {
|
|
569
|
+
const bytes2 = new Uint8Array(data.length);
|
|
570
|
+
for (let i = 0; i < data.length; i++) {
|
|
571
|
+
bytes2[i] = data.charCodeAt(i) & 255;
|
|
572
|
+
}
|
|
573
|
+
return new _BufferPolyfill(bytes2);
|
|
574
|
+
}
|
|
575
|
+
const bytes = _encoder.encode(data);
|
|
576
|
+
return new _BufferPolyfill(bytes);
|
|
577
|
+
}
|
|
578
|
+
if (data instanceof ArrayBuffer) {
|
|
579
|
+
return new _BufferPolyfill(data);
|
|
580
|
+
}
|
|
581
|
+
return new _BufferPolyfill(data);
|
|
582
|
+
}
|
|
583
|
+
static alloc(size, fill) {
|
|
584
|
+
const buffer = new _BufferPolyfill(size);
|
|
585
|
+
if (fill !== void 0) {
|
|
586
|
+
buffer.fill(fill);
|
|
587
|
+
}
|
|
588
|
+
return buffer;
|
|
589
|
+
}
|
|
590
|
+
static allocUnsafe(size) {
|
|
591
|
+
return new _BufferPolyfill(size);
|
|
592
|
+
}
|
|
593
|
+
static allocUnsafeSlow(size) {
|
|
594
|
+
return new _BufferPolyfill(size);
|
|
595
|
+
}
|
|
596
|
+
static concat(buffers) {
|
|
597
|
+
const totalLength = buffers.reduce((sum, buf) => sum + buf.length, 0);
|
|
598
|
+
const result = new _BufferPolyfill(totalLength);
|
|
599
|
+
let offset = 0;
|
|
600
|
+
for (const buf of buffers) {
|
|
601
|
+
result.set(buf, offset);
|
|
602
|
+
offset += buf.length;
|
|
603
|
+
}
|
|
604
|
+
return result;
|
|
605
|
+
}
|
|
606
|
+
static isBuffer(obj) {
|
|
607
|
+
return obj instanceof _BufferPolyfill || obj instanceof Uint8Array;
|
|
608
|
+
}
|
|
609
|
+
static isEncoding(encoding) {
|
|
610
|
+
return ["utf8", "utf-8", "ascii", "latin1", "binary", "base64", "base64url", "hex"].includes(encoding.toLowerCase());
|
|
611
|
+
}
|
|
612
|
+
static byteLength(string, encoding) {
|
|
613
|
+
const enc = (encoding || "utf8").toLowerCase();
|
|
614
|
+
if (enc === "base64" || enc === "base64url") {
|
|
615
|
+
const base64 = string.replace(/[=]/g, "");
|
|
616
|
+
return Math.floor(base64.length * 3 / 4);
|
|
617
|
+
}
|
|
618
|
+
if (enc === "hex") {
|
|
619
|
+
return string.length / 2;
|
|
620
|
+
}
|
|
621
|
+
return _encoder.encode(string).length;
|
|
622
|
+
}
|
|
623
|
+
toString(encoding = "utf8") {
|
|
624
|
+
const enc = (encoding || "utf8").toLowerCase();
|
|
625
|
+
if (enc === "base64") {
|
|
626
|
+
return uint8ToBase64(this);
|
|
627
|
+
}
|
|
628
|
+
if (enc === "base64url") {
|
|
629
|
+
return uint8ToBase64(this).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
630
|
+
}
|
|
631
|
+
if (enc === "hex") {
|
|
632
|
+
return uint8ToHex(this);
|
|
633
|
+
}
|
|
634
|
+
if (enc === "latin1" || enc === "binary") {
|
|
635
|
+
return uint8ToBinaryString(this);
|
|
636
|
+
}
|
|
637
|
+
return _decoder.decode(this);
|
|
638
|
+
}
|
|
639
|
+
slice(start, end) {
|
|
640
|
+
return new _BufferPolyfill(super.slice(start, end));
|
|
641
|
+
}
|
|
642
|
+
subarray(start, end) {
|
|
643
|
+
return new _BufferPolyfill(super.subarray(start, end));
|
|
644
|
+
}
|
|
645
|
+
write(string, offset) {
|
|
646
|
+
const bytes = _encoder.encode(string);
|
|
647
|
+
this.set(bytes, offset || 0);
|
|
648
|
+
return bytes.length;
|
|
649
|
+
}
|
|
650
|
+
copy(target, targetStart, sourceStart, sourceEnd) {
|
|
651
|
+
const src = this.subarray(sourceStart || 0, sourceEnd);
|
|
652
|
+
target.set(src, targetStart || 0);
|
|
653
|
+
return src.length;
|
|
654
|
+
}
|
|
655
|
+
compare(otherBuffer) {
|
|
656
|
+
const len = Math.min(this.length, otherBuffer.length);
|
|
657
|
+
for (let i = 0; i < len; i++) {
|
|
658
|
+
if (this[i] < otherBuffer[i]) return -1;
|
|
659
|
+
if (this[i] > otherBuffer[i]) return 1;
|
|
660
|
+
}
|
|
661
|
+
if (this.length < otherBuffer.length) return -1;
|
|
662
|
+
if (this.length > otherBuffer.length) return 1;
|
|
663
|
+
return 0;
|
|
664
|
+
}
|
|
665
|
+
equals(otherBuffer) {
|
|
666
|
+
return this.compare(otherBuffer) === 0;
|
|
667
|
+
}
|
|
668
|
+
toJSON() {
|
|
669
|
+
return {
|
|
670
|
+
type: "Buffer",
|
|
671
|
+
data: Array.from(this)
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
// Add Object prototype methods that TypedArrays don't have directly
|
|
675
|
+
hasOwnProperty(prop) {
|
|
676
|
+
return Object.prototype.hasOwnProperty.call(this, prop);
|
|
677
|
+
}
|
|
678
|
+
readUInt8(offset) {
|
|
679
|
+
return this[offset];
|
|
680
|
+
}
|
|
681
|
+
readUInt16BE(offset) {
|
|
682
|
+
return this[offset] << 8 | this[offset + 1];
|
|
683
|
+
}
|
|
684
|
+
readUInt16LE(offset) {
|
|
685
|
+
return this[offset] | this[offset + 1] << 8;
|
|
686
|
+
}
|
|
687
|
+
readUInt32BE(offset) {
|
|
688
|
+
return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
|
|
689
|
+
}
|
|
690
|
+
readUInt32LE(offset) {
|
|
691
|
+
return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
|
|
692
|
+
}
|
|
693
|
+
writeUInt8(value, offset) {
|
|
694
|
+
this[offset] = value & 255;
|
|
695
|
+
return offset + 1;
|
|
696
|
+
}
|
|
697
|
+
writeUInt16BE(value, offset) {
|
|
698
|
+
this[offset] = value >> 8 & 255;
|
|
699
|
+
this[offset + 1] = value & 255;
|
|
700
|
+
return offset + 2;
|
|
701
|
+
}
|
|
702
|
+
writeUInt16LE(value, offset) {
|
|
703
|
+
this[offset] = value & 255;
|
|
704
|
+
this[offset + 1] = value >> 8 & 255;
|
|
705
|
+
return offset + 2;
|
|
706
|
+
}
|
|
707
|
+
writeUInt32BE(value, offset) {
|
|
708
|
+
this[offset] = value >> 24 & 255;
|
|
709
|
+
this[offset + 1] = value >> 16 & 255;
|
|
710
|
+
this[offset + 2] = value >> 8 & 255;
|
|
711
|
+
this[offset + 3] = value & 255;
|
|
712
|
+
return offset + 4;
|
|
713
|
+
}
|
|
714
|
+
writeUInt32LE(value, offset) {
|
|
715
|
+
this[offset] = value & 255;
|
|
716
|
+
this[offset + 1] = value >> 8 & 255;
|
|
717
|
+
this[offset + 2] = value >> 16 & 255;
|
|
718
|
+
this[offset + 3] = value >> 24 & 255;
|
|
719
|
+
return offset + 4;
|
|
720
|
+
}
|
|
721
|
+
// Lowercase aliases for UInt methods (Node.js Buffer API compatibility)
|
|
722
|
+
readUint8(offset) {
|
|
723
|
+
return this.readUInt8(offset);
|
|
724
|
+
}
|
|
725
|
+
readUint16BE(offset) {
|
|
726
|
+
return this.readUInt16BE(offset);
|
|
727
|
+
}
|
|
728
|
+
readUint16LE(offset) {
|
|
729
|
+
return this.readUInt16LE(offset);
|
|
730
|
+
}
|
|
731
|
+
readUint32BE(offset) {
|
|
732
|
+
return this.readUInt32BE(offset);
|
|
733
|
+
}
|
|
734
|
+
readUint32LE(offset) {
|
|
735
|
+
return this.readUInt32LE(offset);
|
|
736
|
+
}
|
|
737
|
+
writeUint8(value, offset) {
|
|
738
|
+
return this.writeUInt8(value, offset);
|
|
739
|
+
}
|
|
740
|
+
writeUint16BE(value, offset) {
|
|
741
|
+
return this.writeUInt16BE(value, offset);
|
|
742
|
+
}
|
|
743
|
+
writeUint16LE(value, offset) {
|
|
744
|
+
return this.writeUInt16LE(value, offset);
|
|
745
|
+
}
|
|
746
|
+
writeUint32BE(value, offset) {
|
|
747
|
+
return this.writeUInt32BE(value, offset);
|
|
748
|
+
}
|
|
749
|
+
writeUint32LE(value, offset) {
|
|
750
|
+
return this.writeUInt32LE(value, offset);
|
|
751
|
+
}
|
|
752
|
+
// Signed integer methods
|
|
753
|
+
readInt8(offset) {
|
|
754
|
+
const val = this[offset];
|
|
755
|
+
return val & 128 ? val - 256 : val;
|
|
756
|
+
}
|
|
757
|
+
readInt16BE(offset) {
|
|
758
|
+
const val = this.readUInt16BE(offset);
|
|
759
|
+
return val & 32768 ? val - 65536 : val;
|
|
760
|
+
}
|
|
761
|
+
readInt16LE(offset) {
|
|
762
|
+
const val = this.readUInt16LE(offset);
|
|
763
|
+
return val & 32768 ? val - 65536 : val;
|
|
764
|
+
}
|
|
765
|
+
readInt32BE(offset) {
|
|
766
|
+
const val = this.readUInt32BE(offset);
|
|
767
|
+
return val | 0;
|
|
768
|
+
}
|
|
769
|
+
readInt32LE(offset) {
|
|
770
|
+
const val = this.readUInt32LE(offset);
|
|
771
|
+
return val | 0;
|
|
772
|
+
}
|
|
773
|
+
writeInt8(value, offset) {
|
|
774
|
+
this[offset] = value & 255;
|
|
775
|
+
return offset + 1;
|
|
776
|
+
}
|
|
777
|
+
writeInt16BE(value, offset) {
|
|
778
|
+
return this.writeUInt16BE(value & 65535, offset);
|
|
779
|
+
}
|
|
780
|
+
writeInt16LE(value, offset) {
|
|
781
|
+
return this.writeUInt16LE(value & 65535, offset);
|
|
782
|
+
}
|
|
783
|
+
writeInt32BE(value, offset) {
|
|
784
|
+
return this.writeUInt32BE(value >>> 0, offset);
|
|
785
|
+
}
|
|
786
|
+
writeInt32LE(value, offset) {
|
|
787
|
+
return this.writeUInt32LE(value >>> 0, offset);
|
|
788
|
+
}
|
|
789
|
+
// BigInt methods (64-bit)
|
|
790
|
+
readBigUInt64LE(offset) {
|
|
791
|
+
const lo = BigInt(this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24) & 0xffffffffn;
|
|
792
|
+
const hi = BigInt(this[offset + 4] | this[offset + 5] << 8 | this[offset + 6] << 16 | this[offset + 7] << 24) & 0xffffffffn;
|
|
793
|
+
return lo | hi << 32n;
|
|
794
|
+
}
|
|
795
|
+
readBigUInt64BE(offset) {
|
|
796
|
+
const hi = BigInt(this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]) & 0xffffffffn;
|
|
797
|
+
const lo = BigInt(this[offset + 4] << 24 | this[offset + 5] << 16 | this[offset + 6] << 8 | this[offset + 7]) & 0xffffffffn;
|
|
798
|
+
return lo | hi << 32n;
|
|
799
|
+
}
|
|
800
|
+
readBigInt64LE(offset) {
|
|
801
|
+
const val = this.readBigUInt64LE(offset);
|
|
802
|
+
if (val >= 0x8000000000000000n) {
|
|
803
|
+
return val - 0x10000000000000000n;
|
|
804
|
+
}
|
|
805
|
+
return val;
|
|
806
|
+
}
|
|
807
|
+
readBigInt64BE(offset) {
|
|
808
|
+
const val = this.readBigUInt64BE(offset);
|
|
809
|
+
if (val >= 0x8000000000000000n) {
|
|
810
|
+
return val - 0x10000000000000000n;
|
|
811
|
+
}
|
|
812
|
+
return val;
|
|
813
|
+
}
|
|
814
|
+
writeBigUInt64LE(value, offset) {
|
|
815
|
+
const lo = value & 0xffffffffn;
|
|
816
|
+
const hi = value >> 32n & 0xffffffffn;
|
|
817
|
+
this[offset] = Number(lo & 0xffn);
|
|
818
|
+
this[offset + 1] = Number(lo >> 8n & 0xffn);
|
|
819
|
+
this[offset + 2] = Number(lo >> 16n & 0xffn);
|
|
820
|
+
this[offset + 3] = Number(lo >> 24n & 0xffn);
|
|
821
|
+
this[offset + 4] = Number(hi & 0xffn);
|
|
822
|
+
this[offset + 5] = Number(hi >> 8n & 0xffn);
|
|
823
|
+
this[offset + 6] = Number(hi >> 16n & 0xffn);
|
|
824
|
+
this[offset + 7] = Number(hi >> 24n & 0xffn);
|
|
825
|
+
return offset + 8;
|
|
826
|
+
}
|
|
827
|
+
writeBigUInt64BE(value, offset) {
|
|
828
|
+
const lo = value & 0xffffffffn;
|
|
829
|
+
const hi = value >> 32n & 0xffffffffn;
|
|
830
|
+
this[offset] = Number(hi >> 24n & 0xffn);
|
|
831
|
+
this[offset + 1] = Number(hi >> 16n & 0xffn);
|
|
832
|
+
this[offset + 2] = Number(hi >> 8n & 0xffn);
|
|
833
|
+
this[offset + 3] = Number(hi & 0xffn);
|
|
834
|
+
this[offset + 4] = Number(lo >> 24n & 0xffn);
|
|
835
|
+
this[offset + 5] = Number(lo >> 16n & 0xffn);
|
|
836
|
+
this[offset + 6] = Number(lo >> 8n & 0xffn);
|
|
837
|
+
this[offset + 7] = Number(lo & 0xffn);
|
|
838
|
+
return offset + 8;
|
|
839
|
+
}
|
|
840
|
+
writeBigInt64LE(value, offset) {
|
|
841
|
+
const unsigned = value < 0n ? value + 0x10000000000000000n : value;
|
|
842
|
+
return this.writeBigUInt64LE(unsigned, offset);
|
|
843
|
+
}
|
|
844
|
+
writeBigInt64BE(value, offset) {
|
|
845
|
+
const unsigned = value < 0n ? value + 0x10000000000000000n : value;
|
|
846
|
+
return this.writeBigUInt64BE(unsigned, offset);
|
|
847
|
+
}
|
|
848
|
+
// Lowercase aliases for BigInt methods (Node.js Buffer API compatibility)
|
|
849
|
+
readBigUint64LE(offset) {
|
|
850
|
+
return this.readBigUInt64LE(offset);
|
|
851
|
+
}
|
|
852
|
+
readBigUint64BE(offset) {
|
|
853
|
+
return this.readBigUInt64BE(offset);
|
|
854
|
+
}
|
|
855
|
+
writeBigUint64LE(value, offset) {
|
|
856
|
+
return this.writeBigUInt64LE(value, offset);
|
|
857
|
+
}
|
|
858
|
+
writeBigUint64BE(value, offset) {
|
|
859
|
+
return this.writeBigUInt64BE(value, offset);
|
|
860
|
+
}
|
|
861
|
+
// Float methods
|
|
862
|
+
readFloatLE(offset) {
|
|
863
|
+
const view = new DataView(this.buffer, this.byteOffset + offset, 4);
|
|
864
|
+
return view.getFloat32(0, true);
|
|
865
|
+
}
|
|
866
|
+
readFloatBE(offset) {
|
|
867
|
+
const view = new DataView(this.buffer, this.byteOffset + offset, 4);
|
|
868
|
+
return view.getFloat32(0, false);
|
|
869
|
+
}
|
|
870
|
+
readDoubleLE(offset) {
|
|
871
|
+
const view = new DataView(this.buffer, this.byteOffset + offset, 8);
|
|
872
|
+
return view.getFloat64(0, true);
|
|
873
|
+
}
|
|
874
|
+
readDoubleBE(offset) {
|
|
875
|
+
const view = new DataView(this.buffer, this.byteOffset + offset, 8);
|
|
876
|
+
return view.getFloat64(0, false);
|
|
877
|
+
}
|
|
878
|
+
writeFloatLE(value, offset) {
|
|
879
|
+
const view = new DataView(this.buffer, this.byteOffset + offset, 4);
|
|
880
|
+
view.setFloat32(0, value, true);
|
|
881
|
+
return offset + 4;
|
|
882
|
+
}
|
|
883
|
+
writeFloatBE(value, offset) {
|
|
884
|
+
const view = new DataView(this.buffer, this.byteOffset + offset, 4);
|
|
885
|
+
view.setFloat32(0, value, false);
|
|
886
|
+
return offset + 4;
|
|
887
|
+
}
|
|
888
|
+
writeDoubleLE(value, offset) {
|
|
889
|
+
const view = new DataView(this.buffer, this.byteOffset + offset, 8);
|
|
890
|
+
view.setFloat64(0, value, true);
|
|
891
|
+
return offset + 8;
|
|
892
|
+
}
|
|
893
|
+
writeDoubleBE(value, offset) {
|
|
894
|
+
const view = new DataView(this.buffer, this.byteOffset + offset, 8);
|
|
895
|
+
view.setFloat64(0, value, false);
|
|
896
|
+
return offset + 8;
|
|
897
|
+
}
|
|
898
|
+
// Variable-length unsigned integer methods
|
|
899
|
+
readUIntLE(offset, byteLength) {
|
|
900
|
+
let val = 0;
|
|
901
|
+
let mul = 1;
|
|
902
|
+
for (let i = 0; i < byteLength; i++) {
|
|
903
|
+
val += this[offset + i] * mul;
|
|
904
|
+
mul *= 256;
|
|
905
|
+
}
|
|
906
|
+
return val;
|
|
907
|
+
}
|
|
908
|
+
readUintLE(offset, byteLength) {
|
|
909
|
+
return this.readUIntLE(offset, byteLength);
|
|
910
|
+
}
|
|
911
|
+
readUIntBE(offset, byteLength) {
|
|
912
|
+
let val = 0;
|
|
913
|
+
let mul = 1;
|
|
914
|
+
for (let i = byteLength - 1; i >= 0; i--) {
|
|
915
|
+
val += this[offset + i] * mul;
|
|
916
|
+
mul *= 256;
|
|
917
|
+
}
|
|
918
|
+
return val;
|
|
919
|
+
}
|
|
920
|
+
readUintBE(offset, byteLength) {
|
|
921
|
+
return this.readUIntBE(offset, byteLength);
|
|
922
|
+
}
|
|
923
|
+
readIntLE(offset, byteLength) {
|
|
924
|
+
let val = this.readUIntLE(offset, byteLength);
|
|
925
|
+
const limit = Math.pow(2, byteLength * 8 - 1);
|
|
926
|
+
if (val >= limit) {
|
|
927
|
+
val -= Math.pow(2, byteLength * 8);
|
|
928
|
+
}
|
|
929
|
+
return val;
|
|
930
|
+
}
|
|
931
|
+
readIntBE(offset, byteLength) {
|
|
932
|
+
let val = this.readUIntBE(offset, byteLength);
|
|
933
|
+
const limit = Math.pow(2, byteLength * 8 - 1);
|
|
934
|
+
if (val >= limit) {
|
|
935
|
+
val -= Math.pow(2, byteLength * 8);
|
|
936
|
+
}
|
|
937
|
+
return val;
|
|
938
|
+
}
|
|
939
|
+
writeUIntLE(value, offset, byteLength) {
|
|
940
|
+
let val = value;
|
|
941
|
+
for (let i = 0; i < byteLength; i++) {
|
|
942
|
+
this[offset + i] = val & 255;
|
|
943
|
+
val = Math.floor(val / 256);
|
|
944
|
+
}
|
|
945
|
+
return offset + byteLength;
|
|
946
|
+
}
|
|
947
|
+
writeUintLE(value, offset, byteLength) {
|
|
948
|
+
return this.writeUIntLE(value, offset, byteLength);
|
|
949
|
+
}
|
|
950
|
+
writeUIntBE(value, offset, byteLength) {
|
|
951
|
+
let val = value;
|
|
952
|
+
for (let i = byteLength - 1; i >= 0; i--) {
|
|
953
|
+
this[offset + i] = val & 255;
|
|
954
|
+
val = Math.floor(val / 256);
|
|
955
|
+
}
|
|
956
|
+
return offset + byteLength;
|
|
957
|
+
}
|
|
958
|
+
writeUintBE(value, offset, byteLength) {
|
|
959
|
+
return this.writeUIntBE(value, offset, byteLength);
|
|
960
|
+
}
|
|
961
|
+
writeIntLE(value, offset, byteLength) {
|
|
962
|
+
let val = value;
|
|
963
|
+
if (val < 0) {
|
|
964
|
+
val += Math.pow(2, byteLength * 8);
|
|
965
|
+
}
|
|
966
|
+
return this.writeUIntLE(val, offset, byteLength);
|
|
967
|
+
}
|
|
968
|
+
writeIntBE(value, offset, byteLength) {
|
|
969
|
+
let val = value;
|
|
970
|
+
if (val < 0) {
|
|
971
|
+
val += Math.pow(2, byteLength * 8);
|
|
972
|
+
}
|
|
973
|
+
return this.writeUIntBE(val, offset, byteLength);
|
|
974
|
+
}
|
|
975
|
+
// Swap methods
|
|
976
|
+
swap16() {
|
|
977
|
+
const len = this.length;
|
|
978
|
+
if (len % 2 !== 0) {
|
|
979
|
+
throw new RangeError("Buffer size must be a multiple of 16-bits");
|
|
980
|
+
}
|
|
981
|
+
for (let i = 0; i < len; i += 2) {
|
|
982
|
+
const a = this[i];
|
|
983
|
+
this[i] = this[i + 1];
|
|
984
|
+
this[i + 1] = a;
|
|
985
|
+
}
|
|
986
|
+
return this;
|
|
987
|
+
}
|
|
988
|
+
swap32() {
|
|
989
|
+
const len = this.length;
|
|
990
|
+
if (len % 4 !== 0) {
|
|
991
|
+
throw new RangeError("Buffer size must be a multiple of 32-bits");
|
|
992
|
+
}
|
|
993
|
+
for (let i = 0; i < len; i += 4) {
|
|
994
|
+
const a = this[i];
|
|
995
|
+
const b = this[i + 1];
|
|
996
|
+
this[i] = this[i + 3];
|
|
997
|
+
this[i + 1] = this[i + 2];
|
|
998
|
+
this[i + 2] = b;
|
|
999
|
+
this[i + 3] = a;
|
|
1000
|
+
}
|
|
1001
|
+
return this;
|
|
1002
|
+
}
|
|
1003
|
+
swap64() {
|
|
1004
|
+
const len = this.length;
|
|
1005
|
+
if (len % 8 !== 0) {
|
|
1006
|
+
throw new RangeError("Buffer size must be a multiple of 64-bits");
|
|
1007
|
+
}
|
|
1008
|
+
for (let i = 0; i < len; i += 8) {
|
|
1009
|
+
const a = this[i];
|
|
1010
|
+
const b = this[i + 1];
|
|
1011
|
+
const c = this[i + 2];
|
|
1012
|
+
const d = this[i + 3];
|
|
1013
|
+
this[i] = this[i + 7];
|
|
1014
|
+
this[i + 1] = this[i + 6];
|
|
1015
|
+
this[i + 2] = this[i + 5];
|
|
1016
|
+
this[i + 3] = this[i + 4];
|
|
1017
|
+
this[i + 4] = d;
|
|
1018
|
+
this[i + 5] = c;
|
|
1019
|
+
this[i + 6] = b;
|
|
1020
|
+
this[i + 7] = a;
|
|
1021
|
+
}
|
|
1022
|
+
return this;
|
|
1023
|
+
}
|
|
1024
|
+
};
|
|
1025
|
+
if (typeof globalThis.Buffer === "undefined") {
|
|
1026
|
+
globalThis.Buffer = BufferPolyfill;
|
|
1027
|
+
}
|
|
1028
|
+
Stream.pipeline = pipeline;
|
|
1029
|
+
Stream.finished = finished;
|
|
1030
|
+
Stream.promises = promises;
|
|
1031
|
+
var stream_default = Stream;
|
|
1032
|
+
|
|
1033
|
+
// node_modules/almostnode/src/shims/http.ts
|
|
1034
|
+
var http_exports = {};
|
|
1035
|
+
__export(http_exports, {
|
|
1036
|
+
Agent: () => Agent,
|
|
1037
|
+
ClientRequest: () => ClientRequest,
|
|
1038
|
+
IncomingMessage: () => IncomingMessage,
|
|
1039
|
+
METHODS: () => METHODS,
|
|
1040
|
+
STATUS_CODES: () => STATUS_CODES,
|
|
1041
|
+
Server: () => Server2,
|
|
1042
|
+
ServerResponse: () => ServerResponse,
|
|
1043
|
+
_createClientRequest: () => _createClientRequest,
|
|
1044
|
+
_createWsFrame: () => _createWsFrame,
|
|
1045
|
+
_parseWsFrame: () => _parseWsFrame,
|
|
1046
|
+
_registerServer: () => _registerServer,
|
|
1047
|
+
_unregisterServer: () => _unregisterServer,
|
|
1048
|
+
createServer: () => createServer2,
|
|
1049
|
+
default: () => http_default,
|
|
1050
|
+
get: () => get,
|
|
1051
|
+
getAllServers: () => getAllServers,
|
|
1052
|
+
getServer: () => getServer,
|
|
1053
|
+
globalAgent: () => globalAgent,
|
|
1054
|
+
request: () => request,
|
|
1055
|
+
setServerCloseCallback: () => setServerCloseCallback,
|
|
1056
|
+
setServerListenCallback: () => setServerListenCallback
|
|
1057
|
+
});
|
|
1058
|
+
|
|
1059
|
+
// node_modules/almostnode/src/shims/net.ts
|
|
1060
|
+
var net_exports = {};
|
|
1061
|
+
__export(net_exports, {
|
|
1062
|
+
Server: () => Server,
|
|
1063
|
+
Socket: () => Socket,
|
|
1064
|
+
connect: () => connect,
|
|
1065
|
+
createConnection: () => createConnection,
|
|
1066
|
+
createServer: () => createServer,
|
|
1067
|
+
default: () => net_default,
|
|
1068
|
+
isIP: () => isIP,
|
|
1069
|
+
isIPv4: () => isIPv4,
|
|
1070
|
+
isIPv6: () => isIPv6
|
|
1071
|
+
});
|
|
1072
|
+
var Socket = class extends Duplex {
|
|
1073
|
+
_connecting = false;
|
|
1074
|
+
_connected = false;
|
|
1075
|
+
_destroyed = false;
|
|
1076
|
+
_remoteAddress = "";
|
|
1077
|
+
_remotePort = 0;
|
|
1078
|
+
_localAddress = "127.0.0.1";
|
|
1079
|
+
_localPort = 0;
|
|
1080
|
+
localAddress = "127.0.0.1";
|
|
1081
|
+
localPort = 0;
|
|
1082
|
+
remoteAddress;
|
|
1083
|
+
remotePort;
|
|
1084
|
+
remoteFamily;
|
|
1085
|
+
connecting = false;
|
|
1086
|
+
destroyed = false;
|
|
1087
|
+
readyState = "closed";
|
|
1088
|
+
constructor(options) {
|
|
1089
|
+
super();
|
|
1090
|
+
}
|
|
1091
|
+
connect(portOrOptions, hostOrCallback, callback) {
|
|
1092
|
+
let port;
|
|
1093
|
+
let host = "127.0.0.1";
|
|
1094
|
+
let cb;
|
|
1095
|
+
if (typeof portOrOptions === "number") {
|
|
1096
|
+
port = portOrOptions;
|
|
1097
|
+
if (typeof hostOrCallback === "string") {
|
|
1098
|
+
host = hostOrCallback;
|
|
1099
|
+
cb = callback;
|
|
1100
|
+
} else {
|
|
1101
|
+
cb = hostOrCallback;
|
|
1102
|
+
}
|
|
1103
|
+
} else {
|
|
1104
|
+
port = portOrOptions.port;
|
|
1105
|
+
host = portOrOptions.host || "127.0.0.1";
|
|
1106
|
+
cb = typeof hostOrCallback === "function" ? hostOrCallback : callback;
|
|
1107
|
+
}
|
|
1108
|
+
this._connecting = true;
|
|
1109
|
+
this.connecting = true;
|
|
1110
|
+
this._remoteAddress = host;
|
|
1111
|
+
this._remotePort = port;
|
|
1112
|
+
this.remoteAddress = host;
|
|
1113
|
+
this.remotePort = port;
|
|
1114
|
+
this.remoteFamily = "IPv4";
|
|
1115
|
+
this.readyState = "opening";
|
|
1116
|
+
queueMicrotask(() => {
|
|
1117
|
+
this._connecting = false;
|
|
1118
|
+
this._connected = true;
|
|
1119
|
+
this.connecting = false;
|
|
1120
|
+
this.readyState = "open";
|
|
1121
|
+
this.emit("connect");
|
|
1122
|
+
if (cb) cb();
|
|
1123
|
+
});
|
|
1124
|
+
return this;
|
|
1125
|
+
}
|
|
1126
|
+
address() {
|
|
1127
|
+
if (!this._connected) return null;
|
|
1128
|
+
return {
|
|
1129
|
+
address: this._localAddress,
|
|
1130
|
+
family: "IPv4",
|
|
1131
|
+
port: this._localPort
|
|
1132
|
+
};
|
|
1133
|
+
}
|
|
1134
|
+
setEncoding(encoding) {
|
|
1135
|
+
return this;
|
|
1136
|
+
}
|
|
1137
|
+
setTimeout(timeout, callback) {
|
|
1138
|
+
if (callback) {
|
|
1139
|
+
this.once("timeout", callback);
|
|
1140
|
+
}
|
|
1141
|
+
return this;
|
|
1142
|
+
}
|
|
1143
|
+
setNoDelay(noDelay) {
|
|
1144
|
+
return this;
|
|
1145
|
+
}
|
|
1146
|
+
setKeepAlive(enable, initialDelay) {
|
|
1147
|
+
return this;
|
|
1148
|
+
}
|
|
1149
|
+
ref() {
|
|
1150
|
+
return this;
|
|
1151
|
+
}
|
|
1152
|
+
unref() {
|
|
1153
|
+
return this;
|
|
1154
|
+
}
|
|
1155
|
+
destroy(error) {
|
|
1156
|
+
if (this._destroyed) return this;
|
|
1157
|
+
this._destroyed = true;
|
|
1158
|
+
this._connected = false;
|
|
1159
|
+
this.destroyed = true;
|
|
1160
|
+
this.readyState = "closed";
|
|
1161
|
+
if (error) {
|
|
1162
|
+
this.emit("error", error);
|
|
1163
|
+
}
|
|
1164
|
+
queueMicrotask(() => {
|
|
1165
|
+
this.emit("close", !!error);
|
|
1166
|
+
});
|
|
1167
|
+
return this;
|
|
1168
|
+
}
|
|
1169
|
+
// Internal: simulate receiving data from remote
|
|
1170
|
+
_receiveData(data) {
|
|
1171
|
+
const buffer = typeof data === "string" ? BufferPolyfill.from(data) : data;
|
|
1172
|
+
this.push(buffer);
|
|
1173
|
+
}
|
|
1174
|
+
// Internal: signal end of remote data
|
|
1175
|
+
_receiveEnd() {
|
|
1176
|
+
this.push(null);
|
|
1177
|
+
}
|
|
1178
|
+
};
|
|
1179
|
+
var Server = class extends EventEmitter {
|
|
1180
|
+
_listening = false;
|
|
1181
|
+
_address = null;
|
|
1182
|
+
_connections = /* @__PURE__ */ new Set();
|
|
1183
|
+
_maxConnections = Infinity;
|
|
1184
|
+
listening = false;
|
|
1185
|
+
maxConnections;
|
|
1186
|
+
constructor(optionsOrConnectionListener, connectionListener) {
|
|
1187
|
+
super();
|
|
1188
|
+
let listener;
|
|
1189
|
+
if (typeof optionsOrConnectionListener === "function") {
|
|
1190
|
+
listener = optionsOrConnectionListener;
|
|
1191
|
+
} else {
|
|
1192
|
+
listener = connectionListener;
|
|
1193
|
+
}
|
|
1194
|
+
if (listener) {
|
|
1195
|
+
this.on("connection", listener);
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
listen(portOrOptions, hostOrCallback, backlogOrCallback, callback) {
|
|
1199
|
+
let port = 0;
|
|
1200
|
+
let host = "0.0.0.0";
|
|
1201
|
+
let cb;
|
|
1202
|
+
if (typeof portOrOptions === "number") {
|
|
1203
|
+
port = portOrOptions;
|
|
1204
|
+
if (typeof hostOrCallback === "string") {
|
|
1205
|
+
host = hostOrCallback;
|
|
1206
|
+
if (typeof backlogOrCallback === "function") {
|
|
1207
|
+
cb = backlogOrCallback;
|
|
1208
|
+
} else {
|
|
1209
|
+
cb = callback;
|
|
1210
|
+
}
|
|
1211
|
+
} else if (typeof hostOrCallback === "function") {
|
|
1212
|
+
cb = hostOrCallback;
|
|
1213
|
+
} else if (typeof hostOrCallback === "number") {
|
|
1214
|
+
cb = typeof backlogOrCallback === "function" ? backlogOrCallback : callback;
|
|
1215
|
+
} else {
|
|
1216
|
+
if (typeof backlogOrCallback === "function") {
|
|
1217
|
+
cb = backlogOrCallback;
|
|
1218
|
+
} else if (typeof callback === "function") {
|
|
1219
|
+
cb = callback;
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
} else if (portOrOptions) {
|
|
1223
|
+
port = portOrOptions.port || 0;
|
|
1224
|
+
host = portOrOptions.host || "0.0.0.0";
|
|
1225
|
+
cb = typeof hostOrCallback === "function" ? hostOrCallback : callback;
|
|
1226
|
+
}
|
|
1227
|
+
if (port === 0) {
|
|
1228
|
+
port = 3e3 + Math.floor(Math.random() * 1e3);
|
|
1229
|
+
}
|
|
1230
|
+
this._address = {
|
|
1231
|
+
address: host,
|
|
1232
|
+
family: "IPv4",
|
|
1233
|
+
port
|
|
1234
|
+
};
|
|
1235
|
+
this._listening = true;
|
|
1236
|
+
this.listening = true;
|
|
1237
|
+
queueMicrotask(() => {
|
|
1238
|
+
this.emit("listening");
|
|
1239
|
+
if (cb) cb();
|
|
1240
|
+
});
|
|
1241
|
+
return this;
|
|
1242
|
+
}
|
|
1243
|
+
address() {
|
|
1244
|
+
return this._address;
|
|
1245
|
+
}
|
|
1246
|
+
close(callback) {
|
|
1247
|
+
this._listening = false;
|
|
1248
|
+
this.listening = false;
|
|
1249
|
+
for (const socket of this._connections) {
|
|
1250
|
+
socket.destroy();
|
|
1251
|
+
}
|
|
1252
|
+
this._connections.clear();
|
|
1253
|
+
queueMicrotask(() => {
|
|
1254
|
+
this.emit("close");
|
|
1255
|
+
if (callback) callback();
|
|
1256
|
+
});
|
|
1257
|
+
return this;
|
|
1258
|
+
}
|
|
1259
|
+
getConnections(callback) {
|
|
1260
|
+
callback(null, this._connections.size);
|
|
1261
|
+
}
|
|
1262
|
+
ref() {
|
|
1263
|
+
return this;
|
|
1264
|
+
}
|
|
1265
|
+
unref() {
|
|
1266
|
+
return this;
|
|
1267
|
+
}
|
|
1268
|
+
// Internal: handle incoming connection
|
|
1269
|
+
_handleConnection(socket) {
|
|
1270
|
+
if (!this._listening) {
|
|
1271
|
+
socket.destroy();
|
|
1272
|
+
return;
|
|
1273
|
+
}
|
|
1274
|
+
this._connections.add(socket);
|
|
1275
|
+
socket.on("close", () => {
|
|
1276
|
+
this._connections.delete(socket);
|
|
1277
|
+
});
|
|
1278
|
+
this.emit("connection", socket);
|
|
1279
|
+
}
|
|
1280
|
+
};
|
|
1281
|
+
function createServer(optionsOrConnectionListener, connectionListener) {
|
|
1282
|
+
return new Server(optionsOrConnectionListener, connectionListener);
|
|
1283
|
+
}
|
|
1284
|
+
function createConnection(portOrOptions, hostOrCallback, callback) {
|
|
1285
|
+
const socket = new Socket();
|
|
1286
|
+
return socket.connect(portOrOptions, hostOrCallback, callback);
|
|
1287
|
+
}
|
|
1288
|
+
var connect = createConnection;
|
|
1289
|
+
function isIP(input) {
|
|
1290
|
+
if (/^(\d{1,3}\.){3}\d{1,3}$/.test(input)) {
|
|
1291
|
+
return 4;
|
|
1292
|
+
}
|
|
1293
|
+
if (/^([0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}$/.test(input)) {
|
|
1294
|
+
return 6;
|
|
1295
|
+
}
|
|
1296
|
+
return 0;
|
|
1297
|
+
}
|
|
1298
|
+
function isIPv4(input) {
|
|
1299
|
+
return isIP(input) === 4;
|
|
1300
|
+
}
|
|
1301
|
+
function isIPv6(input) {
|
|
1302
|
+
return isIP(input) === 6;
|
|
1303
|
+
}
|
|
1304
|
+
var net_default = {
|
|
1305
|
+
Socket,
|
|
1306
|
+
Server,
|
|
1307
|
+
createServer,
|
|
1308
|
+
createConnection,
|
|
1309
|
+
connect,
|
|
1310
|
+
isIP,
|
|
1311
|
+
isIPv4,
|
|
1312
|
+
isIPv6
|
|
1313
|
+
};
|
|
1314
|
+
|
|
1315
|
+
// node_modules/almostnode/src/shims/crypto.ts
|
|
1316
|
+
var crypto_exports = {};
|
|
1317
|
+
__export(crypto_exports, {
|
|
1318
|
+
KeyObject: () => KeyObject,
|
|
1319
|
+
constants: () => constants,
|
|
1320
|
+
createHash: () => createHash,
|
|
1321
|
+
createHmac: () => createHmac,
|
|
1322
|
+
createPrivateKey: () => createPrivateKey,
|
|
1323
|
+
createPublicKey: () => createPublicKey,
|
|
1324
|
+
createSecretKey: () => createSecretKey,
|
|
1325
|
+
createSign: () => createSign,
|
|
1326
|
+
createVerify: () => createVerify,
|
|
1327
|
+
default: () => crypto_default,
|
|
1328
|
+
getCiphers: () => getCiphers,
|
|
1329
|
+
getHashes: () => getHashes,
|
|
1330
|
+
getRandomValues: () => getRandomValues,
|
|
1331
|
+
pbkdf2: () => pbkdf2,
|
|
1332
|
+
pbkdf2Sync: () => pbkdf2Sync,
|
|
1333
|
+
randomBytes: () => randomBytes,
|
|
1334
|
+
randomFillSync: () => randomFillSync,
|
|
1335
|
+
randomInt: () => randomInt,
|
|
1336
|
+
randomUUID: () => randomUUID,
|
|
1337
|
+
sign: () => sign,
|
|
1338
|
+
timingSafeEqual: () => timingSafeEqual,
|
|
1339
|
+
verify: () => verify
|
|
1340
|
+
});
|
|
1341
|
+
function randomBytes(size) {
|
|
1342
|
+
const array = new Uint8Array(size);
|
|
1343
|
+
crypto.getRandomValues(array);
|
|
1344
|
+
return BufferPolyfill.from(array);
|
|
1345
|
+
}
|
|
1346
|
+
function randomFillSync(buffer, offset, size) {
|
|
1347
|
+
const start = offset || 0;
|
|
1348
|
+
const len = size !== void 0 ? size : buffer.length - start;
|
|
1349
|
+
const view = new Uint8Array(buffer.buffer, buffer.byteOffset + start, len);
|
|
1350
|
+
crypto.getRandomValues(view);
|
|
1351
|
+
return buffer;
|
|
1352
|
+
}
|
|
1353
|
+
function randomUUID() {
|
|
1354
|
+
return crypto.randomUUID();
|
|
1355
|
+
}
|
|
1356
|
+
function randomInt(min, max) {
|
|
1357
|
+
if (max === void 0) {
|
|
1358
|
+
max = min;
|
|
1359
|
+
min = 0;
|
|
1360
|
+
}
|
|
1361
|
+
const range = max - min;
|
|
1362
|
+
const array = new Uint32Array(1);
|
|
1363
|
+
crypto.getRandomValues(array);
|
|
1364
|
+
return min + array[0] % range;
|
|
1365
|
+
}
|
|
1366
|
+
function getRandomValues(array) {
|
|
1367
|
+
return crypto.getRandomValues(array);
|
|
1368
|
+
}
|
|
1369
|
+
function createHash(algorithm) {
|
|
1370
|
+
return new Hash(algorithm);
|
|
1371
|
+
}
|
|
1372
|
+
var Hash = class {
|
|
1373
|
+
algorithm;
|
|
1374
|
+
data = [];
|
|
1375
|
+
constructor(algorithm) {
|
|
1376
|
+
this.algorithm = normalizeHashAlgorithm(algorithm);
|
|
1377
|
+
}
|
|
1378
|
+
update(data, encoding) {
|
|
1379
|
+
let buffer;
|
|
1380
|
+
if (typeof data === "string") {
|
|
1381
|
+
if (encoding === "base64") {
|
|
1382
|
+
buffer = BufferPolyfill.from(atob(data));
|
|
1383
|
+
} else {
|
|
1384
|
+
buffer = BufferPolyfill.from(data);
|
|
1385
|
+
}
|
|
1386
|
+
} else {
|
|
1387
|
+
buffer = BufferPolyfill.from(data);
|
|
1388
|
+
}
|
|
1389
|
+
this.data.push(buffer);
|
|
1390
|
+
return this;
|
|
1391
|
+
}
|
|
1392
|
+
async digestAsync(encoding) {
|
|
1393
|
+
const combined = concatBuffers(this.data);
|
|
1394
|
+
const dataBuffer = new Uint8Array(combined).buffer;
|
|
1395
|
+
const hashBuffer = await crypto.subtle.digest(this.algorithm, dataBuffer);
|
|
1396
|
+
return encodeResult(new Uint8Array(hashBuffer), encoding);
|
|
1397
|
+
}
|
|
1398
|
+
digest(encoding) {
|
|
1399
|
+
const combined = concatBuffers(this.data);
|
|
1400
|
+
const hash = syncHash(combined, this.algorithm);
|
|
1401
|
+
return encodeResult(hash, encoding);
|
|
1402
|
+
}
|
|
1403
|
+
};
|
|
1404
|
+
function createHmac(algorithm, key) {
|
|
1405
|
+
return new Hmac(algorithm, key);
|
|
1406
|
+
}
|
|
1407
|
+
var Hmac = class {
|
|
1408
|
+
algorithm;
|
|
1409
|
+
key;
|
|
1410
|
+
data = [];
|
|
1411
|
+
constructor(algorithm, key) {
|
|
1412
|
+
this.algorithm = normalizeHashAlgorithm(algorithm);
|
|
1413
|
+
this.key = typeof key === "string" ? BufferPolyfill.from(key) : key;
|
|
1414
|
+
}
|
|
1415
|
+
update(data, encoding) {
|
|
1416
|
+
const buffer = typeof data === "string" ? BufferPolyfill.from(data) : data;
|
|
1417
|
+
this.data.push(buffer);
|
|
1418
|
+
return this;
|
|
1419
|
+
}
|
|
1420
|
+
async digestAsync(encoding) {
|
|
1421
|
+
const combined = concatBuffers(this.data);
|
|
1422
|
+
const keyBuffer = new Uint8Array(this.key).buffer;
|
|
1423
|
+
const dataBuffer = new Uint8Array(combined).buffer;
|
|
1424
|
+
const cryptoKey = await crypto.subtle.importKey(
|
|
1425
|
+
"raw",
|
|
1426
|
+
keyBuffer,
|
|
1427
|
+
{ name: "HMAC", hash: this.algorithm },
|
|
1428
|
+
false,
|
|
1429
|
+
["sign"]
|
|
1430
|
+
);
|
|
1431
|
+
const signature = await crypto.subtle.sign("HMAC", cryptoKey, dataBuffer);
|
|
1432
|
+
return encodeResult(new Uint8Array(signature), encoding);
|
|
1433
|
+
}
|
|
1434
|
+
digest(encoding) {
|
|
1435
|
+
const combined = concatBuffers(this.data);
|
|
1436
|
+
const hash = syncHmac(combined, this.key, this.algorithm);
|
|
1437
|
+
return encodeResult(hash, encoding);
|
|
1438
|
+
}
|
|
1439
|
+
};
|
|
1440
|
+
async function pbkdf2Async(password, salt, iterations, keylen, digest) {
|
|
1441
|
+
const passwordBuffer = typeof password === "string" ? BufferPolyfill.from(password) : password instanceof Uint8Array ? password : BufferPolyfill.from(password);
|
|
1442
|
+
const saltBuffer = typeof salt === "string" ? BufferPolyfill.from(salt) : salt instanceof Uint8Array ? salt : BufferPolyfill.from(salt);
|
|
1443
|
+
const passwordArrayBuffer = new Uint8Array(passwordBuffer).buffer;
|
|
1444
|
+
const saltArrayBuffer = new Uint8Array(saltBuffer).buffer;
|
|
1445
|
+
const key = await crypto.subtle.importKey(
|
|
1446
|
+
"raw",
|
|
1447
|
+
passwordArrayBuffer,
|
|
1448
|
+
"PBKDF2",
|
|
1449
|
+
false,
|
|
1450
|
+
["deriveBits"]
|
|
1451
|
+
);
|
|
1452
|
+
const derivedBits = await crypto.subtle.deriveBits(
|
|
1453
|
+
{
|
|
1454
|
+
name: "PBKDF2",
|
|
1455
|
+
salt: saltArrayBuffer,
|
|
1456
|
+
iterations,
|
|
1457
|
+
hash: normalizeHashAlgorithm(digest)
|
|
1458
|
+
},
|
|
1459
|
+
key,
|
|
1460
|
+
keylen * 8
|
|
1461
|
+
// Convert bytes to bits
|
|
1462
|
+
);
|
|
1463
|
+
return BufferPolyfill.from(derivedBits);
|
|
1464
|
+
}
|
|
1465
|
+
function pbkdf2(password, salt, iterations, keylen, digest, callback) {
|
|
1466
|
+
pbkdf2Async(password, salt, iterations, keylen, digest).then((key) => callback(null, key)).catch((err) => callback(err, BufferPolyfill.alloc(0)));
|
|
1467
|
+
}
|
|
1468
|
+
function pbkdf2Sync(password, salt, iterations, keylen, digest) {
|
|
1469
|
+
const passwordBuffer = typeof password === "string" ? BufferPolyfill.from(password) : password;
|
|
1470
|
+
const saltBuffer = typeof salt === "string" ? BufferPolyfill.from(salt) : salt;
|
|
1471
|
+
const hashAlg = normalizeHashAlgorithm(digest);
|
|
1472
|
+
let hashLen;
|
|
1473
|
+
if (hashAlg.includes("512")) {
|
|
1474
|
+
hashLen = 64;
|
|
1475
|
+
} else if (hashAlg.includes("384")) {
|
|
1476
|
+
hashLen = 48;
|
|
1477
|
+
} else if (hashAlg.includes("1") || hashAlg === "SHA-1") {
|
|
1478
|
+
hashLen = 20;
|
|
1479
|
+
} else {
|
|
1480
|
+
hashLen = 32;
|
|
1481
|
+
}
|
|
1482
|
+
const numBlocks = Math.ceil(keylen / hashLen);
|
|
1483
|
+
const derivedKey = new Uint8Array(numBlocks * hashLen);
|
|
1484
|
+
for (let blockNum = 1; blockNum <= numBlocks; blockNum++) {
|
|
1485
|
+
const blockNumBuf = new Uint8Array(4);
|
|
1486
|
+
blockNumBuf[0] = blockNum >>> 24 & 255;
|
|
1487
|
+
blockNumBuf[1] = blockNum >>> 16 & 255;
|
|
1488
|
+
blockNumBuf[2] = blockNum >>> 8 & 255;
|
|
1489
|
+
blockNumBuf[3] = blockNum & 255;
|
|
1490
|
+
const saltWithBlock = new Uint8Array(saltBuffer.length + 4);
|
|
1491
|
+
saltWithBlock.set(saltBuffer);
|
|
1492
|
+
saltWithBlock.set(blockNumBuf, saltBuffer.length);
|
|
1493
|
+
let u = syncHmac(saltWithBlock, passwordBuffer, hashAlg);
|
|
1494
|
+
const block = new Uint8Array(u);
|
|
1495
|
+
for (let i = 1; i < iterations; i++) {
|
|
1496
|
+
u = syncHmac(u, passwordBuffer, hashAlg);
|
|
1497
|
+
for (let j = 0; j < block.length; j++) {
|
|
1498
|
+
block[j] ^= u[j];
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
derivedKey.set(block, (blockNum - 1) * hashLen);
|
|
1502
|
+
}
|
|
1503
|
+
return BufferPolyfill.from(derivedKey.slice(0, keylen));
|
|
1504
|
+
}
|
|
1505
|
+
function sign(algorithm, data, key, callback) {
|
|
1506
|
+
const keyInfo = extractKeyInfo(key);
|
|
1507
|
+
const alg = algorithm || keyInfo.algorithm;
|
|
1508
|
+
if (!alg) {
|
|
1509
|
+
const error = new Error("Algorithm must be specified");
|
|
1510
|
+
if (callback) {
|
|
1511
|
+
callback(error, null);
|
|
1512
|
+
return;
|
|
1513
|
+
}
|
|
1514
|
+
throw error;
|
|
1515
|
+
}
|
|
1516
|
+
if (callback) {
|
|
1517
|
+
signAsync(alg, data, keyInfo).then((sig) => callback(null, sig)).catch((err) => callback(err, null));
|
|
1518
|
+
return;
|
|
1519
|
+
}
|
|
1520
|
+
const result = signSync(alg, data, keyInfo);
|
|
1521
|
+
return result;
|
|
1522
|
+
}
|
|
1523
|
+
function verify(algorithm, data, key, signature, callback) {
|
|
1524
|
+
const keyInfo = extractKeyInfo(key);
|
|
1525
|
+
const alg = algorithm || keyInfo.algorithm;
|
|
1526
|
+
if (!alg) {
|
|
1527
|
+
const error = new Error("Algorithm must be specified");
|
|
1528
|
+
if (callback) {
|
|
1529
|
+
callback(error, false);
|
|
1530
|
+
return;
|
|
1531
|
+
}
|
|
1532
|
+
throw error;
|
|
1533
|
+
}
|
|
1534
|
+
if (callback) {
|
|
1535
|
+
verifyAsync(alg, data, keyInfo, signature).then((result) => callback(null, result)).catch((err) => callback(err, false));
|
|
1536
|
+
return;
|
|
1537
|
+
}
|
|
1538
|
+
return verifySync(alg, data, keyInfo, signature);
|
|
1539
|
+
}
|
|
1540
|
+
function createSign(algorithm) {
|
|
1541
|
+
return new Sign(algorithm);
|
|
1542
|
+
}
|
|
1543
|
+
function createVerify(algorithm) {
|
|
1544
|
+
return new Verify(algorithm);
|
|
1545
|
+
}
|
|
1546
|
+
var Sign = class extends EventEmitter {
|
|
1547
|
+
algorithm;
|
|
1548
|
+
data = [];
|
|
1549
|
+
constructor(algorithm) {
|
|
1550
|
+
super();
|
|
1551
|
+
this.algorithm = algorithm;
|
|
1552
|
+
}
|
|
1553
|
+
update(data, encoding) {
|
|
1554
|
+
const buffer = typeof data === "string" ? BufferPolyfill.from(data) : data;
|
|
1555
|
+
this.data.push(buffer);
|
|
1556
|
+
return this;
|
|
1557
|
+
}
|
|
1558
|
+
sign(privateKey, outputEncoding) {
|
|
1559
|
+
const combined = concatBuffers(this.data);
|
|
1560
|
+
const keyInfo = extractKeyInfo(privateKey);
|
|
1561
|
+
const signature = signSync(this.algorithm, combined, keyInfo);
|
|
1562
|
+
if (outputEncoding === "base64") {
|
|
1563
|
+
return btoa(String.fromCharCode(...signature));
|
|
1564
|
+
}
|
|
1565
|
+
if (outputEncoding === "hex") {
|
|
1566
|
+
return Array.from(signature).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1567
|
+
}
|
|
1568
|
+
return signature;
|
|
1569
|
+
}
|
|
1570
|
+
};
|
|
1571
|
+
var Verify = class extends EventEmitter {
|
|
1572
|
+
algorithm;
|
|
1573
|
+
data = [];
|
|
1574
|
+
constructor(algorithm) {
|
|
1575
|
+
super();
|
|
1576
|
+
this.algorithm = algorithm;
|
|
1577
|
+
}
|
|
1578
|
+
update(data, encoding) {
|
|
1579
|
+
const buffer = typeof data === "string" ? BufferPolyfill.from(data) : data;
|
|
1580
|
+
this.data.push(buffer);
|
|
1581
|
+
return this;
|
|
1582
|
+
}
|
|
1583
|
+
verify(publicKey, signature, signatureEncoding) {
|
|
1584
|
+
const combined = concatBuffers(this.data);
|
|
1585
|
+
const keyInfo = extractKeyInfo(publicKey);
|
|
1586
|
+
let sig;
|
|
1587
|
+
if (typeof signature === "string") {
|
|
1588
|
+
if (signatureEncoding === "base64") {
|
|
1589
|
+
sig = BufferPolyfill.from(atob(signature));
|
|
1590
|
+
} else if (signatureEncoding === "hex") {
|
|
1591
|
+
sig = BufferPolyfill.from(signature.match(/.{2}/g).map((byte) => parseInt(byte, 16)));
|
|
1592
|
+
} else {
|
|
1593
|
+
sig = BufferPolyfill.from(signature);
|
|
1594
|
+
}
|
|
1595
|
+
} else {
|
|
1596
|
+
sig = signature;
|
|
1597
|
+
}
|
|
1598
|
+
return verifySync(this.algorithm, combined, keyInfo, sig);
|
|
1599
|
+
}
|
|
1600
|
+
};
|
|
1601
|
+
var KeyObject = class {
|
|
1602
|
+
_keyData;
|
|
1603
|
+
_type;
|
|
1604
|
+
_algorithm;
|
|
1605
|
+
constructor(type, keyData, algorithm) {
|
|
1606
|
+
this._type = type;
|
|
1607
|
+
this._keyData = keyData;
|
|
1608
|
+
this._algorithm = algorithm;
|
|
1609
|
+
}
|
|
1610
|
+
get type() {
|
|
1611
|
+
return this._type;
|
|
1612
|
+
}
|
|
1613
|
+
get asymmetricKeyType() {
|
|
1614
|
+
if (this._type === "secret") return void 0;
|
|
1615
|
+
if (this._algorithm?.includes("RSA")) return "rsa";
|
|
1616
|
+
if (this._algorithm?.includes("EC") || this._algorithm?.includes("ES")) return "ec";
|
|
1617
|
+
if (this._algorithm?.includes("Ed")) return "ed25519";
|
|
1618
|
+
return void 0;
|
|
1619
|
+
}
|
|
1620
|
+
get symmetricKeySize() {
|
|
1621
|
+
if (this._type !== "secret") return void 0;
|
|
1622
|
+
if (this._keyData instanceof Uint8Array) {
|
|
1623
|
+
return this._keyData.length * 8;
|
|
1624
|
+
}
|
|
1625
|
+
return void 0;
|
|
1626
|
+
}
|
|
1627
|
+
export(options) {
|
|
1628
|
+
if (this._keyData instanceof Uint8Array) {
|
|
1629
|
+
return BufferPolyfill.from(this._keyData);
|
|
1630
|
+
}
|
|
1631
|
+
throw new Error("Cannot export CryptoKey synchronously");
|
|
1632
|
+
}
|
|
1633
|
+
};
|
|
1634
|
+
function createSecretKey(key, encoding) {
|
|
1635
|
+
const keyBuffer = typeof key === "string" ? BufferPolyfill.from(key, encoding) : key;
|
|
1636
|
+
return new KeyObject("secret", keyBuffer);
|
|
1637
|
+
}
|
|
1638
|
+
function createPublicKey(key) {
|
|
1639
|
+
const keyInfo = extractKeyInfo(key);
|
|
1640
|
+
return new KeyObject("public", keyInfo.keyData, keyInfo.algorithm);
|
|
1641
|
+
}
|
|
1642
|
+
function createPrivateKey(key) {
|
|
1643
|
+
const keyInfo = extractKeyInfo(key);
|
|
1644
|
+
return new KeyObject("private", keyInfo.keyData, keyInfo.algorithm);
|
|
1645
|
+
}
|
|
1646
|
+
function timingSafeEqual(a, b) {
|
|
1647
|
+
if (a.length !== b.length) {
|
|
1648
|
+
return false;
|
|
1649
|
+
}
|
|
1650
|
+
let result = 0;
|
|
1651
|
+
for (let i = 0; i < a.length; i++) {
|
|
1652
|
+
result |= a[i] ^ b[i];
|
|
1653
|
+
}
|
|
1654
|
+
return result === 0;
|
|
1655
|
+
}
|
|
1656
|
+
function getCiphers() {
|
|
1657
|
+
return ["aes-128-cbc", "aes-256-cbc", "aes-128-gcm", "aes-256-gcm"];
|
|
1658
|
+
}
|
|
1659
|
+
function getHashes() {
|
|
1660
|
+
return ["sha1", "sha256", "sha384", "sha512"];
|
|
1661
|
+
}
|
|
1662
|
+
var constants = {
|
|
1663
|
+
SSL_OP_ALL: 0,
|
|
1664
|
+
RSA_PKCS1_PADDING: 1,
|
|
1665
|
+
RSA_PKCS1_OAEP_PADDING: 4,
|
|
1666
|
+
RSA_PKCS1_PSS_PADDING: 6
|
|
1667
|
+
};
|
|
1668
|
+
function normalizeHashAlgorithm(alg) {
|
|
1669
|
+
const normalized = alg.toUpperCase().replace(/[^A-Z0-9]/g, "");
|
|
1670
|
+
switch (normalized) {
|
|
1671
|
+
case "SHA1":
|
|
1672
|
+
return "SHA-1";
|
|
1673
|
+
case "SHA256":
|
|
1674
|
+
return "SHA-256";
|
|
1675
|
+
case "SHA384":
|
|
1676
|
+
return "SHA-384";
|
|
1677
|
+
case "SHA512":
|
|
1678
|
+
return "SHA-512";
|
|
1679
|
+
case "MD5":
|
|
1680
|
+
return "MD5";
|
|
1681
|
+
// Not supported by WebCrypto
|
|
1682
|
+
default:
|
|
1683
|
+
return alg;
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
function getWebCryptoAlgorithm(nodeAlgorithm) {
|
|
1687
|
+
const alg = nodeAlgorithm.toUpperCase().replace(/[^A-Z0-9]/g, "");
|
|
1688
|
+
if (alg.includes("RSA")) {
|
|
1689
|
+
if (alg.includes("PSS")) {
|
|
1690
|
+
const hash2 = alg.match(/SHA(\d+)/)?.[0] || "SHA-256";
|
|
1691
|
+
return { name: "RSA-PSS", hash: `SHA-${hash2.replace("SHA", "")}` };
|
|
1692
|
+
}
|
|
1693
|
+
const hash = alg.match(/SHA(\d+)/)?.[0] || "SHA-256";
|
|
1694
|
+
return { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${hash.replace("SHA", "")}` };
|
|
1695
|
+
}
|
|
1696
|
+
if (alg.startsWith("ES") || alg.includes("ECDSA")) {
|
|
1697
|
+
const bits = alg.match(/\d+/)?.[0] || "256";
|
|
1698
|
+
const hash = bits === "512" ? "SHA-512" : bits === "384" ? "SHA-384" : "SHA-256";
|
|
1699
|
+
return { name: "ECDSA", hash };
|
|
1700
|
+
}
|
|
1701
|
+
if (alg.includes("ED25519") || alg === "EDDSA") {
|
|
1702
|
+
return { name: "Ed25519" };
|
|
1703
|
+
}
|
|
1704
|
+
if (alg.includes("HS") || alg.includes("HMAC")) {
|
|
1705
|
+
const bits = alg.match(/\d+/)?.[0] || "256";
|
|
1706
|
+
return { name: "HMAC", hash: `SHA-${bits}` };
|
|
1707
|
+
}
|
|
1708
|
+
return { name: "RSASSA-PKCS1-v1_5", hash: "SHA-256" };
|
|
1709
|
+
}
|
|
1710
|
+
function extractKeyInfo(key) {
|
|
1711
|
+
if (key instanceof KeyObject) {
|
|
1712
|
+
return {
|
|
1713
|
+
keyData: key._keyData,
|
|
1714
|
+
algorithm: key._algorithm,
|
|
1715
|
+
type: key._type,
|
|
1716
|
+
format: "raw"
|
|
1717
|
+
};
|
|
1718
|
+
}
|
|
1719
|
+
if (typeof key === "object" && "key" in key) {
|
|
1720
|
+
return extractKeyInfo(key.key);
|
|
1721
|
+
}
|
|
1722
|
+
const keyStr = typeof key === "string" ? key : key.toString();
|
|
1723
|
+
if (keyStr.includes("-----BEGIN")) {
|
|
1724
|
+
const isPrivate = keyStr.includes("PRIVATE");
|
|
1725
|
+
const isPublic = keyStr.includes("PUBLIC");
|
|
1726
|
+
const base64 = keyStr.replace(/-----BEGIN [^-]+-----/, "").replace(/-----END [^-]+-----/, "").replace(/\s/g, "");
|
|
1727
|
+
const keyData2 = BufferPolyfill.from(atob(base64));
|
|
1728
|
+
let algorithm;
|
|
1729
|
+
if (keyStr.includes("RSA")) algorithm = "RSA-SHA256";
|
|
1730
|
+
else if (keyStr.includes("EC")) algorithm = "ES256";
|
|
1731
|
+
else if (keyStr.includes("ED25519")) algorithm = "Ed25519";
|
|
1732
|
+
return {
|
|
1733
|
+
keyData: keyData2,
|
|
1734
|
+
algorithm,
|
|
1735
|
+
type: isPrivate ? "private" : isPublic ? "public" : "secret",
|
|
1736
|
+
format: "pem"
|
|
1737
|
+
};
|
|
1738
|
+
}
|
|
1739
|
+
const keyData = typeof key === "string" ? BufferPolyfill.from(key) : key;
|
|
1740
|
+
return {
|
|
1741
|
+
keyData,
|
|
1742
|
+
type: "secret",
|
|
1743
|
+
format: "raw"
|
|
1744
|
+
};
|
|
1745
|
+
}
|
|
1746
|
+
function concatBuffers(buffers) {
|
|
1747
|
+
const totalLength = buffers.reduce((acc, arr) => acc + arr.length, 0);
|
|
1748
|
+
const result = new Uint8Array(totalLength);
|
|
1749
|
+
let offset = 0;
|
|
1750
|
+
for (const buf of buffers) {
|
|
1751
|
+
result.set(buf, offset);
|
|
1752
|
+
offset += buf.length;
|
|
1753
|
+
}
|
|
1754
|
+
return result;
|
|
1755
|
+
}
|
|
1756
|
+
function encodeResult(data, encoding) {
|
|
1757
|
+
if (encoding === "hex") {
|
|
1758
|
+
return Array.from(data).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1759
|
+
}
|
|
1760
|
+
if (encoding === "base64") {
|
|
1761
|
+
return btoa(String.fromCharCode(...data));
|
|
1762
|
+
}
|
|
1763
|
+
return BufferPolyfill.from(data);
|
|
1764
|
+
}
|
|
1765
|
+
function syncHash(data, algorithm) {
|
|
1766
|
+
let size;
|
|
1767
|
+
if (algorithm.includes("512")) {
|
|
1768
|
+
size = 64;
|
|
1769
|
+
} else if (algorithm.includes("384")) {
|
|
1770
|
+
size = 48;
|
|
1771
|
+
} else if (algorithm.includes("1") || algorithm === "SHA-1") {
|
|
1772
|
+
size = 20;
|
|
1773
|
+
} else {
|
|
1774
|
+
size = 32;
|
|
1775
|
+
}
|
|
1776
|
+
const result = new Uint8Array(size);
|
|
1777
|
+
let h1 = 3735928559;
|
|
1778
|
+
let h2 = 1103547991;
|
|
1779
|
+
for (let i = 0; i < data.length; i++) {
|
|
1780
|
+
h1 = Math.imul(h1 ^ data[i], 2654435761);
|
|
1781
|
+
h2 = Math.imul(h2 ^ data[i], 1597334677);
|
|
1782
|
+
}
|
|
1783
|
+
h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
|
|
1784
|
+
h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
|
|
1785
|
+
for (let i = 0; i < size; i++) {
|
|
1786
|
+
const mix = i < size / 2 ? h1 : h2;
|
|
1787
|
+
result[i] = mix >>> i % 4 * 8 & 255;
|
|
1788
|
+
h1 = Math.imul(h1, 1103515245) + 12345;
|
|
1789
|
+
h2 = Math.imul(h2, 1103515245) + 12345;
|
|
1790
|
+
}
|
|
1791
|
+
return result;
|
|
1792
|
+
}
|
|
1793
|
+
function syncHmac(data, key, algorithm) {
|
|
1794
|
+
const combined = new Uint8Array(key.length + data.length);
|
|
1795
|
+
combined.set(key, 0);
|
|
1796
|
+
combined.set(data, key.length);
|
|
1797
|
+
return syncHash(combined, algorithm);
|
|
1798
|
+
}
|
|
1799
|
+
async function signAsync(algorithm, data, keyInfo) {
|
|
1800
|
+
const webCryptoAlg = getWebCryptoAlgorithm(algorithm);
|
|
1801
|
+
try {
|
|
1802
|
+
const cryptoKey = await importKey(keyInfo, webCryptoAlg, ["sign"]);
|
|
1803
|
+
const signatureAlg = webCryptoAlg.hash ? { name: webCryptoAlg.name, hash: webCryptoAlg.hash } : { name: webCryptoAlg.name };
|
|
1804
|
+
const dataBuffer = new Uint8Array(data).buffer;
|
|
1805
|
+
const signature = await crypto.subtle.sign(signatureAlg, cryptoKey, dataBuffer);
|
|
1806
|
+
return BufferPolyfill.from(signature);
|
|
1807
|
+
} catch (error) {
|
|
1808
|
+
console.warn("WebCrypto sign failed, using fallback:", error);
|
|
1809
|
+
return signSync(algorithm, data, keyInfo);
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
async function verifyAsync(algorithm, data, keyInfo, signature) {
|
|
1813
|
+
const webCryptoAlg = getWebCryptoAlgorithm(algorithm);
|
|
1814
|
+
try {
|
|
1815
|
+
const cryptoKey = await importKey(keyInfo, webCryptoAlg, ["verify"]);
|
|
1816
|
+
const verifyAlg = webCryptoAlg.hash ? { name: webCryptoAlg.name, hash: webCryptoAlg.hash } : { name: webCryptoAlg.name };
|
|
1817
|
+
const sigBuffer = new Uint8Array(signature).buffer;
|
|
1818
|
+
const dataBuffer = new Uint8Array(data).buffer;
|
|
1819
|
+
return await crypto.subtle.verify(verifyAlg, cryptoKey, sigBuffer, dataBuffer);
|
|
1820
|
+
} catch (error) {
|
|
1821
|
+
console.warn("WebCrypto verify failed, using fallback:", error);
|
|
1822
|
+
return verifySync(algorithm, data, keyInfo, signature);
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
function signSync(algorithm, data, keyInfo) {
|
|
1826
|
+
const keyData = keyInfo.keyData instanceof Uint8Array ? keyInfo.keyData : new Uint8Array(0);
|
|
1827
|
+
const combined = new Uint8Array(keyData.length + data.length);
|
|
1828
|
+
combined.set(keyData, 0);
|
|
1829
|
+
combined.set(data, keyData.length);
|
|
1830
|
+
const hash = syncHash(combined, algorithm);
|
|
1831
|
+
return BufferPolyfill.from(hash);
|
|
1832
|
+
}
|
|
1833
|
+
function verifySync(algorithm, data, keyInfo, signature) {
|
|
1834
|
+
const expectedSig = signSync(algorithm, data, keyInfo);
|
|
1835
|
+
return timingSafeEqual(BufferPolyfill.from(signature), expectedSig);
|
|
1836
|
+
}
|
|
1837
|
+
async function importKey(keyInfo, algorithm, usages) {
|
|
1838
|
+
if (keyInfo.keyData instanceof CryptoKey) {
|
|
1839
|
+
return keyInfo.keyData;
|
|
1840
|
+
}
|
|
1841
|
+
const keyData = keyInfo.keyData;
|
|
1842
|
+
const keyBuffer = new Uint8Array(keyData).buffer;
|
|
1843
|
+
if (keyInfo.format === "pem") {
|
|
1844
|
+
const format = keyInfo.type === "private" ? "pkcs8" : "spki";
|
|
1845
|
+
const importAlg = algorithm.name === "ECDSA" ? { name: "ECDSA", namedCurve: "P-256" } : algorithm.name === "Ed25519" ? { name: "Ed25519" } : { name: algorithm.name, hash: algorithm.hash || "SHA-256" };
|
|
1846
|
+
return await crypto.subtle.importKey(
|
|
1847
|
+
format,
|
|
1848
|
+
keyBuffer,
|
|
1849
|
+
importAlg,
|
|
1850
|
+
true,
|
|
1851
|
+
usages
|
|
1852
|
+
);
|
|
1853
|
+
}
|
|
1854
|
+
if (keyInfo.type === "secret") {
|
|
1855
|
+
return await crypto.subtle.importKey(
|
|
1856
|
+
"raw",
|
|
1857
|
+
keyBuffer,
|
|
1858
|
+
{ name: algorithm.name, hash: algorithm.hash },
|
|
1859
|
+
true,
|
|
1860
|
+
usages
|
|
1861
|
+
);
|
|
1862
|
+
}
|
|
1863
|
+
throw new Error(`Unsupported key format: ${keyInfo.format}`);
|
|
1864
|
+
}
|
|
1865
|
+
var crypto_default = {
|
|
1866
|
+
randomBytes,
|
|
1867
|
+
randomFillSync,
|
|
1868
|
+
randomUUID,
|
|
1869
|
+
randomInt,
|
|
1870
|
+
getRandomValues,
|
|
1871
|
+
createHash,
|
|
1872
|
+
createHmac,
|
|
1873
|
+
createSign,
|
|
1874
|
+
createVerify,
|
|
1875
|
+
sign,
|
|
1876
|
+
verify,
|
|
1877
|
+
pbkdf2,
|
|
1878
|
+
pbkdf2Sync,
|
|
1879
|
+
timingSafeEqual,
|
|
1880
|
+
getCiphers,
|
|
1881
|
+
getHashes,
|
|
1882
|
+
constants,
|
|
1883
|
+
KeyObject,
|
|
1884
|
+
createSecretKey,
|
|
1885
|
+
createPublicKey,
|
|
1886
|
+
createPrivateKey
|
|
1887
|
+
};
|
|
1888
|
+
|
|
1889
|
+
// node_modules/almostnode/src/shims/http.ts
|
|
1890
|
+
var _isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
1891
|
+
var _BrowserWebSocket = _isBrowser && typeof globalThis.WebSocket === "function" ? globalThis.WebSocket : null;
|
|
1892
|
+
var IncomingMessage = class _IncomingMessage extends Readable {
|
|
1893
|
+
httpVersion = "1.1";
|
|
1894
|
+
httpVersionMajor = 1;
|
|
1895
|
+
httpVersionMinor = 1;
|
|
1896
|
+
complete = false;
|
|
1897
|
+
headers = {};
|
|
1898
|
+
rawHeaders = [];
|
|
1899
|
+
trailers = {};
|
|
1900
|
+
rawTrailers = [];
|
|
1901
|
+
method;
|
|
1902
|
+
url;
|
|
1903
|
+
statusCode;
|
|
1904
|
+
statusMessage;
|
|
1905
|
+
socket;
|
|
1906
|
+
_body = null;
|
|
1907
|
+
constructor(socket) {
|
|
1908
|
+
super();
|
|
1909
|
+
this.socket = socket || new Socket();
|
|
1910
|
+
}
|
|
1911
|
+
setTimeout(msecs, callback) {
|
|
1912
|
+
if (callback) {
|
|
1913
|
+
this.once("timeout", callback);
|
|
1914
|
+
}
|
|
1915
|
+
return this;
|
|
1916
|
+
}
|
|
1917
|
+
destroy(error) {
|
|
1918
|
+
super.destroy(error);
|
|
1919
|
+
return this;
|
|
1920
|
+
}
|
|
1921
|
+
// Internal: set body data
|
|
1922
|
+
_setBody(body) {
|
|
1923
|
+
if (body === null) {
|
|
1924
|
+
this._body = null;
|
|
1925
|
+
} else {
|
|
1926
|
+
this._body = typeof body === "string" ? BufferPolyfill.from(body) : body;
|
|
1927
|
+
}
|
|
1928
|
+
if (this._body) {
|
|
1929
|
+
this.push(this._body);
|
|
1930
|
+
}
|
|
1931
|
+
this.push(null);
|
|
1932
|
+
this.complete = true;
|
|
1933
|
+
}
|
|
1934
|
+
// Internal: initialize from raw request
|
|
1935
|
+
static fromRequest(method, url, headers, body) {
|
|
1936
|
+
const msg = new _IncomingMessage();
|
|
1937
|
+
msg.method = method;
|
|
1938
|
+
msg.url = url;
|
|
1939
|
+
msg.headers = { ...headers };
|
|
1940
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
1941
|
+
msg.rawHeaders.push(key, value);
|
|
1942
|
+
}
|
|
1943
|
+
if (body) {
|
|
1944
|
+
msg._setBody(body);
|
|
1945
|
+
} else {
|
|
1946
|
+
msg.push(null);
|
|
1947
|
+
msg.complete = true;
|
|
1948
|
+
}
|
|
1949
|
+
return msg;
|
|
1950
|
+
}
|
|
1951
|
+
};
|
|
1952
|
+
var ServerResponse = class extends Writable {
|
|
1953
|
+
statusCode = 200;
|
|
1954
|
+
statusMessage = "OK";
|
|
1955
|
+
headersSent = false;
|
|
1956
|
+
finished = false;
|
|
1957
|
+
sendDate = true;
|
|
1958
|
+
socket;
|
|
1959
|
+
_headers = /* @__PURE__ */ new Map();
|
|
1960
|
+
_body = [];
|
|
1961
|
+
_resolve;
|
|
1962
|
+
constructor(req) {
|
|
1963
|
+
super();
|
|
1964
|
+
this.socket = req.socket;
|
|
1965
|
+
}
|
|
1966
|
+
// Internal: set resolver for async response handling
|
|
1967
|
+
_setResolver(resolve) {
|
|
1968
|
+
this._resolve = resolve;
|
|
1969
|
+
}
|
|
1970
|
+
setHeader(name, value) {
|
|
1971
|
+
if (this.headersSent) {
|
|
1972
|
+
throw new Error("Cannot set headers after they are sent");
|
|
1973
|
+
}
|
|
1974
|
+
this._headers.set(name.toLowerCase(), String(value));
|
|
1975
|
+
return this;
|
|
1976
|
+
}
|
|
1977
|
+
getHeader(name) {
|
|
1978
|
+
return this._headers.get(name.toLowerCase());
|
|
1979
|
+
}
|
|
1980
|
+
getHeaders() {
|
|
1981
|
+
const headers = {};
|
|
1982
|
+
for (const [key, value] of this._headers) {
|
|
1983
|
+
headers[key] = value;
|
|
1984
|
+
}
|
|
1985
|
+
return headers;
|
|
1986
|
+
}
|
|
1987
|
+
getHeaderNames() {
|
|
1988
|
+
return [...this._headers.keys()];
|
|
1989
|
+
}
|
|
1990
|
+
hasHeader(name) {
|
|
1991
|
+
return this._headers.has(name.toLowerCase());
|
|
1992
|
+
}
|
|
1993
|
+
removeHeader(name) {
|
|
1994
|
+
if (this.headersSent) {
|
|
1995
|
+
throw new Error("Cannot remove headers after they are sent");
|
|
1996
|
+
}
|
|
1997
|
+
this._headers.delete(name.toLowerCase());
|
|
1998
|
+
}
|
|
1999
|
+
writeHead(statusCode, statusMessageOrHeaders, headers) {
|
|
2000
|
+
this.statusCode = statusCode;
|
|
2001
|
+
if (typeof statusMessageOrHeaders === "string") {
|
|
2002
|
+
this.statusMessage = statusMessageOrHeaders;
|
|
2003
|
+
if (headers) {
|
|
2004
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
2005
|
+
this.setHeader(key, value);
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
} else if (statusMessageOrHeaders) {
|
|
2009
|
+
for (const [key, value] of Object.entries(statusMessageOrHeaders)) {
|
|
2010
|
+
this.setHeader(key, value);
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
return this;
|
|
2014
|
+
}
|
|
2015
|
+
write(chunk, encodingOrCallback, callback) {
|
|
2016
|
+
this.headersSent = true;
|
|
2017
|
+
const buffer = typeof chunk === "string" ? BufferPolyfill.from(chunk) : chunk;
|
|
2018
|
+
this._body.push(buffer);
|
|
2019
|
+
const cb = typeof encodingOrCallback === "function" ? encodingOrCallback : callback;
|
|
2020
|
+
if (cb) {
|
|
2021
|
+
queueMicrotask(() => cb(null));
|
|
2022
|
+
}
|
|
2023
|
+
return true;
|
|
2024
|
+
}
|
|
2025
|
+
end(chunkOrCallback, encodingOrCallback, callback) {
|
|
2026
|
+
if (typeof chunkOrCallback === "function") {
|
|
2027
|
+
callback = chunkOrCallback;
|
|
2028
|
+
} else if (chunkOrCallback !== void 0) {
|
|
2029
|
+
this.write(chunkOrCallback);
|
|
2030
|
+
}
|
|
2031
|
+
if (typeof encodingOrCallback === "function") {
|
|
2032
|
+
callback = encodingOrCallback;
|
|
2033
|
+
}
|
|
2034
|
+
this.headersSent = true;
|
|
2035
|
+
this.finished = true;
|
|
2036
|
+
if (this._resolve) {
|
|
2037
|
+
const headers = {};
|
|
2038
|
+
for (const [key, value] of this._headers) {
|
|
2039
|
+
headers[key] = Array.isArray(value) ? value.join(", ") : value;
|
|
2040
|
+
}
|
|
2041
|
+
this._resolve({
|
|
2042
|
+
statusCode: this.statusCode,
|
|
2043
|
+
statusMessage: this.statusMessage,
|
|
2044
|
+
headers,
|
|
2045
|
+
body: BufferPolyfill.concat(this._body)
|
|
2046
|
+
});
|
|
2047
|
+
}
|
|
2048
|
+
queueMicrotask(() => {
|
|
2049
|
+
this.emit("finish");
|
|
2050
|
+
if (callback) callback();
|
|
2051
|
+
});
|
|
2052
|
+
return this;
|
|
2053
|
+
}
|
|
2054
|
+
// Convenience method for simple responses
|
|
2055
|
+
send(data) {
|
|
2056
|
+
if (typeof data === "object" && !BufferPolyfill.isBuffer(data)) {
|
|
2057
|
+
this.setHeader("Content-Type", "application/json");
|
|
2058
|
+
data = JSON.stringify(data);
|
|
2059
|
+
}
|
|
2060
|
+
if (!this.hasHeader("Content-Type")) {
|
|
2061
|
+
this.setHeader("Content-Type", "text/html");
|
|
2062
|
+
}
|
|
2063
|
+
this.write(typeof data === "string" ? data : data);
|
|
2064
|
+
return this.end();
|
|
2065
|
+
}
|
|
2066
|
+
// Express compatibility
|
|
2067
|
+
json(data) {
|
|
2068
|
+
this.setHeader("Content-Type", "application/json");
|
|
2069
|
+
return this.end(JSON.stringify(data));
|
|
2070
|
+
}
|
|
2071
|
+
status(code) {
|
|
2072
|
+
this.statusCode = code;
|
|
2073
|
+
return this;
|
|
2074
|
+
}
|
|
2075
|
+
redirect(urlOrStatus, url) {
|
|
2076
|
+
if (typeof urlOrStatus === "number") {
|
|
2077
|
+
this.statusCode = urlOrStatus;
|
|
2078
|
+
this.setHeader("Location", url);
|
|
2079
|
+
} else {
|
|
2080
|
+
this.statusCode = 302;
|
|
2081
|
+
this.setHeader("Location", urlOrStatus);
|
|
2082
|
+
}
|
|
2083
|
+
this.end();
|
|
2084
|
+
}
|
|
2085
|
+
// Get body for testing/debugging
|
|
2086
|
+
_getBody() {
|
|
2087
|
+
return BufferPolyfill.concat(this._body);
|
|
2088
|
+
}
|
|
2089
|
+
_getBodyAsString() {
|
|
2090
|
+
return this._getBody().toString("utf8");
|
|
2091
|
+
}
|
|
2092
|
+
};
|
|
2093
|
+
var Server2 = class extends EventEmitter {
|
|
2094
|
+
_netServer;
|
|
2095
|
+
_requestListener;
|
|
2096
|
+
_pendingRequests = /* @__PURE__ */ new Map();
|
|
2097
|
+
listening = false;
|
|
2098
|
+
maxHeadersCount = null;
|
|
2099
|
+
timeout = 0;
|
|
2100
|
+
keepAliveTimeout = 5e3;
|
|
2101
|
+
headersTimeout = 6e4;
|
|
2102
|
+
requestTimeout = 0;
|
|
2103
|
+
constructor(requestListener) {
|
|
2104
|
+
super();
|
|
2105
|
+
this._requestListener = requestListener;
|
|
2106
|
+
this._netServer = new Server();
|
|
2107
|
+
this._netServer.on("listening", () => {
|
|
2108
|
+
this.listening = true;
|
|
2109
|
+
this.emit("listening");
|
|
2110
|
+
});
|
|
2111
|
+
this._netServer.on("close", () => {
|
|
2112
|
+
this.listening = false;
|
|
2113
|
+
this.emit("close");
|
|
2114
|
+
});
|
|
2115
|
+
this._netServer.on("error", (err) => {
|
|
2116
|
+
this.emit("error", err);
|
|
2117
|
+
});
|
|
2118
|
+
}
|
|
2119
|
+
listen(portOrOptions, hostOrCallback, callback) {
|
|
2120
|
+
let port;
|
|
2121
|
+
let host;
|
|
2122
|
+
let cb;
|
|
2123
|
+
if (typeof portOrOptions === "number") {
|
|
2124
|
+
port = portOrOptions;
|
|
2125
|
+
if (typeof hostOrCallback === "string") {
|
|
2126
|
+
host = hostOrCallback;
|
|
2127
|
+
cb = callback;
|
|
2128
|
+
} else {
|
|
2129
|
+
cb = hostOrCallback;
|
|
2130
|
+
}
|
|
2131
|
+
} else if (portOrOptions) {
|
|
2132
|
+
port = portOrOptions.port;
|
|
2133
|
+
host = portOrOptions.host;
|
|
2134
|
+
cb = typeof hostOrCallback === "function" ? hostOrCallback : callback;
|
|
2135
|
+
}
|
|
2136
|
+
const originalCb = cb;
|
|
2137
|
+
const self = this;
|
|
2138
|
+
cb = function() {
|
|
2139
|
+
const addr = self._netServer.address();
|
|
2140
|
+
if (addr) {
|
|
2141
|
+
_registerServer(addr.port, self);
|
|
2142
|
+
}
|
|
2143
|
+
if (originalCb) originalCb();
|
|
2144
|
+
};
|
|
2145
|
+
this._netServer.listen(port, host, cb);
|
|
2146
|
+
return this;
|
|
2147
|
+
}
|
|
2148
|
+
close(callback) {
|
|
2149
|
+
const addr = this._netServer.address();
|
|
2150
|
+
if (addr) {
|
|
2151
|
+
_unregisterServer(addr.port);
|
|
2152
|
+
}
|
|
2153
|
+
this._netServer.close(callback);
|
|
2154
|
+
return this;
|
|
2155
|
+
}
|
|
2156
|
+
address() {
|
|
2157
|
+
return this._netServer.address();
|
|
2158
|
+
}
|
|
2159
|
+
setTimeout(msecs, callback) {
|
|
2160
|
+
this.timeout = msecs || 0;
|
|
2161
|
+
if (callback) {
|
|
2162
|
+
this.on("timeout", callback);
|
|
2163
|
+
}
|
|
2164
|
+
return this;
|
|
2165
|
+
}
|
|
2166
|
+
ref() {
|
|
2167
|
+
this._netServer.ref();
|
|
2168
|
+
return this;
|
|
2169
|
+
}
|
|
2170
|
+
unref() {
|
|
2171
|
+
this._netServer.unref();
|
|
2172
|
+
return this;
|
|
2173
|
+
}
|
|
2174
|
+
/**
|
|
2175
|
+
* Handle an incoming request (used by server bridge)
|
|
2176
|
+
*/
|
|
2177
|
+
async handleRequest(method, url, headers, body) {
|
|
2178
|
+
return new Promise((resolve, reject) => {
|
|
2179
|
+
const req = IncomingMessage.fromRequest(method, url, headers, body);
|
|
2180
|
+
const res = new ServerResponse(req);
|
|
2181
|
+
res._setResolver(resolve);
|
|
2182
|
+
const timeoutId = this.timeout ? setTimeout(() => {
|
|
2183
|
+
reject(new Error("Request timeout"));
|
|
2184
|
+
}, this.timeout) : null;
|
|
2185
|
+
res.on("finish", () => {
|
|
2186
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
2187
|
+
});
|
|
2188
|
+
try {
|
|
2189
|
+
this.emit("request", req, res);
|
|
2190
|
+
if (this._requestListener) {
|
|
2191
|
+
this._requestListener(req, res);
|
|
2192
|
+
}
|
|
2193
|
+
} catch (error) {
|
|
2194
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
2195
|
+
reject(error);
|
|
2196
|
+
}
|
|
2197
|
+
});
|
|
2198
|
+
}
|
|
2199
|
+
};
|
|
2200
|
+
function createServer2(requestListener) {
|
|
2201
|
+
return new Server2(requestListener);
|
|
2202
|
+
}
|
|
2203
|
+
var STATUS_CODES = {
|
|
2204
|
+
100: "Continue",
|
|
2205
|
+
101: "Switching Protocols",
|
|
2206
|
+
200: "OK",
|
|
2207
|
+
201: "Created",
|
|
2208
|
+
202: "Accepted",
|
|
2209
|
+
204: "No Content",
|
|
2210
|
+
301: "Moved Permanently",
|
|
2211
|
+
302: "Found",
|
|
2212
|
+
304: "Not Modified",
|
|
2213
|
+
400: "Bad Request",
|
|
2214
|
+
401: "Unauthorized",
|
|
2215
|
+
403: "Forbidden",
|
|
2216
|
+
404: "Not Found",
|
|
2217
|
+
405: "Method Not Allowed",
|
|
2218
|
+
408: "Request Timeout",
|
|
2219
|
+
500: "Internal Server Error",
|
|
2220
|
+
501: "Not Implemented",
|
|
2221
|
+
502: "Bad Gateway",
|
|
2222
|
+
503: "Service Unavailable"
|
|
2223
|
+
};
|
|
2224
|
+
var METHODS = [
|
|
2225
|
+
"GET",
|
|
2226
|
+
"POST",
|
|
2227
|
+
"PUT",
|
|
2228
|
+
"DELETE",
|
|
2229
|
+
"PATCH",
|
|
2230
|
+
"HEAD",
|
|
2231
|
+
"OPTIONS",
|
|
2232
|
+
"CONNECT",
|
|
2233
|
+
"TRACE"
|
|
2234
|
+
];
|
|
2235
|
+
function getCorsProxy() {
|
|
2236
|
+
if (typeof localStorage !== "undefined") {
|
|
2237
|
+
return localStorage.getItem("__corsProxyUrl") || null;
|
|
2238
|
+
}
|
|
2239
|
+
return null;
|
|
2240
|
+
}
|
|
2241
|
+
var ClientRequest = class extends Writable {
|
|
2242
|
+
method;
|
|
2243
|
+
path;
|
|
2244
|
+
headers;
|
|
2245
|
+
_options;
|
|
2246
|
+
_protocol;
|
|
2247
|
+
_bodyChunks = [];
|
|
2248
|
+
_aborted = false;
|
|
2249
|
+
_timeout = null;
|
|
2250
|
+
_timeoutId = null;
|
|
2251
|
+
_requestEnded = false;
|
|
2252
|
+
constructor(options, protocol = "http") {
|
|
2253
|
+
super();
|
|
2254
|
+
this._options = options;
|
|
2255
|
+
this._protocol = protocol;
|
|
2256
|
+
this.method = options.method || "GET";
|
|
2257
|
+
this.path = options.path || "/";
|
|
2258
|
+
this.headers = {};
|
|
2259
|
+
if (options.headers) {
|
|
2260
|
+
for (const [key, value] of Object.entries(options.headers)) {
|
|
2261
|
+
this.headers[key.toLowerCase()] = Array.isArray(value) ? value.join(", ") : value;
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
}
|
|
2265
|
+
setHeader(name, value) {
|
|
2266
|
+
this.headers[name.toLowerCase()] = value;
|
|
2267
|
+
}
|
|
2268
|
+
getHeader(name) {
|
|
2269
|
+
return this.headers[name.toLowerCase()];
|
|
2270
|
+
}
|
|
2271
|
+
removeHeader(name) {
|
|
2272
|
+
delete this.headers[name.toLowerCase()];
|
|
2273
|
+
}
|
|
2274
|
+
write(chunk, encodingOrCallback, callback) {
|
|
2275
|
+
const buffer = typeof chunk === "string" ? BufferPolyfill.from(chunk) : chunk;
|
|
2276
|
+
this._bodyChunks.push(buffer);
|
|
2277
|
+
const cb = typeof encodingOrCallback === "function" ? encodingOrCallback : callback;
|
|
2278
|
+
if (cb) {
|
|
2279
|
+
queueMicrotask(() => cb(null));
|
|
2280
|
+
}
|
|
2281
|
+
return true;
|
|
2282
|
+
}
|
|
2283
|
+
end(dataOrCallback, encodingOrCallback, callback) {
|
|
2284
|
+
if (this._requestEnded) return this;
|
|
2285
|
+
this._requestEnded = true;
|
|
2286
|
+
let finalCallback = callback;
|
|
2287
|
+
if (typeof dataOrCallback === "function") {
|
|
2288
|
+
finalCallback = dataOrCallback;
|
|
2289
|
+
} else if (dataOrCallback !== void 0) {
|
|
2290
|
+
this.write(dataOrCallback);
|
|
2291
|
+
}
|
|
2292
|
+
if (typeof encodingOrCallback === "function") {
|
|
2293
|
+
finalCallback = encodingOrCallback;
|
|
2294
|
+
}
|
|
2295
|
+
this._performRequest().then(() => {
|
|
2296
|
+
if (finalCallback) finalCallback();
|
|
2297
|
+
}).catch((error) => {
|
|
2298
|
+
this.emit("error", error);
|
|
2299
|
+
});
|
|
2300
|
+
return this;
|
|
2301
|
+
}
|
|
2302
|
+
abort() {
|
|
2303
|
+
this._aborted = true;
|
|
2304
|
+
if (this._timeoutId) {
|
|
2305
|
+
clearTimeout(this._timeoutId);
|
|
2306
|
+
}
|
|
2307
|
+
this.emit("abort");
|
|
2308
|
+
}
|
|
2309
|
+
setTimeout(ms, callback) {
|
|
2310
|
+
this._timeout = ms;
|
|
2311
|
+
if (callback) {
|
|
2312
|
+
this.once("timeout", callback);
|
|
2313
|
+
}
|
|
2314
|
+
return this;
|
|
2315
|
+
}
|
|
2316
|
+
async _performRequest() {
|
|
2317
|
+
if (this._aborted) return;
|
|
2318
|
+
try {
|
|
2319
|
+
const protocol = this._protocol === "https" ? "https:" : "http:";
|
|
2320
|
+
let hostname = this._options.hostname || "";
|
|
2321
|
+
let port = this._options.port ? `:${this._options.port}` : "";
|
|
2322
|
+
if (!hostname && this._options.host) {
|
|
2323
|
+
const hostParts = this._options.host.split(":");
|
|
2324
|
+
hostname = hostParts[0];
|
|
2325
|
+
if (!port && hostParts[1]) {
|
|
2326
|
+
port = `:${hostParts[1]}`;
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
if (!hostname) hostname = "localhost";
|
|
2330
|
+
const path = this._options.path || "/";
|
|
2331
|
+
const url = `${protocol}//${hostname}${port}${path}`;
|
|
2332
|
+
if (this.headers["upgrade"]?.toLowerCase() === "websocket") {
|
|
2333
|
+
this._handleWebSocketUpgrade(url);
|
|
2334
|
+
return;
|
|
2335
|
+
}
|
|
2336
|
+
const corsProxy = getCorsProxy();
|
|
2337
|
+
const fetchUrl = corsProxy ? corsProxy + encodeURIComponent(url) : url;
|
|
2338
|
+
const fetchOptions = {
|
|
2339
|
+
method: this.method,
|
|
2340
|
+
headers: this.headers
|
|
2341
|
+
};
|
|
2342
|
+
if (this._bodyChunks.length > 0 && this.method !== "GET" && this.method !== "HEAD") {
|
|
2343
|
+
fetchOptions.body = BufferPolyfill.concat(this._bodyChunks);
|
|
2344
|
+
}
|
|
2345
|
+
const controller = new AbortController();
|
|
2346
|
+
fetchOptions.signal = controller.signal;
|
|
2347
|
+
if (this._timeout) {
|
|
2348
|
+
this._timeoutId = setTimeout(() => {
|
|
2349
|
+
controller.abort();
|
|
2350
|
+
this.emit("timeout");
|
|
2351
|
+
}, this._timeout);
|
|
2352
|
+
}
|
|
2353
|
+
const response = await fetch(fetchUrl, fetchOptions);
|
|
2354
|
+
if (this._timeoutId) {
|
|
2355
|
+
clearTimeout(this._timeoutId);
|
|
2356
|
+
this._timeoutId = null;
|
|
2357
|
+
}
|
|
2358
|
+
if (this._aborted) return;
|
|
2359
|
+
const incomingMessage = await this._responseToIncomingMessage(response);
|
|
2360
|
+
this.emit("response", incomingMessage);
|
|
2361
|
+
} catch (error) {
|
|
2362
|
+
if (this._timeoutId) {
|
|
2363
|
+
clearTimeout(this._timeoutId);
|
|
2364
|
+
}
|
|
2365
|
+
if (this._aborted) return;
|
|
2366
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
2367
|
+
return;
|
|
2368
|
+
}
|
|
2369
|
+
this.emit("error", error);
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
async _responseToIncomingMessage(response) {
|
|
2373
|
+
const msg = new IncomingMessage();
|
|
2374
|
+
msg.statusCode = response.status;
|
|
2375
|
+
msg.statusMessage = response.statusText || STATUS_CODES[response.status] || "";
|
|
2376
|
+
response.headers.forEach((value, key) => {
|
|
2377
|
+
msg.headers[key.toLowerCase()] = value;
|
|
2378
|
+
msg.rawHeaders.push(key, value);
|
|
2379
|
+
});
|
|
2380
|
+
const body = await response.arrayBuffer();
|
|
2381
|
+
msg._setBody(BufferPolyfill.from(body));
|
|
2382
|
+
return msg;
|
|
2383
|
+
}
|
|
2384
|
+
/**
|
|
2385
|
+
* Bridge a WebSocket upgrade request to the browser's native WebSocket.
|
|
2386
|
+
*
|
|
2387
|
+
* The bundled ws library (inside the Convex CLI) creates WebSocket connections
|
|
2388
|
+
* via http.request() with Upgrade headers. It expects frame-level I/O on the
|
|
2389
|
+
* socket from the 'upgrade' event. This method bridges between:
|
|
2390
|
+
* - ws library ↔ frame-level I/O on a mock Socket
|
|
2391
|
+
* - browser native WebSocket ↔ message-level I/O
|
|
2392
|
+
*/
|
|
2393
|
+
_handleWebSocketUpgrade(url) {
|
|
2394
|
+
const wsUrl = url.replace(/^https:/, "wss:").replace(/^http:/, "ws:");
|
|
2395
|
+
const wsKey = this.headers["sec-websocket-key"] || "";
|
|
2396
|
+
const NativeWS = _BrowserWebSocket;
|
|
2397
|
+
if (!NativeWS) {
|
|
2398
|
+
setTimeout(() => {
|
|
2399
|
+
this.emit("error", new TypeError("Failed to fetch"));
|
|
2400
|
+
}, 0);
|
|
2401
|
+
return;
|
|
2402
|
+
}
|
|
2403
|
+
const GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
|
2404
|
+
const acceptValue = createHash("sha1").update(wsKey + GUID).digest("base64");
|
|
2405
|
+
let nativeWs;
|
|
2406
|
+
try {
|
|
2407
|
+
nativeWs = new NativeWS(wsUrl);
|
|
2408
|
+
nativeWs.binaryType = "arraybuffer";
|
|
2409
|
+
} catch (e) {
|
|
2410
|
+
setTimeout(() => {
|
|
2411
|
+
this.emit("error", e instanceof Error ? e : new Error(String(e)));
|
|
2412
|
+
}, 0);
|
|
2413
|
+
return;
|
|
2414
|
+
}
|
|
2415
|
+
const socket = new Socket();
|
|
2416
|
+
if (typeof socket.cork !== "function") socket.cork = () => {
|
|
2417
|
+
};
|
|
2418
|
+
if (typeof socket.uncork !== "function") socket.uncork = () => {
|
|
2419
|
+
};
|
|
2420
|
+
socket._readableState = { endEmitted: false };
|
|
2421
|
+
socket._writableState = { finished: false, errorEmitted: false };
|
|
2422
|
+
let writeBuffer = new Uint8Array(0);
|
|
2423
|
+
socket.write = ((chunk, encodingOrCallback, callback) => {
|
|
2424
|
+
const data = typeof chunk === "string" ? BufferPolyfill.from(chunk) : new Uint8Array(chunk);
|
|
2425
|
+
const cb = typeof encodingOrCallback === "function" ? encodingOrCallback : callback;
|
|
2426
|
+
const newBuf = new Uint8Array(writeBuffer.length + data.length);
|
|
2427
|
+
newBuf.set(writeBuffer, 0);
|
|
2428
|
+
newBuf.set(data, writeBuffer.length);
|
|
2429
|
+
writeBuffer = newBuf;
|
|
2430
|
+
while (writeBuffer.length >= 2) {
|
|
2431
|
+
const parsed = _parseWsFrame(writeBuffer);
|
|
2432
|
+
if (!parsed) break;
|
|
2433
|
+
const { opcode, payload, totalLength } = parsed;
|
|
2434
|
+
writeBuffer = writeBuffer.slice(totalLength);
|
|
2435
|
+
if (nativeWs.readyState !== NativeWS.OPEN) continue;
|
|
2436
|
+
if (opcode === 8) {
|
|
2437
|
+
nativeWs.close();
|
|
2438
|
+
} else if (opcode === 9) {
|
|
2439
|
+
nativeWs.send(payload);
|
|
2440
|
+
} else if (opcode === 10) {
|
|
2441
|
+
} else if (opcode === 1) {
|
|
2442
|
+
const text = new TextDecoder().decode(payload);
|
|
2443
|
+
nativeWs.send(text);
|
|
2444
|
+
} else if (opcode === 2) {
|
|
2445
|
+
nativeWs.send(payload);
|
|
2446
|
+
}
|
|
2447
|
+
}
|
|
2448
|
+
if (cb) queueMicrotask(() => cb(null));
|
|
2449
|
+
return true;
|
|
2450
|
+
});
|
|
2451
|
+
nativeWs.onopen = () => {
|
|
2452
|
+
const response = new IncomingMessage(socket);
|
|
2453
|
+
response.statusCode = 101;
|
|
2454
|
+
response.statusMessage = "Switching Protocols";
|
|
2455
|
+
response.headers = {
|
|
2456
|
+
"upgrade": "websocket",
|
|
2457
|
+
"connection": "Upgrade",
|
|
2458
|
+
"sec-websocket-accept": acceptValue
|
|
2459
|
+
};
|
|
2460
|
+
response.complete = true;
|
|
2461
|
+
response.push(null);
|
|
2462
|
+
this.emit("upgrade", response, socket, BufferPolyfill.alloc(0));
|
|
2463
|
+
};
|
|
2464
|
+
nativeWs.onmessage = (event) => {
|
|
2465
|
+
let payload;
|
|
2466
|
+
let opcode;
|
|
2467
|
+
if (typeof event.data === "string") {
|
|
2468
|
+
payload = new TextEncoder().encode(event.data);
|
|
2469
|
+
opcode = 1;
|
|
2470
|
+
} else if (event.data instanceof ArrayBuffer) {
|
|
2471
|
+
payload = new Uint8Array(event.data);
|
|
2472
|
+
opcode = 2;
|
|
2473
|
+
} else {
|
|
2474
|
+
return;
|
|
2475
|
+
}
|
|
2476
|
+
const frame = _createWsFrame(opcode, payload, false);
|
|
2477
|
+
socket._receiveData(BufferPolyfill.from(frame));
|
|
2478
|
+
};
|
|
2479
|
+
nativeWs.onclose = (event) => {
|
|
2480
|
+
const code = event.code || 1e3;
|
|
2481
|
+
const closePayload = new Uint8Array(2);
|
|
2482
|
+
closePayload[0] = code >> 8 & 255;
|
|
2483
|
+
closePayload[1] = code & 255;
|
|
2484
|
+
const frame = _createWsFrame(8, closePayload, false);
|
|
2485
|
+
socket._receiveData(BufferPolyfill.from(frame));
|
|
2486
|
+
setTimeout(() => {
|
|
2487
|
+
socket._readableState.endEmitted = true;
|
|
2488
|
+
socket._receiveEnd();
|
|
2489
|
+
socket.emit("close", false);
|
|
2490
|
+
}, 10);
|
|
2491
|
+
};
|
|
2492
|
+
nativeWs.onerror = () => {
|
|
2493
|
+
socket.emit("error", new Error("WebSocket connection error"));
|
|
2494
|
+
socket.destroy();
|
|
2495
|
+
};
|
|
2496
|
+
const origDestroy = socket.destroy.bind(socket);
|
|
2497
|
+
socket.destroy = ((error) => {
|
|
2498
|
+
if (nativeWs.readyState === NativeWS.OPEN || nativeWs.readyState === NativeWS.CONNECTING) {
|
|
2499
|
+
nativeWs.close();
|
|
2500
|
+
}
|
|
2501
|
+
return origDestroy(error);
|
|
2502
|
+
});
|
|
2503
|
+
}
|
|
2504
|
+
};
|
|
2505
|
+
function parseRequestArgs(urlOrOptions, optionsOrCallback, callback) {
|
|
2506
|
+
let options;
|
|
2507
|
+
let cb = callback;
|
|
2508
|
+
if (typeof urlOrOptions === "string" || urlOrOptions instanceof URL) {
|
|
2509
|
+
const parsed = new URL(urlOrOptions.toString());
|
|
2510
|
+
options = {
|
|
2511
|
+
hostname: parsed.hostname,
|
|
2512
|
+
port: parsed.port ? parseInt(parsed.port) : void 0,
|
|
2513
|
+
path: parsed.pathname + parsed.search,
|
|
2514
|
+
method: "GET"
|
|
2515
|
+
};
|
|
2516
|
+
if (typeof optionsOrCallback === "function") {
|
|
2517
|
+
cb = optionsOrCallback;
|
|
2518
|
+
} else if (optionsOrCallback) {
|
|
2519
|
+
options = { ...options, ...optionsOrCallback };
|
|
2520
|
+
}
|
|
2521
|
+
} else {
|
|
2522
|
+
options = urlOrOptions;
|
|
2523
|
+
if (typeof optionsOrCallback === "function") {
|
|
2524
|
+
cb = optionsOrCallback;
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
return { options, callback: cb };
|
|
2528
|
+
}
|
|
2529
|
+
function request(urlOrOptions, optionsOrCallback, callback) {
|
|
2530
|
+
const { options, callback: cb } = parseRequestArgs(urlOrOptions, optionsOrCallback, callback);
|
|
2531
|
+
const req = new ClientRequest(options, "http");
|
|
2532
|
+
if (cb) {
|
|
2533
|
+
req.once("response", cb);
|
|
2534
|
+
}
|
|
2535
|
+
return req;
|
|
2536
|
+
}
|
|
2537
|
+
function get(urlOrOptions, optionsOrCallback, callback) {
|
|
2538
|
+
const { options, callback: cb } = parseRequestArgs(urlOrOptions, optionsOrCallback, callback);
|
|
2539
|
+
const req = new ClientRequest({ ...options, method: "GET" }, "http");
|
|
2540
|
+
if (cb) {
|
|
2541
|
+
req.once("response", cb);
|
|
2542
|
+
}
|
|
2543
|
+
req.end();
|
|
2544
|
+
return req;
|
|
2545
|
+
}
|
|
2546
|
+
function _createClientRequest(urlOrOptions, optionsOrCallback, callback, protocol) {
|
|
2547
|
+
const { options, callback: cb } = parseRequestArgs(urlOrOptions, optionsOrCallback, callback);
|
|
2548
|
+
const req = new ClientRequest(options, protocol);
|
|
2549
|
+
if (cb) {
|
|
2550
|
+
req.once("response", cb);
|
|
2551
|
+
}
|
|
2552
|
+
return req;
|
|
2553
|
+
}
|
|
2554
|
+
var serverRegistry = /* @__PURE__ */ new Map();
|
|
2555
|
+
var onServerListenCallback = null;
|
|
2556
|
+
var onServerCloseCallback = null;
|
|
2557
|
+
function _registerServer(port, server) {
|
|
2558
|
+
serverRegistry.set(port, server);
|
|
2559
|
+
if (onServerListenCallback) {
|
|
2560
|
+
onServerListenCallback(port, server);
|
|
2561
|
+
}
|
|
2562
|
+
}
|
|
2563
|
+
function _unregisterServer(port) {
|
|
2564
|
+
serverRegistry.delete(port);
|
|
2565
|
+
if (onServerCloseCallback) {
|
|
2566
|
+
onServerCloseCallback(port);
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2569
|
+
function getServer(port) {
|
|
2570
|
+
return serverRegistry.get(port);
|
|
2571
|
+
}
|
|
2572
|
+
function getAllServers() {
|
|
2573
|
+
return new Map(serverRegistry);
|
|
2574
|
+
}
|
|
2575
|
+
function setServerListenCallback(callback) {
|
|
2576
|
+
onServerListenCallback = callback;
|
|
2577
|
+
}
|
|
2578
|
+
function setServerCloseCallback(callback) {
|
|
2579
|
+
onServerCloseCallback = callback;
|
|
2580
|
+
}
|
|
2581
|
+
var Agent = class extends EventEmitter {
|
|
2582
|
+
maxSockets;
|
|
2583
|
+
maxFreeSockets;
|
|
2584
|
+
maxTotalSockets;
|
|
2585
|
+
sockets;
|
|
2586
|
+
freeSockets;
|
|
2587
|
+
requests;
|
|
2588
|
+
options;
|
|
2589
|
+
constructor(opts) {
|
|
2590
|
+
super();
|
|
2591
|
+
this.options = opts || {};
|
|
2592
|
+
this.maxSockets = opts?.maxSockets ?? Infinity;
|
|
2593
|
+
this.maxFreeSockets = opts?.maxFreeSockets ?? 256;
|
|
2594
|
+
this.maxTotalSockets = opts?.maxTotalSockets ?? Infinity;
|
|
2595
|
+
this.sockets = {};
|
|
2596
|
+
this.freeSockets = {};
|
|
2597
|
+
this.requests = {};
|
|
2598
|
+
}
|
|
2599
|
+
createConnection(_options, callback) {
|
|
2600
|
+
const socket = new Socket();
|
|
2601
|
+
if (callback) {
|
|
2602
|
+
callback(null, socket);
|
|
2603
|
+
}
|
|
2604
|
+
return socket;
|
|
2605
|
+
}
|
|
2606
|
+
getName(options) {
|
|
2607
|
+
const host = options.host || "localhost";
|
|
2608
|
+
const port = options.port || 80;
|
|
2609
|
+
return `${host}:${port}:${options.localAddress || ""}`;
|
|
2610
|
+
}
|
|
2611
|
+
addRequest(_req, _options) {
|
|
2612
|
+
}
|
|
2613
|
+
destroy() {
|
|
2614
|
+
this.sockets = {};
|
|
2615
|
+
this.freeSockets = {};
|
|
2616
|
+
this.requests = {};
|
|
2617
|
+
}
|
|
2618
|
+
};
|
|
2619
|
+
var globalAgent = new Agent();
|
|
2620
|
+
function _parseWsFrame(data) {
|
|
2621
|
+
if (data.length < 2) return null;
|
|
2622
|
+
const opcode = data[0] & 15;
|
|
2623
|
+
const masked = (data[1] & 128) !== 0;
|
|
2624
|
+
let payloadLength = data[1] & 127;
|
|
2625
|
+
let offset = 2;
|
|
2626
|
+
if (payloadLength === 126) {
|
|
2627
|
+
if (data.length < 4) return null;
|
|
2628
|
+
payloadLength = data[2] << 8 | data[3];
|
|
2629
|
+
offset = 4;
|
|
2630
|
+
} else if (payloadLength === 127) {
|
|
2631
|
+
if (data.length < 10) return null;
|
|
2632
|
+
payloadLength = data[6] << 24 | data[7] << 16 | data[8] << 8 | data[9];
|
|
2633
|
+
offset = 10;
|
|
2634
|
+
}
|
|
2635
|
+
if (masked) {
|
|
2636
|
+
if (data.length < offset + 4 + payloadLength) return null;
|
|
2637
|
+
const maskKey = data.slice(offset, offset + 4);
|
|
2638
|
+
offset += 4;
|
|
2639
|
+
const payload = new Uint8Array(payloadLength);
|
|
2640
|
+
for (let i = 0; i < payloadLength; i++) {
|
|
2641
|
+
payload[i] = data[offset + i] ^ maskKey[i % 4];
|
|
2642
|
+
}
|
|
2643
|
+
return { opcode, payload, totalLength: offset + payloadLength };
|
|
2644
|
+
} else {
|
|
2645
|
+
if (data.length < offset + payloadLength) return null;
|
|
2646
|
+
const payload = data.slice(offset, offset + payloadLength);
|
|
2647
|
+
return { opcode, payload, totalLength: offset + payloadLength };
|
|
2648
|
+
}
|
|
2649
|
+
}
|
|
2650
|
+
function _createWsFrame(opcode, payload, masked) {
|
|
2651
|
+
const length = payload.length;
|
|
2652
|
+
let headerSize = 2;
|
|
2653
|
+
if (length > 125 && length <= 65535) {
|
|
2654
|
+
headerSize += 2;
|
|
2655
|
+
} else if (length > 65535) {
|
|
2656
|
+
headerSize += 8;
|
|
2657
|
+
}
|
|
2658
|
+
if (masked) {
|
|
2659
|
+
headerSize += 4;
|
|
2660
|
+
}
|
|
2661
|
+
const frame = new Uint8Array(headerSize + length);
|
|
2662
|
+
frame[0] = 128 | opcode;
|
|
2663
|
+
let offset = 2;
|
|
2664
|
+
if (length <= 125) {
|
|
2665
|
+
frame[1] = (masked ? 128 : 0) | length;
|
|
2666
|
+
} else if (length <= 65535) {
|
|
2667
|
+
frame[1] = (masked ? 128 : 0) | 126;
|
|
2668
|
+
frame[2] = length >> 8 & 255;
|
|
2669
|
+
frame[3] = length & 255;
|
|
2670
|
+
offset = 4;
|
|
2671
|
+
} else {
|
|
2672
|
+
frame[1] = (masked ? 128 : 0) | 127;
|
|
2673
|
+
frame[2] = 0;
|
|
2674
|
+
frame[3] = 0;
|
|
2675
|
+
frame[4] = 0;
|
|
2676
|
+
frame[5] = 0;
|
|
2677
|
+
frame[6] = length >> 24 & 255;
|
|
2678
|
+
frame[7] = length >> 16 & 255;
|
|
2679
|
+
frame[8] = length >> 8 & 255;
|
|
2680
|
+
frame[9] = length & 255;
|
|
2681
|
+
offset = 10;
|
|
2682
|
+
}
|
|
2683
|
+
if (masked) {
|
|
2684
|
+
const maskKey = new Uint8Array(4);
|
|
2685
|
+
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
2686
|
+
crypto.getRandomValues(maskKey);
|
|
2687
|
+
} else {
|
|
2688
|
+
for (let i = 0; i < 4; i++) maskKey[i] = Math.floor(Math.random() * 256);
|
|
2689
|
+
}
|
|
2690
|
+
frame.set(maskKey, offset);
|
|
2691
|
+
offset += 4;
|
|
2692
|
+
for (let i = 0; i < length; i++) {
|
|
2693
|
+
frame[offset + i] = payload[i] ^ maskKey[i % 4];
|
|
2694
|
+
}
|
|
2695
|
+
} else {
|
|
2696
|
+
frame.set(payload, offset);
|
|
2697
|
+
}
|
|
2698
|
+
return frame;
|
|
2699
|
+
}
|
|
2700
|
+
var http_default = {
|
|
2701
|
+
Server: Server2,
|
|
2702
|
+
IncomingMessage,
|
|
2703
|
+
ServerResponse,
|
|
2704
|
+
ClientRequest,
|
|
2705
|
+
createServer: createServer2,
|
|
2706
|
+
request,
|
|
2707
|
+
get,
|
|
2708
|
+
STATUS_CODES,
|
|
2709
|
+
METHODS,
|
|
2710
|
+
getServer,
|
|
2711
|
+
getAllServers,
|
|
2712
|
+
setServerListenCallback,
|
|
2713
|
+
setServerCloseCallback,
|
|
2714
|
+
_createClientRequest,
|
|
2715
|
+
Agent,
|
|
2716
|
+
globalAgent,
|
|
2717
|
+
_parseWsFrame,
|
|
2718
|
+
_createWsFrame
|
|
2719
|
+
};
|
|
2720
|
+
|
|
2721
|
+
export {
|
|
2722
|
+
uint8ToBase64,
|
|
2723
|
+
base64ToUint8,
|
|
2724
|
+
uint8ToHex,
|
|
2725
|
+
uint8ToBinaryString,
|
|
2726
|
+
EventEmitter,
|
|
2727
|
+
events_default,
|
|
2728
|
+
Readable,
|
|
2729
|
+
Writable,
|
|
2730
|
+
BufferPolyfill,
|
|
2731
|
+
stream_default,
|
|
2732
|
+
net_exports,
|
|
2733
|
+
crypto_exports,
|
|
2734
|
+
IncomingMessage,
|
|
2735
|
+
ServerResponse,
|
|
2736
|
+
Server2 as Server,
|
|
2737
|
+
createServer2 as createServer,
|
|
2738
|
+
STATUS_CODES,
|
|
2739
|
+
METHODS,
|
|
2740
|
+
ClientRequest,
|
|
2741
|
+
_createClientRequest,
|
|
2742
|
+
getServer,
|
|
2743
|
+
getAllServers,
|
|
2744
|
+
setServerListenCallback,
|
|
2745
|
+
setServerCloseCallback,
|
|
2746
|
+
Agent,
|
|
2747
|
+
globalAgent,
|
|
2748
|
+
http_exports
|
|
2749
|
+
};
|
|
2750
|
+
//# sourceMappingURL=chunk-L7KW6Y27.js.map
|