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 +6 -3
- package/dist/index.mjs +6 -3
- package/package.json +1 -1
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
|
-
|
|
418
|
-
|
|
419
|
-
|
|
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
|
-
|
|
369
|
-
|
|
370
|
-
|
|
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 {
|