11import { EnvironmentName , V1Network } from 'bitgo' ;
22import { isNil , isNumber } from 'lodash' ;
3- import { readFileSync , existsSync } from 'fs' ;
43import 'dotenv/config' ;
54
65import { args } from './args' ;
@@ -39,8 +38,6 @@ export interface Config {
3938 customBitcoinNetwork ?: V1Network ;
4039 authVersion : number ;
4140 externalSignerUrl ?: string ;
42- enclavedExpressUrl ?: string ;
43- enclavedExpressSSLCert ?: string ;
4441 signerMode ?: boolean ;
4542 signerFileSystemPath ?: string ;
4643 lightningSignerFileSystemPath ?: string ;
@@ -67,8 +64,6 @@ export const ArgConfig = (args): Partial<Config> => ({
6764 customBitcoinNetwork : args . custombitcoinnetwork ,
6865 authVersion : args . authVersion ,
6966 externalSignerUrl : args . externalSignerUrl ,
70- enclavedExpressUrl : args . enclavedExpressUrl ,
71- enclavedExpressSSLCert : args . enclavedExpressSSLCert ,
7267 signerMode : args . signerMode ,
7368 signerFileSystemPath : args . signerFileSystemPath ,
7469 lightningSignerFileSystemPath : args . lightningSignerFileSystemPath ,
@@ -95,8 +90,6 @@ export const EnvConfig = (): Partial<Config> => ({
9590 customBitcoinNetwork : readEnvVar ( 'BITGO_CUSTOM_BITCOIN_NETWORK' ) as V1Network ,
9691 authVersion : Number ( readEnvVar ( 'BITGO_AUTH_VERSION' ) ) ,
9792 externalSignerUrl : readEnvVar ( 'BITGO_EXTERNAL_SIGNER_URL' ) ,
98- enclavedExpressUrl : readEnvVar ( 'BITGO_ENCLAVED_EXPRESS_URL' ) ,
99- enclavedExpressSSLCert : readEnvVar ( 'BITGO_ENCLAVED_EXPRESS_SSL_CERT' ) ,
10093 signerMode : readEnvVar ( 'BITGO_SIGNER_MODE' ) ? true : undefined ,
10194 signerFileSystemPath : readEnvVar ( 'BITGO_SIGNER_FILE_SYSTEM_PATH' ) ,
10295 lightningSignerFileSystemPath : readEnvVar ( 'BITGO_LIGHTNING_SIGNER_FILE_SYSTEM_PATH' ) ,
@@ -117,8 +110,6 @@ export const DefaultConfig: Config = {
117110 disableEnvCheck : true ,
118111 timeout : 305 * 1000 ,
119112 authVersion : 2 ,
120- enclavedExpressUrl : undefined ,
121- enclavedExpressSSLCert : undefined ,
122113} ;
123114
124115/**
@@ -156,8 +147,6 @@ function mergeConfigs(...configs: Partial<Config>[]): Config {
156147 const disableSSL = get ( 'disableSSL' ) || false ;
157148 let customRootUri = get ( 'customRootUri' ) ;
158149 let externalSignerUrl = get ( 'externalSignerUrl' ) ;
159- let enclavedExpressUrl = get ( 'enclavedExpressUrl' ) ;
160- let enclavedExpressSSLCert : string | undefined ;
161150
162151 if ( disableSSL !== true ) {
163152 if ( customRootUri ) {
@@ -166,24 +155,6 @@ function mergeConfigs(...configs: Partial<Config>[]): Config {
166155 if ( externalSignerUrl ) {
167156 externalSignerUrl = forceSecureUrl ( externalSignerUrl ) ;
168157 }
169- if ( enclavedExpressUrl ) {
170- enclavedExpressUrl = forceSecureUrl ( enclavedExpressUrl ) ;
171- console . log ( 'Using secure enclaved express URL:' , enclavedExpressUrl ) ;
172- }
173- const enclavedExpressSSLCertValue = get ( 'enclavedExpressSSLCert' ) ;
174- if ( enclavedExpressSSLCertValue ) {
175- try {
176- // First try to read it as a file path
177- enclavedExpressSSLCert = existsSync ( enclavedExpressSSLCertValue )
178- ? readFileSync ( enclavedExpressSSLCertValue , { encoding : 'utf8' } )
179- : enclavedExpressSSLCertValue ; // If not a file, use the value directly
180- if ( existsSync ( enclavedExpressSSLCertValue ) ) {
181- console . log ( 'Successfully loaded SSL cert from:' , enclavedExpressSSLCertValue ) ;
182- }
183- } catch ( e ) {
184- console . error ( `Failed to process enclaved express SSL cert: ${ enclavedExpressSSLCertValue } ` , e ) ;
185- }
186- }
187158 }
188159
189160 return {
@@ -205,8 +176,6 @@ function mergeConfigs(...configs: Partial<Config>[]): Config {
205176 customBitcoinNetwork : get ( 'customBitcoinNetwork' ) ,
206177 authVersion : get ( 'authVersion' ) ,
207178 externalSignerUrl,
208- enclavedExpressUrl,
209- enclavedExpressSSLCert,
210179 signerMode : get ( 'signerMode' ) ,
211180 signerFileSystemPath : get ( 'signerFileSystemPath' ) ,
212181 lightningSignerFileSystemPath : get ( 'lightningSignerFileSystemPath' ) ,
@@ -215,8 +184,8 @@ function mergeConfigs(...configs: Partial<Config>[]): Config {
215184 } ;
216185}
217186
218- export function config ( ) : Config {
187+ export const config = ( ) => {
219188 const arg = ArgConfig ( args ( ) ) ;
220189 const env = EnvConfig ( ) ;
221190 return mergeConfigs ( env , arg ) ;
222- }
191+ } ;
0 commit comments