diff --git a/src/config.ts b/src/config.ts index 433e0fc1..95de557d 100644 --- a/src/config.ts +++ b/src/config.ts @@ -2,6 +2,7 @@ export interface AppConfig { beeApiUrl: string beeDebugApiUrl: string authorization?: string + allowlist?: string[] hostname?: string cidSubdomains?: boolean ensSubdomains?: boolean @@ -54,6 +55,7 @@ export type EnvironmentVariables = Partial<{ // Proxy BEE_API_URL: string AUTH_SECRET: string + ALLOWLIST: string // Server PORT: string @@ -106,6 +108,7 @@ export function getAppConfig({ BEE_API_URL, BEE_DEBUG_API_URL, AUTH_SECRET, + ALLOWLIST, CID_SUBDOMAINS, ENS_SUBDOMAINS, HOSTNAME, @@ -117,6 +120,7 @@ export function getAppConfig({ beeApiUrl: BEE_API_URL || DEFAULT_BEE_API_URL, beeDebugApiUrl: BEE_DEBUG_API_URL || DEFAULT_BEE_DEBUG_API_URL, authorization: AUTH_SECRET, + allowlist: ALLOWLIST ? ALLOWLIST.split(',') : undefined, cidSubdomains: CID_SUBDOMAINS === 'true', ensSubdomains: ENS_SUBDOMAINS === 'true', removePinHeader: REMOVE_PIN_HEADER ? REMOVE_PIN_HEADER === 'true' : true, @@ -176,7 +180,7 @@ export function getStampsConfig({ throw new Error( `config: please provide POSTAGE_DEPTH=${POSTAGE_DEPTH}, POSTAGE_AMOUNT=${POSTAGE_AMOUNT}, POSTAGE_TTL_MIN=${POSTAGE_TTL_MIN} ${ POSTAGE_EXTENDSTTL === 'true' ? 'at least 60 seconds ' : '' - } for the feature to work`, + }for the feature to work`, ) } diff --git a/src/proxy.ts b/src/proxy.ts index eff2a1a7..9a1cdd45 100644 --- a/src/proxy.ts +++ b/src/proxy.ts @@ -15,6 +15,7 @@ interface Options { beeApiUrl: string removePinHeader: boolean stampManager: StampsManager | null + allowlist?: string[] } export function createProxyEndpoints(app: Application, options: Options) { @@ -45,7 +46,6 @@ async function fetchAndRespond(req: Request, res: Response, options: Options) { validateStatus: status => status < 500, responseType: 'arraybuffer', }) - console.log(response.headers) if ((response.headers['content-disposition'] || '').includes('.html')) { res.status(403).send('Forbidden') return diff --git a/test/config.spec.ts b/test/config.spec.ts index 41d35af5..593cb1ed 100644 --- a/test/config.spec.ts +++ b/test/config.spec.ts @@ -1,16 +1,16 @@ import { + DEFAULT_BEE_API_URL, DEFAULT_BEE_DEBUG_API_URL, DEFAULT_HOSTNAME, DEFAULT_PORT, - DEFAULT_POSTAGE_USAGE_THRESHOLD, - DEFAULT_POSTAGE_USAGE_MAX, DEFAULT_POSTAGE_REFRESH_PERIOD, + DEFAULT_POSTAGE_USAGE_MAX, + DEFAULT_POSTAGE_USAGE_THRESHOLD, + EnvironmentVariables, + StampsConfig, getAppConfig, getServerConfig, getStampsConfig, - EnvironmentVariables, - StampsConfig, - DEFAULT_BEE_API_URL, } from '../src/config' describe('getAppConfig', () => { @@ -195,9 +195,7 @@ describe('getStampsConfig', () => { }).toThrowError( `config: please provide POSTAGE_DEPTH=${v.POSTAGE_DEPTH}, POSTAGE_AMOUNT=${v.POSTAGE_AMOUNT}, POSTAGE_TTL_MIN=${ v.POSTAGE_TTL_MIN - } ${v.POSTAGE_EXTENDSTTL === 'true' ? 'at least 60 seconds ' : ''}or BEE_DEBUG_API_URL=${ - v.BEE_DEBUG_API_URL - } for the feature to work`, + } ${v.POSTAGE_EXTENDSTTL === 'true' ? 'at least 60 seconds ' : ''}for the feature to work`, ) }) })