PageSourceSearch

https://rolandmineral.com/static/AuthContext-B_UiQeWd.js

js rolandmineral.com collected 2026-10-09 21:25:04 UTC 6,890 bytes, 1 lines download raw bytes

1import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{P as t,_ as n,h as r,j as i,n as a}from"./axiosClient-CdQMSRdY.js";import{i as o}from"./runtime-QtgwY_nV.js";import{r as s}from"./domainValidation-FMKryCR2.js";import{g as c,n as l,x as u}from"./backend-CG0Gwium.js";import{v as d,x as f}from"./vendor-react-DpRoP2jP.js";import{i as p,o as m}from"./i18n-BaEcDXrH.js";import{E as h}from"./errorReporting-DLPoz25o.js";import{g,u as _,y as v}from"./mixpanelUtils-rMsmO2Gh.js";import{n as y}from"./base-dsvE4a4m.js";import{t as b}from"./AuthAPI-BcaMQ-Cd.js";import{r as ee}from"./useDesignSystem-6Kcl9LIZ.js";import{r as x}from"./logoutReturnPath-HjtsxsFd.js";var S=e(f()),C=`sso_workspace_challenge_pending`,w=6e5;function T(e,t){try{sessionStorage.setItem(C,JSON.stringify({workspaceId:e,workspaceName:t,startedAt:Date.now()}))}catch{}}function E(){try{let e=sessionStorage.getItem(C);if(!e)return null;let t=JSON.parse(e);return t?.workspaceId?Date.now()-(t.startedAt??0)>w?(sessionStorage.removeItem(C),null):t:null}catch{return null}}
1function D(){try{sessionStorage.removeItem(C)}catch{}}function te(){let e=E();if(e)try{sessionStorage.removeItem(C)}catch{}return e}var O=new class extends y{getBaseURL(){return`/auth`}prepareChallenge(e){return this.axios.post(`/sso-challenge/prepare`,{workspace_id:e})}passwordChallenge(e,t){return this.axios.post(`/workspace-challenge`,{workspace_id:e,password:t})}},k=(e,t)=>{let n=encodeURIComponent(t),r=e.indexOf(`#`),i=(r===-1?e:e.slice(0,r)).replace(/(\/workspace\/)[^/?#]+/,`$1${n}`),a=i.indexOf(`?`),o=a===-1?i:i.slice(0,a),s=(a===-1?``:i.slice(a+1)).split(`&`).filter(e=>e&&!/^active_workspace=/.test(e));return s.push(`active_workspace=${n}`),`${o}?${s.join(`&`)}`},A=({workspaceId:e,fromUrl:t,email:n})=>{let r=new URLSearchParams({from_url:k(t,e)}),i=n?.trim();i&&r.set(`login_hint`,i);let a=new URLSearchParams(window.location.search),o=a.get(`mcp_oauth_context`);o&&r.set(`mcp_oauth_context`,o);let s=a.get(`ref`);return s&&r.set(`ref`,s),`${l()}/workspaces/${e}/auth/sso/login?${r.toString()}`},j=`oauth_pending_prompt`,M=2e3,N=3e5;function P(e){if(!e)return`/`;if(e.length<=M)return e;try{let t=new URL(e,window.location.origin),n=t.searchParams.get(`prompt`);if(n){let r={prompt:n,timestamp:Date.now()};return sessionStorage.setItem(j,JSON.stringify(r)),t.searchParams.delete(`prompt`),e.startsWith(`http://`)||e.startsWith(`https://`)?t.href:t.pathname+t.search+t.hash}}catch{}return e}function F(){try{let e=sessionStorage.getItem(j);if(sessionStorage.removeItem(j),!e)return null;let t=JSON.parse(e);if(t.prompt&&t.timestamp&&Date.now()-t.timestamp<N)return t.prompt}catch{}return null}function I(){try{let e=sessionStorage.getItem(j);if(!e)return!1;let t=JSON.parse(e);return!!(t.prompt&&t.timestamp&&Date.now()-t.timestamp<N)}catch{return!1}}var L=(e,t)=>`${e}${e.includes(`?`)?`&`:`?`}continuation=${encodeURIComponent(t)}`,R=0;function z(){R++}async function B({workspaceId:e,workspaceName:t,userEmail:n}){let r=++R,i=P(s(window.location.href,`/`));try{let{continuation:a}=await O.prepareChallenge(e);return r===R?(T(e,t??``),window.location.href=L(A({workspaceId:e,fromUrl:i,email:n??void 0}),a),`redirected`):`superseded`}catch{return r===R?(D(),`failed`):`superseded`}}var V=null;function H(){!u(window.location.host)&&!o()||(V=t.ensureSessionReady().then(()=>{let e=i(!1);return e?(p(`Authorization`,`Bearer ${e}`),b.getCurrentUser()):null}),V.catch(()=>{}))}function U(){let e=V;return V=null,e}var W=()=>{try{v(`logged_in`,`true`)}catch{}},G=()=>{try{g(`logged_in`)}catch{}};function K(e){let t=e.split(`:`,1)[0].toLowerCase(),n=c();return!!(t===new URL(`https://app.base44.com`).hostname||n&&t===n)}function q(e){let t=`${e.pathname}${e.search}${e.hash}`;return`/auth/oidc/login?return_to=${encodeURIComponent(t)}`}function J(e){return K(e)?`/api/auth/oidc/logout`:null}var Y=`b44_entry_referrer`;function X(e){try{return new URL(e).origin===window.location.origin}catch{return!1}}function Z(){try{if(X(document.referrer))return;let e={referrer:document.referrer};sessionStorage.setItem(Y,JSON.stringify(e))}catch{}}function ne(){let e=document.referrer;if(e&&!X(e))return e;try{let t=sessionStorage.getItem(Y);if(t===null)return e;let n=JSON.parse(t),r=performance.timeOrigin;return n.readBy===void 0?(sessionStorage.setItem(Y,JSON.stringify({...n,readBy:r})),n.referrer):n.readBy===r?n.referrer:(sessionStorage.removeItem(Y),e)}catch{return e}}function re(){try{sessionStorage.removeItem(Y)}catch{}}var Q=d(),$=(0,S.createContext)(),ie=e=>e.response?.status===401,ae=({children:e})=>{let[o,s]=(0,S.useState)(null),[c,l]=(0,S.useState)(!1),[u,d]=(0,S.useState)(!0),f=()=>{G(),localStorage.removeItem(`token`),localStorage.removeItem(`base44_access_token`),localStorage.removeItem(`home_draft_prompt`),localStorage.removeItem(`home_draft_connectors`),localStorage.removeItem(`home_draft_pinned_url`),localStorage.removeItem(`home_draft_pinned_mode`),localStorage.removeItem(`activeWorkspaceId`),m(`Authorization`),r(),z(),D(),_(null),s(null),l(!1),d(!1)},g=e=>{_(e?.feature_flag_variants,e?.analytics_arms),s(e)};(0,S.useEffect)(()=>{n(()=>o?.email??null)},[o?.email]),(0,S.useEffect)(()=>{ee(h(o?.email))},[o?.email]),(0,S.useEffect)(()=>{c&&re()},[c]),(0,S.useEffect)(()=>{let e=!1,n=()=>{};return t.ensureSessionReady().then(()=>
1{if(e)return;let r=i(!0);r?(localStorage.setItem(`token`,r),p(`Authorization`,`Bearer ${r}`),C()):d(!1);let a=t.getPrincipalId(),o=()=>{if(t.getPrincipalId()!==a){m(`Authorization`),m(`SSO_AUTHORIZATION`),window.location.reload();return}let e=i(!1);e?p(`Authorization`,`Bearer ${e}`):m(`Authorization`)},s=e=>{e.storageArea===localStorage&&(e.key===null||e.key===`token`||e.key===`base44_access_token`)&&o()},c=t.addListener(e=>{e===`token_changed`&&(a===`anon`&&(a=t.getPrincipalId()),o())});window.addEventListener(`storage`,s),window.addEventListener(`focus`,o),n=()=>{c(),window.removeEventListener(`storage`,s),window.removeEventListener(`focus`,o)}}),a(e=>{ie(e)&&f()}),()=>{e=!0,n()}},[]);let v=e=>{s(t=>({...t,...e}))},y=async(e=!0)=>{let t=e?J(window.location.host):null,{href:n,pathname:r,search:i,hash:a}=window.location;if(f(),t){x(r+i+a),window.location.href=t;return}let o=b.logout().catch(()=>{});e&&await o,e&&(window.location.href=`/login?from_url=`+encodeURIComponent(n))},C=async()=>{try{d(!0);let e=U(),t=(e?await e:null)??await b.getCurrentUser();return g(t),l(!0),d(!1),W(),t}catch(e){d(!1);let t=e.response?.status;(t===401||t===403)&&f()}},w=(0,S.useCallback)(async({fresh:e=!1}={})=>{let t=await b.getCurrentUser({fresh:e});t&&(g(t),l(!0),d(!1))},[]);return(0,Q.jsx)($.Provider,{value:{user:o,isAuthenticated:c,logout:y,isLoadingAuth:u,updateUser:v,reloadUser:w},children:e})},oe=()=>(0,S.useContext)($);export{D as _,q as a,T as b,B as c,I as d,F as f,O as g,A as h,Z as i,z as l,k as m,oe as n,K as o,P as p,ne as r,H as s,ae as t,L as u,te as v,E as y};

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.