@@ -140,9 +140,17 @@ export async function loadKey(contents: string | Buffer): Promise<Key> {
140
140
return keys [ 0 ] ;
141
141
}
142
142
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
+
146
154
let key : Key ;
147
155
148
156
if ( override ) {
@@ -176,9 +184,17 @@ export async function loadPrivateKey(
176
184
return key ;
177
185
}
178
186
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
+
182
198
let key : Key ;
183
199
184
200
if ( override ) {
0 commit comments