PageSourceSearch

https://app.boosted.ai/assets/alfaAuth-B3Ya6XCG.js

js boosted.ai collected 2026-09-25 14:56:47 UTC 15,065 bytes, 1 lines download raw bytes

1import{is as ne,it as ie,es as k,iu as se,iv as oe,ev as O,iw as W,ix as N,iy as G,iz as V,iA as re,iB as C,iC as H,iD as de,eR as S,eu as I,iE as T,et as v,iF as ae,iG as j,ez as A,iH as ce,iI as w,g8 as x,d1 as _,d2 as le,bQ as P,d3 as R,bN as h,c5 as B,c_ as ue,ed as b,iJ as Ie,c$ as he}from"./usePrimeStore-C2Yvd7x-.js";import{i as ge}from"./useSpoofStore-Baz3I7HO.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};e.SENTRY_RELEASE={id:"all-0.0.1608"};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d10a3b66-ba54-433e-b3b5-91cee060052e",e._sentryDebugIdIdentifier="sentry-dbid-d10a3b66-ba54-433e-b3b5-91cee060052e")}catch{}})();const z="cognito-identity",$={service:z,retryDecider:ie(k),computeDelay:ne,cache:"no-store"},ye=()=>e=>async function(n){return n.headers["cache-control"]="no-store",e(n)},J=se(oe,[ye]),M=e=>(t,n)=>{const o=fe(e),i=JSON.stringify(t);return me(n,o,i)},fe=e=>({"content-type":"application/x-amz-json-1.1","x-amz-target":`AWSCognitoIdentityService.${e}`}),me=({url:e},t,n)=>({headers:t,url:e,body:n,method:"POST"}),K=e=>O(J,M("GetCredentialsForIdentity"),Ce,{...$,...e,userAgentValue:W()}),Ce=async e=>{if(e.statusCode>=300)throw await k(e);const t=await N(e);return{IdentityId:t.IdentityId,Credentials:we(t.Credentials),$metadata:G(e)}},we=({Expiration:e,...t}={})=>({...t,Expiration:e&&new Date(e*1e3)}),Ae=e=>O(J,M("GetId"),_e,{...$,...e,userAgentValue:W()}),_e=async e=>{if(e.statusCode>=300)throw await k(e);return{IdentityId:(await N(e)).IdentityId,$metadata:G(e)}},Se=({region:e})=>({url:new V(`https://${z}.${e}.${re(e)}`)});/*! js-cookie v3.0.8 | MIT */function y(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)o!=="__proto__"&&(e[o]=n[o])}return e}var Te={read:function(e){return e[0]==='"'&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function p(e,t){function n(i,s,d){if(!(typeof document>"u")){d=y({},t,d),typeof d.expires=="number"&&(d.expires=new Date(Date.now()+d.expires*864e5)),d.expires&&(d.expires=d.expires.toUTCString()),i=encodeURIComponent(i).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var r in d)d[r]&&(a+="; "+r,d[r]!==!0&&(a+="="+d[r].split(";")[0]));return document.cookie=i+"="+e.write(s,i)+a}}function o(i){if(!(typeof document>"u"||arguments.length&&!i)){for(var s=document.cookie?document.cookie.split("; "):[],d={},a=0;a<s.length;a++){var r=s[a].split("="),l=r.slice(1).join("=");try{var c=decodeURIComponent(r[0]);if(c in d||(d[c]=e.read(l,c)),i===c)break}catch{}}return i?d[i]:d}}return Object.create({set:n,get:o,remove:function(i,s){n(i,"",y({},s,{expires:-1}))},withAttributes:function(i){return p(this.converter,y({},this.attributes,i))},withConverter:function(i){return p(y({},this.converter,i),this.attributes)}},{attributes:{value:Object.freeze(t)},converter:{value:Object.freeze(e)}})}var f=p(Te,{path:"/"});class ve{constructor(t={}){const{path:n,domain:o,expires:i,sameSite:s,secure:d}=t;if(this.domain=o,this.path=n||"/",this.expires=Object.prototype.hasOwnProperty.call(t,"expires")?i:365,this.secure=Object.prototype.hasOwnProperty.call(t,"secure")?d:!0,Object.prototype.hasOwnProperty.call(t,"sameSite")){if(!s||!["strict","lax","none"].includes(s))throw new Error('The sameSite value of cookieStorage must be "lax", "strict" or "none".');if(s==="none"&&!this.secure)throw new Error("sameSite = None requires the Secure attribute in latest browser versions.");this.sameSite=s}}async setItem(t,n){f.set(t,n,this.getData())}async getItem(t){return f.get(t)??null}async removeItem(t){f.remove(t,this.getData())}async clear(){const t=f.get(),n=Object.keys(t).map(o=>this.removeItem(o));await Promise.all(n)}getData(){return{path:this.path,expires:this.expires,domain:this.domain,secure:this.secure,...this.sameSite&&{sameSite:this.sameSite}}}}const pe={identityId:"identityId"},Ee=new H("DefaultIdentityIdStore");class U{setAuthConfig(t){C(t.Cognito),this.authConfig=t,this._authKeys=ke("Cognito",t.Cognito.identityPoolId)}constructor(t){this._authKeys={},this._hasGuestIdentityId=!1,this.keyValueStorage=t}async loadIdentityId(){var t;C((t=this.authConfig)==null?void 0:t.Cognito);try{if(this._primaryIdentityId)return{id:this._primaryIdentityId,type:"primary"};{const n=await this.keyValueStorage.getItem(this._authKeys.identityId);return n?(this._hasGuestIdentityId=!0,{id:n,type:"guest"}):null}}catch(n){return Ee.log("Error getting stored IdentityId.",n),null}}async storeIdentityId(t){var n;C((n=this.authConfig)==null?void 0:n.Cognito),t.type==="guest"?(this.keyValueStorage.setItem(this._authKeys.identityId,t.id),this._primaryIdentityId=void 0,this._hasGuestIdentityId=!0):(this._primaryIdentityId=t.
1id,this._hasGuestIdentityId&&(this.keyValueStorage.removeItem(this._authKeys.identityId),this._hasGuestIdentityId=!1))}async clearIdentityId(){this._primaryIdentityId=void 0,await this.keyValueStorage.removeItem(this._authKeys.identityId)}}const ke=(e,t)=>de(pe)(`com.amplify.${e}`,t),E=({endpointOverride:e})=>t=>e?{url:new V(e)}:Se(t);function Y(e){const t=S(e).payload.iss,n={};if(!t)throw new I({name:"InvalidIdTokenException",message:"Invalid Idtoken."});const o=t.replace(/(^\w+:|^)\/\//,"");return n[o]=e,n}async function Pe({tokens:e,authConfig:t,identityIdStore:n}){n.setAuthConfig({Cognito:t});const o=await n.loadIdentityId();if(o)return o.id;const i=e!=null&&e.idToken?Y(e.idToken.toString()):{},s=await Re(i,t);return n.storeIdentityId({id:s,type:e?"primary":"guest"}),s}async function Re(e,t){const n=t==null?void 0:t.identityPoolId,o=T(n),i=Ae({endpointResolver:E({endpointOverride:t.identityPoolEndpoint})});let s;try{s=(await i({region:o},{IdentityPoolId:n,Logins:e})).IdentityId}catch(d){throw v(d),new I(d)}if(!s)throw new I({name:"GetIdResponseException",message:"Received undefined response from getId operation",recoverySuggestion:"Make sure to pass a valid identityPoolId in the configuration."});return s}const m=new H("CognitoCredentialsProvider"),F=3e3*1e3;class Z{constructor(t){this._nextCredentialsRefresh=0,this._identityIdStore=t}async clearCredentialsAndIdentityId(){m.debug("Clearing out credentials and identityId"),this._credentialsAndIdentityId=void 0,await this._identityIdStore.clearIdentityId()}async clearCredentials(){m.debug("Clearing out in-memory credentials"),this._credentialsAndIdentityId=void 0}async getCredentialsAndIdentityId(t){const n=t.authenticated,{tokens:o}=t,{authConfig:i}=t;try{C(i==null?void 0:i.Cognito)}catch{return}if(!n&&!i.Cognito.allowGuestAccess)return;const{forceRefresh:s}=t,d=this.hasTokenChanged(o),a=await Pe({tokens:o,authConfig:i.Cognito,identityIdStore:this._identityIdStore});return(s||d)&&this.clearCredentials(),n?(ae(o),this.credsForOIDCTokens(i.Cognito,o,a)):this.getGuestCredentials(a,i.Cognito)}async getGuestCredentials(t,n){var d,a;if(this._credentialsAndIdentityId&&!this.isPastTTL()&&this._credentialsAndIdentityId.isAuthenticatedCreds===!1)return m.info("returning stored credentials as they neither past TTL nor expired."),this._credentialsAndIdentityId;this.clearCredentials();const o=T(n.identityPoolId),i=K({endpointResolver:E({endpointOverride:n.identityPoolEndpoint})});let s;try{s=await i({region:o},{IdentityId:t})}catch(r){throw v(r),new I(r)}if((d=s==null?void 0:s.Credentials)!=null&&d.AccessKeyId&&((a=s==null?void 0:s.Credentials)!=null&&a.SecretKey)){this._nextCredentialsRefresh=new Date().getTime()+F;const r={credentials:{accessKeyId:s.Credentials.AccessKeyId,secretAccessKey:s.Credentials.SecretKey,sessionToken:s.Credentials.SessionToken,expiration:s.Credentials.Expiration},identityId:t};return s.IdentityId&&(r.identityId=s.IdentityId,this._identityIdStore.storeIdentityId({id:s.IdentityId,type:"guest"})),this._credentialsAndIdentityId={...r,isAuthenticatedCreds:!1},r}else throw new I({name:"CredentialsNotFoundException",message:"Cognito did not respond with either Credentials, AccessKeyId or SecretKey."})}async credsForOIDCTokens(t,n,o){var r,l,c;if(this._credentialsAndIdentityId&&!this.isPastTTL()&&this._credentialsAndIdentityId.isAuthenticatedCreds===!0)return m.debug("returning stored credentials as they neither past TTL nor expired."),this._credentialsAndIdentityId;this.clearCredentials();const i=n.idToken?Y(n.idToken.toString()):{},s=T(t.identityPoolId),d=K({endpointResolver:E({endpointOverride:t.identityPoolEndpoint})});let a;try{a=await d({region:s},{IdentityId:o,Logins:i})}catch(u){throw v(u),new I(u)}if((r=a==null?void 0:a.Credentials)!=null&&r.AccessKeyId&&((l=a==null?void 0:a.Credentials)!=null&&l.SecretKey)){this._nextCredentialsRefresh=new Date().getTime()+F;const u={credentials:{accessKeyId:a.Credentials.AccessKeyId,secretAccessKey:a.Credentials.SecretKey,sessionToken:a.Credentials.SessionToken,expiration:a.Credentials.Expiration},identityId:o};return a.IdentityId&&(u.identityId=a.IdentityId,this._identityIdStore.storeIdentityId({id:a.IdentityId,type:"primary"})),this._credentialsAndIdentityId={...u,isAuthenticatedCreds:!0,associatedIdToken:(c=n.idToken)==null?void 0:c.toString()},u}else throw new I({name:"CredentialsException",message:"Cognito did not respond with either Credentials, AccessKeyId or SecretKey."})}isPastTTL(){return this._nextCredentialsRefresh===void 0?!0:this._nextCredentialsRefresh<=Date.now()}hasTokenChanged(t){var n,o;return!!t&&!!((n=this._credentialsAndIdentityId)!=null&&n.associatedIdToken)&&((o=t.idToken)==null?void 0:o.toString())!==this._credentialsAndIdentityId.associatedIdToken}}const De=new Z(new U(j)),xe={configure(e,t){const n=ce(e),o=new ve({sameSite:"lax"}),i=t!=null&&t.ssr?o:j,s=t!=null&&t.ssr?new Z(new U(o)):De;if(!n.Auth||t!=null&&t.Auth){A.configure(n,t);return}w.setAuthConfig(n.Auth),w.setKeyValueStorage(i),A.configure(n,{...t,Auth:{tokenProvider:w,credentialsProvider:s}})},getConfig(){return A.getConfig()}};let L=!1;function be(){if(L)return;L=!0;const e=!window.location.protocol.startsWith("http"),t=le(),n=e?t:`${window.location.origin}/login/redirect`,o=e?t.replace("/auth/callback","/auth/close"):window.location.origin,i=x.enabled?{oauth:{domain:_.authDomain,scopes:["email","openid","profile","aws.cognito.signin.user.admin"],responseType:"code",redirectSignIn:[n],redirectSignOut:[o],providers:[...x.googleEnabled?["Google"]:[]]}}:{};xe.configure({Auth:{Cognito:{userPoolId:_.userPoolId,userPoolClientId:_.userPoolClientId,loginWith:{username:!0,...i}}}})}const D=be,q=60;function Ke(e){return e?he(R(e)):void 0}async function Fe(e){var s;D();const t=S(e.access_token),n=S(e.id_token),o=(t.payload.iat??0)*1e3;if(await w.tokenOrchestrator.setTokens({tokens:{accessToken:t,idToken:n,refreshToken:e.refresh_token,clockDrift:o>0?o-Date.now():0,username:e.username}}),!((s=(await B()).tokens)!=null&&s.accessToken))throw new Error("MAGIC_LINK_COGNITO_SESSION_HYDRATION_FAILED")}async function Q(e){var s,d,a,r;D();const t=await B({forceRefresh:(e==null?void 0:e.forceRefresh)??!1}),n=(d=(s=t.tokens)==null?void 0:s.accessToken)==null?void 0:d.toString();if(!n)return null;const o=(r=(a=t.tokens)==null?void 0:a.idToken)==null?void 0:r.toString(),i=await ue(n,{idToken:o,signupProfile:e==null?void 0:e.signupProfile,workspaceId:e==null?void 0:e.workspaceId,onBeforeRegister:e==null?void 0:e.onBeforeRegister,signupContext:e==null?void 0:e.signupContext,trustDevice:e==null?void 0:e.trustDevice});return{cognitoAccessToken:n,boostedJwt:i.jwt,name:i.name??"",email:i.email??"",userId:i.user_id??"",pictureUrl:Ke(o)}}function X(e,t=q){if(!e)return!0;const n=R(e);if(!n)return!0;const o=n.exp;return o?Date.now()/1e3>o-t:!1}function ee(e){const t=P(e.boostedJwt),n=R(e.boostedJwt),o=!!n&&(n["boosted:auth_providers"]!==void 0||n.auth_providers!==void 0),i=!!n&&(n["boosted:email_verified"]!==void 0||n.email_verified!==void 0),{user:s,baseUser:d,setAuth:a}=h.getState(),r=d??s,l=o&&t.authProviders.length>0?t.authProviders:r==null?void 0:r.authProviders;a(e.boostedJwt,e.cognitoAccessToken,{email:e.email||(r==null?void 0:r.email)||"",name:e.name||(r==null?void 0:r.name)||e.email||"",userId:e.userId||(r==null?void 0:r.userId)||"",authProviders:l,emailVerified:i?t.emailVerified:(r==null?void 0:r.emailVerified)||!1,groups:t.groups,globalUserId:t.globalUserId??(r==null?void 0:r.globalUserId),isWaitlisted:t.isWaitlisted,orgId:t.orgId??(r==null?void 0:r.orgId),realUserId:t.realUserId??(r==null?void 0:r.realUserId),teamId:t.teamId??(r==null?void 0:r.teamId),pictureUrl:e.pictureUrl??(r==null?void 0:r.pictureUrl)})}async function Le(e){const t=e.trim();
1if(!t)throw new Error("WORKSPACE_SWITCH_INVALID_ID");const n=await te({useBaseAuth:!0});if(!n)throw new Error("WORKSPACE_SWITCH_UNAUTHORIZED");const o=await fetch(`${Ie}/user/token?workspace_id=${encodeURIComponent(t)}`,{method:"GET",headers:{Authorization:`Boosted-V1 ${n}`}});if(o.status===401)throw h.getState().handleUnauthorized(),new Error("WORKSPACE_SWITCH_UNAUTHORIZED");if(!o.ok)throw console.error("[WORKSPACE_SWITCH_FAILED]",{status:o.status}),new Error(`WORKSPACE_SWITCH_FAILED: ${o.status}`);const i=await o.json().catch(()=>null);if(!i||typeof i.jwt!="string")throw new Error("WORKSPACE_SWITCH_INVALID_RESPONSE");const s=P(i.jwt),{cognitoAccessToken:d,user:a,baseUser:r,setAuth:l}=h.getState(),c=r??a;l(i.jwt,d??"",{email:typeof i.email=="string"&&i.email||s.email||(c==null?void 0:c.email)||"",name:typeof i.name=="string"&&i.name||s.name||(c==null?void 0:c.name)||"",userId:typeof i.user_id=="string"&&i.user_id||s.userId||(c==null?void 0:c.userId)||"",authProviders:s.authProviders.length>0?s.authProviders:c==null?void 0:c.authProviders,emailVerified:s.emailVerified||(c==null?void 0:c.emailVerified)||!1,globalUserId:s.globalUserId??(c==null?void 0:c.globalUserId),groups:s.groups,isWaitlisted:s.isWaitlisted,orgId:s.orgId??(c==null?void 0:c.orgId),realUserId:s.realUserId??(c==null?void 0:c.realUserId),teamId:typeof i.team_id=="string"&&i.team_id||s.teamId||(c==null?void 0:c.teamId)||t})}let g=null;async function te(e){const t=(e==null?void 0:e.useBaseAuth)??!1;if(!t&&ge())return b();const n=b({useBaseAuth:t});return n&&!X(n)?n:g||(g=(async()=>{var o;try{const i=h.getState(),s=((o=t?i.baseUser:i.user)==null?void 0:o.teamId)??(n?P(n).teamId:void 0),d=await Q({forceRefresh:!0,workspaceId:s});return d?(ee(d),d.boostedJwt):(console.error("[ALFA_TOKEN_REFRESH_FAILED]",{reason:"no_cognito_session"}),h.getState().handleUnauthorized(),null)}catch(i){return console.error("[ALFA_TOKEN_REFRESH_FAILED]",i),h.getState().handleUnauthorized(),null}finally{g=null}})(),g)}const Ne=Object.freeze(Object.defineProperty({__proto__:null,REFRESH_WINDOW_SECONDS:q,applyRefreshedAuth:ee,ensureAlfaAmplifyConfigured:D,getBoostedTokenFromCognitoSession:Q,getValidAlfaToken:te,hydrateAmplifySessionFromMagicLink:Fe,switchAlfaWorkspace:Le,willExpireSoon:X},Symbol.toStringTag,{value:"Module"}));export{q as R,te as a,ee as b,be as c,Ne as d,D as e,Q as g,Fe as h,Le as s};

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.