1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 02:10:12 +01:00
metamask-extension/app/scripts/use-snow.js

30 lines
861 B
JavaScript
Raw Normal View History

/*
NOTICE:
This Snow + LavaMoat scuttling integration is currently being used
with an experimental API (https://github.com/LavaMoat/LavaMoat/pull/462).
Changing this code must be done cautiously to avoid breaking the app!
*/
// eslint-disable-next-line import/unambiguous
(function () {
const log = console.log.bind(console);
// eslint-disable-next-line no-undef
const isWorker = !self.document;
const msg =
'Snow detected a new realm creation attempt in MetaMask. Performing scuttling on new realm.';
// eslint-disable-next-line no-undef
Object.defineProperty(self, 'SCUTTLER', {
value: (realm, scuttle) => {
if (isWorker) {
scuttle(realm);
} else {
// eslint-disable-next-line no-undef
self.SNOW((win) => {
log(msg, win);
scuttle(win);
}, realm);
}
},
});
})();