@avenlabs/halal-trace-sdk 0.1.1 → 0.1.2

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/README.md CHANGED
@@ -94,6 +94,12 @@ const client = new ApiClient({
94
94
  });
95
95
  ```
96
96
 
97
+ ## Node-only helpers
98
+
99
+ ```ts
100
+ import { saveToFile } from "@halal-trace/sdk/node";
101
+ ```
102
+
97
103
  ## List all relayer jobs
98
104
 
99
105
  ```ts
package/dist/index.d.ts CHANGED
@@ -2,4 +2,3 @@ export { ApiClient } from "./client.js";
2
2
  export type { Anchor, ApiErrorResponse, ApiResponse, AuthResult, AuthSession, AuditLog, AuditPack, AuditPackManifest, Batch, CertificationRecord, Device, DocumentAnchor, EventDepartment, HealthResponse, Hologram, HologramVerification, Invite, Member, Org, OrgInviteResult, OrgUserLookup, Permission, PublicAttribute, RelayerJobSummary, SignatureRecord, TraceEvent, } from "./types.js";
3
3
  export { ApiError } from "./http.js";
4
4
  export type { AuthOptions, ClientHooks, RetryOptions } from "./http.js";
5
- export { saveToFile } from "./utils.js";
package/dist/index.js CHANGED
@@ -1,3 +1,2 @@
1
1
  export { ApiClient } from "./client.js";
2
2
  export { ApiError } from "./http.js";
3
- export { saveToFile } from "./utils.js";
package/dist/node.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { saveToFile } from "./utils.js";
package/dist/node.js ADDED
@@ -0,0 +1 @@
1
+ export { saveToFile } from "./utils.js";
package/dist/utils.js CHANGED
@@ -1,5 +1,8 @@
1
- import { writeFile } from "node:fs/promises";
2
1
  export const saveToFile = async (path, data) => {
2
+ if (typeof window !== "undefined") {
3
+ throw new Error("saveToFile is only available in Node.js");
4
+ }
5
+ const { writeFile } = await import("node:fs/promises");
3
6
  const buffer = data instanceof Uint8Array ? data : Buffer.from(data);
4
7
  await writeFile(path, buffer);
5
8
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avenlabs/halal-trace-sdk",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/index.ts CHANGED
@@ -29,4 +29,3 @@ export type {
29
29
  } from "./types.js";
30
30
  export { ApiError } from "./http.js";
31
31
  export type { AuthOptions, ClientHooks, RetryOptions } from "./http.js";
32
- export { saveToFile } from "./utils.js";
package/src/node.ts ADDED
@@ -0,0 +1 @@
1
+ export { saveToFile } from "./utils.js";
package/src/utils.ts CHANGED
@@ -1,6 +1,8 @@
1
- import { writeFile } from "node:fs/promises";
2
-
3
1
  export const saveToFile = async (path: string, data: ArrayBuffer | Uint8Array) => {
2
+ if (typeof window !== "undefined") {
3
+ throw new Error("saveToFile is only available in Node.js");
4
+ }
5
+ const { writeFile } = await import("node:fs/promises");
4
6
  const buffer = data instanceof Uint8Array ? data : Buffer.from(data);
5
7
  await writeFile(path, buffer);
6
8
  };