File: /home/teamadsc/public_html/wp-content/plugins/wp-defender/assets/js/biometric-login.js
function _createForOfIteratorHelper(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||n&&e&&"number"==typeof e.length){r&&(e=r);var t=0,a=function(){};return{s:a,n:function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,f=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){f=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(f)throw i}}}}function _unsupportedIterableToArray(e,n){if(e){if("string"==typeof e)return _arrayLikeToArray(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,n):void 0}}function _arrayLikeToArray(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=Array(n);r<n;r++)t[r]=e[r];return t}!function(e){var n=!1,r=null,t=e("#login"),a=t.find("#wpdef-2fa-form-"+webauthn.provider_slug);function i(r,t){r.preventDefault(),!0!==n&&!1!==wpdefCheckBrowserSupportForWebauthn()&&(o(),e.ajax({url:webauthn.admin_url,type:"POST",data:{action:"defender_webauthn_get_option",username:webauthn.username,type:t,_def_nonce:webauthn.nonce},success:function(e){if(!1===e.success||void 0===e.data.challenge){return d("undefined"!==e.data.message&&"undefined"!==e.data.code&&0<e.data.code?e.data.message:webauthn.i18n.login_failed),void f()}var n=e.data;if(n.challenge=Uint8Array.from(window.atob(wpdefBase64Url2Base64(n.challenge)),function(e){return e.charCodeAt(0)}),n.allowCredentials){var r,i=_createForOfIteratorHelper(n.allowCredentials);try{for(i.s();!(r=i.n()).done;){var o=r.value;"cross-platform"===t?o.transports=["usb","nfc","ble"]:"platform"===t&&(o.transports=["internal"]),o.id=Uint8Array.from(window.atob(wpdefBase64Url2Base64(o.id)),function(e){return e.charCodeAt(0)})}}catch(e){i.e(e)}finally{i.f()}}var c=n.clientID;delete n.clientID,navigator.credentials.get({publicKey:n}).then(function(e){return{id:e.id,type:e.type,rawId:wpdefArrayToBase64String(new Uint8Array(e.rawId)),response:{authenticatorData:wpdefArrayToBase64String(new Uint8Array(e.response.authenticatorData)),clientDataJSON:wpdefArrayToBase64String(new Uint8Array(e.response.clientDataJSON)),signature:wpdefArrayToBase64String(new Uint8Array(e.response.signature)),userHandle:e.response.userHandle?wpdefArrayToBase64String(new Uint8Array(e.response.userHandle)):null}}}).then(JSON.stringify).then(function(e){a.find("#wpdef-2fa-biometric-data").val(window.btoa(e)),a.find("#wpdef-2fa-biometric-username").val(webauthn.username),a.find("#wpdef-2fa-biometric-client-id").val(c),a.find("#wpdef-2fa-biometric-nonce").val(webauthn.nonce),a.find("#wpdef-2fa-biometric-submit-btn").trigger("click")}).catch(function(){d(webauthn.i18n.login_failed),f()})},error:function(){d(webauthn.i18n.login_failed),f()}}))}function o(){n=!0,t.find("#login_error").remove(),a.find(".welcome-screen").hide(),a.find(".webauthn-"+r).show(),a.find(".wpdef-2fa-webauthn-control").hide(),a.find(".wpdef-2fa-biometric-process-desc").show()}function f(){n=!1,a.find(".wpdef-2fa-biometric-process-desc").hide(),a.find(".wpdef-2fa-webauthn-control").show()}function d(e){var n='<div id="login_error" class="notice notice-error">'+e+"</div>";t.find("h1").after(n)}e(function(){!1===wpdefCheckBrowserSupportForWebauthn()&&(e=webauthn.i18n.client_webauthn_notice,n='<div class="wpdef-notice warning webauthn-client-notice"><span class="dashicons dashicons-info"></span><span class="wpdef-notice-message">'+e+"</span></div>",a.append(n),a.find(".wpdef-2fa-biometric-process-desc").hide());var e,n}),a.find(".option-row").on("click",function(n){i(n,r=e(this).attr("data-authType"))}),a.find("#wpdef-2fa-biometric-retry-btn").on("click",function(e){null!==r&&i(e,r)}),a.find("#wpdef-2fa-webauthn-back-btn").on("click",function(){null!==r&&(t.find("#login_error").remove(),a.find(".welcome-screen").show(),a.find(".webauthn-"+r).hide(),a.find(".wpdef-2fa-webauthn-control").hide())})}(jQuery);