buckyos 0.7.175 → 0.7.180

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.
Files changed (60) hide show
  1. package/cli/dist/cli.mjs +147 -41
  2. package/cli/dist/cli.mjs.map +1 -1
  3. package/cli/modules/pikg.ts +193 -51
  4. package/cli/runtime/fs_retry.ts +26 -0
  5. package/cli/runtime/host_deno.ts +17 -2
  6. package/cli/runtime/host_node.ts +16 -2
  7. package/cli/version.ts +1 -1
  8. package/dist/aiworkspace_client.d.ts +36 -2
  9. package/dist/aiworkspace_client.d.ts.map +1 -1
  10. package/dist/app-frame.cjs +1 -1
  11. package/dist/app-frame.cjs.map +1 -1
  12. package/dist/app-frame.d.ts +57 -1
  13. package/dist/app-frame.d.ts.map +1 -1
  14. package/dist/app-frame.mjs +291 -6
  15. package/dist/app-frame.mjs.map +1 -1
  16. package/dist/browser.cjs +1 -1
  17. package/dist/browser.cjs.map +1 -1
  18. package/dist/browser.d.ts +2 -0
  19. package/dist/browser.d.ts.map +1 -1
  20. package/dist/browser.mjs +16 -2
  21. package/dist/browser.mjs.map +1 -1
  22. package/dist/content.cjs +1 -1
  23. package/dist/content.cjs.map +1 -1
  24. package/dist/content.d.ts +77 -0
  25. package/dist/content.d.ts.map +1 -1
  26. package/dist/content.mjs +65 -0
  27. package/dist/content.mjs.map +1 -1
  28. package/dist/content_objid-1aff74b6.js +2 -0
  29. package/dist/content_objid-1aff74b6.js.map +1 -0
  30. package/dist/content_objid-9232bcaf.mjs +29 -0
  31. package/dist/content_objid-9232bcaf.mjs.map +1 -0
  32. package/dist/content_objid.d.ts +15 -0
  33. package/dist/content_objid.d.ts.map +1 -0
  34. package/dist/executor_client-7ce0ddc7.js +13 -0
  35. package/dist/executor_client-7ce0ddc7.js.map +1 -0
  36. package/dist/{executor_client-c620d25c.mjs → executor_client-bfc8a1e1.mjs} +77 -6
  37. package/dist/executor_client-bfc8a1e1.mjs.map +1 -0
  38. package/dist/executor_client.d.ts +1 -1
  39. package/dist/executor_client.d.ts.map +1 -1
  40. package/dist/index.cjs +1 -1
  41. package/dist/index.cjs.map +1 -1
  42. package/dist/index.d.ts +1 -0
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.mjs +12 -3
  45. package/dist/index.mjs.map +1 -1
  46. package/dist/nfsp.cjs.map +1 -1
  47. package/dist/nfsp.d.ts +2 -1
  48. package/dist/nfsp.d.ts.map +1 -1
  49. package/dist/nfsp.mjs.map +1 -1
  50. package/dist/node.cjs +1 -1
  51. package/dist/node.mjs +2 -2
  52. package/dist/provision.cjs +1 -1
  53. package/dist/provision.cjs.map +1 -1
  54. package/dist/provision.mjs +48 -16
  55. package/dist/provision.mjs.map +1 -1
  56. package/dist/provision_activate.d.ts.map +1 -1
  57. package/package.json +1 -1
  58. package/dist/executor_client-c620d25c.mjs.map +0 -1
  59. package/dist/executor_client-d4439d54.js +0 -13
  60. package/dist/executor_client-d4439d54.js.map +0 -1
@@ -14209,7 +14209,7 @@ function readJsonObjectOrThrow(filePath) {
14209
14209
  function jsonPretty(value) {
14210
14210
  return JSON.stringify(value, null, 2);
14211
14211
  }
14212
- function commitFile(filePath, content, mode, dirMode) {
14212
+ function commitFile(filePath, content, mode, dirMode, placeholder) {
14213
14213
  const fs = requireNode$1("node:fs");
14214
14214
  const path = requireNode$1("node:path");
14215
14215
  const directory = path.dirname(filePath);
@@ -14217,15 +14217,23 @@ function commitFile(filePath, content, mode, dirMode) {
14217
14217
  if (!isWindows()) {
14218
14218
  fs.chmodSync(directory, dirMode);
14219
14219
  }
14220
- if (lstatOrNull(filePath)) {
14221
- throw new Error(`refusing to overwrite existing file: ${filePath}`);
14222
- }
14220
+ const assertDestination = () => {
14221
+ if (placeholder !== void 0) {
14222
+ if (readGatewayPlaceholder(filePath) !== placeholder) {
14223
+ throw new Error(`gateway placeholder changed during activation: ${filePath}`);
14224
+ }
14225
+ } else if (lstatOrNull(filePath)) {
14226
+ throw new Error(`refusing to overwrite existing file: ${filePath}`);
14227
+ }
14228
+ };
14229
+ assertDestination();
14223
14230
  const temporary = path.join(directory, `.${path.basename(filePath)}.provision-${randomSuffix()}`);
14224
14231
  try {
14225
14232
  fs.writeFileSync(temporary, content, { mode, flag: "wx" });
14226
14233
  if (!isWindows()) {
14227
14234
  fs.chmodSync(temporary, mode);
14228
14235
  }
14236
+ assertDestination();
14229
14237
  fs.renameSync(temporary, filePath);
14230
14238
  } finally {
14231
14239
  if (lstatOrNull(temporary)) {
@@ -14474,13 +14482,23 @@ function observeIdentity(nodeIdentityPath, problems) {
14474
14482
  return { nodeIdentity: null, zoneDid: null, deviceDid: null };
14475
14483
  }
14476
14484
  }
14477
- function gatewayParamsIsPlaceholder(gatewayParamsPath) {
14485
+ function readGatewayPlaceholder(gatewayParamsPath) {
14486
+ var _a3;
14478
14487
  try {
14479
- const value = readJsonObjectOrThrow(gatewayParamsPath);
14488
+ if (!((_a3 = lstatOrNull(gatewayParamsPath)) == null ? void 0 : _a3.isFile()))
14489
+ return void 0;
14490
+ const content = requireNode$1("node:fs").readFileSync(gatewayParamsPath, "utf8");
14491
+ const value = JSON.parse(content);
14492
+ if (!value || typeof value !== "object" || Array.isArray(value) || Object.keys(value).some((key) => key !== "params"))
14493
+ return void 0;
14480
14494
  const params = value.params;
14481
- return !!params && typeof params === "object" && params.device_did === UNACTIVATED_GATEWAY_DEVICE_DID;
14495
+ if (!params || typeof params !== "object" || Array.isArray(params) || params.device_did !== UNACTIVATED_GATEWAY_DEVICE_DID || Object.keys(params).some((key) => key !== "device_did" && key !== "rtcp_port"))
14496
+ return void 0;
14497
+ if (params.rtcp_port !== void 0 && (typeof params.rtcp_port !== "string" || !/^\d+$/.test(params.rtcp_port) || Number(params.rtcp_port) < 1 || Number(params.rtcp_port) > 65535))
14498
+ return void 0;
14499
+ return content;
14482
14500
  } catch {
14483
- return false;
14501
+ return void 0;
14484
14502
  }
14485
14503
  }
14486
14504
  async function validateActivationMaterials(rootDir, layout, identity, problems) {
@@ -14675,6 +14693,9 @@ function getXFromJwkSafe(jwk) {
14675
14693
  }
14676
14694
  }
14677
14695
  async function inspectActivationRoot(rootDir) {
14696
+ return inspectRoot(rootDir);
14697
+ }
14698
+ async function inspectRoot(rootDir, ignoreOwnLock = false) {
14678
14699
  const path = requireNode$1("node:path");
14679
14700
  const root = path.resolve(String(rootDir ?? ""));
14680
14701
  const observedAt = buckyosGetUnixTimestamp();
@@ -14707,7 +14728,7 @@ async function inspectActivationRoot(rootDir) {
14707
14728
  return base("not_installed");
14708
14729
  }
14709
14730
  const etcDir = path.join(root, "etc");
14710
- const lock = readLock(path.join(etcDir, ACTIVATION_LOCK_FILE_NAME));
14731
+ const lock = ignoreOwnLock ? null : readLock(path.join(etcDir, ACTIVATION_LOCK_FILE_NAME));
14711
14732
  const identity = observeIdentity(path.join(etcDir, "node_identity.json"), problems);
14712
14733
  let zoneDid = identity.zoneDid;
14713
14734
  let deviceDid = identity.deviceDid;
@@ -14752,7 +14773,7 @@ async function inspectActivationRoot(rootDir) {
14752
14773
  }
14753
14774
  }
14754
14775
  const gatewayEntry = files.find((file) => file.role === "gateway_params");
14755
- const gatewayPlaceholder = (gatewayEntry == null ? void 0 : gatewayEntry.present) === true && gatewayParamsIsPlaceholder(path.join(etcDir, "node_gateway_params.json"));
14776
+ const gatewayPlaceholder = (gatewayEntry == null ? void 0 : gatewayEntry.present) === true && readGatewayPlaceholder(path.join(etcDir, "node_gateway_params.json")) !== void 0;
14756
14777
  if (gatewayEntry && gatewayPlaceholder)
14757
14778
  gatewayEntry.present = false;
14758
14779
  const markers = files.filter((file) => file.present && file.role !== "dns_records");
@@ -14839,8 +14860,11 @@ function targetStateProblem(status) {
14839
14860
  }
14840
14861
  }
14841
14862
  async function checkOfflineActivation(options) {
14863
+ return checkActivation(options);
14864
+ }
14865
+ async function checkActivation(options, ignoreOwnLock = false) {
14842
14866
  const params = normalizeActivationParams(options);
14843
- const status = await inspectActivationRoot(params.rootDir);
14867
+ const status = await inspectRoot(params.rootDir, ignoreOwnLock);
14844
14868
  const problems = [];
14845
14869
  const stateProblem = targetStateProblem(status);
14846
14870
  if (stateProblem)
@@ -15068,18 +15092,20 @@ async function activateOfflineZone(options) {
15068
15092
  };
15069
15093
  let recheck;
15070
15094
  try {
15071
- recheck = await checkOfflineActivation(options);
15095
+ recheck = await checkActivation(options, true);
15072
15096
  } catch (error) {
15073
15097
  releaseLock();
15074
15098
  throw error;
15075
15099
  }
15076
- const recheckProblems = recheck.problems.filter((problem) => problem.code !== "ACTIVATION_IN_PROGRESS");
15077
- if (recheckProblems.length > 0) {
15100
+ if (!recheck.ready) {
15078
15101
  releaseLock();
15079
- throw precheckError({ ...recheck, problems: recheckProblems });
15102
+ throw precheckError(recheck);
15080
15103
  }
15104
+ const gatewayPlaceholder = readGatewayPlaceholder(layout.gatewayParamsPath);
15081
15105
  for (const file of files) {
15082
15106
  if (lstatOrNull(file.absolutePath)) {
15107
+ if (file.role === "gateway_params" && gatewayPlaceholder !== void 0)
15108
+ continue;
15083
15109
  releaseLock();
15084
15110
  throw new ActivationError(
15085
15111
  "TARGET_PARTIALLY_ACTIVATED",
@@ -15123,7 +15149,13 @@ async function activateOfflineZone(options) {
15123
15149
  for (const file of files) {
15124
15150
  const content = fileContent(file, material, deviceKeyPair, params.domain);
15125
15151
  try {
15126
- commitFile(file.absolutePath, content, file.mode, file.dirMode);
15152
+ commitFile(
15153
+ file.absolutePath,
15154
+ content,
15155
+ file.mode,
15156
+ file.dirMode,
15157
+ file.role === "gateway_params" ? gatewayPlaceholder : void 0
15158
+ );
15127
15159
  } catch (error) {
15128
15160
  failCommit(error, file.path);
15129
15161
  }