PageSourceSearch

https://babki.app/build/assets/useSessionAnalytics-wiildM4L.js

js babki.app collected 2026-09-24 13:54:41 UTC 3,996 bytes, 1 lines download raw bytes

1import{r as D,C as O}from"./index-Dlm2pfU4.js";import{s as E,v as o,w as H,u as j}from"./index-CRYugZLt.js";import{r as K}from"./verisoul-web-C5xQl4sV.js";import{u as U}from"./usePostHog-C_IwsGB_.js";const M=D("Verisoul"),J=2e4,x=2e4;let V=!1;const d=o(!1),a=o(!1),g=o(!1),h=o(null),p=o(!1),S=o(!1);let k=null;const G=()=>{k===null&&(a.value||(k=setTimeout(()=>{a.value||(S.value=!0)},J)))},N=()=>{k!==null&&(clearTimeout(k),k=null)},A=()=>typeof window<"u"&&new URLSearchParams(window.location.search).has("vpntest"),y=o(!1),z=O.isNativePlatform();let C=Promise.resolve();function W(l){const s=C.then(l,l);return C=s.then(()=>{},()=>{}),s}let _=null;const I=()=>W(()=>{if(z)return M.session();if(!window.Verisoul)throw new Error("sdk_not_loaded");return window.Verisoul.session()}),b=()=>_||(_=W(async()=>{if(z)return M.reinitialize();if(window.Verisoul)return window.Verisoul.reinitialize()}).finally(()=>{_=null}),_),L=()=>z||!!window.Verisoul,P=(l,s)=>{if(V)return;V=!0,d.value=!0,a.value=!0,S.value=!0,N();const T=document.head.querySelector('meta[name="csrf-token"]')?.getAttribute("content"),f=Intl.DateTimeFormat().resolvedOptions().timeZone,u=navigator.languages?Array.from(navigator.languages):[navigator.language];let m,v;s instanceof Error?(m=s.message,v=s.name):s!==void 0&&(m=String(s)),fetch("/api/session-blocked",{method:"POST",headers:{"Content-Type":"application/json","X-CSRF-TOKEN":T||"","X-Requested-With":"XMLHttpRequest"},credentials:"same-origin",body:JSON.stringify({reason:l,timezone:f,browser_languages:u,error_message:m,error_name:v})}).catch(()=>{})};function ee(l={}){const{immediate:s=!0}=l,T=j(),f=o(!1),u=o(null),m=E(()=>T.props.auth?.user),v=async i=>{const e=document.head.querySelector('meta[name="csrf-token"]')?.getAttribute("content");try{const n=await fetch("/api/session-sync",{method:"POST",headers:{"Content-Type":"application/json","X-CSRF-TOKEN":e||"","X-Requested-With":"XMLHttpRequest"},credentials:"same-origin",body:JSON.stringify({session_id:i})});if(!n.ok)return{status:"blocked",reason:"server_error",blockReason:null,shouldReinitialize:!1};const r=await n.json();if(r.shouldReinitialize)try{await b();const t=await I();return u.value=t.session_id,v(t.session_id)}catch(t){return console.error("Verisoul reinitialize failed",t),{status:"blocked",reason:"reinitialize_failed",blockReason:null,shouldReinitialize:!1}}return r}catch{return{status:"blocked",reason:"network_error",blockReason:null,shouldReinitialize:!1}}},R=async(i=!1)=>{if(A())return g.value=!0,h.value="network",p.value=!0,null;G();try{if(!L())return P("sdk_not_loaded"),null;const e=1e4,n=I(),r=new Promise((c,w)=>setTimeout(()=>w(new Error("timeout")),e)),t=await Promise.race([n,r]);if(u.value=t.session_id,f.value=!0,a.value=!0,N(),!i){const c=await v(t.session_id);c?(g.value=c.status==="blocked",h.value=c.blockReason):g.value=!0,p.value=!0}return t.session_id}catch(e){const n=e instanceof Error&&e.message==="timeout"?"session_timeout":"session_error";return P(n,e),null}},q=(i=x)=>d.value?Promise.resolve("failed"):a.value?Promise.resolve("ready"):new Promise(e=>{let n=!1;const r=w=>{n||(n=!0,clearTimeout(c),t(),e(w))},t=H([a,d],([w,B])=>{B?r("failed"):w&&r("ready")}),c=setTimeout(()=>{P("session_timeout",new Error("await_timeout")),r("failed")},i)}),X=async()=>{try{if(!L())return;await b(),u.value=null,f.value=!1}catch{}},F=async()=>{if(y.value)return;y.value=!0;const{capture:i}=U();if(i("sdk_retry_attempted"),A()){await new Promise(e=>setTimeout(e,1e3)),y.value=!1;return}d.value=!1,g.value=!1,h.value=null,p.value=!1,a.value=!1,S.value=!1,V=!1,N();try{O.isNativePlatform()?await b():K(),await R(),i(d.value?"sdk_retry_failed":"sdk_retry_succeeded")}finally{y.value=!1}};return s&&typeof window<"u"&&R(),{getSessionId:R,awaitSession:q,reinitialize:X,retrySession:F,sessionId:u,isReady:f,isSessionBlocked:d,sessionCheckComplete:a,isRiskBlocked:g,blockReason:h,riskCheckComplete:p,sdkWarningVisible:S,isRetrying:y,userId:E(()=>m.value?.uuid)}}export{ee as u};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.