Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4821.js (118.4 MB)
77 lines
2.5 KiB
TypeScript
77 lines
2.5 KiB
TypeScript
// Module ID: 7052
|
|
// Function ID: 7053
|
|
// Name: MFAUtils
|
|
// Dependencies: [17, 1608, 7053, 1230, 2]
|
|
// Exports: captureWebAuthnException, encodeTotpSecret, encodeTotpSecretAsUrl, generateTotpSecret
|
|
|
|
// Module 7052 (MFAUtils)
|
|
import _mod17 from "module_17" /* 17 */;
|
|
import SentryUtilsDefault from "SentryUtils" /* 1230 */;
|
|
import MetaQuestUtils from "MetaQuestUtils" /* 1608 */;
|
|
import encodeDefault from "encode" /* 7053 */;
|
|
import size from "module_2" /* 2 */;
|
|
|
|
let _crypto;
|
|
if (window != null) {
|
|
_crypto = window.crypto;
|
|
}
|
|
if (_crypto == null) {
|
|
let msCrypto;
|
|
if (window != null) {
|
|
msCrypto = window.msCrypto;
|
|
}
|
|
_crypto = msCrypto;
|
|
}
|
|
let tmp5 = null != _crypto;
|
|
if (tmp5) {
|
|
tmp5 = "getRandomValues" in _crypto;
|
|
}
|
|
if (tmp5) {
|
|
tmp5 = tmp4;
|
|
}
|
|
let tmp6 = null != _mod17.NativeModules.DCDSecurityKeyManager;
|
|
if (tmp6) {
|
|
const _module = MetaQuestUtils;
|
|
tmp6 = !_module.isMetaQuest();
|
|
}
|
|
function encodeTotpSecret(totpSecret) {
|
|
return totpSecret.replace(/[\s._-]+/g, "").toUpperCase();
|
|
}
|
|
const result = size.fileFinishedImporting("utils/MFAUtils.tsx");
|
|
|
|
export const hasCrypto = tmp5;
|
|
export const hasWebAuthn = tmp6;
|
|
export const generateTotpSecret = function generateTotpSecret() {
|
|
const uint8Array = new Uint8Array(20);
|
|
const randomValues = _crypto.getRandomValues(uint8Array);
|
|
const encoder = encodeDefault;
|
|
const str = encoder.encode(randomValues);
|
|
const str2 = encoder.encode(randomValues).toString("utf8");
|
|
const str3 = encoder.encode(randomValues).toString("utf8").replace(/=/g, "");
|
|
const str4 = encoder.encode(randomValues).toString("utf8").replace(/=/g, "").toLowerCase();
|
|
return encoder.encode(randomValues).toString("utf8").replace(/=/g, "").toLowerCase().replace(/(\w{4})/g, "$1 ").trim();
|
|
};
|
|
export { encodeTotpSecret };
|
|
export const encodeTotpSecretAsUrl = function encodeTotpSecretAsUrl(arg0, str) {
|
|
str = arg2;
|
|
if (arg2 === undefined) {
|
|
str = "Discord";
|
|
}
|
|
const encodeURIResult = encodeURI(str);
|
|
const encodeURIResult1 = encodeURI(arg0);
|
|
const formatted = str.replace(/[\s._-]+/g, "").toUpperCase();
|
|
return "otpauth://totp/" + encodeURIResult + ":" + encodeURIResult1 + "?secret=" + formatted + "&issuer=" + encodeURIComponent(str);
|
|
};
|
|
export const captureWebAuthnException = function captureWebAuthnException(error, tags) {
|
|
const obj2 = {};
|
|
const merged = Object.assign(tags);
|
|
tags = undefined;
|
|
if (tags != null) {
|
|
tags = tags.tags;
|
|
}
|
|
const obj3 = {};
|
|
const merged1 = Object.assign(tags);
|
|
obj3.app_context = "webauthn";
|
|
obj2.tags = obj3;
|
|
SentryUtilsDefault.captureException(error, obj2);
|
|
};
|