@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.mjs CHANGED
@@ -572,10 +572,10 @@ var AuthApiClient = class {
572
572
  `/admin/keys/${keyId}/permissions`
573
573
  );
574
574
  }
575
- async updateKeyPermissions(keyId, permissions) {
575
+ async updateKeyPermissions(keyId, changes) {
576
576
  return this.httpClient.put(
577
577
  `/admin/keys/${keyId}/permissions`,
578
- { permissions }
578
+ { add: changes.add, remove: changes.remove }
579
579
  );
580
580
  }
581
581
  };
@@ -817,11 +817,9 @@ var AdminApiClient = class {
817
817
  * context as stranded.
818
818
  */
819
819
  async resyncContext(contextId, request = {}) {
820
- return unwrap(
821
- await this.httpClient.post(
822
- `/admin-api/contexts/${contextId}/resync`,
823
- request
824
- )
820
+ return this.httpClient.post(
821
+ `/admin-api/contexts/${contextId}/resync`,
822
+ request
825
823
  );
826
824
  }
827
825
  async inviteSpecializedNode(request) {
@@ -843,24 +841,59 @@ var AdminApiClient = class {
843
841
  );
844
842
  }
845
843
  // ---- Blob Management ----
846
- async uploadBlob(data) {
847
- return unwrap(await this.httpClient.put("/admin-api/blobs", data));
844
+ async uploadBlob(request) {
845
+ const params = new URLSearchParams();
846
+ if (request.hash) params.set("hash", request.hash);
847
+ if (request.contextId) params.set("context_id", request.contextId);
848
+ const query = params.toString();
849
+ const path = query ? `/admin-api/blobs?${query}` : "/admin-api/blobs";
850
+ const res = unwrap(
851
+ await this.httpClient.request(path, {
852
+ method: "PUT",
853
+ body: request.data,
854
+ headers: { "Content-Type": "application/octet-stream" }
855
+ })
856
+ );
857
+ return { blobId: res.blob_id, size: res.size };
848
858
  }
849
859
  async deleteBlob(blobId) {
850
- return unwrap(await this.httpClient.delete(`/admin-api/blobs/${blobId}`));
860
+ const body = await this.httpClient.delete(
861
+ `/admin-api/blobs/${blobId}`
862
+ );
863
+ return { blobId: body.blob_id, deleted: body.deleted };
851
864
  }
852
865
  async listBlobs() {
853
- return unwrap(await this.httpClient.get("/admin-api/blobs"));
866
+ const res = unwrap(
867
+ await this.httpClient.get(
868
+ "/admin-api/blobs"
869
+ )
870
+ );
871
+ return { blobs: res.blobs.map((b) => ({ blobId: b.blob_id, size: b.size })) };
854
872
  }
855
873
  async getBlob(blobId) {
856
- return unwrap(await this.httpClient.get(`/admin-api/blobs/${blobId}`));
874
+ const res = unwrap(
875
+ await this.httpClient.get(
876
+ `/admin-api/blobs/${blobId}`
877
+ )
878
+ );
879
+ return { blobId: res.blob_id, size: res.size };
857
880
  }
858
881
  // ---- Alias Management ----
859
882
  async createContextAlias(request) {
860
- return unwrap(await this.httpClient.post("/admin-api/alias/create/context", request));
883
+ return unwrap(
884
+ await this.httpClient.post(
885
+ "/admin-api/alias/create/context",
886
+ { alias: request.alias, contextId: request.contextId }
887
+ )
888
+ );
861
889
  }
862
890
  async createApplicationAlias(request) {
863
- return unwrap(await this.httpClient.post("/admin-api/alias/create/application", request));
891
+ return unwrap(
892
+ await this.httpClient.post(
893
+ "/admin-api/alias/create/application",
894
+ { alias: request.alias, applicationId: request.applicationId }
895
+ )
896
+ );
864
897
  }
865
898
  async lookupContextAlias(name) {
866
899
  return unwrap(
@@ -912,7 +945,7 @@ var AdminApiClient = class {
912
945
  return unwrap(
913
946
  await this.httpClient.post(
914
947
  `/admin-api/alias/create/identity/${contextId}`,
915
- request
948
+ { alias: request.alias, identity: request.identity }
916
949
  )
917
950
  );
918
951
  }
@@ -1366,9 +1399,9 @@ var SseClient = class {
1366
1399
  */
1367
1400
  onAppVersionChanged(handler) {
1368
1401
  const listener = (ev) => {
1402
+ if (ev.type !== "AppVersionChanged") return;
1369
1403
  const d = ev.data;
1370
- if (d?.type !== "AppVersionChanged") return;
1371
- handler({ contextId: ev.contextId, fromVersion: d.data?.fromVersion, toVersion: d.data?.toVersion });
1404
+ handler({ contextId: ev.contextId, fromVersion: d?.fromVersion, toVersion: d?.toVersion });
1372
1405
  };
1373
1406
  this.on("event", listener);
1374
1407
  return () => this.off("event", listener);
@@ -1477,6 +1510,9 @@ var SseClient = class {
1477
1510
  }
1478
1511
  this.emit("event", {
1479
1512
  contextId: msg.result.contextId,
1513
+ // Forward the event tag (sibling of `data` in core's flattened
1514
+ // payload) so typed helpers like `onAppVersionChanged` can discriminate.
1515
+ type: msg.result.type,
1480
1516
  data: eventData
1481
1517
  });
1482
1518
  }