Files
discord-decomp/sources/utils/MFAUtils.tsx
T
2026-07-27 16:20:00 +03:00

70 lines
3.5 KiB
TypeScript

/* Metro module 8980; source: utils/MFAUtils.tsx; dependencies: [27, 1581, 8981, 1216, 2] */
function _fun69993(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#69993, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9165:6, offset: 0x01ceaa90, size: 301 bytes, params: 8, frame: 22
var r4;
var value6;
const closure = function(a0) {
return a0.replace(RegExp('[\\s._-]+', 'g'), '').toUpperCase();
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const window = global.window;
let value = undefined;
const r10 = (window == null ? value : window.crypto) ?? (global.window == null ? value : global.window.msCrypto);
const r5 = r10 != null && 'getRandomValues' in r10 && 'Uint8Array' in global.window;
const NativeModules = (require(27) /* metro dependency 27 */).NativeModules;
const DCDSecurityKeyManager = NativeModules.DCDSecurityKeyManager;
const value5 = DCDSecurityKeyManager != null;
if (value5) {
value6 = require(1581) /* metro dependency 1581: MetaQuestUtilsAndroid */;
r4 = !value6.isMetaQuest();
} else {
r4 = value5;
}
(require(2) /* metro dependency 2 */).fileFinishedImporting('utils/MFAUtils.tsx');
exports.hasCrypto = r5;
exports.hasWebAuthn = r4;
exports.generateTotpSecret = generateTotpSecret;
exports.encodeTotpSecret = closure;
exports.encodeTotpSecretAsUrl = function(a0, a1) {
var r3;
var value = a2;
r3 = value !== undefined ? value : 'Discord';
return 'otpauth://totp/' + (0, global.encodeURI)(r3) + ':' + (0,
global.encodeURI)(a0) + '?secret=' + encodeTotpSecret(a1) + '&issuer=' + (0, global.encodeURIComponent)(r3);
};
exports.captureWebAuthnException = captureWebAuthnException;
return value;
}
function generateTotpSecret() { // fn#69995, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9165:508, offset: 0x01ceabe9, size: 180 bytes, params: 1, frame: 15
const binding = env0_2;
const getRandomValues = binding.getRandomValues;
const Uint8Array = global.Uint8Array;
const value2 = Object.create(Uint8Array.prototype, {constructor: {value: Uint8Array}});
const uint8Array = new Uint8Array(20);
const value4 = Reflect.apply(getRandomValues, binding, [uint8Array instanceof Object ? uint8Array : value2]);
let value = importDefault(8981) /* metro dependency 8981 */;
value = value.encode(value4);
value = value.toString('utf8');
value = value.replace(RegExp('=', 'g'), '');
value = value.toLowerCase();
value = value.replace(RegExp('(\\w{4})', 'g'), '$1 ');
return value.trim();
}
function captureWebAuthnException(a0, a1) { // fn#69997, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9165:1012, offset: 0x01cead0b, size: 108 bytes, params: 3, frame: 17
const value = undefined;
const defaultImport = importDefault(1216) /* metro dependency 1216: SentryUtilsNative */;
const captureException = defaultImport.captureException;
const object3 = {};
copyDataProperties(object3, a1, undefined);
const object4 = {};
const value2 = a1 == null;
copyDataProperties(object4, value2 ? value : a1.tags, value2);
object4['app_context'] = 'webauthn';
object3['tags'] = object4;
Reflect.apply(captureException, defaultImport, [a0, object3]);
return value;
}