blob: a622f2e36af2e30dc301d8cb8c062536dbd833b0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.crypto = exports.TextEncoder = void 0;
exports.setCrypto = setCrypto;
exports.setTextEncoder = setTextEncoder;
exports.subtleCrypto = void 0;
var _logger = require("../logger");
var _global$window, _global$window$crypto, _global$window2, _global$window2$crypt, _global$window3, _global$window3$crypt, _global$window4;
let crypto = (_global$window = global.window) === null || _global$window === void 0 ? void 0 : _global$window.crypto;
exports.crypto = crypto;
let subtleCrypto = (_global$window$crypto = (_global$window2 = global.window) === null || _global$window2 === void 0 ? void 0 : (_global$window2$crypt = _global$window2.crypto) === null || _global$window2$crypt === void 0 ? void 0 : _global$window2$crypt.subtle) !== null && _global$window$crypto !== void 0 ? _global$window$crypto : (_global$window3 = global.window) === null || _global$window3 === void 0 ? void 0 : (_global$window3$crypt = _global$window3.crypto) === null || _global$window3$crypt === void 0 ? void 0 : _global$window3$crypt.webkitSubtle;
exports.subtleCrypto = subtleCrypto;
let TextEncoder = (_global$window4 = global.window) === null || _global$window4 === void 0 ? void 0 : _global$window4.TextEncoder;
/* eslint-disable @typescript-eslint/no-var-requires */
exports.TextEncoder = TextEncoder;
if (!crypto) {
try {
exports.crypto = crypto = require("crypto").webcrypto;
} catch (e) {
_logger.logger.error("Failed to load webcrypto", e);
}
}
if (!subtleCrypto) {
var _crypto2;
exports.subtleCrypto = subtleCrypto = (_crypto2 = crypto) === null || _crypto2 === void 0 ? void 0 : _crypto2.subtle;
}
if (!TextEncoder) {
try {
exports.TextEncoder = TextEncoder = require("util").TextEncoder;
} catch (e) {
_logger.logger.error("Failed to load TextEncoder util", e);
}
}
/* eslint-enable @typescript-eslint/no-var-requires */
function setCrypto(_crypto) {
var _crypto$subtle;
exports.crypto = crypto = _crypto;
exports.subtleCrypto = subtleCrypto = (_crypto$subtle = _crypto.subtle) !== null && _crypto$subtle !== void 0 ? _crypto$subtle : _crypto.webkitSubtle;
}
function setTextEncoder(_TextEncoder) {
exports.TextEncoder = TextEncoder = _TextEncoder;
}
//# sourceMappingURL=crypto.js.map
|