@calimero-network/mero-js 6.0.3 → 6.1.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
@@ -839,10 +839,11 @@ var AdminApiClient = class {
839
839
  * context as stranded.
840
840
  */
841
841
  async resyncContext(contextId, request = {}) {
842
- return this.httpClient.post(
842
+ const r = await this.httpClient.post(
843
843
  `/admin-api/contexts/${contextId}/resync`,
844
844
  request
845
845
  );
846
+ return r ?? { contextId, resyncStarted: true };
846
847
  }
847
848
  async inviteSpecializedNode(request) {
848
849
  return unwrap(
@@ -890,13 +891,30 @@ var AdminApiClient = class {
890
891
  );
891
892
  return { blobs: res.blobs.map((b) => ({ blobId: b.blob_id, size: b.size })) };
892
893
  }
894
+ /**
895
+ * Download a blob's raw bytes. `GET /admin-api/blobs/:id` streams the blob
896
+ * content (e.g. `application/gzip`), NOT JSON — so fetch it as an ArrayBuffer.
897
+ * Use {@link listBlobs} for `{ blobId, size }` metadata.
898
+ */
893
899
  async getBlob(blobId) {
894
- const res = unwrap(
895
- await this.httpClient.get(
896
- `/admin-api/blobs/${blobId}`
897
- )
898
- );
899
- return { blobId: res.blob_id, size: res.size };
900
+ return this.httpClient.get(`/admin-api/blobs/${blobId}`, {
901
+ parse: "arrayBuffer"
902
+ });
903
+ }
904
+ /**
905
+ * Fetch a blob's metadata without downloading it. `HEAD /admin-api/blobs/:id`
906
+ * returns the info in response headers (size via `content-length`, plus
907
+ * `x-blob-id`/`x-blob-hash`/`x-blob-mime-type`).
908
+ */
909
+ async getBlobInfo(blobId) {
910
+ const { headers } = await this.httpClient.head(`/admin-api/blobs/${blobId}`);
911
+ const size = Number(headers["content-length"]);
912
+ return {
913
+ blobId: headers["x-blob-id"] ?? blobId,
914
+ size: Number.isFinite(size) ? size : 0,
915
+ hash: headers["x-blob-hash"],
916
+ mimeType: headers["x-blob-mime-type"]
917
+ };
900
918
  }
901
919
  // ---- Alias Management ----
902
920
  async createContextAlias(request) {
@@ -1105,6 +1123,10 @@ var AdminApiClient = class {
1105
1123
  async setTeeAdmissionPolicy(groupId, request) {
1106
1124
  await this.httpClient.put(`/admin-api/groups/${groupId}/settings/tee-admission-policy`, request);
1107
1125
  }
1126
+ async getTeeAdmissionPolicy(groupId) {
1127
+ const response = await this.httpClient.get(`/admin-api/groups/${groupId}/settings/tee-admission-policy`);
1128
+ return response.data ?? response;
1129
+ }
1108
1130
  async updateGroupSettings(groupId, request) {
1109
1131
  await this.httpClient.patch(`/admin-api/groups/${groupId}`, request);
1110
1132
  }
@@ -1759,6 +1781,9 @@ var _WsClient = class _WsClient {
1759
1781
  }
1760
1782
  this.emit("event", {
1761
1783
  contextId: msg.result.contextId,
1784
+ // Forward the event tag (sibling of `data` in core's flattened
1785
+ // payload) so consumers can discriminate, matching `SseClient`.
1786
+ type: msg.result.type,
1762
1787
  data: eventData
1763
1788
  });
1764
1789
  }