Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 8x 8x 8x 8x 8x 8x 8x | import { copyRequest } from '../utils/request'
import { addIntegrationInfo } from '../../shared/integrationInfo'
/**
* Fetches and returns a script with FingerprintJS Pro agent loader for the specified public API key.
* The response is returned as received, without platform caching or header changes.
*
* @param {Request} incomingRequest - The incoming HTTP request received by the worker.
* @param {string} publicApiKey - The public API key used to generate the script URL.
* @param {string} cdnHost - Hostname of the Fingerprint CDN.
* @return {Promise<Response>} A promise that resolves to the unchanged Fingerprint CDN response.
*/
export async function getAgentLoader(
incomingRequest: Request,
publicApiKey: string,
cdnHost: string
): Promise<Response> {
// Query params from the incoming request are not forwarded to the CDN
const fpScriptUrl = new URL(`https://${cdnHost}/v4/${publicApiKey}`)
addIntegrationInfo(fpScriptUrl, 'procdn')
console.debug('Fetching agent loader from:', fpScriptUrl)
const requestHeaders = new Headers(incomingRequest.headers)
requestHeaders.delete('Cookie')
const request = copyRequest({
request: incomingRequest,
url: fpScriptUrl,
init: {
headers: requestHeaders,
},
})
return fetch(request)
}
|