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U,EAAE,OAAO,CAAC,EAAE,CAAC;IACrC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,EAAE;QAChC,QAAQ;QACR,eAAe;QACf,YAAY;QACZ,cAAc;KACf,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB;IACnC,YAAY,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,SAAS,EAAE,EAAE;QAC7C,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE,CAAC;YAClC,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,QAAQ,EAAE;gBACzC,KAAK,EAAE,SAAS;gBAChB,YAAY,EAAE,KAAK;gBACnB,QAAQ,EAAE,KAAK;aAChB,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["// When creating a sandbox, limitation of the events from leaking\n// sensitive objects is required. This is done by overriding own properties\n// of prototypes of all existing events.\nimport { hasProperty } from '@metamask/utils';\n\n/**\n * Targeted Event objects and properties.\n * Note: This is a map of the prototypes that inherit from Events with\n * properties that are identified to leak sensitive objects.\n * Not all browsers support all event types, so checking its existence is required.\n */\nconst targetEvents = new Map();\nif (hasProperty(globalThis, 'UIEvent')) {\n  targetEvents.set(UIEvent.prototype, ['view']);\n}\nif (hasProperty(globalThis, 'MutationEvent')) {\n  targetEvents.set(MutationEvent.prototype, ['relatedNode']);\n}\nif (hasProperty(globalThis, 'MessageEvent')) {\n  targetEvents.set(MessageEvent.prototype, ['source']);\n}\nif (hasProperty(globalThis, 'FocusEvent')) {\n  targetEvents.set(FocusEvent.prototype, ['relatedTarget']);\n}\nif (hasProperty(globalThis, 'MouseEvent')) {\n  targetEvents.set(MouseEvent.prototype, [\n    'relatedTarget',\n    'fromElement',\n    'toElement',\n  ]);\n}\nif (hasProperty(globalThis, 'TouchEvent')) {\n  targetEvents.set(TouchEvent.prototype, ['targetTouches', 'touches']);\n}\nif (hasProperty(globalThis, 'Event')) {\n  targetEvents.set(Event.prototype, [\n    'target',\n    'currentTarget',\n    'srcElement',\n    'composedPath',\n  ]);\n}\n\n/**\n * Attenuate Event objects by replacing its own properties.\n */\nexport function executeLockdownEvents() {\n  targetEvents.forEach((properties, prototype) => {\n    for (const property of properties) {\n      Object.defineProperty(prototype, property, {\n        value: undefined,\n        configurable: false,\n        writable: false,\n      });\n    }\n  });\n}\n"]}