Skip to content

Commit e5bb0a8

Browse files
authored
Merge pull request #7328 from BitGo/WP-6488
fix: revert changes from WP-4376
2 parents 2d50512 + e35665a commit e5bb0a8

File tree

7 files changed

+3
-88
lines changed

7 files changed

+3
-88
lines changed

modules/express/src/args.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,6 @@ parser.addArgument(['--externalSignerUrl'], {
9696
help: 'URL which specifies the external signing API.',
9797
});
9898

99-
parser.addArgument(['--enclavedExpressUrl'], {
100-
help: 'URL to an Express instance in a secure environment.',
101-
});
102-
103-
parser.addArgument(['--enclavedExpressSSLCert'], {
104-
help: 'Path to the SSL certificate file for communicating with enclavedExpressUrl.',
105-
});
106-
10799
parser.addArgument(['--signerMode'], {
108100
action: 'storeConst',
109101
constant: true,

modules/express/src/clientRoutes.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import type { ParamsDictionary } from 'express-serve-static-core';
3838
import * as _ from 'lodash';
3939
import * as url from 'url';
4040
import * as superagent from 'superagent';
41-
import { handlePingEnclavedExpress } from './enclavedExpressRoutes';
4241

4342
// RequestTracer should be extracted into a separate npm package (along with
4443
// the rest of the BitGoJS HTTP request machinery)
@@ -1752,11 +1751,6 @@ export function setupSigningRoutes(app: express.Application, config: Config): vo
17521751
);
17531752
}
17541753

1755-
export function setupEnclavedExpressRoutes(app: express.Application, config: Config): void {
1756-
// Keep the ping endpoint for health checks
1757-
app.get('/ping/enclavedExpress', parseBody, prepareBitGo(config), promiseWrapper(handlePingEnclavedExpress));
1758-
}
1759-
17601754
export function setupLightningSignerNodeRoutes(app: express.Application, config: Config): void {
17611755
app.post(
17621756
'/api/v2/:coin/wallet/:id/signermacaroon',

modules/express/src/config.ts

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { EnvironmentName, V1Network } from 'bitgo';
22
import { isNil, isNumber } from 'lodash';
3-
import { readFileSync, existsSync } from 'fs';
43
import 'dotenv/config';
54

65
import { 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+
};

modules/express/src/enclavedExpressRoutes/enclavedExpressRoutes.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

modules/express/src/enclavedExpressRoutes/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

modules/express/src/expressApp.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,7 @@ function createHttpServer(app: express.Application): http.Server {
117117
*/
118118
export function startup(config: Config, baseUri: string): () => void {
119119
return function () {
120-
const {
121-
env,
122-
ipc,
123-
customRootUri,
124-
customBitcoinNetwork,
125-
signerMode,
126-
lightningSignerFileSystemPath,
127-
enclavedExpressUrl,
128-
enclavedExpressSSLCert,
129-
} = config;
120+
const { env, ipc, customRootUri, customBitcoinNetwork, signerMode, lightningSignerFileSystemPath } = config;
130121
/* eslint-disable no-console */
131122
console.log('BitGo-Express running');
132123
console.log(`Environment: ${env}`);
@@ -147,12 +138,6 @@ export function startup(config: Config, baseUri: string): () => void {
147138
if (lightningSignerFileSystemPath) {
148139
console.log(`Lightning signer file system path: ${lightningSignerFileSystemPath}`);
149140
}
150-
if (enclavedExpressUrl) {
151-
console.log(`Enclaved Express URL: ${enclavedExpressUrl}`);
152-
if (enclavedExpressSSLCert) {
153-
console.log('Enclaved Express SSL certificate configured');
154-
}
155-
}
156141
/* eslint-enable no-console */
157142
};
158143
}
@@ -287,8 +272,6 @@ function checkPreconditions(config: Config) {
287272
export function setupRoutes(app: express.Application, config: Config): void {
288273
if (config.signerMode) {
289274
clientRoutes.setupSigningRoutes(app, config);
290-
} else if (config.enclavedExpressUrl && config.enclavedExpressSSLCert) {
291-
clientRoutes.setupEnclavedExpressRoutes(app, config);
292275
} else {
293276
if (config.lightningSignerFileSystemPath) {
294277
clientRoutes.setupLightningSignerNodeRoutes(app, config);

modules/express/test/unit/config.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ describe('Config:', () => {
123123
BITGO_CUSTOM_ROOT_URI: 'envcustomRootUri',
124124
BITGO_CUSTOM_BITCOIN_NETWORK: 'envcustomBitcoinNetwork',
125125
BITGO_EXTERNAL_SIGNER_URL: 'envexternalSignerUrl',
126-
BITGO_ENCLAVED_EXPRESS_URL: 'envenclavedExpressUrl',
127-
BITGO_ENCLAVED_EXPRESS_SSL_CERT: 'envenclavedExpressSSLCert',
128126
BITGO_SIGNER_MODE: 'envsignerMode',
129127
BITGO_SIGNER_FILE_SYSTEM_PATH: 'envsignerFileSystemPath',
130128
BITGO_LIGHTNING_SIGNER_FILE_SYSTEM_PATH: 'envlightningSignerFileSystemPath',
@@ -181,8 +179,6 @@ describe('Config:', () => {
181179
customBitcoinNetwork: 'argcustomBitcoinNetwork',
182180
authVersion: 2,
183181
externalSignerUrl: 'https://argexternalSignerUrl',
184-
enclavedExpressUrl: 'https://argenclavedExpressUrl',
185-
enclavedExpressSSLCert: 'argenclavedExpressSSLCert',
186182
signerMode: 'argsignerMode',
187183
signerFileSystemPath: 'argsignerFileSystemPath',
188184
lightningSignerFileSystemPath: 'arglightningSignerFileSystemPath',

0 commit comments

Comments
 (0)