@calimero-network/mero-js 19.13.0 → 19.14.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
@@ -1378,6 +1378,43 @@ var AdminApiClient = class {
1378
1378
  )
1379
1379
  );
1380
1380
  }
1381
+ /**
1382
+ * Sign a payload an outside verifier specified, with this account's root.
1383
+ *
1384
+ * The counterpart to a verifier that issued a challenge and will check the
1385
+ * signature against the account id it derives — the cloud's account link and
1386
+ * login exchanges being the ones this exists for. The root never leaves the
1387
+ * node, so this is the only way a client can produce that signature.
1388
+ *
1389
+ * `domain` is a NAME from a closed set the node knows, never the domain bytes.
1390
+ * That is the security property rather than an encoding preference: signing
1391
+ * caller-supplied bytes under a caller-supplied prefix would be an oracle over
1392
+ * the one key that can certify a device. A node refuses a name it does not
1393
+ * know, and refuses one whose bytes could be extended into a credential of its
1394
+ * own.
1395
+ *
1396
+ * What comes back proves possession of the root and nothing else. Whether the
1397
+ * payload is a challenge anyone issued, whether it is fresh, and whether the
1398
+ * holder may link this account are the verifier's to decide — it issued the
1399
+ * challenge and knows who to.
1400
+ *
1401
+ * ```ts
1402
+ * const { nonce } = await cloud.getAccountLoginChallenge();
1403
+ * const { rootPublicKey, signature } = await admin.signWithAccountRoot({
1404
+ * domain: 'mdma.account-login',
1405
+ * payload: hexEncodeUtf8(nonce),
1406
+ * });
1407
+ * await cloud.submitAccountLogin({ rootPublicKey, nonce, signature });
1408
+ * ```
1409
+ */
1410
+ async signWithAccountRoot(request) {
1411
+ return unwrap(
1412
+ await this.httpClient.post(
1413
+ "/admin-api/account/sign-with-root",
1414
+ request
1415
+ )
1416
+ );
1417
+ }
1381
1418
  /**
1382
1419
  * Name a device of this account, for a listing to render.
1383
1420
  *
@@ -1793,6 +1830,14 @@ var AdminApiClient = class {
1793
1830
  }
1794
1831
  };
1795
1832
 
1833
+ // src/admin-api/admin-types.ts
1834
+ function hexEncodeUtf8(text) {
1835
+ return Array.from(
1836
+ new TextEncoder().encode(text),
1837
+ (b) => b.toString(16).padStart(2, "0")
1838
+ ).join("");
1839
+ }
1840
+
1796
1841
  // src/admin-api/admin-factory.ts
1797
1842
  function createBrowserAdminApiClient(config) {
1798
1843
  return new AdminApiClient(createBrowserHttpClient(config));
@@ -6638,6 +6683,7 @@ export {
6638
6683
  generateAccountRoot,
6639
6684
  generateSessionKey,
6640
6685
  hasCap,
6686
+ hexEncodeUtf8,
6641
6687
  intentHash,
6642
6688
  jsonCodec,
6643
6689
  localNodeUrl,