@calimero-network/mero-js 3.0.1 → 5.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
@@ -559,9 +559,6 @@ var AuthApiClient = class {
559
559
  async generateMockTokens(request) {
560
560
  return this.httpClient.post("/auth/mock-token", request);
561
561
  }
562
- async getChallenge() {
563
- return this.httpClient.get("/auth/challenge");
564
- }
565
562
  async validateToken(token) {
566
563
  try {
567
564
  const response = await this.validateTokenGet(token);
@@ -587,12 +584,18 @@ var AuthApiClient = class {
587
584
  headers: response.headers
588
585
  };
589
586
  }
590
- async isAuthed() {
591
- return this.httpClient.get("/auth/is-authed");
592
- }
593
587
  // Token Management Endpoints
588
+ // NOTE: node auth status lives on AdminApiClient.isAuthed() (/admin-api/is-authed);
589
+ // there is no /auth/is-authed on the auth service.
594
590
  async revokeTokens(request) {
595
- return this.httpClient.post("/admin/revoke", request);
591
+ const response = await this.httpClient.post(
592
+ "/admin/revoke",
593
+ request
594
+ );
595
+ if (!response.data) {
596
+ throw new Error("Revoke tokens response data is null");
597
+ }
598
+ return response.data;
596
599
  }
597
600
  // Key Management Endpoints
598
601
  async listRootKeys() {
@@ -603,7 +606,14 @@ var AuthApiClient = class {
603
606
  return response.data;
604
607
  }
605
608
  async createRootKey(request) {
606
- return this.httpClient.post("/admin/keys", request);
609
+ const response = await this.httpClient.post(
610
+ "/admin/keys",
611
+ request
612
+ );
613
+ if (!response.data) {
614
+ throw new Error("Create root key response data is null");
615
+ }
616
+ return response.data;
607
617
  }
608
618
  async deleteRootKey(keyId) {
609
619
  return this.httpClient.delete(`/admin/keys/${keyId}`);
@@ -632,10 +642,10 @@ var AuthApiClient = class {
632
642
  `/admin/keys/${keyId}/permissions`
633
643
  );
634
644
  }
635
- async updateKeyPermissions(keyId, permissions) {
645
+ async updateKeyPermissions(keyId, changes) {
636
646
  return this.httpClient.put(
637
647
  `/admin/keys/${keyId}/permissions`,
638
- { permissions }
648
+ { add: changes.add, remove: changes.remove }
639
649
  );
640
650
  }
641
651
  };
@@ -901,8 +911,20 @@ var AdminApiClient = class {
901
911
  );
902
912
  }
903
913
  // ---- Blob Management ----
904
- async uploadBlob(data) {
905
- return unwrap(await this.httpClient.put("/admin-api/blobs", data));
914
+ async uploadBlob(request) {
915
+ const params = new URLSearchParams();
916
+ if (request.hash) params.set("hash", request.hash);
917
+ if (request.contextId) params.set("context_id", request.contextId);
918
+ const query = params.toString();
919
+ const path = query ? `/admin-api/blobs?${query}` : "/admin-api/blobs";
920
+ const res = unwrap(
921
+ await this.httpClient.request(path, {
922
+ method: "PUT",
923
+ body: request.data,
924
+ headers: { "Content-Type": "application/octet-stream" }
925
+ })
926
+ );
927
+ return { blobId: res.blob_id, size: res.size };
906
928
  }
907
929
  async deleteBlob(blobId) {
908
930
  const body = await this.httpClient.delete(
@@ -911,17 +933,37 @@ var AdminApiClient = class {
911
933
  return { blobId: body.blob_id, deleted: body.deleted };
912
934
  }
913
935
  async listBlobs() {
914
- return unwrap(await this.httpClient.get("/admin-api/blobs"));
936
+ const res = unwrap(
937
+ await this.httpClient.get(
938
+ "/admin-api/blobs"
939
+ )
940
+ );
941
+ return { blobs: res.blobs.map((b) => ({ blobId: b.blob_id, size: b.size })) };
915
942
  }
916
943
  async getBlob(blobId) {
917
- return unwrap(await this.httpClient.get(`/admin-api/blobs/${blobId}`));
944
+ const res = unwrap(
945
+ await this.httpClient.get(
946
+ `/admin-api/blobs/${blobId}`
947
+ )
948
+ );
949
+ return { blobId: res.blob_id, size: res.size };
918
950
  }
919
951
  // ---- Alias Management ----
920
952
  async createContextAlias(request) {
921
- return unwrap(await this.httpClient.post("/admin-api/alias/create/context", request));
953
+ return unwrap(
954
+ await this.httpClient.post(
955
+ "/admin-api/alias/create/context",
956
+ { alias: request.alias, contextId: request.contextId }
957
+ )
958
+ );
922
959
  }
923
960
  async createApplicationAlias(request) {
924
- return unwrap(await this.httpClient.post("/admin-api/alias/create/application", request));
961
+ return unwrap(
962
+ await this.httpClient.post(
963
+ "/admin-api/alias/create/application",
964
+ { alias: request.alias, applicationId: request.applicationId }
965
+ )
966
+ );
925
967
  }
926
968
  async lookupContextAlias(name) {
927
969
  return unwrap(
@@ -973,7 +1015,7 @@ var AdminApiClient = class {
973
1015
  return unwrap(
974
1016
  await this.httpClient.post(
975
1017
  `/admin-api/alias/create/identity/${contextId}`,
976
- request
1018
+ { alias: request.alias, identity: request.identity }
977
1019
  )
978
1020
  );
979
1021
  }