Files
Investidor-V2/outputs/investmoz-navegacao-QA-20261016/DOC01/rollback/public/build/assets/react-mlFDtEmO.js
T
nala cef6e201c7
tests / ci (push) Canceled after 0s
versao nrgocios 2
2026-10-16 20:11:05 +02:00

1 line
14 KiB
JavaScript

import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{n as t}from"./jsx-runtime-BpzPEenQ.js";import{t as n}from"./createLucideIcon-oMeAlXbs.js";var r=n(`KeyRound`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),i=e(t(),1);function a(e){let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function o(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,`=`),i=atob(r),a=new ArrayBuffer(i.length),o=new Uint8Array(a);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return a}function s(){return c.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential==`function`)}var c={stubThis:e=>e};function l(e){let{id:t}=e;return{...e,id:o(t),transports:e.transports}}function u(e){return e===`localhost`||/^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(e)}var d=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=r??n.name,this.code=t}};function f({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new d({message:`Registration ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`ConstraintError`){if(n.authenticatorSelection?.requireResidentKey===!0)return new d({message:`Discoverable credentials were required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT`,cause:e});if(t.mediation===`conditional`&&n.authenticatorSelection?.userVerification===`required`)return new d({message:`User verification was required during automatic registration but it could not be performed`,code:`ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE`,cause:e});if(n.authenticatorSelection?.userVerification===`required`)return new d({message:`User verification was required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT`,cause:e})}else if(e.name===`InvalidStateError`)return new d({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new d({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`NotSupportedError`)return n.pubKeyCredParams.filter(e=>e.type===`public-key`).length===0?new d({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new d({message:`No available authenticator supported any of the specified pubKeyCredParams algorithms`,code:`ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!u(t))return new d({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new d({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`TypeError`){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new d({message:`User ID was not between 1 and 64 characters`,code:`ERROR_INVALID_USER_ID_LENGTH`,cause:e})}else if(e.name===`UnknownError`)return new d({message:`The authenticator was unable to process the specified options, or could not create a new credential`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}var p=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let e=Error(`Cancelling existing WebAuthn API call for new one`);e.name=`AbortError`,this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(`Manually cancelling existing WebAuthn API call`);e.name=`AbortError`,this.controller.abort(e),this.controller=void 0}}},m=[`cross-platform`,`platform`];function h(e){if(e&&!(m.indexOf(e)<0))return e}async function g(e){!e.optionsJSON&&e.challenge&&(console.warn(`startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useAutoRegister:n=!1}=e;if(!s())throw Error(`WebAuthn is not supported in this browser`);let r={...t,challenge:o(t.challenge),user:{...t.user,id:o(t.user.id)},excludeCredentials:t.excludeCredentials?.map(l)},i={};n&&(i.mediation=`conditional`),i.publicKey=r,i.signal=p.createNewAbortSignal();let c;try{c=await navigator.credentials.create(i)}catch(e){throw f({error:e,options:i})}if(!c)throw Error(`Registration was not completed`);let{id:u,rawId:d,response:m,type:g}=c,v;typeof m.getTransports==`function`&&(v=m.getTransports());let y;if(typeof m.getPublicKeyAlgorithm==`function`)try{y=m.getPublicKeyAlgorithm()}catch(e){_(`getPublicKeyAlgorithm()`,e)}let b;if(typeof m.getPublicKey==`function`)try{let e=m.getPublicKey();e!==null&&(b=a(e))}catch(e){_(`getPublicKey()`,e)}let x;if(typeof m.getAuthenticatorData==`function`)try{x=a(m.getAuthenticatorData())}catch(e){_(`getAuthenticatorData()`,e)}return{id:u,rawId:a(d),response:{attestationObject:a(m.attestationObject),clientDataJSON:a(m.clientDataJSON),transports:v,publicKeyAlgorithm:y,publicKey:b,authenticatorData:x},type:g,clientExtensionResults:c.getClientExtensionResults(),authenticatorAttachment:h(c.authenticatorAttachment)}}function _(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.\n`,t)}function v(){if(!s())return y.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?y.stubThis(new Promise(e=>e(!1))):y.stubThis(e.isConditionalMediationAvailable())}var y={stubThis:e=>e};function b({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new d({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new d({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!u(t))return new d({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new d({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`UnknownError`)return new d({message:`The authenticator was unable to process the specified options, or could not create a new assertion signature`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}async function x(e){!e.optionsJSON&&e.challenge&&(console.warn(`startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!s())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(l));let c={...t,challenge:o(t.challenge),allowCredentials:i},u={};if(n){if(!await v())throw Error(`Browser does not support WebAuthn autofill`);if(document.querySelectorAll(`input[autocomplete$='webauthn']`).length<1&&r)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');u.mediation=`conditional`,c.allowCredentials=[]}u.publicKey=c,u.signal=p.createNewAbortSignal();let d;try{d=await navigator.credentials.get(u)}catch(e){throw b({error:e,options:u})}if(!d)throw Error(`Authentication was not completed`);let{id:f,rawId:m,response:g,type:_}=d,y;return g.userHandle&&(y=a(g.userHandle)),{id:f,rawId:a(m),response:{authenticatorData:a(g.authenticatorData),clientDataJSON:a(g.clientDataJSON),signature:a(g.signature),userHandle:y},type:_,clientExtensionResults:d.getClientExtensionResults(),authenticatorAttachment:h(d.authenticatorAttachment)}}var S=class extends Error{constructor(e){super(e),this.name=`PasskeyError`}},C=class extends S{constructor(){super(`Passkeys are not supported in this browser.`),this.name=`NotSupportedError`}},w=class extends S{constructor(){super(`The passkey operation was cancelled.`),this.name=`UserCancelledError`}},T=class extends S{constructor(){super(`This device is already registered as a passkey.`),this.name=`PasskeyExistsError`}},E=class extends S{constructor(e){super(`Passkeys can't be used on ${e??`this domain`}. For local development, use localhost.`),this.name=`InvalidDomainError`}},D=e=>{if(e instanceof S)return e;if(!(e instanceof Error))return new S(`An unknown error occurred.`);if(O(e))return new E(A());switch(e.name){case`NotAllowedError`:return new w;case`InvalidStateError`:return new T;case`NotSupportedError`:return new C;default:return new S(e.message)}},O=e=>k(e)===`ERROR_INVALID_DOMAIN`,k=e=>`code`in e&&typeof e.code==`string`?e.code:void 0,A=()=>typeof globalThis.location?.hostname==`string`&&globalThis.location.hostname.length>0?globalThis.location.hostname:void 0,j={},M=e=>{j={...j,...e,fetch:{...j.fetch,...e.fetch,headers:{...j.fetch?.headers,...e.fetch?.headers}}}},N=()=>typeof document>`u`?null:P()||F(),P=()=>{let e=document.querySelector(`meta[name="csrf-token"]`);if(!e)return null;let t=e.getAttribute(`content`);return t?{header:`X-CSRF-TOKEN`,value:t}:null},F=()=>{let e=document.cookie.split(`; `).find(e=>e.startsWith(`XSRF-TOKEN=`));if(!e)return null;let t=e.slice(11);return t?{header:`X-XSRF-TOKEN`,value:decodeURIComponent(t)}:null},I=async e=>{let t=await fetch(e,{method:`GET`,headers:{Accept:`application/json`,...j.fetch?.headers},credentials:j.fetch?.credentials??`same-origin`});return t.ok||await R(t),t.json()},L=async(e,t)=>{let n=N(),r={"Content-Type":`application/json`,Accept:`application/json`,...j.fetch?.headers};n&&(r[n.header]=n.value);let i=await fetch(e,{method:`POST`,headers:r,credentials:j.fetch?.credentials??`same-origin`,body:JSON.stringify(t)});return i.ok||await R(i),i.json()},R=async e=>{let t=`Request failed with status ${e.status}`;try{let n=await e.json();n&&typeof n==`object`&&`message`in n&&typeof n.message==`string`&&(t=n.message)}catch{}throw Error(t)},z={registerOptions:`/user/passkeys/options`,registerStore:`/user/passkeys`,verifyOptions:`/passkeys/login/options`,verifySubmit:`/passkeys/login`},B={configure(e){M(e)},isSupported(){return s()},async isAutofillSupported(){return v()},async register(e){if(!this.isSupported())throw new C;this.cancel();try{let t=V(e,{options:z.registerOptions,submit:z.registerStore}),{options:n}=await I(t.optionsRoute),r=await g({optionsJSON:n}),i={name:e.name,credential:r};return await L(t.submitRoute,i)}catch(e){throw D(e)}},async verify(e={}){if(!this.isSupported())throw new C;this.cancel();try{let t=V(e,{options:z.verifyOptions,submit:z.verifySubmit}),{options:n}=await I(t.optionsRoute),r={credential:await x({optionsJSON:n})};return await L(t.submitRoute,r)}catch(e){throw D(e)}},async autofill(e={}){if(this.isSupported()&&await this.isAutofillSupported())try{let t=V(e,{options:z.verifyOptions,submit:z.verifySubmit}),{options:n}=await I(t.optionsRoute),r={credential:await x({optionsJSON:n,useBrowserAutofill:!0})};return await L(t.submitRoute,r)}catch(e){if(e instanceof Error&&[`AbortError`,`NotAllowedError`].includes(e.name))return;throw D(e)}},cancel(){p.cancelCeremony()}},V=(e,t)=>({optionsRoute:e.routes?.options??t.options,submitRoute:e.routes?.submit??t.submit}),H=()=>{},U=()=>H,W=()=>B.isSupported(),G=()=>!1,K=({autofill:e=!1,routes:t,onSuccess:n,onError:r}={})=>{let[a,o]=(0,i.useState)(!1),[s,c]=(0,i.useState)(null),[l,u]=(0,i.useState)(null),d=(0,i.useSyncExternalStore)(U,W,G),f=(0,i.useRef)(n),p=(0,i.useRef)(r),m=(0,i.useRef)(t);(0,i.useEffect)(()=>{f.current=n,p.current=r,m.current=t});let h=()=>{c(null),u(null)},g=e=>{let t=D(e);c(t.message),u(t),p.current?.(t)},_=(0,i.useCallback)(async()=>{o(!0),h();try{let e=await B.verify({routes:m.current});f.current?.(e)}catch(e){g(e)}finally{o(!1)}},[]);return(0,i.useEffect)(()=>{if(!e)return;let t=!1;return B.cancel(),(async()=>{let e=await B.isAutofillSupported();if(!t&&e){o(!0),h();try{let e=await B.autofill({routes:m.current});if(t||!e)return;f.current?.(e)}catch(e){if(t)return;g(e)}finally{o(!1)}}})(),()=>{t=!0,B.cancel()}},[e]),{verify:_,isLoading:a,error:s,errorInstance:l,isSupported:d}},q=({routes:e,onSuccess:t,onError:n}={})=>{let[r,a]=(0,i.useState)(!1),[o,s]=(0,i.useState)(null),[c,l]=(0,i.useState)(null),u=(0,i.useSyncExternalStore)(U,W,G),d=(0,i.useRef)(t),f=(0,i.useRef)(n),p=(0,i.useRef)(e);return(0,i.useEffect)(()=>{d.current=t,f.current=n,p.current=e}),{register:(0,i.useCallback)(async e=>{a(!0),s(null),l(null);try{await B.register({name:e,routes:p.current}),d.current?.()}catch(e){let t=D(e);s(t.message),l(t),f.current?.(t)}finally{a(!1)}},[]),isLoading:r,error:o,errorInstance:c,isSupported:u}};export{q as n,r,K as t};