zen-fs-config 0.3.18 → 0.3.19

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.js CHANGED
@@ -414,9 +414,12 @@ async function sha256(data) {
414
414
  const hex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
415
415
  return `sha256:${hex}`;
416
416
  }
417
- const nodeCrypto = await import("crypto");
418
- const hash = nodeCrypto.createHash("sha256").update(Buffer.from(buffer)).digest("hex");
419
- return `sha256:${hash}`;
417
+ if (typeof globalThis.window === "undefined") {
418
+ const nodeCrypto = await new Function("return import('node:crypto')")();
419
+ const hash = nodeCrypto.createHash("sha256").update(Buffer.from(buffer)).digest("hex");
420
+ return `sha256:${hash}`;
421
+ }
422
+ throw new Error("SHA-256 not available: neither Web Crypto nor Node.js crypto module found");
420
423
  }
421
424
  async function readVersion(fs, versionFilePath) {
422
425
  try {
package/dist/index.mjs CHANGED
@@ -365,9 +365,12 @@ async function sha256(data) {
365
365
  const hex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
366
366
  return `sha256:${hex}`;
367
367
  }
368
- const nodeCrypto = await import("crypto");
369
- const hash = nodeCrypto.createHash("sha256").update(Buffer.from(buffer)).digest("hex");
370
- return `sha256:${hash}`;
368
+ if (typeof globalThis.window === "undefined") {
369
+ const nodeCrypto = await new Function("return import('node:crypto')")();
370
+ const hash = nodeCrypto.createHash("sha256").update(Buffer.from(buffer)).digest("hex");
371
+ return `sha256:${hash}`;
372
+ }
373
+ throw new Error("SHA-256 not available: neither Web Crypto nor Node.js crypto module found");
371
374
  }
372
375
  async function readVersion(fs, versionFilePath) {
373
376
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zen-fs-config",
3
- "version": "0.3.18",
3
+ "version": "0.3.19",
4
4
  "description": "Distributed config management library built on ZenFS, zen-fs-cache, and zen-fs-sync",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",