PageSourceSearch

https://heyfinn.ai/_next/static/chunks/8430-faec8822491d9f38.js?dpl=dpl_5QK9yAQofpyzKb6XPm9rMdGpzkNk

js heyfinn.ai collected 2026-10-05 13:11:42 UTC 10,098 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8430],{8430:(e,t,r)=>{r.d(t,{iP:()=>f,Ou:()=>T,hS:()=>b,Z1:()=>y});var s=r(37882),i=r(79088),o=r(24229),a=r(35977),n=r(36854),u=r(99650),l=r(87420),c=r(41463);let d=(0,l.h)("Auth"),h={providers:[(0,o.A)({name:"credentials",credentials:{email:{label:"Email",type:"email"},password:{label:"Password",type:"password"},verificationToken:{label:"Verification Token",type:"text"}},async authorize(e){let t=(0,u.getApiBaseUrl)();if(e?.verificationToken){d.debug("Attempting token-based auth");try{let r=await fetch(`${t}/auth/me`,{method:"GET",headers:{Authorization:`Bearer ${e.verificationToken}`,"Content-Type":"application/json"}});if(!r.ok)return d.debug("Token validation failed",{status:r.status}),null;let s=await r.json();return d.debug("Token auth successful",{userId:s.id}),{id:s.id,email:s.email,name:s.name,role:s.role,accessToken:e.verificationToken,isActive:s.isActive,businessId:s.businessId,registrationCompleted:s.registrationCompleted,tutorialCompleted:s.tutorialCompleted,customerPortalUrl:s.customerPortalUrl,createdAt:s.createdAt,updatedAt:s.updatedAt}}catch(e){return d.error("Token auth failed",e),null}}if(!e?.email||!e?.password)return d.debug("Missing credentials"),null;try{let r=await fetch(`${t}/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e.email,password:e.password})});if(!r.ok)return d.debug("Login failed",{status:r.status}),null;let s=await r.json();if(s.access_token&&s.user)return d.debug("Login successful",{userId:s.user.id}),{id:s.user.id,email:s.user.email,name:s.user.name,role:s.user.role,accessToken:s.access_token,isActive:s.user.isActive,businessId:s.user.businessId,registrationCompleted:s.user.registrationCompleted,tutorialCompleted:s.user.tutorialCompleted,customerPortalUrl:s.user.customerPortalUrl,createdAt:s.user.createdAt,updatedAt:s.user.updatedAt};return d.debug("Login response missing required fields"),null}catch(e){return d.error("Login failed",e),null}}}),(0,n.A)({clientId:c.env.GOOGLE_CLIENT_ID,clientSecret:c.env.GOOGLE_CLIENT_SECRET}),(0,a.A)({clientId:c.env.FACEBOOK_CLIENT_ID,clientSecret:c.env.FACEBOOK_CLIENT_SECRET})],callbacks:{async jwt({token:e,user:t,trigger:r,session:s,account:i,profile:o}){if(i&&"facebook"===i.provider&&o){d.debug("Facebook OAuth sign-in",{email:o.email});try{let t=(0,u.getApiBaseUrl)(),r=await fetch(`${t}/auth/oauth/facebook`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sub:o.sub||o.id,email:o.email,name:o.name,picture:o.picture})});if(!r.ok){let e=await r.text();throw d.error("Facebook OAuth backend call failed",{status:r.status,body:e}),Error("Facebook OAuth failed")}let s=await r.json();e.accessToken=s.access_token,e.role=s.user.role||"user",e.isActive=!!s.user.isActive,e.registrationCompleted=!!s.user.registrationCompleted,e.tutorialCompleted=!!s.user.tutorialCompleted,e.businessId=s.user.businessId||"",e.oauthProvider="facebook",d.debug("Facebook OAuth successful",{userId:s.user.id})}catch(e){throw d.error("Facebook OAuth error",e),e}}else if(i&&"google"===i.provider&&o){d.debug("Google OAuth sign-in",{email:o.email});try{let t=(0,u.getApiBaseUrl)(),r=await fetch(`${t}/auth/oauth/google`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sub:o.sub,email:o.email,name:o.name,picture:o.picture})});if(!r.ok){let e=await r.text();throw d.error("Google OAuth backend call failed",{status:r.status,body:e}),Error("Google OAuth failed")}let s=await r.json();e.accessToken=s.access_token,e.role=s.user.role||"user",e.isActive=!!s.user.isActive,e.registrationCompleted=!!s.user.registrationCompleted,e.tutorialCompleted=!!s.user.tutorialCompleted,e.businessId=s.user.businessId||"",e.oauthProvider="google",d.debug("Google OAuth successful",{userId:s.user.id})}catch(e){throw d.error("Google OAuth error",e),e}}else t&&(e.accessToken=t.accessToken||"",e.role=t.role||"",e.isActive=!!t.isActive,e.registrationCompleted=!!t.registrationCompleted,e.tutorialCompleted=!!t.tutorialCompleted,e.businessId=t.businessId||"");return"update"===r&&s&&(s.accessToken&&(e.accessToken=s.accessToken),s.user?.isActive!==void 0&&(e.isActive=!!s.user.isActive),s.user?.role&&(e.role=s.user.role),s.user?.registrationCompleted!==void 0&&(e.registrationCompleted=!!s.user.registrationCompleted),s.user?.tutorialCompleted!==void 0&&(e.tutorialCompleted=!!s.user.tutorialCompleted),s.user?.businessId!==void 0&&(e.businessId=s.user.businessId)),e},session:async({session:e,token:t})=>(t&&(e.user.id=t.sub||"",e.user.role=t.role||"",e.accessToken=t.accessToken||"",e.user.isActive=!!t.isActive,e.user.registrationCompleted=!!t.registrationCompleted,e.user.tutorialCompleted=!!t.tutorialCompleted,e.user.businessId=t.businessId||""),e)},events:{async signIn(){d.debug("Sign in event triggered")},async signOut(){d.debug("Sign out event triggered")}},pages:{signIn:"/login"},session:{strategy:"jwt",maxAge:1209600},secret:c.env.NEXTAUTH_SECRET,debug:!1};var p=r(7318);let g=(0,l.h)("API"),m=(0,u.getApiBaseUrl)();class A{static{this.TOKEN_CACHE_TTL=6e4}constructor(e=m,t=!1){this.cachedToken=null,this.tokenCacheExpiry=0,this.baseUrl=e,this.isServer=t}clearTokenCache(){this.cachedToken=null,this.tokenCacheExpiry=0}async getAuthToken(){let e=Date.now();if(!this.isServer&&this.cachedToken&&e<this.tokenCacheExpiry)return this.cachedToken;try{if(this.isServer){let e=await (0,i.Mt)(h);return e?.accessToken||null}{let t=await (0,s.getSession)(),r=t?.accessToken||null;return this.cachedToken=r,this.tokenCacheExpiry=e+A.TOKEN_CACHE_TTL,r}}catch(e){return g.error("Failed to get auth token",e),null}}async createFetchOptions(e,t,r=!1,s=!1,i="required"){let o={};if(s||(o["Content-Type"]="application/json"),o.Accept="application/json",o[l.KJ]=(0,l.v5)(),r){let e=await this.getAuthToken();if(e)o.Authorization=`Bearer ${e}`;else if("required"===i)throw this.isServer||await (0,p.T4)("Authentication required but no token available"),Error("Authentication required but no token available")}return{method:e,headers:o,body:t?s?t:JSON.stringify(t):void 0}}async request(e,t){let{method:r,body:s,requireAuth:i=!1,isMultipart:o=!1,useNextApi:a=!1,authMode:n="required"}=t;try{let t=await this.createFetchOptions(r,s,i,o,n),u=a?e:`${this.baseUrl}${e}`,l=await fetch(u,t);if(!l.ok){let e,t,r=`Request failed with status ${l.status}`;try{let s=l.headers.get("content-type");if(s?.includes("application/json")){e=await l.json();let s=e?.detail;if(s&&"object"==typeof s)"string"==typeof s.code&&(t=s.code),"string"==typeof s.message&&(r=s.message);else if("string"==typeof s)r=s;else{let t=e&&(e.message||e.error);
1r=("string"==typeof t?t:null)||JSON.stringify(e)}"string"==typeof e?.code&&(t=t||e.code)}else r=await l.text()}catch{}if(401===l.status){i&&"optional"!==n&&!this.isServer&&await (0,p.T4)("Your session has expired. Please sign in again.");let e=Error(r||"Authentication failed");throw e.status=401,e}let s=Error(r||`HTTP ${l.status}`);throw s.status=l.status,e&&(s.body=e),t&&(s.code=t),s}let c=l.headers.get("content-type");if(c?.includes("application/json"))return await l.json();if(c?.includes("image/")||c?.includes("application/octet-stream")||c?.includes("application/pdf")||c?.includes("application/msword")||c?.includes("application/vnd.openxmlformats-officedocument")||c?.includes("text/plain"))return await l.blob();try{return await l.blob()}catch{return await l.text()}}catch(i){let t=i instanceof Error?i.message:String(i),s=i.status;if(401===s&&"optional"===n)throw i;throw t.includes("429")?g.warn("Request rate-limited",{endpoint:e,status:429}):g.error("Request failed",i,{endpoint:e,method:r,status:s}),i}}async get(e,t=!1){return this.request(e,{method:"GET",useNextApi:t})}async post(e,t,r=!1){return this.request(e,{method:"POST",body:t,useNextApi:r})}async put(e,t,r=!1){return this.request(e,{method:"PUT",body:t,useNextApi:r})}async delete(e,t=!1){return this.request(e,{method:"DELETE",useNextApi:t})}async getAuth(e,t=!1){return this.request(e,{method:"GET",requireAuth:!0,useNextApi:t})}async getAuthOptional(e,t=!1){return this.request(e,{method:"GET",requireAuth:!0,useNextApi:t,authMode:"optional"})}async postAuth(e,t,r){let{useNextApi:s=!1,authMode:i="required"}="boolean"==typeof r?{useNextApi:r}:r??{};return this.request(e,{method:"POST",body:t,requireAuth:!0,useNextApi:s,authMode:i})}async putAuth(e,t,r=!1){return this.request(e,{method:"PUT",body:t,requireAuth:!0,useNextApi:r})}async patchAuth(e,t,r){let{useNextApi:s=!1,authMode:i="required"}="boolean"==typeof r?{useNextApi:r}:r??{};return this.request(e,{method:"PATCH",body:t,requireAuth:!0,useNextApi:s,authMode:i})}async deleteAuth(e,t=!1){return this.request(e,{method:"DELETE",requireAuth:!0,useNextApi:t})}async uploadFile(e,t,r=!1){return this.request(e,{method:"POST",body:t,requireAuth:!0,isMultipart:!0,useNextApi:r})}async uploadFilePublic(e,t,r=!1){return this.request(e,{method:"POST",body:t,requireAuth:!1,isMultipart:!0,useNextApi:r})}async uploadFilePutAuth(e,t,r=!1){return this.request(e,{method:"PUT",body:t,requireAuth:!0,isMultipart:!0,useNextApi:r})}}let f=new A(m,!1);new A(m,!0);let b=async e=>{let t=e instanceof Error?e.message:String(e);return(t.includes("429")?g.warn("Rate-limited",{message:t}):g.error("Handler caught error",e),e instanceof Error)?"Authentication failed"===e.message?(await (0,p.T4)("Your session has expired. Please sign in again."),"Authentication failed. Please sign in again."):e.message:"An unexpected error occurred"},T=e=>{if(!e||"object"!=typeof e)return;let t=e.code;return"string"==typeof t?t:void 0},y=(e,t)=>{let r=Error(t),s=T(e);s&&(r.code=s);let i=e?.status;throw"number"==typeof i&&(r.status=i),r}},99650:(e,t,r)=>{r.d(t,{getApiBaseUrl:()=>i});var s=r(41463);function i(){return("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.includes("localhost"))&&(void 0===s||"true"!==s.env.NEXT_PUBLIC_USE_REMOTE_BACKEND)?"http://localhost:8000":"https://api.stellenscout.ch"}}}]);
2//# sourceMappingURL=8430-faec8822491d9f38.js.map

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.