Skip to content

Commit 6b7575a

Browse files
committed
feat: uses environmentOptionsFromContext for decryptValue encryption extension
1 parent 1c21d95 commit 6b7575a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

app-config-encryption/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { ParsingExtension } from '@app-config/core';
22
import { named } from '@app-config/extension-utils';
33
import { logger } from '@app-config/logging';
4+
import { environmentOptionsFromContext } from '@app-config/node';
45
import { DecryptedSymmetricKey, decryptValue } from './encryption';
56

67
export * from './encryption';
@@ -12,7 +13,7 @@ export default function encryptedDirective(
1213
symmetricKey?: DecryptedSymmetricKey,
1314
shouldShowDeprecationNotice?: true,
1415
): ParsingExtension {
15-
return named('encryption', (value) => {
16+
return named('encryption', (value, _, __, ctx) => {
1617
if (typeof value === 'string' && value.startsWith('enc:')) {
1718
return async (parse) => {
1819
if (shouldShowDeprecationNotice) {
@@ -21,7 +22,8 @@ export default function encryptedDirective(
2122
);
2223
}
2324

24-
const decrypted = await decryptValue(value, symmetricKey);
25+
const environmentOptions = environmentOptionsFromContext(ctx);
26+
const decrypted = await decryptValue(value, symmetricKey, environmentOptions);
2527

2628
return parse(decrypted, { fromSecrets: true, parsedFromEncryptedValue: true });
2729
};

0 commit comments

Comments
 (0)