@workflow/world-testing 5.0.0-beta.39 → 5.0.0-beta.40
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/.well-known/workflow/v1/__step_registrations.mjs +4145 -258
- package/dist/.well-known/workflow/v1/flow.mjs +77862 -61493
- package/dist/.well-known/workflow/v1/manifest.json +952 -952
- package/package.json +5 -5
|
@@ -8,6 +8,12 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
8
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
10
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
11
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
12
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
13
|
+
}) : x)(function(x) {
|
|
14
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
15
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
16
|
+
});
|
|
11
17
|
var __esm = (fn, res, err) => function __init() {
|
|
12
18
|
if (err) throw err[0];
|
|
13
19
|
try {
|
|
@@ -16,7 +22,7 @@ var __esm = (fn, res, err) => function __init() {
|
|
|
16
22
|
throw err = [e], e;
|
|
17
23
|
}
|
|
18
24
|
};
|
|
19
|
-
var __commonJS = (cb, mod) => function
|
|
25
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
20
26
|
try {
|
|
21
27
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
22
28
|
} catch (e) {
|
|
@@ -361,7 +367,9 @@ var init_error_codes = __esm({
|
|
|
361
367
|
/** Workflow replay exceeded the maximum allowed duration */
|
|
362
368
|
REPLAY_TIMEOUT: "REPLAY_TIMEOUT",
|
|
363
369
|
/** World response violated the SDK contract and cannot be retried safely */
|
|
364
|
-
WORLD_CONTRACT_ERROR: "WORLD_CONTRACT_ERROR"
|
|
370
|
+
WORLD_CONTRACT_ERROR: "WORLD_CONTRACT_ERROR",
|
|
371
|
+
/** Run was delivered to a deployment other than the one it is pinned to */
|
|
372
|
+
DEPLOYMENT_MISMATCH: "DEPLOYMENT_MISMATCH"
|
|
365
373
|
};
|
|
366
374
|
}
|
|
367
375
|
});
|
|
@@ -421,7 +429,8 @@ var init_dist2 = __esm({
|
|
|
421
429
|
REPLAY_DIVERGENCE: "replay-divergence",
|
|
422
430
|
STEP_NOT_REGISTERED: "step-not-registered",
|
|
423
431
|
WORKFLOW_NOT_REGISTERED: "workflow-not-registered",
|
|
424
|
-
RUNTIME_DECRYPTION_FAILED: "runtime-decryption-failed"
|
|
432
|
+
RUNTIME_DECRYPTION_FAILED: "runtime-decryption-failed",
|
|
433
|
+
DEPLOYMENT_MISMATCH: "deployment-mismatch"
|
|
425
434
|
};
|
|
426
435
|
WorkflowError = class extends Error {
|
|
427
436
|
static {
|
|
@@ -16924,7 +16933,7 @@ var init_events = __esm({
|
|
|
16924
16933
|
function isTerminalWorkflowRunStatus(status) {
|
|
16925
16934
|
return TERMINAL_WORKFLOW_RUN_STATUSES.includes(status);
|
|
16926
16935
|
}
|
|
16927
|
-
var WorkflowRunStatusSchema, TerminalWorkflowRunStatusSchema, TERMINAL_WORKFLOW_RUN_STATUSES, WorkflowRunBaseSchema, WorkflowRunSchema;
|
|
16936
|
+
var WorkflowRunStatusSchema, TerminalWorkflowRunStatusSchema, TERMINAL_WORKFLOW_RUN_STATUSES, WorkflowRunBaseSchema, WorkflowRunSchema, BULK_CANCEL_MAX_RUN_IDS, BulkCancelWorkflowRunsRequestSchema, BulkCancelWorkflowRunResultSchema, BulkCancelWorkflowRunsResultSchema;
|
|
16928
16937
|
var init_runs = __esm({
|
|
16929
16938
|
"../world/dist/runs.js"() {
|
|
16930
16939
|
"use strict";
|
|
@@ -17065,6 +17074,49 @@ var init_runs = __esm({
|
|
|
17065
17074
|
completedAt: external_exports.coerce.date()
|
|
17066
17075
|
})
|
|
17067
17076
|
]);
|
|
17077
|
+
BULK_CANCEL_MAX_RUN_IDS = 500;
|
|
17078
|
+
BulkCancelWorkflowRunsRequestSchema = external_exports.object({
|
|
17079
|
+
runIds: external_exports.array(external_exports.string()).min(1).max(BULK_CANCEL_MAX_RUN_IDS).refine((ids) => new Set(ids).size === ids.length, {
|
|
17080
|
+
message: "runIds must not contain duplicates"
|
|
17081
|
+
}),
|
|
17082
|
+
cancelReason: external_exports.string().max(512).optional()
|
|
17083
|
+
});
|
|
17084
|
+
BulkCancelWorkflowRunResultSchema = external_exports.discriminatedUnion("outcome", [
|
|
17085
|
+
external_exports.object({
|
|
17086
|
+
runId: external_exports.string(),
|
|
17087
|
+
outcome: external_exports.literal("cancelled")
|
|
17088
|
+
}),
|
|
17089
|
+
external_exports.object({
|
|
17090
|
+
runId: external_exports.string(),
|
|
17091
|
+
outcome: external_exports.literal("already_cancelled")
|
|
17092
|
+
}),
|
|
17093
|
+
external_exports.object({
|
|
17094
|
+
runId: external_exports.string(),
|
|
17095
|
+
outcome: external_exports.literal("not_cancellable"),
|
|
17096
|
+
status: external_exports.string()
|
|
17097
|
+
}),
|
|
17098
|
+
external_exports.object({
|
|
17099
|
+
runId: external_exports.string(),
|
|
17100
|
+
outcome: external_exports.literal("not_found")
|
|
17101
|
+
}),
|
|
17102
|
+
external_exports.object({
|
|
17103
|
+
runId: external_exports.string(),
|
|
17104
|
+
outcome: external_exports.literal("failed"),
|
|
17105
|
+
code: external_exports.string(),
|
|
17106
|
+
retryable: external_exports.boolean()
|
|
17107
|
+
})
|
|
17108
|
+
]);
|
|
17109
|
+
BulkCancelWorkflowRunsResultSchema = external_exports.object({
|
|
17110
|
+
summary: external_exports.object({
|
|
17111
|
+
requested: external_exports.number(),
|
|
17112
|
+
cancelled: external_exports.number(),
|
|
17113
|
+
alreadyCancelled: external_exports.number(),
|
|
17114
|
+
notCancellable: external_exports.number(),
|
|
17115
|
+
notFound: external_exports.number(),
|
|
17116
|
+
failed: external_exports.number()
|
|
17117
|
+
}),
|
|
17118
|
+
results: external_exports.array(BulkCancelWorkflowRunResultSchema)
|
|
17119
|
+
});
|
|
17068
17120
|
}
|
|
17069
17121
|
});
|
|
17070
17122
|
|
|
@@ -17436,6 +17488,8 @@ var init_queue = __esm({
|
|
|
17436
17488
|
preconditionReinvocations: external_exports.number().int().positive().optional(),
|
|
17437
17489
|
/** Number of times this message has been re-enqueued due to server errors (5xx) */
|
|
17438
17490
|
serverErrorRetryCount: external_exports.number().int().optional(),
|
|
17491
|
+
/** Number of times this message has been re-routed after a deployment mismatch */
|
|
17492
|
+
deploymentMismatchRetryCount: external_exports.number().int().nonnegative().optional(),
|
|
17439
17493
|
/** Step ID for inline step execution in combined handler. If provided, the flow execution
|
|
17440
17494
|
* will jump directly to execute the step with the given ID before doing an event replay. */
|
|
17441
17495
|
stepId: external_exports.string().optional(),
|
|
@@ -17525,6 +17579,9 @@ var init_hooks = __esm({
|
|
|
17525
17579
|
specVersion: external_exports.number().optional(),
|
|
17526
17580
|
isWebhook: external_exports.boolean().optional(),
|
|
17527
17581
|
isSystem: external_exports.boolean().optional(),
|
|
17582
|
+
// Earliest time the token can become available after the owning run ends.
|
|
17583
|
+
// An active run keeps the token beyond this deadline.
|
|
17584
|
+
tokenRetentionUntil: external_exports.coerce.date().optional(),
|
|
17528
17585
|
// Present when the server stored it (new hooks) or synthesized it from the
|
|
17529
17586
|
// run (old hooks). Absent only against an old server, where the resume path
|
|
17530
17587
|
// falls back to `runs.get`.
|
|
@@ -19960,11 +20017,22 @@ function reviveArrayBuffer(value, global2) {
|
|
|
19960
20017
|
function revive(str) {
|
|
19961
20018
|
return JSON.parse(str);
|
|
19962
20019
|
}
|
|
20020
|
+
function readErrorStack(value) {
|
|
20021
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, "stack");
|
|
20022
|
+
if (descriptor && "value" in descriptor) {
|
|
20023
|
+
return descriptor.value;
|
|
20024
|
+
}
|
|
20025
|
+
recordGuestCode("getter", "stack");
|
|
20026
|
+
if (descriptor?.get) {
|
|
20027
|
+
return descriptor.get.call(value);
|
|
20028
|
+
}
|
|
20029
|
+
return readProperty(value, "stack");
|
|
20030
|
+
}
|
|
19963
20031
|
function reduceErrorBase(value) {
|
|
19964
20032
|
if (!types2.isNativeError(value)) return false;
|
|
19965
20033
|
const reduced = {
|
|
19966
20034
|
message: readProperty(value, "message"),
|
|
19967
|
-
stack:
|
|
20035
|
+
stack: readErrorStack(value)
|
|
19968
20036
|
};
|
|
19969
20037
|
if (hasProperty(value, "cause")) reduced.cause = readProperty(value, "cause");
|
|
19970
20038
|
return reduced;
|
|
@@ -20021,7 +20089,7 @@ function getCommonReducers(_global = globalThis) {
|
|
|
20021
20089
|
const reduced = {
|
|
20022
20090
|
message: readProperty(value, "message"),
|
|
20023
20091
|
name: readProperty(value, "name"),
|
|
20024
|
-
stack:
|
|
20092
|
+
stack: readErrorStack(value)
|
|
20025
20093
|
};
|
|
20026
20094
|
if (hasProperty(value, "cause")) {
|
|
20027
20095
|
reduced.cause = readProperty(value, "cause");
|
|
@@ -20119,7 +20187,7 @@ function getCommonReducers(_global = globalThis) {
|
|
|
20119
20187
|
const reduced = {
|
|
20120
20188
|
name: readProperty(value, "name"),
|
|
20121
20189
|
message: readProperty(value, "message"),
|
|
20122
|
-
stack:
|
|
20190
|
+
stack: readErrorStack(value)
|
|
20123
20191
|
};
|
|
20124
20192
|
if (hasProperty(value, "cause")) {
|
|
20125
20193
|
reduced.cause = readProperty(value, "cause");
|
|
@@ -20283,6 +20351,7 @@ var init_common = __esm({
|
|
|
20283
20351
|
__name(viewToBase64, "viewToBase64");
|
|
20284
20352
|
__name(reviveArrayBuffer, "reviveArrayBuffer");
|
|
20285
20353
|
__name(revive, "revive");
|
|
20354
|
+
__name(readErrorStack, "readErrorStack");
|
|
20286
20355
|
__name(reduceErrorBase, "reduceErrorBase");
|
|
20287
20356
|
__name(reduceNamedErrorSubclassBase, "reduceNamedErrorSubclassBase");
|
|
20288
20357
|
__name(makeErrorSubclassReducer, "makeErrorSubclassReducer");
|
|
@@ -20966,7 +21035,7 @@ function SemanticConvention(...names) {
|
|
|
20966
21035
|
value
|
|
20967
21036
|
]));
|
|
20968
21037
|
}
|
|
20969
|
-
var WorkflowName, WorkflowOperation, WorkflowRunId, WorkflowRunStatus, WorkflowStartedAt, WorkflowEventsCount, WorkflowArgumentsCount, WorkflowResultType, WorkflowTracePropagated, WorkflowTraceMode, WorkflowTurbo, WorkflowErrorName, WorkflowErrorMessage, WorkflowErrorCode, WorkflowStepsCreated, WorkflowHooksCreated, WorkflowWaitsCreated, WorkflowOwnedRecoverySteps, WorkflowBackstopWakesArmed, WorkflowRouteType, WorkflowRouteHandlerCached, WorkflowRouteInvocationCount, WorkflowRouteEntrypointAgeMs, WorkflowRouteModuleBodyInitMs, FaasInstance, StepName, StepId, StepAttempt, StepStatus, StepMaxRetries, StepTracePropagated, StepTtfsMs, StepStsoMs, StepRsfsMs, StepFinalSchedulingReplayMs, StepLatencyOptimizations, StepSkipped, StepSkipReason, StepArgumentsCount, StepResultType, StepErrorName, StepErrorMessage, StepFatalError, StepRetryExhausted, StepRetryTimeoutSeconds, StepRetryWillRetry, MessagingSystem, MessagingDestinationName, MessagingMessageId, MessagingOperationType, QueueOverheadMs, DeploymentId, HookToken, HookId, HookFound, HookResilientResume, HookResilientResumeMaterialized, WebhookHandlersTriggered, WorkflowSuspensionState, WorkflowSuspensionHookCount, WorkflowSuspensionStepCount, WorkflowSuspensionWaitCount, HttpRequestMethod, HttpRoute, UrlFull, ServerAddress, ServerPort, HttpResponseStatusCode, ErrorType, WorldParseFormat, WorkflowEventsPagesLoaded, QueueDeserializeTimeMs, QueueExecutionTimeMs, QueueSerializeTimeMs, SerializationOperation, SerializationCompressed, SerializationCodec, SerializationUncompressedBytes, SerializationStoredBytes, SerializationCompressionRatio, SerializationGuestCodeExecutions, SerializationGuestCodeDetails, PeerService, RpcSystem, RpcService, RpcMethod, ErrorRetryable, ErrorCategory;
|
|
21038
|
+
var WorkflowName, WorkflowOperation, WorkflowRunId, WorkflowRunStatus, WorkflowStartedAt, WorkflowEventsCount, WorkflowExecutionMode, WorkflowArgumentsCount, WorkflowResultType, WorkflowTracePropagated, WorkflowVm, QuickJSOutcome, QuickJSEventsPreloaded, QuickJSEventsFetchedCount, QuickJSEventsFetchedPages, QuickJSPendingOpsCount, QuickJSInlineSteps, WorkflowTraceMode, WorkflowTurbo, WorkflowErrorName, WorkflowErrorMessage, WorkflowErrorCode, WorkflowStepsCreated, WorkflowHooksCreated, WorkflowWaitsCreated, WorkflowOwnedRecoverySteps, WorkflowBackstopWakesArmed, WorkflowRouteType, WorkflowRouteHandlerCached, WorkflowRouteInvocationCount, WorkflowRouteEntrypointAgeMs, WorkflowRouteModuleBodyInitMs, FaasInstance, StepName, StepId, StepAttempt, StepStatus, StepMaxRetries, StepTracePropagated, StepTtfsMs, StepStsoMs, StepRsfsMs, StepFinalSchedulingReplayMs, StepLatencyOptimizations, StepSkipped, StepSkipReason, StepArgumentsCount, StepResultType, StepErrorName, StepErrorMessage, StepFatalError, StepRetryExhausted, StepRetryTimeoutSeconds, StepRetryWillRetry, MessagingSystem, MessagingDestinationName, MessagingMessageId, MessagingOperationType, QueueOverheadMs, DeploymentId, WorkflowRunPinnedDeploymentId, WorkflowDeploymentMismatchRetryCount, WorkflowDeploymentMismatchRecovered, HookToken, HookId, HookFound, HookResilientResume, HookResilientResumeMaterialized, HookResumeSetupSource, WebhookHandlersTriggered, WorkflowSuspensionState, WorkflowSuspensionHookCount, WorkflowSuspensionStepCount, WorkflowSuspensionWaitCount, HttpRequestMethod, HttpRoute, UrlFull, ServerAddress, ServerPort, HttpResponseStatusCode, ErrorType, WorldParseFormat, WorkflowEventsPagesLoaded, QueueDeserializeTimeMs, QueueExecutionTimeMs, QueueSerializeTimeMs, SerializationOperation, SerializationCompressed, SerializationCodec, SerializationUncompressedBytes, SerializationStoredBytes, SerializationCompressionRatio, SerializationGuestCodeExecutions, SerializationGuestCodeDetails, PeerService, RpcSystem, RpcService, RpcMethod, ErrorRetryable, ErrorCategory;
|
|
20970
21039
|
var init_semantic_conventions = __esm({
|
|
20971
21040
|
"../core/dist/telemetry/semantic-conventions.js"() {
|
|
20972
21041
|
"use strict";
|
|
@@ -20977,9 +21046,17 @@ var init_semantic_conventions = __esm({
|
|
|
20977
21046
|
WorkflowRunStatus = SemanticConvention("workflow.run.status");
|
|
20978
21047
|
WorkflowStartedAt = SemanticConvention("workflow.started_at");
|
|
20979
21048
|
WorkflowEventsCount = SemanticConvention("workflow.events.count");
|
|
21049
|
+
WorkflowExecutionMode = SemanticConvention("workflow.execution.mode");
|
|
20980
21050
|
WorkflowArgumentsCount = SemanticConvention("workflow.arguments.count");
|
|
20981
21051
|
WorkflowResultType = SemanticConvention("workflow.result.type");
|
|
20982
21052
|
WorkflowTracePropagated = SemanticConvention("workflow.trace.propagated");
|
|
21053
|
+
WorkflowVm = SemanticConvention("workflow.vm");
|
|
21054
|
+
QuickJSOutcome = SemanticConvention("workflow.vm.outcome");
|
|
21055
|
+
QuickJSEventsPreloaded = SemanticConvention("workflow.vm.events.preloaded");
|
|
21056
|
+
QuickJSEventsFetchedCount = SemanticConvention("workflow.vm.events.fetched_count");
|
|
21057
|
+
QuickJSEventsFetchedPages = SemanticConvention("workflow.vm.events.fetched_pages");
|
|
21058
|
+
QuickJSPendingOpsCount = SemanticConvention("workflow.vm.pending_ops_count");
|
|
21059
|
+
QuickJSInlineSteps = SemanticConvention("quickjs.inline_steps");
|
|
20983
21060
|
WorkflowTraceMode = SemanticConvention("workflow.trace.mode");
|
|
20984
21061
|
WorkflowTurbo = SemanticConvention("workflow.turbo");
|
|
20985
21062
|
WorkflowErrorName = SemanticConvention("workflow.error.name");
|
|
@@ -21023,11 +21100,15 @@ var init_semantic_conventions = __esm({
|
|
|
21023
21100
|
MessagingOperationType = SemanticConvention("messaging.operation.type");
|
|
21024
21101
|
QueueOverheadMs = SemanticConvention("workflow.queue.overhead_ms");
|
|
21025
21102
|
DeploymentId = SemanticConvention("deployment.id");
|
|
21103
|
+
WorkflowRunPinnedDeploymentId = SemanticConvention("workflow.deployment.pinned_id");
|
|
21104
|
+
WorkflowDeploymentMismatchRetryCount = SemanticConvention("workflow.deployment_mismatch.retry_count");
|
|
21105
|
+
WorkflowDeploymentMismatchRecovered = SemanticConvention("workflow.deployment_mismatch.recovered");
|
|
21026
21106
|
HookToken = SemanticConvention("workflow.hook.token");
|
|
21027
21107
|
HookId = SemanticConvention("workflow.hook.id");
|
|
21028
21108
|
HookFound = SemanticConvention("workflow.hook.found");
|
|
21029
21109
|
HookResilientResume = SemanticConvention("workflow.hook.resilient_resume");
|
|
21030
21110
|
HookResilientResumeMaterialized = SemanticConvention("workflow.hook.resilient_resume_materialized");
|
|
21111
|
+
HookResumeSetupSource = SemanticConvention("workflow.resume_setup_source");
|
|
21031
21112
|
WebhookHandlersTriggered = SemanticConvention("webhook.handlers.triggered");
|
|
21032
21113
|
WorkflowSuspensionState = SemanticConvention("workflow.suspension.state");
|
|
21033
21114
|
WorkflowSuspensionHookCount = SemanticConvention("workflow.suspension.hook_count");
|
|
@@ -23160,11 +23241,17 @@ async function trace(spanName, ...args) {
|
|
|
23160
23241
|
});
|
|
23161
23242
|
return result;
|
|
23162
23243
|
} catch (e) {
|
|
23163
|
-
|
|
23164
|
-
|
|
23165
|
-
|
|
23166
|
-
|
|
23167
|
-
|
|
23244
|
+
if (WorkflowSuspension.is(e)) {
|
|
23245
|
+
span.setStatus({
|
|
23246
|
+
code: otel.SpanStatusCode.OK
|
|
23247
|
+
});
|
|
23248
|
+
applyWorkflowSuspensionToSpan(e, span);
|
|
23249
|
+
} else {
|
|
23250
|
+
span.setStatus({
|
|
23251
|
+
code: otel.SpanStatusCode.ERROR,
|
|
23252
|
+
message: e.message
|
|
23253
|
+
});
|
|
23254
|
+
}
|
|
23168
23255
|
throw e;
|
|
23169
23256
|
} finally {
|
|
23170
23257
|
span.end();
|
|
@@ -23179,13 +23266,7 @@ async function recordElapsedSpan(spanName, startEpochMs, opts) {
|
|
|
23179
23266
|
startTime: startEpochMs
|
|
23180
23267
|
}).end();
|
|
23181
23268
|
}
|
|
23182
|
-
function applyWorkflowSuspensionToSpan(error48,
|
|
23183
|
-
if (!error48 || !WorkflowSuspension.is(error48)) {
|
|
23184
|
-
return;
|
|
23185
|
-
}
|
|
23186
|
-
span.setStatus({
|
|
23187
|
-
code: otel.SpanStatusCode.OK
|
|
23188
|
-
});
|
|
23269
|
+
function applyWorkflowSuspensionToSpan(error48, span) {
|
|
23189
23270
|
span.setAttributes({
|
|
23190
23271
|
...WorkflowSuspensionState("suspended"),
|
|
23191
23272
|
...WorkflowSuspensionStepCount(error48.stepCount),
|
|
@@ -25702,7 +25783,7 @@ var version2;
|
|
|
25702
25783
|
var init_version = __esm({
|
|
25703
25784
|
"../core/dist/version.js"() {
|
|
25704
25785
|
"use strict";
|
|
25705
|
-
version2 = "5.0.0-beta.
|
|
25786
|
+
version2 = "5.0.0-beta.40";
|
|
25706
25787
|
}
|
|
25707
25788
|
});
|
|
25708
25789
|
|
|
@@ -25881,9 +25962,9 @@ var init_helpers = __esm({
|
|
|
25881
25962
|
}
|
|
25882
25963
|
});
|
|
25883
25964
|
|
|
25884
|
-
// ../../node_modules/.pnpm/@vercel+functions@3.
|
|
25965
|
+
// ../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/headers.js
|
|
25885
25966
|
var require_headers = __commonJS({
|
|
25886
|
-
"../../node_modules/.pnpm/@vercel+functions@3.
|
|
25967
|
+
"../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/headers.js"(exports, module) {
|
|
25887
25968
|
"use strict";
|
|
25888
25969
|
var __defProp2 = Object.defineProperty;
|
|
25889
25970
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -25975,9 +26056,9 @@ var require_headers = __commonJS({
|
|
|
25975
26056
|
}
|
|
25976
26057
|
});
|
|
25977
26058
|
|
|
25978
|
-
// ../../node_modules/.pnpm/@vercel+functions@3.
|
|
26059
|
+
// ../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/get-env.js
|
|
25979
26060
|
var require_get_env = __commonJS({
|
|
25980
|
-
"../../node_modules/.pnpm/@vercel+functions@3.
|
|
26061
|
+
"../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/get-env.js"(exports, module) {
|
|
25981
26062
|
"use strict";
|
|
25982
26063
|
var __defProp2 = Object.defineProperty;
|
|
25983
26064
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -26144,9 +26225,9 @@ var require_get_env = __commonJS({
|
|
|
26144
26225
|
}
|
|
26145
26226
|
});
|
|
26146
26227
|
|
|
26147
|
-
// ../../node_modules/.pnpm/@vercel+functions@3.
|
|
26228
|
+
// ../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/get-context.js
|
|
26148
26229
|
var require_get_context = __commonJS({
|
|
26149
|
-
"../../node_modules/.pnpm/@vercel+functions@3.
|
|
26230
|
+
"../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/get-context.js"(exports, module) {
|
|
26150
26231
|
"use strict";
|
|
26151
26232
|
var __defProp2 = Object.defineProperty;
|
|
26152
26233
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -26185,9 +26266,56 @@ var require_get_context = __commonJS({
|
|
|
26185
26266
|
}
|
|
26186
26267
|
});
|
|
26187
26268
|
|
|
26188
|
-
// ../../node_modules/.pnpm/@vercel+functions@3.
|
|
26269
|
+
// ../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/deadline.js
|
|
26270
|
+
var require_deadline = __commonJS({
|
|
26271
|
+
"../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/deadline.js"(exports, module) {
|
|
26272
|
+
"use strict";
|
|
26273
|
+
var __defProp2 = Object.defineProperty;
|
|
26274
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
26275
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
26276
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
26277
|
+
var __export2 = /* @__PURE__ */ __name((target, all) => {
|
|
26278
|
+
for (var name in all) __defProp2(target, name, {
|
|
26279
|
+
get: all[name],
|
|
26280
|
+
enumerable: true
|
|
26281
|
+
});
|
|
26282
|
+
}, "__export");
|
|
26283
|
+
var __copyProps2 = /* @__PURE__ */ __name((to, from, except, desc) => {
|
|
26284
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
26285
|
+
for (let key of __getOwnPropNames2(from)) if (!__hasOwnProp2.call(to, key) && key !== except) __defProp2(to, key, {
|
|
26286
|
+
get: /* @__PURE__ */ __name(() => from[key], "get"),
|
|
26287
|
+
enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable
|
|
26288
|
+
});
|
|
26289
|
+
}
|
|
26290
|
+
return to;
|
|
26291
|
+
}, "__copyProps");
|
|
26292
|
+
var __toCommonJS = /* @__PURE__ */ __name((mod) => __copyProps2(__defProp2({}, "__esModule", {
|
|
26293
|
+
value: true
|
|
26294
|
+
}), mod), "__toCommonJS");
|
|
26295
|
+
var deadline_exports = {};
|
|
26296
|
+
__export2(deadline_exports, {
|
|
26297
|
+
getDeadline: /* @__PURE__ */ __name(() => getDeadline2, "getDeadline")
|
|
26298
|
+
});
|
|
26299
|
+
module.exports = __toCommonJS(deadline_exports);
|
|
26300
|
+
var import_get_context = require_get_context();
|
|
26301
|
+
function getDeadline2() {
|
|
26302
|
+
const deadline = (0, import_get_context.getContext)().deadline;
|
|
26303
|
+
if (deadline === void 0) {
|
|
26304
|
+
return void 0;
|
|
26305
|
+
}
|
|
26306
|
+
const date5 = new Date(deadline);
|
|
26307
|
+
if (isNaN(date5.getTime())) {
|
|
26308
|
+
return void 0;
|
|
26309
|
+
}
|
|
26310
|
+
return date5;
|
|
26311
|
+
}
|
|
26312
|
+
__name(getDeadline2, "getDeadline");
|
|
26313
|
+
}
|
|
26314
|
+
});
|
|
26315
|
+
|
|
26316
|
+
// ../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/wait-until.js
|
|
26189
26317
|
var require_wait_until = __commonJS({
|
|
26190
|
-
"../../node_modules/.pnpm/@vercel+functions@3.
|
|
26318
|
+
"../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/wait-until.js"(exports, module) {
|
|
26191
26319
|
"use strict";
|
|
26192
26320
|
var __defProp2 = Object.defineProperty;
|
|
26193
26321
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -26226,9 +26354,9 @@ var require_wait_until = __commonJS({
|
|
|
26226
26354
|
}
|
|
26227
26355
|
});
|
|
26228
26356
|
|
|
26229
|
-
// ../../node_modules/.pnpm/@vercel+functions@3.
|
|
26357
|
+
// ../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/middleware.js
|
|
26230
26358
|
var require_middleware = __commonJS({
|
|
26231
|
-
"../../node_modules/.pnpm/@vercel+functions@3.
|
|
26359
|
+
"../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/middleware.js"(exports, module) {
|
|
26232
26360
|
"use strict";
|
|
26233
26361
|
var __defProp2 = Object.defineProperty;
|
|
26234
26362
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -26295,9 +26423,9 @@ var require_middleware = __commonJS({
|
|
|
26295
26423
|
}
|
|
26296
26424
|
});
|
|
26297
26425
|
|
|
26298
|
-
// ../../node_modules/.pnpm/@vercel+functions@3.
|
|
26426
|
+
// ../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/cache/in-memory-cache.js
|
|
26299
26427
|
var require_in_memory_cache = __commonJS({
|
|
26300
|
-
"../../node_modules/.pnpm/@vercel+functions@3.
|
|
26428
|
+
"../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/cache/in-memory-cache.js"(exports, module) {
|
|
26301
26429
|
"use strict";
|
|
26302
26430
|
var __defProp2 = Object.defineProperty;
|
|
26303
26431
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -26373,9 +26501,9 @@ var require_in_memory_cache = __commonJS({
|
|
|
26373
26501
|
}
|
|
26374
26502
|
});
|
|
26375
26503
|
|
|
26376
|
-
// ../../node_modules/.pnpm/@vercel+functions@3.
|
|
26504
|
+
// ../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/cache/build-client.js
|
|
26377
26505
|
var require_build_client = __commonJS({
|
|
26378
|
-
"../../node_modules/.pnpm/@vercel+functions@3.
|
|
26506
|
+
"../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/cache/build-client.js"(exports, module) {
|
|
26379
26507
|
"use strict";
|
|
26380
26508
|
var __defProp2 = Object.defineProperty;
|
|
26381
26509
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -26547,9 +26675,9 @@ var require_build_client = __commonJS({
|
|
|
26547
26675
|
}
|
|
26548
26676
|
});
|
|
26549
26677
|
|
|
26550
|
-
// ../../node_modules/.pnpm/@vercel+functions@3.
|
|
26678
|
+
// ../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/cache/index.js
|
|
26551
26679
|
var require_cache = __commonJS({
|
|
26552
|
-
"../../node_modules/.pnpm/@vercel+functions@3.
|
|
26680
|
+
"../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/cache/index.js"(exports, module) {
|
|
26553
26681
|
"use strict";
|
|
26554
26682
|
var __defProp2 = Object.defineProperty;
|
|
26555
26683
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -26623,7 +26751,10 @@ var require_cache = __commonJS({
|
|
|
26623
26751
|
return resolveCache().get(makeKey(key));
|
|
26624
26752
|
}, "get"),
|
|
26625
26753
|
set: /* @__PURE__ */ __name((key, value, options) => {
|
|
26626
|
-
return resolveCache().set(makeKey(key), value,
|
|
26754
|
+
return resolveCache().set(makeKey(key), value, {
|
|
26755
|
+
...options,
|
|
26756
|
+
name: options?.name ?? key
|
|
26757
|
+
});
|
|
26627
26758
|
}, "set"),
|
|
26628
26759
|
delete: /* @__PURE__ */ __name((key) => {
|
|
26629
26760
|
return resolveCache().delete(makeKey(key));
|
|
@@ -26699,9 +26830,9 @@ var require_cache = __commonJS({
|
|
|
26699
26830
|
}
|
|
26700
26831
|
});
|
|
26701
26832
|
|
|
26702
|
-
// ../../node_modules/.pnpm/@vercel+functions@3.
|
|
26833
|
+
// ../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/db-connections/index.js
|
|
26703
26834
|
var require_db_connections = __commonJS({
|
|
26704
|
-
"../../node_modules/.pnpm/@vercel+functions@3.
|
|
26835
|
+
"../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/db-connections/index.js"(exports, module) {
|
|
26705
26836
|
"use strict";
|
|
26706
26837
|
var __defProp2 = Object.defineProperty;
|
|
26707
26838
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -26857,9 +26988,9 @@ var require_db_connections = __commonJS({
|
|
|
26857
26988
|
}
|
|
26858
26989
|
});
|
|
26859
26990
|
|
|
26860
|
-
// ../../node_modules/.pnpm/@vercel+functions@3.
|
|
26991
|
+
// ../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/purge/index.js
|
|
26861
26992
|
var require_purge = __commonJS({
|
|
26862
|
-
"../../node_modules/.pnpm/@vercel+functions@3.
|
|
26993
|
+
"../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/purge/index.js"(exports, module) {
|
|
26863
26994
|
"use strict";
|
|
26864
26995
|
var __defProp2 = Object.defineProperty;
|
|
26865
26996
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -26917,9 +27048,9 @@ var require_purge = __commonJS({
|
|
|
26917
27048
|
}
|
|
26918
27049
|
});
|
|
26919
27050
|
|
|
26920
|
-
// ../../node_modules/.pnpm/@vercel+functions@3.
|
|
27051
|
+
// ../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/addcachetag/index.js
|
|
26921
27052
|
var require_addcachetag = __commonJS({
|
|
26922
|
-
"../../node_modules/.pnpm/@vercel+functions@3.
|
|
27053
|
+
"../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/addcachetag/index.js"(exports, module) {
|
|
26923
27054
|
"use strict";
|
|
26924
27055
|
var __defProp2 = Object.defineProperty;
|
|
26925
27056
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -26959,193 +27090,3925 @@ var require_addcachetag = __commonJS({
|
|
|
26959
27090
|
}
|
|
26960
27091
|
});
|
|
26961
27092
|
|
|
26962
|
-
// ../../node_modules/.pnpm
|
|
26963
|
-
var
|
|
26964
|
-
"../../node_modules/.pnpm
|
|
27093
|
+
// ../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/stream.js
|
|
27094
|
+
var require_stream = __commonJS({
|
|
27095
|
+
"../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/stream.js"(exports, module) {
|
|
26965
27096
|
"use strict";
|
|
26966
|
-
var
|
|
26967
|
-
|
|
26968
|
-
|
|
26969
|
-
|
|
26970
|
-
|
|
26971
|
-
|
|
26972
|
-
|
|
26973
|
-
|
|
26974
|
-
});
|
|
26975
|
-
}, "__export");
|
|
26976
|
-
var __copyProps2 = /* @__PURE__ */ __name((to, from, except, desc) => {
|
|
26977
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
26978
|
-
for (let key of __getOwnPropNames2(from)) if (!__hasOwnProp2.call(to, key) && key !== except) __defProp2(to, key, {
|
|
26979
|
-
get: /* @__PURE__ */ __name(() => from[key], "get"),
|
|
26980
|
-
enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable
|
|
26981
|
-
});
|
|
27097
|
+
var { Duplex } = __require("stream");
|
|
27098
|
+
function emitClose(stream) {
|
|
27099
|
+
stream.emit("close");
|
|
27100
|
+
}
|
|
27101
|
+
__name(emitClose, "emitClose");
|
|
27102
|
+
function duplexOnEnd() {
|
|
27103
|
+
if (!this.destroyed && this._writableState.finished) {
|
|
27104
|
+
this.destroy();
|
|
26982
27105
|
}
|
|
26983
|
-
|
|
26984
|
-
|
|
26985
|
-
|
|
26986
|
-
|
|
26987
|
-
|
|
26988
|
-
|
|
26989
|
-
|
|
26990
|
-
addCacheTag: /* @__PURE__ */ __name(() => import_addcachetag.addCacheTag, "addCacheTag"),
|
|
26991
|
-
attachDatabasePool: /* @__PURE__ */ __name(() => import_db_connections.attachDatabasePool, "attachDatabasePool"),
|
|
26992
|
-
dangerouslyDeleteBySrcImage: /* @__PURE__ */ __name(() => import_purge.dangerouslyDeleteBySrcImage, "dangerouslyDeleteBySrcImage"),
|
|
26993
|
-
dangerouslyDeleteByTag: /* @__PURE__ */ __name(() => import_purge.dangerouslyDeleteByTag, "dangerouslyDeleteByTag"),
|
|
26994
|
-
experimental_attachDatabasePool: /* @__PURE__ */ __name(() => import_db_connections.experimental_attachDatabasePool, "experimental_attachDatabasePool"),
|
|
26995
|
-
geolocation: /* @__PURE__ */ __name(() => import_headers.geolocation, "geolocation"),
|
|
26996
|
-
getCache: /* @__PURE__ */ __name(() => import_cache.getCache, "getCache"),
|
|
26997
|
-
getEnv: /* @__PURE__ */ __name(() => import_get_env.getEnv, "getEnv"),
|
|
26998
|
-
invalidateBySrcImage: /* @__PURE__ */ __name(() => import_purge.invalidateBySrcImage, "invalidateBySrcImage"),
|
|
26999
|
-
invalidateByTag: /* @__PURE__ */ __name(() => import_purge.invalidateByTag, "invalidateByTag"),
|
|
27000
|
-
ipAddress: /* @__PURE__ */ __name(() => import_headers.ipAddress, "ipAddress"),
|
|
27001
|
-
next: /* @__PURE__ */ __name(() => import_middleware.next, "next"),
|
|
27002
|
-
rewrite: /* @__PURE__ */ __name(() => import_middleware.rewrite, "rewrite"),
|
|
27003
|
-
waitUntil: /* @__PURE__ */ __name(() => import_wait_until3.waitUntil, "waitUntil")
|
|
27004
|
-
});
|
|
27005
|
-
module.exports = __toCommonJS(src_exports);
|
|
27006
|
-
var import_headers = require_headers();
|
|
27007
|
-
var import_get_env = require_get_env();
|
|
27008
|
-
var import_wait_until3 = require_wait_until();
|
|
27009
|
-
var import_middleware = require_middleware();
|
|
27010
|
-
var import_cache = require_cache();
|
|
27011
|
-
var import_db_connections = require_db_connections();
|
|
27012
|
-
var import_purge = require_purge();
|
|
27013
|
-
var import_addcachetag = require_addcachetag();
|
|
27014
|
-
}
|
|
27015
|
-
});
|
|
27016
|
-
|
|
27017
|
-
// ../core/dist/runtime/wait-until.js
|
|
27018
|
-
function waitUntil2(promise2) {
|
|
27019
|
-
void Promise.resolve().then(() => __toESM(require_functions(), 1)).then(({ waitUntil: waitUntil3 }) => {
|
|
27020
|
-
waitUntil3(promise2);
|
|
27021
|
-
});
|
|
27022
|
-
}
|
|
27023
|
-
function safeWaitUntil(promise2, onError) {
|
|
27024
|
-
waitUntil2(promise2.catch((err) => {
|
|
27025
|
-
const isAbortError = err?.name === "AbortError" || err?.name === "ResponseAborted";
|
|
27026
|
-
if (!isAbortError) {
|
|
27027
|
-
try {
|
|
27028
|
-
onError(err);
|
|
27029
|
-
} catch {
|
|
27106
|
+
}
|
|
27107
|
+
__name(duplexOnEnd, "duplexOnEnd");
|
|
27108
|
+
function duplexOnError(err) {
|
|
27109
|
+
this.removeListener("error", duplexOnError);
|
|
27110
|
+
this.destroy();
|
|
27111
|
+
if (this.listenerCount("error") === 0) {
|
|
27112
|
+
this.emit("error", err);
|
|
27030
27113
|
}
|
|
27031
27114
|
}
|
|
27032
|
-
|
|
27033
|
-
|
|
27034
|
-
|
|
27035
|
-
|
|
27036
|
-
|
|
27037
|
-
|
|
27038
|
-
|
|
27039
|
-
|
|
27040
|
-
|
|
27041
|
-
|
|
27042
|
-
|
|
27043
|
-
|
|
27044
|
-
|
|
27045
|
-
|
|
27115
|
+
__name(duplexOnError, "duplexOnError");
|
|
27116
|
+
function createWebSocketStream2(ws, options) {
|
|
27117
|
+
let terminateOnDestroy = true;
|
|
27118
|
+
const duplex = new Duplex({
|
|
27119
|
+
...options,
|
|
27120
|
+
autoDestroy: false,
|
|
27121
|
+
emitClose: false,
|
|
27122
|
+
objectMode: false,
|
|
27123
|
+
writableObjectMode: false
|
|
27124
|
+
});
|
|
27125
|
+
ws.on("message", /* @__PURE__ */ __name(function message(msg, isBinary) {
|
|
27126
|
+
const data = !isBinary && duplex._readableState.objectMode ? msg.toString() : msg;
|
|
27127
|
+
if (!duplex.push(data)) ws.pause();
|
|
27128
|
+
}, "message"));
|
|
27129
|
+
ws.once("error", /* @__PURE__ */ __name(function error48(err) {
|
|
27130
|
+
if (duplex.destroyed) return;
|
|
27131
|
+
terminateOnDestroy = false;
|
|
27132
|
+
duplex.destroy(err);
|
|
27133
|
+
}, "error"));
|
|
27134
|
+
ws.once("close", /* @__PURE__ */ __name(function close() {
|
|
27135
|
+
if (duplex.destroyed) return;
|
|
27136
|
+
duplex.push(null);
|
|
27137
|
+
}, "close"));
|
|
27138
|
+
duplex._destroy = function(err, callback) {
|
|
27139
|
+
if (ws.readyState === ws.CLOSED) {
|
|
27140
|
+
callback(err);
|
|
27141
|
+
process.nextTick(emitClose, duplex);
|
|
27142
|
+
return;
|
|
27143
|
+
}
|
|
27144
|
+
let called = false;
|
|
27145
|
+
ws.once("error", /* @__PURE__ */ __name(function error48(err2) {
|
|
27146
|
+
called = true;
|
|
27147
|
+
callback(err2);
|
|
27148
|
+
}, "error"));
|
|
27149
|
+
ws.once("close", /* @__PURE__ */ __name(function close() {
|
|
27150
|
+
if (!called) callback(err);
|
|
27151
|
+
process.nextTick(emitClose, duplex);
|
|
27152
|
+
}, "close"));
|
|
27153
|
+
if (terminateOnDestroy) ws.terminate();
|
|
27154
|
+
};
|
|
27155
|
+
duplex._final = function(callback) {
|
|
27156
|
+
if (ws.readyState === ws.CONNECTING) {
|
|
27157
|
+
ws.once("open", /* @__PURE__ */ __name(function open2() {
|
|
27158
|
+
duplex._final(callback);
|
|
27159
|
+
}, "open"));
|
|
27160
|
+
return;
|
|
27161
|
+
}
|
|
27162
|
+
if (ws._socket === null) return;
|
|
27163
|
+
if (ws._socket._writableState.finished) {
|
|
27164
|
+
callback();
|
|
27165
|
+
if (duplex._readableState.endEmitted) duplex.destroy();
|
|
27166
|
+
} else {
|
|
27167
|
+
ws._socket.once("finish", /* @__PURE__ */ __name(function finish() {
|
|
27168
|
+
callback();
|
|
27169
|
+
}, "finish"));
|
|
27170
|
+
ws.close();
|
|
27171
|
+
}
|
|
27172
|
+
};
|
|
27173
|
+
duplex._read = function() {
|
|
27174
|
+
if (ws.isPaused) ws.resume();
|
|
27175
|
+
};
|
|
27176
|
+
duplex._write = function(chunk, encoding, callback) {
|
|
27177
|
+
if (ws.readyState === ws.CONNECTING) {
|
|
27178
|
+
ws.once("open", /* @__PURE__ */ __name(function open2() {
|
|
27179
|
+
duplex._write(chunk, encoding, callback);
|
|
27180
|
+
}, "open"));
|
|
27181
|
+
return;
|
|
27182
|
+
}
|
|
27183
|
+
ws.send(chunk, callback);
|
|
27184
|
+
};
|
|
27185
|
+
duplex.on("end", duplexOnEnd);
|
|
27186
|
+
duplex.on("error", duplexOnError);
|
|
27187
|
+
return duplex;
|
|
27188
|
+
}
|
|
27189
|
+
__name(createWebSocketStream2, "createWebSocketStream");
|
|
27190
|
+
module.exports = createWebSocketStream2;
|
|
27046
27191
|
}
|
|
27047
27192
|
});
|
|
27048
27193
|
|
|
27049
|
-
//
|
|
27050
|
-
var
|
|
27051
|
-
|
|
27052
|
-
|
|
27053
|
-
|
|
27054
|
-
|
|
27055
|
-
|
|
27056
|
-
|
|
27057
|
-
|
|
27058
|
-
|
|
27059
|
-
|
|
27060
|
-
|
|
27061
|
-
|
|
27062
|
-
|
|
27063
|
-
|
|
27064
|
-
|
|
27065
|
-
|
|
27066
|
-
|
|
27067
|
-
|
|
27068
|
-
|
|
27069
|
-
|
|
27070
|
-
|
|
27071
|
-
|
|
27072
|
-
runSpecVersion: run2.specVersion,
|
|
27073
|
-
workflowCoreVersion: typeof coreVersion === "string" ? coreVersion : void 0,
|
|
27074
|
-
traceCarrier: traceCarrier && typeof traceCarrier === "object" ? traceCarrier : void 0,
|
|
27075
|
-
encryptionPublicKey: run2.encryptionPublicKey,
|
|
27076
|
-
hookResumeInputVersion: typeof hookResumeInputVersion === "number" ? hookResumeInputVersion : void 0
|
|
27077
|
-
};
|
|
27078
|
-
}
|
|
27079
|
-
async function resolveHookResumeInfo(hook) {
|
|
27080
|
-
if (hook.resumeContext) {
|
|
27081
|
-
return {
|
|
27082
|
-
resumeContext: hook.resumeContext,
|
|
27083
|
-
source: "hook"
|
|
27194
|
+
// ../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/constants.js
|
|
27195
|
+
var require_constants2 = __commonJS({
|
|
27196
|
+
"../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/constants.js"(exports, module) {
|
|
27197
|
+
"use strict";
|
|
27198
|
+
var BINARY_TYPES = [
|
|
27199
|
+
"nodebuffer",
|
|
27200
|
+
"arraybuffer",
|
|
27201
|
+
"fragments"
|
|
27202
|
+
];
|
|
27203
|
+
var hasBlob = typeof Blob !== "undefined";
|
|
27204
|
+
if (hasBlob) BINARY_TYPES.push("blob");
|
|
27205
|
+
module.exports = {
|
|
27206
|
+
BINARY_TYPES,
|
|
27207
|
+
CLOSE_TIMEOUT: 3e4,
|
|
27208
|
+
EMPTY_BUFFER: Buffer.alloc(0),
|
|
27209
|
+
GUID: "258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
|
|
27210
|
+
hasBlob,
|
|
27211
|
+
kForOnEventAttribute: /* @__PURE__ */ Symbol("kIsForOnEventAttribute"),
|
|
27212
|
+
kListener: /* @__PURE__ */ Symbol("kListener"),
|
|
27213
|
+
kStatusCode: /* @__PURE__ */ Symbol("status-code"),
|
|
27214
|
+
kWebSocket: /* @__PURE__ */ Symbol("websocket"),
|
|
27215
|
+
NOOP: /* @__PURE__ */ __name(() => {
|
|
27216
|
+
}, "NOOP")
|
|
27084
27217
|
};
|
|
27085
27218
|
}
|
|
27086
|
-
|
|
27087
|
-
|
|
27088
|
-
|
|
27089
|
-
|
|
27090
|
-
|
|
27091
|
-
|
|
27092
|
-
}
|
|
27093
|
-
|
|
27094
|
-
|
|
27095
|
-
|
|
27096
|
-
|
|
27097
|
-
|
|
27098
|
-
|
|
27099
|
-
|
|
27100
|
-
|
|
27101
|
-
|
|
27102
|
-
|
|
27103
|
-
|
|
27104
|
-
|
|
27105
|
-
|
|
27106
|
-
|
|
27107
|
-
|
|
27108
|
-
|
|
27109
|
-
|
|
27110
|
-
|
|
27111
|
-
|
|
27112
|
-
|
|
27113
|
-
|
|
27114
|
-
|
|
27115
|
-
|
|
27116
|
-
|
|
27117
|
-
|
|
27118
|
-
|
|
27119
|
-
|
|
27120
|
-
|
|
27121
|
-
|
|
27122
|
-
|
|
27123
|
-
|
|
27124
|
-
|
|
27125
|
-
|
|
27126
|
-
|
|
27127
|
-
|
|
27128
|
-
|
|
27129
|
-
|
|
27130
|
-
|
|
27131
|
-
|
|
27132
|
-
|
|
27133
|
-
|
|
27134
|
-
|
|
27135
|
-
|
|
27136
|
-
|
|
27137
|
-
|
|
27138
|
-
|
|
27139
|
-
|
|
27140
|
-
|
|
27141
|
-
|
|
27142
|
-
|
|
27143
|
-
|
|
27144
|
-
|
|
27145
|
-
|
|
27146
|
-
|
|
27147
|
-
|
|
27148
|
-
|
|
27219
|
+
});
|
|
27220
|
+
|
|
27221
|
+
// ../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/validation.js
|
|
27222
|
+
var require_validation = __commonJS({
|
|
27223
|
+
"../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/validation.js"(exports, module) {
|
|
27224
|
+
"use strict";
|
|
27225
|
+
var { isUtf8 } = __require("buffer");
|
|
27226
|
+
var { hasBlob } = require_constants2();
|
|
27227
|
+
var tokenChars = [
|
|
27228
|
+
0,
|
|
27229
|
+
0,
|
|
27230
|
+
0,
|
|
27231
|
+
0,
|
|
27232
|
+
0,
|
|
27233
|
+
0,
|
|
27234
|
+
0,
|
|
27235
|
+
0,
|
|
27236
|
+
0,
|
|
27237
|
+
0,
|
|
27238
|
+
0,
|
|
27239
|
+
0,
|
|
27240
|
+
0,
|
|
27241
|
+
0,
|
|
27242
|
+
0,
|
|
27243
|
+
0,
|
|
27244
|
+
0,
|
|
27245
|
+
0,
|
|
27246
|
+
0,
|
|
27247
|
+
0,
|
|
27248
|
+
0,
|
|
27249
|
+
0,
|
|
27250
|
+
0,
|
|
27251
|
+
0,
|
|
27252
|
+
0,
|
|
27253
|
+
0,
|
|
27254
|
+
0,
|
|
27255
|
+
0,
|
|
27256
|
+
0,
|
|
27257
|
+
0,
|
|
27258
|
+
0,
|
|
27259
|
+
0,
|
|
27260
|
+
0,
|
|
27261
|
+
1,
|
|
27262
|
+
0,
|
|
27263
|
+
1,
|
|
27264
|
+
1,
|
|
27265
|
+
1,
|
|
27266
|
+
1,
|
|
27267
|
+
1,
|
|
27268
|
+
0,
|
|
27269
|
+
0,
|
|
27270
|
+
1,
|
|
27271
|
+
1,
|
|
27272
|
+
0,
|
|
27273
|
+
1,
|
|
27274
|
+
1,
|
|
27275
|
+
0,
|
|
27276
|
+
1,
|
|
27277
|
+
1,
|
|
27278
|
+
1,
|
|
27279
|
+
1,
|
|
27280
|
+
1,
|
|
27281
|
+
1,
|
|
27282
|
+
1,
|
|
27283
|
+
1,
|
|
27284
|
+
1,
|
|
27285
|
+
1,
|
|
27286
|
+
0,
|
|
27287
|
+
0,
|
|
27288
|
+
0,
|
|
27289
|
+
0,
|
|
27290
|
+
0,
|
|
27291
|
+
0,
|
|
27292
|
+
0,
|
|
27293
|
+
1,
|
|
27294
|
+
1,
|
|
27295
|
+
1,
|
|
27296
|
+
1,
|
|
27297
|
+
1,
|
|
27298
|
+
1,
|
|
27299
|
+
1,
|
|
27300
|
+
1,
|
|
27301
|
+
1,
|
|
27302
|
+
1,
|
|
27303
|
+
1,
|
|
27304
|
+
1,
|
|
27305
|
+
1,
|
|
27306
|
+
1,
|
|
27307
|
+
1,
|
|
27308
|
+
1,
|
|
27309
|
+
1,
|
|
27310
|
+
1,
|
|
27311
|
+
1,
|
|
27312
|
+
1,
|
|
27313
|
+
1,
|
|
27314
|
+
1,
|
|
27315
|
+
1,
|
|
27316
|
+
1,
|
|
27317
|
+
1,
|
|
27318
|
+
1,
|
|
27319
|
+
0,
|
|
27320
|
+
0,
|
|
27321
|
+
0,
|
|
27322
|
+
1,
|
|
27323
|
+
1,
|
|
27324
|
+
1,
|
|
27325
|
+
1,
|
|
27326
|
+
1,
|
|
27327
|
+
1,
|
|
27328
|
+
1,
|
|
27329
|
+
1,
|
|
27330
|
+
1,
|
|
27331
|
+
1,
|
|
27332
|
+
1,
|
|
27333
|
+
1,
|
|
27334
|
+
1,
|
|
27335
|
+
1,
|
|
27336
|
+
1,
|
|
27337
|
+
1,
|
|
27338
|
+
1,
|
|
27339
|
+
1,
|
|
27340
|
+
1,
|
|
27341
|
+
1,
|
|
27342
|
+
1,
|
|
27343
|
+
1,
|
|
27344
|
+
1,
|
|
27345
|
+
1,
|
|
27346
|
+
1,
|
|
27347
|
+
1,
|
|
27348
|
+
1,
|
|
27349
|
+
1,
|
|
27350
|
+
1,
|
|
27351
|
+
0,
|
|
27352
|
+
1,
|
|
27353
|
+
0,
|
|
27354
|
+
1,
|
|
27355
|
+
0
|
|
27356
|
+
// 112 - 127
|
|
27357
|
+
];
|
|
27358
|
+
function isValidStatusCode(code2) {
|
|
27359
|
+
return code2 >= 1e3 && code2 <= 1014 && code2 !== 1004 && code2 !== 1005 && code2 !== 1006 || code2 >= 3e3 && code2 <= 4999;
|
|
27360
|
+
}
|
|
27361
|
+
__name(isValidStatusCode, "isValidStatusCode");
|
|
27362
|
+
function _isValidUTF8(buf) {
|
|
27363
|
+
const len = buf.length;
|
|
27364
|
+
let i = 0;
|
|
27365
|
+
while (i < len) {
|
|
27366
|
+
if ((buf[i] & 128) === 0) {
|
|
27367
|
+
i++;
|
|
27368
|
+
} else if ((buf[i] & 224) === 192) {
|
|
27369
|
+
if (i + 1 === len || (buf[i + 1] & 192) !== 128 || (buf[i] & 254) === 192) {
|
|
27370
|
+
return false;
|
|
27371
|
+
}
|
|
27372
|
+
i += 2;
|
|
27373
|
+
} else if ((buf[i] & 240) === 224) {
|
|
27374
|
+
if (i + 2 >= len || (buf[i + 1] & 192) !== 128 || (buf[i + 2] & 192) !== 128 || buf[i] === 224 && (buf[i + 1] & 224) === 128 || // Overlong
|
|
27375
|
+
buf[i] === 237 && (buf[i + 1] & 224) === 160) {
|
|
27376
|
+
return false;
|
|
27377
|
+
}
|
|
27378
|
+
i += 3;
|
|
27379
|
+
} else if ((buf[i] & 248) === 240) {
|
|
27380
|
+
if (i + 3 >= len || (buf[i + 1] & 192) !== 128 || (buf[i + 2] & 192) !== 128 || (buf[i + 3] & 192) !== 128 || buf[i] === 240 && (buf[i + 1] & 240) === 128 || // Overlong
|
|
27381
|
+
buf[i] === 244 && buf[i + 1] > 143 || buf[i] > 244) {
|
|
27382
|
+
return false;
|
|
27383
|
+
}
|
|
27384
|
+
i += 4;
|
|
27385
|
+
} else {
|
|
27386
|
+
return false;
|
|
27387
|
+
}
|
|
27388
|
+
}
|
|
27389
|
+
return true;
|
|
27390
|
+
}
|
|
27391
|
+
__name(_isValidUTF8, "_isValidUTF8");
|
|
27392
|
+
function isBlob(value) {
|
|
27393
|
+
return hasBlob && typeof value === "object" && typeof value.arrayBuffer === "function" && typeof value.type === "string" && typeof value.stream === "function" && (value[Symbol.toStringTag] === "Blob" || value[Symbol.toStringTag] === "File");
|
|
27394
|
+
}
|
|
27395
|
+
__name(isBlob, "isBlob");
|
|
27396
|
+
module.exports = {
|
|
27397
|
+
isBlob,
|
|
27398
|
+
isValidStatusCode,
|
|
27399
|
+
isValidUTF8: _isValidUTF8,
|
|
27400
|
+
tokenChars
|
|
27401
|
+
};
|
|
27402
|
+
if (isUtf8) {
|
|
27403
|
+
module.exports.isValidUTF8 = function(buf) {
|
|
27404
|
+
return buf.length < 24 ? _isValidUTF8(buf) : isUtf8(buf);
|
|
27405
|
+
};
|
|
27406
|
+
} else if (!process.env.WS_NO_UTF_8_VALIDATE) {
|
|
27407
|
+
try {
|
|
27408
|
+
const isValidUTF8 = __require("utf-8-validate");
|
|
27409
|
+
module.exports.isValidUTF8 = function(buf) {
|
|
27410
|
+
return buf.length < 32 ? _isValidUTF8(buf) : isValidUTF8(buf);
|
|
27411
|
+
};
|
|
27412
|
+
} catch (e) {
|
|
27413
|
+
}
|
|
27414
|
+
}
|
|
27415
|
+
}
|
|
27416
|
+
});
|
|
27417
|
+
|
|
27418
|
+
// ../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/extension.js
|
|
27419
|
+
var require_extension = __commonJS({
|
|
27420
|
+
"../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/extension.js"(exports, module) {
|
|
27421
|
+
"use strict";
|
|
27422
|
+
var { tokenChars } = require_validation();
|
|
27423
|
+
function push(dest, name, elem) {
|
|
27424
|
+
if (dest[name] === void 0) dest[name] = [
|
|
27425
|
+
elem
|
|
27426
|
+
];
|
|
27427
|
+
else dest[name].push(elem);
|
|
27428
|
+
}
|
|
27429
|
+
__name(push, "push");
|
|
27430
|
+
function parse4(header) {
|
|
27431
|
+
const offers = /* @__PURE__ */ Object.create(null);
|
|
27432
|
+
let params = /* @__PURE__ */ Object.create(null);
|
|
27433
|
+
let mustUnescape = false;
|
|
27434
|
+
let isEscaping = false;
|
|
27435
|
+
let inQuotes = false;
|
|
27436
|
+
let extensionName;
|
|
27437
|
+
let paramName;
|
|
27438
|
+
let start2 = -1;
|
|
27439
|
+
let code2 = -1;
|
|
27440
|
+
let end = -1;
|
|
27441
|
+
let i = 0;
|
|
27442
|
+
for (; i < header.length; i++) {
|
|
27443
|
+
code2 = header.charCodeAt(i);
|
|
27444
|
+
if (extensionName === void 0) {
|
|
27445
|
+
if (end === -1 && tokenChars[code2] === 1) {
|
|
27446
|
+
if (start2 === -1) start2 = i;
|
|
27447
|
+
} else if (i !== 0 && (code2 === 32 || code2 === 9)) {
|
|
27448
|
+
if (end === -1 && start2 !== -1) end = i;
|
|
27449
|
+
} else if (code2 === 59 || code2 === 44) {
|
|
27450
|
+
if (start2 === -1) {
|
|
27451
|
+
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
27452
|
+
}
|
|
27453
|
+
if (end === -1) end = i;
|
|
27454
|
+
const name = header.slice(start2, end);
|
|
27455
|
+
if (code2 === 44) {
|
|
27456
|
+
push(offers, name, params);
|
|
27457
|
+
params = /* @__PURE__ */ Object.create(null);
|
|
27458
|
+
} else {
|
|
27459
|
+
extensionName = name;
|
|
27460
|
+
}
|
|
27461
|
+
start2 = end = -1;
|
|
27462
|
+
} else {
|
|
27463
|
+
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
27464
|
+
}
|
|
27465
|
+
} else if (paramName === void 0) {
|
|
27466
|
+
if (end === -1 && tokenChars[code2] === 1) {
|
|
27467
|
+
if (start2 === -1) start2 = i;
|
|
27468
|
+
} else if (code2 === 32 || code2 === 9) {
|
|
27469
|
+
if (end === -1 && start2 !== -1) end = i;
|
|
27470
|
+
} else if (code2 === 59 || code2 === 44) {
|
|
27471
|
+
if (start2 === -1) {
|
|
27472
|
+
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
27473
|
+
}
|
|
27474
|
+
if (end === -1) end = i;
|
|
27475
|
+
push(params, header.slice(start2, end), true);
|
|
27476
|
+
if (code2 === 44) {
|
|
27477
|
+
push(offers, extensionName, params);
|
|
27478
|
+
params = /* @__PURE__ */ Object.create(null);
|
|
27479
|
+
extensionName = void 0;
|
|
27480
|
+
}
|
|
27481
|
+
start2 = end = -1;
|
|
27482
|
+
} else if (code2 === 61 && start2 !== -1 && end === -1) {
|
|
27483
|
+
paramName = header.slice(start2, i);
|
|
27484
|
+
start2 = end = -1;
|
|
27485
|
+
} else {
|
|
27486
|
+
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
27487
|
+
}
|
|
27488
|
+
} else {
|
|
27489
|
+
if (isEscaping) {
|
|
27490
|
+
if (tokenChars[code2] !== 1) {
|
|
27491
|
+
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
27492
|
+
}
|
|
27493
|
+
if (start2 === -1) start2 = i;
|
|
27494
|
+
else if (!mustUnescape) mustUnescape = true;
|
|
27495
|
+
isEscaping = false;
|
|
27496
|
+
} else if (inQuotes) {
|
|
27497
|
+
if (tokenChars[code2] === 1) {
|
|
27498
|
+
if (start2 === -1) start2 = i;
|
|
27499
|
+
} else if (code2 === 34 && start2 !== -1) {
|
|
27500
|
+
inQuotes = false;
|
|
27501
|
+
end = i;
|
|
27502
|
+
} else if (code2 === 92) {
|
|
27503
|
+
isEscaping = true;
|
|
27504
|
+
} else {
|
|
27505
|
+
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
27506
|
+
}
|
|
27507
|
+
} else if (code2 === 34 && header.charCodeAt(i - 1) === 61) {
|
|
27508
|
+
inQuotes = true;
|
|
27509
|
+
} else if (end === -1 && tokenChars[code2] === 1) {
|
|
27510
|
+
if (start2 === -1) start2 = i;
|
|
27511
|
+
} else if (start2 !== -1 && (code2 === 32 || code2 === 9)) {
|
|
27512
|
+
if (end === -1) end = i;
|
|
27513
|
+
} else if (code2 === 59 || code2 === 44) {
|
|
27514
|
+
if (start2 === -1) {
|
|
27515
|
+
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
27516
|
+
}
|
|
27517
|
+
if (end === -1) end = i;
|
|
27518
|
+
let value = header.slice(start2, end);
|
|
27519
|
+
if (mustUnescape) {
|
|
27520
|
+
value = value.replace(/\\/g, "");
|
|
27521
|
+
mustUnescape = false;
|
|
27522
|
+
}
|
|
27523
|
+
push(params, paramName, value);
|
|
27524
|
+
if (code2 === 44) {
|
|
27525
|
+
push(offers, extensionName, params);
|
|
27526
|
+
params = /* @__PURE__ */ Object.create(null);
|
|
27527
|
+
extensionName = void 0;
|
|
27528
|
+
}
|
|
27529
|
+
paramName = void 0;
|
|
27530
|
+
start2 = end = -1;
|
|
27531
|
+
} else {
|
|
27532
|
+
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
27533
|
+
}
|
|
27534
|
+
}
|
|
27535
|
+
}
|
|
27536
|
+
if (start2 === -1 || inQuotes || code2 === 32 || code2 === 9) {
|
|
27537
|
+
throw new SyntaxError("Unexpected end of input");
|
|
27538
|
+
}
|
|
27539
|
+
if (end === -1) end = i;
|
|
27540
|
+
const token = header.slice(start2, end);
|
|
27541
|
+
if (extensionName === void 0) {
|
|
27542
|
+
push(offers, token, params);
|
|
27543
|
+
} else {
|
|
27544
|
+
if (paramName === void 0) {
|
|
27545
|
+
push(params, token, true);
|
|
27546
|
+
} else if (mustUnescape) {
|
|
27547
|
+
push(params, paramName, token.replace(/\\/g, ""));
|
|
27548
|
+
} else {
|
|
27549
|
+
push(params, paramName, token);
|
|
27550
|
+
}
|
|
27551
|
+
push(offers, extensionName, params);
|
|
27552
|
+
}
|
|
27553
|
+
return offers;
|
|
27554
|
+
}
|
|
27555
|
+
__name(parse4, "parse");
|
|
27556
|
+
function format(extensions) {
|
|
27557
|
+
return Object.keys(extensions).map((extension2) => {
|
|
27558
|
+
let configurations = extensions[extension2];
|
|
27559
|
+
if (!Array.isArray(configurations)) configurations = [
|
|
27560
|
+
configurations
|
|
27561
|
+
];
|
|
27562
|
+
return configurations.map((params) => {
|
|
27563
|
+
return [
|
|
27564
|
+
extension2
|
|
27565
|
+
].concat(Object.keys(params).map((k) => {
|
|
27566
|
+
let values = params[k];
|
|
27567
|
+
if (!Array.isArray(values)) values = [
|
|
27568
|
+
values
|
|
27569
|
+
];
|
|
27570
|
+
return values.map((v) => v === true ? k : `${k}=${v}`).join("; ");
|
|
27571
|
+
})).join("; ");
|
|
27572
|
+
}).join(", ");
|
|
27573
|
+
}).join(", ");
|
|
27574
|
+
}
|
|
27575
|
+
__name(format, "format");
|
|
27576
|
+
module.exports = {
|
|
27577
|
+
format,
|
|
27578
|
+
parse: parse4
|
|
27579
|
+
};
|
|
27580
|
+
}
|
|
27581
|
+
});
|
|
27582
|
+
|
|
27583
|
+
// ../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/buffer-util.js
|
|
27584
|
+
var require_buffer_util = __commonJS({
|
|
27585
|
+
"../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/buffer-util.js"(exports, module) {
|
|
27586
|
+
"use strict";
|
|
27587
|
+
var { EMPTY_BUFFER } = require_constants2();
|
|
27588
|
+
var FastBuffer = Buffer[Symbol.species];
|
|
27589
|
+
function concat(list, totalLength) {
|
|
27590
|
+
if (list.length === 0) return EMPTY_BUFFER;
|
|
27591
|
+
if (list.length === 1) return list[0];
|
|
27592
|
+
const target = Buffer.allocUnsafe(totalLength);
|
|
27593
|
+
let offset = 0;
|
|
27594
|
+
for (let i = 0; i < list.length; i++) {
|
|
27595
|
+
const buf = list[i];
|
|
27596
|
+
target.set(buf, offset);
|
|
27597
|
+
offset += buf.length;
|
|
27598
|
+
}
|
|
27599
|
+
if (offset < totalLength) {
|
|
27600
|
+
return new FastBuffer(target.buffer, target.byteOffset, offset);
|
|
27601
|
+
}
|
|
27602
|
+
return target;
|
|
27603
|
+
}
|
|
27604
|
+
__name(concat, "concat");
|
|
27605
|
+
function _mask(source, mask, output, offset, length) {
|
|
27606
|
+
for (let i = 0; i < length; i++) {
|
|
27607
|
+
output[offset + i] = source[i] ^ mask[i & 3];
|
|
27608
|
+
}
|
|
27609
|
+
}
|
|
27610
|
+
__name(_mask, "_mask");
|
|
27611
|
+
function _unmask(buffer2, mask) {
|
|
27612
|
+
for (let i = 0; i < buffer2.length; i++) {
|
|
27613
|
+
buffer2[i] ^= mask[i & 3];
|
|
27614
|
+
}
|
|
27615
|
+
}
|
|
27616
|
+
__name(_unmask, "_unmask");
|
|
27617
|
+
function toArrayBuffer(buf) {
|
|
27618
|
+
if (buf.length === buf.buffer.byteLength) {
|
|
27619
|
+
return buf.buffer;
|
|
27620
|
+
}
|
|
27621
|
+
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.length);
|
|
27622
|
+
}
|
|
27623
|
+
__name(toArrayBuffer, "toArrayBuffer");
|
|
27624
|
+
function toBuffer(data) {
|
|
27625
|
+
toBuffer.readOnly = true;
|
|
27626
|
+
if (Buffer.isBuffer(data)) return data;
|
|
27627
|
+
let buf;
|
|
27628
|
+
if (data instanceof ArrayBuffer) {
|
|
27629
|
+
buf = new FastBuffer(data);
|
|
27630
|
+
} else if (ArrayBuffer.isView(data)) {
|
|
27631
|
+
buf = new FastBuffer(data.buffer, data.byteOffset, data.byteLength);
|
|
27632
|
+
} else {
|
|
27633
|
+
buf = Buffer.from(data);
|
|
27634
|
+
toBuffer.readOnly = false;
|
|
27635
|
+
}
|
|
27636
|
+
return buf;
|
|
27637
|
+
}
|
|
27638
|
+
__name(toBuffer, "toBuffer");
|
|
27639
|
+
module.exports = {
|
|
27640
|
+
concat,
|
|
27641
|
+
mask: _mask,
|
|
27642
|
+
toArrayBuffer,
|
|
27643
|
+
toBuffer,
|
|
27644
|
+
unmask: _unmask
|
|
27645
|
+
};
|
|
27646
|
+
if (!process.env.WS_NO_BUFFER_UTIL) {
|
|
27647
|
+
try {
|
|
27648
|
+
const bufferUtil = __require("bufferutil");
|
|
27649
|
+
module.exports.mask = function(source, mask, output, offset, length) {
|
|
27650
|
+
if (length < 48) _mask(source, mask, output, offset, length);
|
|
27651
|
+
else bufferUtil.mask(source, mask, output, offset, length);
|
|
27652
|
+
};
|
|
27653
|
+
module.exports.unmask = function(buffer2, mask) {
|
|
27654
|
+
if (buffer2.length < 32) _unmask(buffer2, mask);
|
|
27655
|
+
else bufferUtil.unmask(buffer2, mask);
|
|
27656
|
+
};
|
|
27657
|
+
} catch (e) {
|
|
27658
|
+
}
|
|
27659
|
+
}
|
|
27660
|
+
}
|
|
27661
|
+
});
|
|
27662
|
+
|
|
27663
|
+
// ../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/limiter.js
|
|
27664
|
+
var require_limiter = __commonJS({
|
|
27665
|
+
"../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/limiter.js"(exports, module) {
|
|
27666
|
+
"use strict";
|
|
27667
|
+
var kDone = /* @__PURE__ */ Symbol("kDone");
|
|
27668
|
+
var kRun = /* @__PURE__ */ Symbol("kRun");
|
|
27669
|
+
var Limiter = class {
|
|
27670
|
+
static {
|
|
27671
|
+
__name(this, "Limiter");
|
|
27672
|
+
}
|
|
27673
|
+
/**
|
|
27674
|
+
* Creates a new `Limiter`.
|
|
27675
|
+
*
|
|
27676
|
+
* @param {Number} [concurrency=Infinity] The maximum number of jobs allowed
|
|
27677
|
+
* to run concurrently
|
|
27678
|
+
*/
|
|
27679
|
+
constructor(concurrency) {
|
|
27680
|
+
this[kDone] = () => {
|
|
27681
|
+
this.pending--;
|
|
27682
|
+
this[kRun]();
|
|
27683
|
+
};
|
|
27684
|
+
this.concurrency = concurrency || Infinity;
|
|
27685
|
+
this.jobs = [];
|
|
27686
|
+
this.pending = 0;
|
|
27687
|
+
}
|
|
27688
|
+
/**
|
|
27689
|
+
* Adds a job to the queue.
|
|
27690
|
+
*
|
|
27691
|
+
* @param {Function} job The job to run
|
|
27692
|
+
* @public
|
|
27693
|
+
*/
|
|
27694
|
+
add(job) {
|
|
27695
|
+
this.jobs.push(job);
|
|
27696
|
+
this[kRun]();
|
|
27697
|
+
}
|
|
27698
|
+
/**
|
|
27699
|
+
* Removes a job from the queue and runs it if possible.
|
|
27700
|
+
*
|
|
27701
|
+
* @private
|
|
27702
|
+
*/
|
|
27703
|
+
[kRun]() {
|
|
27704
|
+
if (this.pending === this.concurrency) return;
|
|
27705
|
+
if (this.jobs.length) {
|
|
27706
|
+
const job = this.jobs.shift();
|
|
27707
|
+
this.pending++;
|
|
27708
|
+
job(this[kDone]);
|
|
27709
|
+
}
|
|
27710
|
+
}
|
|
27711
|
+
};
|
|
27712
|
+
module.exports = Limiter;
|
|
27713
|
+
}
|
|
27714
|
+
});
|
|
27715
|
+
|
|
27716
|
+
// ../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/permessage-deflate.js
|
|
27717
|
+
var require_permessage_deflate = __commonJS({
|
|
27718
|
+
"../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/permessage-deflate.js"(exports, module) {
|
|
27719
|
+
"use strict";
|
|
27720
|
+
var zlib = __require("zlib");
|
|
27721
|
+
var bufferUtil = require_buffer_util();
|
|
27722
|
+
var Limiter = require_limiter();
|
|
27723
|
+
var { kStatusCode } = require_constants2();
|
|
27724
|
+
var FastBuffer = Buffer[Symbol.species];
|
|
27725
|
+
var TRAILER = Buffer.from([
|
|
27726
|
+
0,
|
|
27727
|
+
0,
|
|
27728
|
+
255,
|
|
27729
|
+
255
|
|
27730
|
+
]);
|
|
27731
|
+
var kPerMessageDeflate = /* @__PURE__ */ Symbol("permessage-deflate");
|
|
27732
|
+
var kTotalLength = /* @__PURE__ */ Symbol("total-length");
|
|
27733
|
+
var kCallback = /* @__PURE__ */ Symbol("callback");
|
|
27734
|
+
var kBuffers = /* @__PURE__ */ Symbol("buffers");
|
|
27735
|
+
var kError = /* @__PURE__ */ Symbol("error");
|
|
27736
|
+
var zlibLimiter;
|
|
27737
|
+
var PerMessageDeflate2 = class {
|
|
27738
|
+
static {
|
|
27739
|
+
__name(this, "PerMessageDeflate");
|
|
27740
|
+
}
|
|
27741
|
+
/**
|
|
27742
|
+
* Creates a PerMessageDeflate instance.
|
|
27743
|
+
*
|
|
27744
|
+
* @param {Object} [options] Configuration options
|
|
27745
|
+
* @param {(Boolean|Number)} [options.clientMaxWindowBits] Advertise support
|
|
27746
|
+
* for, or request, a custom client window size
|
|
27747
|
+
* @param {Boolean} [options.clientNoContextTakeover=false] Advertise/
|
|
27748
|
+
* acknowledge disabling of client context takeover
|
|
27749
|
+
* @param {Number} [options.concurrencyLimit=10] The number of concurrent
|
|
27750
|
+
* calls to zlib
|
|
27751
|
+
* @param {Boolean} [options.isServer=false] Create the instance in either
|
|
27752
|
+
* server or client mode
|
|
27753
|
+
* @param {Number} [options.maxPayload=0] The maximum allowed message length
|
|
27754
|
+
* @param {(Boolean|Number)} [options.serverMaxWindowBits] Request/confirm the
|
|
27755
|
+
* use of a custom server window size
|
|
27756
|
+
* @param {Boolean} [options.serverNoContextTakeover=false] Request/accept
|
|
27757
|
+
* disabling of server context takeover
|
|
27758
|
+
* @param {Number} [options.threshold=1024] Size (in bytes) below which
|
|
27759
|
+
* messages should not be compressed if context takeover is disabled
|
|
27760
|
+
* @param {Object} [options.zlibDeflateOptions] Options to pass to zlib on
|
|
27761
|
+
* deflate
|
|
27762
|
+
* @param {Object} [options.zlibInflateOptions] Options to pass to zlib on
|
|
27763
|
+
* inflate
|
|
27764
|
+
*/
|
|
27765
|
+
constructor(options) {
|
|
27766
|
+
this._options = options || {};
|
|
27767
|
+
this._threshold = this._options.threshold !== void 0 ? this._options.threshold : 1024;
|
|
27768
|
+
this._maxPayload = this._options.maxPayload | 0;
|
|
27769
|
+
this._isServer = !!this._options.isServer;
|
|
27770
|
+
this._deflate = null;
|
|
27771
|
+
this._inflate = null;
|
|
27772
|
+
this.params = null;
|
|
27773
|
+
if (!zlibLimiter) {
|
|
27774
|
+
const concurrency = this._options.concurrencyLimit !== void 0 ? this._options.concurrencyLimit : 10;
|
|
27775
|
+
zlibLimiter = new Limiter(concurrency);
|
|
27776
|
+
}
|
|
27777
|
+
}
|
|
27778
|
+
/**
|
|
27779
|
+
* @type {String}
|
|
27780
|
+
*/
|
|
27781
|
+
static get extensionName() {
|
|
27782
|
+
return "permessage-deflate";
|
|
27783
|
+
}
|
|
27784
|
+
/**
|
|
27785
|
+
* Create an extension negotiation offer.
|
|
27786
|
+
*
|
|
27787
|
+
* @return {Object} Extension parameters
|
|
27788
|
+
* @public
|
|
27789
|
+
*/
|
|
27790
|
+
offer() {
|
|
27791
|
+
const params = {};
|
|
27792
|
+
if (this._options.serverNoContextTakeover) {
|
|
27793
|
+
params.server_no_context_takeover = true;
|
|
27794
|
+
}
|
|
27795
|
+
if (this._options.clientNoContextTakeover) {
|
|
27796
|
+
params.client_no_context_takeover = true;
|
|
27797
|
+
}
|
|
27798
|
+
if (this._options.serverMaxWindowBits) {
|
|
27799
|
+
params.server_max_window_bits = this._options.serverMaxWindowBits;
|
|
27800
|
+
}
|
|
27801
|
+
if (this._options.clientMaxWindowBits) {
|
|
27802
|
+
params.client_max_window_bits = this._options.clientMaxWindowBits;
|
|
27803
|
+
} else if (this._options.clientMaxWindowBits == null) {
|
|
27804
|
+
params.client_max_window_bits = true;
|
|
27805
|
+
}
|
|
27806
|
+
return params;
|
|
27807
|
+
}
|
|
27808
|
+
/**
|
|
27809
|
+
* Accept an extension negotiation offer/response.
|
|
27810
|
+
*
|
|
27811
|
+
* @param {Array} configurations The extension negotiation offers/reponse
|
|
27812
|
+
* @return {Object} Accepted configuration
|
|
27813
|
+
* @public
|
|
27814
|
+
*/
|
|
27815
|
+
accept(configurations) {
|
|
27816
|
+
configurations = this.normalizeParams(configurations);
|
|
27817
|
+
this.params = this._isServer ? this.acceptAsServer(configurations) : this.acceptAsClient(configurations);
|
|
27818
|
+
return this.params;
|
|
27819
|
+
}
|
|
27820
|
+
/**
|
|
27821
|
+
* Releases all resources used by the extension.
|
|
27822
|
+
*
|
|
27823
|
+
* @public
|
|
27824
|
+
*/
|
|
27825
|
+
cleanup() {
|
|
27826
|
+
if (this._inflate) {
|
|
27827
|
+
this._inflate.close();
|
|
27828
|
+
this._inflate = null;
|
|
27829
|
+
}
|
|
27830
|
+
if (this._deflate) {
|
|
27831
|
+
const callback = this._deflate[kCallback];
|
|
27832
|
+
this._deflate.close();
|
|
27833
|
+
this._deflate = null;
|
|
27834
|
+
if (callback) {
|
|
27835
|
+
callback(new Error("The deflate stream was closed while data was being processed"));
|
|
27836
|
+
}
|
|
27837
|
+
}
|
|
27838
|
+
}
|
|
27839
|
+
/**
|
|
27840
|
+
* Accept an extension negotiation offer.
|
|
27841
|
+
*
|
|
27842
|
+
* @param {Array} offers The extension negotiation offers
|
|
27843
|
+
* @return {Object} Accepted configuration
|
|
27844
|
+
* @private
|
|
27845
|
+
*/
|
|
27846
|
+
acceptAsServer(offers) {
|
|
27847
|
+
const opts = this._options;
|
|
27848
|
+
const accepted = offers.find((params) => {
|
|
27849
|
+
if (opts.serverNoContextTakeover === false && params.server_no_context_takeover || params.server_max_window_bits && (opts.serverMaxWindowBits === false || typeof opts.serverMaxWindowBits === "number" && opts.serverMaxWindowBits > params.server_max_window_bits) || typeof opts.clientMaxWindowBits === "number" && !params.client_max_window_bits) {
|
|
27850
|
+
return false;
|
|
27851
|
+
}
|
|
27852
|
+
return true;
|
|
27853
|
+
});
|
|
27854
|
+
if (!accepted) {
|
|
27855
|
+
throw new Error("None of the extension offers can be accepted");
|
|
27856
|
+
}
|
|
27857
|
+
if (opts.serverNoContextTakeover) {
|
|
27858
|
+
accepted.server_no_context_takeover = true;
|
|
27859
|
+
}
|
|
27860
|
+
if (opts.clientNoContextTakeover) {
|
|
27861
|
+
accepted.client_no_context_takeover = true;
|
|
27862
|
+
}
|
|
27863
|
+
if (typeof opts.serverMaxWindowBits === "number") {
|
|
27864
|
+
accepted.server_max_window_bits = opts.serverMaxWindowBits;
|
|
27865
|
+
}
|
|
27866
|
+
if (typeof opts.clientMaxWindowBits === "number") {
|
|
27867
|
+
accepted.client_max_window_bits = opts.clientMaxWindowBits;
|
|
27868
|
+
} else if (accepted.client_max_window_bits === true || opts.clientMaxWindowBits === false) {
|
|
27869
|
+
delete accepted.client_max_window_bits;
|
|
27870
|
+
}
|
|
27871
|
+
return accepted;
|
|
27872
|
+
}
|
|
27873
|
+
/**
|
|
27874
|
+
* Accept the extension negotiation response.
|
|
27875
|
+
*
|
|
27876
|
+
* @param {Array} response The extension negotiation response
|
|
27877
|
+
* @return {Object} Accepted configuration
|
|
27878
|
+
* @private
|
|
27879
|
+
*/
|
|
27880
|
+
acceptAsClient(response) {
|
|
27881
|
+
const params = response[0];
|
|
27882
|
+
if (this._options.clientNoContextTakeover === false && params.client_no_context_takeover) {
|
|
27883
|
+
throw new Error('Unexpected parameter "client_no_context_takeover"');
|
|
27884
|
+
}
|
|
27885
|
+
if (!params.client_max_window_bits) {
|
|
27886
|
+
if (typeof this._options.clientMaxWindowBits === "number") {
|
|
27887
|
+
params.client_max_window_bits = this._options.clientMaxWindowBits;
|
|
27888
|
+
}
|
|
27889
|
+
} else if (this._options.clientMaxWindowBits === false || typeof this._options.clientMaxWindowBits === "number" && params.client_max_window_bits > this._options.clientMaxWindowBits) {
|
|
27890
|
+
throw new Error('Unexpected or invalid parameter "client_max_window_bits"');
|
|
27891
|
+
}
|
|
27892
|
+
return params;
|
|
27893
|
+
}
|
|
27894
|
+
/**
|
|
27895
|
+
* Normalize parameters.
|
|
27896
|
+
*
|
|
27897
|
+
* @param {Array} configurations The extension negotiation offers/reponse
|
|
27898
|
+
* @return {Array} The offers/response with normalized parameters
|
|
27899
|
+
* @private
|
|
27900
|
+
*/
|
|
27901
|
+
normalizeParams(configurations) {
|
|
27902
|
+
configurations.forEach((params) => {
|
|
27903
|
+
Object.keys(params).forEach((key) => {
|
|
27904
|
+
let value = params[key];
|
|
27905
|
+
if (value.length > 1) {
|
|
27906
|
+
throw new Error(`Parameter "${key}" must have only a single value`);
|
|
27907
|
+
}
|
|
27908
|
+
value = value[0];
|
|
27909
|
+
if (key === "client_max_window_bits") {
|
|
27910
|
+
if (value !== true) {
|
|
27911
|
+
const num = +value;
|
|
27912
|
+
if (!Number.isInteger(num) || num < 8 || num > 15) {
|
|
27913
|
+
throw new TypeError(`Invalid value for parameter "${key}": ${value}`);
|
|
27914
|
+
}
|
|
27915
|
+
value = num;
|
|
27916
|
+
} else if (!this._isServer) {
|
|
27917
|
+
throw new TypeError(`Invalid value for parameter "${key}": ${value}`);
|
|
27918
|
+
}
|
|
27919
|
+
} else if (key === "server_max_window_bits") {
|
|
27920
|
+
const num = +value;
|
|
27921
|
+
if (!Number.isInteger(num) || num < 8 || num > 15) {
|
|
27922
|
+
throw new TypeError(`Invalid value for parameter "${key}": ${value}`);
|
|
27923
|
+
}
|
|
27924
|
+
value = num;
|
|
27925
|
+
} else if (key === "client_no_context_takeover" || key === "server_no_context_takeover") {
|
|
27926
|
+
if (value !== true) {
|
|
27927
|
+
throw new TypeError(`Invalid value for parameter "${key}": ${value}`);
|
|
27928
|
+
}
|
|
27929
|
+
} else {
|
|
27930
|
+
throw new Error(`Unknown parameter "${key}"`);
|
|
27931
|
+
}
|
|
27932
|
+
params[key] = value;
|
|
27933
|
+
});
|
|
27934
|
+
});
|
|
27935
|
+
return configurations;
|
|
27936
|
+
}
|
|
27937
|
+
/**
|
|
27938
|
+
* Decompress data. Concurrency limited.
|
|
27939
|
+
*
|
|
27940
|
+
* @param {Buffer} data Compressed data
|
|
27941
|
+
* @param {Boolean} fin Specifies whether or not this is the last fragment
|
|
27942
|
+
* @param {Function} callback Callback
|
|
27943
|
+
* @public
|
|
27944
|
+
*/
|
|
27945
|
+
decompress(data, fin, callback) {
|
|
27946
|
+
zlibLimiter.add((done) => {
|
|
27947
|
+
this._decompress(data, fin, (err, result) => {
|
|
27948
|
+
done();
|
|
27949
|
+
callback(err, result);
|
|
27950
|
+
});
|
|
27951
|
+
});
|
|
27952
|
+
}
|
|
27953
|
+
/**
|
|
27954
|
+
* Compress data. Concurrency limited.
|
|
27955
|
+
*
|
|
27956
|
+
* @param {(Buffer|String)} data Data to compress
|
|
27957
|
+
* @param {Boolean} fin Specifies whether or not this is the last fragment
|
|
27958
|
+
* @param {Function} callback Callback
|
|
27959
|
+
* @public
|
|
27960
|
+
*/
|
|
27961
|
+
compress(data, fin, callback) {
|
|
27962
|
+
zlibLimiter.add((done) => {
|
|
27963
|
+
this._compress(data, fin, (err, result) => {
|
|
27964
|
+
done();
|
|
27965
|
+
callback(err, result);
|
|
27966
|
+
});
|
|
27967
|
+
});
|
|
27968
|
+
}
|
|
27969
|
+
/**
|
|
27970
|
+
* Decompress data.
|
|
27971
|
+
*
|
|
27972
|
+
* @param {Buffer} data Compressed data
|
|
27973
|
+
* @param {Boolean} fin Specifies whether or not this is the last fragment
|
|
27974
|
+
* @param {Function} callback Callback
|
|
27975
|
+
* @private
|
|
27976
|
+
*/
|
|
27977
|
+
_decompress(data, fin, callback) {
|
|
27978
|
+
const endpoint = this._isServer ? "client" : "server";
|
|
27979
|
+
if (!this._inflate) {
|
|
27980
|
+
const key = `${endpoint}_max_window_bits`;
|
|
27981
|
+
const windowBits = typeof this.params[key] !== "number" ? zlib.Z_DEFAULT_WINDOWBITS : this.params[key];
|
|
27982
|
+
this._inflate = zlib.createInflateRaw({
|
|
27983
|
+
...this._options.zlibInflateOptions,
|
|
27984
|
+
windowBits
|
|
27985
|
+
});
|
|
27986
|
+
this._inflate[kPerMessageDeflate] = this;
|
|
27987
|
+
this._inflate[kTotalLength] = 0;
|
|
27988
|
+
this._inflate[kBuffers] = [];
|
|
27989
|
+
this._inflate.on("error", inflateOnError);
|
|
27990
|
+
this._inflate.on("data", inflateOnData);
|
|
27991
|
+
}
|
|
27992
|
+
this._inflate[kCallback] = callback;
|
|
27993
|
+
this._inflate.write(data);
|
|
27994
|
+
if (fin) this._inflate.write(TRAILER);
|
|
27995
|
+
this._inflate.flush(() => {
|
|
27996
|
+
const err = this._inflate[kError];
|
|
27997
|
+
if (err) {
|
|
27998
|
+
this._inflate.close();
|
|
27999
|
+
this._inflate = null;
|
|
28000
|
+
callback(err);
|
|
28001
|
+
return;
|
|
28002
|
+
}
|
|
28003
|
+
const data2 = bufferUtil.concat(this._inflate[kBuffers], this._inflate[kTotalLength]);
|
|
28004
|
+
if (this._inflate._readableState.endEmitted) {
|
|
28005
|
+
this._inflate.close();
|
|
28006
|
+
this._inflate = null;
|
|
28007
|
+
} else {
|
|
28008
|
+
this._inflate[kTotalLength] = 0;
|
|
28009
|
+
this._inflate[kBuffers] = [];
|
|
28010
|
+
if (fin && this.params[`${endpoint}_no_context_takeover`]) {
|
|
28011
|
+
this._inflate.reset();
|
|
28012
|
+
}
|
|
28013
|
+
}
|
|
28014
|
+
callback(null, data2);
|
|
28015
|
+
});
|
|
28016
|
+
}
|
|
28017
|
+
/**
|
|
28018
|
+
* Compress data.
|
|
28019
|
+
*
|
|
28020
|
+
* @param {(Buffer|String)} data Data to compress
|
|
28021
|
+
* @param {Boolean} fin Specifies whether or not this is the last fragment
|
|
28022
|
+
* @param {Function} callback Callback
|
|
28023
|
+
* @private
|
|
28024
|
+
*/
|
|
28025
|
+
_compress(data, fin, callback) {
|
|
28026
|
+
const endpoint = this._isServer ? "server" : "client";
|
|
28027
|
+
if (!this._deflate) {
|
|
28028
|
+
const key = `${endpoint}_max_window_bits`;
|
|
28029
|
+
const windowBits = typeof this.params[key] !== "number" ? zlib.Z_DEFAULT_WINDOWBITS : this.params[key];
|
|
28030
|
+
this._deflate = zlib.createDeflateRaw({
|
|
28031
|
+
...this._options.zlibDeflateOptions,
|
|
28032
|
+
windowBits
|
|
28033
|
+
});
|
|
28034
|
+
this._deflate[kTotalLength] = 0;
|
|
28035
|
+
this._deflate[kBuffers] = [];
|
|
28036
|
+
this._deflate.on("data", deflateOnData);
|
|
28037
|
+
}
|
|
28038
|
+
this._deflate[kCallback] = callback;
|
|
28039
|
+
this._deflate.write(data);
|
|
28040
|
+
this._deflate.flush(zlib.Z_SYNC_FLUSH, () => {
|
|
28041
|
+
if (!this._deflate) {
|
|
28042
|
+
return;
|
|
28043
|
+
}
|
|
28044
|
+
let data2 = bufferUtil.concat(this._deflate[kBuffers], this._deflate[kTotalLength]);
|
|
28045
|
+
if (fin) {
|
|
28046
|
+
data2 = new FastBuffer(data2.buffer, data2.byteOffset, data2.length - 4);
|
|
28047
|
+
}
|
|
28048
|
+
this._deflate[kCallback] = null;
|
|
28049
|
+
this._deflate[kTotalLength] = 0;
|
|
28050
|
+
this._deflate[kBuffers] = [];
|
|
28051
|
+
if (fin && this.params[`${endpoint}_no_context_takeover`]) {
|
|
28052
|
+
this._deflate.reset();
|
|
28053
|
+
}
|
|
28054
|
+
callback(null, data2);
|
|
28055
|
+
});
|
|
28056
|
+
}
|
|
28057
|
+
};
|
|
28058
|
+
module.exports = PerMessageDeflate2;
|
|
28059
|
+
function deflateOnData(chunk) {
|
|
28060
|
+
this[kBuffers].push(chunk);
|
|
28061
|
+
this[kTotalLength] += chunk.length;
|
|
28062
|
+
}
|
|
28063
|
+
__name(deflateOnData, "deflateOnData");
|
|
28064
|
+
function inflateOnData(chunk) {
|
|
28065
|
+
this[kTotalLength] += chunk.length;
|
|
28066
|
+
if (this[kPerMessageDeflate]._maxPayload < 1 || this[kTotalLength] <= this[kPerMessageDeflate]._maxPayload) {
|
|
28067
|
+
this[kBuffers].push(chunk);
|
|
28068
|
+
return;
|
|
28069
|
+
}
|
|
28070
|
+
this[kError] = new RangeError("Max payload size exceeded");
|
|
28071
|
+
this[kError].code = "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH";
|
|
28072
|
+
this[kError][kStatusCode] = 1009;
|
|
28073
|
+
this.removeListener("data", inflateOnData);
|
|
28074
|
+
this.reset();
|
|
28075
|
+
}
|
|
28076
|
+
__name(inflateOnData, "inflateOnData");
|
|
28077
|
+
function inflateOnError(err) {
|
|
28078
|
+
this[kPerMessageDeflate]._inflate = null;
|
|
28079
|
+
if (this[kError]) {
|
|
28080
|
+
this[kCallback](this[kError]);
|
|
28081
|
+
return;
|
|
28082
|
+
}
|
|
28083
|
+
err[kStatusCode] = 1007;
|
|
28084
|
+
this[kCallback](err);
|
|
28085
|
+
}
|
|
28086
|
+
__name(inflateOnError, "inflateOnError");
|
|
28087
|
+
}
|
|
28088
|
+
});
|
|
28089
|
+
|
|
28090
|
+
// ../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/receiver.js
|
|
28091
|
+
var require_receiver = __commonJS({
|
|
28092
|
+
"../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/receiver.js"(exports, module) {
|
|
28093
|
+
"use strict";
|
|
28094
|
+
var { Writable } = __require("stream");
|
|
28095
|
+
var PerMessageDeflate2 = require_permessage_deflate();
|
|
28096
|
+
var { BINARY_TYPES, EMPTY_BUFFER, kStatusCode, kWebSocket } = require_constants2();
|
|
28097
|
+
var { concat, toArrayBuffer, unmask } = require_buffer_util();
|
|
28098
|
+
var { isValidStatusCode, isValidUTF8 } = require_validation();
|
|
28099
|
+
var FastBuffer = Buffer[Symbol.species];
|
|
28100
|
+
var GET_INFO = 0;
|
|
28101
|
+
var GET_PAYLOAD_LENGTH_16 = 1;
|
|
28102
|
+
var GET_PAYLOAD_LENGTH_64 = 2;
|
|
28103
|
+
var GET_MASK = 3;
|
|
28104
|
+
var GET_DATA = 4;
|
|
28105
|
+
var INFLATING = 5;
|
|
28106
|
+
var DEFER_EVENT = 6;
|
|
28107
|
+
var Receiver2 = class extends Writable {
|
|
28108
|
+
static {
|
|
28109
|
+
__name(this, "Receiver");
|
|
28110
|
+
}
|
|
28111
|
+
/**
|
|
28112
|
+
* Creates a Receiver instance.
|
|
28113
|
+
*
|
|
28114
|
+
* @param {Object} [options] Options object
|
|
28115
|
+
* @param {Boolean} [options.allowSynchronousEvents=true] Specifies whether
|
|
28116
|
+
* any of the `'message'`, `'ping'`, and `'pong'` events can be emitted
|
|
28117
|
+
* multiple times in the same tick
|
|
28118
|
+
* @param {String} [options.binaryType=nodebuffer] The type for binary data
|
|
28119
|
+
* @param {Object} [options.extensions] An object containing the negotiated
|
|
28120
|
+
* extensions
|
|
28121
|
+
* @param {Boolean} [options.isServer=false] Specifies whether to operate in
|
|
28122
|
+
* client or server mode
|
|
28123
|
+
* @param {Number} [options.maxPayload=0] The maximum allowed message length
|
|
28124
|
+
* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
|
|
28125
|
+
* not to skip UTF-8 validation for text and close messages
|
|
28126
|
+
*/
|
|
28127
|
+
constructor(options = {}) {
|
|
28128
|
+
super();
|
|
28129
|
+
this._allowSynchronousEvents = options.allowSynchronousEvents !== void 0 ? options.allowSynchronousEvents : true;
|
|
28130
|
+
this._binaryType = options.binaryType || BINARY_TYPES[0];
|
|
28131
|
+
this._extensions = options.extensions || {};
|
|
28132
|
+
this._isServer = !!options.isServer;
|
|
28133
|
+
this._maxPayload = options.maxPayload | 0;
|
|
28134
|
+
this._skipUTF8Validation = !!options.skipUTF8Validation;
|
|
28135
|
+
this[kWebSocket] = void 0;
|
|
28136
|
+
this._bufferedBytes = 0;
|
|
28137
|
+
this._buffers = [];
|
|
28138
|
+
this._compressed = false;
|
|
28139
|
+
this._payloadLength = 0;
|
|
28140
|
+
this._mask = void 0;
|
|
28141
|
+
this._fragmented = 0;
|
|
28142
|
+
this._masked = false;
|
|
28143
|
+
this._fin = false;
|
|
28144
|
+
this._opcode = 0;
|
|
28145
|
+
this._totalPayloadLength = 0;
|
|
28146
|
+
this._messageLength = 0;
|
|
28147
|
+
this._fragments = [];
|
|
28148
|
+
this._errored = false;
|
|
28149
|
+
this._loop = false;
|
|
28150
|
+
this._state = GET_INFO;
|
|
28151
|
+
}
|
|
28152
|
+
/**
|
|
28153
|
+
* Implements `Writable.prototype._write()`.
|
|
28154
|
+
*
|
|
28155
|
+
* @param {Buffer} chunk The chunk of data to write
|
|
28156
|
+
* @param {String} encoding The character encoding of `chunk`
|
|
28157
|
+
* @param {Function} cb Callback
|
|
28158
|
+
* @private
|
|
28159
|
+
*/
|
|
28160
|
+
_write(chunk, encoding, cb) {
|
|
28161
|
+
if (this._opcode === 8 && this._state == GET_INFO) return cb();
|
|
28162
|
+
this._bufferedBytes += chunk.length;
|
|
28163
|
+
this._buffers.push(chunk);
|
|
28164
|
+
this.startLoop(cb);
|
|
28165
|
+
}
|
|
28166
|
+
/**
|
|
28167
|
+
* Consumes `n` bytes from the buffered data.
|
|
28168
|
+
*
|
|
28169
|
+
* @param {Number} n The number of bytes to consume
|
|
28170
|
+
* @return {Buffer} The consumed bytes
|
|
28171
|
+
* @private
|
|
28172
|
+
*/
|
|
28173
|
+
consume(n) {
|
|
28174
|
+
this._bufferedBytes -= n;
|
|
28175
|
+
if (n === this._buffers[0].length) return this._buffers.shift();
|
|
28176
|
+
if (n < this._buffers[0].length) {
|
|
28177
|
+
const buf = this._buffers[0];
|
|
28178
|
+
this._buffers[0] = new FastBuffer(buf.buffer, buf.byteOffset + n, buf.length - n);
|
|
28179
|
+
return new FastBuffer(buf.buffer, buf.byteOffset, n);
|
|
28180
|
+
}
|
|
28181
|
+
const dst = Buffer.allocUnsafe(n);
|
|
28182
|
+
do {
|
|
28183
|
+
const buf = this._buffers[0];
|
|
28184
|
+
const offset = dst.length - n;
|
|
28185
|
+
if (n >= buf.length) {
|
|
28186
|
+
dst.set(this._buffers.shift(), offset);
|
|
28187
|
+
} else {
|
|
28188
|
+
dst.set(new Uint8Array(buf.buffer, buf.byteOffset, n), offset);
|
|
28189
|
+
this._buffers[0] = new FastBuffer(buf.buffer, buf.byteOffset + n, buf.length - n);
|
|
28190
|
+
}
|
|
28191
|
+
n -= buf.length;
|
|
28192
|
+
} while (n > 0);
|
|
28193
|
+
return dst;
|
|
28194
|
+
}
|
|
28195
|
+
/**
|
|
28196
|
+
* Starts the parsing loop.
|
|
28197
|
+
*
|
|
28198
|
+
* @param {Function} cb Callback
|
|
28199
|
+
* @private
|
|
28200
|
+
*/
|
|
28201
|
+
startLoop(cb) {
|
|
28202
|
+
this._loop = true;
|
|
28203
|
+
do {
|
|
28204
|
+
switch (this._state) {
|
|
28205
|
+
case GET_INFO:
|
|
28206
|
+
this.getInfo(cb);
|
|
28207
|
+
break;
|
|
28208
|
+
case GET_PAYLOAD_LENGTH_16:
|
|
28209
|
+
this.getPayloadLength16(cb);
|
|
28210
|
+
break;
|
|
28211
|
+
case GET_PAYLOAD_LENGTH_64:
|
|
28212
|
+
this.getPayloadLength64(cb);
|
|
28213
|
+
break;
|
|
28214
|
+
case GET_MASK:
|
|
28215
|
+
this.getMask();
|
|
28216
|
+
break;
|
|
28217
|
+
case GET_DATA:
|
|
28218
|
+
this.getData(cb);
|
|
28219
|
+
break;
|
|
28220
|
+
case INFLATING:
|
|
28221
|
+
case DEFER_EVENT:
|
|
28222
|
+
this._loop = false;
|
|
28223
|
+
return;
|
|
28224
|
+
}
|
|
28225
|
+
} while (this._loop);
|
|
28226
|
+
if (!this._errored) cb();
|
|
28227
|
+
}
|
|
28228
|
+
/**
|
|
28229
|
+
* Reads the first two bytes of a frame.
|
|
28230
|
+
*
|
|
28231
|
+
* @param {Function} cb Callback
|
|
28232
|
+
* @private
|
|
28233
|
+
*/
|
|
28234
|
+
getInfo(cb) {
|
|
28235
|
+
if (this._bufferedBytes < 2) {
|
|
28236
|
+
this._loop = false;
|
|
28237
|
+
return;
|
|
28238
|
+
}
|
|
28239
|
+
const buf = this.consume(2);
|
|
28240
|
+
if ((buf[0] & 48) !== 0) {
|
|
28241
|
+
const error48 = this.createError(RangeError, "RSV2 and RSV3 must be clear", true, 1002, "WS_ERR_UNEXPECTED_RSV_2_3");
|
|
28242
|
+
cb(error48);
|
|
28243
|
+
return;
|
|
28244
|
+
}
|
|
28245
|
+
const compressed = (buf[0] & 64) === 64;
|
|
28246
|
+
if (compressed && !this._extensions[PerMessageDeflate2.extensionName]) {
|
|
28247
|
+
const error48 = this.createError(RangeError, "RSV1 must be clear", true, 1002, "WS_ERR_UNEXPECTED_RSV_1");
|
|
28248
|
+
cb(error48);
|
|
28249
|
+
return;
|
|
28250
|
+
}
|
|
28251
|
+
this._fin = (buf[0] & 128) === 128;
|
|
28252
|
+
this._opcode = buf[0] & 15;
|
|
28253
|
+
this._payloadLength = buf[1] & 127;
|
|
28254
|
+
if (this._opcode === 0) {
|
|
28255
|
+
if (compressed) {
|
|
28256
|
+
const error48 = this.createError(RangeError, "RSV1 must be clear", true, 1002, "WS_ERR_UNEXPECTED_RSV_1");
|
|
28257
|
+
cb(error48);
|
|
28258
|
+
return;
|
|
28259
|
+
}
|
|
28260
|
+
if (!this._fragmented) {
|
|
28261
|
+
const error48 = this.createError(RangeError, "invalid opcode 0", true, 1002, "WS_ERR_INVALID_OPCODE");
|
|
28262
|
+
cb(error48);
|
|
28263
|
+
return;
|
|
28264
|
+
}
|
|
28265
|
+
this._opcode = this._fragmented;
|
|
28266
|
+
} else if (this._opcode === 1 || this._opcode === 2) {
|
|
28267
|
+
if (this._fragmented) {
|
|
28268
|
+
const error48 = this.createError(RangeError, `invalid opcode ${this._opcode}`, true, 1002, "WS_ERR_INVALID_OPCODE");
|
|
28269
|
+
cb(error48);
|
|
28270
|
+
return;
|
|
28271
|
+
}
|
|
28272
|
+
this._compressed = compressed;
|
|
28273
|
+
} else if (this._opcode > 7 && this._opcode < 11) {
|
|
28274
|
+
if (!this._fin) {
|
|
28275
|
+
const error48 = this.createError(RangeError, "FIN must be set", true, 1002, "WS_ERR_EXPECTED_FIN");
|
|
28276
|
+
cb(error48);
|
|
28277
|
+
return;
|
|
28278
|
+
}
|
|
28279
|
+
if (compressed) {
|
|
28280
|
+
const error48 = this.createError(RangeError, "RSV1 must be clear", true, 1002, "WS_ERR_UNEXPECTED_RSV_1");
|
|
28281
|
+
cb(error48);
|
|
28282
|
+
return;
|
|
28283
|
+
}
|
|
28284
|
+
if (this._payloadLength > 125 || this._opcode === 8 && this._payloadLength === 1) {
|
|
28285
|
+
const error48 = this.createError(RangeError, `invalid payload length ${this._payloadLength}`, true, 1002, "WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");
|
|
28286
|
+
cb(error48);
|
|
28287
|
+
return;
|
|
28288
|
+
}
|
|
28289
|
+
} else {
|
|
28290
|
+
const error48 = this.createError(RangeError, `invalid opcode ${this._opcode}`, true, 1002, "WS_ERR_INVALID_OPCODE");
|
|
28291
|
+
cb(error48);
|
|
28292
|
+
return;
|
|
28293
|
+
}
|
|
28294
|
+
if (!this._fin && !this._fragmented) this._fragmented = this._opcode;
|
|
28295
|
+
this._masked = (buf[1] & 128) === 128;
|
|
28296
|
+
if (this._isServer) {
|
|
28297
|
+
if (!this._masked) {
|
|
28298
|
+
const error48 = this.createError(RangeError, "MASK must be set", true, 1002, "WS_ERR_EXPECTED_MASK");
|
|
28299
|
+
cb(error48);
|
|
28300
|
+
return;
|
|
28301
|
+
}
|
|
28302
|
+
} else if (this._masked) {
|
|
28303
|
+
const error48 = this.createError(RangeError, "MASK must be clear", true, 1002, "WS_ERR_UNEXPECTED_MASK");
|
|
28304
|
+
cb(error48);
|
|
28305
|
+
return;
|
|
28306
|
+
}
|
|
28307
|
+
if (this._payloadLength === 126) this._state = GET_PAYLOAD_LENGTH_16;
|
|
28308
|
+
else if (this._payloadLength === 127) this._state = GET_PAYLOAD_LENGTH_64;
|
|
28309
|
+
else this.haveLength(cb);
|
|
28310
|
+
}
|
|
28311
|
+
/**
|
|
28312
|
+
* Gets extended payload length (7+16).
|
|
28313
|
+
*
|
|
28314
|
+
* @param {Function} cb Callback
|
|
28315
|
+
* @private
|
|
28316
|
+
*/
|
|
28317
|
+
getPayloadLength16(cb) {
|
|
28318
|
+
if (this._bufferedBytes < 2) {
|
|
28319
|
+
this._loop = false;
|
|
28320
|
+
return;
|
|
28321
|
+
}
|
|
28322
|
+
this._payloadLength = this.consume(2).readUInt16BE(0);
|
|
28323
|
+
this.haveLength(cb);
|
|
28324
|
+
}
|
|
28325
|
+
/**
|
|
28326
|
+
* Gets extended payload length (7+64).
|
|
28327
|
+
*
|
|
28328
|
+
* @param {Function} cb Callback
|
|
28329
|
+
* @private
|
|
28330
|
+
*/
|
|
28331
|
+
getPayloadLength64(cb) {
|
|
28332
|
+
if (this._bufferedBytes < 8) {
|
|
28333
|
+
this._loop = false;
|
|
28334
|
+
return;
|
|
28335
|
+
}
|
|
28336
|
+
const buf = this.consume(8);
|
|
28337
|
+
const num = buf.readUInt32BE(0);
|
|
28338
|
+
if (num > Math.pow(2, 53 - 32) - 1) {
|
|
28339
|
+
const error48 = this.createError(RangeError, "Unsupported WebSocket frame: payload length > 2^53 - 1", false, 1009, "WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");
|
|
28340
|
+
cb(error48);
|
|
28341
|
+
return;
|
|
28342
|
+
}
|
|
28343
|
+
this._payloadLength = num * Math.pow(2, 32) + buf.readUInt32BE(4);
|
|
28344
|
+
this.haveLength(cb);
|
|
28345
|
+
}
|
|
28346
|
+
/**
|
|
28347
|
+
* Payload length has been read.
|
|
28348
|
+
*
|
|
28349
|
+
* @param {Function} cb Callback
|
|
28350
|
+
* @private
|
|
28351
|
+
*/
|
|
28352
|
+
haveLength(cb) {
|
|
28353
|
+
if (this._payloadLength && this._opcode < 8) {
|
|
28354
|
+
this._totalPayloadLength += this._payloadLength;
|
|
28355
|
+
if (this._totalPayloadLength > this._maxPayload && this._maxPayload > 0) {
|
|
28356
|
+
const error48 = this.createError(RangeError, "Max payload size exceeded", false, 1009, "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");
|
|
28357
|
+
cb(error48);
|
|
28358
|
+
return;
|
|
28359
|
+
}
|
|
28360
|
+
}
|
|
28361
|
+
if (this._masked) this._state = GET_MASK;
|
|
28362
|
+
else this._state = GET_DATA;
|
|
28363
|
+
}
|
|
28364
|
+
/**
|
|
28365
|
+
* Reads mask bytes.
|
|
28366
|
+
*
|
|
28367
|
+
* @private
|
|
28368
|
+
*/
|
|
28369
|
+
getMask() {
|
|
28370
|
+
if (this._bufferedBytes < 4) {
|
|
28371
|
+
this._loop = false;
|
|
28372
|
+
return;
|
|
28373
|
+
}
|
|
28374
|
+
this._mask = this.consume(4);
|
|
28375
|
+
this._state = GET_DATA;
|
|
28376
|
+
}
|
|
28377
|
+
/**
|
|
28378
|
+
* Reads data bytes.
|
|
28379
|
+
*
|
|
28380
|
+
* @param {Function} cb Callback
|
|
28381
|
+
* @private
|
|
28382
|
+
*/
|
|
28383
|
+
getData(cb) {
|
|
28384
|
+
let data = EMPTY_BUFFER;
|
|
28385
|
+
if (this._payloadLength) {
|
|
28386
|
+
if (this._bufferedBytes < this._payloadLength) {
|
|
28387
|
+
this._loop = false;
|
|
28388
|
+
return;
|
|
28389
|
+
}
|
|
28390
|
+
data = this.consume(this._payloadLength);
|
|
28391
|
+
if (this._masked && (this._mask[0] | this._mask[1] | this._mask[2] | this._mask[3]) !== 0) {
|
|
28392
|
+
unmask(data, this._mask);
|
|
28393
|
+
}
|
|
28394
|
+
}
|
|
28395
|
+
if (this._opcode > 7) {
|
|
28396
|
+
this.controlMessage(data, cb);
|
|
28397
|
+
return;
|
|
28398
|
+
}
|
|
28399
|
+
if (this._compressed) {
|
|
28400
|
+
this._state = INFLATING;
|
|
28401
|
+
this.decompress(data, cb);
|
|
28402
|
+
return;
|
|
28403
|
+
}
|
|
28404
|
+
if (data.length) {
|
|
28405
|
+
this._messageLength = this._totalPayloadLength;
|
|
28406
|
+
this._fragments.push(data);
|
|
28407
|
+
}
|
|
28408
|
+
this.dataMessage(cb);
|
|
28409
|
+
}
|
|
28410
|
+
/**
|
|
28411
|
+
* Decompresses data.
|
|
28412
|
+
*
|
|
28413
|
+
* @param {Buffer} data Compressed data
|
|
28414
|
+
* @param {Function} cb Callback
|
|
28415
|
+
* @private
|
|
28416
|
+
*/
|
|
28417
|
+
decompress(data, cb) {
|
|
28418
|
+
const perMessageDeflate = this._extensions[PerMessageDeflate2.extensionName];
|
|
28419
|
+
perMessageDeflate.decompress(data, this._fin, (err, buf) => {
|
|
28420
|
+
if (err) return cb(err);
|
|
28421
|
+
if (buf.length) {
|
|
28422
|
+
this._messageLength += buf.length;
|
|
28423
|
+
if (this._messageLength > this._maxPayload && this._maxPayload > 0) {
|
|
28424
|
+
const error48 = this.createError(RangeError, "Max payload size exceeded", false, 1009, "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");
|
|
28425
|
+
cb(error48);
|
|
28426
|
+
return;
|
|
28427
|
+
}
|
|
28428
|
+
this._fragments.push(buf);
|
|
28429
|
+
}
|
|
28430
|
+
this.dataMessage(cb);
|
|
28431
|
+
if (this._state === GET_INFO) this.startLoop(cb);
|
|
28432
|
+
});
|
|
28433
|
+
}
|
|
28434
|
+
/**
|
|
28435
|
+
* Handles a data message.
|
|
28436
|
+
*
|
|
28437
|
+
* @param {Function} cb Callback
|
|
28438
|
+
* @private
|
|
28439
|
+
*/
|
|
28440
|
+
dataMessage(cb) {
|
|
28441
|
+
if (!this._fin) {
|
|
28442
|
+
this._state = GET_INFO;
|
|
28443
|
+
return;
|
|
28444
|
+
}
|
|
28445
|
+
const messageLength = this._messageLength;
|
|
28446
|
+
const fragments = this._fragments;
|
|
28447
|
+
this._totalPayloadLength = 0;
|
|
28448
|
+
this._messageLength = 0;
|
|
28449
|
+
this._fragmented = 0;
|
|
28450
|
+
this._fragments = [];
|
|
28451
|
+
if (this._opcode === 2) {
|
|
28452
|
+
let data;
|
|
28453
|
+
if (this._binaryType === "nodebuffer") {
|
|
28454
|
+
data = concat(fragments, messageLength);
|
|
28455
|
+
} else if (this._binaryType === "arraybuffer") {
|
|
28456
|
+
data = toArrayBuffer(concat(fragments, messageLength));
|
|
28457
|
+
} else if (this._binaryType === "blob") {
|
|
28458
|
+
data = new Blob(fragments);
|
|
28459
|
+
} else {
|
|
28460
|
+
data = fragments;
|
|
28461
|
+
}
|
|
28462
|
+
if (this._allowSynchronousEvents) {
|
|
28463
|
+
this.emit("message", data, true);
|
|
28464
|
+
this._state = GET_INFO;
|
|
28465
|
+
} else {
|
|
28466
|
+
this._state = DEFER_EVENT;
|
|
28467
|
+
setImmediate(() => {
|
|
28468
|
+
this.emit("message", data, true);
|
|
28469
|
+
this._state = GET_INFO;
|
|
28470
|
+
this.startLoop(cb);
|
|
28471
|
+
});
|
|
28472
|
+
}
|
|
28473
|
+
} else {
|
|
28474
|
+
const buf = concat(fragments, messageLength);
|
|
28475
|
+
if (!this._skipUTF8Validation && !isValidUTF8(buf)) {
|
|
28476
|
+
const error48 = this.createError(Error, "invalid UTF-8 sequence", true, 1007, "WS_ERR_INVALID_UTF8");
|
|
28477
|
+
cb(error48);
|
|
28478
|
+
return;
|
|
28479
|
+
}
|
|
28480
|
+
if (this._state === INFLATING || this._allowSynchronousEvents) {
|
|
28481
|
+
this.emit("message", buf, false);
|
|
28482
|
+
this._state = GET_INFO;
|
|
28483
|
+
} else {
|
|
28484
|
+
this._state = DEFER_EVENT;
|
|
28485
|
+
setImmediate(() => {
|
|
28486
|
+
this.emit("message", buf, false);
|
|
28487
|
+
this._state = GET_INFO;
|
|
28488
|
+
this.startLoop(cb);
|
|
28489
|
+
});
|
|
28490
|
+
}
|
|
28491
|
+
}
|
|
28492
|
+
}
|
|
28493
|
+
/**
|
|
28494
|
+
* Handles a control message.
|
|
28495
|
+
*
|
|
28496
|
+
* @param {Buffer} data Data to handle
|
|
28497
|
+
* @return {(Error|RangeError|undefined)} A possible error
|
|
28498
|
+
* @private
|
|
28499
|
+
*/
|
|
28500
|
+
controlMessage(data, cb) {
|
|
28501
|
+
if (this._opcode === 8) {
|
|
28502
|
+
if (data.length === 0) {
|
|
28503
|
+
this._loop = false;
|
|
28504
|
+
this.emit("conclude", 1005, EMPTY_BUFFER);
|
|
28505
|
+
this.end();
|
|
28506
|
+
} else {
|
|
28507
|
+
const code2 = data.readUInt16BE(0);
|
|
28508
|
+
if (!isValidStatusCode(code2)) {
|
|
28509
|
+
const error48 = this.createError(RangeError, `invalid status code ${code2}`, true, 1002, "WS_ERR_INVALID_CLOSE_CODE");
|
|
28510
|
+
cb(error48);
|
|
28511
|
+
return;
|
|
28512
|
+
}
|
|
28513
|
+
const buf = new FastBuffer(data.buffer, data.byteOffset + 2, data.length - 2);
|
|
28514
|
+
if (!this._skipUTF8Validation && !isValidUTF8(buf)) {
|
|
28515
|
+
const error48 = this.createError(Error, "invalid UTF-8 sequence", true, 1007, "WS_ERR_INVALID_UTF8");
|
|
28516
|
+
cb(error48);
|
|
28517
|
+
return;
|
|
28518
|
+
}
|
|
28519
|
+
this._loop = false;
|
|
28520
|
+
this.emit("conclude", code2, buf);
|
|
28521
|
+
this.end();
|
|
28522
|
+
}
|
|
28523
|
+
this._state = GET_INFO;
|
|
28524
|
+
return;
|
|
28525
|
+
}
|
|
28526
|
+
if (this._allowSynchronousEvents) {
|
|
28527
|
+
this.emit(this._opcode === 9 ? "ping" : "pong", data);
|
|
28528
|
+
this._state = GET_INFO;
|
|
28529
|
+
} else {
|
|
28530
|
+
this._state = DEFER_EVENT;
|
|
28531
|
+
setImmediate(() => {
|
|
28532
|
+
this.emit(this._opcode === 9 ? "ping" : "pong", data);
|
|
28533
|
+
this._state = GET_INFO;
|
|
28534
|
+
this.startLoop(cb);
|
|
28535
|
+
});
|
|
28536
|
+
}
|
|
28537
|
+
}
|
|
28538
|
+
/**
|
|
28539
|
+
* Builds an error object.
|
|
28540
|
+
*
|
|
28541
|
+
* @param {function(new:Error|RangeError)} ErrorCtor The error constructor
|
|
28542
|
+
* @param {String} message The error message
|
|
28543
|
+
* @param {Boolean} prefix Specifies whether or not to add a default prefix to
|
|
28544
|
+
* `message`
|
|
28545
|
+
* @param {Number} statusCode The status code
|
|
28546
|
+
* @param {String} errorCode The exposed error code
|
|
28547
|
+
* @return {(Error|RangeError)} The error
|
|
28548
|
+
* @private
|
|
28549
|
+
*/
|
|
28550
|
+
createError(ErrorCtor, message, prefix, statusCode, errorCode) {
|
|
28551
|
+
this._loop = false;
|
|
28552
|
+
this._errored = true;
|
|
28553
|
+
const err = new ErrorCtor(prefix ? `Invalid WebSocket frame: ${message}` : message);
|
|
28554
|
+
Error.captureStackTrace(err, this.createError);
|
|
28555
|
+
err.code = errorCode;
|
|
28556
|
+
err[kStatusCode] = statusCode;
|
|
28557
|
+
return err;
|
|
28558
|
+
}
|
|
28559
|
+
};
|
|
28560
|
+
module.exports = Receiver2;
|
|
28561
|
+
}
|
|
28562
|
+
});
|
|
28563
|
+
|
|
28564
|
+
// ../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/sender.js
|
|
28565
|
+
var require_sender = __commonJS({
|
|
28566
|
+
"../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/sender.js"(exports, module) {
|
|
28567
|
+
"use strict";
|
|
28568
|
+
var { randomFillSync } = __require("crypto");
|
|
28569
|
+
var PerMessageDeflate2 = require_permessage_deflate();
|
|
28570
|
+
var { EMPTY_BUFFER, kWebSocket, NOOP } = require_constants2();
|
|
28571
|
+
var { isBlob, isValidStatusCode } = require_validation();
|
|
28572
|
+
var { mask: applyMask, toBuffer } = require_buffer_util();
|
|
28573
|
+
var kByteLength = /* @__PURE__ */ Symbol("kByteLength");
|
|
28574
|
+
var maskBuffer = Buffer.alloc(4);
|
|
28575
|
+
var RANDOM_POOL_SIZE = 8 * 1024;
|
|
28576
|
+
var randomPool;
|
|
28577
|
+
var randomPoolPointer = RANDOM_POOL_SIZE;
|
|
28578
|
+
var DEFAULT = 0;
|
|
28579
|
+
var DEFLATING = 1;
|
|
28580
|
+
var GET_BLOB_DATA = 2;
|
|
28581
|
+
var Sender2 = class _Sender {
|
|
28582
|
+
static {
|
|
28583
|
+
__name(this, "Sender");
|
|
28584
|
+
}
|
|
28585
|
+
/**
|
|
28586
|
+
* Creates a Sender instance.
|
|
28587
|
+
*
|
|
28588
|
+
* @param {Duplex} socket The connection socket
|
|
28589
|
+
* @param {Object} [extensions] An object containing the negotiated extensions
|
|
28590
|
+
* @param {Function} [generateMask] The function used to generate the masking
|
|
28591
|
+
* key
|
|
28592
|
+
*/
|
|
28593
|
+
constructor(socket, extensions, generateMask) {
|
|
28594
|
+
this._extensions = extensions || {};
|
|
28595
|
+
if (generateMask) {
|
|
28596
|
+
this._generateMask = generateMask;
|
|
28597
|
+
this._maskBuffer = Buffer.alloc(4);
|
|
28598
|
+
}
|
|
28599
|
+
this._socket = socket;
|
|
28600
|
+
this._firstFragment = true;
|
|
28601
|
+
this._compress = false;
|
|
28602
|
+
this._bufferedBytes = 0;
|
|
28603
|
+
this._queue = [];
|
|
28604
|
+
this._state = DEFAULT;
|
|
28605
|
+
this.onerror = NOOP;
|
|
28606
|
+
this[kWebSocket] = void 0;
|
|
28607
|
+
}
|
|
28608
|
+
/**
|
|
28609
|
+
* Frames a piece of data according to the HyBi WebSocket protocol.
|
|
28610
|
+
*
|
|
28611
|
+
* @param {(Buffer|String)} data The data to frame
|
|
28612
|
+
* @param {Object} options Options object
|
|
28613
|
+
* @param {Boolean} [options.fin=false] Specifies whether or not to set the
|
|
28614
|
+
* FIN bit
|
|
28615
|
+
* @param {Function} [options.generateMask] The function used to generate the
|
|
28616
|
+
* masking key
|
|
28617
|
+
* @param {Boolean} [options.mask=false] Specifies whether or not to mask
|
|
28618
|
+
* `data`
|
|
28619
|
+
* @param {Buffer} [options.maskBuffer] The buffer used to store the masking
|
|
28620
|
+
* key
|
|
28621
|
+
* @param {Number} options.opcode The opcode
|
|
28622
|
+
* @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
|
|
28623
|
+
* modified
|
|
28624
|
+
* @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
|
|
28625
|
+
* RSV1 bit
|
|
28626
|
+
* @return {(Buffer|String)[]} The framed data
|
|
28627
|
+
* @public
|
|
28628
|
+
*/
|
|
28629
|
+
static frame(data, options) {
|
|
28630
|
+
let mask;
|
|
28631
|
+
let merge2 = false;
|
|
28632
|
+
let offset = 2;
|
|
28633
|
+
let skipMasking = false;
|
|
28634
|
+
if (options.mask) {
|
|
28635
|
+
mask = options.maskBuffer || maskBuffer;
|
|
28636
|
+
if (options.generateMask) {
|
|
28637
|
+
options.generateMask(mask);
|
|
28638
|
+
} else {
|
|
28639
|
+
if (randomPoolPointer === RANDOM_POOL_SIZE) {
|
|
28640
|
+
if (randomPool === void 0) {
|
|
28641
|
+
randomPool = Buffer.alloc(RANDOM_POOL_SIZE);
|
|
28642
|
+
}
|
|
28643
|
+
randomFillSync(randomPool, 0, RANDOM_POOL_SIZE);
|
|
28644
|
+
randomPoolPointer = 0;
|
|
28645
|
+
}
|
|
28646
|
+
mask[0] = randomPool[randomPoolPointer++];
|
|
28647
|
+
mask[1] = randomPool[randomPoolPointer++];
|
|
28648
|
+
mask[2] = randomPool[randomPoolPointer++];
|
|
28649
|
+
mask[3] = randomPool[randomPoolPointer++];
|
|
28650
|
+
}
|
|
28651
|
+
skipMasking = (mask[0] | mask[1] | mask[2] | mask[3]) === 0;
|
|
28652
|
+
offset = 6;
|
|
28653
|
+
}
|
|
28654
|
+
let dataLength;
|
|
28655
|
+
if (typeof data === "string") {
|
|
28656
|
+
if ((!options.mask || skipMasking) && options[kByteLength] !== void 0) {
|
|
28657
|
+
dataLength = options[kByteLength];
|
|
28658
|
+
} else {
|
|
28659
|
+
data = Buffer.from(data);
|
|
28660
|
+
dataLength = data.length;
|
|
28661
|
+
}
|
|
28662
|
+
} else {
|
|
28663
|
+
dataLength = data.length;
|
|
28664
|
+
merge2 = options.mask && options.readOnly && !skipMasking;
|
|
28665
|
+
}
|
|
28666
|
+
let payloadLength = dataLength;
|
|
28667
|
+
if (dataLength >= 65536) {
|
|
28668
|
+
offset += 8;
|
|
28669
|
+
payloadLength = 127;
|
|
28670
|
+
} else if (dataLength > 125) {
|
|
28671
|
+
offset += 2;
|
|
28672
|
+
payloadLength = 126;
|
|
28673
|
+
}
|
|
28674
|
+
const target = Buffer.allocUnsafe(merge2 ? dataLength + offset : offset);
|
|
28675
|
+
target[0] = options.fin ? options.opcode | 128 : options.opcode;
|
|
28676
|
+
if (options.rsv1) target[0] |= 64;
|
|
28677
|
+
target[1] = payloadLength;
|
|
28678
|
+
if (payloadLength === 126) {
|
|
28679
|
+
target.writeUInt16BE(dataLength, 2);
|
|
28680
|
+
} else if (payloadLength === 127) {
|
|
28681
|
+
target[2] = target[3] = 0;
|
|
28682
|
+
target.writeUIntBE(dataLength, 4, 6);
|
|
28683
|
+
}
|
|
28684
|
+
if (!options.mask) return [
|
|
28685
|
+
target,
|
|
28686
|
+
data
|
|
28687
|
+
];
|
|
28688
|
+
target[1] |= 128;
|
|
28689
|
+
target[offset - 4] = mask[0];
|
|
28690
|
+
target[offset - 3] = mask[1];
|
|
28691
|
+
target[offset - 2] = mask[2];
|
|
28692
|
+
target[offset - 1] = mask[3];
|
|
28693
|
+
if (skipMasking) return [
|
|
28694
|
+
target,
|
|
28695
|
+
data
|
|
28696
|
+
];
|
|
28697
|
+
if (merge2) {
|
|
28698
|
+
applyMask(data, mask, target, offset, dataLength);
|
|
28699
|
+
return [
|
|
28700
|
+
target
|
|
28701
|
+
];
|
|
28702
|
+
}
|
|
28703
|
+
applyMask(data, mask, data, 0, dataLength);
|
|
28704
|
+
return [
|
|
28705
|
+
target,
|
|
28706
|
+
data
|
|
28707
|
+
];
|
|
28708
|
+
}
|
|
28709
|
+
/**
|
|
28710
|
+
* Sends a close message to the other peer.
|
|
28711
|
+
*
|
|
28712
|
+
* @param {Number} [code] The status code component of the body
|
|
28713
|
+
* @param {(String|Buffer)} [data] The message component of the body
|
|
28714
|
+
* @param {Boolean} [mask=false] Specifies whether or not to mask the message
|
|
28715
|
+
* @param {Function} [cb] Callback
|
|
28716
|
+
* @public
|
|
28717
|
+
*/
|
|
28718
|
+
close(code2, data, mask, cb) {
|
|
28719
|
+
let buf;
|
|
28720
|
+
if (code2 === void 0) {
|
|
28721
|
+
buf = EMPTY_BUFFER;
|
|
28722
|
+
} else if (typeof code2 !== "number" || !isValidStatusCode(code2)) {
|
|
28723
|
+
throw new TypeError("First argument must be a valid error code number");
|
|
28724
|
+
} else if (data === void 0 || !data.length) {
|
|
28725
|
+
buf = Buffer.allocUnsafe(2);
|
|
28726
|
+
buf.writeUInt16BE(code2, 0);
|
|
28727
|
+
} else {
|
|
28728
|
+
const length = Buffer.byteLength(data);
|
|
28729
|
+
if (length > 123) {
|
|
28730
|
+
throw new RangeError("The message must not be greater than 123 bytes");
|
|
28731
|
+
}
|
|
28732
|
+
buf = Buffer.allocUnsafe(2 + length);
|
|
28733
|
+
buf.writeUInt16BE(code2, 0);
|
|
28734
|
+
if (typeof data === "string") {
|
|
28735
|
+
buf.write(data, 2);
|
|
28736
|
+
} else {
|
|
28737
|
+
buf.set(data, 2);
|
|
28738
|
+
}
|
|
28739
|
+
}
|
|
28740
|
+
const options = {
|
|
28741
|
+
[kByteLength]: buf.length,
|
|
28742
|
+
fin: true,
|
|
28743
|
+
generateMask: this._generateMask,
|
|
28744
|
+
mask,
|
|
28745
|
+
maskBuffer: this._maskBuffer,
|
|
28746
|
+
opcode: 8,
|
|
28747
|
+
readOnly: false,
|
|
28748
|
+
rsv1: false
|
|
28749
|
+
};
|
|
28750
|
+
if (this._state !== DEFAULT) {
|
|
28751
|
+
this.enqueue([
|
|
28752
|
+
this.dispatch,
|
|
28753
|
+
buf,
|
|
28754
|
+
false,
|
|
28755
|
+
options,
|
|
28756
|
+
cb
|
|
28757
|
+
]);
|
|
28758
|
+
} else {
|
|
28759
|
+
this.sendFrame(_Sender.frame(buf, options), cb);
|
|
28760
|
+
}
|
|
28761
|
+
}
|
|
28762
|
+
/**
|
|
28763
|
+
* Sends a ping message to the other peer.
|
|
28764
|
+
*
|
|
28765
|
+
* @param {*} data The message to send
|
|
28766
|
+
* @param {Boolean} [mask=false] Specifies whether or not to mask `data`
|
|
28767
|
+
* @param {Function} [cb] Callback
|
|
28768
|
+
* @public
|
|
28769
|
+
*/
|
|
28770
|
+
ping(data, mask, cb) {
|
|
28771
|
+
let byteLength;
|
|
28772
|
+
let readOnly;
|
|
28773
|
+
if (typeof data === "string") {
|
|
28774
|
+
byteLength = Buffer.byteLength(data);
|
|
28775
|
+
readOnly = false;
|
|
28776
|
+
} else if (isBlob(data)) {
|
|
28777
|
+
byteLength = data.size;
|
|
28778
|
+
readOnly = false;
|
|
28779
|
+
} else {
|
|
28780
|
+
data = toBuffer(data);
|
|
28781
|
+
byteLength = data.length;
|
|
28782
|
+
readOnly = toBuffer.readOnly;
|
|
28783
|
+
}
|
|
28784
|
+
if (byteLength > 125) {
|
|
28785
|
+
throw new RangeError("The data size must not be greater than 125 bytes");
|
|
28786
|
+
}
|
|
28787
|
+
const options = {
|
|
28788
|
+
[kByteLength]: byteLength,
|
|
28789
|
+
fin: true,
|
|
28790
|
+
generateMask: this._generateMask,
|
|
28791
|
+
mask,
|
|
28792
|
+
maskBuffer: this._maskBuffer,
|
|
28793
|
+
opcode: 9,
|
|
28794
|
+
readOnly,
|
|
28795
|
+
rsv1: false
|
|
28796
|
+
};
|
|
28797
|
+
if (isBlob(data)) {
|
|
28798
|
+
if (this._state !== DEFAULT) {
|
|
28799
|
+
this.enqueue([
|
|
28800
|
+
this.getBlobData,
|
|
28801
|
+
data,
|
|
28802
|
+
false,
|
|
28803
|
+
options,
|
|
28804
|
+
cb
|
|
28805
|
+
]);
|
|
28806
|
+
} else {
|
|
28807
|
+
this.getBlobData(data, false, options, cb);
|
|
28808
|
+
}
|
|
28809
|
+
} else if (this._state !== DEFAULT) {
|
|
28810
|
+
this.enqueue([
|
|
28811
|
+
this.dispatch,
|
|
28812
|
+
data,
|
|
28813
|
+
false,
|
|
28814
|
+
options,
|
|
28815
|
+
cb
|
|
28816
|
+
]);
|
|
28817
|
+
} else {
|
|
28818
|
+
this.sendFrame(_Sender.frame(data, options), cb);
|
|
28819
|
+
}
|
|
28820
|
+
}
|
|
28821
|
+
/**
|
|
28822
|
+
* Sends a pong message to the other peer.
|
|
28823
|
+
*
|
|
28824
|
+
* @param {*} data The message to send
|
|
28825
|
+
* @param {Boolean} [mask=false] Specifies whether or not to mask `data`
|
|
28826
|
+
* @param {Function} [cb] Callback
|
|
28827
|
+
* @public
|
|
28828
|
+
*/
|
|
28829
|
+
pong(data, mask, cb) {
|
|
28830
|
+
let byteLength;
|
|
28831
|
+
let readOnly;
|
|
28832
|
+
if (typeof data === "string") {
|
|
28833
|
+
byteLength = Buffer.byteLength(data);
|
|
28834
|
+
readOnly = false;
|
|
28835
|
+
} else if (isBlob(data)) {
|
|
28836
|
+
byteLength = data.size;
|
|
28837
|
+
readOnly = false;
|
|
28838
|
+
} else {
|
|
28839
|
+
data = toBuffer(data);
|
|
28840
|
+
byteLength = data.length;
|
|
28841
|
+
readOnly = toBuffer.readOnly;
|
|
28842
|
+
}
|
|
28843
|
+
if (byteLength > 125) {
|
|
28844
|
+
throw new RangeError("The data size must not be greater than 125 bytes");
|
|
28845
|
+
}
|
|
28846
|
+
const options = {
|
|
28847
|
+
[kByteLength]: byteLength,
|
|
28848
|
+
fin: true,
|
|
28849
|
+
generateMask: this._generateMask,
|
|
28850
|
+
mask,
|
|
28851
|
+
maskBuffer: this._maskBuffer,
|
|
28852
|
+
opcode: 10,
|
|
28853
|
+
readOnly,
|
|
28854
|
+
rsv1: false
|
|
28855
|
+
};
|
|
28856
|
+
if (isBlob(data)) {
|
|
28857
|
+
if (this._state !== DEFAULT) {
|
|
28858
|
+
this.enqueue([
|
|
28859
|
+
this.getBlobData,
|
|
28860
|
+
data,
|
|
28861
|
+
false,
|
|
28862
|
+
options,
|
|
28863
|
+
cb
|
|
28864
|
+
]);
|
|
28865
|
+
} else {
|
|
28866
|
+
this.getBlobData(data, false, options, cb);
|
|
28867
|
+
}
|
|
28868
|
+
} else if (this._state !== DEFAULT) {
|
|
28869
|
+
this.enqueue([
|
|
28870
|
+
this.dispatch,
|
|
28871
|
+
data,
|
|
28872
|
+
false,
|
|
28873
|
+
options,
|
|
28874
|
+
cb
|
|
28875
|
+
]);
|
|
28876
|
+
} else {
|
|
28877
|
+
this.sendFrame(_Sender.frame(data, options), cb);
|
|
28878
|
+
}
|
|
28879
|
+
}
|
|
28880
|
+
/**
|
|
28881
|
+
* Sends a data message to the other peer.
|
|
28882
|
+
*
|
|
28883
|
+
* @param {*} data The message to send
|
|
28884
|
+
* @param {Object} options Options object
|
|
28885
|
+
* @param {Boolean} [options.binary=false] Specifies whether `data` is binary
|
|
28886
|
+
* or text
|
|
28887
|
+
* @param {Boolean} [options.compress=false] Specifies whether or not to
|
|
28888
|
+
* compress `data`
|
|
28889
|
+
* @param {Boolean} [options.fin=false] Specifies whether the fragment is the
|
|
28890
|
+
* last one
|
|
28891
|
+
* @param {Boolean} [options.mask=false] Specifies whether or not to mask
|
|
28892
|
+
* `data`
|
|
28893
|
+
* @param {Function} [cb] Callback
|
|
28894
|
+
* @public
|
|
28895
|
+
*/
|
|
28896
|
+
send(data, options, cb) {
|
|
28897
|
+
const perMessageDeflate = this._extensions[PerMessageDeflate2.extensionName];
|
|
28898
|
+
let opcode = options.binary ? 2 : 1;
|
|
28899
|
+
let rsv1 = options.compress;
|
|
28900
|
+
let byteLength;
|
|
28901
|
+
let readOnly;
|
|
28902
|
+
if (typeof data === "string") {
|
|
28903
|
+
byteLength = Buffer.byteLength(data);
|
|
28904
|
+
readOnly = false;
|
|
28905
|
+
} else if (isBlob(data)) {
|
|
28906
|
+
byteLength = data.size;
|
|
28907
|
+
readOnly = false;
|
|
28908
|
+
} else {
|
|
28909
|
+
data = toBuffer(data);
|
|
28910
|
+
byteLength = data.length;
|
|
28911
|
+
readOnly = toBuffer.readOnly;
|
|
28912
|
+
}
|
|
28913
|
+
if (this._firstFragment) {
|
|
28914
|
+
this._firstFragment = false;
|
|
28915
|
+
if (rsv1 && perMessageDeflate && perMessageDeflate.params[perMessageDeflate._isServer ? "server_no_context_takeover" : "client_no_context_takeover"]) {
|
|
28916
|
+
rsv1 = byteLength >= perMessageDeflate._threshold;
|
|
28917
|
+
}
|
|
28918
|
+
this._compress = rsv1;
|
|
28919
|
+
} else {
|
|
28920
|
+
rsv1 = false;
|
|
28921
|
+
opcode = 0;
|
|
28922
|
+
}
|
|
28923
|
+
if (options.fin) this._firstFragment = true;
|
|
28924
|
+
const opts = {
|
|
28925
|
+
[kByteLength]: byteLength,
|
|
28926
|
+
fin: options.fin,
|
|
28927
|
+
generateMask: this._generateMask,
|
|
28928
|
+
mask: options.mask,
|
|
28929
|
+
maskBuffer: this._maskBuffer,
|
|
28930
|
+
opcode,
|
|
28931
|
+
readOnly,
|
|
28932
|
+
rsv1
|
|
28933
|
+
};
|
|
28934
|
+
if (isBlob(data)) {
|
|
28935
|
+
if (this._state !== DEFAULT) {
|
|
28936
|
+
this.enqueue([
|
|
28937
|
+
this.getBlobData,
|
|
28938
|
+
data,
|
|
28939
|
+
this._compress,
|
|
28940
|
+
opts,
|
|
28941
|
+
cb
|
|
28942
|
+
]);
|
|
28943
|
+
} else {
|
|
28944
|
+
this.getBlobData(data, this._compress, opts, cb);
|
|
28945
|
+
}
|
|
28946
|
+
} else if (this._state !== DEFAULT) {
|
|
28947
|
+
this.enqueue([
|
|
28948
|
+
this.dispatch,
|
|
28949
|
+
data,
|
|
28950
|
+
this._compress,
|
|
28951
|
+
opts,
|
|
28952
|
+
cb
|
|
28953
|
+
]);
|
|
28954
|
+
} else {
|
|
28955
|
+
this.dispatch(data, this._compress, opts, cb);
|
|
28956
|
+
}
|
|
28957
|
+
}
|
|
28958
|
+
/**
|
|
28959
|
+
* Gets the contents of a blob as binary data.
|
|
28960
|
+
*
|
|
28961
|
+
* @param {Blob} blob The blob
|
|
28962
|
+
* @param {Boolean} [compress=false] Specifies whether or not to compress
|
|
28963
|
+
* the data
|
|
28964
|
+
* @param {Object} options Options object
|
|
28965
|
+
* @param {Boolean} [options.fin=false] Specifies whether or not to set the
|
|
28966
|
+
* FIN bit
|
|
28967
|
+
* @param {Function} [options.generateMask] The function used to generate the
|
|
28968
|
+
* masking key
|
|
28969
|
+
* @param {Boolean} [options.mask=false] Specifies whether or not to mask
|
|
28970
|
+
* `data`
|
|
28971
|
+
* @param {Buffer} [options.maskBuffer] The buffer used to store the masking
|
|
28972
|
+
* key
|
|
28973
|
+
* @param {Number} options.opcode The opcode
|
|
28974
|
+
* @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
|
|
28975
|
+
* modified
|
|
28976
|
+
* @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
|
|
28977
|
+
* RSV1 bit
|
|
28978
|
+
* @param {Function} [cb] Callback
|
|
28979
|
+
* @private
|
|
28980
|
+
*/
|
|
28981
|
+
getBlobData(blob, compress2, options, cb) {
|
|
28982
|
+
this._bufferedBytes += options[kByteLength];
|
|
28983
|
+
this._state = GET_BLOB_DATA;
|
|
28984
|
+
blob.arrayBuffer().then((arrayBuffer) => {
|
|
28985
|
+
if (this._socket.destroyed) {
|
|
28986
|
+
const err = new Error("The socket was closed while the blob was being read");
|
|
28987
|
+
process.nextTick(callCallbacks, this, err, cb);
|
|
28988
|
+
return;
|
|
28989
|
+
}
|
|
28990
|
+
this._bufferedBytes -= options[kByteLength];
|
|
28991
|
+
const data = toBuffer(arrayBuffer);
|
|
28992
|
+
if (!compress2) {
|
|
28993
|
+
this._state = DEFAULT;
|
|
28994
|
+
this.sendFrame(_Sender.frame(data, options), cb);
|
|
28995
|
+
this.dequeue();
|
|
28996
|
+
} else {
|
|
28997
|
+
this.dispatch(data, compress2, options, cb);
|
|
28998
|
+
}
|
|
28999
|
+
}).catch((err) => {
|
|
29000
|
+
process.nextTick(onError, this, err, cb);
|
|
29001
|
+
});
|
|
29002
|
+
}
|
|
29003
|
+
/**
|
|
29004
|
+
* Dispatches a message.
|
|
29005
|
+
*
|
|
29006
|
+
* @param {(Buffer|String)} data The message to send
|
|
29007
|
+
* @param {Boolean} [compress=false] Specifies whether or not to compress
|
|
29008
|
+
* `data`
|
|
29009
|
+
* @param {Object} options Options object
|
|
29010
|
+
* @param {Boolean} [options.fin=false] Specifies whether or not to set the
|
|
29011
|
+
* FIN bit
|
|
29012
|
+
* @param {Function} [options.generateMask] The function used to generate the
|
|
29013
|
+
* masking key
|
|
29014
|
+
* @param {Boolean} [options.mask=false] Specifies whether or not to mask
|
|
29015
|
+
* `data`
|
|
29016
|
+
* @param {Buffer} [options.maskBuffer] The buffer used to store the masking
|
|
29017
|
+
* key
|
|
29018
|
+
* @param {Number} options.opcode The opcode
|
|
29019
|
+
* @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
|
|
29020
|
+
* modified
|
|
29021
|
+
* @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
|
|
29022
|
+
* RSV1 bit
|
|
29023
|
+
* @param {Function} [cb] Callback
|
|
29024
|
+
* @private
|
|
29025
|
+
*/
|
|
29026
|
+
dispatch(data, compress2, options, cb) {
|
|
29027
|
+
if (!compress2) {
|
|
29028
|
+
this.sendFrame(_Sender.frame(data, options), cb);
|
|
29029
|
+
return;
|
|
29030
|
+
}
|
|
29031
|
+
const perMessageDeflate = this._extensions[PerMessageDeflate2.extensionName];
|
|
29032
|
+
this._bufferedBytes += options[kByteLength];
|
|
29033
|
+
this._state = DEFLATING;
|
|
29034
|
+
perMessageDeflate.compress(data, options.fin, (_, buf) => {
|
|
29035
|
+
if (this._socket.destroyed) {
|
|
29036
|
+
const err = new Error("The socket was closed while data was being compressed");
|
|
29037
|
+
callCallbacks(this, err, cb);
|
|
29038
|
+
return;
|
|
29039
|
+
}
|
|
29040
|
+
this._bufferedBytes -= options[kByteLength];
|
|
29041
|
+
this._state = DEFAULT;
|
|
29042
|
+
options.readOnly = false;
|
|
29043
|
+
this.sendFrame(_Sender.frame(buf, options), cb);
|
|
29044
|
+
this.dequeue();
|
|
29045
|
+
});
|
|
29046
|
+
}
|
|
29047
|
+
/**
|
|
29048
|
+
* Executes queued send operations.
|
|
29049
|
+
*
|
|
29050
|
+
* @private
|
|
29051
|
+
*/
|
|
29052
|
+
dequeue() {
|
|
29053
|
+
while (this._state === DEFAULT && this._queue.length) {
|
|
29054
|
+
const params = this._queue.shift();
|
|
29055
|
+
this._bufferedBytes -= params[3][kByteLength];
|
|
29056
|
+
Reflect.apply(params[0], this, params.slice(1));
|
|
29057
|
+
}
|
|
29058
|
+
}
|
|
29059
|
+
/**
|
|
29060
|
+
* Enqueues a send operation.
|
|
29061
|
+
*
|
|
29062
|
+
* @param {Array} params Send operation parameters.
|
|
29063
|
+
* @private
|
|
29064
|
+
*/
|
|
29065
|
+
enqueue(params) {
|
|
29066
|
+
this._bufferedBytes += params[3][kByteLength];
|
|
29067
|
+
this._queue.push(params);
|
|
29068
|
+
}
|
|
29069
|
+
/**
|
|
29070
|
+
* Sends a frame.
|
|
29071
|
+
*
|
|
29072
|
+
* @param {(Buffer | String)[]} list The frame to send
|
|
29073
|
+
* @param {Function} [cb] Callback
|
|
29074
|
+
* @private
|
|
29075
|
+
*/
|
|
29076
|
+
sendFrame(list, cb) {
|
|
29077
|
+
if (list.length === 2) {
|
|
29078
|
+
this._socket.cork();
|
|
29079
|
+
this._socket.write(list[0]);
|
|
29080
|
+
this._socket.write(list[1], cb);
|
|
29081
|
+
this._socket.uncork();
|
|
29082
|
+
} else {
|
|
29083
|
+
this._socket.write(list[0], cb);
|
|
29084
|
+
}
|
|
29085
|
+
}
|
|
29086
|
+
};
|
|
29087
|
+
module.exports = Sender2;
|
|
29088
|
+
function callCallbacks(sender, err, cb) {
|
|
29089
|
+
if (typeof cb === "function") cb(err);
|
|
29090
|
+
for (let i = 0; i < sender._queue.length; i++) {
|
|
29091
|
+
const params = sender._queue[i];
|
|
29092
|
+
const callback = params[params.length - 1];
|
|
29093
|
+
if (typeof callback === "function") callback(err);
|
|
29094
|
+
}
|
|
29095
|
+
}
|
|
29096
|
+
__name(callCallbacks, "callCallbacks");
|
|
29097
|
+
function onError(sender, err, cb) {
|
|
29098
|
+
callCallbacks(sender, err, cb);
|
|
29099
|
+
sender.onerror(err);
|
|
29100
|
+
}
|
|
29101
|
+
__name(onError, "onError");
|
|
29102
|
+
}
|
|
29103
|
+
});
|
|
29104
|
+
|
|
29105
|
+
// ../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/subprotocol.js
|
|
29106
|
+
var require_subprotocol = __commonJS({
|
|
29107
|
+
"../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/subprotocol.js"(exports, module) {
|
|
29108
|
+
"use strict";
|
|
29109
|
+
var { tokenChars } = require_validation();
|
|
29110
|
+
function parse4(header) {
|
|
29111
|
+
const protocols = /* @__PURE__ */ new Set();
|
|
29112
|
+
let start2 = -1;
|
|
29113
|
+
let end = -1;
|
|
29114
|
+
let i = 0;
|
|
29115
|
+
for (i; i < header.length; i++) {
|
|
29116
|
+
const code2 = header.charCodeAt(i);
|
|
29117
|
+
if (end === -1 && tokenChars[code2] === 1) {
|
|
29118
|
+
if (start2 === -1) start2 = i;
|
|
29119
|
+
} else if (i !== 0 && (code2 === 32 || code2 === 9)) {
|
|
29120
|
+
if (end === -1 && start2 !== -1) end = i;
|
|
29121
|
+
} else if (code2 === 44) {
|
|
29122
|
+
if (start2 === -1) {
|
|
29123
|
+
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
29124
|
+
}
|
|
29125
|
+
if (end === -1) end = i;
|
|
29126
|
+
const protocol2 = header.slice(start2, end);
|
|
29127
|
+
if (protocols.has(protocol2)) {
|
|
29128
|
+
throw new SyntaxError(`The "${protocol2}" subprotocol is duplicated`);
|
|
29129
|
+
}
|
|
29130
|
+
protocols.add(protocol2);
|
|
29131
|
+
start2 = end = -1;
|
|
29132
|
+
} else {
|
|
29133
|
+
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
29134
|
+
}
|
|
29135
|
+
}
|
|
29136
|
+
if (start2 === -1 || end !== -1) {
|
|
29137
|
+
throw new SyntaxError("Unexpected end of input");
|
|
29138
|
+
}
|
|
29139
|
+
const protocol = header.slice(start2, i);
|
|
29140
|
+
if (protocols.has(protocol)) {
|
|
29141
|
+
throw new SyntaxError(`The "${protocol}" subprotocol is duplicated`);
|
|
29142
|
+
}
|
|
29143
|
+
protocols.add(protocol);
|
|
29144
|
+
return protocols;
|
|
29145
|
+
}
|
|
29146
|
+
__name(parse4, "parse");
|
|
29147
|
+
module.exports = {
|
|
29148
|
+
parse: parse4
|
|
29149
|
+
};
|
|
29150
|
+
}
|
|
29151
|
+
});
|
|
29152
|
+
|
|
29153
|
+
// ../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/event-target.js
|
|
29154
|
+
var require_event_target = __commonJS({
|
|
29155
|
+
"../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/event-target.js"(exports, module) {
|
|
29156
|
+
"use strict";
|
|
29157
|
+
var { kForOnEventAttribute, kListener } = require_constants2();
|
|
29158
|
+
var kCode = /* @__PURE__ */ Symbol("kCode");
|
|
29159
|
+
var kData = /* @__PURE__ */ Symbol("kData");
|
|
29160
|
+
var kError = /* @__PURE__ */ Symbol("kError");
|
|
29161
|
+
var kMessage = /* @__PURE__ */ Symbol("kMessage");
|
|
29162
|
+
var kReason = /* @__PURE__ */ Symbol("kReason");
|
|
29163
|
+
var kTarget = /* @__PURE__ */ Symbol("kTarget");
|
|
29164
|
+
var kType = /* @__PURE__ */ Symbol("kType");
|
|
29165
|
+
var kWasClean = /* @__PURE__ */ Symbol("kWasClean");
|
|
29166
|
+
var Event = class {
|
|
29167
|
+
static {
|
|
29168
|
+
__name(this, "Event");
|
|
29169
|
+
}
|
|
29170
|
+
/**
|
|
29171
|
+
* Create a new `Event`.
|
|
29172
|
+
*
|
|
29173
|
+
* @param {String} type The name of the event
|
|
29174
|
+
* @throws {TypeError} If the `type` argument is not specified
|
|
29175
|
+
*/
|
|
29176
|
+
constructor(type) {
|
|
29177
|
+
this[kTarget] = null;
|
|
29178
|
+
this[kType] = type;
|
|
29179
|
+
}
|
|
29180
|
+
/**
|
|
29181
|
+
* @type {*}
|
|
29182
|
+
*/
|
|
29183
|
+
get target() {
|
|
29184
|
+
return this[kTarget];
|
|
29185
|
+
}
|
|
29186
|
+
/**
|
|
29187
|
+
* @type {String}
|
|
29188
|
+
*/
|
|
29189
|
+
get type() {
|
|
29190
|
+
return this[kType];
|
|
29191
|
+
}
|
|
29192
|
+
};
|
|
29193
|
+
Object.defineProperty(Event.prototype, "target", {
|
|
29194
|
+
enumerable: true
|
|
29195
|
+
});
|
|
29196
|
+
Object.defineProperty(Event.prototype, "type", {
|
|
29197
|
+
enumerable: true
|
|
29198
|
+
});
|
|
29199
|
+
var CloseEvent = class extends Event {
|
|
29200
|
+
static {
|
|
29201
|
+
__name(this, "CloseEvent");
|
|
29202
|
+
}
|
|
29203
|
+
/**
|
|
29204
|
+
* Create a new `CloseEvent`.
|
|
29205
|
+
*
|
|
29206
|
+
* @param {String} type The name of the event
|
|
29207
|
+
* @param {Object} [options] A dictionary object that allows for setting
|
|
29208
|
+
* attributes via object members of the same name
|
|
29209
|
+
* @param {Number} [options.code=0] The status code explaining why the
|
|
29210
|
+
* connection was closed
|
|
29211
|
+
* @param {String} [options.reason=''] A human-readable string explaining why
|
|
29212
|
+
* the connection was closed
|
|
29213
|
+
* @param {Boolean} [options.wasClean=false] Indicates whether or not the
|
|
29214
|
+
* connection was cleanly closed
|
|
29215
|
+
*/
|
|
29216
|
+
constructor(type, options = {}) {
|
|
29217
|
+
super(type);
|
|
29218
|
+
this[kCode] = options.code === void 0 ? 0 : options.code;
|
|
29219
|
+
this[kReason] = options.reason === void 0 ? "" : options.reason;
|
|
29220
|
+
this[kWasClean] = options.wasClean === void 0 ? false : options.wasClean;
|
|
29221
|
+
}
|
|
29222
|
+
/**
|
|
29223
|
+
* @type {Number}
|
|
29224
|
+
*/
|
|
29225
|
+
get code() {
|
|
29226
|
+
return this[kCode];
|
|
29227
|
+
}
|
|
29228
|
+
/**
|
|
29229
|
+
* @type {String}
|
|
29230
|
+
*/
|
|
29231
|
+
get reason() {
|
|
29232
|
+
return this[kReason];
|
|
29233
|
+
}
|
|
29234
|
+
/**
|
|
29235
|
+
* @type {Boolean}
|
|
29236
|
+
*/
|
|
29237
|
+
get wasClean() {
|
|
29238
|
+
return this[kWasClean];
|
|
29239
|
+
}
|
|
29240
|
+
};
|
|
29241
|
+
Object.defineProperty(CloseEvent.prototype, "code", {
|
|
29242
|
+
enumerable: true
|
|
29243
|
+
});
|
|
29244
|
+
Object.defineProperty(CloseEvent.prototype, "reason", {
|
|
29245
|
+
enumerable: true
|
|
29246
|
+
});
|
|
29247
|
+
Object.defineProperty(CloseEvent.prototype, "wasClean", {
|
|
29248
|
+
enumerable: true
|
|
29249
|
+
});
|
|
29250
|
+
var ErrorEvent = class extends Event {
|
|
29251
|
+
static {
|
|
29252
|
+
__name(this, "ErrorEvent");
|
|
29253
|
+
}
|
|
29254
|
+
/**
|
|
29255
|
+
* Create a new `ErrorEvent`.
|
|
29256
|
+
*
|
|
29257
|
+
* @param {String} type The name of the event
|
|
29258
|
+
* @param {Object} [options] A dictionary object that allows for setting
|
|
29259
|
+
* attributes via object members of the same name
|
|
29260
|
+
* @param {*} [options.error=null] The error that generated this event
|
|
29261
|
+
* @param {String} [options.message=''] The error message
|
|
29262
|
+
*/
|
|
29263
|
+
constructor(type, options = {}) {
|
|
29264
|
+
super(type);
|
|
29265
|
+
this[kError] = options.error === void 0 ? null : options.error;
|
|
29266
|
+
this[kMessage] = options.message === void 0 ? "" : options.message;
|
|
29267
|
+
}
|
|
29268
|
+
/**
|
|
29269
|
+
* @type {*}
|
|
29270
|
+
*/
|
|
29271
|
+
get error() {
|
|
29272
|
+
return this[kError];
|
|
29273
|
+
}
|
|
29274
|
+
/**
|
|
29275
|
+
* @type {String}
|
|
29276
|
+
*/
|
|
29277
|
+
get message() {
|
|
29278
|
+
return this[kMessage];
|
|
29279
|
+
}
|
|
29280
|
+
};
|
|
29281
|
+
Object.defineProperty(ErrorEvent.prototype, "error", {
|
|
29282
|
+
enumerable: true
|
|
29283
|
+
});
|
|
29284
|
+
Object.defineProperty(ErrorEvent.prototype, "message", {
|
|
29285
|
+
enumerable: true
|
|
29286
|
+
});
|
|
29287
|
+
var MessageEvent = class extends Event {
|
|
29288
|
+
static {
|
|
29289
|
+
__name(this, "MessageEvent");
|
|
29290
|
+
}
|
|
29291
|
+
/**
|
|
29292
|
+
* Create a new `MessageEvent`.
|
|
29293
|
+
*
|
|
29294
|
+
* @param {String} type The name of the event
|
|
29295
|
+
* @param {Object} [options] A dictionary object that allows for setting
|
|
29296
|
+
* attributes via object members of the same name
|
|
29297
|
+
* @param {*} [options.data=null] The message content
|
|
29298
|
+
*/
|
|
29299
|
+
constructor(type, options = {}) {
|
|
29300
|
+
super(type);
|
|
29301
|
+
this[kData] = options.data === void 0 ? null : options.data;
|
|
29302
|
+
}
|
|
29303
|
+
/**
|
|
29304
|
+
* @type {*}
|
|
29305
|
+
*/
|
|
29306
|
+
get data() {
|
|
29307
|
+
return this[kData];
|
|
29308
|
+
}
|
|
29309
|
+
};
|
|
29310
|
+
Object.defineProperty(MessageEvent.prototype, "data", {
|
|
29311
|
+
enumerable: true
|
|
29312
|
+
});
|
|
29313
|
+
var EventTarget = {
|
|
29314
|
+
/**
|
|
29315
|
+
* Register an event listener.
|
|
29316
|
+
*
|
|
29317
|
+
* @param {String} type A string representing the event type to listen for
|
|
29318
|
+
* @param {(Function|Object)} handler The listener to add
|
|
29319
|
+
* @param {Object} [options] An options object specifies characteristics about
|
|
29320
|
+
* the event listener
|
|
29321
|
+
* @param {Boolean} [options.once=false] A `Boolean` indicating that the
|
|
29322
|
+
* listener should be invoked at most once after being added. If `true`,
|
|
29323
|
+
* the listener would be automatically removed when invoked.
|
|
29324
|
+
* @public
|
|
29325
|
+
*/
|
|
29326
|
+
addEventListener(type, handler, options = {}) {
|
|
29327
|
+
for (const listener of this.listeners(type)) {
|
|
29328
|
+
if (!options[kForOnEventAttribute] && listener[kListener] === handler && !listener[kForOnEventAttribute]) {
|
|
29329
|
+
return;
|
|
29330
|
+
}
|
|
29331
|
+
}
|
|
29332
|
+
let wrapper;
|
|
29333
|
+
if (type === "message") {
|
|
29334
|
+
wrapper = /* @__PURE__ */ __name(function onMessage(data, isBinary) {
|
|
29335
|
+
const event = new MessageEvent("message", {
|
|
29336
|
+
data: isBinary ? data : data.toString()
|
|
29337
|
+
});
|
|
29338
|
+
event[kTarget] = this;
|
|
29339
|
+
callListener(handler, this, event);
|
|
29340
|
+
}, "onMessage");
|
|
29341
|
+
} else if (type === "close") {
|
|
29342
|
+
wrapper = /* @__PURE__ */ __name(function onClose(code2, message) {
|
|
29343
|
+
const event = new CloseEvent("close", {
|
|
29344
|
+
code: code2,
|
|
29345
|
+
reason: message.toString(),
|
|
29346
|
+
wasClean: this._closeFrameReceived && this._closeFrameSent
|
|
29347
|
+
});
|
|
29348
|
+
event[kTarget] = this;
|
|
29349
|
+
callListener(handler, this, event);
|
|
29350
|
+
}, "onClose");
|
|
29351
|
+
} else if (type === "error") {
|
|
29352
|
+
wrapper = /* @__PURE__ */ __name(function onError(error48) {
|
|
29353
|
+
const event = new ErrorEvent("error", {
|
|
29354
|
+
error: error48,
|
|
29355
|
+
message: error48.message
|
|
29356
|
+
});
|
|
29357
|
+
event[kTarget] = this;
|
|
29358
|
+
callListener(handler, this, event);
|
|
29359
|
+
}, "onError");
|
|
29360
|
+
} else if (type === "open") {
|
|
29361
|
+
wrapper = /* @__PURE__ */ __name(function onOpen() {
|
|
29362
|
+
const event = new Event("open");
|
|
29363
|
+
event[kTarget] = this;
|
|
29364
|
+
callListener(handler, this, event);
|
|
29365
|
+
}, "onOpen");
|
|
29366
|
+
} else {
|
|
29367
|
+
return;
|
|
29368
|
+
}
|
|
29369
|
+
wrapper[kForOnEventAttribute] = !!options[kForOnEventAttribute];
|
|
29370
|
+
wrapper[kListener] = handler;
|
|
29371
|
+
if (options.once) {
|
|
29372
|
+
this.once(type, wrapper);
|
|
29373
|
+
} else {
|
|
29374
|
+
this.on(type, wrapper);
|
|
29375
|
+
}
|
|
29376
|
+
},
|
|
29377
|
+
/**
|
|
29378
|
+
* Remove an event listener.
|
|
29379
|
+
*
|
|
29380
|
+
* @param {String} type A string representing the event type to remove
|
|
29381
|
+
* @param {(Function|Object)} handler The listener to remove
|
|
29382
|
+
* @public
|
|
29383
|
+
*/
|
|
29384
|
+
removeEventListener(type, handler) {
|
|
29385
|
+
for (const listener of this.listeners(type)) {
|
|
29386
|
+
if (listener[kListener] === handler && !listener[kForOnEventAttribute]) {
|
|
29387
|
+
this.removeListener(type, listener);
|
|
29388
|
+
break;
|
|
29389
|
+
}
|
|
29390
|
+
}
|
|
29391
|
+
}
|
|
29392
|
+
};
|
|
29393
|
+
module.exports = {
|
|
29394
|
+
CloseEvent,
|
|
29395
|
+
ErrorEvent,
|
|
29396
|
+
Event,
|
|
29397
|
+
EventTarget,
|
|
29398
|
+
MessageEvent
|
|
29399
|
+
};
|
|
29400
|
+
function callListener(listener, thisArg, event) {
|
|
29401
|
+
if (typeof listener === "object" && listener.handleEvent) {
|
|
29402
|
+
listener.handleEvent.call(listener, event);
|
|
29403
|
+
} else {
|
|
29404
|
+
listener.call(thisArg, event);
|
|
29405
|
+
}
|
|
29406
|
+
}
|
|
29407
|
+
__name(callListener, "callListener");
|
|
29408
|
+
}
|
|
29409
|
+
});
|
|
29410
|
+
|
|
29411
|
+
// ../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/websocket.js
|
|
29412
|
+
var require_websocket = __commonJS({
|
|
29413
|
+
"../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/websocket.js"(exports, module) {
|
|
29414
|
+
"use strict";
|
|
29415
|
+
var EventEmitter = __require("events");
|
|
29416
|
+
var https = __require("https");
|
|
29417
|
+
var http = __require("http");
|
|
29418
|
+
var net = __require("net");
|
|
29419
|
+
var tls = __require("tls");
|
|
29420
|
+
var { randomBytes, createHash } = __require("crypto");
|
|
29421
|
+
var { URL: URL2 } = __require("url");
|
|
29422
|
+
var PerMessageDeflate2 = require_permessage_deflate();
|
|
29423
|
+
var Receiver2 = require_receiver();
|
|
29424
|
+
var Sender2 = require_sender();
|
|
29425
|
+
var { isBlob } = require_validation();
|
|
29426
|
+
var { BINARY_TYPES, CLOSE_TIMEOUT, EMPTY_BUFFER, GUID, kForOnEventAttribute, kListener, kStatusCode, kWebSocket, NOOP } = require_constants2();
|
|
29427
|
+
var { EventTarget: { addEventListener, removeEventListener } } = require_event_target();
|
|
29428
|
+
var { format, parse: parse4 } = require_extension();
|
|
29429
|
+
var { toBuffer } = require_buffer_util();
|
|
29430
|
+
var kAborted = /* @__PURE__ */ Symbol("kAborted");
|
|
29431
|
+
var protocolVersions = [
|
|
29432
|
+
8,
|
|
29433
|
+
13
|
|
29434
|
+
];
|
|
29435
|
+
var readyStates = [
|
|
29436
|
+
"CONNECTING",
|
|
29437
|
+
"OPEN",
|
|
29438
|
+
"CLOSING",
|
|
29439
|
+
"CLOSED"
|
|
29440
|
+
];
|
|
29441
|
+
var subprotocolRegex = /^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;
|
|
29442
|
+
var WebSocket2 = class _WebSocket extends EventEmitter {
|
|
29443
|
+
static {
|
|
29444
|
+
__name(this, "WebSocket");
|
|
29445
|
+
}
|
|
29446
|
+
/**
|
|
29447
|
+
* Create a new `WebSocket`.
|
|
29448
|
+
*
|
|
29449
|
+
* @param {(String|URL)} address The URL to which to connect
|
|
29450
|
+
* @param {(String|String[])} [protocols] The subprotocols
|
|
29451
|
+
* @param {Object} [options] Connection options
|
|
29452
|
+
*/
|
|
29453
|
+
constructor(address, protocols, options) {
|
|
29454
|
+
super();
|
|
29455
|
+
this._binaryType = BINARY_TYPES[0];
|
|
29456
|
+
this._closeCode = 1006;
|
|
29457
|
+
this._closeFrameReceived = false;
|
|
29458
|
+
this._closeFrameSent = false;
|
|
29459
|
+
this._closeMessage = EMPTY_BUFFER;
|
|
29460
|
+
this._closeTimer = null;
|
|
29461
|
+
this._errorEmitted = false;
|
|
29462
|
+
this._extensions = {};
|
|
29463
|
+
this._paused = false;
|
|
29464
|
+
this._protocol = "";
|
|
29465
|
+
this._readyState = _WebSocket.CONNECTING;
|
|
29466
|
+
this._receiver = null;
|
|
29467
|
+
this._sender = null;
|
|
29468
|
+
this._socket = null;
|
|
29469
|
+
if (address !== null) {
|
|
29470
|
+
this._bufferedAmount = 0;
|
|
29471
|
+
this._isServer = false;
|
|
29472
|
+
this._redirects = 0;
|
|
29473
|
+
if (protocols === void 0) {
|
|
29474
|
+
protocols = [];
|
|
29475
|
+
} else if (!Array.isArray(protocols)) {
|
|
29476
|
+
if (typeof protocols === "object" && protocols !== null) {
|
|
29477
|
+
options = protocols;
|
|
29478
|
+
protocols = [];
|
|
29479
|
+
} else {
|
|
29480
|
+
protocols = [
|
|
29481
|
+
protocols
|
|
29482
|
+
];
|
|
29483
|
+
}
|
|
29484
|
+
}
|
|
29485
|
+
initAsClient(this, address, protocols, options);
|
|
29486
|
+
} else {
|
|
29487
|
+
this._autoPong = options.autoPong;
|
|
29488
|
+
this._closeTimeout = options.closeTimeout;
|
|
29489
|
+
this._isServer = true;
|
|
29490
|
+
}
|
|
29491
|
+
}
|
|
29492
|
+
/**
|
|
29493
|
+
* For historical reasons, the custom "nodebuffer" type is used by the default
|
|
29494
|
+
* instead of "blob".
|
|
29495
|
+
*
|
|
29496
|
+
* @type {String}
|
|
29497
|
+
*/
|
|
29498
|
+
get binaryType() {
|
|
29499
|
+
return this._binaryType;
|
|
29500
|
+
}
|
|
29501
|
+
set binaryType(type) {
|
|
29502
|
+
if (!BINARY_TYPES.includes(type)) return;
|
|
29503
|
+
this._binaryType = type;
|
|
29504
|
+
if (this._receiver) this._receiver._binaryType = type;
|
|
29505
|
+
}
|
|
29506
|
+
/**
|
|
29507
|
+
* @type {Number}
|
|
29508
|
+
*/
|
|
29509
|
+
get bufferedAmount() {
|
|
29510
|
+
if (!this._socket) return this._bufferedAmount;
|
|
29511
|
+
return this._socket._writableState.length + this._sender._bufferedBytes;
|
|
29512
|
+
}
|
|
29513
|
+
/**
|
|
29514
|
+
* @type {String}
|
|
29515
|
+
*/
|
|
29516
|
+
get extensions() {
|
|
29517
|
+
return Object.keys(this._extensions).join();
|
|
29518
|
+
}
|
|
29519
|
+
/**
|
|
29520
|
+
* @type {Boolean}
|
|
29521
|
+
*/
|
|
29522
|
+
get isPaused() {
|
|
29523
|
+
return this._paused;
|
|
29524
|
+
}
|
|
29525
|
+
/**
|
|
29526
|
+
* @type {Function}
|
|
29527
|
+
*/
|
|
29528
|
+
/* istanbul ignore next */
|
|
29529
|
+
get onclose() {
|
|
29530
|
+
return null;
|
|
29531
|
+
}
|
|
29532
|
+
/**
|
|
29533
|
+
* @type {Function}
|
|
29534
|
+
*/
|
|
29535
|
+
/* istanbul ignore next */
|
|
29536
|
+
get onerror() {
|
|
29537
|
+
return null;
|
|
29538
|
+
}
|
|
29539
|
+
/**
|
|
29540
|
+
* @type {Function}
|
|
29541
|
+
*/
|
|
29542
|
+
/* istanbul ignore next */
|
|
29543
|
+
get onopen() {
|
|
29544
|
+
return null;
|
|
29545
|
+
}
|
|
29546
|
+
/**
|
|
29547
|
+
* @type {Function}
|
|
29548
|
+
*/
|
|
29549
|
+
/* istanbul ignore next */
|
|
29550
|
+
get onmessage() {
|
|
29551
|
+
return null;
|
|
29552
|
+
}
|
|
29553
|
+
/**
|
|
29554
|
+
* @type {String}
|
|
29555
|
+
*/
|
|
29556
|
+
get protocol() {
|
|
29557
|
+
return this._protocol;
|
|
29558
|
+
}
|
|
29559
|
+
/**
|
|
29560
|
+
* @type {Number}
|
|
29561
|
+
*/
|
|
29562
|
+
get readyState() {
|
|
29563
|
+
return this._readyState;
|
|
29564
|
+
}
|
|
29565
|
+
/**
|
|
29566
|
+
* @type {String}
|
|
29567
|
+
*/
|
|
29568
|
+
get url() {
|
|
29569
|
+
return this._url;
|
|
29570
|
+
}
|
|
29571
|
+
/**
|
|
29572
|
+
* Set up the socket and the internal resources.
|
|
29573
|
+
*
|
|
29574
|
+
* @param {Duplex} socket The network socket between the server and client
|
|
29575
|
+
* @param {Buffer} head The first packet of the upgraded stream
|
|
29576
|
+
* @param {Object} options Options object
|
|
29577
|
+
* @param {Boolean} [options.allowSynchronousEvents=false] Specifies whether
|
|
29578
|
+
* any of the `'message'`, `'ping'`, and `'pong'` events can be emitted
|
|
29579
|
+
* multiple times in the same tick
|
|
29580
|
+
* @param {Function} [options.generateMask] The function used to generate the
|
|
29581
|
+
* masking key
|
|
29582
|
+
* @param {Number} [options.maxPayload=0] The maximum allowed message size
|
|
29583
|
+
* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
|
|
29584
|
+
* not to skip UTF-8 validation for text and close messages
|
|
29585
|
+
* @private
|
|
29586
|
+
*/
|
|
29587
|
+
setSocket(socket, head, options) {
|
|
29588
|
+
const receiver = new Receiver2({
|
|
29589
|
+
allowSynchronousEvents: options.allowSynchronousEvents,
|
|
29590
|
+
binaryType: this.binaryType,
|
|
29591
|
+
extensions: this._extensions,
|
|
29592
|
+
isServer: this._isServer,
|
|
29593
|
+
maxPayload: options.maxPayload,
|
|
29594
|
+
skipUTF8Validation: options.skipUTF8Validation
|
|
29595
|
+
});
|
|
29596
|
+
const sender = new Sender2(socket, this._extensions, options.generateMask);
|
|
29597
|
+
this._receiver = receiver;
|
|
29598
|
+
this._sender = sender;
|
|
29599
|
+
this._socket = socket;
|
|
29600
|
+
receiver[kWebSocket] = this;
|
|
29601
|
+
sender[kWebSocket] = this;
|
|
29602
|
+
socket[kWebSocket] = this;
|
|
29603
|
+
receiver.on("conclude", receiverOnConclude);
|
|
29604
|
+
receiver.on("drain", receiverOnDrain);
|
|
29605
|
+
receiver.on("error", receiverOnError);
|
|
29606
|
+
receiver.on("message", receiverOnMessage);
|
|
29607
|
+
receiver.on("ping", receiverOnPing);
|
|
29608
|
+
receiver.on("pong", receiverOnPong);
|
|
29609
|
+
sender.onerror = senderOnError;
|
|
29610
|
+
if (socket.setTimeout) socket.setTimeout(0);
|
|
29611
|
+
if (socket.setNoDelay) socket.setNoDelay();
|
|
29612
|
+
if (head.length > 0) socket.unshift(head);
|
|
29613
|
+
socket.on("close", socketOnClose);
|
|
29614
|
+
socket.on("data", socketOnData);
|
|
29615
|
+
socket.on("end", socketOnEnd);
|
|
29616
|
+
socket.on("error", socketOnError);
|
|
29617
|
+
this._readyState = _WebSocket.OPEN;
|
|
29618
|
+
this.emit("open");
|
|
29619
|
+
}
|
|
29620
|
+
/**
|
|
29621
|
+
* Emit the `'close'` event.
|
|
29622
|
+
*
|
|
29623
|
+
* @private
|
|
29624
|
+
*/
|
|
29625
|
+
emitClose() {
|
|
29626
|
+
if (!this._socket) {
|
|
29627
|
+
this._readyState = _WebSocket.CLOSED;
|
|
29628
|
+
this.emit("close", this._closeCode, this._closeMessage);
|
|
29629
|
+
return;
|
|
29630
|
+
}
|
|
29631
|
+
if (this._extensions[PerMessageDeflate2.extensionName]) {
|
|
29632
|
+
this._extensions[PerMessageDeflate2.extensionName].cleanup();
|
|
29633
|
+
}
|
|
29634
|
+
this._receiver.removeAllListeners();
|
|
29635
|
+
this._readyState = _WebSocket.CLOSED;
|
|
29636
|
+
this.emit("close", this._closeCode, this._closeMessage);
|
|
29637
|
+
}
|
|
29638
|
+
/**
|
|
29639
|
+
* Start a closing handshake.
|
|
29640
|
+
*
|
|
29641
|
+
* +----------+ +-----------+ +----------+
|
|
29642
|
+
* - - -|ws.close()|-->|close frame|-->|ws.close()|- - -
|
|
29643
|
+
* | +----------+ +-----------+ +----------+ |
|
|
29644
|
+
* +----------+ +-----------+ |
|
|
29645
|
+
* CLOSING |ws.close()|<--|close frame|<--+-----+ CLOSING
|
|
29646
|
+
* +----------+ +-----------+ |
|
|
29647
|
+
* | | | +---+ |
|
|
29648
|
+
* +------------------------+-->|fin| - - - -
|
|
29649
|
+
* | +---+ | +---+
|
|
29650
|
+
* - - - - -|fin|<---------------------+
|
|
29651
|
+
* +---+
|
|
29652
|
+
*
|
|
29653
|
+
* @param {Number} [code] Status code explaining why the connection is closing
|
|
29654
|
+
* @param {(String|Buffer)} [data] The reason why the connection is
|
|
29655
|
+
* closing
|
|
29656
|
+
* @public
|
|
29657
|
+
*/
|
|
29658
|
+
close(code2, data) {
|
|
29659
|
+
if (this.readyState === _WebSocket.CLOSED) return;
|
|
29660
|
+
if (this.readyState === _WebSocket.CONNECTING) {
|
|
29661
|
+
const msg = "WebSocket was closed before the connection was established";
|
|
29662
|
+
abortHandshake(this, this._req, msg);
|
|
29663
|
+
return;
|
|
29664
|
+
}
|
|
29665
|
+
if (this.readyState === _WebSocket.CLOSING) {
|
|
29666
|
+
if (this._closeFrameSent && (this._closeFrameReceived || this._receiver._writableState.errorEmitted)) {
|
|
29667
|
+
this._socket.end();
|
|
29668
|
+
}
|
|
29669
|
+
return;
|
|
29670
|
+
}
|
|
29671
|
+
this._readyState = _WebSocket.CLOSING;
|
|
29672
|
+
this._sender.close(code2, data, !this._isServer, (err) => {
|
|
29673
|
+
if (err) return;
|
|
29674
|
+
this._closeFrameSent = true;
|
|
29675
|
+
if (this._closeFrameReceived || this._receiver._writableState.errorEmitted) {
|
|
29676
|
+
this._socket.end();
|
|
29677
|
+
}
|
|
29678
|
+
});
|
|
29679
|
+
setCloseTimer(this);
|
|
29680
|
+
}
|
|
29681
|
+
/**
|
|
29682
|
+
* Pause the socket.
|
|
29683
|
+
*
|
|
29684
|
+
* @public
|
|
29685
|
+
*/
|
|
29686
|
+
pause() {
|
|
29687
|
+
if (this.readyState === _WebSocket.CONNECTING || this.readyState === _WebSocket.CLOSED) {
|
|
29688
|
+
return;
|
|
29689
|
+
}
|
|
29690
|
+
this._paused = true;
|
|
29691
|
+
this._socket.pause();
|
|
29692
|
+
}
|
|
29693
|
+
/**
|
|
29694
|
+
* Send a ping.
|
|
29695
|
+
*
|
|
29696
|
+
* @param {*} [data] The data to send
|
|
29697
|
+
* @param {Boolean} [mask] Indicates whether or not to mask `data`
|
|
29698
|
+
* @param {Function} [cb] Callback which is executed when the ping is sent
|
|
29699
|
+
* @public
|
|
29700
|
+
*/
|
|
29701
|
+
ping(data, mask, cb) {
|
|
29702
|
+
if (this.readyState === _WebSocket.CONNECTING) {
|
|
29703
|
+
throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
|
|
29704
|
+
}
|
|
29705
|
+
if (typeof data === "function") {
|
|
29706
|
+
cb = data;
|
|
29707
|
+
data = mask = void 0;
|
|
29708
|
+
} else if (typeof mask === "function") {
|
|
29709
|
+
cb = mask;
|
|
29710
|
+
mask = void 0;
|
|
29711
|
+
}
|
|
29712
|
+
if (typeof data === "number") data = data.toString();
|
|
29713
|
+
if (this.readyState !== _WebSocket.OPEN) {
|
|
29714
|
+
sendAfterClose(this, data, cb);
|
|
29715
|
+
return;
|
|
29716
|
+
}
|
|
29717
|
+
if (mask === void 0) mask = !this._isServer;
|
|
29718
|
+
this._sender.ping(data || EMPTY_BUFFER, mask, cb);
|
|
29719
|
+
}
|
|
29720
|
+
/**
|
|
29721
|
+
* Send a pong.
|
|
29722
|
+
*
|
|
29723
|
+
* @param {*} [data] The data to send
|
|
29724
|
+
* @param {Boolean} [mask] Indicates whether or not to mask `data`
|
|
29725
|
+
* @param {Function} [cb] Callback which is executed when the pong is sent
|
|
29726
|
+
* @public
|
|
29727
|
+
*/
|
|
29728
|
+
pong(data, mask, cb) {
|
|
29729
|
+
if (this.readyState === _WebSocket.CONNECTING) {
|
|
29730
|
+
throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
|
|
29731
|
+
}
|
|
29732
|
+
if (typeof data === "function") {
|
|
29733
|
+
cb = data;
|
|
29734
|
+
data = mask = void 0;
|
|
29735
|
+
} else if (typeof mask === "function") {
|
|
29736
|
+
cb = mask;
|
|
29737
|
+
mask = void 0;
|
|
29738
|
+
}
|
|
29739
|
+
if (typeof data === "number") data = data.toString();
|
|
29740
|
+
if (this.readyState !== _WebSocket.OPEN) {
|
|
29741
|
+
sendAfterClose(this, data, cb);
|
|
29742
|
+
return;
|
|
29743
|
+
}
|
|
29744
|
+
if (mask === void 0) mask = !this._isServer;
|
|
29745
|
+
this._sender.pong(data || EMPTY_BUFFER, mask, cb);
|
|
29746
|
+
}
|
|
29747
|
+
/**
|
|
29748
|
+
* Resume the socket.
|
|
29749
|
+
*
|
|
29750
|
+
* @public
|
|
29751
|
+
*/
|
|
29752
|
+
resume() {
|
|
29753
|
+
if (this.readyState === _WebSocket.CONNECTING || this.readyState === _WebSocket.CLOSED) {
|
|
29754
|
+
return;
|
|
29755
|
+
}
|
|
29756
|
+
this._paused = false;
|
|
29757
|
+
if (!this._receiver._writableState.needDrain) this._socket.resume();
|
|
29758
|
+
}
|
|
29759
|
+
/**
|
|
29760
|
+
* Send a data message.
|
|
29761
|
+
*
|
|
29762
|
+
* @param {*} data The message to send
|
|
29763
|
+
* @param {Object} [options] Options object
|
|
29764
|
+
* @param {Boolean} [options.binary] Specifies whether `data` is binary or
|
|
29765
|
+
* text
|
|
29766
|
+
* @param {Boolean} [options.compress] Specifies whether or not to compress
|
|
29767
|
+
* `data`
|
|
29768
|
+
* @param {Boolean} [options.fin=true] Specifies whether the fragment is the
|
|
29769
|
+
* last one
|
|
29770
|
+
* @param {Boolean} [options.mask] Specifies whether or not to mask `data`
|
|
29771
|
+
* @param {Function} [cb] Callback which is executed when data is written out
|
|
29772
|
+
* @public
|
|
29773
|
+
*/
|
|
29774
|
+
send(data, options, cb) {
|
|
29775
|
+
if (this.readyState === _WebSocket.CONNECTING) {
|
|
29776
|
+
throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
|
|
29777
|
+
}
|
|
29778
|
+
if (typeof options === "function") {
|
|
29779
|
+
cb = options;
|
|
29780
|
+
options = {};
|
|
29781
|
+
}
|
|
29782
|
+
if (typeof data === "number") data = data.toString();
|
|
29783
|
+
if (this.readyState !== _WebSocket.OPEN) {
|
|
29784
|
+
sendAfterClose(this, data, cb);
|
|
29785
|
+
return;
|
|
29786
|
+
}
|
|
29787
|
+
const opts = {
|
|
29788
|
+
binary: typeof data !== "string",
|
|
29789
|
+
mask: !this._isServer,
|
|
29790
|
+
compress: true,
|
|
29791
|
+
fin: true,
|
|
29792
|
+
...options
|
|
29793
|
+
};
|
|
29794
|
+
if (!this._extensions[PerMessageDeflate2.extensionName]) {
|
|
29795
|
+
opts.compress = false;
|
|
29796
|
+
}
|
|
29797
|
+
this._sender.send(data || EMPTY_BUFFER, opts, cb);
|
|
29798
|
+
}
|
|
29799
|
+
/**
|
|
29800
|
+
* Forcibly close the connection.
|
|
29801
|
+
*
|
|
29802
|
+
* @public
|
|
29803
|
+
*/
|
|
29804
|
+
terminate() {
|
|
29805
|
+
if (this.readyState === _WebSocket.CLOSED) return;
|
|
29806
|
+
if (this.readyState === _WebSocket.CONNECTING) {
|
|
29807
|
+
const msg = "WebSocket was closed before the connection was established";
|
|
29808
|
+
abortHandshake(this, this._req, msg);
|
|
29809
|
+
return;
|
|
29810
|
+
}
|
|
29811
|
+
if (this._socket) {
|
|
29812
|
+
this._readyState = _WebSocket.CLOSING;
|
|
29813
|
+
this._socket.destroy();
|
|
29814
|
+
}
|
|
29815
|
+
}
|
|
29816
|
+
};
|
|
29817
|
+
Object.defineProperty(WebSocket2, "CONNECTING", {
|
|
29818
|
+
enumerable: true,
|
|
29819
|
+
value: readyStates.indexOf("CONNECTING")
|
|
29820
|
+
});
|
|
29821
|
+
Object.defineProperty(WebSocket2.prototype, "CONNECTING", {
|
|
29822
|
+
enumerable: true,
|
|
29823
|
+
value: readyStates.indexOf("CONNECTING")
|
|
29824
|
+
});
|
|
29825
|
+
Object.defineProperty(WebSocket2, "OPEN", {
|
|
29826
|
+
enumerable: true,
|
|
29827
|
+
value: readyStates.indexOf("OPEN")
|
|
29828
|
+
});
|
|
29829
|
+
Object.defineProperty(WebSocket2.prototype, "OPEN", {
|
|
29830
|
+
enumerable: true,
|
|
29831
|
+
value: readyStates.indexOf("OPEN")
|
|
29832
|
+
});
|
|
29833
|
+
Object.defineProperty(WebSocket2, "CLOSING", {
|
|
29834
|
+
enumerable: true,
|
|
29835
|
+
value: readyStates.indexOf("CLOSING")
|
|
29836
|
+
});
|
|
29837
|
+
Object.defineProperty(WebSocket2.prototype, "CLOSING", {
|
|
29838
|
+
enumerable: true,
|
|
29839
|
+
value: readyStates.indexOf("CLOSING")
|
|
29840
|
+
});
|
|
29841
|
+
Object.defineProperty(WebSocket2, "CLOSED", {
|
|
29842
|
+
enumerable: true,
|
|
29843
|
+
value: readyStates.indexOf("CLOSED")
|
|
29844
|
+
});
|
|
29845
|
+
Object.defineProperty(WebSocket2.prototype, "CLOSED", {
|
|
29846
|
+
enumerable: true,
|
|
29847
|
+
value: readyStates.indexOf("CLOSED")
|
|
29848
|
+
});
|
|
29849
|
+
[
|
|
29850
|
+
"binaryType",
|
|
29851
|
+
"bufferedAmount",
|
|
29852
|
+
"extensions",
|
|
29853
|
+
"isPaused",
|
|
29854
|
+
"protocol",
|
|
29855
|
+
"readyState",
|
|
29856
|
+
"url"
|
|
29857
|
+
].forEach((property) => {
|
|
29858
|
+
Object.defineProperty(WebSocket2.prototype, property, {
|
|
29859
|
+
enumerable: true
|
|
29860
|
+
});
|
|
29861
|
+
});
|
|
29862
|
+
[
|
|
29863
|
+
"open",
|
|
29864
|
+
"error",
|
|
29865
|
+
"close",
|
|
29866
|
+
"message"
|
|
29867
|
+
].forEach((method) => {
|
|
29868
|
+
Object.defineProperty(WebSocket2.prototype, `on${method}`, {
|
|
29869
|
+
enumerable: true,
|
|
29870
|
+
get() {
|
|
29871
|
+
for (const listener of this.listeners(method)) {
|
|
29872
|
+
if (listener[kForOnEventAttribute]) return listener[kListener];
|
|
29873
|
+
}
|
|
29874
|
+
return null;
|
|
29875
|
+
},
|
|
29876
|
+
set(handler) {
|
|
29877
|
+
for (const listener of this.listeners(method)) {
|
|
29878
|
+
if (listener[kForOnEventAttribute]) {
|
|
29879
|
+
this.removeListener(method, listener);
|
|
29880
|
+
break;
|
|
29881
|
+
}
|
|
29882
|
+
}
|
|
29883
|
+
if (typeof handler !== "function") return;
|
|
29884
|
+
this.addEventListener(method, handler, {
|
|
29885
|
+
[kForOnEventAttribute]: true
|
|
29886
|
+
});
|
|
29887
|
+
}
|
|
29888
|
+
});
|
|
29889
|
+
});
|
|
29890
|
+
WebSocket2.prototype.addEventListener = addEventListener;
|
|
29891
|
+
WebSocket2.prototype.removeEventListener = removeEventListener;
|
|
29892
|
+
module.exports = WebSocket2;
|
|
29893
|
+
function initAsClient(websocket, address, protocols, options) {
|
|
29894
|
+
const opts = {
|
|
29895
|
+
allowSynchronousEvents: true,
|
|
29896
|
+
autoPong: true,
|
|
29897
|
+
closeTimeout: CLOSE_TIMEOUT,
|
|
29898
|
+
protocolVersion: protocolVersions[1],
|
|
29899
|
+
maxPayload: 100 * 1024 * 1024,
|
|
29900
|
+
skipUTF8Validation: false,
|
|
29901
|
+
perMessageDeflate: true,
|
|
29902
|
+
followRedirects: false,
|
|
29903
|
+
maxRedirects: 10,
|
|
29904
|
+
...options,
|
|
29905
|
+
socketPath: void 0,
|
|
29906
|
+
hostname: void 0,
|
|
29907
|
+
protocol: void 0,
|
|
29908
|
+
timeout: void 0,
|
|
29909
|
+
method: "GET",
|
|
29910
|
+
host: void 0,
|
|
29911
|
+
path: void 0,
|
|
29912
|
+
port: void 0
|
|
29913
|
+
};
|
|
29914
|
+
websocket._autoPong = opts.autoPong;
|
|
29915
|
+
websocket._closeTimeout = opts.closeTimeout;
|
|
29916
|
+
if (!protocolVersions.includes(opts.protocolVersion)) {
|
|
29917
|
+
throw new RangeError(`Unsupported protocol version: ${opts.protocolVersion} (supported versions: ${protocolVersions.join(", ")})`);
|
|
29918
|
+
}
|
|
29919
|
+
let parsedUrl;
|
|
29920
|
+
if (address instanceof URL2) {
|
|
29921
|
+
parsedUrl = address;
|
|
29922
|
+
} else {
|
|
29923
|
+
try {
|
|
29924
|
+
parsedUrl = new URL2(address);
|
|
29925
|
+
} catch {
|
|
29926
|
+
throw new SyntaxError(`Invalid URL: ${address}`);
|
|
29927
|
+
}
|
|
29928
|
+
}
|
|
29929
|
+
if (parsedUrl.protocol === "http:") {
|
|
29930
|
+
parsedUrl.protocol = "ws:";
|
|
29931
|
+
} else if (parsedUrl.protocol === "https:") {
|
|
29932
|
+
parsedUrl.protocol = "wss:";
|
|
29933
|
+
}
|
|
29934
|
+
websocket._url = parsedUrl.href;
|
|
29935
|
+
const isSecure = parsedUrl.protocol === "wss:";
|
|
29936
|
+
const isIpcUrl = parsedUrl.protocol === "ws+unix:";
|
|
29937
|
+
let invalidUrlMessage;
|
|
29938
|
+
if (parsedUrl.protocol !== "ws:" && !isSecure && !isIpcUrl) {
|
|
29939
|
+
invalidUrlMessage = `The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`;
|
|
29940
|
+
} else if (isIpcUrl && !parsedUrl.pathname) {
|
|
29941
|
+
invalidUrlMessage = "The URL's pathname is empty";
|
|
29942
|
+
} else if (parsedUrl.hash) {
|
|
29943
|
+
invalidUrlMessage = "The URL contains a fragment identifier";
|
|
29944
|
+
}
|
|
29945
|
+
if (invalidUrlMessage) {
|
|
29946
|
+
const err = new SyntaxError(invalidUrlMessage);
|
|
29947
|
+
if (websocket._redirects === 0) {
|
|
29948
|
+
throw err;
|
|
29949
|
+
} else {
|
|
29950
|
+
emitErrorAndClose(websocket, err);
|
|
29951
|
+
return;
|
|
29952
|
+
}
|
|
29953
|
+
}
|
|
29954
|
+
const defaultPort = isSecure ? 443 : 80;
|
|
29955
|
+
const key = randomBytes(16).toString("base64");
|
|
29956
|
+
const request = isSecure ? https.request : http.request;
|
|
29957
|
+
const protocolSet = /* @__PURE__ */ new Set();
|
|
29958
|
+
let perMessageDeflate;
|
|
29959
|
+
opts.createConnection = opts.createConnection || (isSecure ? tlsConnect : netConnect);
|
|
29960
|
+
opts.defaultPort = opts.defaultPort || defaultPort;
|
|
29961
|
+
opts.port = parsedUrl.port || defaultPort;
|
|
29962
|
+
opts.host = parsedUrl.hostname.startsWith("[") ? parsedUrl.hostname.slice(1, -1) : parsedUrl.hostname;
|
|
29963
|
+
opts.headers = {
|
|
29964
|
+
...opts.headers,
|
|
29965
|
+
"Sec-WebSocket-Version": opts.protocolVersion,
|
|
29966
|
+
"Sec-WebSocket-Key": key,
|
|
29967
|
+
Connection: "Upgrade",
|
|
29968
|
+
Upgrade: "websocket"
|
|
29969
|
+
};
|
|
29970
|
+
opts.path = parsedUrl.pathname + parsedUrl.search;
|
|
29971
|
+
opts.timeout = opts.handshakeTimeout;
|
|
29972
|
+
if (opts.perMessageDeflate) {
|
|
29973
|
+
perMessageDeflate = new PerMessageDeflate2({
|
|
29974
|
+
...opts.perMessageDeflate,
|
|
29975
|
+
isServer: false,
|
|
29976
|
+
maxPayload: opts.maxPayload
|
|
29977
|
+
});
|
|
29978
|
+
opts.headers["Sec-WebSocket-Extensions"] = format({
|
|
29979
|
+
[PerMessageDeflate2.extensionName]: perMessageDeflate.offer()
|
|
29980
|
+
});
|
|
29981
|
+
}
|
|
29982
|
+
if (protocols.length) {
|
|
29983
|
+
for (const protocol of protocols) {
|
|
29984
|
+
if (typeof protocol !== "string" || !subprotocolRegex.test(protocol) || protocolSet.has(protocol)) {
|
|
29985
|
+
throw new SyntaxError("An invalid or duplicated subprotocol was specified");
|
|
29986
|
+
}
|
|
29987
|
+
protocolSet.add(protocol);
|
|
29988
|
+
}
|
|
29989
|
+
opts.headers["Sec-WebSocket-Protocol"] = protocols.join(",");
|
|
29990
|
+
}
|
|
29991
|
+
if (opts.origin) {
|
|
29992
|
+
if (opts.protocolVersion < 13) {
|
|
29993
|
+
opts.headers["Sec-WebSocket-Origin"] = opts.origin;
|
|
29994
|
+
} else {
|
|
29995
|
+
opts.headers.Origin = opts.origin;
|
|
29996
|
+
}
|
|
29997
|
+
}
|
|
29998
|
+
if (parsedUrl.username || parsedUrl.password) {
|
|
29999
|
+
opts.auth = `${parsedUrl.username}:${parsedUrl.password}`;
|
|
30000
|
+
}
|
|
30001
|
+
if (isIpcUrl) {
|
|
30002
|
+
const parts = opts.path.split(":");
|
|
30003
|
+
opts.socketPath = parts[0];
|
|
30004
|
+
opts.path = parts[1];
|
|
30005
|
+
}
|
|
30006
|
+
let req;
|
|
30007
|
+
if (opts.followRedirects) {
|
|
30008
|
+
if (websocket._redirects === 0) {
|
|
30009
|
+
websocket._originalIpc = isIpcUrl;
|
|
30010
|
+
websocket._originalSecure = isSecure;
|
|
30011
|
+
websocket._originalHostOrSocketPath = isIpcUrl ? opts.socketPath : parsedUrl.host;
|
|
30012
|
+
const headers = options && options.headers;
|
|
30013
|
+
options = {
|
|
30014
|
+
...options,
|
|
30015
|
+
headers: {}
|
|
30016
|
+
};
|
|
30017
|
+
if (headers) {
|
|
30018
|
+
for (const [key2, value] of Object.entries(headers)) {
|
|
30019
|
+
options.headers[key2.toLowerCase()] = value;
|
|
30020
|
+
}
|
|
30021
|
+
}
|
|
30022
|
+
} else if (websocket.listenerCount("redirect") === 0) {
|
|
30023
|
+
const isSameHost = isIpcUrl ? websocket._originalIpc ? opts.socketPath === websocket._originalHostOrSocketPath : false : websocket._originalIpc ? false : parsedUrl.host === websocket._originalHostOrSocketPath;
|
|
30024
|
+
if (!isSameHost || websocket._originalSecure && !isSecure) {
|
|
30025
|
+
delete opts.headers.authorization;
|
|
30026
|
+
delete opts.headers.cookie;
|
|
30027
|
+
if (!isSameHost) delete opts.headers.host;
|
|
30028
|
+
opts.auth = void 0;
|
|
30029
|
+
}
|
|
30030
|
+
}
|
|
30031
|
+
if (opts.auth && !options.headers.authorization) {
|
|
30032
|
+
options.headers.authorization = "Basic " + Buffer.from(opts.auth).toString("base64");
|
|
30033
|
+
}
|
|
30034
|
+
req = websocket._req = request(opts);
|
|
30035
|
+
if (websocket._redirects) {
|
|
30036
|
+
websocket.emit("redirect", websocket.url, req);
|
|
30037
|
+
}
|
|
30038
|
+
} else {
|
|
30039
|
+
req = websocket._req = request(opts);
|
|
30040
|
+
}
|
|
30041
|
+
if (opts.timeout) {
|
|
30042
|
+
req.on("timeout", () => {
|
|
30043
|
+
abortHandshake(websocket, req, "Opening handshake has timed out");
|
|
30044
|
+
});
|
|
30045
|
+
}
|
|
30046
|
+
req.on("error", (err) => {
|
|
30047
|
+
if (req === null || req[kAborted]) return;
|
|
30048
|
+
req = websocket._req = null;
|
|
30049
|
+
emitErrorAndClose(websocket, err);
|
|
30050
|
+
});
|
|
30051
|
+
req.on("response", (res) => {
|
|
30052
|
+
const location = res.headers.location;
|
|
30053
|
+
const statusCode = res.statusCode;
|
|
30054
|
+
if (location && opts.followRedirects && statusCode >= 300 && statusCode < 400) {
|
|
30055
|
+
if (++websocket._redirects > opts.maxRedirects) {
|
|
30056
|
+
abortHandshake(websocket, req, "Maximum redirects exceeded");
|
|
30057
|
+
return;
|
|
30058
|
+
}
|
|
30059
|
+
req.abort();
|
|
30060
|
+
let addr;
|
|
30061
|
+
try {
|
|
30062
|
+
addr = new URL2(location, address);
|
|
30063
|
+
} catch (e) {
|
|
30064
|
+
const err = new SyntaxError(`Invalid URL: ${location}`);
|
|
30065
|
+
emitErrorAndClose(websocket, err);
|
|
30066
|
+
return;
|
|
30067
|
+
}
|
|
30068
|
+
initAsClient(websocket, addr, protocols, options);
|
|
30069
|
+
} else if (!websocket.emit("unexpected-response", req, res)) {
|
|
30070
|
+
abortHandshake(websocket, req, `Unexpected server response: ${res.statusCode}`);
|
|
30071
|
+
}
|
|
30072
|
+
});
|
|
30073
|
+
req.on("upgrade", (res, socket, head) => {
|
|
30074
|
+
websocket.emit("upgrade", res);
|
|
30075
|
+
if (websocket.readyState !== WebSocket2.CONNECTING) return;
|
|
30076
|
+
req = websocket._req = null;
|
|
30077
|
+
const upgrade = res.headers.upgrade;
|
|
30078
|
+
if (upgrade === void 0 || upgrade.toLowerCase() !== "websocket") {
|
|
30079
|
+
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
30080
|
+
return;
|
|
30081
|
+
}
|
|
30082
|
+
const digest = createHash("sha1").update(key + GUID).digest("base64");
|
|
30083
|
+
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
30084
|
+
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
30085
|
+
return;
|
|
30086
|
+
}
|
|
30087
|
+
const serverProt = res.headers["sec-websocket-protocol"];
|
|
30088
|
+
let protError;
|
|
30089
|
+
if (serverProt !== void 0) {
|
|
30090
|
+
if (!protocolSet.size) {
|
|
30091
|
+
protError = "Server sent a subprotocol but none was requested";
|
|
30092
|
+
} else if (!protocolSet.has(serverProt)) {
|
|
30093
|
+
protError = "Server sent an invalid subprotocol";
|
|
30094
|
+
}
|
|
30095
|
+
} else if (protocolSet.size) {
|
|
30096
|
+
protError = "Server sent no subprotocol";
|
|
30097
|
+
}
|
|
30098
|
+
if (protError) {
|
|
30099
|
+
abortHandshake(websocket, socket, protError);
|
|
30100
|
+
return;
|
|
30101
|
+
}
|
|
30102
|
+
if (serverProt) websocket._protocol = serverProt;
|
|
30103
|
+
const secWebSocketExtensions = res.headers["sec-websocket-extensions"];
|
|
30104
|
+
if (secWebSocketExtensions !== void 0) {
|
|
30105
|
+
if (!perMessageDeflate) {
|
|
30106
|
+
const message = "Server sent a Sec-WebSocket-Extensions header but no extension was requested";
|
|
30107
|
+
abortHandshake(websocket, socket, message);
|
|
30108
|
+
return;
|
|
30109
|
+
}
|
|
30110
|
+
let extensions;
|
|
30111
|
+
try {
|
|
30112
|
+
extensions = parse4(secWebSocketExtensions);
|
|
30113
|
+
} catch (err) {
|
|
30114
|
+
const message = "Invalid Sec-WebSocket-Extensions header";
|
|
30115
|
+
abortHandshake(websocket, socket, message);
|
|
30116
|
+
return;
|
|
30117
|
+
}
|
|
30118
|
+
const extensionNames = Object.keys(extensions);
|
|
30119
|
+
if (extensionNames.length !== 1 || extensionNames[0] !== PerMessageDeflate2.extensionName) {
|
|
30120
|
+
const message = "Server indicated an extension that was not requested";
|
|
30121
|
+
abortHandshake(websocket, socket, message);
|
|
30122
|
+
return;
|
|
30123
|
+
}
|
|
30124
|
+
try {
|
|
30125
|
+
perMessageDeflate.accept(extensions[PerMessageDeflate2.extensionName]);
|
|
30126
|
+
} catch (err) {
|
|
30127
|
+
const message = "Invalid Sec-WebSocket-Extensions header";
|
|
30128
|
+
abortHandshake(websocket, socket, message);
|
|
30129
|
+
return;
|
|
30130
|
+
}
|
|
30131
|
+
websocket._extensions[PerMessageDeflate2.extensionName] = perMessageDeflate;
|
|
30132
|
+
}
|
|
30133
|
+
websocket.setSocket(socket, head, {
|
|
30134
|
+
allowSynchronousEvents: opts.allowSynchronousEvents,
|
|
30135
|
+
generateMask: opts.generateMask,
|
|
30136
|
+
maxPayload: opts.maxPayload,
|
|
30137
|
+
skipUTF8Validation: opts.skipUTF8Validation
|
|
30138
|
+
});
|
|
30139
|
+
});
|
|
30140
|
+
if (opts.finishRequest) {
|
|
30141
|
+
opts.finishRequest(req, websocket);
|
|
30142
|
+
} else {
|
|
30143
|
+
req.end();
|
|
30144
|
+
}
|
|
30145
|
+
}
|
|
30146
|
+
__name(initAsClient, "initAsClient");
|
|
30147
|
+
function emitErrorAndClose(websocket, err) {
|
|
30148
|
+
websocket._readyState = WebSocket2.CLOSING;
|
|
30149
|
+
websocket._errorEmitted = true;
|
|
30150
|
+
websocket.emit("error", err);
|
|
30151
|
+
websocket.emitClose();
|
|
30152
|
+
}
|
|
30153
|
+
__name(emitErrorAndClose, "emitErrorAndClose");
|
|
30154
|
+
function netConnect(options) {
|
|
30155
|
+
options.path = options.socketPath;
|
|
30156
|
+
return net.connect(options);
|
|
30157
|
+
}
|
|
30158
|
+
__name(netConnect, "netConnect");
|
|
30159
|
+
function tlsConnect(options) {
|
|
30160
|
+
options.path = void 0;
|
|
30161
|
+
if (!options.servername && options.servername !== "") {
|
|
30162
|
+
options.servername = net.isIP(options.host) ? "" : options.host;
|
|
30163
|
+
}
|
|
30164
|
+
return tls.connect(options);
|
|
30165
|
+
}
|
|
30166
|
+
__name(tlsConnect, "tlsConnect");
|
|
30167
|
+
function abortHandshake(websocket, stream, message) {
|
|
30168
|
+
websocket._readyState = WebSocket2.CLOSING;
|
|
30169
|
+
const err = new Error(message);
|
|
30170
|
+
Error.captureStackTrace(err, abortHandshake);
|
|
30171
|
+
if (stream.setHeader) {
|
|
30172
|
+
stream[kAborted] = true;
|
|
30173
|
+
stream.abort();
|
|
30174
|
+
if (stream.socket && !stream.socket.destroyed) {
|
|
30175
|
+
stream.socket.destroy();
|
|
30176
|
+
}
|
|
30177
|
+
process.nextTick(emitErrorAndClose, websocket, err);
|
|
30178
|
+
} else {
|
|
30179
|
+
stream.destroy(err);
|
|
30180
|
+
stream.once("error", websocket.emit.bind(websocket, "error"));
|
|
30181
|
+
stream.once("close", websocket.emitClose.bind(websocket));
|
|
30182
|
+
}
|
|
30183
|
+
}
|
|
30184
|
+
__name(abortHandshake, "abortHandshake");
|
|
30185
|
+
function sendAfterClose(websocket, data, cb) {
|
|
30186
|
+
if (data) {
|
|
30187
|
+
const length = isBlob(data) ? data.size : toBuffer(data).length;
|
|
30188
|
+
if (websocket._socket) websocket._sender._bufferedBytes += length;
|
|
30189
|
+
else websocket._bufferedAmount += length;
|
|
30190
|
+
}
|
|
30191
|
+
if (cb) {
|
|
30192
|
+
const err = new Error(`WebSocket is not open: readyState ${websocket.readyState} (${readyStates[websocket.readyState]})`);
|
|
30193
|
+
process.nextTick(cb, err);
|
|
30194
|
+
}
|
|
30195
|
+
}
|
|
30196
|
+
__name(sendAfterClose, "sendAfterClose");
|
|
30197
|
+
function receiverOnConclude(code2, reason) {
|
|
30198
|
+
const websocket = this[kWebSocket];
|
|
30199
|
+
websocket._closeFrameReceived = true;
|
|
30200
|
+
websocket._closeMessage = reason;
|
|
30201
|
+
websocket._closeCode = code2;
|
|
30202
|
+
if (websocket._socket[kWebSocket] === void 0) return;
|
|
30203
|
+
websocket._socket.removeListener("data", socketOnData);
|
|
30204
|
+
process.nextTick(resume, websocket._socket);
|
|
30205
|
+
if (code2 === 1005) websocket.close();
|
|
30206
|
+
else websocket.close(code2, reason);
|
|
30207
|
+
}
|
|
30208
|
+
__name(receiverOnConclude, "receiverOnConclude");
|
|
30209
|
+
function receiverOnDrain() {
|
|
30210
|
+
const websocket = this[kWebSocket];
|
|
30211
|
+
if (!websocket.isPaused) websocket._socket.resume();
|
|
30212
|
+
}
|
|
30213
|
+
__name(receiverOnDrain, "receiverOnDrain");
|
|
30214
|
+
function receiverOnError(err) {
|
|
30215
|
+
const websocket = this[kWebSocket];
|
|
30216
|
+
if (websocket._socket[kWebSocket] !== void 0) {
|
|
30217
|
+
websocket._socket.removeListener("data", socketOnData);
|
|
30218
|
+
process.nextTick(resume, websocket._socket);
|
|
30219
|
+
websocket.close(err[kStatusCode]);
|
|
30220
|
+
}
|
|
30221
|
+
if (!websocket._errorEmitted) {
|
|
30222
|
+
websocket._errorEmitted = true;
|
|
30223
|
+
websocket.emit("error", err);
|
|
30224
|
+
}
|
|
30225
|
+
}
|
|
30226
|
+
__name(receiverOnError, "receiverOnError");
|
|
30227
|
+
function receiverOnFinish() {
|
|
30228
|
+
this[kWebSocket].emitClose();
|
|
30229
|
+
}
|
|
30230
|
+
__name(receiverOnFinish, "receiverOnFinish");
|
|
30231
|
+
function receiverOnMessage(data, isBinary) {
|
|
30232
|
+
this[kWebSocket].emit("message", data, isBinary);
|
|
30233
|
+
}
|
|
30234
|
+
__name(receiverOnMessage, "receiverOnMessage");
|
|
30235
|
+
function receiverOnPing(data) {
|
|
30236
|
+
const websocket = this[kWebSocket];
|
|
30237
|
+
if (websocket._autoPong) websocket.pong(data, !this._isServer, NOOP);
|
|
30238
|
+
websocket.emit("ping", data);
|
|
30239
|
+
}
|
|
30240
|
+
__name(receiverOnPing, "receiverOnPing");
|
|
30241
|
+
function receiverOnPong(data) {
|
|
30242
|
+
this[kWebSocket].emit("pong", data);
|
|
30243
|
+
}
|
|
30244
|
+
__name(receiverOnPong, "receiverOnPong");
|
|
30245
|
+
function resume(stream) {
|
|
30246
|
+
stream.resume();
|
|
30247
|
+
}
|
|
30248
|
+
__name(resume, "resume");
|
|
30249
|
+
function senderOnError(err) {
|
|
30250
|
+
const websocket = this[kWebSocket];
|
|
30251
|
+
if (websocket.readyState === WebSocket2.CLOSED) return;
|
|
30252
|
+
if (websocket.readyState === WebSocket2.OPEN) {
|
|
30253
|
+
websocket._readyState = WebSocket2.CLOSING;
|
|
30254
|
+
setCloseTimer(websocket);
|
|
30255
|
+
}
|
|
30256
|
+
this._socket.end();
|
|
30257
|
+
if (!websocket._errorEmitted) {
|
|
30258
|
+
websocket._errorEmitted = true;
|
|
30259
|
+
websocket.emit("error", err);
|
|
30260
|
+
}
|
|
30261
|
+
}
|
|
30262
|
+
__name(senderOnError, "senderOnError");
|
|
30263
|
+
function setCloseTimer(websocket) {
|
|
30264
|
+
websocket._closeTimer = setTimeout(websocket._socket.destroy.bind(websocket._socket), websocket._closeTimeout);
|
|
30265
|
+
}
|
|
30266
|
+
__name(setCloseTimer, "setCloseTimer");
|
|
30267
|
+
function socketOnClose() {
|
|
30268
|
+
const websocket = this[kWebSocket];
|
|
30269
|
+
this.removeListener("close", socketOnClose);
|
|
30270
|
+
this.removeListener("data", socketOnData);
|
|
30271
|
+
this.removeListener("end", socketOnEnd);
|
|
30272
|
+
websocket._readyState = WebSocket2.CLOSING;
|
|
30273
|
+
if (!this._readableState.endEmitted && !websocket._closeFrameReceived && !websocket._receiver._writableState.errorEmitted && this._readableState.length !== 0) {
|
|
30274
|
+
const chunk = this.read(this._readableState.length);
|
|
30275
|
+
websocket._receiver.write(chunk);
|
|
30276
|
+
}
|
|
30277
|
+
websocket._receiver.end();
|
|
30278
|
+
this[kWebSocket] = void 0;
|
|
30279
|
+
clearTimeout(websocket._closeTimer);
|
|
30280
|
+
if (websocket._receiver._writableState.finished || websocket._receiver._writableState.errorEmitted) {
|
|
30281
|
+
websocket.emitClose();
|
|
30282
|
+
} else {
|
|
30283
|
+
websocket._receiver.on("error", receiverOnFinish);
|
|
30284
|
+
websocket._receiver.on("finish", receiverOnFinish);
|
|
30285
|
+
}
|
|
30286
|
+
}
|
|
30287
|
+
__name(socketOnClose, "socketOnClose");
|
|
30288
|
+
function socketOnData(chunk) {
|
|
30289
|
+
if (!this[kWebSocket]._receiver.write(chunk)) {
|
|
30290
|
+
this.pause();
|
|
30291
|
+
}
|
|
30292
|
+
}
|
|
30293
|
+
__name(socketOnData, "socketOnData");
|
|
30294
|
+
function socketOnEnd() {
|
|
30295
|
+
const websocket = this[kWebSocket];
|
|
30296
|
+
websocket._readyState = WebSocket2.CLOSING;
|
|
30297
|
+
websocket._receiver.end();
|
|
30298
|
+
this.end();
|
|
30299
|
+
}
|
|
30300
|
+
__name(socketOnEnd, "socketOnEnd");
|
|
30301
|
+
function socketOnError() {
|
|
30302
|
+
const websocket = this[kWebSocket];
|
|
30303
|
+
this.removeListener("error", socketOnError);
|
|
30304
|
+
this.on("error", NOOP);
|
|
30305
|
+
if (websocket) {
|
|
30306
|
+
websocket._readyState = WebSocket2.CLOSING;
|
|
30307
|
+
this.destroy();
|
|
30308
|
+
}
|
|
30309
|
+
}
|
|
30310
|
+
__name(socketOnError, "socketOnError");
|
|
30311
|
+
}
|
|
30312
|
+
});
|
|
30313
|
+
|
|
30314
|
+
// ../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/websocket-server.js
|
|
30315
|
+
var require_websocket_server = __commonJS({
|
|
30316
|
+
"../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/websocket-server.js"(exports, module) {
|
|
30317
|
+
"use strict";
|
|
30318
|
+
var EventEmitter = __require("events");
|
|
30319
|
+
var http = __require("http");
|
|
30320
|
+
var { createHash } = __require("crypto");
|
|
30321
|
+
var extension2 = require_extension();
|
|
30322
|
+
var PerMessageDeflate2 = require_permessage_deflate();
|
|
30323
|
+
var subprotocol2 = require_subprotocol();
|
|
30324
|
+
var WebSocket2 = require_websocket();
|
|
30325
|
+
var { CLOSE_TIMEOUT, GUID, kWebSocket } = require_constants2();
|
|
30326
|
+
var keyRegex = /^[+/0-9A-Za-z]{22}==$/;
|
|
30327
|
+
var RUNNING = 0;
|
|
30328
|
+
var CLOSING = 1;
|
|
30329
|
+
var CLOSED = 2;
|
|
30330
|
+
var WebSocketServer2 = class extends EventEmitter {
|
|
30331
|
+
static {
|
|
30332
|
+
__name(this, "WebSocketServer");
|
|
30333
|
+
}
|
|
30334
|
+
/**
|
|
30335
|
+
* Create a `WebSocketServer` instance.
|
|
30336
|
+
*
|
|
30337
|
+
* @param {Object} options Configuration options
|
|
30338
|
+
* @param {Boolean} [options.allowSynchronousEvents=true] Specifies whether
|
|
30339
|
+
* any of the `'message'`, `'ping'`, and `'pong'` events can be emitted
|
|
30340
|
+
* multiple times in the same tick
|
|
30341
|
+
* @param {Boolean} [options.autoPong=true] Specifies whether or not to
|
|
30342
|
+
* automatically send a pong in response to a ping
|
|
30343
|
+
* @param {Number} [options.backlog=511] The maximum length of the queue of
|
|
30344
|
+
* pending connections
|
|
30345
|
+
* @param {Boolean} [options.clientTracking=true] Specifies whether or not to
|
|
30346
|
+
* track clients
|
|
30347
|
+
* @param {Number} [options.closeTimeout=30000] Duration in milliseconds to
|
|
30348
|
+
* wait for the closing handshake to finish after `websocket.close()` is
|
|
30349
|
+
* called
|
|
30350
|
+
* @param {Function} [options.handleProtocols] A hook to handle protocols
|
|
30351
|
+
* @param {String} [options.host] The hostname where to bind the server
|
|
30352
|
+
* @param {Number} [options.maxPayload=104857600] The maximum allowed message
|
|
30353
|
+
* size
|
|
30354
|
+
* @param {Boolean} [options.noServer=false] Enable no server mode
|
|
30355
|
+
* @param {String} [options.path] Accept only connections matching this path
|
|
30356
|
+
* @param {(Boolean|Object)} [options.perMessageDeflate=false] Enable/disable
|
|
30357
|
+
* permessage-deflate
|
|
30358
|
+
* @param {Number} [options.port] The port where to bind the server
|
|
30359
|
+
* @param {(http.Server|https.Server)} [options.server] A pre-created HTTP/S
|
|
30360
|
+
* server to use
|
|
30361
|
+
* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
|
|
30362
|
+
* not to skip UTF-8 validation for text and close messages
|
|
30363
|
+
* @param {Function} [options.verifyClient] A hook to reject connections
|
|
30364
|
+
* @param {Function} [options.WebSocket=WebSocket] Specifies the `WebSocket`
|
|
30365
|
+
* class to use. It must be the `WebSocket` class or class that extends it
|
|
30366
|
+
* @param {Function} [callback] A listener for the `listening` event
|
|
30367
|
+
*/
|
|
30368
|
+
constructor(options, callback) {
|
|
30369
|
+
super();
|
|
30370
|
+
options = {
|
|
30371
|
+
allowSynchronousEvents: true,
|
|
30372
|
+
autoPong: true,
|
|
30373
|
+
maxPayload: 100 * 1024 * 1024,
|
|
30374
|
+
skipUTF8Validation: false,
|
|
30375
|
+
perMessageDeflate: false,
|
|
30376
|
+
handleProtocols: null,
|
|
30377
|
+
clientTracking: true,
|
|
30378
|
+
closeTimeout: CLOSE_TIMEOUT,
|
|
30379
|
+
verifyClient: null,
|
|
30380
|
+
noServer: false,
|
|
30381
|
+
backlog: null,
|
|
30382
|
+
server: null,
|
|
30383
|
+
host: null,
|
|
30384
|
+
path: null,
|
|
30385
|
+
port: null,
|
|
30386
|
+
WebSocket: WebSocket2,
|
|
30387
|
+
...options
|
|
30388
|
+
};
|
|
30389
|
+
if (options.port == null && !options.server && !options.noServer || options.port != null && (options.server || options.noServer) || options.server && options.noServer) {
|
|
30390
|
+
throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');
|
|
30391
|
+
}
|
|
30392
|
+
if (options.port != null) {
|
|
30393
|
+
this._server = http.createServer((req, res) => {
|
|
30394
|
+
const body = http.STATUS_CODES[426];
|
|
30395
|
+
res.writeHead(426, {
|
|
30396
|
+
"Content-Length": body.length,
|
|
30397
|
+
"Content-Type": "text/plain"
|
|
30398
|
+
});
|
|
30399
|
+
res.end(body);
|
|
30400
|
+
});
|
|
30401
|
+
this._server.listen(options.port, options.host, options.backlog, callback);
|
|
30402
|
+
} else if (options.server) {
|
|
30403
|
+
this._server = options.server;
|
|
30404
|
+
}
|
|
30405
|
+
if (this._server) {
|
|
30406
|
+
const emitConnection = this.emit.bind(this, "connection");
|
|
30407
|
+
this._removeListeners = addListeners(this._server, {
|
|
30408
|
+
listening: this.emit.bind(this, "listening"),
|
|
30409
|
+
error: this.emit.bind(this, "error"),
|
|
30410
|
+
upgrade: /* @__PURE__ */ __name((req, socket, head) => {
|
|
30411
|
+
this.handleUpgrade(req, socket, head, emitConnection);
|
|
30412
|
+
}, "upgrade")
|
|
30413
|
+
});
|
|
30414
|
+
}
|
|
30415
|
+
if (options.perMessageDeflate === true) options.perMessageDeflate = {};
|
|
30416
|
+
if (options.clientTracking) {
|
|
30417
|
+
this.clients = /* @__PURE__ */ new Set();
|
|
30418
|
+
this._shouldEmitClose = false;
|
|
30419
|
+
}
|
|
30420
|
+
this.options = options;
|
|
30421
|
+
this._state = RUNNING;
|
|
30422
|
+
}
|
|
30423
|
+
/**
|
|
30424
|
+
* Returns the bound address, the address family name, and port of the server
|
|
30425
|
+
* as reported by the operating system if listening on an IP socket.
|
|
30426
|
+
* If the server is listening on a pipe or UNIX domain socket, the name is
|
|
30427
|
+
* returned as a string.
|
|
30428
|
+
*
|
|
30429
|
+
* @return {(Object|String|null)} The address of the server
|
|
30430
|
+
* @public
|
|
30431
|
+
*/
|
|
30432
|
+
address() {
|
|
30433
|
+
if (this.options.noServer) {
|
|
30434
|
+
throw new Error('The server is operating in "noServer" mode');
|
|
30435
|
+
}
|
|
30436
|
+
if (!this._server) return null;
|
|
30437
|
+
return this._server.address();
|
|
30438
|
+
}
|
|
30439
|
+
/**
|
|
30440
|
+
* Stop the server from accepting new connections and emit the `'close'` event
|
|
30441
|
+
* when all existing connections are closed.
|
|
30442
|
+
*
|
|
30443
|
+
* @param {Function} [cb] A one-time listener for the `'close'` event
|
|
30444
|
+
* @public
|
|
30445
|
+
*/
|
|
30446
|
+
close(cb) {
|
|
30447
|
+
if (this._state === CLOSED) {
|
|
30448
|
+
if (cb) {
|
|
30449
|
+
this.once("close", () => {
|
|
30450
|
+
cb(new Error("The server is not running"));
|
|
30451
|
+
});
|
|
30452
|
+
}
|
|
30453
|
+
process.nextTick(emitClose, this);
|
|
30454
|
+
return;
|
|
30455
|
+
}
|
|
30456
|
+
if (cb) this.once("close", cb);
|
|
30457
|
+
if (this._state === CLOSING) return;
|
|
30458
|
+
this._state = CLOSING;
|
|
30459
|
+
if (this.options.noServer || this.options.server) {
|
|
30460
|
+
if (this._server) {
|
|
30461
|
+
this._removeListeners();
|
|
30462
|
+
this._removeListeners = this._server = null;
|
|
30463
|
+
}
|
|
30464
|
+
if (this.clients) {
|
|
30465
|
+
if (!this.clients.size) {
|
|
30466
|
+
process.nextTick(emitClose, this);
|
|
30467
|
+
} else {
|
|
30468
|
+
this._shouldEmitClose = true;
|
|
30469
|
+
}
|
|
30470
|
+
} else {
|
|
30471
|
+
process.nextTick(emitClose, this);
|
|
30472
|
+
}
|
|
30473
|
+
} else {
|
|
30474
|
+
const server = this._server;
|
|
30475
|
+
this._removeListeners();
|
|
30476
|
+
this._removeListeners = this._server = null;
|
|
30477
|
+
server.close(() => {
|
|
30478
|
+
emitClose(this);
|
|
30479
|
+
});
|
|
30480
|
+
}
|
|
30481
|
+
}
|
|
30482
|
+
/**
|
|
30483
|
+
* See if a given request should be handled by this server instance.
|
|
30484
|
+
*
|
|
30485
|
+
* @param {http.IncomingMessage} req Request object to inspect
|
|
30486
|
+
* @return {Boolean} `true` if the request is valid, else `false`
|
|
30487
|
+
* @public
|
|
30488
|
+
*/
|
|
30489
|
+
shouldHandle(req) {
|
|
30490
|
+
if (this.options.path) {
|
|
30491
|
+
const index = req.url.indexOf("?");
|
|
30492
|
+
const pathname = index !== -1 ? req.url.slice(0, index) : req.url;
|
|
30493
|
+
if (pathname !== this.options.path) return false;
|
|
30494
|
+
}
|
|
30495
|
+
return true;
|
|
30496
|
+
}
|
|
30497
|
+
/**
|
|
30498
|
+
* Handle a HTTP Upgrade request.
|
|
30499
|
+
*
|
|
30500
|
+
* @param {http.IncomingMessage} req The request object
|
|
30501
|
+
* @param {Duplex} socket The network socket between the server and client
|
|
30502
|
+
* @param {Buffer} head The first packet of the upgraded stream
|
|
30503
|
+
* @param {Function} cb Callback
|
|
30504
|
+
* @public
|
|
30505
|
+
*/
|
|
30506
|
+
handleUpgrade(req, socket, head, cb) {
|
|
30507
|
+
socket.on("error", socketOnError);
|
|
30508
|
+
const key = req.headers["sec-websocket-key"];
|
|
30509
|
+
const upgrade = req.headers.upgrade;
|
|
30510
|
+
const version3 = +req.headers["sec-websocket-version"];
|
|
30511
|
+
if (req.method !== "GET") {
|
|
30512
|
+
const message = "Invalid HTTP method";
|
|
30513
|
+
abortHandshakeOrEmitwsClientError(this, req, socket, 405, message);
|
|
30514
|
+
return;
|
|
30515
|
+
}
|
|
30516
|
+
if (upgrade === void 0 || upgrade.toLowerCase() !== "websocket") {
|
|
30517
|
+
const message = "Invalid Upgrade header";
|
|
30518
|
+
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
30519
|
+
return;
|
|
30520
|
+
}
|
|
30521
|
+
if (key === void 0 || !keyRegex.test(key)) {
|
|
30522
|
+
const message = "Missing or invalid Sec-WebSocket-Key header";
|
|
30523
|
+
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
30524
|
+
return;
|
|
30525
|
+
}
|
|
30526
|
+
if (version3 !== 13 && version3 !== 8) {
|
|
30527
|
+
const message = "Missing or invalid Sec-WebSocket-Version header";
|
|
30528
|
+
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message, {
|
|
30529
|
+
"Sec-WebSocket-Version": "13, 8"
|
|
30530
|
+
});
|
|
30531
|
+
return;
|
|
30532
|
+
}
|
|
30533
|
+
if (!this.shouldHandle(req)) {
|
|
30534
|
+
abortHandshake(socket, 400);
|
|
30535
|
+
return;
|
|
30536
|
+
}
|
|
30537
|
+
const secWebSocketProtocol = req.headers["sec-websocket-protocol"];
|
|
30538
|
+
let protocols = /* @__PURE__ */ new Set();
|
|
30539
|
+
if (secWebSocketProtocol !== void 0) {
|
|
30540
|
+
try {
|
|
30541
|
+
protocols = subprotocol2.parse(secWebSocketProtocol);
|
|
30542
|
+
} catch (err) {
|
|
30543
|
+
const message = "Invalid Sec-WebSocket-Protocol header";
|
|
30544
|
+
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
30545
|
+
return;
|
|
30546
|
+
}
|
|
30547
|
+
}
|
|
30548
|
+
const secWebSocketExtensions = req.headers["sec-websocket-extensions"];
|
|
30549
|
+
const extensions = {};
|
|
30550
|
+
if (this.options.perMessageDeflate && secWebSocketExtensions !== void 0) {
|
|
30551
|
+
const perMessageDeflate = new PerMessageDeflate2({
|
|
30552
|
+
...this.options.perMessageDeflate,
|
|
30553
|
+
isServer: true,
|
|
30554
|
+
maxPayload: this.options.maxPayload
|
|
30555
|
+
});
|
|
30556
|
+
try {
|
|
30557
|
+
const offers = extension2.parse(secWebSocketExtensions);
|
|
30558
|
+
if (offers[PerMessageDeflate2.extensionName]) {
|
|
30559
|
+
perMessageDeflate.accept(offers[PerMessageDeflate2.extensionName]);
|
|
30560
|
+
extensions[PerMessageDeflate2.extensionName] = perMessageDeflate;
|
|
30561
|
+
}
|
|
30562
|
+
} catch (err) {
|
|
30563
|
+
const message = "Invalid or unacceptable Sec-WebSocket-Extensions header";
|
|
30564
|
+
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
30565
|
+
return;
|
|
30566
|
+
}
|
|
30567
|
+
}
|
|
30568
|
+
if (this.options.verifyClient) {
|
|
30569
|
+
const info = {
|
|
30570
|
+
origin: req.headers[`${version3 === 8 ? "sec-websocket-origin" : "origin"}`],
|
|
30571
|
+
secure: !!(req.socket.authorized || req.socket.encrypted),
|
|
30572
|
+
req
|
|
30573
|
+
};
|
|
30574
|
+
if (this.options.verifyClient.length === 2) {
|
|
30575
|
+
this.options.verifyClient(info, (verified, code2, message, headers) => {
|
|
30576
|
+
if (!verified) {
|
|
30577
|
+
return abortHandshake(socket, code2 || 401, message, headers);
|
|
30578
|
+
}
|
|
30579
|
+
this.completeUpgrade(extensions, key, protocols, req, socket, head, cb);
|
|
30580
|
+
});
|
|
30581
|
+
return;
|
|
30582
|
+
}
|
|
30583
|
+
if (!this.options.verifyClient(info)) return abortHandshake(socket, 401);
|
|
30584
|
+
}
|
|
30585
|
+
this.completeUpgrade(extensions, key, protocols, req, socket, head, cb);
|
|
30586
|
+
}
|
|
30587
|
+
/**
|
|
30588
|
+
* Upgrade the connection to WebSocket.
|
|
30589
|
+
*
|
|
30590
|
+
* @param {Object} extensions The accepted extensions
|
|
30591
|
+
* @param {String} key The value of the `Sec-WebSocket-Key` header
|
|
30592
|
+
* @param {Set} protocols The subprotocols
|
|
30593
|
+
* @param {http.IncomingMessage} req The request object
|
|
30594
|
+
* @param {Duplex} socket The network socket between the server and client
|
|
30595
|
+
* @param {Buffer} head The first packet of the upgraded stream
|
|
30596
|
+
* @param {Function} cb Callback
|
|
30597
|
+
* @throws {Error} If called more than once with the same socket
|
|
30598
|
+
* @private
|
|
30599
|
+
*/
|
|
30600
|
+
completeUpgrade(extensions, key, protocols, req, socket, head, cb) {
|
|
30601
|
+
if (!socket.readable || !socket.writable) return socket.destroy();
|
|
30602
|
+
if (socket[kWebSocket]) {
|
|
30603
|
+
throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");
|
|
30604
|
+
}
|
|
30605
|
+
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
30606
|
+
const digest = createHash("sha1").update(key + GUID).digest("base64");
|
|
30607
|
+
const headers = [
|
|
30608
|
+
"HTTP/1.1 101 Switching Protocols",
|
|
30609
|
+
"Upgrade: websocket",
|
|
30610
|
+
"Connection: Upgrade",
|
|
30611
|
+
`Sec-WebSocket-Accept: ${digest}`
|
|
30612
|
+
];
|
|
30613
|
+
const ws = new this.options.WebSocket(null, void 0, this.options);
|
|
30614
|
+
if (protocols.size) {
|
|
30615
|
+
const protocol = this.options.handleProtocols ? this.options.handleProtocols(protocols, req) : protocols.values().next().value;
|
|
30616
|
+
if (protocol) {
|
|
30617
|
+
headers.push(`Sec-WebSocket-Protocol: ${protocol}`);
|
|
30618
|
+
ws._protocol = protocol;
|
|
30619
|
+
}
|
|
30620
|
+
}
|
|
30621
|
+
if (extensions[PerMessageDeflate2.extensionName]) {
|
|
30622
|
+
const params = extensions[PerMessageDeflate2.extensionName].params;
|
|
30623
|
+
const value = extension2.format({
|
|
30624
|
+
[PerMessageDeflate2.extensionName]: [
|
|
30625
|
+
params
|
|
30626
|
+
]
|
|
30627
|
+
});
|
|
30628
|
+
headers.push(`Sec-WebSocket-Extensions: ${value}`);
|
|
30629
|
+
ws._extensions = extensions;
|
|
30630
|
+
}
|
|
30631
|
+
this.emit("headers", headers, req);
|
|
30632
|
+
socket.write(headers.concat("\r\n").join("\r\n"));
|
|
30633
|
+
socket.removeListener("error", socketOnError);
|
|
30634
|
+
ws.setSocket(socket, head, {
|
|
30635
|
+
allowSynchronousEvents: this.options.allowSynchronousEvents,
|
|
30636
|
+
maxPayload: this.options.maxPayload,
|
|
30637
|
+
skipUTF8Validation: this.options.skipUTF8Validation
|
|
30638
|
+
});
|
|
30639
|
+
if (this.clients) {
|
|
30640
|
+
this.clients.add(ws);
|
|
30641
|
+
ws.on("close", () => {
|
|
30642
|
+
this.clients.delete(ws);
|
|
30643
|
+
if (this._shouldEmitClose && !this.clients.size) {
|
|
30644
|
+
process.nextTick(emitClose, this);
|
|
30645
|
+
}
|
|
30646
|
+
});
|
|
30647
|
+
}
|
|
30648
|
+
cb(ws, req);
|
|
30649
|
+
}
|
|
30650
|
+
};
|
|
30651
|
+
module.exports = WebSocketServer2;
|
|
30652
|
+
function addListeners(server, map2) {
|
|
30653
|
+
for (const event of Object.keys(map2)) server.on(event, map2[event]);
|
|
30654
|
+
return /* @__PURE__ */ __name(function removeListeners() {
|
|
30655
|
+
for (const event of Object.keys(map2)) {
|
|
30656
|
+
server.removeListener(event, map2[event]);
|
|
30657
|
+
}
|
|
30658
|
+
}, "removeListeners");
|
|
30659
|
+
}
|
|
30660
|
+
__name(addListeners, "addListeners");
|
|
30661
|
+
function emitClose(server) {
|
|
30662
|
+
server._state = CLOSED;
|
|
30663
|
+
server.emit("close");
|
|
30664
|
+
}
|
|
30665
|
+
__name(emitClose, "emitClose");
|
|
30666
|
+
function socketOnError() {
|
|
30667
|
+
this.destroy();
|
|
30668
|
+
}
|
|
30669
|
+
__name(socketOnError, "socketOnError");
|
|
30670
|
+
function abortHandshake(socket, code2, message, headers) {
|
|
30671
|
+
message = message || http.STATUS_CODES[code2];
|
|
30672
|
+
headers = {
|
|
30673
|
+
Connection: "close",
|
|
30674
|
+
"Content-Type": "text/html",
|
|
30675
|
+
"Content-Length": Buffer.byteLength(message),
|
|
30676
|
+
...headers
|
|
30677
|
+
};
|
|
30678
|
+
socket.once("finish", socket.destroy);
|
|
30679
|
+
socket.end(`HTTP/1.1 ${code2} ${http.STATUS_CODES[code2]}\r
|
|
30680
|
+
` + Object.keys(headers).map((h) => `${h}: ${headers[h]}`).join("\r\n") + "\r\n\r\n" + message);
|
|
30681
|
+
}
|
|
30682
|
+
__name(abortHandshake, "abortHandshake");
|
|
30683
|
+
function abortHandshakeOrEmitwsClientError(server, req, socket, code2, message, headers) {
|
|
30684
|
+
if (server.listenerCount("wsClientError")) {
|
|
30685
|
+
const err = new Error(message);
|
|
30686
|
+
Error.captureStackTrace(err, abortHandshakeOrEmitwsClientError);
|
|
30687
|
+
server.emit("wsClientError", err, socket, req);
|
|
30688
|
+
} else {
|
|
30689
|
+
abortHandshake(socket, code2, message, headers);
|
|
30690
|
+
}
|
|
30691
|
+
}
|
|
30692
|
+
__name(abortHandshakeOrEmitwsClientError, "abortHandshakeOrEmitwsClientError");
|
|
30693
|
+
}
|
|
30694
|
+
});
|
|
30695
|
+
|
|
30696
|
+
// ../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/wrapper.mjs
|
|
30697
|
+
var wrapper_exports = {};
|
|
30698
|
+
__export(wrapper_exports, {
|
|
30699
|
+
PerMessageDeflate: () => import_permessage_deflate.default,
|
|
30700
|
+
Receiver: () => import_receiver.default,
|
|
30701
|
+
Sender: () => import_sender.default,
|
|
30702
|
+
WebSocket: () => import_websocket.default,
|
|
30703
|
+
WebSocketServer: () => import_websocket_server.default,
|
|
30704
|
+
createWebSocketStream: () => import_stream.default,
|
|
30705
|
+
default: () => wrapper_default,
|
|
30706
|
+
extension: () => import_extension.default,
|
|
30707
|
+
subprotocol: () => import_subprotocol.default
|
|
30708
|
+
});
|
|
30709
|
+
var import_stream, import_extension, import_permessage_deflate, import_receiver, import_sender, import_subprotocol, import_websocket, import_websocket_server, wrapper_default;
|
|
30710
|
+
var init_wrapper = __esm({
|
|
30711
|
+
"../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/wrapper.mjs"() {
|
|
30712
|
+
"use strict";
|
|
30713
|
+
import_stream = __toESM(require_stream(), 1);
|
|
30714
|
+
import_extension = __toESM(require_extension(), 1);
|
|
30715
|
+
import_permessage_deflate = __toESM(require_permessage_deflate(), 1);
|
|
30716
|
+
import_receiver = __toESM(require_receiver(), 1);
|
|
30717
|
+
import_sender = __toESM(require_sender(), 1);
|
|
30718
|
+
import_subprotocol = __toESM(require_subprotocol(), 1);
|
|
30719
|
+
import_websocket = __toESM(require_websocket(), 1);
|
|
30720
|
+
import_websocket_server = __toESM(require_websocket_server(), 1);
|
|
30721
|
+
wrapper_default = import_websocket.default;
|
|
30722
|
+
}
|
|
30723
|
+
});
|
|
30724
|
+
|
|
30725
|
+
// ../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/websocket/index.js
|
|
30726
|
+
var require_websocket2 = __commonJS({
|
|
30727
|
+
"../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/websocket/index.js"(exports, module) {
|
|
30728
|
+
"use strict";
|
|
30729
|
+
var __defProp2 = Object.defineProperty;
|
|
30730
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
30731
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
30732
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
30733
|
+
var __export2 = /* @__PURE__ */ __name((target, all) => {
|
|
30734
|
+
for (var name in all) __defProp2(target, name, {
|
|
30735
|
+
get: all[name],
|
|
30736
|
+
enumerable: true
|
|
30737
|
+
});
|
|
30738
|
+
}, "__export");
|
|
30739
|
+
var __copyProps2 = /* @__PURE__ */ __name((to, from, except, desc) => {
|
|
30740
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
30741
|
+
for (let key of __getOwnPropNames2(from)) if (!__hasOwnProp2.call(to, key) && key !== except) __defProp2(to, key, {
|
|
30742
|
+
get: /* @__PURE__ */ __name(() => from[key], "get"),
|
|
30743
|
+
enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable
|
|
30744
|
+
});
|
|
30745
|
+
}
|
|
30746
|
+
return to;
|
|
30747
|
+
}, "__copyProps");
|
|
30748
|
+
var __toCommonJS = /* @__PURE__ */ __name((mod) => __copyProps2(__defProp2({}, "__esModule", {
|
|
30749
|
+
value: true
|
|
30750
|
+
}), mod), "__toCommonJS");
|
|
30751
|
+
var websocket_exports = {};
|
|
30752
|
+
__export2(websocket_exports, {
|
|
30753
|
+
experimental_upgradeWebSocket: /* @__PURE__ */ __name(() => experimental_upgradeWebSocket2, "experimental_upgradeWebSocket")
|
|
30754
|
+
});
|
|
30755
|
+
module.exports = __toCommonJS(websocket_exports);
|
|
30756
|
+
var import_get_context = require_get_context();
|
|
30757
|
+
var DEFAULT_MAX_PAYLOAD = 256 * 1024;
|
|
30758
|
+
async function loadWebSocketServer() {
|
|
30759
|
+
try {
|
|
30760
|
+
const ws = await Promise.resolve().then(() => (init_wrapper(), wrapper_exports));
|
|
30761
|
+
return ws.WebSocketServer;
|
|
30762
|
+
} catch {
|
|
30763
|
+
throw new Error('The "ws" package is required for experimental_upgradeWebSocket(). Install it with: npm install ws');
|
|
30764
|
+
}
|
|
30765
|
+
}
|
|
30766
|
+
__name(loadWebSocketServer, "loadWebSocketServer");
|
|
30767
|
+
async function experimental_upgradeWebSocket2(handler, options = {}) {
|
|
30768
|
+
const ctx = (0, import_get_context.getContext)();
|
|
30769
|
+
if (typeof ctx.upgradeWebSocket !== "function") {
|
|
30770
|
+
throw new Error("experimental_upgradeWebSocket is not available in the current runtime environment. This feature requires a Vercel runtime that supports WebSocket upgrades.");
|
|
30771
|
+
}
|
|
30772
|
+
const WebSocketServer2 = await loadWebSocketServer();
|
|
30773
|
+
const { req, socket, head } = ctx.upgradeWebSocket();
|
|
30774
|
+
const wss = new WebSocketServer2({
|
|
30775
|
+
noServer: true,
|
|
30776
|
+
maxPayload: options.maxPayload ?? DEFAULT_MAX_PAYLOAD
|
|
30777
|
+
});
|
|
30778
|
+
const ws = await new Promise((resolve, reject) => {
|
|
30779
|
+
const cleanup = /* @__PURE__ */ __name(() => {
|
|
30780
|
+
socket.removeListener("error", onError);
|
|
30781
|
+
socket.removeListener("close", onClose);
|
|
30782
|
+
}, "cleanup");
|
|
30783
|
+
const rejectUpgrade = /* @__PURE__ */ __name((err) => {
|
|
30784
|
+
cleanup();
|
|
30785
|
+
if (err instanceof Error) {
|
|
30786
|
+
reject(err);
|
|
30787
|
+
return;
|
|
30788
|
+
}
|
|
30789
|
+
const error48 = new Error("WebSocket upgrade failed");
|
|
30790
|
+
error48.cause = err;
|
|
30791
|
+
reject(error48);
|
|
30792
|
+
}, "rejectUpgrade");
|
|
30793
|
+
const resolveUpgrade = /* @__PURE__ */ __name((ws2) => {
|
|
30794
|
+
cleanup();
|
|
30795
|
+
resolve(ws2);
|
|
30796
|
+
}, "resolveUpgrade");
|
|
30797
|
+
const onError = /* @__PURE__ */ __name((err) => rejectUpgrade(err), "onError");
|
|
30798
|
+
const onClose = /* @__PURE__ */ __name(() => rejectUpgrade(new Error("socket closed before the WebSocket upgrade completed")), "onClose");
|
|
30799
|
+
socket.once("error", onError);
|
|
30800
|
+
socket.once("close", onClose);
|
|
30801
|
+
try {
|
|
30802
|
+
wss.handleUpgrade(req, socket, head, resolveUpgrade);
|
|
30803
|
+
} catch (err) {
|
|
30804
|
+
rejectUpgrade(err);
|
|
30805
|
+
}
|
|
30806
|
+
});
|
|
30807
|
+
try {
|
|
30808
|
+
await handler(ws);
|
|
30809
|
+
} catch (err) {
|
|
30810
|
+
ws.close(1011, "WebSocket handler failed");
|
|
30811
|
+
throw err;
|
|
30812
|
+
}
|
|
30813
|
+
return new Response(null, {
|
|
30814
|
+
status: 204
|
|
30815
|
+
});
|
|
30816
|
+
}
|
|
30817
|
+
__name(experimental_upgradeWebSocket2, "experimental_upgradeWebSocket");
|
|
30818
|
+
}
|
|
30819
|
+
});
|
|
30820
|
+
|
|
30821
|
+
// ../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/index.js
|
|
30822
|
+
var require_functions = __commonJS({
|
|
30823
|
+
"../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/index.js"(exports, module) {
|
|
30824
|
+
"use strict";
|
|
30825
|
+
var __defProp2 = Object.defineProperty;
|
|
30826
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
30827
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
30828
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
30829
|
+
var __export2 = /* @__PURE__ */ __name((target, all) => {
|
|
30830
|
+
for (var name in all) __defProp2(target, name, {
|
|
30831
|
+
get: all[name],
|
|
30832
|
+
enumerable: true
|
|
30833
|
+
});
|
|
30834
|
+
}, "__export");
|
|
30835
|
+
var __copyProps2 = /* @__PURE__ */ __name((to, from, except, desc) => {
|
|
30836
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
30837
|
+
for (let key of __getOwnPropNames2(from)) if (!__hasOwnProp2.call(to, key) && key !== except) __defProp2(to, key, {
|
|
30838
|
+
get: /* @__PURE__ */ __name(() => from[key], "get"),
|
|
30839
|
+
enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable
|
|
30840
|
+
});
|
|
30841
|
+
}
|
|
30842
|
+
return to;
|
|
30843
|
+
}, "__copyProps");
|
|
30844
|
+
var __toCommonJS = /* @__PURE__ */ __name((mod) => __copyProps2(__defProp2({}, "__esModule", {
|
|
30845
|
+
value: true
|
|
30846
|
+
}), mod), "__toCommonJS");
|
|
30847
|
+
var src_exports = {};
|
|
30848
|
+
__export2(src_exports, {
|
|
30849
|
+
addCacheTag: /* @__PURE__ */ __name(() => import_addcachetag.addCacheTag, "addCacheTag"),
|
|
30850
|
+
attachDatabasePool: /* @__PURE__ */ __name(() => import_db_connections.attachDatabasePool, "attachDatabasePool"),
|
|
30851
|
+
dangerouslyDeleteBySrcImage: /* @__PURE__ */ __name(() => import_purge.dangerouslyDeleteBySrcImage, "dangerouslyDeleteBySrcImage"),
|
|
30852
|
+
dangerouslyDeleteByTag: /* @__PURE__ */ __name(() => import_purge.dangerouslyDeleteByTag, "dangerouslyDeleteByTag"),
|
|
30853
|
+
experimental_attachDatabasePool: /* @__PURE__ */ __name(() => import_db_connections.experimental_attachDatabasePool, "experimental_attachDatabasePool"),
|
|
30854
|
+
experimental_upgradeWebSocket: /* @__PURE__ */ __name(() => import_websocket2.experimental_upgradeWebSocket, "experimental_upgradeWebSocket"),
|
|
30855
|
+
geolocation: /* @__PURE__ */ __name(() => import_headers.geolocation, "geolocation"),
|
|
30856
|
+
getCache: /* @__PURE__ */ __name(() => import_cache.getCache, "getCache"),
|
|
30857
|
+
getDeadline: /* @__PURE__ */ __name(() => import_deadline.getDeadline, "getDeadline"),
|
|
30858
|
+
getEnv: /* @__PURE__ */ __name(() => import_get_env.getEnv, "getEnv"),
|
|
30859
|
+
invalidateBySrcImage: /* @__PURE__ */ __name(() => import_purge.invalidateBySrcImage, "invalidateBySrcImage"),
|
|
30860
|
+
invalidateByTag: /* @__PURE__ */ __name(() => import_purge.invalidateByTag, "invalidateByTag"),
|
|
30861
|
+
ipAddress: /* @__PURE__ */ __name(() => import_headers.ipAddress, "ipAddress"),
|
|
30862
|
+
next: /* @__PURE__ */ __name(() => import_middleware.next, "next"),
|
|
30863
|
+
rewrite: /* @__PURE__ */ __name(() => import_middleware.rewrite, "rewrite"),
|
|
30864
|
+
waitUntil: /* @__PURE__ */ __name(() => import_wait_until3.waitUntil, "waitUntil")
|
|
30865
|
+
});
|
|
30866
|
+
module.exports = __toCommonJS(src_exports);
|
|
30867
|
+
var import_headers = require_headers();
|
|
30868
|
+
var import_get_env = require_get_env();
|
|
30869
|
+
var import_deadline = require_deadline();
|
|
30870
|
+
var import_wait_until3 = require_wait_until();
|
|
30871
|
+
var import_middleware = require_middleware();
|
|
30872
|
+
var import_cache = require_cache();
|
|
30873
|
+
var import_db_connections = require_db_connections();
|
|
30874
|
+
var import_purge = require_purge();
|
|
30875
|
+
var import_addcachetag = require_addcachetag();
|
|
30876
|
+
var import_websocket2 = require_websocket2();
|
|
30877
|
+
}
|
|
30878
|
+
});
|
|
30879
|
+
|
|
30880
|
+
// ../core/dist/runtime/wait-until.js
|
|
30881
|
+
function waitUntil2(promise2) {
|
|
30882
|
+
void Promise.resolve().then(() => __toESM(require_functions(), 1)).then(({ waitUntil: waitUntil3 }) => {
|
|
30883
|
+
waitUntil3(promise2);
|
|
30884
|
+
});
|
|
30885
|
+
}
|
|
30886
|
+
function safeWaitUntil(promise2, onError) {
|
|
30887
|
+
waitUntil2(promise2.catch((err) => {
|
|
30888
|
+
const isAbortError = err?.name === "AbortError" || err?.name === "ResponseAborted";
|
|
30889
|
+
if (!isAbortError) {
|
|
30890
|
+
try {
|
|
30891
|
+
onError(err);
|
|
30892
|
+
} catch {
|
|
30893
|
+
}
|
|
30894
|
+
}
|
|
30895
|
+
}));
|
|
30896
|
+
}
|
|
30897
|
+
async function waitedUntil(fn) {
|
|
30898
|
+
const result = fn();
|
|
30899
|
+
waitUntil2(result.catch(() => {
|
|
30900
|
+
}));
|
|
30901
|
+
return result;
|
|
30902
|
+
}
|
|
30903
|
+
var init_wait_until = __esm({
|
|
30904
|
+
"../core/dist/runtime/wait-until.js"() {
|
|
30905
|
+
"use strict";
|
|
30906
|
+
__name(waitUntil2, "waitUntil");
|
|
30907
|
+
__name(safeWaitUntil, "safeWaitUntil");
|
|
30908
|
+
__name(waitedUntil, "waitedUntil");
|
|
30909
|
+
}
|
|
30910
|
+
});
|
|
30911
|
+
|
|
30912
|
+
// ../core/dist/runtime/resume-hook.js
|
|
30913
|
+
var resume_hook_exports = {};
|
|
30914
|
+
__export(resume_hook_exports, {
|
|
30915
|
+
getHookByToken: () => getHookByToken,
|
|
30916
|
+
resumeHook: () => resumeHook,
|
|
30917
|
+
resumeWebhook: () => resumeWebhook
|
|
30918
|
+
});
|
|
30919
|
+
async function computeResumePayloadDigest(bytes) {
|
|
30920
|
+
const digest = await crypto.subtle.digest("SHA-256", bytes);
|
|
30921
|
+
const view = new Uint8Array(digest);
|
|
30922
|
+
let hex3 = "";
|
|
30923
|
+
for (const b of view) {
|
|
30924
|
+
hex3 += b.toString(16).padStart(2, "0");
|
|
30925
|
+
}
|
|
30926
|
+
return hex3;
|
|
30927
|
+
}
|
|
30928
|
+
function resumeContextFromRun(run2) {
|
|
30929
|
+
const coreVersion = run2.executionContext?.workflowCoreVersion;
|
|
30930
|
+
const traceCarrier = run2.executionContext?.traceCarrier;
|
|
30931
|
+
const hookResumeInputVersion = run2.executionContext?.hookResumeInputVersion;
|
|
30932
|
+
return {
|
|
30933
|
+
deploymentId: run2.deploymentId,
|
|
30934
|
+
workflowName: run2.workflowName,
|
|
30935
|
+
runSpecVersion: run2.specVersion,
|
|
30936
|
+
workflowCoreVersion: typeof coreVersion === "string" ? coreVersion : void 0,
|
|
30937
|
+
traceCarrier: traceCarrier && typeof traceCarrier === "object" ? traceCarrier : void 0,
|
|
30938
|
+
encryptionPublicKey: run2.encryptionPublicKey,
|
|
30939
|
+
hookResumeInputVersion: typeof hookResumeInputVersion === "number" ? hookResumeInputVersion : void 0
|
|
30940
|
+
};
|
|
30941
|
+
}
|
|
30942
|
+
async function resolveHookResumeInfo(hook) {
|
|
30943
|
+
if (hook.resumeContext) {
|
|
30944
|
+
return {
|
|
30945
|
+
resumeContext: hook.resumeContext,
|
|
30946
|
+
source: "hook"
|
|
30947
|
+
};
|
|
30948
|
+
}
|
|
30949
|
+
const run2 = await (await getWorldLazy()).runs.get(hook.runId);
|
|
30950
|
+
return {
|
|
30951
|
+
resumeContext: resumeContextFromRun(run2),
|
|
30952
|
+
source: "run_fallback",
|
|
30953
|
+
run: run2
|
|
30954
|
+
};
|
|
30955
|
+
}
|
|
30956
|
+
async function resolveHookEncryptionKey(hook, info) {
|
|
30957
|
+
const world = await getWorldLazy();
|
|
30958
|
+
const rawKey = info.run ? await world.getEncryptionKeyForRun?.(info.run) : await world.getEncryptionKeyForRun?.(hook.runId, {
|
|
30959
|
+
deploymentId: info.resumeContext.deploymentId
|
|
30960
|
+
});
|
|
30961
|
+
return rawKey ? await importKey(rawKey) : void 0;
|
|
30962
|
+
}
|
|
30963
|
+
async function getHookByTokenWithKey(token) {
|
|
30964
|
+
const world = await getWorldLazy();
|
|
30965
|
+
const hook = await world.hooks.getByToken(token);
|
|
30966
|
+
let encryptionKey;
|
|
30967
|
+
if (typeof hook.metadata !== "undefined") {
|
|
30968
|
+
const info = await resolveHookResumeInfo(hook);
|
|
30969
|
+
const rawKey = info.run ? await world.getEncryptionKeyForRun?.(info.run) : await world.getEncryptionKeyForRun?.(hook.runId, {
|
|
30970
|
+
deploymentId: info.resumeContext.deploymentId
|
|
30971
|
+
});
|
|
30972
|
+
encryptionKey = rawKey ? await deriveRunPayloadKeys(rawKey) : void 0;
|
|
30973
|
+
hook.metadata = await hydrateStepArguments(hook.metadata, hook.runId, encryptionKey);
|
|
30974
|
+
}
|
|
30975
|
+
return {
|
|
30976
|
+
hook,
|
|
30977
|
+
encryptionKey
|
|
30978
|
+
};
|
|
30979
|
+
}
|
|
30980
|
+
async function getHookByToken(token) {
|
|
30981
|
+
const { hook } = await getHookByTokenWithKey(token);
|
|
30982
|
+
return hook;
|
|
30983
|
+
}
|
|
30984
|
+
async function resumeHook(tokenOrHook, payload, encryptionKeyOverride) {
|
|
30985
|
+
return resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, false);
|
|
30986
|
+
}
|
|
30987
|
+
async function resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, hookFreshlyLookedUp) {
|
|
30988
|
+
return await waitedUntil(() => {
|
|
30989
|
+
return trace("hook.resume", async (span) => {
|
|
30990
|
+
const world = await getWorldLazy();
|
|
30991
|
+
try {
|
|
30992
|
+
const suppliedToken = typeof tokenOrHook === "string";
|
|
30993
|
+
const hook = suppliedToken ? await world.hooks.getByToken(tokenOrHook) : tokenOrHook;
|
|
30994
|
+
const hookResumeCapabilitiesAreFresh = suppliedToken || hookFreshlyLookedUp;
|
|
30995
|
+
const info = await resolveHookResumeInfo(hook);
|
|
30996
|
+
const { resumeContext } = info;
|
|
30997
|
+
span?.setAttributes({
|
|
30998
|
+
...HookToken(hook.token),
|
|
30999
|
+
...HookId(hook.hookId),
|
|
31000
|
+
...WorkflowRunId(hook.runId),
|
|
31001
|
+
"workflow.hook.resume_context_source": info.source
|
|
31002
|
+
});
|
|
31003
|
+
if (info.run && isTerminalWorkflowRunStatus(info.run.status)) {
|
|
31004
|
+
throw new HookNotFoundError(hook.token);
|
|
31005
|
+
}
|
|
31006
|
+
const capabilities = getRunCapabilities(resumeContext.workflowCoreVersion);
|
|
31007
|
+
let payloadKey;
|
|
31008
|
+
const runPublicKey = encryptionKeyOverride ? (
|
|
31009
|
+
// hydrate hook metadata), so sealing would add an ECDH for no
|
|
31010
|
+
// saved round trip. Reuse what it resolved.
|
|
31011
|
+
void 0
|
|
27149
31012
|
) : decodeRunPublicKey(resumeContext.encryptionPublicKey);
|
|
27150
31013
|
if (runPublicKey) {
|
|
27151
31014
|
payloadKey = sealTo(runPublicKey);
|
|
@@ -27798,6 +31661,8 @@ function recordStreamClose(startEpochMs, runId, name) {
|
|
|
27798
31661
|
})();
|
|
27799
31662
|
}
|
|
27800
31663
|
function getAllBaseReducers(global2 = globalThis) {
|
|
31664
|
+
const requestPrototype = once(() => getHostClassPrototype(global2, "Request"));
|
|
31665
|
+
const responsePrototype = once(() => getHostClassPrototype(global2, "Response"));
|
|
27801
31666
|
return {
|
|
27802
31667
|
...getClassReducers(),
|
|
27803
31668
|
...getStepFunctionReducer(),
|
|
@@ -27805,7 +31670,7 @@ function getAllBaseReducers(global2 = globalThis) {
|
|
|
27805
31670
|
// Request and Response reducers are mode-specific and added by
|
|
27806
31671
|
// getExternalReducers / getWorkflowReducers / getStepReducers below.
|
|
27807
31672
|
Request: /* @__PURE__ */ __name((value) => {
|
|
27808
|
-
if (!isInstanceOfPrototype(value,
|
|
31673
|
+
if (!isInstanceOfPrototype(value, requestPrototype.value)) return false;
|
|
27809
31674
|
const data = {
|
|
27810
31675
|
method: readProperty(value, "method"),
|
|
27811
31676
|
url: readProperty(value, "url"),
|
|
@@ -27824,7 +31689,7 @@ function getAllBaseReducers(global2 = globalThis) {
|
|
|
27824
31689
|
return data;
|
|
27825
31690
|
}, "Request"),
|
|
27826
31691
|
Response: /* @__PURE__ */ __name((value) => {
|
|
27827
|
-
if (!isInstanceOfPrototype(value,
|
|
31692
|
+
if (!isInstanceOfPrototype(value, responsePrototype.value)) return false;
|
|
27828
31693
|
return {
|
|
27829
31694
|
type: readProperty(value, "type"),
|
|
27830
31695
|
url: readProperty(value, "url"),
|
|
@@ -27962,28 +31827,22 @@ function getExternalReducers(global2 = globalThis, ops, runId, cryptoKey, framed
|
|
|
27962
31827
|
}, "AbortSignal")
|
|
27963
31828
|
};
|
|
27964
31829
|
}
|
|
27965
|
-
function getStreamPrototype(global2, kind) {
|
|
27966
|
-
return getHostClassPrototype(global2, `${kind}Stream`);
|
|
27967
|
-
}
|
|
27968
31830
|
function getHostClassPrototype(global2, name) {
|
|
27969
|
-
const ctor = global2
|
|
27970
|
-
|
|
27971
|
-
|
|
27972
|
-
function getAbortControllerPrototype(global2) {
|
|
27973
|
-
const ctor = global2.AbortController ?? globalThis.AbortController;
|
|
27974
|
-
return typeof ctor === "function" ? ctor.prototype : void 0;
|
|
27975
|
-
}
|
|
27976
|
-
function getAbortSignalPrototype(global2) {
|
|
27977
|
-
const ctor = global2.AbortSignal ?? globalThis.AbortSignal;
|
|
27978
|
-
return typeof ctor === "function" ? ctor.prototype : void 0;
|
|
31831
|
+
const ctor = readProperty(global2, name) ?? readProperty(globalThis, name);
|
|
31832
|
+
if (typeof ctor !== "function") return void 0;
|
|
31833
|
+
return readProperty(ctor, "prototype");
|
|
27979
31834
|
}
|
|
27980
31835
|
function getWorkflowReducers(global2 = globalThis) {
|
|
31836
|
+
const readableStreamPrototype = once(() => getHostClassPrototype(global2, "ReadableStream"));
|
|
31837
|
+
const writableStreamPrototype = once(() => getHostClassPrototype(global2, "WritableStream"));
|
|
31838
|
+
const abortControllerPrototype = once(() => getHostClassPrototype(global2, "AbortController"));
|
|
31839
|
+
const abortSignalPrototype = once(() => getHostClassPrototype(global2, "AbortSignal"));
|
|
27981
31840
|
return {
|
|
27982
31841
|
...getAllBaseReducers(global2),
|
|
27983
31842
|
// Readable/Writable streams from within the workflow execution environment
|
|
27984
31843
|
// are simply "handles" that can be passed around to other steps.
|
|
27985
31844
|
ReadableStream: /* @__PURE__ */ __name((value) => {
|
|
27986
|
-
if (!isInstanceOfPrototype(value,
|
|
31845
|
+
if (!isInstanceOfPrototype(value, readableStreamPrototype.value)) return false;
|
|
27987
31846
|
const bodyInit = readProperty(value, BODY_INIT_SYMBOL);
|
|
27988
31847
|
if (bodyInit !== void 0) {
|
|
27989
31848
|
return {
|
|
@@ -28004,7 +31863,7 @@ function getWorkflowReducers(global2 = globalThis) {
|
|
|
28004
31863
|
return s;
|
|
28005
31864
|
}, "ReadableStream"),
|
|
28006
31865
|
WritableStream: /* @__PURE__ */ __name((value) => {
|
|
28007
|
-
if (!isInstanceOfPrototype(value,
|
|
31866
|
+
if (!isInstanceOfPrototype(value, writableStreamPrototype.value)) return false;
|
|
28008
31867
|
const name = readProperty(value, STREAM_NAME_SYMBOL);
|
|
28009
31868
|
if (!name) {
|
|
28010
31869
|
throw new WorkflowRuntimeError("WritableStream `name` is not set");
|
|
@@ -28032,7 +31891,7 @@ function getWorkflowReducers(global2 = globalThis) {
|
|
|
28032
31891
|
if (value === null || typeof value !== "object") return false;
|
|
28033
31892
|
const holder = value;
|
|
28034
31893
|
const ownSymbol = readProperty(value, ABORT_STREAM_NAME);
|
|
28035
|
-
const isNativeAbortController = isInstanceOfPrototype(value,
|
|
31894
|
+
const isNativeAbortController = isInstanceOfPrototype(value, abortControllerPrototype.value);
|
|
28036
31895
|
if (ownSymbol === void 0 && !isNativeAbortController) {
|
|
28037
31896
|
const maybeSignal = readProperty(value, "signal");
|
|
28038
31897
|
if (maybeSignal === null || typeof maybeSignal !== "object" || readProperty(maybeSignal, ABORT_STREAM_NAME) === void 0) {
|
|
@@ -28046,7 +31905,7 @@ function getWorkflowReducers(global2 = globalThis) {
|
|
|
28046
31905
|
AbortSignal: /* @__PURE__ */ __name((value) => {
|
|
28047
31906
|
if (value === null || typeof value !== "object") return false;
|
|
28048
31907
|
const hasAbortSymbol = readProperty(value, ABORT_STREAM_NAME) !== void 0;
|
|
28049
|
-
const isNativeAbortSignal = isInstanceOfPrototype(value,
|
|
31908
|
+
const isNativeAbortSignal = isInstanceOfPrototype(value, abortSignalPrototype.value);
|
|
28050
31909
|
if (!hasAbortSymbol && !isNativeAbortSignal) return false;
|
|
28051
31910
|
return reduceAbortBySymbol(value, value);
|
|
28052
31911
|
}, "AbortSignal")
|
|
@@ -28683,6 +32542,7 @@ var init_serialization2 = __esm({
|
|
|
28683
32542
|
"../core/dist/serialization.js"() {
|
|
28684
32543
|
"use strict";
|
|
28685
32544
|
init_dist2();
|
|
32545
|
+
init_dist();
|
|
28686
32546
|
init_dist4();
|
|
28687
32547
|
init_devalue();
|
|
28688
32548
|
init_node();
|
|
@@ -29025,10 +32885,7 @@ var init_serialization2 = __esm({
|
|
|
29025
32885
|
__name(reduceAbortBySymbol, "reduceAbortBySymbol");
|
|
29026
32886
|
__name(attachAbortListenerOnce, "attachAbortListenerOnce");
|
|
29027
32887
|
__name(getExternalReducers, "getExternalReducers");
|
|
29028
|
-
__name(getStreamPrototype, "getStreamPrototype");
|
|
29029
32888
|
__name(getHostClassPrototype, "getHostClassPrototype");
|
|
29030
|
-
__name(getAbortControllerPrototype, "getAbortControllerPrototype");
|
|
29031
|
-
__name(getAbortSignalPrototype, "getAbortSignalPrototype");
|
|
29032
32889
|
__name(getWorkflowReducers, "getWorkflowReducers");
|
|
29033
32890
|
__name(getStepReducers, "getStepReducers");
|
|
29034
32891
|
__name(setupAbortStreamReader, "setupAbortStreamReader");
|
|
@@ -29215,6 +33072,24 @@ init_telemetry();
|
|
|
29215
33072
|
init_version();
|
|
29216
33073
|
init_get_world_lazy();
|
|
29217
33074
|
init_helpers();
|
|
33075
|
+
|
|
33076
|
+
// ../core/dist/runtime/vm-mode.js
|
|
33077
|
+
init_dist2();
|
|
33078
|
+
var WORKFLOW_VMS = [
|
|
33079
|
+
"node",
|
|
33080
|
+
"quickjs"
|
|
33081
|
+
];
|
|
33082
|
+
function getWorkflowVmFromEnv(env = process.env) {
|
|
33083
|
+
const raw = env.WORKFLOW_VM;
|
|
33084
|
+
if (raw === void 0 || raw === "") return void 0;
|
|
33085
|
+
if (WORKFLOW_VMS.includes(raw)) {
|
|
33086
|
+
return raw;
|
|
33087
|
+
}
|
|
33088
|
+
throw new WorkflowRuntimeError(`Invalid WORKFLOW_VM value: "${raw}". Expected one of: ${WORKFLOW_VMS.join(", ")}.`);
|
|
33089
|
+
}
|
|
33090
|
+
__name(getWorkflowVmFromEnv, "getWorkflowVmFromEnv");
|
|
33091
|
+
|
|
33092
|
+
// ../core/dist/runtime/start.js
|
|
29218
33093
|
init_wait_until();
|
|
29219
33094
|
init_world_compatibility();
|
|
29220
33095
|
var CROSS_DEPLOYMENT_CAPABILITY_PROBE_TIMEOUT_MS = 2e3;
|
|
@@ -29351,6 +33226,7 @@ async function start(workflow, argsOrOptions, options) {
|
|
|
29351
33226
|
const compression = targetSupportsCompression && specVersion >= SPEC_VERSION_SUPPORTS_COMPRESSION;
|
|
29352
33227
|
const workflowArguments = await dehydrateWorkflowArguments(args, runId, encryptionKey, ops, globalThis, v1Compat, framedByteStreams, compression);
|
|
29353
33228
|
const creatorEnvironment = world.getEnvironment?.();
|
|
33229
|
+
const workflowVm = getWorkflowVmFromEnv();
|
|
29354
33230
|
const executionContext = {
|
|
29355
33231
|
traceCarrier,
|
|
29356
33232
|
workflowCoreVersion: version2,
|
|
@@ -29369,6 +33245,9 @@ async function start(workflow, argsOrOptions, options) {
|
|
|
29369
33245
|
...targetHookResumeInputVersion !== void 0 ? {
|
|
29370
33246
|
hookResumeInputVersion: targetHookResumeInputVersion
|
|
29371
33247
|
} : {},
|
|
33248
|
+
...workflowVm ? {
|
|
33249
|
+
workflowVm
|
|
33250
|
+
} : {},
|
|
29372
33251
|
...opts.replayedFromRunId ? {
|
|
29373
33252
|
replayedFromRunId: opts.replayedFromRunId
|
|
29374
33253
|
} : {}
|
|
@@ -29472,7 +33351,7 @@ __name(start, "start");
|
|
|
29472
33351
|
value: "start",
|
|
29473
33352
|
configurable: true
|
|
29474
33353
|
});
|
|
29475
|
-
})(start, "step//@workflow/core/runtime/start@5.0.0-beta.
|
|
33354
|
+
})(start, "step//@workflow/core/runtime/start@5.0.0-beta.40//start");
|
|
29476
33355
|
|
|
29477
33356
|
// ../core/dist/runtime/runs.js
|
|
29478
33357
|
async function wakeUpRun(world, runId, options) {
|
|
@@ -29558,6 +33437,14 @@ async function wakeUpRun(world, runId, options) {
|
|
|
29558
33437
|
__name(wakeUpRun, "wakeUpRun");
|
|
29559
33438
|
|
|
29560
33439
|
// ../core/dist/runtime/run.js
|
|
33440
|
+
var RETURN_VALUE_POLL_INTERVAL_MS = 1e3;
|
|
33441
|
+
function getReturnValuePollIntervalMs() {
|
|
33442
|
+
return envNumber("WORKFLOW_RETURN_VALUE_POLL_INTERVAL_MS", RETURN_VALUE_POLL_INTERVAL_MS, {
|
|
33443
|
+
integer: true,
|
|
33444
|
+
min: 1
|
|
33445
|
+
});
|
|
33446
|
+
}
|
|
33447
|
+
__name(getReturnValuePollIntervalMs, "getReturnValuePollIntervalMs");
|
|
29561
33448
|
var Run = class _Run {
|
|
29562
33449
|
static {
|
|
29563
33450
|
__name(this, "Run");
|
|
@@ -29748,7 +33635,7 @@ var Run = class _Run {
|
|
|
29748
33635
|
});
|
|
29749
33636
|
}
|
|
29750
33637
|
/**
|
|
29751
|
-
* Polls the workflow return value
|
|
33638
|
+
* Polls the workflow return value until it is completed.
|
|
29752
33639
|
* @internal
|
|
29753
33640
|
* @returns The workflow return value.
|
|
29754
33641
|
*/
|
|
@@ -29786,7 +33673,7 @@ var Run = class _Run {
|
|
|
29786
33673
|
throw new WorkflowRunNotCompletedError(this.runId, run2.status);
|
|
29787
33674
|
} catch (error48) {
|
|
29788
33675
|
if (WorkflowRunNotCompletedError.is(error48)) {
|
|
29789
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
33676
|
+
await new Promise((resolve) => setTimeout(resolve, getReturnValuePollIntervalMs()));
|
|
29790
33677
|
continue;
|
|
29791
33678
|
}
|
|
29792
33679
|
if (WorkflowRunNotFoundError.is(error48) && notFoundRetries < NOT_FOUND_MAX_RETRIES) {
|
|
@@ -29808,7 +33695,7 @@ var Run = class _Run {
|
|
|
29808
33695
|
value: "wakeUp",
|
|
29809
33696
|
configurable: true
|
|
29810
33697
|
});
|
|
29811
|
-
})(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
33698
|
+
})(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.40//Run#wakeUp");
|
|
29812
33699
|
(function(__wf_fn, __wf_id) {
|
|
29813
33700
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
29814
33701
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -29817,7 +33704,7 @@ var Run = class _Run {
|
|
|
29817
33704
|
value: "cancel",
|
|
29818
33705
|
configurable: true
|
|
29819
33706
|
});
|
|
29820
|
-
})(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
33707
|
+
})(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.40//Run#cancel");
|
|
29821
33708
|
(function(__wf_fn, __wf_id) {
|
|
29822
33709
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
29823
33710
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -29826,7 +33713,7 @@ var Run = class _Run {
|
|
|
29826
33713
|
value: "getReadable",
|
|
29827
33714
|
configurable: true
|
|
29828
33715
|
});
|
|
29829
|
-
})(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
33716
|
+
})(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.40//Run#getReadable");
|
|
29830
33717
|
(function(__wf_fn, __wf_id) {
|
|
29831
33718
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
29832
33719
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -29835,7 +33722,7 @@ var Run = class _Run {
|
|
|
29835
33722
|
value: "exists",
|
|
29836
33723
|
configurable: true
|
|
29837
33724
|
});
|
|
29838
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
33725
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.40//Run#exists");
|
|
29839
33726
|
(function(__wf_fn, __wf_id) {
|
|
29840
33727
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
29841
33728
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -29844,7 +33731,7 @@ var Run = class _Run {
|
|
|
29844
33731
|
value: "status",
|
|
29845
33732
|
configurable: true
|
|
29846
33733
|
});
|
|
29847
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
33734
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.40//Run#status");
|
|
29848
33735
|
(function(__wf_fn, __wf_id) {
|
|
29849
33736
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
29850
33737
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -29853,7 +33740,7 @@ var Run = class _Run {
|
|
|
29853
33740
|
value: "returnValue",
|
|
29854
33741
|
configurable: true
|
|
29855
33742
|
});
|
|
29856
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
33743
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.40//Run#returnValue");
|
|
29857
33744
|
(function(__wf_fn, __wf_id) {
|
|
29858
33745
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
29859
33746
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -29862,7 +33749,7 @@ var Run = class _Run {
|
|
|
29862
33749
|
value: "workflowName",
|
|
29863
33750
|
configurable: true
|
|
29864
33751
|
});
|
|
29865
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
33752
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.40//Run#workflowName");
|
|
29866
33753
|
(function(__wf_fn, __wf_id) {
|
|
29867
33754
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
29868
33755
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -29871,7 +33758,7 @@ var Run = class _Run {
|
|
|
29871
33758
|
value: "createdAt",
|
|
29872
33759
|
configurable: true
|
|
29873
33760
|
});
|
|
29874
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
33761
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.40//Run#createdAt");
|
|
29875
33762
|
(function(__wf_fn, __wf_id) {
|
|
29876
33763
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
29877
33764
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -29880,7 +33767,7 @@ var Run = class _Run {
|
|
|
29880
33767
|
value: "startedAt",
|
|
29881
33768
|
configurable: true
|
|
29882
33769
|
});
|
|
29883
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
33770
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.40//Run#startedAt");
|
|
29884
33771
|
(function(__wf_fn, __wf_id) {
|
|
29885
33772
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
29886
33773
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -29889,7 +33776,7 @@ var Run = class _Run {
|
|
|
29889
33776
|
value: "completedAt",
|
|
29890
33777
|
configurable: true
|
|
29891
33778
|
});
|
|
29892
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
33779
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.40//Run#completedAt");
|
|
29893
33780
|
(function(__wf_cls, __wf_id) {
|
|
29894
33781
|
var __wf_sym = /* @__PURE__ */ Symbol.for("workflow-class-registry"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
29895
33782
|
__wf_reg.set(__wf_id, __wf_cls);
|
|
@@ -29899,7 +33786,7 @@ var Run = class _Run {
|
|
|
29899
33786
|
enumerable: false,
|
|
29900
33787
|
configurable: false
|
|
29901
33788
|
});
|
|
29902
|
-
})(Run, "class//@workflow/core/runtime/run@5.0.0-beta.
|
|
33789
|
+
})(Run, "class//@workflow/core/runtime/run@5.0.0-beta.40//Run");
|
|
29903
33790
|
|
|
29904
33791
|
// ../workflow/dist/stdlib.js
|
|
29905
33792
|
async function fetch2(...args) {
|