decord/source/utils/MFAUtils.tsx

73 lines
2.4 KiB
TypeScript
Raw Normal View History

2026-08-05 07:35:12 +00:00
// Module ID: 8261
// Function ID: 8262
2026-07-29 08:29:29 +00:00
// Name: _crypto
2026-08-05 07:35:12 +00:00
// Dependencies: [17, 1577, 8262, 1208, 2]
2026-07-29 08:29:29 +00:00
// Exports: captureWebAuthnException, encodeTotpSecret, encodeTotpSecretAsUrl, generateTotpSecret
2026-07-20 16:05:17 +00:00
2026-08-05 07:35:12 +00:00
// Module 8261 (_crypto)
2026-07-20 16:05:17 +00:00
let _crypto;
2026-07-29 08:29:29 +00:00
if (window != null) {
2026-07-20 16:05:17 +00:00
_crypto = window.crypto;
}
2026-07-29 08:29:29 +00:00
if (_crypto == null) {
2026-07-20 16:05:17 +00:00
let msCrypto;
2026-07-29 08:29:29 +00:00
if (window != null) {
2026-07-20 16:05:17 +00:00
msCrypto = window.msCrypto;
}
_crypto = msCrypto;
}
let tmp5 = null != _crypto;
if (tmp5) {
tmp5 = "getRandomValues" in _crypto;
}
if (tmp5) {
tmp5 = tmp4;
}
2026-07-23 10:11:24 +00:00
let tmp6 = null != require("get ActivityIndicator").NativeModules.DCDSecurityKeyManager;
2026-07-20 16:05:17 +00:00
if (tmp6) {
2026-07-23 10:11:24 +00:00
const _module = require("isMetaQuest");
2026-07-20 16:05:17 +00:00
tmp6 = !_module.isMetaQuest();
}
2026-07-29 08:29:29 +00:00
function encodeTotpSecret(totpSecret) {
return totpSecret.replace(/[\s._-]+/g, "").toUpperCase();
}
2026-07-23 10:11:24 +00:00
const result = require("encode").fileFinishedImporting("utils/MFAUtils.tsx");
2026-07-20 16:05:17 +00:00
export const hasCrypto = tmp5;
export const hasWebAuthn = tmp6;
export const generateTotpSecret = function generateTotpSecret() {
const uint8Array = new Uint8Array(20);
const randomValues = _crypto.getRandomValues(uint8Array);
2026-08-05 07:35:12 +00:00
const obj = importDefault(8262);
const str = importDefault(8262).encode(randomValues);
const str2 = importDefault(8262).encode(randomValues).toString("utf8");
const str3 = importDefault(8262).encode(randomValues).toString("utf8").replace(/=/g, "");
const str4 = importDefault(8262).encode(randomValues).toString("utf8").replace(/=/g, "").toLowerCase();
return importDefault(8262).encode(randomValues).toString("utf8").replace(/=/g, "").toLowerCase().replace(/(\w{4})/g, "$1 ").trim();
2026-07-20 16:05:17 +00:00
};
export { encodeTotpSecret };
2026-07-29 08:29:29 +00:00
export const encodeTotpSecretAsUrl = function encodeTotpSecretAsUrl(arg0, str) {
str = arg2;
2026-07-20 16:05:17 +00:00
if (arg2 === undefined) {
str = "Discord";
}
const encodeURIResult = encodeURI(str);
const encodeURIResult1 = encodeURI(arg0);
2026-07-29 08:29:29 +00:00
const formatted = str.replace(/[\s._-]+/g, "").toUpperCase();
return "otpauth://totp/" + encodeURIResult + ":" + encodeURIResult1 + "?secret=" + formatted + "&issuer=" + encodeURIComponent(str);
2026-07-20 16:05:17 +00:00
};
2026-07-29 08:29:29 +00:00
export const captureWebAuthnException = function captureWebAuthnException(closure_1, tags) {
let obj = importDefault(1208);
2026-07-20 16:05:17 +00:00
obj = {};
const merged = Object.assign(tags);
tags = undefined;
2026-07-29 08:29:29 +00:00
if (tags != null) {
2026-07-20 16:05:17 +00:00
tags = tags.tags;
}
2026-07-29 08:29:29 +00:00
obj = {};
2026-07-20 16:05:17 +00:00
const merged1 = Object.assign(tags);
2026-07-29 08:29:29 +00:00
obj.app_context = "webauthn";
obj.tags = obj;
obj.captureException(closure_1, obj);
2026-07-20 16:05:17 +00:00
};