I have a JavaScript embedded in HTML using a sdk.js This SDK is using a compiled wasm file (not possible to decompile it), that child is performing a curl to a specific domain.
I am looking for a solution to include a global URL listener in my HTML JavaScript in order to block the curl to that specific domain.
Is this somehow possible? Does anybody has a clever idea to solve that issue?
according to mdn on FetchEvent and mdn on Abortcontroller.abort() you could do something like
const el = document.querySelector('#exampleId')
const controller = new AbortController()
el.addEventListener('fetch', function(event) {
if (event.request.url === "someUrl") {
controller.abort()
}
})
You will need to attach this event listener to the element that fires the request. if there are going to be multiple elements that do that then you can add the same class to each and use this code to add an event listener to each one:
const elsArray = document.getElementsByClassName('exampleClass')
const controller = new AbortController()
elsArray.forEach(el => {
el.addEventListener('fetch', function(event) {
if (event.request.url === "someUrl") {
controller.abort()
}
}
})
never done that myself so let me know how it goes