1
1
import type { ParsingExtension } from '@app-config/core' ;
2
2
import { named } from '@app-config/extension-utils' ;
3
3
import { logger } from '@app-config/logging' ;
4
+ import { environmentOptionsFromContext } from '@app-config/node' ;
4
5
import { DecryptedSymmetricKey , decryptValue } from './encryption' ;
5
6
6
7
export * from './encryption' ;
@@ -12,7 +13,7 @@ export default function encryptedDirective(
12
13
symmetricKey ?: DecryptedSymmetricKey ,
13
14
shouldShowDeprecationNotice ?: true ,
14
15
) : ParsingExtension {
15
- return named ( 'encryption' , ( value ) => {
16
+ return named ( 'encryption' , ( value , _ , __ , ctx ) => {
16
17
if ( typeof value === 'string' && value . startsWith ( 'enc:' ) ) {
17
18
return async ( parse ) => {
18
19
if ( shouldShowDeprecationNotice ) {
@@ -21,7 +22,8 @@ export default function encryptedDirective(
21
22
) ;
22
23
}
23
24
24
- const decrypted = await decryptValue ( value , symmetricKey ) ;
25
+ const environmentOptions = environmentOptionsFromContext ( ctx ) ;
26
+ const decrypted = await decryptValue ( value , symmetricKey , environmentOptions ) ;
25
27
26
28
return parse ( decrypted , { fromSecrets : true , parsedFromEncryptedValue : true } ) ;
27
29
} ;
0 commit comments