@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.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
  };
@@ -841,8 +841,20 @@ var AdminApiClient = class {
841
841
  );
842
842
  }
843
843
  // ---- Blob Management ----
844
- async uploadBlob(data) {
845
- 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 };
846
858
  }
847
859
  async deleteBlob(blobId) {
848
860
  const body = await this.httpClient.delete(
@@ -851,17 +863,37 @@ var AdminApiClient = class {
851
863
  return { blobId: body.blob_id, deleted: body.deleted };
852
864
  }
853
865
  async listBlobs() {
854
- 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 })) };
855
872
  }
856
873
  async getBlob(blobId) {
857
- 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 };
858
880
  }
859
881
  // ---- Alias Management ----
860
882
  async createContextAlias(request) {
861
- 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
+ );
862
889
  }
863
890
  async createApplicationAlias(request) {
864
- 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
+ );
865
897
  }
866
898
  async lookupContextAlias(name) {
867
899
  return unwrap(
@@ -913,7 +945,7 @@ var AdminApiClient = class {
913
945
  return unwrap(
914
946
  await this.httpClient.post(
915
947
  `/admin-api/alias/create/identity/${contextId}`,
916
- request
948
+ { alias: request.alias, identity: request.identity }
917
949
  )
918
950
  );
919
951
  }