@calimero-network/mero-js 3.0.1 → 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
  };
@@ -901,8 +901,20 @@ var AdminApiClient = class {
901
901
  );
902
902
  }
903
903
  // ---- Blob Management ----
904
- async uploadBlob(data) {
905
- 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 };
906
918
  }
907
919
  async deleteBlob(blobId) {
908
920
  const body = await this.httpClient.delete(
@@ -911,17 +923,37 @@ var AdminApiClient = class {
911
923
  return { blobId: body.blob_id, deleted: body.deleted };
912
924
  }
913
925
  async listBlobs() {
914
- 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 })) };
915
932
  }
916
933
  async getBlob(blobId) {
917
- 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 };
918
940
  }
919
941
  // ---- Alias Management ----
920
942
  async createContextAlias(request) {
921
- 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
+ );
922
949
  }
923
950
  async createApplicationAlias(request) {
924
- 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
+ );
925
957
  }
926
958
  async lookupContextAlias(name) {
927
959
  return unwrap(
@@ -973,7 +1005,7 @@ var AdminApiClient = class {
973
1005
  return unwrap(
974
1006
  await this.httpClient.post(
975
1007
  `/admin-api/alias/create/identity/${contextId}`,
976
- request
1008
+ { alias: request.alias, identity: request.identity }
977
1009
  )
978
1010
  );
979
1011
  }