@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/cloud/cloud-client.d.ts +26 -3
- package/dist/cloud/cloud-client.js +51 -4
- package/dist/cloud/index.d.ts +1 -1
- package/dist/cloud/index.js +1 -1
- package/dist/index.browser.mjs +2 -2
- package/dist/index.browser.mjs.map +3 -3
- package/dist/index.cjs +32 -4
- package/dist/index.cjs.map +2 -2
- package/dist/index.mjs +32 -4
- package/dist/index.mjs.map +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -41,6 +41,7 @@ __export(index_exports, {
|
|
|
41
41
|
accountForRoot: () => accountForRoot,
|
|
42
42
|
accountRootFromPhrase: () => accountRootFromPhrase,
|
|
43
43
|
accountRootFromSecret: () => accountRootFromSecret,
|
|
44
|
+
admitterAddrsFromNetworkStatus: () => admitterAddrsFromNetworkStatus,
|
|
44
45
|
buildAuthLoginUrl: () => buildAuthLoginUrl,
|
|
45
46
|
callerProof: () => callerProof,
|
|
46
47
|
combineSignals: () => combineSignals,
|
|
@@ -5501,17 +5502,27 @@ var CloudClient = class {
|
|
|
5501
5502
|
* Ask the fleet to host a claimed namespace — the step that gets a relay
|
|
5502
5503
|
* assigned.
|
|
5503
5504
|
*
|
|
5504
|
-
*
|
|
5505
|
-
* this is the separate "now host it" half. Idempotent.
|
|
5505
|
+
* Carries no proof: {@link claimNamespace} already established ownership,
|
|
5506
|
+
* and this is the separate "now host it" half. Idempotent.
|
|
5507
|
+
*
|
|
5508
|
+
* `admitterAddrs` is where the owner's own node can be dialed — take it from
|
|
5509
|
+
* that node's network status with {@link admitterAddrsFromNetworkStatus}.
|
|
5510
|
+
* The first fleet node placed on a namespace has nobody but the owner to ask
|
|
5511
|
+
* for admission, and without these it can only broadcast and hope the
|
|
5512
|
+
* owner's node — often a laptop behind a relay — hears it. They are a dial
|
|
5513
|
+
* hint, not a grant: the owner's node admits by its own policy. Omit them to
|
|
5514
|
+
* leave whatever the cloud already holds; pass them again when the node's
|
|
5515
|
+
* relay address changes, and they replace the stored ones.
|
|
5506
5516
|
*
|
|
5507
5517
|
* Not to be confused with {@link enableHA}, which opens the cloud's web flow
|
|
5508
5518
|
* in a browser tab for a user to complete by hand. This is the API call.
|
|
5509
5519
|
*/
|
|
5510
|
-
async enableNamespaceHa(namespaceId) {
|
|
5520
|
+
async enableNamespaceHa(namespaceId, options = {}) {
|
|
5521
|
+
const body = options.admitterAddrs === void 0 ? {} : { admitter_addrs: [...options.admitterAddrs] };
|
|
5511
5522
|
return this.request(
|
|
5512
5523
|
"POST",
|
|
5513
5524
|
`/api/cloud/namespaces/${encodeURIComponent(namespaceId)}/enable-ha`,
|
|
5514
|
-
{ body
|
|
5525
|
+
{ body }
|
|
5515
5526
|
);
|
|
5516
5527
|
}
|
|
5517
5528
|
/**
|
|
@@ -5835,6 +5846,23 @@ var CloudClient = class {
|
|
|
5835
5846
|
void this.notifySession(this.session);
|
|
5836
5847
|
}
|
|
5837
5848
|
};
|
|
5849
|
+
function admitterAddrsFromNetworkStatus(status) {
|
|
5850
|
+
const record = status && typeof status === "object" ? status.data ?? status : void 0;
|
|
5851
|
+
if (!record || typeof record !== "object") return [];
|
|
5852
|
+
const peerId = record.localPeerId;
|
|
5853
|
+
const external = record.externalAddrs;
|
|
5854
|
+
if (typeof peerId !== "string" || !peerId || !Array.isArray(external)) return [];
|
|
5855
|
+
const suffix = `/p2p/${peerId}`;
|
|
5856
|
+
const out = [];
|
|
5857
|
+
for (const entry of external) {
|
|
5858
|
+
if (typeof entry !== "string") continue;
|
|
5859
|
+
const addr = entry.trim();
|
|
5860
|
+
if (!addr.startsWith("/")) continue;
|
|
5861
|
+
const dialable = addr.endsWith(suffix) ? addr : `${addr}${suffix}`;
|
|
5862
|
+
if (!out.includes(dialable)) out.push(dialable);
|
|
5863
|
+
}
|
|
5864
|
+
return out;
|
|
5865
|
+
}
|
|
5838
5866
|
|
|
5839
5867
|
// src/mero-js.ts
|
|
5840
5868
|
function resolveProofSigner(config) {
|