芝麻web文件管理V1.00
编辑当前文件:/home/freeclou/optimyar/wp-content/plugins/ithemes-security-pro/dist/webauthn/utils.min.js
(globalThis.itsecWebpackJsonP=globalThis.itsecWebpackJsonP||[]).push([[1294],{40509:(e,t,r)=>{"use strict";r.r(t),r.d(t,{isAvailable:()=>d,isPlatformAuthenticatorAvailable:()=>u,preparePublicKeyCreationOptions:()=>o,preparePublicKeyCredentials:()=>l,preparePublicKeyRequestOptions:()=>c,registerCredential:()=>p,verifyCredential:()=>w});var n=r(87514),a=r.n(n);function i(e){return window.btoa(String.fromCharCode(...e)).replace(/\+/g,"-").replace(/\//g,"_")}function s(e){return Uint8Array.from(function(e){const t=(e=e.replace(/-/g,"+").replace(/_/g,"/")).length%4;if(t){if(1===t)throw new Error("InvalidLengthError: Input base64url string is the wrong length to determine padding");e+=new Array(5-t).join("=")}return window.atob(e)}(e),(e=>e.charCodeAt(0)))}function o(e){const t={challenge:s(e.challenge),rp:e.rp,user:{...e.user,id:s(e.user.id)},pubKeyCredParams:e.pubKeyCredParams};return void 0!==e.excludeCredentials&&(t.excludeCredentials=e.excludeCredentials.map((e=>({...e,id:s(e.id)})))),e.authenticatorSelection&&(t.authenticatorSelection=e.authenticatorSelection),e.attestation&&(t.attestation=e.attestation),t}function c(e){const t={challenge:s(e.challenge)};return void 0!==e.rpId&&(t.rpId=e.rpId),void 0!==e.allowCredentials&&(t.allowCredentials=e.allowCredentials.map((e=>({...e,id:s(e.id)})))),e.userVerification&&(t.userVerification=e.userVerification),t}function l(e){const t={id:e.id,type:e.type,rawId:i(new Uint8Array(e.rawId)),response:{clientDataJSON:i(new Uint8Array(e.response.clientDataJSON))}};return void 0!==e.response.attestationObject&&(t.response.attestationObject=i(new Uint8Array(e.response.attestationObject))),void 0!==e.response.authenticatorData&&(t.response.authenticatorData=i(new Uint8Array(e.response.authenticatorData))),void 0!==e.response.signature&&(t.response.signature=i(new Uint8Array(e.response.signature))),void 0!==e.response.userHandle&&(t.response.userHandle=i(new Uint8Array(e.response.userHandle))),e.response.getTransports&&(t.response.transports=e.response.getTransports()),t}function d(){return window.navigator.credentials&&window.PublicKeyCredential}function u(){return d()?window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():Promise.resolve(!1)}async function p({label:e,authenticatorSelection:t,email:r,captcha:n}){const i=await a()({path:"/ithemes-security/rpc/webauthn/register-credential",method:"POST",data:{authenticatorSelection:t,email:r,captcha:n}}),s=o(i),c=await window.navigator.credentials.create({publicKey:s});if(!(c.response instanceof window.AuthenticatorAttestationResponse))throw new Error("Invalid response format.");const d=i._links?.["ithemes-security:webauthn-create-credential"]?.[0]?.href,u=l(c);return await a()({url:d,method:"POST",data:{credential:u,label:e,email:r}})}async function w(e){const t=await a()({path:"/ithemes-security/rpc/webauthn/verify-credential",method:"POST",data:{user:e},credentials:"omit"}),r=c(t),n=await window.navigator.credentials.get({publicKey:r});if(!(n.response instanceof window.AuthenticatorAssertionResponse))throw new Error("Invalid response format.");const i=t._links?.["ithemes-security:webauthn-verify-credential"]?.[0]?.href,s=l(n);return await a()({url:i,method:"POST",data:{credential:s,user:e},credentials:"omit"})}r.p=window.itsecWebpackPublicPath},87514:e=>{e.exports=function(){return this.wp.apiFetch}()}},e=>{var t=(40509,e(e.s=40509));((window.itsec=window.itsec||{}).webauthn=window.itsec.webauthn||{}).utils=t}]);