PageSourceSearch

https://seedly.sg/_next/static/chunks/pages/auth/keycloak/callback-93ebc0dabf33a51d.js

js seedly.sg collected 2026-09-25 09:52:13 UTC 5,220 bytes, 2 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9292],{86584:function(e,r,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/auth/keycloak/callback",function(){return t(69943)}])},69943:function(e,r,t){"use strict";t.r(r);var a=t(34051),n=t.n(a),s=t(85893),o=t(67294),c=t(11163),i=t(14416),u=t(39666),l=t(45637),d=t(50210),f=t(87955),h=t(31955),p=t(6245);function k(e,r,t,a,n,s,o){try{var c=e[s](o),i=c.value}catch(u){return void t(u)}c.done?r(i):Promise.resolve(i).then(a,n)}r.default=function(){var e=(0,c.useRouter)(),r=(0,i.I0)(),t=(0,o.useState)("processing"),a=t[0],g=t[1],y=(0,o.useState)("Completing login with SingSaver..."),x=y[0],v=y[1];(0,o.useEffect)((function(){var t=!1,a=function(){sessionStorage.removeItem("singsaver_code_verifier")},s=function(){var s,o=(s=n().mark((function s(){var o,c,i,k,y,x,m,b,_,w,N;return n().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!t){n.next=2;break}return n.abrupt("return");case 2:if(n.prev=2,t=!0,o=e.query,c=o.code,i=o.state,!(k=o.error)){n.next=13;break}return console.error("OAuth authorization error:",k),u.Tb(new Error("Keycloak OAuth error: ".concat(k)),{tags:{operation:"keycloak_callback",stage:"oauth_authorization"},extra:{error:k,state:i,query:e.query}}),g("error"),v("Authorization failed. Please try again."),a(),setTimeout((function(){return e.push("/")}),3e3),n.abrupt("return");case 13:if(c){n.next=21;break}return console.error("No authorization code received"),u.Tb(new Error("No authorization code received from Keycloak"),{tags:{operation:"keycloak_callback",stage:"code_validation"},extra:{query:e.query}}),g("error"),v("No authorization code received. Please try again."),a(),setTimeout((function(){return e.push("/")}),3e3),n.abrupt("return");case 21:return(y=sessionStorage.getItem("singsaver_code_verifier"))||console.warn("Code verifier missing from sessionStorage"),x={code:c,state:i,code_verifier:y,codeVerifier:y},n.next=26,fetch("".concat(l.Z.api,"v4/auth/keycloak/callback"),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(x)});case 26:return m=n.sent,n.next=29,m.text();case 29:b=n.sent,n.prev=31,_=JSON.parse(b),n.next=40;break;case 35:throw n.prev=35,n.t0=n.catch(31),console.error("Failed to parse response as JSON:",n.t0),u.Tb(n.t0,{tags:{operation:"keycloak_callback",stage:"response_parsing"},extra:{responseText:b,response:{status:m.status,statusText:m.statusText}}}),new Error("Invalid JSON response from backend");case 40:_.success?(u.n_({message:"Keycloak authentication successful",category:"auth",data:{hasUserData:!!_.data.user,hasTokens:!!_.data.seedly_tokens}}),w=_.data.seedly_tokens,N={"access-token":w["access-token"],client:w.client,uid:w.uid},p.Z.setHeaders(N),h.Z.set(f.B,JSON.stringify(N),{domain:l.Z.domain,secure:!0,expires:30}),g("success"),v("Login successful! Redirecting..."),_.data.user&&r(d.ZP.authUserTokenSuccess(_.data.user)),a(),setTimeout((function(){window.location.href="/"}),1500)):(console.error("Authentication failed:",_.error),u.Tb(new Error("Keycloak authentication failed: ".concat(_.error)),{tags:{operation:"keycloak_callback",stage:"backend_authentication"},extra:{response:_,code:"string"===typeof c?"".concat(c.substring(0,10),"..."):c}}),g("error"),v("Authentication failed. Please try again."),a(),setTimeout((function(){return e.push("/")}),3e3)),n.next=50;break;case 43:n.prev=43,n.t1=n.catch(2),console.error("Network error during callback:",n.t1),u.Tb(n.t1,{tags:{operation:"keycloak_callback",stage:"network_request"},extra:{query:e.query,apiUrl:"".concat(l.Z.api,"v4/auth/keycloak/callback")}}),g("error"),v("Network error. Please try again."),setTimeout((function(){return e.push("/")}),3e3);case 50:return n.prev=50,t=!1,n.finish(50);case 53:case"end":return n.stop()}}),s,null,[[2,43,50,53],[31,35]])})),function(){var e=this,r=arguments;return new Promise((function(t,a){var n=s.apply(e,r);function o(e){k(n,t,a,o,c,"next",e)}function c(e){k(n,t,a,o,c,"throw",e)}o(void 0)}))});return function(){return o.apply(this,arguments)}}();e.isReady&&e.query.code&&s()}),[e.isReady,e.query.code,r,e]);return(0,s.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-gray-50",children:(0,s.jsx)("div",{className:"max-w-md w-full space-y-8",children:(0,s.jsxs)("div",{className:"text-center",children:["processing"===a?(0,s.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500 mx-auto mb-4"}):null,(0,s.jsx)("h2",{className:"mt-6 text-2xl font-bold text-gray-900",children:"SingSaver Login"}),(0,s.jsx)("p",{className:"mt-2 text-sm ".concat(function(){switch(a){case"processing":return"text-blue-500";case"success":return"text-green-500";case"error":return"text-red-500";default:return"text-gray-500"}}()),children:x}),"processing"===a&&(0,s.jsxs)("div",{className:"mt-4 text-xs text-gray-500",children:[(0,s.jsx)("p",{children:"\u2713 Received authorization code"}),(0,s.jsx)("p",{children:"\u2713 Verifying with PKCE..."}),(0,s.jsx)("p",{children:"\u2713 Creating your Seedly account..."})]})]})})})}}},function(e){e.O(0,[9774,2888,179],(function(){return r=86584,e(e.s=r);var r}));var r=e.O();_N_E=r}]);
2//# sourceMappingURL=callback-93ebc0dabf33a51d.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.