@veris-ai/daytona 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/gateway.d.ts CHANGED
@@ -69,6 +69,12 @@ export declare function gatewayIps(credential: {
69
69
  * store directly rather than honouring the variables. It is best-effort.
70
70
  */
71
71
  export declare function installCa(sandbox: Sandbox, caPem: string): Promise<void>;
72
+ /**
73
+ * Put the Node proxy preload where NODE_OPTIONS names it. Separate from the
74
+ * CA install because it is about routing, not trust: a sandbox created with
75
+ * installCa: false still needs its Node SDKs to reach the gateway.
76
+ */
77
+ export declare function installNodeProxyPreload(sandbox: Sandbox): Promise<void>;
72
78
  /**
73
79
  * Run the bundled-CA patcher installed above, and report what it changed.
74
80
  *
package/dist/index.cjs CHANGED
@@ -30,6 +30,8 @@ __export(index_exports, {
30
30
  DELETE_SANDBOXES: () => DELETE_SANDBOXES,
31
31
  Daytona: () => Daytona,
32
32
  MissingCredentialsError: () => MissingCredentialsError,
33
+ NODE_PROXY_FLAG: () => NODE_PROXY_FLAG,
34
+ NODE_PROXY_PRELOAD: () => NODE_PROXY_PRELOAD,
33
35
  NODE_TRUST_FLAG: () => NODE_TRUST_FLAG,
34
36
  ReceiptIntegrityError: () => ReceiptIntegrityError,
35
37
  SDK_VERSION: () => SDK_VERSION,
@@ -58,7 +60,9 @@ __export(index_exports, {
58
60
  isPermissionDenied: () => isPermissionDenied,
59
61
  isVerisSandbox: () => isVerisSandbox,
60
62
  missingKeyMessage: () => missingKeyMessage,
63
+ nodeOptionsWithProxy: () => nodeOptionsWithProxy,
61
64
  nodeOptionsWithTrust: () => nodeOptionsWithTrust,
65
+ nodeProxyPreloadScript: () => nodeProxyPreloadScript,
62
66
  patchBundledCas: () => patchBundledCas,
63
67
  profilePath: () => profilePath,
64
68
  requireVerisCredentials: () => requireVerisCredentials,
@@ -69,6 +73,7 @@ __export(index_exports, {
69
73
  twinHosts: () => twinHosts,
70
74
  vendorHosts: () => vendorHosts,
71
75
  vendoredTrustEnv: () => vendoredTrustEnv,
76
+ verisNodeOptions: () => verisNodeOptions,
72
77
  verisOwnsTwin: () => verisOwnsTwin,
73
78
  verisTwinId: () => verisTwinId
74
79
  });
@@ -598,9 +603,38 @@ function bundledCaPatchScript() {
598
603
  }
599
604
  var NODE_TRUST_FLAG = "--use-openssl-ca";
600
605
  function nodeOptionsWithTrust(existing) {
606
+ return appendFlag(existing, NODE_TRUST_FLAG);
607
+ }
608
+ var NODE_PROXY_PRELOAD = "/tmp/veris-node-proxy.cjs";
609
+ var NODE_PROXY_FLAG = `--require ${NODE_PROXY_PRELOAD}`;
610
+ function nodeProxyPreloadScript() {
611
+ return [
612
+ `// Preloaded by @veris-ai/daytona through NODE_OPTIONS=--require.`,
613
+ `// Gives every http(s).Agent the proxy environment, which Node applies only`,
614
+ `// to its global agents under NODE_USE_ENV_PROXY=1. An SDK that builds its own`,
615
+ `// Agent would otherwise dial the vendor directly, which this sandbox cannot.`,
616
+ `for (const mod of [require("http"), require("https")]) {`,
617
+ ` const Base = mod.Agent`,
618
+ ` mod.Agent = class Agent extends Base {`,
619
+ ` constructor(options) {`,
620
+ ` super({ proxyEnv: process.env, ...(options || {}) })`,
621
+ ` }`,
622
+ ` }`,
623
+ `}`,
624
+ ``
625
+ ].join("\n");
626
+ }
627
+ function nodeOptionsWithProxy(existing) {
628
+ return appendFlag(existing, NODE_PROXY_FLAG);
629
+ }
630
+ function verisNodeOptions(existing, opts = {}) {
631
+ const withProxy = nodeOptionsWithProxy(existing);
632
+ return opts.trust === false ? withProxy : nodeOptionsWithTrust(withProxy);
633
+ }
634
+ function appendFlag(existing, flag) {
601
635
  const base = (existing ?? "").trim();
602
- if (base.split(/\s+/).includes(NODE_TRUST_FLAG)) return base;
603
- return base ? `${base} ${NODE_TRUST_FLAG}` : NODE_TRUST_FLAG;
636
+ if (base === flag || base.startsWith(`${flag} `) || base.endsWith(` ${flag}`) || base.includes(` ${flag} `)) return base;
637
+ return base ? `${base} ${flag}` : flag;
604
638
  }
605
639
  var CA_INSTALL_CMD = [
606
640
  "update-ca-certificates",
@@ -673,6 +707,7 @@ function assertProxyUrl(raw) {
673
707
  async function installCa(sandbox, caPem) {
674
708
  await sandbox.fs.uploadFile(Buffer.from(caPem, "utf8"), VERIS_CA_FILE);
675
709
  await sandbox.fs.uploadFile(Buffer.from(bundledCaPatchScript(), "utf8"), BUNDLED_CA_PATCH_SCRIPT);
710
+ await installNodeProxyPreload(sandbox);
676
711
  const script = [
677
712
  `chmod 0644 ${VERIS_CA_FILE}`,
678
713
  // Public roots first so they keep working; ours appended. `cat` of a
@@ -698,6 +733,9 @@ async function installCa(sandbox, caPem) {
698
733
  );
699
734
  }
700
735
  }
736
+ async function installNodeProxyPreload(sandbox) {
737
+ await sandbox.fs.uploadFile(Buffer.from(nodeProxyPreloadScript(), "utf8"), NODE_PROXY_PRELOAD);
738
+ }
701
739
  async function patchBundledCas(sandbox) {
702
740
  const r = await sh(sandbox, `sh ${BUNDLED_CA_PATCH_SCRIPT}`, 180).catch((e) => ({ exitCode: 1, result: String(e) }));
703
741
  return (r.result ?? "").split("\n").filter((line) => line.startsWith(BUNDLED_CA_PATCHED_MARKER)).map((line) => line.slice(BUNDLED_CA_PATCHED_MARKER.length).trim()).filter(Boolean);
@@ -990,7 +1028,7 @@ function requireVerisCredentials(opts = {}) {
990
1028
  }
991
1029
 
992
1030
  // src/version.ts
993
- var SDK_VERSION = true ? "0.3.0" : "0.0.0-dev";
1031
+ var SDK_VERSION = true ? "0.3.1" : "0.0.0-dev";
994
1032
 
995
1033
  // src/daytona.ts
996
1034
  var LABEL = {
@@ -1068,9 +1106,12 @@ var Daytona = class extends import_sdk.Daytona {
1068
1106
  const verisManaged = {
1069
1107
  ...v.installCa !== false ? sanitizeTrustEnv(void 0) : {},
1070
1108
  // Node reads none of the variables above once Daytona has overwritten
1071
- // them; the flag makes it read OpenSSL's store, which the CA install
1072
- // fills. Appended, not replaced: a caller's own NODE_OPTIONS keep working.
1073
- ...v.installCa !== false ? { NODE_OPTIONS: nodeOptionsWithTrust(rest.envVars?.NODE_OPTIONS) } : {},
1109
+ // them; the trust flag makes it read OpenSSL's store, which the CA
1110
+ // install fills. The preload gives every http(s).Agent the proxy
1111
+ // environment, which NODE_USE_ENV_PROXY below reaches only for the
1112
+ // global ones. Appended, not replaced: a caller's own NODE_OPTIONS keep
1113
+ // working.
1114
+ NODE_OPTIONS: verisNodeOptions(rest.envVars?.NODE_OPTIONS, { trust: v.installCa !== false }),
1074
1115
  // Node ignores HTTPS_PROXY unless told to, and Daytona blocks anything
1075
1116
  // that dials out directly — so without this every plain `https.get`
1076
1117
  // and `fetch` in Node 24+ dies with ECONNRESET instead of reaching
@@ -1113,7 +1154,8 @@ var Daytona = class extends import_sdk.Daytona {
1113
1154
  });
1114
1155
  }
1115
1156
  try {
1116
- await installCa(sandbox, credential.ca_pem);
1157
+ if (v.installCa !== false) await installCa(sandbox, credential.ca_pem);
1158
+ else await installNodeProxyPreload(sandbox);
1117
1159
  await probeCanary(sandbox, credential.canary_host, twin.id);
1118
1160
  } catch (err) {
1119
1161
  await sandbox.delete().catch(() => {
@@ -1375,6 +1417,8 @@ function teardownRefusedMessage(r) {
1375
1417
  DELETE_SANDBOXES,
1376
1418
  Daytona,
1377
1419
  MissingCredentialsError,
1420
+ NODE_PROXY_FLAG,
1421
+ NODE_PROXY_PRELOAD,
1378
1422
  NODE_TRUST_FLAG,
1379
1423
  ReceiptIntegrityError,
1380
1424
  SDK_VERSION,
@@ -1402,7 +1446,9 @@ function teardownRefusedMessage(r) {
1402
1446
  isPermissionDenied,
1403
1447
  isVerisSandbox,
1404
1448
  missingKeyMessage,
1449
+ nodeOptionsWithProxy,
1405
1450
  nodeOptionsWithTrust,
1451
+ nodeProxyPreloadScript,
1406
1452
  patchBundledCas,
1407
1453
  profilePath,
1408
1454
  requireVerisCredentials,
@@ -1413,6 +1459,7 @@ function teardownRefusedMessage(r) {
1413
1459
  twinHosts,
1414
1460
  vendorHosts,
1415
1461
  vendoredTrustEnv,
1462
+ verisNodeOptions,
1416
1463
  verisOwnsTwin,
1417
1464
  verisTwinId,
1418
1465
  ...require("@daytona/sdk")