Skip to content

Commit 1422758

Browse files
committed
make fs dynamic loading
1 parent 8caaa99 commit 1422758

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/KeyPair.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
66
*/
77

8-
import fs from 'fs'
98
import { KeyObject, generateKeyPairSync, createPrivateKey, createPublicKey, randomBytes, sign } from 'crypto'
109
import pem from 'pem-file'
1110

@@ -91,6 +90,8 @@ export class KeyPair {
9190
*
9291
*/
9392
public static async importFromFile(filename: string, password: string): Promise<KeyPair> {
93+
94+
const fs = await import('fs')
9495
if (fs.existsSync(filename)) {
9596
const data = await fs.promises.readFile(filename)
9697
return KeyPair.importFromString(data.toString(), password)
@@ -124,6 +125,7 @@ export class KeyPair {
124125
*
125126
*/
126127
public async exportToFile(filename: string, password: string): Promise<unknown> {
128+
const fs = await import('fs')
127129
return await fs.promises.writeFile(filename, this.exportToString(password))
128130
}
129131

0 commit comments

Comments
 (0)