// Metro module 9197 (f9198). import { NativeModules } from "react-native"; import Logger from "../../debug/Logger"; import { startRegisterWebAuthnCredential } from "../WebAuthnActionCreators"; import * as _PlatformUtils from "../../../utils/PlatformUtils"; import { IgnorableWebAuthnError } from "../WebAuthnTypes"; import { captureWebAuthnException } from "../../../utils/MFAUtils"; import { isMetaQuest } from "../../device/MetaQuestUtils.android"; function $mk82101($env) { return (a0) => { const r3 = $env[0]; if (r3 === void 0) { throw a0; } const r7 = $env.$parent; const r6 = r7[0]; const r8 = r7[1]; r3(r6(r8[4]).intl.string(r6(r8[4]).t.xSCvBf)); throw a0; }; } function $mk82102($env) { return () => (0, $env[1])(false); } function $mk82103($env) { return (a0) => { const r5 = JSON.parse(a0); r5.publicKey.authenticatorSelection.residentKey = "required"; return (0, $env[0])(JSON.stringify(r5)); }; } let c6039_4; let $mk82100 = function() { return function promptForRegisterCredential() { return env6039[5].apply(this, arguments); }; }; let env6039 = {}; env6039[5] = function _promptForRegisterCredential() { const r8 = async function(c26391_0) { let r10 = c26391_0; if (r10 === void 0) { r10 = NativeModules.DCDSecurityKeyManager.register; } let c30060_0 = r10; await void 0; let c30060_1 = await startRegisterWebAuthnCredential(); let c30060_2 = c30060_1.ticket; let c30060_3 = c30060_1.challenge; const value = {}; value.ticket = c30060_2; value.credential = await (0, c30060_0)(c30060_3); return value; }; env6039[5] = r8; return r8.apply(this, arguments); }; c6039_4 = new Logger("WebAuthnUtils"); const r27 = {}; Object.defineProperty(r27, "hasAndroidPasskeySupport", { get: function() { return _PlatformUtils.isAndroid() && NativeModules.DCDSecurityKeyManager?.registerPasskey != null; }, set: void 0, enumerable: true, configurable: true }); Object.defineProperty(r27, "shouldDisplayAndroidFidoSelector", { get: function() { return _PlatformUtils.isAndroid() && !isMetaQuest(); }, set: void 0, enumerable: true, configurable: true }); r27.getPasskeyAuthenticator = function getPasskeyAuthenticator() { let authenticate = NativeModules.DCDSecurityKeyManager.authenticate; if (_PlatformUtils.isAndroid() && NativeModules.DCDSecurityKeyManager?.authenticatePasskey != null) { authenticate = NativeModules.DCDSecurityKeyManager.authenticatePasskey; } return async function(...c26392_0) { let r63; let c26392_3; let c26392_4 = 0; let c30061_0, c30061_1; try { c30061_0 = c26392_0; await void 0; c26392_4 = 1; r63 = await authenticate.apply(void 0, [...c30061_0]); c26392_4 = 0; } catch ($e) { const r30 = $e; let r7 = r30; c26392_3 = r30; if (c26392_4 !== 0) { while (true) { try { const r82 = c26392_3; c26392_4 = 0; c30061_1 = r82; const code = c30061_1.code; if (code !== "AbortError" && code !== "NotAllowedError") { captureWebAuthnException(c30061_1); c6039_4.error(c30061_1); throw c30061_1; } c6039_4.warn(c30061_1); throw new IgnorableWebAuthnError(); } catch (r79) { r7 = r79; c26392_3 = r79; if (c26392_4 === 0) { break; } } } } throw r7; } return r63; }; }; r27.registerAndroidCredentialManagerPasskey = function registerAndroidCredentialManagerPasskey(a0) { let env17064; let env17065; const registerPasskey2 = NativeModules.DCDSecurityKeyManager.registerPasskey; const r4 = env17064 = {}; env17064[0] = registerPasskey2; const r11 = env17065 = { $parent: env6039 }; env17065[0] = void 0; env17065[1] = void 0; const { onRegisterSuccess, setError } = a0; env17065[0] = setError; const setRegistering = a0.setRegistering; env17065[1] = setRegistering; if (setError !== void 0) { setError(""); } const r14 = $mk82103(r4); setRegistering(true); return $mk82100()(r14).then(onRegisterSuccess).catch($mk82101(r11)).finally($mk82102(r11)); }; r27.registerAndroidDevicePasskey = function registerAndroidDevicePasskey(a0) { let env17067; let env17068; const register = NativeModules.DCDSecurityKeyManager.register; const r4 = env17067 = {}; env17067[0] = register; const r11 = env17068 = { $parent: env6039 }; env17068[0] = void 0; env17068[1] = void 0; const { onRegisterSuccess, setError } = a0; env17068[0] = setError; const setRegistering = a0.setRegistering; env17068[1] = setRegistering; if (setError !== void 0) { setError(""); } const r14 = $mk82103(r4); setRegistering(true); return $mk82100()(r14).then(onRegisterSuccess).catch($mk82101(r11)).finally($mk82102(r11)); }; r27.registerPasskey = function registerPasskey(a0) { let r29; let env17069; const isAndroid = _PlatformUtils.isAndroid(); const DCDSecurityKeyManager = NativeModules.DCDSecurityKeyManager; const r16 = env17069 = { $parent: env6039 }; if (isAndroid) { let env17070; const registerPasskey2 = DCDSecurityKeyManager.registerPasskey; const r31 = env17070 = {}; env17070[0] = registerPasskey2; env17069[0] = void 0; env17069[1] = void 0; const { onRegisterSuccess: onRegisterSuccess2, setError: setError2 } = a0; env17069[0] = setError2; const setRegistering2 = a0.setRegistering; env17069[1] = setRegistering2; if (setError2 !== void 0) { setError2(""); } const r37 = $mk82103(r31); setRegistering2(true); r29 = $mk82100()(r37).then(onRegisterSuccess2).catch($mk82101(r16)).finally($mk82102(r16)); } else { const register = DCDSecurityKeyManager.register; env17069[0] = void 0; env17069[1] = void 0; const { onRegisterSuccess, setError } = a0; env17069[0] = setError; const setRegistering = a0.setRegistering; env17069[1] = setRegistering; if (setError !== void 0) { setError(""); } setRegistering(true); r29 = $mk82100()(register).then(onRegisterSuccess).catch($mk82101(r16)).finally($mk82102(r16)); } return r29; }; r27.registerSecurityKey = function registerSecurityKey(a0, r4 = NativeModules.DCDSecurityKeyManager.register) { let env17063; const r10 = env17063 = { $parent: env6039 }; env17063[0] = void 0; env17063[1] = void 0; const { onRegisterSuccess, setError } = a0; env17063[0] = setError; const setRegistering = a0.setRegistering; env17063[1] = setRegistering; if (setError !== void 0) { setError(""); } setRegistering(true); return $mk82100()(r4).then(onRegisterSuccess).catch($mk82101(r10)).finally($mk82102(r10)); }; export default r27;