@calimero-network/mero-js 19.11.0 → 19.13.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/admin-api/admin-client.d.ts +8 -1
- package/dist/admin-api/admin-client.js +9 -0
- package/dist/admin-api/admin-types.d.ts +39 -0
- package/dist/cloud/cloud-client.d.ts +45 -1
- package/dist/cloud/cloud-client.js +54 -0
- package/dist/cloud/index.d.ts +2 -2
- package/dist/cloud/routing-proof.d.ts +22 -1
- package/dist/cloud/routing-proof.js +4 -0
- package/dist/index.browser.mjs +2 -2
- package/dist/index.browser.mjs.map +3 -3
- package/dist/index.cjs +69 -0
- package/dist/index.cjs.map +2 -2
- package/dist/index.mjs +69 -0
- package/dist/index.mjs.map +2 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1378,6 +1378,20 @@ var AdminApiClient = class {
|
|
|
1378
1378
|
)
|
|
1379
1379
|
);
|
|
1380
1380
|
}
|
|
1381
|
+
/**
|
|
1382
|
+
* Name a device of this account, for a listing to render.
|
|
1383
|
+
*
|
|
1384
|
+
* Run on the node holding the account root to name any device; a paired
|
|
1385
|
+
* node is accepted only for that device's own id.
|
|
1386
|
+
*/
|
|
1387
|
+
async labelAccountDevice(deviceId, request) {
|
|
1388
|
+
return unwrap(
|
|
1389
|
+
await this.httpClient.put(
|
|
1390
|
+
`/admin-api/account/devices/${encodeURIComponent(deviceId)}/label`,
|
|
1391
|
+
request
|
|
1392
|
+
)
|
|
1393
|
+
);
|
|
1394
|
+
}
|
|
1381
1395
|
/**
|
|
1382
1396
|
* Every device of this account, as this node sees them - its own included.
|
|
1383
1397
|
*
|
|
@@ -5072,6 +5086,61 @@ var CloudClient = class {
|
|
|
5072
5086
|
const challenge = await this.getRoutingChallenge(namespaceId);
|
|
5073
5087
|
return routingProofHeaders(challenge, this.routingCredential);
|
|
5074
5088
|
}
|
|
5089
|
+
/**
|
|
5090
|
+
* Ask the cloud for a challenge bound to one ACCOUNT.
|
|
5091
|
+
*
|
|
5092
|
+
* Public and unauthenticated like {@link getRoutingChallenge}: an account id
|
|
5093
|
+
* is `H(genesis(root_pk))` and travels in the clear in every device-link op,
|
|
5094
|
+
* so naming one here reveals nothing and authorises nothing. MDMA re-derives
|
|
5095
|
+
* the account from the certificate and refuses a mismatch.
|
|
5096
|
+
*/
|
|
5097
|
+
async getAccountRelaysChallenge(accountId) {
|
|
5098
|
+
const body = await this.request("GET", `/api/cloud/accounts/${encodeURIComponent(accountId)}/challenge`, {
|
|
5099
|
+
anonymous: true
|
|
5100
|
+
});
|
|
5101
|
+
return {
|
|
5102
|
+
accountId: String(body.account_id ?? accountId),
|
|
5103
|
+
nonce: String(body.nonce ?? ""),
|
|
5104
|
+
expiresAtMs: Number(body.expires_at_ms ?? 0)
|
|
5105
|
+
};
|
|
5106
|
+
}
|
|
5107
|
+
/**
|
|
5108
|
+
* Which relays serve this account — the bootstrap, and nothing more.
|
|
5109
|
+
*
|
|
5110
|
+
* A device holding a certificate can resolve a namespace it can *name*
|
|
5111
|
+
* ({@link getNamespaceRouting}) and can ask a node it can *reach* what its
|
|
5112
|
+
* account belongs to. It starts with neither. This closes that one gap.
|
|
5113
|
+
*
|
|
5114
|
+
* **It does not return namespaces, deliberately.** The node answers that from
|
|
5115
|
+
* the governance DAG, scoped to the calling account: log in at one of these
|
|
5116
|
+
* relays with an account proof and read its namespace listing. A cloud-side
|
|
5117
|
+
* copy would be a second source of truth built from rows that linger for an
|
|
5118
|
+
* account which left a namespace.
|
|
5119
|
+
*
|
|
5120
|
+
* So the sequence is: this → log in at a relay → ask it what you are in.
|
|
5121
|
+
*
|
|
5122
|
+
* Proven with the **device certificate**, not a cloud session, so it needs a
|
|
5123
|
+
* `routingCredential` and throws without one rather than returning an empty
|
|
5124
|
+
* list — "you configured no credential" and "you have no relays" are
|
|
5125
|
+
* different answers and must not look alike.
|
|
5126
|
+
*/
|
|
5127
|
+
async getAccountRelays(accountId) {
|
|
5128
|
+
if (!this.routingCredential) {
|
|
5129
|
+
throw new Error(
|
|
5130
|
+
"getAccountRelays needs a routingCredential: construct the client with the device certificate and its signing secret, since this read is proven by the device, not by a session."
|
|
5131
|
+
);
|
|
5132
|
+
}
|
|
5133
|
+
const challenge = await this.getAccountRelaysChallenge(accountId);
|
|
5134
|
+
const body = await this.request("GET", `/api/cloud/accounts/${encodeURIComponent(accountId)}/relays`, {
|
|
5135
|
+
anonymous: true,
|
|
5136
|
+
headers: await routingProofHeaders(challenge, this.routingCredential)
|
|
5137
|
+
});
|
|
5138
|
+
return (body.relays ?? []).map((row) => ({
|
|
5139
|
+
peerId: String(row.peer_id ?? ""),
|
|
5140
|
+
relayUrl: row.relay_url ?? null,
|
|
5141
|
+
fresh: row.fresh === true
|
|
5142
|
+
}));
|
|
5143
|
+
}
|
|
5075
5144
|
/**
|
|
5076
5145
|
* The node to send a signed join to, chosen from those an invitation names.
|
|
5077
5146
|
*
|