diff --git a/packages/config/src/index.ts b/packages/config/src/index.ts index 785b4e2809..ae739c8978 100644 --- a/packages/config/src/index.ts +++ b/packages/config/src/index.ts @@ -1,4 +1,3 @@ -import axios from 'axios'; import { track, setEnvironment, setPublishableApiKey } from '@imtbl/metrics'; export enum Environment { @@ -55,6 +54,7 @@ export const addKeysToHeadersOverride = { - if (!apiKey.startsWith(API_KEY_PREFIX)) { - throw new Error( - 'Invalid API key. Create your api key in Immutable developer hub. https://hub.immutable.com', - ); - } - axios.defaults.headers.common[KeyHeaders.API_KEY] = apiKey; -}; - -export const addPublishableKeyToAxiosHeader = (publishableKey: string) => { - if (!publishableKey.startsWith(PUBLISHABLE_KEY_PREFIX)) { - throw new Error( - 'Invalid Publishable key. Create your Publishable key in Immutable developer hub.' - + ' https://hub.immutable.com', - ); - } - setPublishableApiKey(publishableKey); - axios.defaults.headers.common[KeyHeaders.PUBLISHABLE_KEY] = publishableKey; -}; - -export const addRateLimitingKeyToAxiosHeader = (rateLimitingKey: string) => { - axios.defaults.headers.common[KeyHeaders.RATE_LIMITING_KEY] = rateLimitingKey; -}; - -type ImmutableConfigurationWithRequireableFields = ImmutableConfiguration & -(T extends { apiKey: 'required' } ? Required<{ apiKey: string }> : {}) & -(T extends { publishableKey: 'required' } - ? Required<{ publishableKey: string }> - : {}); - -type ImmutableConfigurationWithOmitableFields = T extends { apiKey: 'omit' } - ? Omit, 'apiKey'> - : ImmutableConfigurationWithRequireableFields; - export interface ModuleConfiguration { - baseConfig: ImmutableConfigurationWithOmitableFields; + baseConfig: ImmutableConfiguration; overrides?: T; }