@calimero-network/mero-js 18.0.0 → 18.1.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
@@ -1189,6 +1189,128 @@ var AdminApiClient = class {
1189
1189
  async listNamespaceGroups(namespaceId) {
1190
1190
  return unwrap(await this.httpClient.get(`/admin-api/namespaces/${namespaceId}/groups`));
1191
1191
  }
1192
+ // ---- Account Devices & Pairing ----
1193
+ /**
1194
+ * Mint this node a device for an account that already lives somewhere else -
1195
+ * the first half of pairing, run on the joining node.
1196
+ *
1197
+ * Publishes nothing and needs no key: it produces the device id, the two
1198
+ * public keys and the signature that the account holder's
1199
+ * {@link completeAccountPairing} certifies, plus a code to read out to them
1200
+ * over a channel the payload does not travel on. Until that second half runs,
1201
+ * the device this mints is inert.
1202
+ *
1203
+ * Takes a set of namespaces rather than one, and takes it from the caller
1204
+ * because this node cannot discover it: a node that is a member of nothing can
1205
+ * neither read the account's namespace set off a DAG nor derive it. One device
1206
+ * covers however many are named - the certificate is over the account, not a
1207
+ * scope - so there is one id and one code to hand over regardless.
1208
+ */
1209
+ async initAccountPairing(request) {
1210
+ return unwrap(
1211
+ await this.httpClient.post("/admin-api/account/pair-init", request)
1212
+ );
1213
+ }
1214
+ /**
1215
+ * Certify a device another node minted, link it, and deliver its scope keys -
1216
+ * the second half of pairing, run on the node that holds the account root.
1217
+ *
1218
+ * Every field but `applications` is copied verbatim out of that node's
1219
+ * {@link initAccountPairing} answer. Only this side can complete it: the
1220
+ * certificate is signed by the account root, which never leaves the node that
1221
+ * holds it.
1222
+ *
1223
+ * The scope is named in applications, not namespaces, because that is the
1224
+ * question a person can answer - a namespace is an implementation unit they
1225
+ * never chose. Leave it out to grant every application.
1226
+ */
1227
+ async completeAccountPairing(request) {
1228
+ return unwrap(
1229
+ await this.httpClient.post("/admin-api/account/pair-complete", request)
1230
+ );
1231
+ }
1232
+ /**
1233
+ * Re-run the pairing fan-out for a device this account already certified,
1234
+ * against the namespaces this node takes part in now.
1235
+ *
1236
+ * Pairing is a snapshot, and this is how it is repeated. A namespace created
1237
+ * or joined afterwards holds no binding for a device paired before it, and the
1238
+ * symptom is silence - the device simply never sees that namespace. Nothing
1239
+ * but the id is needed to repair it: the certificate is already held here,
1240
+ * root-signed and naming no namespace, so a fresh endorsement and a key wrap
1241
+ * are all a later namespace is missing. The device does not have to be online.
1242
+ *
1243
+ * Passing `applications` widens the device's stored scope as well as
1244
+ * repairing. Passing none - or an empty list - repairs against the scope
1245
+ * already stored, which is deliberately NOT the "every application" that an
1246
+ * empty list means on {@link completeAccountPairing}: overloading it here
1247
+ * would make the accidental request the widest one.
1248
+ */
1249
+ async relinkAccountDevice(deviceId, request) {
1250
+ return unwrap(
1251
+ await this.httpClient.post(
1252
+ `/admin-api/account/devices/${deviceId}/relink`,
1253
+ request ?? {}
1254
+ )
1255
+ );
1256
+ }
1257
+ /**
1258
+ * Every device of this account, as this node sees them - its own included.
1259
+ *
1260
+ * Joined from the node-local certificate cache and the live bindings of every
1261
+ * namespace this node takes part in, so it is this node's view rather than a
1262
+ * global one: a device certified by another holder appears with an empty
1263
+ * `applications`, because the certificate that would name its scope is not
1264
+ * cached here.
1265
+ *
1266
+ * The wire wraps this in `devices` rather than the usual `data`; the array is
1267
+ * what a caller wants, so that wrapper is not passed on.
1268
+ */
1269
+ async listAccountDevices() {
1270
+ const response = await this.httpClient.get("/admin-api/account/devices");
1271
+ return response.devices;
1272
+ }
1273
+ /**
1274
+ * Every application this account speaks in, with the namespaces targeting each.
1275
+ *
1276
+ * What a device-scoping UI lists: {@link completeAccountPairing} and
1277
+ * {@link relinkAccountDevice} both take applications, and this is where the
1278
+ * ids they take come from. Derived from the namespaces this node takes part
1279
+ * in, so an application installed with no namespace yet is absent - it has
1280
+ * nothing to scope a device to until one exists.
1281
+ *
1282
+ * Wrapped in `applications` on the wire rather than `data`, unwrapped here for
1283
+ * the same reason {@link listAccountDevices} unwraps `devices`.
1284
+ */
1285
+ async listAccountApplications() {
1286
+ const response = await this.httpClient.get(
1287
+ "/admin-api/account/applications"
1288
+ );
1289
+ return response.applications;
1290
+ }
1291
+ /**
1292
+ * Withdraw a device from this account, terminally.
1293
+ *
1294
+ * Two authorities reach the same endpoint. An admin may revoke any device and
1295
+ * rotates the scope key as it goes. The account holder may revoke its own with
1296
+ * a root-signed `proof`, which does not rotate - so read
1297
+ * {@link RevokeAccountDeviceResponseData.revokedIn} rather than assuming the
1298
+ * device lost its access: a namespace reporting `keyRotated: false` has
1299
+ * stopped the device writing but leaves it able to read until an admin
1300
+ * rotates.
1301
+ *
1302
+ * `namespaceId` names where to publish from, not the extent of the revocation:
1303
+ * a device belongs to the account, so every namespace holding a binding for it
1304
+ * is withdrawn from and reported back.
1305
+ */
1306
+ async revokeAccountDevice(namespaceId, request) {
1307
+ return unwrap(
1308
+ await this.httpClient.post(
1309
+ `/admin-api/namespaces/${namespaceId}/account/revoke`,
1310
+ request
1311
+ )
1312
+ );
1313
+ }
1192
1314
  // ---- Group Management ----
1193
1315
  async getGroupInfo(groupId) {
1194
1316
  return unwrap(await this.httpClient.get(`/admin-api/groups/${groupId}`));