@calimero-network/mero-js 13.4.0 → 14.0.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/account/index.d.ts +15 -15
- package/dist/account/index.js +15 -15
- package/dist/admin-api/admin-client.d.ts +10 -5
- package/dist/admin-api/admin-client.js +10 -5
- package/dist/admin-api/admin-types.d.ts +8 -7
- package/dist/events/group.d.ts +1 -1
- package/dist/index.browser.mjs +2 -2
- package/dist/index.browser.mjs.map +3 -3
- package/dist/index.cjs +11 -48
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +1 -1
- package/dist/index.mjs +11 -48
- package/dist/index.mjs.map +2 -2
- package/dist/warrant/warrant.d.ts +5 -6
- package/dist/warrant/warrant.js +1 -54
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ export * from './auth-api/index.js';
|
|
|
10
10
|
export * from './admin-api/index.js';
|
|
11
11
|
// Auth utilities
|
|
12
12
|
export { parseAuthCallback, buildAuthLoginUrl } from './auth/index.js';
|
|
13
|
-
// Account id encoding (hex
|
|
13
|
+
// Account id encoding (hex everywhere core spells one; an app may re-encode)
|
|
14
14
|
export { toAccountHex, toAccountBase58, sameAccount, } from './account/index.js';
|
|
15
15
|
// Token store
|
|
16
16
|
export { MemoryTokenStore, LocalStorageTokenStore } from './token-store/index.js';
|
package/dist/index.mjs
CHANGED
|
@@ -1226,14 +1226,16 @@ var AdminApiClient = class {
|
|
|
1226
1226
|
}
|
|
1227
1227
|
/**
|
|
1228
1228
|
* `identity` is the member's ACCOUNT (64 hex), as returned by
|
|
1229
|
-
* {@link listGroupMembers} — not the
|
|
1229
|
+
* {@link listGroupMembers} — not the signing key that added them. Both are
|
|
1230
|
+
* 64 hex, so nothing but the source tells them apart.
|
|
1230
1231
|
*/
|
|
1231
1232
|
async updateMemberRole(groupId, identity, request) {
|
|
1232
1233
|
await this.httpClient.put(`/admin-api/groups/${groupId}/members/${identity}/role`, request);
|
|
1233
1234
|
}
|
|
1234
1235
|
/**
|
|
1235
1236
|
* `identity` is the member's ACCOUNT (64 hex), as returned by
|
|
1236
|
-
* {@link listGroupMembers} — not the
|
|
1237
|
+
* {@link listGroupMembers} — not the signing key that added them. Both are
|
|
1238
|
+
* 64 hex, so nothing but the source tells them apart.
|
|
1237
1239
|
*/
|
|
1238
1240
|
async getMemberCapabilities(groupId, identity) {
|
|
1239
1241
|
return unwrap(
|
|
@@ -1244,7 +1246,8 @@ var AdminApiClient = class {
|
|
|
1244
1246
|
}
|
|
1245
1247
|
/**
|
|
1246
1248
|
* `identity` is the member's ACCOUNT (64 hex), as returned by
|
|
1247
|
-
* {@link listGroupMembers} — not the
|
|
1249
|
+
* {@link listGroupMembers} — not the signing key that added them. Both are
|
|
1250
|
+
* 64 hex, so nothing but the source tells them apart.
|
|
1248
1251
|
*/
|
|
1249
1252
|
async setMemberCapabilities(groupId, identity, request) {
|
|
1250
1253
|
await this.httpClient.put(`/admin-api/groups/${groupId}/members/${identity}/capabilities`, request);
|
|
@@ -1277,7 +1280,8 @@ var AdminApiClient = class {
|
|
|
1277
1280
|
}
|
|
1278
1281
|
/**
|
|
1279
1282
|
* `identity` is the member's ACCOUNT (64 hex), as returned by
|
|
1280
|
-
* {@link listGroupMembers} — not the
|
|
1283
|
+
* {@link listGroupMembers} — not the signing key that added them. Both are
|
|
1284
|
+
* 64 hex, so nothing but the source tells them apart.
|
|
1281
1285
|
*/
|
|
1282
1286
|
async getMemberMetadata(groupId, identity) {
|
|
1283
1287
|
const response = await this.httpClient.get(
|
|
@@ -1431,7 +1435,8 @@ var AdminApiClient = class {
|
|
|
1431
1435
|
* /admin-api/groups/:group_id/members/:identity/auto-follow).
|
|
1432
1436
|
*
|
|
1433
1437
|
* `identity` is the member's ACCOUNT (64 hex), as returned by
|
|
1434
|
-
* {@link listGroupMembers} — not the
|
|
1438
|
+
* {@link listGroupMembers} — not the signing key that added them. Both are
|
|
1439
|
+
* 64 hex, so nothing but the source tells them apart.
|
|
1435
1440
|
*/
|
|
1436
1441
|
async setMemberAutoFollow(groupId, identity, request) {
|
|
1437
1442
|
await this.httpClient.put(`/admin-api/groups/${groupId}/members/${identity}/auto-follow`, request);
|
|
@@ -2625,7 +2630,6 @@ var PKCS8_ED25519_PREFIX = new Uint8Array([
|
|
|
2625
2630
|
4,
|
|
2626
2631
|
32
|
|
2627
2632
|
]);
|
|
2628
|
-
var B58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
2629
2633
|
function hex(bytes) {
|
|
2630
2634
|
return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
2631
2635
|
}
|
|
@@ -2642,47 +2646,6 @@ function fromHex2(value, label, expectedBytes) {
|
|
|
2642
2646
|
}
|
|
2643
2647
|
return bytes;
|
|
2644
2648
|
}
|
|
2645
|
-
function fromBase58(value, label) {
|
|
2646
|
-
const clean = value.trim();
|
|
2647
|
-
let n = 0n;
|
|
2648
|
-
for (const char of clean) {
|
|
2649
|
-
const digit = B58.indexOf(char);
|
|
2650
|
-
if (digit < 0) {
|
|
2651
|
-
throw new Error(`${label} is not base58: unexpected character '${char}'`);
|
|
2652
|
-
}
|
|
2653
|
-
n = n * 58n + BigInt(digit);
|
|
2654
|
-
}
|
|
2655
|
-
const out = new Uint8Array(32);
|
|
2656
|
-
for (let i = 31; i >= 0; i -= 1) {
|
|
2657
|
-
out[i] = Number(n & 0xffn);
|
|
2658
|
-
n >>= 8n;
|
|
2659
|
-
}
|
|
2660
|
-
if (n !== 0n) {
|
|
2661
|
-
throw new Error(`${label} decodes to more than 32 bytes`);
|
|
2662
|
-
}
|
|
2663
|
-
if (toBase58(out) !== clean) {
|
|
2664
|
-
throw new Error(
|
|
2665
|
-
`${label} is not a canonical base58 32-byte id. If you have it in hex, note that ${label} is base58 here while accounts are hex`
|
|
2666
|
-
);
|
|
2667
|
-
}
|
|
2668
|
-
return out;
|
|
2669
|
-
}
|
|
2670
|
-
function toBase58(bytes) {
|
|
2671
|
-
let n = 0n;
|
|
2672
|
-
for (const byte of bytes) {
|
|
2673
|
-
n = n << 8n | BigInt(byte);
|
|
2674
|
-
}
|
|
2675
|
-
let out = "";
|
|
2676
|
-
while (n > 0n) {
|
|
2677
|
-
out = B58[Number(n % 58n)] + out;
|
|
2678
|
-
n /= 58n;
|
|
2679
|
-
}
|
|
2680
|
-
let leadingZeros = 0;
|
|
2681
|
-
while (leadingZeros < bytes.length && bytes[leadingZeros] === 0) {
|
|
2682
|
-
leadingZeros += 1;
|
|
2683
|
-
}
|
|
2684
|
-
return "1".repeat(leadingZeros) + out;
|
|
2685
|
-
}
|
|
2686
2649
|
function u64le(value) {
|
|
2687
2650
|
const out = new Uint8Array(8);
|
|
2688
2651
|
new DataView(out.buffer).setBigUint64(0, BigInt(value), true);
|
|
@@ -2729,7 +2692,7 @@ async function importSigningKey(secretHex) {
|
|
|
2729
2692
|
}
|
|
2730
2693
|
}
|
|
2731
2694
|
async function signWarrant(input) {
|
|
2732
|
-
const context =
|
|
2695
|
+
const context = fromHex2(input.context, "context", 32);
|
|
2733
2696
|
const authorAccount = fromHex2(input.authorAccount, "authorAccount", 32);
|
|
2734
2697
|
const executor = fromHex2(input.executor, "executor", 32);
|
|
2735
2698
|
const key = await importSigningKey(input.deviceSecret);
|