@calimero-network/mero-js 19.18.0 → 19.19.0

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/index.mjs CHANGED
@@ -5404,17 +5404,27 @@ var CloudClient = class {
5404
5404
  * Ask the fleet to host a claimed namespace — the step that gets a relay
5405
5405
  * assigned.
5406
5406
  *
5407
- * Takes no body: {@link claimNamespace} already established ownership, and
5408
- * this is the separate "now host it" half. Idempotent.
5407
+ * Carries no proof: {@link claimNamespace} already established ownership,
5408
+ * and this is the separate "now host it" half. Idempotent.
5409
+ *
5410
+ * `admitterAddrs` is where the owner's own node can be dialed — take it from
5411
+ * that node's network status with {@link admitterAddrsFromNetworkStatus}.
5412
+ * The first fleet node placed on a namespace has nobody but the owner to ask
5413
+ * for admission, and without these it can only broadcast and hope the
5414
+ * owner's node — often a laptop behind a relay — hears it. They are a dial
5415
+ * hint, not a grant: the owner's node admits by its own policy. Omit them to
5416
+ * leave whatever the cloud already holds; pass them again when the node's
5417
+ * relay address changes, and they replace the stored ones.
5409
5418
  *
5410
5419
  * Not to be confused with {@link enableHA}, which opens the cloud's web flow
5411
5420
  * in a browser tab for a user to complete by hand. This is the API call.
5412
5421
  */
5413
- async enableNamespaceHa(namespaceId) {
5422
+ async enableNamespaceHa(namespaceId, options = {}) {
5423
+ const body = options.admitterAddrs === void 0 ? {} : { admitter_addrs: [...options.admitterAddrs] };
5414
5424
  return this.request(
5415
5425
  "POST",
5416
5426
  `/api/cloud/namespaces/${encodeURIComponent(namespaceId)}/enable-ha`,
5417
- { body: {} }
5427
+ { body }
5418
5428
  );
5419
5429
  }
5420
5430
  /**
@@ -5738,6 +5748,23 @@ var CloudClient = class {
5738
5748
  void this.notifySession(this.session);
5739
5749
  }
5740
5750
  };
5751
+ function admitterAddrsFromNetworkStatus(status) {
5752
+ const record = status && typeof status === "object" ? status.data ?? status : void 0;
5753
+ if (!record || typeof record !== "object") return [];
5754
+ const peerId = record.localPeerId;
5755
+ const external = record.externalAddrs;
5756
+ if (typeof peerId !== "string" || !peerId || !Array.isArray(external)) return [];
5757
+ const suffix = `/p2p/${peerId}`;
5758
+ const out = [];
5759
+ for (const entry of external) {
5760
+ if (typeof entry !== "string") continue;
5761
+ const addr = entry.trim();
5762
+ if (!addr.startsWith("/")) continue;
5763
+ const dialable = addr.endsWith(suffix) ? addr : `${addr}${suffix}`;
5764
+ if (!out.includes(dialable)) out.push(dialable);
5765
+ }
5766
+ return out;
5767
+ }
5741
5768
 
5742
5769
  // src/mero-js.ts
5743
5770
  function resolveProofSigner(config) {
@@ -6802,6 +6829,7 @@ export {
6802
6829
  accountForRoot,
6803
6830
  accountRootFromPhrase,
6804
6831
  accountRootFromSecret,
6832
+ admitterAddrsFromNetworkStatus,
6805
6833
  buildAuthLoginUrl,
6806
6834
  callerProof,
6807
6835
  combineSignals,