Using airgap.js in Web Workers
airgap.js 9.28 and later can protect web workers and worklets.
airgap.js does not yet support consent sync within protected worker threads. This means that quarantined events aren’t replayed when consent changes outside the worker's realm, so quarantined events are effectively blocked.
In order to apply airgap.js protections without our realm auto-protection hooks, use the following snippets:
TypeScript
self.airgap = { loadOptions: { airgap: '[location of airgap.js]', baseUrl: '[URL of the original worker script]', }, };
Classic worker
TypeScript
importScripts(self.airgap.loadOptions.airgap);
Module worker or worklet
TypeScript
await import(self.airgap.loadOptions.airgap);