@@ -140,9 +140,17 @@ export async function loadKey(contents: string | Buffer): Promise<Key> {
140140 return keys [ 0 ] ;
141141}
142142
143- export async function loadPrivateKey (
144- override : string | Buffer | undefined = process . env . APP_CONFIG_SECRETS_KEY ,
145- ) : Promise < Key > {
143+ export async function loadPrivateKey ( override ?: string | Buffer ) : Promise < Key > {
144+ if ( override === undefined ) {
145+ if ( process . env . APP_CONFIG_SECRETS_KEY ) {
146+ // eslint-disable-next-line no-param-reassign
147+ override = process . env . APP_CONFIG_SECRETS_KEY ;
148+ } else if ( process . env . APP_CONFIG_SECRETS_KEY_FILE ) {
149+ // eslint-disable-next-line no-param-reassign
150+ override = ( await fs . readFile ( process . env . APP_CONFIG_SECRETS_KEY_FILE ) ) . toString ( ) ;
151+ }
152+ }
153+
146154 let key : Key ;
147155
148156 if ( override ) {
@@ -176,9 +184,17 @@ export async function loadPrivateKey(
176184 return key ;
177185}
178186
179- export async function loadPublicKey (
180- override : string | Buffer | undefined = process . env . APP_CONFIG_SECRETS_PUBLIC_KEY ,
181- ) : Promise < Key > {
187+ export async function loadPublicKey ( override ?: string | Buffer ) : Promise < Key > {
188+ if ( override === undefined ) {
189+ if ( process . env . APP_CONFIG_SECRETS_PUBLIC_KEY ) {
190+ // eslint-disable-next-line no-param-reassign
191+ override = process . env . APP_CONFIG_SECRETS_PUBLIC_KEY ;
192+ } else if ( process . env . APP_CONFIG_SECRETS_PUBLIC_KEY_FILE ) {
193+ // eslint-disable-next-line no-param-reassign
194+ override = ( await fs . readFile ( process . env . APP_CONFIG_SECRETS_PUBLIC_KEY_FILE ) ) . toString ( ) ;
195+ }
196+ }
197+
182198 let key : Key ;
183199
184200 if ( override ) {
0 commit comments