Skip to content

Commit

Permalink
fix: config key export
Browse files Browse the repository at this point in the history
  • Loading branch information
npenin committed Dec 28, 2023
1 parent d093be2 commit 15d144d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/config/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export default class Configuration<T extends object = SerializableObject>
content = await fs.readFile(file, 'utf8');
try
{
cryptKey = await subtle.importKey('pkcs8', await fs.readFile(file + '.key'), { name: 'AES-CBC' }, true, ['encrypt', 'decrypt']);
cryptKey = await subtle.importKey('raw', await fs.readFile(file + '.key'), { name: 'AES-CBC' }, true, ['encrypt', 'decrypt']);

}
catch (e)
Expand Down Expand Up @@ -307,7 +307,7 @@ export default class Configuration<T extends object = SerializableObject>
formatted = process.env.NODE_ENV !== 'production';
await fs.writeFile(file || this.path, JSON.stringify(this.rootConfig, null, formatted && 4 || undefined), 'utf8');
if (this.cryptKey)
await fs.writeFile((file || this.path) + '.key', Buffer.from(await subtle.exportKey('pkcs8', this.cryptKey)), 'utf8');
await fs.writeFile((file || this.path) + '.key', Buffer.from(await subtle.exportKey('raw', this.cryptKey)));

}
}

0 comments on commit 15d144d

Please sign in to comment.