PageSourceSearch

https://aibuildershub.ai/_next/static/chunks/13489-6206276cac914b7e.js

js aibuildershub.ai collected 2026-10-05 15:26:53 UTC 15,989 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[13489],{26305:function(e,t,r){r.d(t,{Ng:function(){return o},lU:function(){return l},x1:function(){return i}});var s=r(83464),a=r(14438);class o extends Error{constructor(e="Authentication required",t=null){super(e),this.action=t,this.name="AuthRequiredError"}}let i=s.Z.create({baseURL:"https://aibuildershub.ai/api",timeout:3e4,headers:{"Content-Type":"application/json",Accept:"application/json"},withCredentials:!0}),n=new Map,l=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s="function"==typeof e?e():e,a="".concat(s.method,":").concat(s.url);n.set(a,s);try{let e={method:s.method,url:s.url,...r};return["POST","PUT","PATCH"].includes(e.method)?e.data=t:t&&"GET"===e.method&&(e.params={...t,...e.params}),s.defaultParams&&(e.params={...s.defaultParams,...e.params}),await i(e)}finally{n.delete(a)}};i.interceptors.request.use(e=>{var t;let r=localStorage.getItem("token"),s="".concat(null===(t=e.method)||void 0===t?void 0:t.toUpperCase(),":").concat(e.url),a=n.get(s);if((null==a?void 0:a.requiresAuth)&&!r){let e=a.authMessage||"perform this action";return window.dispatchEvent(new CustomEvent("authRequired",{detail:{action:e,message:"Please login to ".concat(e)}})),Promise.reject(new o("Please login to ".concat(e),e))}return r&&(e.headers.Authorization="Bearer ".concat(r)),e},e=>Promise.reject(e)),i.interceptors.response.use(e=>e,e=>{var t,r,s,i,n,l,u,c,d,h,E,g,m,p,T,f,v,U,R,S,w;if((null===(t=e.response)||void 0===t?void 0:t.status)===401)return localStorage.removeItem("token"),localStorage.removeItem("user"),localStorage.removeItem("authMethod"),window.dispatchEvent(new CustomEvent("authRequired",{detail:{action:"continue",message:"Your session has expired. Please login again."}})),Promise.reject(new o("Session expired"));if((null===(r=e.response)||void 0===r?void 0:r.status)===403){{let t=null===(g=e.response.data)||void 0===g?void 0:g.error;if((null==t?void 0:null===(m=t.message)||void 0===m?void 0:m.toLowerCase().includes("suspended"))||(null==t?void 0:t.code)==="ACCOUNT_SUSPENDED")return window.location.href="/auth/account-suspended",Promise.reject(Error("Your account has been suspended"))}return Promise.reject(Error("Access denied. You do not have permission to perform this action."))}let A="An unexpected error occurred";if(null===(i=e.response)||void 0===i?void 0:null===(s=i.data)||void 0===s?void 0:s.error){let t=e.response.data.error;"object"==typeof t&&t.message?A=t.message:"string"==typeof t&&(A=t)}else(null===(l=e.response)||void 0===l?void 0:null===(n=l.data)||void 0===n?void 0:n.message)?A=e.response.data.message:e.message&&(A=e.message);switch(null===(u=e.response)||void 0===u?void 0:u.status){case 400:(null===(p=e.response.data)||void 0===p?void 0:p.error)||(null===(T=e.response.data)||void 0===T?void 0:T.message)||(A="Invalid request. Please check your input.");break;case 403:A="Access denied. You do not have permission to perform this action.";break;case 404:A="The requested resource was not found.";break;case 409:(null===(f=e.response.data)||void 0===f?void 0:f.error)||(null===(v=e.response.data)||void 0===v?void 0:v.message)||(A="A conflict occurred. The resource may already exist.");break;case 422:(null===(U=e.response.data)||void 0===U?void 0:U.error)||(null===(R=e.response.data)||void 0===R?void 0:R.message)||(A="Validation failed. Please check your input.");break;case 429:A="Too many requests. Please try again later.";break;case 500:A="Server error. Please try again later.";break;case 502:A="Service temporarily unavailable. Please try again later.";break;case 503:A="Service unavailable. Please try again later.";break;default:"ECONNABORTED"===e.code?A="Request timeout. Please try again.":"ERR_NETWORK"===e.code&&(A="Network error. Please check your connection.")}return!((null===(c=e.response)||void 0===c?void 0:c.status)>=400)||!((null===(d=e.response)||void 0===d?void 0:d.status)<500)||(null===(h=e.response)||void 0===h?void 0:h.status)===401||e instanceof o||(null===(S=e.response)||void 0===S?void 0:S.status)===422||(null===(w=e.response)||void 0===w?void 0:w.status)===400||a.Am.error(A),(null===(E=e.response)||void 0===E?void 0:E.status)>=500&&a.Am.error("Something went wrong. Please try again later."),Promise.reject(Error(A))})},6770:function(e,t,r){r.d(t,{a:function(){return s}});let s={login:{url:"/auth/local",method:"POST",requiresAuth:!1},register:{url:"/auth/local/register",method:"POST",requiresAuth:!1},me:{url:"/users/me",method:"GET",requiresAuth:!0,authMessage:"access your profile",defaultParams:{populate:"profile_picture"}},forgotPassword:{url:"/auth/forgot-password",method:"POST",requiresAuth:!1},resetPassword:{url:"/auth/reset-password",method:"POST",requiresAuth:!1},sendEmailConfirmation:{url:"/auth/send-email-confirmation",method:"POST",requiresAuth:!1},emailConfirmation:{url:"/auth/email-confirmation",method:"GET",requiresAuth:!1},changePassword:{url:"/auth/change-password",method:"POST",requiresAuth:!0,authMessage:"change your password"},oauthConnect:e=>({url:"/connect/".concat(e),method:"GET",requiresAuth:!1}),oauthCallback:e=>({url:"/auth/".concat(e,"/callback"),method:"GET",requiresAuth:!1})}},13489:function(e,t,r){r.d(t,{t:function(){return d}});var s=r(59625),a=r(89134),o=r(26305),i=r(6770),n=r(40257);let l={STORAGE_KEYS:{TOKEN:"token",USER:"user",AUTH_METHOD:"authMethod"},TOKEN_EXPIRY_BUFFER:3e5,REFRESH_THRESHOLD:9e5,OAUTH:{GOOGLE:{CLIENT_ID:n.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID,REDIRECT_URI:"".concat(n.env.NEXT_PUBLIC_SITE_URL,"/auth/callback/google"),SCOPES:["openid","profile","email"]},GITHUB:{CLIENT_ID:n.env.NEXT_PUBLIC_GITHUB_CLIENT_ID,REDIRECT_URI:"".concat(n.env.NEXT_PUBLIC_SITE_URL,"/auth/callback/github"),SCOPES:["user:email"]}},PASSWORD_REQUIREMENTS:{MIN_LENGTH:6,MAX_LENGTH:128,REQUIRE_UPPERCASE:!1,REQUIRE_LOWERCASE:!1,REQUIRE_NUMBERS:!1,REQUIRE_SPECIAL:!1},USERNAME_REQUIREMENTS:{MIN_LENGTH:3,MAX_LENGTH:20,PATTERN:/^[a-zA-Z0-9_]+$/,RESERVED_USERNAMES:["admin","api","www","mail","root","support","help","info","contact","about","terms","privacy","blog","news","search","login","register","auth","user","profile","settings","dashboard","hackathons","discu
1ssions"]}};class u{static setToken(e){localStorage.setItem(l.STORAGE_KEYS.TOKEN,e)}static getToken(){return localStorage.getItem(l.STORAGE_KEYS.TOKEN)}static removeToken(){localStorage.removeItem(l.STORAGE_KEYS.TOKEN)}static setUser(e){localStorage.setItem(l.STORAGE_KEYS.USER,JSON.stringify(e))}static getUser(){{let e=localStorage.getItem(l.STORAGE_KEYS.USER);if(e)try{return JSON.parse(e)}catch(e){}}return null}static removeUser(){localStorage.removeItem(l.STORAGE_KEYS.USER)}static setAuthMethod(e){localStorage.setItem(l.STORAGE_KEYS.AUTH_METHOD,e)}static getAuthMethod(){return localStorage.getItem(l.STORAGE_KEYS.AUTH_METHOD)}static removeAuthMethod(){localStorage.removeItem(l.STORAGE_KEYS.AUTH_METHOD)}static clearAuth(){this.removeToken(),this.removeUser(),this.removeAuthMethod()}static isTokenValid(e){if(!e)return!1;try{let t=e.split(".");if(3!==t.length)return!1;let r=JSON.parse(atob(t[1])),s=Math.floor(Date.now()/1e3),a=r.exp-l.TOKEN_EXPIRY_BUFFER/1e3;return s<a}catch(e){return!1}}static shouldRefreshToken(e){if(!e)return!1;try{let t=e.split(".");if(3!==t.length)return!1;let r=JSON.parse(atob(t[1])),s=Math.floor(Date.now()/1e3);return r.exp-s<=l.REFRESH_THRESHOLD/1e3}catch(e){return!1}}static getGoogleOAuthUrl(){let e=new URLSearchParams({client_id:l.OAUTH.GOOGLE.CLIENT_ID||"",redirect_uri:l.OAUTH.GOOGLE.REDIRECT_URI,response_type:"code",scope:l.OAUTH.GOOGLE.SCOPES.join(" "),access_type:"offline",prompt:"consent"});return"https://accounts.google.com/o/oauth2/v2/auth?".concat(e.toString())}static getGitHubOAuthUrl(){let e=new URLSearchParams({client_id:l.OAUTH.GITHUB.CLIENT_ID||"",redirect_uri:l.OAUTH.GITHUB.REDIRECT_URI,scope:l.OAUTH.GITHUB.SCOPES.join(" "),state:Math.random().toString(36).substring(7)});return"https://github.com/login/oauth/authorize?".concat(e.toString())}static validatePassword(e){let t=[],r=l.PASSWORD_REQUIREMENTS;return e.length<r.MIN_LENGTH&&t.push("Password must be at least ".concat(r.MIN_LENGTH," characters")),e.length>r.MAX_LENGTH&&t.push("Password must be less than ".concat(r.MAX_LENGTH," characters")),r.REQUIRE_UPPERCASE&&!/[A-Z]/.test(e)&&t.push("Password must contain at least one uppercase letter"),r.REQUIRE_LOWERCASE&&!/[a-z]/.test(e)&&t.push("Password must contain at least one lowercase letter"),r.REQUIRE_NUMBERS&&!/\d/.test(e)&&t.push("Password must contain at least one number"),r.REQUIRE_SPECIAL&&!/[!@#$%^&*(),.?":{}|<>]/.test(e)&&t.push("Password must contain at least one special character"),{isValid:0===t.length,errors:t}}static validateUsername(e){let t=[],r=l.USERNAME_REQUIREMENTS;return e.length<r.MIN_LENGTH&&t.push("Username must be at least ".concat(r.MIN_LENGTH," characters")),e.length>r.MAX_LENGTH&&t.push("Username must be less than ".concat(r.MAX_LENGTH," characters")),r.PATTERN.test(e)||t.push("Username can only contain letters, numbers, and underscores"),r.RESERVED_USERNAMES.includes(e.toLowerCase())&&t.push("This username is reserved and cannot be used"),{isValid:0===t.length,errors:t}}static hasRole(e,t){return!!e&&!!(e.role===t||e.additionalRoles&&e.additionalRoles.includes(t))}static isAdmin(e){return this.hasRole(e,"admin")}static isModerator(e){return this.hasRole(e,"moderator")||this.isAdmin(e)}static isJury(e){return this.hasRole(e,"jury_member")||this.isAdmin(e)}static isHackathonAdmin(e){return this.hasRole(e,"hackathon_admin")||this.isAdmin(e)}static getProfilePictureUrl(e){var t;if(!e)return"/images/placeholders/user-placeholder.png";if(e.profile_picture_url)return e.profile_picture_url;if(null===(t=e.profile_picture)||void 0===t?void 0:t.url){let t=e.profile_picture.url;return t.startsWith("http")?t:"".concat("https://aibuildershub.ai/api").concat(t)}return"/images/placeholders/user-placeholder.png"}static getUserStats(e){var t,r,s,a;return{posts:(null==e?void 0:null===(t=e.stats)||void 0===t?void 0:t.posts)||0,drafts:(null==e?void 0:null===(r=e.stats)||void 0===r?void 0:r.drafts)||0,followers:(null==e?void 0:null===(s=e.stats)||void 0===s?void 0:s.followers)||0,following:(null==e?void 0:null===(a=e.stats)||void 0===a?void 0:a.following)||0}}static getSocialLinks(e){return e?{twitter:e.twitter_url,linkedin:e.linkedin_url,github:e.github_url,website:e.website_url,kofi:e.ko_fi_url}:{}}static isAuthenticated(){let e=this.getToken();return!!e&&this.isTokenValid(e)}static getCurrentUser(){return this.isAuthenticated()?this.getUser():null}static extendSession(){let e=this.getUser(),t=this.getToken();e&&t&&this.isTokenValid(t)&&this.setUser(e)}static logout(){this.clearAuth(),window.dispatchEvent(new CustomEvent("auth:logout"))}}window.addEventListener("storage",e=>
1{e.key!==l.STORAGE_KEYS.TOKEN||e.newValue||window.dispatchEvent(new CustomEvent("auth:logout"))}),window.addEventListener("auth:logout",()=>{u.clearAuth(),window.location.pathname.startsWith("/dashboard")&&(window.location.href="/login")});let c={user:null,token:null,isAuthenticated:!1,isLoading:!1,isRefreshing:!1,authMethod:null,error:null,lastUpdated:null},d=(0,s.Ue)()((0,a.mW)((0,a.tJ)((e,t)=>({...c,setUser:t=>e({user:t,lastUpdated:Date.now()}),setToken:t=>e({token:t,lastUpdated:Date.now()}),setLoading:t=>e({isLoading:t}),setRefreshing:t=>e({isRefreshing:t}),setError:t=>e({error:t}),setAuthMethod:t=>e({authMethod:t}),initialize:async()=>{let{token:r}=t(),s=u.getToken(),a=u.getUser();if(!s||!u.isTokenValid(s)){e({isAuthenticated:!1,isLoading:!1,user:null,token:null}),u.clearAuth();return}e({token:s,user:a,isAuthenticated:!0,authMethod:u.getAuthMethod()});try{e({isLoading:!0});let t=(await (0,o.lU)(i.a.me)).data;e({user:t,isAuthenticated:!0,isLoading:!1}),u.setUser(t)}catch(t){e({isAuthenticated:!1,isLoading:!1,user:null,token:null}),u.clearAuth()}},login:async t=>{e({isLoading:!0,error:null});try{let r=(await (0,o.lU)(i.a.login,{identifier:t.identifier,password:t.password})).data;return u.setToken(r.jwt),u.setUser(r.user),u.setAuthMethod("local"),e({user:r.user,token:r.jwt,isAuthenticated:!0,isLoading:!1,authMethod:"local"}),{success:!0}}catch(r){let t=r instanceof Error?r.message:"Login failed";return e({error:t,isLoading:!1}),{success:!1,error:t}}},register:async t=>{e({isLoading:!0,error:null});try{let r=(await (0,o.lU)(i.a.register,t)).data;if(r.jwt&&r.user)return u.setToken(r.jwt),u.setUser(r.user),u.setAuthMethod("local"),e({user:r.user,token:r.jwt,isAuthenticated:!0,isLoading:!1,authMethod:"local"}),{success:!0};return e({isLoading:!1}),{success:!0,requiresVerification:!0,message:"Please check your email to verify your account."}}catch(r){let t=r instanceof Error?r.message:"Registration failed";return e({error:t,isLoading:!1}),{success:!1,error:t}}},logout:async()=>(u.clearAuth(),e(c),Promise.resolve()),getUserStats:()=>{let{user:e}=t();return u.getUserStats(e)},getProfilePictureUrl:()=>{let{user:e}=t();return u.getProfilePictureUrl(e)},isTokenValid:()=>{let{token:e}=t();return!!e&&u.isTokenValid(e)},forgotPassword:async t=>{e({isLoading:!0,error:null});try{return await (0,o.lU)(i.a.forgotPassword,{email:t}),e({isLoading:!1}),{success:!0}}catch(r){let t=r instanceof Error?r.message:"Failed to send reset email";return e({error:t,isLoading:!1}),{success:!1,error:t}}},resetPassword:async(t,r,s)=>{e({isLoading:!0,error:null});try{let a=(await (0,o.lU)(i.a.resetPassword,{code:t,password:r,passwordConfirmation:s})).data;return a.jwt&&a.user&&(u.setToken(a.jwt),u.setUser(a.user),u.setAuthMethod("local"),e({user:a.user,token:a.jwt,isAuthenticated:!0,isLoading:!1,authMethod:"local"})),{success:!0}}catch(r){let t=r instanceof Error?r.message:"Failed to reset password";return e({error:t,isLoading:!1}),{success:!1,error:t}}},changePassword:async(t,r,s)=>{e({isLoading:!0,error:null});try{let a=(await (0,o.lU)(i.a.changePassword,{currentPassword:t,password:r,passwordConfirmation:s})).data;return a.jwt&&(u.setToken(a.jwt),e({token:a.jwt})),e({isLoading:!1}),{success:!0}}catch(r){let t=r instanceof Error?r.message:"Failed to change password";return e({error:t,isLoading:!1}),{success:!1,error:t}}},loginWithGoogle:async()=>(window.location.href="".concat("https://aibuildershub.ai/api","/connect/google"),{success:!0}),loginWithGitHub:async()=>(window.location.href="".concat("https://aibuildershub.ai/api","/connect/github"),{success:!0}),handleOAuthCallback:async(t,r)=>{e({isLoading:!0,error:null});try{u.setToken(t),e({token:t});let s=(await (0,o.lU)(i.a.me)).data;return u.setUser(s),u.setAuthMethod(r),e({user:s,isAuthenticated:!0,isLoading:!1,authMethod:r}),{success:!0,user:s}}catch(r){let t=r instanceof Error?r.message:"OAuth authentication failed";return e({error:t,isLoading:!1}),u.clearAuth(),{success:!1,error:t}}},refreshProfilePicture:async()=>{let{user:r}=t();if(!r)return null;try{e({isRefreshing:!0});let t=(await (0,o.lU)(i.a.me)).data;return e({user:t,isRefreshing:!1}),u.setUser(t),u.getProfilePictureUrl(t)}catch(t){return e({isRefreshing:!1}),null}},updateProfilePictureUrl:r=>{let{user:s}=t();if(!s)return;let a={...s,profile_picture_url:r};e({user:a}),u.setUser(a)},updateUser:r=>{let{user:s}=t();if(!s)return;let a={...s,...r};e({user:a}),u.setUser(a)}
1,fetchUser:async()=>{let{token:r}=t();if(!r||!u.isTokenValid(r))return null;try{let t=(await (0,o.lU)(i.a.me)).data;return e({user:t}),u.setUser(t),t}catch(e){return null}},clearError:()=>e({error:null}),resendEmailConfirmation:async t=>{e({isLoading:!0,error:null});try{return await (0,o.lU)(i.a.sendEmailConfirmation,{email:t}),e({isLoading:!1}),{success:!0}}catch(r){let t=r instanceof Error?r.message:"Failed to send verification email";return e({error:t,isLoading:!1}),{success:!1,error:t}}}}),{name:"auth-storage",partialize:e=>({user:e.user,token:e.token,authMethod:e.authMethod}),onRehydrateStorage:()=>e=>{e&&e.initialize()}}),{name:"auth-store",enabled:!1}))}}]);

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.