-
Notifications
You must be signed in to change notification settings - Fork 0
/
integrity_check.js.map
1 lines (1 loc) · 5.16 KB
/
integrity_check.js.map
1
{"version":3,"sources":["src/integrity_check.js"],"names":[],"mappings":"CAGC,AAAC,WACA,IAAM,EAAO,KAAQ,KAAM,oCAAqC,EAwChE,SAAS,EAAkB,CAAU,QACH,CAAA,IAA5B,EAAW,YAAY,EACvB,AAAwB,CAAA,IAAxB,EAAW,QAAQ,EACnB,AAA0B,YAA1B,OAAO,EAAW,GAAG,AAE3B,CAEA,SAAS,EAAkB,CAAE,CAAE,EAAe,EAAG,IAAI,EACnD,GAAI,AAAwB,UAAxB,OAAO,EAA2B,KAAM,iCAC5C,GAAI,CAhDN,AAgDO,SAhDY,CAAE,EA2BnB,IAAM,EAAO,EAAG,IAAI,CACpB,GAAI,AAAgB,UAAhB,OAAO,EAAmB,MAAO,CAAA,EACrC,IAAM,EAAI,yCACV,IAAK,IAAI,EAAI,EAAG,EAAI,EAAK,MAAM,CAAE,IAAK,CACpC,IAAM,EAAI,CAAI,CAAC,EAAE,CACjB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAE,MAAM,CAAE,IAC5B,GAAI,IAAM,CAAC,CAAC,EAAE,CAAE,MAAO,CAAA,CAE3B,CACA,MAnCgB,AAmCT,CAnCS,CAAC,EAAO,KACtB,IAAI,EAAe,EACf,EAAU,EACd,KAAO,EAAe,EAAM,MAAM,EAAE,CAClC,IAAM,EAAO,CAAK,CAAC,EAAa,CAC5B,EAAI,EACR,KAAO,EAAI,EAAK,MAAM,EAAI,EAAU,EAAI,MAAM,EAAE,CAC9C,IAAM,EAAI,CAAI,CAAC,EAAE,CACX,EAAI,CAAG,CAAC,EAAQ,CACtB,GAAI,IAAM,EACR,IACA,SACK,GAAI,AAAO,IAAN,GAAW,IAAM,EAAK,MAAM,EAAM,AAAM,MAAN,GAAa,AAAM,MAAN,GAAc,AAAM,OAAN,GAAc,AAAM,OAAN,EAGrF,MAAO,CAAA,CAFP,CAAA,IAIJ,CACA,GAAI,IAAM,EAAK,MAAM,CAGnB,MAAO,CAAA,CAFP,CAAA,GAIJ,CACA,MAAO,CAAA,CACT,CAAA,EAUe,CAAC,YAAa,EAAG,IAAI,CAAE,KAAM,IAAK,gBAAiB,IAAI,CAAE,EAAK,QAAQ,CAAC,IAAI,CAAC,GAC7F,EAWgB,GAAK,KAAM,CAAC,SAAS,EAAE,EAAG,IAAI,CAAC,sCAAsC,CAAC,CACpF,GAAI,EAAG,IAAI,GAAK,EAAc,KAAM,CAAC,SAAS,EAAE,EAAa,6CAA6C,CAAC,AAC7G,EAEA,AA8BA,WA7BE,EAAiB,OAAQ,UACzB,EAAiB,OAAO,yBAAyB,CAAE,6BACnD,EAAiB,OAAO,MAAM,CAAE,UAChC,IAAM,EAAc,EAAE,CACtB,EAAiB,EAAY,IAAI,CAAE,QACnC,EAAY,IAAI,CAAC,OAAO,yBAAyB,CAAC,aAClD,IAAI,EAAe,EAEnB,KAAO,EAAe,EAAY,MAAM,EAAE,KAE1B,EADd,IAAM,EAAa,CAAW,CAAC,IAAe,CACxC,EAAQ,QAAA,EAAA,EAAW,KAAK,YAAhB,EAAA,EAAoB,CAAC,EAC7B,EAAa,AAAiB,YAAjB,OAAO,EACpB,EAAW,AAAiB,UAAjB,OAAO,EACxB,GAAI,GAAc,EAAU,CAG1B,IAAK,IAAM,KAAa,OAAO,MAAM,CAFlB,OAAO,yBAAyB,CAAC,IAG9C,GAAa,CAAC,EAAiB,IACjC,QAAQ,KAAK,CAAC,yBAA0B,GAGxC,GACF,EAAiB,EAErB,MAAY,EAAiB,IAC3B,QAAQ,KAAK,CAAC,yBAA0B,EAE5C,CACF,GAEF","file":"integrity_check.js","sourcesContent":["/* Copyright [email protected] 2024 */\r\n/* eslint-disable no-undef */\r\n/* eslint-disable no-throw-literal */\r\n;(function () {\r\n const noop = () => { throw 'This function should not be called' }\r\n function isNative (fn) {\r\n const matches = (parts, str) => {\r\n let partsMatched = 0\r\n let matched = 0\r\n while (partsMatched < parts.length) {\r\n const part = parts[partsMatched]\r\n let i = 0\r\n while (i < part.length && matched < str.length) {\r\n const p = part[i]\r\n const c = str[matched]\r\n if (p === c) {\r\n i++\r\n matched++\r\n } else if ((i === 0 || i === part.length) && (c === ' ' || c === '\\t' || c === '\\n' || c === '\\r')) {\r\n matched++\r\n } else {\r\n return false\r\n }\r\n }\r\n if (i === part.length) {\r\n partsMatched++\r\n } else {\r\n return false\r\n }\r\n }\r\n return true\r\n }\r\n const name = fn.name\r\n if (typeof name !== 'string') return false\r\n const s = '\\t\\r\\n !\"#%&\\'()*+,-./:;<=>?@[\\\\]^`{|}~'\r\n for (let i = 0; i < name.length; i++) {\r\n const c = name[i]\r\n for (let j = 0; j < s.length; j++) {\r\n if (c === s[j]) return false\r\n }\r\n }\r\n return matches(['function ', fn.name, '()', '{', '[native code]', '}'], noop.toString.call(fn))\r\n }\r\n\r\n function isPropertyFrozen (descriptor) {\r\n if (descriptor.configurable === true) return false\r\n if (descriptor.writable === true) return false\r\n if (typeof descriptor.set === 'function') return false\r\n return true\r\n }\r\n\r\n function throwIfNotNative (fn, expectedName = fn.name) {\r\n if (typeof expectedName !== 'string') throw 'Expected name must be a string'\r\n if (!isNative(fn)) throw `Function ${fn.name} is user-defined and cannot be trusted`\r\n if (fn.name !== expectedName) throw `Function ${expectedName} has been tampered with and cannot be trusted`\r\n }\r\n\r\n function validate () {\r\n throwIfNotNative(Object, 'Object')\r\n throwIfNotNative(Object.getOwnPropertyDescriptors, 'getOwnPropertyDescriptors')\r\n throwIfNotNative(Object.values, 'values')\r\n const descriptors = []\r\n throwIfNotNative(descriptors.push, 'push')\r\n descriptors.push(Object.getOwnPropertyDescriptors(globalThis))\r\n let visitedIndex = 0\r\n\r\n while (visitedIndex < descriptors.length) {\r\n const descriptor = descriptors[visitedIndex++]\r\n const value = descriptor.value ?? {}\r\n const isFunction = typeof value === 'function'\r\n const isObject = typeof value === 'object'\r\n if (isFunction || isObject) {\r\n const candidates = Object.getOwnPropertyDescriptors(value)\r\n // filter already visited objects\r\n for (const candidate of Object.values(candidates)) {\r\n if (candidate && !isPropertyFrozen(candidate)) {\r\n console.error('Property is not frozen', candidate)\r\n }\r\n }\r\n if (isFunction) {\r\n throwIfNotNative(value)\r\n }\r\n } else if (!isPropertyFrozen(descriptor)) {\r\n console.error('Property is not frozen', descriptor)\r\n }\r\n }\r\n }\r\n validate()\r\n})()\r\n"]}