@boxes-dev/dvb-runtime 1.0.1100 → 1.0.1102
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/bin/dvb.mjs +9562 -10048
- package/dist/bin/dvbd.mjs +520 -164
- package/dist/product-docs/references/automations.md +2 -1
- package/dist/product-docs/references/billing-and-limits.md +7 -0
- package/dist/product-docs/references/cli.md +7 -3
- package/dist/product-docs/references/slack.md +39 -1
- package/dist/product-docs/references/template-box-environment.md +6 -0
- package/package.json +2 -2
package/dist/bin/dvbd.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="9db0576c-15b7-50ce-b106-337e56c41bd4")}catch(e){}}();
|
|
4
4
|
import { createRequire as __dvbCreateRequire } from "node:module";
|
|
5
5
|
import { dirname as __dvbDirname } from "node:path";
|
|
6
6
|
import { fileURLToPath as __dvbFileURLToPath } from "node:url";
|
|
@@ -2299,7 +2299,7 @@ var require_websocket = __commonJS({
|
|
|
2299
2299
|
var https3 = __require("https");
|
|
2300
2300
|
var http5 = __require("http");
|
|
2301
2301
|
var net5 = __require("net");
|
|
2302
|
-
var
|
|
2302
|
+
var tls3 = __require("tls");
|
|
2303
2303
|
var { randomBytes, createHash: createHash3 } = __require("crypto");
|
|
2304
2304
|
var { Duplex, Readable: Readable2 } = __require("stream");
|
|
2305
2305
|
var { URL: URL3 } = __require("url");
|
|
@@ -3049,7 +3049,7 @@ var require_websocket = __commonJS({
|
|
|
3049
3049
|
if (!options.servername && options.servername !== "") {
|
|
3050
3050
|
options.servername = net5.isIP(options.host) ? "" : options.host;
|
|
3051
3051
|
}
|
|
3052
|
-
return
|
|
3052
|
+
return tls3.connect(options);
|
|
3053
3053
|
}
|
|
3054
3054
|
function abortHandshake(websocket, stream, message) {
|
|
3055
3055
|
websocket._readyState = WebSocket3.CLOSING;
|
|
@@ -64675,9 +64675,9 @@ var init_sentry = __esm({
|
|
|
64675
64675
|
uncaughtExceptionMonitorInstalled = false;
|
|
64676
64676
|
currentDevboxSentryUser = null;
|
|
64677
64677
|
readBuildMetadata = () => {
|
|
64678
|
-
const rawPackageVersion = "1.0.
|
|
64679
|
-
const rawGitSha = "
|
|
64680
|
-
const rawSentryRelease = "boxes-dev-dvb@1.0.
|
|
64678
|
+
const rawPackageVersion = "1.0.1102";
|
|
64679
|
+
const rawGitSha = "f5480fcea3e05ded20280167aedfefba3a32d9d1";
|
|
64680
|
+
const rawSentryRelease = "boxes-dev-dvb@1.0.1102+f5480fcea3e05ded20280167aedfefba3a32d9d1";
|
|
64681
64681
|
const packageVersion = typeof rawPackageVersion === "string" ? rawPackageVersion : void 0;
|
|
64682
64682
|
const gitSha = typeof rawGitSha === "string" ? rawGitSha : void 0;
|
|
64683
64683
|
const sentryRelease = typeof rawSentryRelease === "string" ? rawSentryRelease : void 0;
|
|
@@ -65593,12 +65593,147 @@ var init_ports = __esm({
|
|
|
65593
65593
|
});
|
|
65594
65594
|
|
|
65595
65595
|
// ../../../../shared/devboxCore/dist/managedDaemonControlAuth.js
|
|
65596
|
-
var textEncoder;
|
|
65596
|
+
var MANAGED_DAEMON_CONTROL_AUTH_VERSION, MANAGED_DAEMON_CONTROL_AUTH_CHALLENGE_BYTES, MANAGED_DAEMON_CONTROL_AUTH_MAC_BYTES, MANAGED_DAEMON_CONTROL_AUTH_MAX_IDENTITY_LENGTH, MAX_CAPABILITY_COUNT, MAX_CAPABILITY_LENGTH, MAX_PATH_LENGTH, BASE64URL_PATTERN, E2B_SANDBOX_ID_PATTERN, textEncoder, isRecord, hasExactKeys, readBoundedString, readCapabilities, encodeBase64Url, decodeBase64UrlExact, constantTimeEqualBase64Url, requireIdentity, buildManagedDaemonControlAuthInitMessage, parseManagedDaemonControlAuthChallengeMessage, buildManagedDaemonDirectWebSocketUrl;
|
|
65597
65597
|
var init_managedDaemonControlAuth = __esm({
|
|
65598
65598
|
"../../../../shared/devboxCore/dist/managedDaemonControlAuth.js"() {
|
|
65599
65599
|
"use strict";
|
|
65600
65600
|
init_ports();
|
|
65601
|
+
MANAGED_DAEMON_CONTROL_AUTH_VERSION = 1;
|
|
65602
|
+
MANAGED_DAEMON_CONTROL_AUTH_CHALLENGE_BYTES = 32;
|
|
65603
|
+
MANAGED_DAEMON_CONTROL_AUTH_MAC_BYTES = 32;
|
|
65604
|
+
MANAGED_DAEMON_CONTROL_AUTH_MAX_IDENTITY_LENGTH = 256;
|
|
65605
|
+
MAX_CAPABILITY_COUNT = 64;
|
|
65606
|
+
MAX_CAPABILITY_LENGTH = 128;
|
|
65607
|
+
MAX_PATH_LENGTH = 2048;
|
|
65608
|
+
BASE64URL_PATTERN = /^[A-Za-z0-9_-]+$/;
|
|
65609
|
+
E2B_SANDBOX_ID_PATTERN = /^[A-Za-z0-9-]+$/;
|
|
65601
65610
|
textEncoder = new TextEncoder();
|
|
65611
|
+
isRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
65612
|
+
hasExactKeys = (value, expectedKeys) => {
|
|
65613
|
+
const actualKeys = Object.keys(value).sort();
|
|
65614
|
+
const sortedExpected = [...expectedKeys].sort();
|
|
65615
|
+
return actualKeys.length === sortedExpected.length && actualKeys.every((key, index) => key === sortedExpected[index]);
|
|
65616
|
+
};
|
|
65617
|
+
readBoundedString = (value, maxLength) => {
|
|
65618
|
+
if (typeof value !== "string" || value !== value.trim()) {
|
|
65619
|
+
return null;
|
|
65620
|
+
}
|
|
65621
|
+
return value.length > 0 && value.length <= maxLength ? value : null;
|
|
65622
|
+
};
|
|
65623
|
+
readCapabilities = (value) => {
|
|
65624
|
+
if (!Array.isArray(value) || value.length > MAX_CAPABILITY_COUNT) {
|
|
65625
|
+
return null;
|
|
65626
|
+
}
|
|
65627
|
+
const capabilities = [];
|
|
65628
|
+
for (const entry of value) {
|
|
65629
|
+
const capability = readBoundedString(entry, MAX_CAPABILITY_LENGTH);
|
|
65630
|
+
if (!capability) {
|
|
65631
|
+
return null;
|
|
65632
|
+
}
|
|
65633
|
+
capabilities.push(capability);
|
|
65634
|
+
}
|
|
65635
|
+
return capabilities;
|
|
65636
|
+
};
|
|
65637
|
+
encodeBase64Url = (bytes) => {
|
|
65638
|
+
let binary = "";
|
|
65639
|
+
for (const byte of bytes) {
|
|
65640
|
+
binary += String.fromCharCode(byte);
|
|
65641
|
+
}
|
|
65642
|
+
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
65643
|
+
};
|
|
65644
|
+
decodeBase64UrlExact = (value, expectedBytes) => {
|
|
65645
|
+
if (typeof value !== "string" || !BASE64URL_PATTERN.test(value) || value.includes("=")) {
|
|
65646
|
+
return null;
|
|
65647
|
+
}
|
|
65648
|
+
const normalized = value.replace(/-/g, "+").replace(/_/g, "/");
|
|
65649
|
+
const padded = `${normalized}${"=".repeat((4 - normalized.length % 4) % 4)}`;
|
|
65650
|
+
let binary;
|
|
65651
|
+
try {
|
|
65652
|
+
binary = atob(padded);
|
|
65653
|
+
} catch {
|
|
65654
|
+
return null;
|
|
65655
|
+
}
|
|
65656
|
+
if (binary.length !== expectedBytes) {
|
|
65657
|
+
return null;
|
|
65658
|
+
}
|
|
65659
|
+
const bytes = new Uint8Array(binary.length);
|
|
65660
|
+
for (let index = 0; index < binary.length; index += 1) {
|
|
65661
|
+
bytes[index] = binary.charCodeAt(index);
|
|
65662
|
+
}
|
|
65663
|
+
return encodeBase64Url(bytes) === value ? bytes : null;
|
|
65664
|
+
};
|
|
65665
|
+
constantTimeEqualBase64Url = (left, right, expectedBytes = MANAGED_DAEMON_CONTROL_AUTH_MAC_BYTES) => {
|
|
65666
|
+
const leftBytes = decodeBase64UrlExact(left, expectedBytes);
|
|
65667
|
+
const rightBytes = decodeBase64UrlExact(right, expectedBytes);
|
|
65668
|
+
if (!leftBytes || !rightBytes) {
|
|
65669
|
+
return false;
|
|
65670
|
+
}
|
|
65671
|
+
let difference = 0;
|
|
65672
|
+
for (let index = 0; index < expectedBytes; index += 1) {
|
|
65673
|
+
difference |= leftBytes[index] ^ rightBytes[index];
|
|
65674
|
+
}
|
|
65675
|
+
return difference === 0;
|
|
65676
|
+
};
|
|
65677
|
+
requireIdentity = (label, value) => {
|
|
65678
|
+
const normalized = readBoundedString(value, MANAGED_DAEMON_CONTROL_AUTH_MAX_IDENTITY_LENGTH);
|
|
65679
|
+
if (!normalized) {
|
|
65680
|
+
throw new Error(`${label} is invalid.`);
|
|
65681
|
+
}
|
|
65682
|
+
return normalized;
|
|
65683
|
+
};
|
|
65684
|
+
buildManagedDaemonControlAuthInitMessage = (capabilities) => {
|
|
65685
|
+
const normalizedCapabilities = readCapabilities([...capabilities]);
|
|
65686
|
+
if (!normalizedCapabilities) {
|
|
65687
|
+
throw new Error("Managed daemon control capabilities are invalid.");
|
|
65688
|
+
}
|
|
65689
|
+
return {
|
|
65690
|
+
type: "control_auth_init",
|
|
65691
|
+
version: MANAGED_DAEMON_CONTROL_AUTH_VERSION,
|
|
65692
|
+
capabilities: normalizedCapabilities
|
|
65693
|
+
};
|
|
65694
|
+
};
|
|
65695
|
+
parseManagedDaemonControlAuthChallengeMessage = (value) => {
|
|
65696
|
+
if (!isRecord(value) || !hasExactKeys(value, [
|
|
65697
|
+
"type",
|
|
65698
|
+
"version",
|
|
65699
|
+
"audience",
|
|
65700
|
+
"instanceId",
|
|
65701
|
+
"provider",
|
|
65702
|
+
"providerInstanceId",
|
|
65703
|
+
"challenge"
|
|
65704
|
+
]) || value.type !== "control_auth_challenge" || value.version !== MANAGED_DAEMON_CONTROL_AUTH_VERSION || value.audience !== "session" && value.audience !== "exec" || value.provider !== "e2b") {
|
|
65705
|
+
return null;
|
|
65706
|
+
}
|
|
65707
|
+
const instanceId = readBoundedString(value.instanceId, MANAGED_DAEMON_CONTROL_AUTH_MAX_IDENTITY_LENGTH);
|
|
65708
|
+
const providerInstanceId = readBoundedString(value.providerInstanceId, MANAGED_DAEMON_CONTROL_AUTH_MAX_IDENTITY_LENGTH);
|
|
65709
|
+
const challenge = typeof value.challenge === "string" && decodeBase64UrlExact(value.challenge, MANAGED_DAEMON_CONTROL_AUTH_CHALLENGE_BYTES) ? value.challenge : null;
|
|
65710
|
+
if (!instanceId || !providerInstanceId || !challenge) {
|
|
65711
|
+
return null;
|
|
65712
|
+
}
|
|
65713
|
+
return {
|
|
65714
|
+
type: "control_auth_challenge",
|
|
65715
|
+
version: MANAGED_DAEMON_CONTROL_AUTH_VERSION,
|
|
65716
|
+
audience: value.audience,
|
|
65717
|
+
instanceId,
|
|
65718
|
+
provider: value.provider,
|
|
65719
|
+
providerInstanceId,
|
|
65720
|
+
challenge
|
|
65721
|
+
};
|
|
65722
|
+
};
|
|
65723
|
+
buildManagedDaemonDirectWebSocketUrl = ({ audience, provider, providerInstanceId, pathname = "" }) => {
|
|
65724
|
+
if (provider !== "e2b") {
|
|
65725
|
+
throw new Error("Unsupported managed daemon provider.");
|
|
65726
|
+
}
|
|
65727
|
+
const normalizedProviderInstanceId = requireIdentity("Managed daemon provider instance ID", providerInstanceId);
|
|
65728
|
+
if (!E2B_SANDBOX_ID_PATTERN.test(normalizedProviderInstanceId)) {
|
|
65729
|
+
throw new Error("Managed daemon provider instance ID is invalid.");
|
|
65730
|
+
}
|
|
65731
|
+
if (pathname.length > MAX_PATH_LENGTH || pathname.length > 0 && (!pathname.startsWith("/") || pathname.includes("#") || pathname.includes("\\") || pathname.includes("\n") || pathname.includes("\r"))) {
|
|
65732
|
+
throw new Error("Managed daemon WebSocket path is invalid.");
|
|
65733
|
+
}
|
|
65734
|
+
const port = audience === "session" ? SPRITE_DAEMON_SESSION_PORT : MANAGED_DAEMON_CONTROL_PORT;
|
|
65735
|
+
return `wss://${port}-${normalizedProviderInstanceId}.e2b.app${pathname}`;
|
|
65736
|
+
};
|
|
65602
65737
|
}
|
|
65603
65738
|
});
|
|
65604
65739
|
|
|
@@ -65610,13 +65745,12 @@ var init_managedFileCapability = __esm({
|
|
|
65610
65745
|
});
|
|
65611
65746
|
|
|
65612
65747
|
// ../../../../shared/devboxCore/dist/ttyControlProtocol.js
|
|
65613
|
-
var
|
|
65748
|
+
var TTY_CONTROL_REMOTE_BROWSER_CAPABILITY, TTY_CONTROL_REQUIRED_CAPABILITIES, TTY_CONTROL_CAPABILITIES;
|
|
65614
65749
|
var init_ttyControlProtocol = __esm({
|
|
65615
65750
|
"../../../../shared/devboxCore/dist/ttyControlProtocol.js"() {
|
|
65616
65751
|
"use strict";
|
|
65617
65752
|
init_managedDaemonControlAuth();
|
|
65618
65753
|
init_managedFileCapability();
|
|
65619
|
-
TTY_CONTROL_PROTOCOL_VERSION = 1;
|
|
65620
65754
|
TTY_CONTROL_REMOTE_BROWSER_CAPABILITY = "remote_browser";
|
|
65621
65755
|
TTY_CONTROL_REQUIRED_CAPABILITIES = [
|
|
65622
65756
|
"tty_session_id_attach_or_create"
|
|
@@ -65625,21 +65759,108 @@ var init_ttyControlProtocol = __esm({
|
|
|
65625
65759
|
...TTY_CONTROL_REQUIRED_CAPABILITIES,
|
|
65626
65760
|
TTY_CONTROL_REMOTE_BROWSER_CAPABILITY
|
|
65627
65761
|
];
|
|
65628
|
-
buildControlAuthMessage = (token) => ({
|
|
65629
|
-
type: "auth",
|
|
65630
|
-
mode: "control",
|
|
65631
|
-
protocolVersion: TTY_CONTROL_PROTOCOL_VERSION,
|
|
65632
|
-
capabilities: [...TTY_CONTROL_REQUIRED_CAPABILITIES],
|
|
65633
|
-
...typeof token === "string" && token.trim().length > 0 ? { token: token.trim() } : {}
|
|
65634
|
-
});
|
|
65635
65762
|
}
|
|
65636
65763
|
});
|
|
65637
65764
|
|
|
65638
65765
|
// ../../../../shared/devboxCore/dist/managedDaemonControlAuthClient.js
|
|
65766
|
+
var readNonEmptyString2, readManagedDaemonControlAuthErrorCode, isManagedDaemonGrantAuthUnavailable, ManagedDaemonControlAuthClientError, createManagedDaemonControlAuthHandshake;
|
|
65639
65767
|
var init_managedDaemonControlAuthClient = __esm({
|
|
65640
65768
|
"../../../../shared/devboxCore/dist/managedDaemonControlAuthClient.js"() {
|
|
65641
65769
|
"use strict";
|
|
65642
65770
|
init_managedDaemonControlAuth();
|
|
65771
|
+
readNonEmptyString2 = (value) => {
|
|
65772
|
+
if (typeof value !== "string") {
|
|
65773
|
+
return null;
|
|
65774
|
+
}
|
|
65775
|
+
const trimmed = value.trim();
|
|
65776
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
65777
|
+
};
|
|
65778
|
+
readManagedDaemonControlAuthErrorCode = (value) => {
|
|
65779
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
65780
|
+
return null;
|
|
65781
|
+
}
|
|
65782
|
+
const record2 = value;
|
|
65783
|
+
const directCode = readNonEmptyString2(record2.code);
|
|
65784
|
+
if (directCode) {
|
|
65785
|
+
return directCode;
|
|
65786
|
+
}
|
|
65787
|
+
if (!record2.error || typeof record2.error !== "object" || Array.isArray(record2.error)) {
|
|
65788
|
+
return null;
|
|
65789
|
+
}
|
|
65790
|
+
return readNonEmptyString2(record2.error.code);
|
|
65791
|
+
};
|
|
65792
|
+
isManagedDaemonGrantAuthUnavailable = ({ errorCode, message, awaitingChallenge }) => {
|
|
65793
|
+
if (!awaitingChallenge) {
|
|
65794
|
+
return false;
|
|
65795
|
+
}
|
|
65796
|
+
if (errorCode === "grant_auth_unavailable" || errorCode === "auth_required") {
|
|
65797
|
+
return true;
|
|
65798
|
+
}
|
|
65799
|
+
if (errorCode !== "forbidden") {
|
|
65800
|
+
return false;
|
|
65801
|
+
}
|
|
65802
|
+
return message?.trim().toLowerCase() === "control auth is required.";
|
|
65803
|
+
};
|
|
65804
|
+
ManagedDaemonControlAuthClientError = class extends Error {
|
|
65805
|
+
code;
|
|
65806
|
+
originalError;
|
|
65807
|
+
constructor(message, code2, originalError) {
|
|
65808
|
+
super(message);
|
|
65809
|
+
this.code = code2;
|
|
65810
|
+
this.originalError = originalError;
|
|
65811
|
+
this.name = "ManagedDaemonControlAuthClientError";
|
|
65812
|
+
}
|
|
65813
|
+
};
|
|
65814
|
+
createManagedDaemonControlAuthHandshake = ({ audience, capabilities, issueGrant, requestId, target }) => {
|
|
65815
|
+
let stage = "awaiting_challenge";
|
|
65816
|
+
let expectedConfirmation = null;
|
|
65817
|
+
return {
|
|
65818
|
+
initMessage: buildManagedDaemonControlAuthInitMessage(capabilities),
|
|
65819
|
+
issueGrantForChallenge: async (value) => {
|
|
65820
|
+
if (stage !== "awaiting_challenge") {
|
|
65821
|
+
throw new ManagedDaemonControlAuthClientError("Managed daemon sent an authorization challenge in an invalid state.", "invalid_state");
|
|
65822
|
+
}
|
|
65823
|
+
const challenge = parseManagedDaemonControlAuthChallengeMessage(value);
|
|
65824
|
+
if (!challenge) {
|
|
65825
|
+
throw new ManagedDaemonControlAuthClientError("Managed daemon sent an invalid authorization challenge.", "invalid_challenge");
|
|
65826
|
+
}
|
|
65827
|
+
if (challenge.audience !== audience || challenge.instanceId !== target.instanceId || challenge.provider !== target.provider || challenge.providerInstanceId !== target.providerInstanceId) {
|
|
65828
|
+
throw new ManagedDaemonControlAuthClientError("Managed daemon identity does not match the selected runtime.", "identity_mismatch");
|
|
65829
|
+
}
|
|
65830
|
+
stage = "grant_pending";
|
|
65831
|
+
let issued;
|
|
65832
|
+
try {
|
|
65833
|
+
issued = await issueGrant({
|
|
65834
|
+
...target,
|
|
65835
|
+
audience,
|
|
65836
|
+
challenge: challenge.challenge,
|
|
65837
|
+
requestId
|
|
65838
|
+
});
|
|
65839
|
+
} catch (error4) {
|
|
65840
|
+
throw new ManagedDaemonControlAuthClientError(error4 instanceof Error ? error4.message : "Managed daemon authorization was rejected.", "grant_rejected", error4);
|
|
65841
|
+
}
|
|
65842
|
+
if (issued.protocolVersion !== MANAGED_DAEMON_CONTROL_AUTH_VERSION || issued.requestId !== requestId || !decodeBase64UrlExact(issued.grant, MANAGED_DAEMON_CONTROL_AUTH_MAC_BYTES) || !decodeBase64UrlExact(issued.expectedConfirmation, MANAGED_DAEMON_CONTROL_AUTH_MAC_BYTES)) {
|
|
65843
|
+
throw new ManagedDaemonControlAuthClientError("Managed daemon authorization response is invalid.", "grant_rejected");
|
|
65844
|
+
}
|
|
65845
|
+
expectedConfirmation = issued.expectedConfirmation;
|
|
65846
|
+
stage = "awaiting_confirmation";
|
|
65847
|
+
return {
|
|
65848
|
+
type: "control_auth_grant",
|
|
65849
|
+
version: MANAGED_DAEMON_CONTROL_AUTH_VERSION,
|
|
65850
|
+
grant: issued.grant
|
|
65851
|
+
};
|
|
65852
|
+
},
|
|
65853
|
+
confirmReady: (confirmation) => {
|
|
65854
|
+
if (stage !== "awaiting_confirmation" || !expectedConfirmation) {
|
|
65855
|
+
throw new ManagedDaemonControlAuthClientError("Managed daemon became ready before authorization completed.", "invalid_state");
|
|
65856
|
+
}
|
|
65857
|
+
if (!constantTimeEqualBase64Url(confirmation, expectedConfirmation)) {
|
|
65858
|
+
throw new ManagedDaemonControlAuthClientError("Managed daemon authorization confirmation is invalid.", "invalid_confirmation");
|
|
65859
|
+
}
|
|
65860
|
+
stage = "confirmed";
|
|
65861
|
+
}
|
|
65862
|
+
};
|
|
65863
|
+
};
|
|
65643
65864
|
}
|
|
65644
65865
|
});
|
|
65645
65866
|
|
|
@@ -65932,25 +66153,23 @@ var init_loopbackHttpAuthority = __esm({
|
|
|
65932
66153
|
|
|
65933
66154
|
// ../../../../shared/devboxCore/dist/portProxying.js
|
|
65934
66155
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
65935
|
-
var DIRECT_DAEMON_PROXY_CONNECT_TIMEOUT_MS, DIRECT_DAEMON_PROXY_OPEN_TIMEOUT_MS,
|
|
66156
|
+
var DIRECT_DAEMON_PROXY_CONNECT_TIMEOUT_MS, DIRECT_DAEMON_PROXY_OPEN_TIMEOUT_MS, buildDirectDaemonProxyWebSocketUrl, parseJsonRecord, parseControlError, decodeBase64, toSocketBuffer, DirectDaemonProxyExecSocket, bridgeExecSocketToLocalSocket;
|
|
65936
66157
|
var init_portProxying = __esm({
|
|
65937
66158
|
"../../../../shared/devboxCore/dist/portProxying.js"() {
|
|
65938
66159
|
"use strict";
|
|
65939
66160
|
init_wrapper();
|
|
65940
66161
|
init_loopbackHttpAuthority();
|
|
66162
|
+
init_managedDaemonControlAuth();
|
|
66163
|
+
init_managedDaemonControlAuthClient();
|
|
65941
66164
|
init_ttyControlProtocol();
|
|
65942
66165
|
DIRECT_DAEMON_PROXY_CONNECT_TIMEOUT_MS = 12e3;
|
|
65943
66166
|
DIRECT_DAEMON_PROXY_OPEN_TIMEOUT_MS = 12e3;
|
|
65944
|
-
|
|
65945
|
-
|
|
65946
|
-
|
|
65947
|
-
|
|
65948
|
-
|
|
65949
|
-
|
|
65950
|
-
};
|
|
65951
|
-
buildDirectDaemonAuthMessage = (connectInfo) => {
|
|
65952
|
-
return buildControlAuthMessage(connectInfo.authToken);
|
|
65953
|
-
};
|
|
66167
|
+
buildDirectDaemonProxyWebSocketUrl = (target) => buildManagedDaemonDirectWebSocketUrl({
|
|
66168
|
+
audience: "exec",
|
|
66169
|
+
provider: target.provider,
|
|
66170
|
+
providerInstanceId: target.providerInstanceId,
|
|
66171
|
+
pathname: "/ws"
|
|
66172
|
+
});
|
|
65954
66173
|
parseJsonRecord = (raw) => {
|
|
65955
66174
|
let text = "";
|
|
65956
66175
|
if (typeof raw === "string") {
|
|
@@ -66029,6 +66248,7 @@ var init_portProxying = __esm({
|
|
|
66029
66248
|
ws = null;
|
|
66030
66249
|
closed = false;
|
|
66031
66250
|
authenticated = false;
|
|
66251
|
+
authStage = "awaiting_challenge";
|
|
66032
66252
|
proxyHandshakeSent = false;
|
|
66033
66253
|
openingChannel = false;
|
|
66034
66254
|
tcpReady = false;
|
|
@@ -66114,23 +66334,85 @@ var init_portProxying = __esm({
|
|
|
66114
66334
|
}
|
|
66115
66335
|
this.pendingFrames = [];
|
|
66116
66336
|
}
|
|
66117
|
-
|
|
66337
|
+
fail(error4) {
|
|
66338
|
+
this.emit("error", {
|
|
66339
|
+
data: error4 instanceof Error ? error4 : new Error(String(error4))
|
|
66340
|
+
});
|
|
66341
|
+
this.close();
|
|
66342
|
+
}
|
|
66343
|
+
handleAuthMessage({ ws, message, handshake, connectInfo, recoveryAttempted }) {
|
|
66118
66344
|
const type = typeof message.type === "string" ? message.type : "";
|
|
66119
|
-
if (
|
|
66120
|
-
|
|
66121
|
-
|
|
66122
|
-
this.
|
|
66123
|
-
|
|
66124
|
-
|
|
66345
|
+
if (type === "control_auth_challenge") {
|
|
66346
|
+
this.authStage = "grant_pending";
|
|
66347
|
+
void handshake.issueGrantForChallenge(message).then((grantMessage) => {
|
|
66348
|
+
if (this.closed || this.ws !== ws) {
|
|
66349
|
+
return;
|
|
66350
|
+
}
|
|
66351
|
+
this.authStage = "awaiting_ready";
|
|
66352
|
+
this.sendJson(grantMessage);
|
|
66353
|
+
}).catch((error4) => {
|
|
66354
|
+
if (!this.closed && this.ws === ws) {
|
|
66355
|
+
this.fail(error4);
|
|
66356
|
+
}
|
|
66357
|
+
});
|
|
66358
|
+
return;
|
|
66359
|
+
}
|
|
66360
|
+
if (type === "control_ready") {
|
|
66361
|
+
try {
|
|
66362
|
+
handshake.confirmReady(message.authConfirmation);
|
|
66363
|
+
} catch (error4) {
|
|
66364
|
+
this.fail(error4);
|
|
66125
66365
|
return;
|
|
66126
66366
|
}
|
|
66127
|
-
|
|
66128
|
-
|
|
66129
|
-
|
|
66130
|
-
|
|
66131
|
-
}
|
|
66367
|
+
this.authenticated = true;
|
|
66368
|
+
this.readyState = 1;
|
|
66369
|
+
this.clearConnectTimer();
|
|
66370
|
+
this.emit("open");
|
|
66132
66371
|
return;
|
|
66133
66372
|
}
|
|
66373
|
+
if (type === "error") {
|
|
66374
|
+
const { text } = parseControlError(message);
|
|
66375
|
+
if (!recoveryAttempted && isManagedDaemonGrantAuthUnavailable({
|
|
66376
|
+
errorCode: readManagedDaemonControlAuthErrorCode(message),
|
|
66377
|
+
message: text,
|
|
66378
|
+
awaitingChallenge: this.authStage === "awaiting_challenge"
|
|
66379
|
+
})) {
|
|
66380
|
+
void this.recoverAndReconnect(ws, connectInfo);
|
|
66381
|
+
return;
|
|
66382
|
+
}
|
|
66383
|
+
this.fail(new Error(text));
|
|
66384
|
+
}
|
|
66385
|
+
}
|
|
66386
|
+
detachWebSocket(ws) {
|
|
66387
|
+
ws.removeAllListeners();
|
|
66388
|
+
ws.on("error", () => void 0);
|
|
66389
|
+
if (ws.readyState <= wrapper_default.OPEN) {
|
|
66390
|
+
try {
|
|
66391
|
+
ws.close();
|
|
66392
|
+
} catch {
|
|
66393
|
+
}
|
|
66394
|
+
}
|
|
66395
|
+
}
|
|
66396
|
+
async recoverAndReconnect(ws, connectInfo) {
|
|
66397
|
+
this.clearConnectTimer();
|
|
66398
|
+
this.detachWebSocket(ws);
|
|
66399
|
+
if (this.ws === ws) {
|
|
66400
|
+
this.ws = null;
|
|
66401
|
+
}
|
|
66402
|
+
try {
|
|
66403
|
+
await connectInfo.recover({
|
|
66404
|
+
requestId: randomUUID3(),
|
|
66405
|
+
allowWake: this.allowWake
|
|
66406
|
+
});
|
|
66407
|
+
await this.connect(true);
|
|
66408
|
+
} catch (error4) {
|
|
66409
|
+
if (!this.closed) {
|
|
66410
|
+
this.fail(error4);
|
|
66411
|
+
}
|
|
66412
|
+
}
|
|
66413
|
+
}
|
|
66414
|
+
handleDaemonMessage(message) {
|
|
66415
|
+
const type = typeof message.type === "string" ? message.type : "";
|
|
66134
66416
|
if (type === "tcp_open_result") {
|
|
66135
66417
|
const responseRequestId = typeof message.requestId === "string" ? message.requestId : null;
|
|
66136
66418
|
if (responseRequestId !== this.requestId) {
|
|
@@ -66196,63 +66478,85 @@ var init_portProxying = __esm({
|
|
|
66196
66478
|
}
|
|
66197
66479
|
async start() {
|
|
66198
66480
|
try {
|
|
66199
|
-
|
|
66200
|
-
|
|
66481
|
+
await this.connect(false);
|
|
66482
|
+
} catch (error4) {
|
|
66483
|
+
this.clearConnectTimer();
|
|
66484
|
+
this.clearOpenTimer();
|
|
66485
|
+
this.fail(error4);
|
|
66486
|
+
}
|
|
66487
|
+
}
|
|
66488
|
+
async connect(recoveryAttempted) {
|
|
66489
|
+
if (this.closed) {
|
|
66490
|
+
return;
|
|
66491
|
+
}
|
|
66492
|
+
const connectInfo = await this.resolveDirectDaemonConnectInfo({
|
|
66493
|
+
alias: this.alias,
|
|
66494
|
+
allowWake: this.allowWake,
|
|
66495
|
+
...this.instanceId ? { instanceId: this.instanceId } : {}
|
|
66496
|
+
});
|
|
66497
|
+
if (this.closed) {
|
|
66498
|
+
return;
|
|
66499
|
+
}
|
|
66500
|
+
const handshake = createManagedDaemonControlAuthHandshake({
|
|
66501
|
+
audience: "exec",
|
|
66502
|
+
capabilities: TTY_CONTROL_REQUIRED_CAPABILITIES,
|
|
66503
|
+
issueGrant: connectInfo.issueGrant,
|
|
66504
|
+
requestId: this.requestId,
|
|
66505
|
+
target: connectInfo.target
|
|
66506
|
+
});
|
|
66507
|
+
const ws = new wrapper_default(connectInfo.wsUrl);
|
|
66508
|
+
this.ws = ws;
|
|
66509
|
+
this.authStage = "awaiting_challenge";
|
|
66510
|
+
this.startConnectTimer();
|
|
66511
|
+
ws.on("open", () => {
|
|
66512
|
+
try {
|
|
66513
|
+
this.sendJson(handshake.initMessage);
|
|
66514
|
+
} catch (error4) {
|
|
66515
|
+
this.fail(error4);
|
|
66201
66516
|
}
|
|
66202
|
-
|
|
66203
|
-
|
|
66204
|
-
|
|
66205
|
-
|
|
66206
|
-
});
|
|
66207
|
-
if (this.closed) {
|
|
66517
|
+
});
|
|
66518
|
+
ws.on("message", (raw) => {
|
|
66519
|
+
const parsed = parseJsonRecord(raw);
|
|
66520
|
+
if (!parsed) {
|
|
66208
66521
|
return;
|
|
66209
66522
|
}
|
|
66210
|
-
|
|
66211
|
-
|
|
66212
|
-
|
|
66213
|
-
|
|
66214
|
-
|
|
66215
|
-
|
|
66216
|
-
|
|
66217
|
-
this.emit("error", {
|
|
66218
|
-
data: error4 instanceof Error ? error4 : new Error(String(error4))
|
|
66219
|
-
});
|
|
66220
|
-
this.close();
|
|
66221
|
-
}
|
|
66222
|
-
});
|
|
66223
|
-
ws.on("message", (raw) => {
|
|
66224
|
-
const parsed = parseJsonRecord(raw);
|
|
66225
|
-
if (!parsed) {
|
|
66226
|
-
return;
|
|
66227
|
-
}
|
|
66228
|
-
this.handleDaemonMessage(parsed);
|
|
66229
|
-
});
|
|
66230
|
-
ws.on("pong", () => {
|
|
66231
|
-
this.emitPong();
|
|
66232
|
-
});
|
|
66233
|
-
ws.on("error", (error4) => {
|
|
66234
|
-
this.emit("error", {
|
|
66235
|
-
data: error4 instanceof Error ? error4 : new Error(String(error4))
|
|
66523
|
+
if (!this.authenticated) {
|
|
66524
|
+
this.handleAuthMessage({
|
|
66525
|
+
ws,
|
|
66526
|
+
message: parsed,
|
|
66527
|
+
handshake,
|
|
66528
|
+
connectInfo,
|
|
66529
|
+
recoveryAttempted
|
|
66236
66530
|
});
|
|
66237
|
-
|
|
66238
|
-
|
|
66239
|
-
|
|
66240
|
-
|
|
66241
|
-
|
|
66242
|
-
|
|
66243
|
-
|
|
66244
|
-
|
|
66245
|
-
|
|
66246
|
-
|
|
66247
|
-
}
|
|
66248
|
-
} catch (error4) {
|
|
66249
|
-
this.clearConnectTimer();
|
|
66250
|
-
this.clearOpenTimer();
|
|
66531
|
+
return;
|
|
66532
|
+
}
|
|
66533
|
+
this.handleDaemonMessage(parsed);
|
|
66534
|
+
});
|
|
66535
|
+
ws.on("pong", () => {
|
|
66536
|
+
this.emitPong();
|
|
66537
|
+
});
|
|
66538
|
+
ws.on("error", (error4) => {
|
|
66539
|
+
if (!this.authenticated && !recoveryAttempted) {
|
|
66540
|
+
return;
|
|
66541
|
+
}
|
|
66251
66542
|
this.emit("error", {
|
|
66252
66543
|
data: error4 instanceof Error ? error4 : new Error(String(error4))
|
|
66253
66544
|
});
|
|
66254
|
-
|
|
66255
|
-
|
|
66545
|
+
});
|
|
66546
|
+
ws.on("close", (code2) => {
|
|
66547
|
+
this.clearConnectTimer();
|
|
66548
|
+
this.clearOpenTimer();
|
|
66549
|
+
if (this.closed) {
|
|
66550
|
+
return;
|
|
66551
|
+
}
|
|
66552
|
+
if (!this.authenticated && !recoveryAttempted && this.ws === ws) {
|
|
66553
|
+
void this.recoverAndReconnect(ws, connectInfo);
|
|
66554
|
+
return;
|
|
66555
|
+
}
|
|
66556
|
+
this.closed = true;
|
|
66557
|
+
this.readyState = 3;
|
|
66558
|
+
this.emit("close", { code: code2 });
|
|
66559
|
+
});
|
|
66256
66560
|
}
|
|
66257
66561
|
send(data, cb) {
|
|
66258
66562
|
if (this.closed) {
|
|
@@ -66895,7 +67199,7 @@ var init_packageVersion = __esm({
|
|
|
66895
67199
|
return path8.join(process.cwd(), "dvb");
|
|
66896
67200
|
};
|
|
66897
67201
|
readEmbeddedPackageVersion = () => {
|
|
66898
|
-
const raw = "1.0.
|
|
67202
|
+
const raw = "1.0.1102";
|
|
66899
67203
|
return trimVersion(raw);
|
|
66900
67204
|
};
|
|
66901
67205
|
readNearestPackageMetadata = (basePath) => {
|
|
@@ -66965,11 +67269,11 @@ var init_clientVersionHeaders = __esm({
|
|
|
66965
67269
|
});
|
|
66966
67270
|
|
|
66967
67271
|
// ../../../../shared/devboxCore/dist/upgradeRequired.js
|
|
66968
|
-
var
|
|
67272
|
+
var readNonEmptyString3, buildUpgradeRequiredMessage, UpgradeRequiredError, fromPayload, fromString, parseUpgradeRequiredResponseBody, coerceUpgradeRequiredError;
|
|
66969
67273
|
var init_upgradeRequired = __esm({
|
|
66970
67274
|
"../../../../shared/devboxCore/dist/upgradeRequired.js"() {
|
|
66971
67275
|
"use strict";
|
|
66972
|
-
|
|
67276
|
+
readNonEmptyString3 = (value) => {
|
|
66973
67277
|
if (typeof value !== "string")
|
|
66974
67278
|
return null;
|
|
66975
67279
|
const trimmed = value.trim();
|
|
@@ -66998,14 +67302,14 @@ var init_upgradeRequired = __esm({
|
|
|
66998
67302
|
}
|
|
66999
67303
|
};
|
|
67000
67304
|
fromPayload = (payload, context34 = {}) => {
|
|
67001
|
-
const errorCode =
|
|
67305
|
+
const errorCode = readNonEmptyString3(payload.error);
|
|
67002
67306
|
if (errorCode !== "client_upgrade_required") {
|
|
67003
67307
|
return null;
|
|
67004
67308
|
}
|
|
67005
67309
|
return new UpgradeRequiredError({
|
|
67006
|
-
minVersion:
|
|
67007
|
-
detail:
|
|
67008
|
-
source:
|
|
67310
|
+
minVersion: readNonEmptyString3(payload.minVersion),
|
|
67311
|
+
detail: readNonEmptyString3(payload.message) ?? readNonEmptyString3(payload.detail),
|
|
67312
|
+
source: readNonEmptyString3(payload.source) ?? readNonEmptyString3(context34.source),
|
|
67009
67313
|
statusCode: context34.statusCode ?? null
|
|
67010
67314
|
});
|
|
67011
67315
|
};
|
|
@@ -67079,11 +67383,11 @@ var init_upgradeRequired = __esm({
|
|
|
67079
67383
|
});
|
|
67080
67384
|
|
|
67081
67385
|
// ../../../../shared/devboxCore/dist/authRefresh.js
|
|
67082
|
-
var
|
|
67386
|
+
var readNonEmptyString4, INVALID_REFRESH_TOKEN_ERROR_CODE, InvalidRefreshTokenError, parseInvalidRefreshTokenResponseBody, isInvalidRefreshTokenError;
|
|
67083
67387
|
var init_authRefresh = __esm({
|
|
67084
67388
|
"../../../../shared/devboxCore/dist/authRefresh.js"() {
|
|
67085
67389
|
"use strict";
|
|
67086
|
-
|
|
67390
|
+
readNonEmptyString4 = (value) => {
|
|
67087
67391
|
if (typeof value !== "string")
|
|
67088
67392
|
return null;
|
|
67089
67393
|
const trimmed = value.trim();
|
|
@@ -67113,11 +67417,11 @@ var init_authRefresh = __esm({
|
|
|
67113
67417
|
if (!payload || typeof payload !== "object") {
|
|
67114
67418
|
return null;
|
|
67115
67419
|
}
|
|
67116
|
-
if (
|
|
67420
|
+
if (readNonEmptyString4(payload.error) !== INVALID_REFRESH_TOKEN_ERROR_CODE) {
|
|
67117
67421
|
return null;
|
|
67118
67422
|
}
|
|
67119
67423
|
return new InvalidRefreshTokenError({
|
|
67120
|
-
detail:
|
|
67424
|
+
detail: readNonEmptyString4(payload.message),
|
|
67121
67425
|
source: context34.source ?? null,
|
|
67122
67426
|
statusCode: context34.statusCode ?? null
|
|
67123
67427
|
});
|
|
@@ -74617,7 +74921,7 @@ var init_simple_client_node = __esm({
|
|
|
74617
74921
|
var https3 = __require2("https");
|
|
74618
74922
|
var http5 = __require2("http");
|
|
74619
74923
|
var net5 = __require2("net");
|
|
74620
|
-
var
|
|
74924
|
+
var tls3 = __require2("tls");
|
|
74621
74925
|
var { randomBytes, createHash: createHash3 } = __require2("crypto");
|
|
74622
74926
|
var { Duplex, Readable: Readable2 } = __require2("stream");
|
|
74623
74927
|
var { URL: URL3 } = __require2("url");
|
|
@@ -75354,7 +75658,7 @@ var init_simple_client_node = __esm({
|
|
|
75354
75658
|
if (!options.servername && options.servername !== "") {
|
|
75355
75659
|
options.servername = net5.isIP(options.host) ? "" : options.host;
|
|
75356
75660
|
}
|
|
75357
|
-
return
|
|
75661
|
+
return tls3.connect(options);
|
|
75358
75662
|
}
|
|
75359
75663
|
function abortHandshake(websocket, stream, message) {
|
|
75360
75664
|
websocket._readyState = WebSocket22.CLOSING;
|
|
@@ -76395,7 +76699,7 @@ var init_server = __esm({
|
|
|
76395
76699
|
|
|
76396
76700
|
// ../daemon/src/spritesRegistry.ts
|
|
76397
76701
|
import { createHash, randomUUID as randomUUID4 } from "node:crypto";
|
|
76398
|
-
var MANAGED_DAEMON_NOT_READY_CODE, MANAGED_DAEMON_WAKING_TIMEOUT_MS, ManagedDaemonNotReadyError, delay, registryGet, registryUpsert, registryUsage, registryRemoveChunked, instancesList, helloViewerGet,
|
|
76702
|
+
var MANAGED_DAEMON_NOT_READY_CODE, MANAGED_DAEMON_WAKING_TIMEOUT_MS, ManagedDaemonNotReadyError, delay, registryGet, registryUpsert, registryUsage, registryRemoveChunked, instancesList, helloViewerGet, managedDaemonControlGrantIssue, managedDaemonRecoverForInstance, logger2, TOKEN_REFRESH_BUFFER_MS, CONVEX_REQUEST_TIMEOUT_MS, MANAGED_DAEMON_HOT_PATH_CONVEX_REQUEST_TIMEOUT_MS, clientCache, clientCacheAuthFingerprint, clientCacheViewerAuthFingerprint, trimEnv, fingerprintToken, resolveConvexUrl, resolveControlPlaneUrl, requireConvexConfig, decodeJwtPayload2, parseTokenExpiresAt, shouldRefreshToken, isUnauthorizedError, clearControlPlaneAccessToken, resetClientCache, forceReconnectControlPlaneClient, getControlPlaneConnectionState, subscribeToControlPlaneConnectionState, handleUnauthorized, refreshSession, discardInvalidControlPlaneRefreshToken, loadControlPlaneToken, requireControlPlaneToken, getClient2, boxPortsList, logRequest, logResponse, withConvexRequestTimeout, resolveInstanceIdFromEntries, loadViewerIdentity, ensureViewerIdentity, resolveProjectCanonical, normalizeOptionalString, resolveProjectForInstance, resolveProjectForInstanceLineage, toLegacyRegistry, resolveInstanceIdForAlias, getRegistryFromConvex, fetchRegistry, listViewerInstances, subscribeViewerInstancesWithClient, subscribePortsForInstanceWithClient, subscribeViewerInstances, upsertRegistry, recordRegistryUsage, removeRegistryEntry, resolveManagedDaemonControlTarget, recoverManagedDaemonControlTarget, resolveManagedDaemonProxyConnectInfo, subscribeBoxPorts, subscribeInstancePorts, fetchBoxPorts, fetchInstancePorts;
|
|
76399
76703
|
var init_spritesRegistry = __esm({
|
|
76400
76704
|
"../daemon/src/spritesRegistry.ts"() {
|
|
76401
76705
|
"use strict";
|
|
@@ -76431,8 +76735,8 @@ var init_spritesRegistry = __esm({
|
|
|
76431
76735
|
registryRemoveChunked = makeFunctionReference("instances:removeForViewerChunked");
|
|
76432
76736
|
instancesList = makeFunctionReference("instances:listForViewer");
|
|
76433
76737
|
helloViewerGet = makeFunctionReference("hello:getViewer");
|
|
76434
|
-
|
|
76435
|
-
|
|
76738
|
+
managedDaemonControlGrantIssue = makeFunctionReference("managedDaemonControlGrants:issueForViewer");
|
|
76739
|
+
managedDaemonRecoverForInstance = makeFunctionReference("managedDaemonTickets:recoverForInstanceForViewer");
|
|
76436
76740
|
logger2 = createLogger("sprites-registry");
|
|
76437
76741
|
TOKEN_REFRESH_BUFFER_MS = 5 * 60 * 1e3;
|
|
76438
76742
|
CONVEX_REQUEST_TIMEOUT_MS = 4e3;
|
|
@@ -77088,47 +77392,67 @@ var init_spritesRegistry = __esm({
|
|
|
77088
77392
|
throw error4;
|
|
77089
77393
|
}
|
|
77090
77394
|
};
|
|
77091
|
-
|
|
77092
|
-
const
|
|
77093
|
-
|
|
77094
|
-
const
|
|
77095
|
-
|
|
77096
|
-
|
|
77097
|
-
|
|
77395
|
+
resolveManagedDaemonControlTarget = async (client, args) => {
|
|
77396
|
+
const requestId = logRequest("query", "instances:listForViewer");
|
|
77397
|
+
try {
|
|
77398
|
+
const entries = await withConvexRequestTimeout(
|
|
77399
|
+
"instances:listForViewer",
|
|
77400
|
+
client.query(instancesList, {
|
|
77401
|
+
includeHiddenForks: true,
|
|
77402
|
+
includeDaemonHeartbeat: false
|
|
77403
|
+
})
|
|
77404
|
+
);
|
|
77405
|
+
logResponse(requestId, "query", "instances:listForViewer", "ok");
|
|
77406
|
+
const instanceId = args.instanceId?.trim() ?? "";
|
|
77407
|
+
const alias = args.alias.trim().toLowerCase();
|
|
77408
|
+
const match = entries.find(
|
|
77409
|
+
(entry) => instanceId ? entry.instanceId.trim() === instanceId : entry.alias.trim().toLowerCase() === alias
|
|
77410
|
+
);
|
|
77411
|
+
const providerInstanceId = match?.providerInstanceId?.trim() ?? "";
|
|
77412
|
+
if (!match || match.provider !== "e2b" || !providerInstanceId) {
|
|
77413
|
+
throw new Error(`Managed machine "${args.alias}" is unavailable.`);
|
|
77414
|
+
}
|
|
77415
|
+
return {
|
|
77416
|
+
instanceId: match.instanceId.trim(),
|
|
77098
77417
|
provider: "e2b",
|
|
77099
|
-
|
|
77100
|
-
|
|
77101
|
-
|
|
77102
|
-
|
|
77103
|
-
|
|
77104
|
-
|
|
77105
|
-
|
|
77106
|
-
|
|
77107
|
-
|
|
77418
|
+
providerInstanceId
|
|
77419
|
+
};
|
|
77420
|
+
} catch (error4) {
|
|
77421
|
+
logResponse(requestId, "query", "instances:listForViewer", "error", error4);
|
|
77422
|
+
await handleUnauthorized(error4);
|
|
77423
|
+
throw error4;
|
|
77424
|
+
}
|
|
77425
|
+
};
|
|
77426
|
+
recoverManagedDaemonControlTarget = async (client, args) => {
|
|
77427
|
+
const actionName = "managedDaemonTickets:recoverForInstanceForViewer";
|
|
77108
77428
|
const requestId = logRequest("action", actionName);
|
|
77109
77429
|
const deadline = Date.now() + MANAGED_DAEMON_WAKING_TIMEOUT_MS;
|
|
77110
77430
|
try {
|
|
77111
77431
|
while (true) {
|
|
77112
77432
|
const response = await withConvexRequestTimeout(
|
|
77113
77433
|
actionName,
|
|
77114
|
-
|
|
77115
|
-
instanceId:
|
|
77116
|
-
intent:
|
|
77117
|
-
|
|
77118
|
-
|
|
77119
|
-
|
|
77120
|
-
|
|
77121
|
-
...args.allowWake !== void 0 ? { allowWake: args.allowWake } : {}
|
|
77434
|
+
client.action(managedDaemonRecoverForInstance, {
|
|
77435
|
+
instanceId: args.target.instanceId,
|
|
77436
|
+
intent: "proxy",
|
|
77437
|
+
requestId: args.requestId,
|
|
77438
|
+
allowWake: args.allowWake,
|
|
77439
|
+
expectedProvider: args.target.provider,
|
|
77440
|
+
expectedProviderInstanceId: args.target.providerInstanceId
|
|
77122
77441
|
}),
|
|
77123
77442
|
MANAGED_DAEMON_HOT_PATH_CONVEX_REQUEST_TIMEOUT_MS
|
|
77124
77443
|
);
|
|
77125
77444
|
if (response?.ok === false && response.code === MANAGED_DAEMON_NOT_READY_CODE) {
|
|
77126
|
-
|
|
77445
|
+
throw new ManagedDaemonNotReadyError({
|
|
77446
|
+
provider: "e2b",
|
|
77447
|
+
alias: args.alias,
|
|
77448
|
+
state: response.state === "failed" ? "failed" : "pending",
|
|
77449
|
+
message: typeof response.message === "string" && response.message.trim() ? response.message.trim() : `Managed E2B machine "${args.alias}" is not ready.`
|
|
77450
|
+
});
|
|
77127
77451
|
}
|
|
77128
77452
|
if (response?.ok === true && response.status === "waking") {
|
|
77129
77453
|
if (Date.now() >= deadline) {
|
|
77130
77454
|
throw new Error(
|
|
77131
|
-
typeof response.detail === "string" && response.detail.trim() ? response.detail.trim() : "Managed daemon
|
|
77455
|
+
typeof response.detail === "string" && response.detail.trim() ? response.detail.trim() : "Managed daemon stayed in waking state too long."
|
|
77132
77456
|
);
|
|
77133
77457
|
}
|
|
77134
77458
|
await delay(
|
|
@@ -77136,26 +77460,11 @@ var init_spritesRegistry = __esm({
|
|
|
77136
77460
|
);
|
|
77137
77461
|
continue;
|
|
77138
77462
|
}
|
|
77139
|
-
|
|
77140
|
-
|
|
77141
|
-
const alias = typeof response?.alias === "string" ? response.alias.trim() : "";
|
|
77142
|
-
const instanceId = typeof response?.instanceId === "string" ? response.instanceId.trim() : "";
|
|
77143
|
-
const providerInstanceId = typeof response?.providerInstanceId === "string" ? response.providerInstanceId.trim() : "";
|
|
77144
|
-
const url2 = typeof response?.url === "string" ? response.url.trim() : "";
|
|
77145
|
-
const token = typeof response?.token === "string" ? response.token.trim() : "";
|
|
77146
|
-
if (response?.ok !== true || response?.status !== "running" || !alias || !instanceId || !providerInstanceId || !url2 || !token || provider !== "e2b") {
|
|
77147
|
-
throw new Error(
|
|
77148
|
-
"Managed daemon ticket response is missing required fields."
|
|
77149
|
-
);
|
|
77463
|
+
if (response?.ok !== true || response.status !== "running" || response.instanceId !== args.target.instanceId || response.providerInstanceId !== args.target.providerInstanceId) {
|
|
77464
|
+
throw new Error("Managed daemon recovery response is invalid.");
|
|
77150
77465
|
}
|
|
77151
|
-
|
|
77152
|
-
|
|
77153
|
-
alias,
|
|
77154
|
-
instanceId,
|
|
77155
|
-
providerInstanceId,
|
|
77156
|
-
url: url2,
|
|
77157
|
-
authToken: token
|
|
77158
|
-
};
|
|
77466
|
+
logResponse(requestId, "action", actionName, "ok");
|
|
77467
|
+
return;
|
|
77159
77468
|
}
|
|
77160
77469
|
} catch (error4) {
|
|
77161
77470
|
logResponse(requestId, "action", actionName, "error", error4);
|
|
@@ -77163,6 +77472,37 @@ var init_spritesRegistry = __esm({
|
|
|
77163
77472
|
throw error4;
|
|
77164
77473
|
}
|
|
77165
77474
|
};
|
|
77475
|
+
resolveManagedDaemonProxyConnectInfo = async (args) => {
|
|
77476
|
+
const client = await getClient2();
|
|
77477
|
+
const target = await resolveManagedDaemonControlTarget(client, args);
|
|
77478
|
+
return {
|
|
77479
|
+
provider: "e2b",
|
|
77480
|
+
wsUrl: buildDirectDaemonProxyWebSocketUrl(target),
|
|
77481
|
+
target,
|
|
77482
|
+
issueGrant: async (request2) => {
|
|
77483
|
+
const functionName2 = "managedDaemonControlGrants:issueForViewer";
|
|
77484
|
+
const requestId = logRequest("mutation", functionName2);
|
|
77485
|
+
try {
|
|
77486
|
+
const response = await withConvexRequestTimeout(
|
|
77487
|
+
functionName2,
|
|
77488
|
+
client.mutation(managedDaemonControlGrantIssue, request2)
|
|
77489
|
+
);
|
|
77490
|
+
logResponse(requestId, "mutation", functionName2, "ok");
|
|
77491
|
+
return response;
|
|
77492
|
+
} catch (error4) {
|
|
77493
|
+
logResponse(requestId, "mutation", functionName2, "error", error4);
|
|
77494
|
+
await handleUnauthorized(error4);
|
|
77495
|
+
throw error4;
|
|
77496
|
+
}
|
|
77497
|
+
},
|
|
77498
|
+
recover: async ({ requestId, allowWake }) => await recoverManagedDaemonControlTarget(client, {
|
|
77499
|
+
alias: args.alias,
|
|
77500
|
+
target,
|
|
77501
|
+
requestId,
|
|
77502
|
+
allowWake
|
|
77503
|
+
})
|
|
77504
|
+
};
|
|
77505
|
+
};
|
|
77166
77506
|
subscribeBoxPorts = async (options) => {
|
|
77167
77507
|
const client = await getClient2();
|
|
77168
77508
|
let currentInstanceId = null;
|
|
@@ -77453,19 +77793,10 @@ var init_ports2 = __esm({
|
|
|
77453
77793
|
);
|
|
77454
77794
|
this.discoveryAdapter = options.discoveryAdapter ?? createControlPlanePortDiscoveryAdapter();
|
|
77455
77795
|
this.knownBoxDiscoveryAdapter = options.knownBoxDiscoveryAdapter ?? createControlPlaneKnownBoxDiscoveryAdapter();
|
|
77456
|
-
this.resolveDirectDaemonConnectInfo = options.resolveDirectDaemonConnectInfo ?? (async ({ alias, instanceId
|
|
77457
|
-
|
|
77458
|
-
|
|
77459
|
-
|
|
77460
|
-
...allowWake !== void 0 ? { allowWake } : {},
|
|
77461
|
-
...instanceId ? { instanceId } : {}
|
|
77462
|
-
});
|
|
77463
|
-
return {
|
|
77464
|
-
provider: "e2b",
|
|
77465
|
-
url: info2.url,
|
|
77466
|
-
authToken: info2.authToken
|
|
77467
|
-
};
|
|
77468
|
-
});
|
|
77796
|
+
this.resolveDirectDaemonConnectInfo = options.resolveDirectDaemonConnectInfo ?? (async ({ alias, instanceId }) => await resolveManagedDaemonProxyConnectInfo({
|
|
77797
|
+
alias,
|
|
77798
|
+
...instanceId ? { instanceId } : {}
|
|
77799
|
+
}));
|
|
77469
77800
|
this.subscriptionRetryDelayMs = Math.max(
|
|
77470
77801
|
100,
|
|
77471
77802
|
options.subscriptionRetryDelayMs ?? SUBSCRIPTION_RETRY_DELAY_MS
|
|
@@ -79924,6 +80255,30 @@ var init_src = __esm({
|
|
|
79924
80255
|
// src/bin/dvbd.ts
|
|
79925
80256
|
init_devboxCore();
|
|
79926
80257
|
|
|
80258
|
+
// src/devbox/compromisedRoots.ts
|
|
80259
|
+
import { X509Certificate } from "node:crypto";
|
|
80260
|
+
import tls2 from "node:tls";
|
|
80261
|
+
var COMPROMISED_ROOT_SHA256_FINGERPRINTS = /* @__PURE__ */ new Set([
|
|
80262
|
+
// emSign ECC Root CA - G3
|
|
80263
|
+
"86:A1:EC:BA:08:9C:4A:8D:3B:BE:27:34:C6:12:BA:34:1D:81:3E:04:3C:F9:E8:A8:62:CD:5C:57:A3:6B:BE:6B",
|
|
80264
|
+
// AAA Certificate Services (Comodo)
|
|
80265
|
+
"D7:A7:A0:FB:5D:7E:27:31:D7:71:E9:48:4E:BC:DE:F7:1D:5F:0C:3E:0A:29:48:78:2B:C8:3E:E0:EA:69:9E:F4"
|
|
80266
|
+
]);
|
|
80267
|
+
var isCompromisedRoot = (pem) => COMPROMISED_ROOT_SHA256_FINGERPRINTS.has(
|
|
80268
|
+
new X509Certificate(pem).fingerprint256
|
|
80269
|
+
);
|
|
80270
|
+
var distrustCompromisedRoots = () => {
|
|
80271
|
+
if (typeof tls2.setDefaultCACertificates !== "function") {
|
|
80272
|
+
return !tls2.rootCertificates.some(isCompromisedRoot);
|
|
80273
|
+
}
|
|
80274
|
+
const current = tls2.getCACertificates("default");
|
|
80275
|
+
const kept = current.filter((pem) => !isCompromisedRoot(pem));
|
|
80276
|
+
if (kept.length !== current.length) {
|
|
80277
|
+
tls2.setDefaultCACertificates(kept);
|
|
80278
|
+
}
|
|
80279
|
+
return true;
|
|
80280
|
+
};
|
|
80281
|
+
|
|
79927
80282
|
// src/devbox/daemonWorkingDirectory.ts
|
|
79928
80283
|
init_devboxCore();
|
|
79929
80284
|
import fs6 from "node:fs";
|
|
@@ -79979,6 +80334,7 @@ var maybeDelayDaemonShutdownForTests = async () => {
|
|
|
79979
80334
|
};
|
|
79980
80335
|
var run = async () => {
|
|
79981
80336
|
assertNodeVersion();
|
|
80337
|
+
distrustCompromisedRoots();
|
|
79982
80338
|
ensureDaemonWorkingDirectory();
|
|
79983
80339
|
initDevboxSentry("dvbd");
|
|
79984
80340
|
const { runDaemon: runDaemon2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
@@ -80048,4 +80404,4 @@ smol-toml/dist/index.js:
|
|
|
80048
80404
|
*)
|
|
80049
80405
|
*/
|
|
80050
80406
|
|
|
80051
|
-
//# debugId=
|
|
80407
|
+
//# debugId=9db0576c-15b7-50ce-b106-337e56c41bd4
|