@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.mjs CHANGED
@@ -499,9 +499,6 @@ var AuthApiClient = class {
499
499
  async generateMockTokens(request) {
500
500
  return this.httpClient.post("/auth/mock-token", request);
501
501
  }
502
- async getChallenge() {
503
- return this.httpClient.get("/auth/challenge");
504
- }
505
502
  async validateToken(token) {
506
503
  try {
507
504
  const response = await this.validateTokenGet(token);
@@ -527,12 +524,18 @@ var AuthApiClient = class {
527
524
  headers: response.headers
528
525
  };
529
526
  }
530
- async isAuthed() {
531
- return this.httpClient.get("/auth/is-authed");
532
- }
533
527
  // Token Management Endpoints
528
+ // NOTE: node auth status lives on AdminApiClient.isAuthed() (/admin-api/is-authed);
529
+ // there is no /auth/is-authed on the auth service.
534
530
  async revokeTokens(request) {
535
- return this.httpClient.post("/admin/revoke", request);
531
+ const response = await this.httpClient.post(
532
+ "/admin/revoke",
533
+ request
534
+ );
535
+ if (!response.data) {
536
+ throw new Error("Revoke tokens response data is null");
537
+ }
538
+ return response.data;
536
539
  }
537
540
  // Key Management Endpoints
538
541
  async listRootKeys() {
@@ -543,7 +546,14 @@ var AuthApiClient = class {
543
546
  return response.data;
544
547
  }
545
548
  async createRootKey(request) {
546
- return this.httpClient.post("/admin/keys", request);
549
+ const response = await this.httpClient.post(
550
+ "/admin/keys",
551
+ request
552
+ );
553
+ if (!response.data) {
554
+ throw new Error("Create root key response data is null");
555
+ }
556
+ return response.data;
547
557
  }
548
558
  async deleteRootKey(keyId) {
549
559
  return this.httpClient.delete(`/admin/keys/${keyId}`);
@@ -572,10 +582,10 @@ var AuthApiClient = class {
572
582
  `/admin/keys/${keyId}/permissions`
573
583
  );
574
584
  }
575
- async updateKeyPermissions(keyId, permissions) {
585
+ async updateKeyPermissions(keyId, changes) {
576
586
  return this.httpClient.put(
577
587
  `/admin/keys/${keyId}/permissions`,
578
- { permissions }
588
+ { add: changes.add, remove: changes.remove }
579
589
  );
580
590
  }
581
591
  };
@@ -841,8 +851,20 @@ var AdminApiClient = class {
841
851
  );
842
852
  }
843
853
  // ---- Blob Management ----
844
- async uploadBlob(data) {
845
- return unwrap(await this.httpClient.put("/admin-api/blobs", data));
854
+ async uploadBlob(request) {
855
+ const params = new URLSearchParams();
856
+ if (request.hash) params.set("hash", request.hash);
857
+ if (request.contextId) params.set("context_id", request.contextId);
858
+ const query = params.toString();
859
+ const path = query ? `/admin-api/blobs?${query}` : "/admin-api/blobs";
860
+ const res = unwrap(
861
+ await this.httpClient.request(path, {
862
+ method: "PUT",
863
+ body: request.data,
864
+ headers: { "Content-Type": "application/octet-stream" }
865
+ })
866
+ );
867
+ return { blobId: res.blob_id, size: res.size };
846
868
  }
847
869
  async deleteBlob(blobId) {
848
870
  const body = await this.httpClient.delete(
@@ -851,17 +873,37 @@ var AdminApiClient = class {
851
873
  return { blobId: body.blob_id, deleted: body.deleted };
852
874
  }
853
875
  async listBlobs() {
854
- return unwrap(await this.httpClient.get("/admin-api/blobs"));
876
+ const res = unwrap(
877
+ await this.httpClient.get(
878
+ "/admin-api/blobs"
879
+ )
880
+ );
881
+ return { blobs: res.blobs.map((b) => ({ blobId: b.blob_id, size: b.size })) };
855
882
  }
856
883
  async getBlob(blobId) {
857
- return unwrap(await this.httpClient.get(`/admin-api/blobs/${blobId}`));
884
+ const res = unwrap(
885
+ await this.httpClient.get(
886
+ `/admin-api/blobs/${blobId}`
887
+ )
888
+ );
889
+ return { blobId: res.blob_id, size: res.size };
858
890
  }
859
891
  // ---- Alias Management ----
860
892
  async createContextAlias(request) {
861
- return unwrap(await this.httpClient.post("/admin-api/alias/create/context", request));
893
+ return unwrap(
894
+ await this.httpClient.post(
895
+ "/admin-api/alias/create/context",
896
+ { alias: request.alias, contextId: request.contextId }
897
+ )
898
+ );
862
899
  }
863
900
  async createApplicationAlias(request) {
864
- return unwrap(await this.httpClient.post("/admin-api/alias/create/application", request));
901
+ return unwrap(
902
+ await this.httpClient.post(
903
+ "/admin-api/alias/create/application",
904
+ { alias: request.alias, applicationId: request.applicationId }
905
+ )
906
+ );
865
907
  }
866
908
  async lookupContextAlias(name) {
867
909
  return unwrap(
@@ -913,7 +955,7 @@ var AdminApiClient = class {
913
955
  return unwrap(
914
956
  await this.httpClient.post(
915
957
  `/admin-api/alias/create/identity/${contextId}`,
916
- request
958
+ { alias: request.alias, identity: request.identity }
917
959
  )
918
960
  );
919
961
  }