1
|
{"version":3,"file":"crypto.js","names":["_logger","require","_global$window","_global$window$crypto","_global$window2","_global$window2$crypt","_global$window3","_global$window3$crypt","_global$window4","crypto","global","window","exports","subtleCrypto","subtle","webkitSubtle","TextEncoder","webcrypto","e","logger","error","_crypto2","setCrypto","_crypto","_crypto$subtle","setTextEncoder","_TextEncoder"],"sources":["../../src/crypto/crypto.ts"],"sourcesContent":["/*\nCopyright 2022 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { logger } from \"../logger\";\n\nexport let crypto = global.window?.crypto;\nexport let subtleCrypto = global.window?.crypto?.subtle ?? global.window?.crypto?.webkitSubtle;\nexport let TextEncoder = global.window?.TextEncoder;\n\n/* eslint-disable @typescript-eslint/no-var-requires */\nif (!crypto) {\n try {\n crypto = require(\"crypto\").webcrypto;\n } catch (e) {\n logger.error(\"Failed to load webcrypto\", e);\n }\n}\nif (!subtleCrypto) {\n subtleCrypto = crypto?.subtle;\n}\nif (!TextEncoder) {\n try {\n TextEncoder = require(\"util\").TextEncoder;\n } catch (e) {\n logger.error(\"Failed to load TextEncoder util\", e);\n }\n}\n/* eslint-enable @typescript-eslint/no-var-requires */\n\nexport function setCrypto(_crypto: Crypto): void {\n crypto = _crypto;\n subtleCrypto = _crypto.subtle ?? _crypto.webkitSubtle;\n}\n\nexport function setTextEncoder(_TextEncoder: typeof TextEncoder): void {\n TextEncoder = _TextEncoder;\n}\n"],"mappings":";;;;;;;;;AAgBA,IAAAA,OAAA,GAAAC,OAAA;AAAmC,IAAAC,cAAA,EAAAC,qBAAA,EAAAC,eAAA,EAAAC,qBAAA,EAA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