Require HTTPS-only external pricing-provider URLs and verify the adapter contract with the application suite.
This commit is contained in:
@@ -10,10 +10,21 @@ export function createHttpPricingProvider({
|
||||
throw new Error('Pricing provider endpoint is required.');
|
||||
}
|
||||
|
||||
let parsedUrl;
|
||||
try {
|
||||
parsedUrl = new URL(endpoint);
|
||||
} catch {
|
||||
throw new Error('Pricing provider endpoint must be a valid HTTPS URL.');
|
||||
}
|
||||
|
||||
if (parsedUrl.protocol !== 'https:') {
|
||||
throw new Error('Pricing provider endpoint must use HTTPS.');
|
||||
}
|
||||
|
||||
return createPricingProvider({
|
||||
id,
|
||||
async observe(input) {
|
||||
const url = new URL(endpoint);
|
||||
const url = new URL(parsedUrl.toString());
|
||||
for (const [key, value] of Object.entries(input)) {
|
||||
if (value) url.searchParams.set(key, value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user