@calimero-network/mero-js 3.0.0 → 4.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/index.cjs CHANGED
@@ -632,10 +632,10 @@ var AuthApiClient = class {
632
632
  `/admin/keys/${keyId}/permissions`
633
633
  );
634
634
  }
635
- async updateKeyPermissions(keyId, permissions) {
635
+ async updateKeyPermissions(keyId, changes) {
636
636
  return this.httpClient.put(
637
637
  `/admin/keys/${keyId}/permissions`,
638
- { permissions }
638
+ { add: changes.add, remove: changes.remove }
639
639
  );
640
640
  }
641
641
  };
@@ -877,11 +877,9 @@ var AdminApiClient = class {
877
877
  * context as stranded.
878
878
  */
879
879
  async resyncContext(contextId, request = {}) {
880
- return unwrap(
881
- await this.httpClient.post(
882
- `/admin-api/contexts/${contextId}/resync`,
883
- request
884
- )
880
+ return this.httpClient.post(
881
+ `/admin-api/contexts/${contextId}/resync`,
882
+ request
885
883
  );
886
884
  }
887
885
  async inviteSpecializedNode(request) {
@@ -903,24 +901,59 @@ var AdminApiClient = class {
903
901
  );
904
902
  }
905
903
  // ---- Blob Management ----
906
- async uploadBlob(data) {
907
- return unwrap(await this.httpClient.put("/admin-api/blobs", data));
904
+ async uploadBlob(request) {
905
+ const params = new URLSearchParams();
906
+ if (request.hash) params.set("hash", request.hash);
907
+ if (request.contextId) params.set("context_id", request.contextId);
908
+ const query = params.toString();
909
+ const path = query ? `/admin-api/blobs?${query}` : "/admin-api/blobs";
910
+ const res = unwrap(
911
+ await this.httpClient.request(path, {
912
+ method: "PUT",
913
+ body: request.data,
914
+ headers: { "Content-Type": "application/octet-stream" }
915
+ })
916
+ );
917
+ return { blobId: res.blob_id, size: res.size };
908
918
  }
909
919
  async deleteBlob(blobId) {
910
- return unwrap(await this.httpClient.delete(`/admin-api/blobs/${blobId}`));
920
+ const body = await this.httpClient.delete(
921
+ `/admin-api/blobs/${blobId}`
922
+ );
923
+ return { blobId: body.blob_id, deleted: body.deleted };
911
924
  }
912
925
  async listBlobs() {
913
- return unwrap(await this.httpClient.get("/admin-api/blobs"));
926
+ const res = unwrap(
927
+ await this.httpClient.get(
928
+ "/admin-api/blobs"
929
+ )
930
+ );
931
+ return { blobs: res.blobs.map((b) => ({ blobId: b.blob_id, size: b.size })) };
914
932
  }
915
933
  async getBlob(blobId) {
916
- return unwrap(await this.httpClient.get(`/admin-api/blobs/${blobId}`));
934
+ const res = unwrap(
935
+ await this.httpClient.get(
936
+ `/admin-api/blobs/${blobId}`
937
+ )
938
+ );
939
+ return { blobId: res.blob_id, size: res.size };
917
940
  }
918
941
  // ---- Alias Management ----
919
942
  async createContextAlias(request) {
920
- return unwrap(await this.httpClient.post("/admin-api/alias/create/context", request));
943
+ return unwrap(
944
+ await this.httpClient.post(
945
+ "/admin-api/alias/create/context",
946
+ { alias: request.alias, contextId: request.contextId }
947
+ )
948
+ );
921
949
  }
922
950
  async createApplicationAlias(request) {
923
- return unwrap(await this.httpClient.post("/admin-api/alias/create/application", request));
951
+ return unwrap(
952
+ await this.httpClient.post(
953
+ "/admin-api/alias/create/application",
954
+ { alias: request.alias, applicationId: request.applicationId }
955
+ )
956
+ );
924
957
  }
925
958
  async lookupContextAlias(name) {
926
959
  return unwrap(
@@ -972,7 +1005,7 @@ var AdminApiClient = class {
972
1005
  return unwrap(
973
1006
  await this.httpClient.post(
974
1007
  `/admin-api/alias/create/identity/${contextId}`,
975
- request
1008
+ { alias: request.alias, identity: request.identity }
976
1009
  )
977
1010
  );
978
1011
  }
@@ -1426,9 +1459,9 @@ var SseClient = class {
1426
1459
  */
1427
1460
  onAppVersionChanged(handler) {
1428
1461
  const listener = (ev) => {
1462
+ if (ev.type !== "AppVersionChanged") return;
1429
1463
  const d = ev.data;
1430
- if (d?.type !== "AppVersionChanged") return;
1431
- handler({ contextId: ev.contextId, fromVersion: d.data?.fromVersion, toVersion: d.data?.toVersion });
1464
+ handler({ contextId: ev.contextId, fromVersion: d?.fromVersion, toVersion: d?.toVersion });
1432
1465
  };
1433
1466
  this.on("event", listener);
1434
1467
  return () => this.off("event", listener);
@@ -1537,6 +1570,9 @@ var SseClient = class {
1537
1570
  }
1538
1571
  this.emit("event", {
1539
1572
  contextId: msg.result.contextId,
1573
+ // Forward the event tag (sibling of `data` in core's flattened
1574
+ // payload) so typed helpers like `onAppVersionChanged` can discriminate.
1575
+ type: msg.result.type,
1540
1576
  data: eventData
1541
1577
  });
1542
1578
  }