fix: Remove API key whitelist field (#323)
* Refactor integrator ID and add Prometheus metrics * Update packages/asset-swapper/src/swap_quoter.ts Co-authored-by: David Walsh <5778036+rhinodavid@users.noreply.github.com> * Update packages/asset-swapper/src/swap_quoter.ts Co-authored-by: David Walsh <5778036+rhinodavid@users.noreply.github.com> * Update packages/asset-swapper/src/swap_quoter.ts Co-authored-by: David Walsh <5778036+rhinodavid@users.noreply.github.com> * Added documentation and fixed some minor requests * Added more metrics * more docs * lint fix * added new Integrator ID addition * refactor tests * Refactor new types Co-authored-by: David Walsh <5778036+rhinodavid@users.noreply.github.com>
This commit is contained in:
parent
6ce4458a5d
commit
79f36cf6fb
@ -244,7 +244,6 @@ export interface RfqRequestOpts {
|
||||
takerAddress: string;
|
||||
txOrigin: string;
|
||||
integrator: Integrator;
|
||||
apiKeyWhitelist?: string[];
|
||||
intentOnFilling: boolean;
|
||||
isIndicative?: boolean;
|
||||
makerEndpointMaxResponseTimeMs?: number;
|
||||
@ -297,6 +296,7 @@ export interface RfqFirmQuoteValidator {
|
||||
export interface Integrator {
|
||||
integratorId: string;
|
||||
label: string;
|
||||
whitelistIntegratorUrls?: string[];
|
||||
}
|
||||
|
||||
export interface SwapQuoterRfqOpts {
|
||||
|
@ -214,7 +214,7 @@ export class QuoteRequestor {
|
||||
* @returns a list of TypedMakerUrl instances
|
||||
*/
|
||||
public static getTypedMakerUrlsAndWhitelist(
|
||||
options: Pick<RfqmRequestOptions, 'apiKeyWhitelist' | 'altRfqAssetOfferings'>,
|
||||
options: Pick<RfqmRequestOptions, 'integrator' | 'altRfqAssetOfferings'>,
|
||||
assetOfferings: RfqMakerAssetOfferings,
|
||||
): TypedMakerUrl[] {
|
||||
const standardUrls = Object.keys(assetOfferings).map(
|
||||
@ -233,8 +233,8 @@ export class QuoteRequestor {
|
||||
let typedMakerUrls = standardUrls.concat(altUrls);
|
||||
|
||||
// If there is a whitelist, only allow approved maker URLs
|
||||
if (options.apiKeyWhitelist !== undefined) {
|
||||
const whitelist = new Set(options.apiKeyWhitelist.map(key => key.toLowerCase()));
|
||||
if (options.integrator.whitelistIntegratorUrls !== undefined) {
|
||||
const whitelist = new Set(options.integrator.whitelistIntegratorUrls.map(key => key.toLowerCase()));
|
||||
typedMakerUrls = typedMakerUrls.filter(makerUrl => whitelist.has(makerUrl.url.toLowerCase()));
|
||||
}
|
||||
return typedMakerUrls;
|
||||
|
@ -862,7 +862,11 @@ describe('QuoteRequestor', async () => {
|
||||
const [apiKeyWhitelist, results] = test;
|
||||
const response = QuoteRequestor.getTypedMakerUrlsAndWhitelist(
|
||||
{
|
||||
apiKeyWhitelist,
|
||||
integrator: {
|
||||
integratorId: 'foo',
|
||||
label: 'bar',
|
||||
whitelistIntegratorUrls: apiKeyWhitelist,
|
||||
},
|
||||
altRfqAssetOfferings: {},
|
||||
},
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user