@forgezero/agent 0.1.58 → 0.1.60

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/fz-agent.js CHANGED
@@ -8448,7 +8448,7 @@ function assertSupportedGuestImage(imageKey) {
8448
8448
  }
8449
8449
 
8450
8450
  // src/version.ts
8451
- var VERSION2 = "0.1.58";
8451
+ var VERSION2 = "0.1.60";
8452
8452
 
8453
8453
  // src/ssh-bootstrap.ts
8454
8454
  class SshBootstrapError extends Error {
@@ -8583,7 +8583,7 @@ var verifiedBunArchive = async (directory) => {
8583
8583
  writeFileSync4(archive, bytes, { mode: 384, flag: "wx" });
8584
8584
  return archive;
8585
8585
  };
8586
- var remote = (exec, ssh, destination, code, argv2, secret = false) => checked(exec, ["ssh", ...ssh, destination, "--", ...argv2], code, { secret });
8586
+ var remote = (exec, ssh, destination, code, argv2, secret = false, stdin) => checked(exec, ["ssh", ...ssh, destination, "--", ...argv2], code, { secret, ...stdin !== undefined ? { stdin } : {} });
8587
8587
  async function executeSshBootstrap(claim, options) {
8588
8588
  validateClaim(claim);
8589
8589
  if (!options.sshKeyPath.startsWith("/") || /[\r\n]/.test(options.sshKeyPath))
@@ -8622,14 +8622,11 @@ async function executeSshBootstrap(claim, options) {
8622
8622
  realm: claim.realm,
8623
8623
  nodeHostname: claim.target.nodeHostname,
8624
8624
  telemetryEndpoint: telemetry.origin,
8625
- enrolTokenFile: "/run/forgezero-bootstrap/enrol.token",
8626
8625
  profile: "app",
8627
8626
  software: [{ id: "bun", version: PINNED_BUN_VERSION }]
8628
8627
  };
8629
8628
  const files = {
8630
8629
  "config.json": `${JSON.stringify(config, null, 2)}
8631
- `,
8632
- "enrol.token": `${claim.enrolmentToken}
8633
8630
  `
8634
8631
  };
8635
8632
  for (const [name, content] of Object.entries(files))
@@ -8753,7 +8750,7 @@ async function executeSshBootstrap(claim, options) {
8753
8750
  "/usr/local/lib/forgezero/agent/fz.js",
8754
8751
  "/usr/local/bin/fz"
8755
8752
  ]);
8756
- for (const name of ["config.json", "enrol.token"])
8753
+ for (const name of ["config.json"])
8757
8754
  await remote(exec, ssh, destination, "REMOTE_CONFIG_INSTALL_FAILED", [
8758
8755
  "/usr/bin/sudo",
8759
8756
  "-n",
@@ -8769,10 +8766,12 @@ async function executeSshBootstrap(claim, options) {
8769
8766
  "/usr/local/bin/fz",
8770
8767
  "agent",
8771
8768
  "activate",
8769
+ "credentials-stdin",
8772
8770
  "--bootstrap-config",
8773
8771
  "/run/forgezero-bootstrap/config.json",
8774
8772
  "--apply"
8775
- ], true);
8773
+ ], true, `${JSON.stringify({ enrolmentToken: claim.enrolmentToken })}
8774
+ `);
8776
8775
  await remote(exec, ssh, destination, "REMOTE_CLEANUP_FAILED", [
8777
8776
  "/usr/bin/sudo",
8778
8777
  "-n",
@@ -13078,10 +13077,10 @@ var AGENT_CREDENTIAL_LOCATIONS = [
13078
13077
  "tenant-compute"
13079
13078
  ];
13080
13079
  var AGENT_CREDENTIAL_POLICY = {
13081
- operator: { vault: false, systemdFallback: false, attendedFile: true },
13082
- metal: { vault: false, systemdFallback: true, attendedFile: false },
13083
- "platform-compute": { vault: true, systemdFallback: true, attendedFile: false },
13084
- "tenant-compute": { vault: true, systemdFallback: true, attendedFile: false }
13080
+ operator: { vault: false, systemdFallback: false, hiddenInput: true },
13081
+ metal: { vault: false, systemdFallback: true, hiddenInput: false },
13082
+ "platform-compute": { vault: true, systemdFallback: true, hiddenInput: false },
13083
+ "tenant-compute": { vault: true, systemdFallback: true, hiddenInput: false }
13085
13084
  };
13086
13085
  var CREDENTIAL_NAME = /^[A-Z_][A-Z0-9_]*$/;
13087
13086
  var SCOPE_PART2 = /^[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}$/;
@@ -13365,7 +13364,7 @@ async function runRecoveryHost(args, run2 = execute2) {
13365
13364
  nonEmpty("/etc/forgezero/creds/arangodb-jwt.cred");
13366
13365
  const hasDatabase = role !== "none";
13367
13366
  if (hasDatabase) {
13368
- nonEmpty("/etc/forgezero/creds/backup-s3-secret.cred");
13367
+ nonEmpty("/etc/forgezero/creds/backup.s3.secretAccessKey.cred");
13369
13368
  nonEmpty("/etc/forgezero/creds/backup-recovery-root.cred");
13370
13369
  }
13371
13370
  const slot = activeSlot();
@@ -13412,7 +13411,7 @@ async function runRecoveryHost(args, run2 = execute2) {
13412
13411
  "--property=LoadCredentialEncrypted=arangodb-jwt:/etc/forgezero/creds/arangodb-jwt.cred",
13413
13412
  ...args.includes("--fleet-fenced") ? ["--property=Environment=FZ_RECOVERY_FLEET_FENCED=all-api-and-scheduler-replicas-are-stopped"] : [],
13414
13413
  ...args.includes("--backup-credentials") ? [
13415
- "--property=LoadCredentialEncrypted=backup-s3-secret:/etc/forgezero/creds/backup-s3-secret.cred",
13414
+ "--property=LoadCredentialEncrypted=backup.s3.secretAccessKey:/etc/forgezero/creds/backup.s3.secretAccessKey.cred",
13416
13415
  "--property=LoadCredentialEncrypted=backup-recovery-root:/etc/forgezero/creds/backup-recovery-root.cred"
13417
13416
  ] : []
13418
13417
  ];
@@ -14177,10 +14176,11 @@ function planProvision(options) {
14177
14176
  const warpEnabled = warpValues.every(Boolean);
14178
14177
  if (warpValues.some(Boolean) && !warpEnabled)
14179
14178
  throw new Error("WARP configuration must be supplied together");
14180
- const enrolmentEnabled = Boolean(options.enrolTokenSourcePath && options.enrolTokenCredentialPath && options.enrolStatePath);
14181
- if (Boolean(options.enrolTokenSourcePath) !== Boolean(options.enrolTokenCredentialPath) || Boolean(options.enrolTokenCredentialPath) !== Boolean(options.enrolStatePath))
14182
- throw new Error("direct enrolment paths must be supplied together");
14183
- const enrolTokenSourcePath = enrolmentEnabled ? systemdPath(options.enrolTokenSourcePath, "enrolment source") : undefined;
14179
+ const enrolmentEnabled = Boolean(options.enrolTokenCredentialPath && options.enrolStatePath);
14180
+ if (Boolean(options.enrolTokenCredentialPath) !== Boolean(options.enrolStatePath) || options.enrolTokenSourcePath && !enrolmentEnabled) {
14181
+ throw new Error("direct enrolment credential and state paths must be supplied together");
14182
+ }
14183
+ const enrolTokenSourcePath = options.enrolTokenSourcePath ? systemdPath(options.enrolTokenSourcePath, "enrolment source") : undefined;
14184
14184
  const enrolTokenCredentialPath = enrolmentEnabled ? systemdPath(options.enrolTokenCredentialPath, "enrolment credential") : undefined;
14185
14185
  const enrolStatePath = enrolmentEnabled ? systemdPath(options.enrolStatePath, "enrolment state") : undefined;
14186
14186
  const enrolStateDir = enrolStatePath?.replace(/\/[^/]+$/, "");
@@ -14308,7 +14308,12 @@ function planProvision(options) {
14308
14308
  ] : [],
14309
14309
  ...enrolmentEnabled ? [
14310
14310
  step2("enrolment state directory", { kind: "directories", directories: [{ path: enrolStateDir, mode: 448, owner: user, group: user }] }),
14311
- step2("encrypted one-time enrolment capability", { kind: "ensure-enrolment", state: enrolStatePath, source: enrolTokenSourcePath, credential: enrolTokenCredentialPath })
14311
+ ...enrolTokenSourcePath ? [step2("encrypted one-time enrolment capability", {
14312
+ kind: "ensure-enrolment",
14313
+ state: enrolStatePath,
14314
+ source: enrolTokenSourcePath,
14315
+ credential: enrolTokenCredentialPath
14316
+ })] : []
14312
14317
  ] : [],
14313
14318
  ...deploymentEnabled ? [step2("deployment directories", { kind: "directories", directories: [
14314
14319
  { path: deployRoot, mode: 493, owner: "root", group: "root" },
@@ -14657,6 +14662,7 @@ var JWT_CREDENTIAL = `${CREDS}/arangodb-jwt.cred`;
14657
14662
  var ENROL_CREDENTIAL = `${CREDS}/enrol-token.cred`;
14658
14663
  var TUNNEL_CREDENTIAL = `${CREDS}/CF_TUNNEL_CONNECTOR_TOKEN.cred`;
14659
14664
  var CF_API_CREDENTIAL = `${CREDS}/CF_API_TOKEN.cred`;
14665
+ var CF_TUNNEL_API_CREDENTIAL = `${CREDS}/CF_TUNNEL_TOKEN.cred`;
14660
14666
  var WARP_CONNECTOR_CREDENTIAL = `${CREDS}/CF_WARP_CONNECTOR_TOKEN.cred`;
14661
14667
  var REALTIME_PUBLISH_CREDENTIAL = `${CREDS}/REALTIME_PUBLISH_SECRET.cred`;
14662
14668
  var REALTIME_TICKET_CREDENTIAL = `${CREDS}/REALTIME_TICKET_SECRET.cred`;
@@ -14887,10 +14893,10 @@ function localBootstrapHost() {
14887
14893
  throw new Error(`Agent software requirements failed: ${result.output.trim()}`);
14888
14894
  return result;
14889
14895
  },
14890
- async installAgent(config, enrolTokenSourcePath) {
14896
+ async installAgent(config) {
14891
14897
  const capabilities = await readCapabilities(localRunner);
14892
14898
  const deployRoot = config.deployRoot ?? "/opt/forgezero";
14893
- const hasBinding = config.kind === "enrolled-compute" || Boolean(enrolTokenSourcePath) || existsSync19("/var/lib/forgezero/enrolment.json");
14899
+ const hasBinding = config.kind === "enrolled-compute" || existsSync19(ENROL_CREDENTIAL) || existsSync19("/var/lib/forgezero/enrolment.json");
14894
14900
  if (config.kind === "platform") {
14895
14901
  const lifecycle = config.database.role === "none" ? {
14896
14902
  apiUnits: ["forgezero@blue.service", "forgezero@green.service"],
@@ -14933,8 +14939,7 @@ function localBootstrapHost() {
14933
14939
  telemetryEndpoint: config.telemetryEndpoint,
14934
14940
  binPath: "/usr/local/lib/forgezero/agent/fz-agent",
14935
14941
  sourceBinPath: PACKAGED_AGENT_BIN,
14936
- ...config.kind === "enrolled-compute" || enrolTokenSourcePath ? {
14937
- enrolTokenSourcePath: config.kind === "enrolled-compute" ? config.enrolTokenFile : enrolTokenSourcePath,
14942
+ ...hasBinding ? {
14938
14943
  enrolTokenCredentialPath: ENROL_CREDENTIAL,
14939
14944
  enrolStatePath: "/var/lib/forgezero/enrolment.json",
14940
14945
  apiUrl: config.apiUrl,