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AAC;IAED,IAAI;QACF,sBAAsB,CAAC,OAAO,CAAC,CAAC,GAAW,EAAE,EAAE;YAC7C,IAAI,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;YAC/B,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,UAAU,EAAE;gBAC5C,IAAI;oBACF,QAAQ,GAAG,EAAE;wBACX,KAAK,QAAQ;4BACX,MAAK;wBACP;4BACE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAA;4BACzB,MAAK;qBACR;iBACF;gBAAC,OAAO,EAAE,EAAE;oBACX,EAAE;iBACH;aACF;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AAED,OAAO,EACL,SAAS,EACV,CAAA\",\"sourcesContent\":[\"'use strict'\\n\\nimport { freeze } from '../freeze/index'\\nimport { Sandbox } from '../sandbox/index'\\nimport windowOwnPropertyNames from '../sandbox/windowOwnPropertyNames.config'\\n\\ntype log = {\\n  object: object\\n  name: string\\n  action: string\\n  value?: any\\n}\\n\\nconst sandbox = new Sandbox()\\nconst randPassword = function (): string {\\n  let shadowString = sandbox.shadowWindow.String\\n  let shadowMath = sandbox.shadowWindow.Math\\n  let shadowArray = sandbox.shadowWindow.Array\\n  return (new shadowArray(8 + shadowMath.round(shadowMath.random() * 8))).join(',').split(',').map(() => {\\n    return shadowString['fromCharCode'](33 + shadowMath.round(shadowMath.random() * 89))\\n  }).join('')\\n}\\n\\nclass Strongbox {\\n  public password = randPassword()\\n  private log: Function | undefined\\n  private tracker = (e: object) => {\\n    if (typeof (this.log) === 'function') {\\n      this.log(e)\\n    } else {\\n      console.log('Event Log:', e)\\n    }\\n  }\\n  constructor (insurance: [object], log?: Function) {\\n    let that = this\\n    let secretKey = this.password\\n\\n    // tracker log\\n    this.log = log\\n\\n    for (let insured of insurance) {\\n      let object = insured[0]\\n      let props = insured[1]\\n      let value = object[props]\\n\\n      Object.defineProperty(object, props, {\\n        get () {\\n          that.password = secretKey = randPassword()\\n          return (password: string, setValue: any) => {\\n            if (password === secretKey) {\\n              if (setValue) {\\n                value = setValue\\n              } else {\\n                return value\\n              }\\n            } else {\\n              let log: log = {\\n                object,\\n                name: props,\\n                action: 'read'\\n              }\\n              if (setValue) {\\n                log.value = setValue\\n                log.action = 'write'\\n              }\\n              that.tracker(log)\\n              return\\n            }\\n          }\\n        },\\n        set () { return },\\n        enumerable: true,\\n        configurable: false\\n      })\\n      freeze(object, true)\\n    }\\n\\n    return this\\n  }\\n\\n  lock () {\\n    windowOwnPropertyNames.forEach((key: string) => {\\n      let type = typeof (window[key])\\n      if (type === 'object' || type === 'function') {\\n        try {\\n          switch (key) {\\n            case 'window':\\n              break\\n            default:\\n              freeze(window[key], true)\\n              break\\n          }\\n        } catch (_e) {\\n          //\\n        }\\n      }\\n    })\\n  }\\n}\\n\\nexport {\\n  Strongbox\\n}\\n\"]}","code":"'use strict';\r\nimport { freeze } from '../freeze/index';\r\nimport { Sandbox } from '../sandbox/index';\r\nimport windowOwnPropertyNames from '../sandbox/windowOwnPropertyNames.config';\r\nconst sandbox = new Sandbox();\r\nconst randPassword = function () {\r\n    let shadowString = sandbox.shadowWindow.String;\r\n    let shadowMath = sandbox.shadowWindow.Math;\r\n    let shadowArray = sandbox.shadowWindow.Array;\r\n    return (new shadowArray(8 + shadowMath.round(shadowMath.random() * 8))).join(',').split(',').map(() => {\r\n        return shadowString['fromCharCode'](33 + shadowMath.round(shadowMath.random() * 89));\r\n    }).join('');\r\n};\r\nclass Strongbox {\r\n    constructor(insurance, log) {\r\n        this.password = randPassword();\r\n        this.tracker = (e) => {\r\n            if (typeof (this.log) === 'function') {\r\n                this.log(e);\r\n            }\r\n            else {\r\n                console.log('Event Log:', e);\r\n            }\r\n        };\r\n        let that = this;\r\n        let secretKey = this.password;\r\n        // tracker log\r\n        this.log = log;\r\n        for (let insured of insurance) {\r\n            let object = insured[0];\r\n            let props = insured[1];\r\n            let value = object[props];\r\n            Object.defineProperty(object, props, {\r\n                get() {\r\n                    that.password = secretKey = randPassword();\r\n                    return (password, setValue) => {\r\n                        if (password === secretKey) {\r\n                            if (setValue) {\r\n                                value = setValue;\r\n                            }\r\n                            else {\r\n                                return value;\r\n                            }\r\n                        }\r\n                        else {\r\n                            let log = {\r\n                                object,\r\n                                name: props,\r\n                                action: 'read'\r\n                            };\r\n                            if (setValue) {\r\n                                log.value = setValue;\r\n                                log.action = 'write';\r\n                            }\r\n                            that.tracker(log);\r\n                            return;\r\n                        }\r\n                    };\r\n                },\r\n                set() { return; },\r\n                enumerable: true,\r\n                configurable: false\r\n            });\r\n            freeze(object, true);\r\n        }\r\n        return this;\r\n    }\r\n    lock() {\r\n        windowOwnPropertyNames.forEach((key) => {\r\n            let type = typeof (window[key]);\r\n            if (type === 'object' || type === 'function') {\r\n                try {\r\n                    switch (key) {\r\n                        case 'window':\r\n                            break;\r\n                        default:\r\n                            freeze(window[key], true);\r\n                            break;\r\n                    }\r\n                }\r\n                catch (_e) {\r\n                    //\r\n                }\r\n            }\r\n        });\r\n    }\r\n}\r\nexport { Strongbox };\r\n//# sourceMappingURL=index.js.map"}
