(storeDir: string)
| 11 | private key: Buffer; |
| 12 | |
| 13 | constructor(storeDir: string) { |
| 14 | mkdirSync(storeDir, { recursive: true }); |
| 15 | const p = join(storeDir, "master.key"); |
| 16 | if (existsSync(p)) { |
| 17 | this.key = Buffer.from(readFileSync(p, "utf8").trim(), "base64"); |
| 18 | } else { |
| 19 | this.key = randomBytes(32); |
| 20 | writeFileSync(p, this.key.toString("base64"), { mode: 0o600 }); |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | encrypt(plaintext: string): string { |
| 25 | const iv = randomBytes(12); |
nothing calls this directly
no outgoing calls
no test coverage detected