Skip to content

Commit 5967a40

Browse files
fs import issues fixed.
1 parent d0f6eb5 commit 5967a40

4 files changed

Lines changed: 14 additions & 14 deletions

File tree

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tiny-crypto-suite",
3-
"version": "1.5.3",
3+
"version": "1.5.4",
44
"description": "Tiny tools, big crypto — seamless encryption and certificate handling for modern web and Node apps.",
55
"scripts": {
66
"test": "npm run test:mjs && npm run test:cjs && npm run test:js",
@@ -104,6 +104,6 @@
104104
},
105105
"dependencies": {
106106
"clone": "^2.1.2",
107-
"tiny-essentials": "^1.11.0"
107+
"tiny-essentials": "^1.12.2"
108108
}
109109
}

src/TinyCertCrypto.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as fs from 'fs';
1+
import { readFileSync } from 'fs';
22
import { Buffer } from 'buffer';
33
import clone from 'clone';
44
import { isBrowser } from './lib/os.mjs';
@@ -441,7 +441,7 @@ class TinyCertCrypto {
441441
: Buffer.isBuffer(this.publicCertBuffer)
442442
? this.publicCertBuffer.toString('utf-8')
443443
: null
444-
: fs.readFileSync(this.publicCertPath, 'utf-8');
444+
: readFileSync(this.publicCertPath, 'utf-8');
445445
loadPublicKey(publicPem);
446446

447447
// Private Key
@@ -452,7 +452,7 @@ class TinyCertCrypto {
452452
: Buffer.isBuffer(this.privateKeyBuffer)
453453
? this.privateKeyBuffer.toString('utf-8')
454454
: null
455-
: fs.readFileSync(this.privateKeyPath, 'utf-8');
455+
: readFileSync(this.privateKeyPath, 'utf-8');
456456

457457
loadPrivateKey(privatePem);
458458
}

src/TinyCrypto.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { randomBytes, createDecipheriv, createCipheriv } from 'crypto';
2-
import * as fs from 'fs';
2+
import { writeFileSync, readFileSync } from 'fs';
33
import { Buffer } from 'buffer';
44

55
import { isBrowser } from './lib/os.mjs';
@@ -280,7 +280,7 @@ class TinyCrypto {
280280
a.download = filename;
281281
a.click();
282282
URL.revokeObjectURL(url);
283-
} else fs.writeFileSync(filename, data);
283+
} else writeFileSync(filename, data);
284284
}
285285

286286
/**
@@ -309,7 +309,7 @@ class TinyCrypto {
309309
a.download = filename;
310310
a.click();
311311
URL.revokeObjectURL(url);
312-
} else fs.writeFileSync(filename, configData);
312+
} else writeFileSync(filename, configData);
313313
}
314314

315315
/**
@@ -352,7 +352,7 @@ class TinyCrypto {
352352
reader.readAsText(file);
353353
});
354354
} else {
355-
const raw = fs.readFileSync(/** @type {string} */ (file), 'utf8');
355+
const raw = readFileSync(/** @type {string} */ (file), 'utf8');
356356
const config = JSON.parse(raw);
357357
return this.importConfig(config);
358358
}
@@ -397,7 +397,7 @@ class TinyCrypto {
397397
reader.readAsText(file);
398398
});
399399
} else {
400-
const hexKey = fs.readFileSync(/** @type {string} */ (file), 'utf8');
400+
const hexKey = readFileSync(/** @type {string} */ (file), 'utf8');
401401
const keyBuffer = Buffer.from(hexKey, 'hex');
402402
this.key = keyBuffer;
403403
return keyBuffer;

0 commit comments

Comments
 (0)