@calimero-network/mero-js 19.13.1 → 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/admin-api/admin-client.d.ts +31 -1
- package/dist/admin-api/admin-client.js +32 -0
- package/dist/admin-api/admin-types.d.ts +55 -0
- package/dist/admin-api/admin-types.js +12 -1
- package/dist/index.browser.mjs +2 -2
- package/dist/index.browser.mjs.map +4 -4
- package/dist/index.cjs +46 -0
- package/dist/index.cjs.map +3 -3
- package/dist/index.mjs +46 -0
- package/dist/index.mjs.map +3 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -68,6 +68,7 @@ __export(index_exports, {
|
|
|
68
68
|
generateAccountRoot: () => generateAccountRoot,
|
|
69
69
|
generateSessionKey: () => generateSessionKey,
|
|
70
70
|
hasCap: () => hasCap,
|
|
71
|
+
hexEncodeUtf8: () => hexEncodeUtf8,
|
|
71
72
|
intentHash: () => intentHash,
|
|
72
73
|
jsonCodec: () => jsonCodec,
|
|
73
74
|
localNodeUrl: () => localNodeUrl,
|
|
@@ -1470,6 +1471,43 @@ var AdminApiClient = class {
|
|
|
1470
1471
|
)
|
|
1471
1472
|
);
|
|
1472
1473
|
}
|
|
1474
|
+
/**
|
|
1475
|
+
* Sign a payload an outside verifier specified, with this account's root.
|
|
1476
|
+
*
|
|
1477
|
+
* The counterpart to a verifier that issued a challenge and will check the
|
|
1478
|
+
* signature against the account id it derives — the cloud's account link and
|
|
1479
|
+
* login exchanges being the ones this exists for. The root never leaves the
|
|
1480
|
+
* node, so this is the only way a client can produce that signature.
|
|
1481
|
+
*
|
|
1482
|
+
* `domain` is a NAME from a closed set the node knows, never the domain bytes.
|
|
1483
|
+
* That is the security property rather than an encoding preference: signing
|
|
1484
|
+
* caller-supplied bytes under a caller-supplied prefix would be an oracle over
|
|
1485
|
+
* the one key that can certify a device. A node refuses a name it does not
|
|
1486
|
+
* know, and refuses one whose bytes could be extended into a credential of its
|
|
1487
|
+
* own.
|
|
1488
|
+
*
|
|
1489
|
+
* What comes back proves possession of the root and nothing else. Whether the
|
|
1490
|
+
* payload is a challenge anyone issued, whether it is fresh, and whether the
|
|
1491
|
+
* holder may link this account are the verifier's to decide — it issued the
|
|
1492
|
+
* challenge and knows who to.
|
|
1493
|
+
*
|
|
1494
|
+
* ```ts
|
|
1495
|
+
* const { nonce } = await cloud.getAccountLoginChallenge();
|
|
1496
|
+
* const { rootPublicKey, signature } = await admin.signWithAccountRoot({
|
|
1497
|
+
* domain: 'mdma.account-login',
|
|
1498
|
+
* payload: hexEncodeUtf8(nonce),
|
|
1499
|
+
* });
|
|
1500
|
+
* await cloud.submitAccountLogin({ rootPublicKey, nonce, signature });
|
|
1501
|
+
* ```
|
|
1502
|
+
*/
|
|
1503
|
+
async signWithAccountRoot(request) {
|
|
1504
|
+
return unwrap(
|
|
1505
|
+
await this.httpClient.post(
|
|
1506
|
+
"/admin-api/account/sign-with-root",
|
|
1507
|
+
request
|
|
1508
|
+
)
|
|
1509
|
+
);
|
|
1510
|
+
}
|
|
1473
1511
|
/**
|
|
1474
1512
|
* Name a device of this account, for a listing to render.
|
|
1475
1513
|
*
|
|
@@ -1885,6 +1923,14 @@ var AdminApiClient = class {
|
|
|
1885
1923
|
}
|
|
1886
1924
|
};
|
|
1887
1925
|
|
|
1926
|
+
// src/admin-api/admin-types.ts
|
|
1927
|
+
function hexEncodeUtf8(text) {
|
|
1928
|
+
return Array.from(
|
|
1929
|
+
new TextEncoder().encode(text),
|
|
1930
|
+
(b) => b.toString(16).padStart(2, "0")
|
|
1931
|
+
).join("");
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1888
1934
|
// src/admin-api/admin-factory.ts
|
|
1889
1935
|
function createBrowserAdminApiClient(config) {
|
|
1890
1936
|
return new AdminApiClient(createBrowserHttpClient(config));
|