PageSourceSearch

https://www.wego.fr/roxana/auth-sdk.f2a4f754.bundle.js

js wego.fr collected 2026-10-08 23:38:19 UTC 19,021 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkroxana=self.webpackChunkroxana||[]).push([[522],{75572(e,t,n){function o(e){const t=new Uint8Array(1);return crypto.getRandomValues(t),t[0]>=Math.floor(256/e)*e?o(e):t[0]%e}function r(e=96){let t="";for(let n=0;n<e;n++)t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(o(62));return t}async function i(e){var t;if(!(null==(t=crypto.subtle)?void 0:t.digest))throw new Error("The context/environment is not secure, and does not support the 'crypto.subtle' module. See: https://developer.mozilla.org/en-US/docs/Web/API/Crypto/subtle");const n=(new TextEncoder).encode(e),o=await crypto.subtle.digest("SHA-256",n),r=String.fromCharCode(...new Uint8Array(o));return btoa(r).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function s(e){try{const t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),n=decodeURIComponent(atob(t).split("").map(e=>`%${e.charCodeAt(0).toString(16).padStart(2,"0")}`).join(""));return JSON.parse(n)}catch(e){throw new Error(`Failed to decode JWT token.\n\tIs it a proper JSON Web Token?\n\t${e.message}`)}}function a(e){if(null==e?void 0:e.length)try{return s(e)}catch(e){console.warn(`Failed to decode access token: ${e.message}`)}}function c(e){if(null==e?void 0:e.length)try{return s(e)}catch(e){console.warn(`Failed to decode idToken: ${e.message}`)}}function l(e){if(!e)return null;const t=e.email??"",n=e.first_name??"",o=e.last_name??"",r=e.principal_name??"";return t||r?{email:t,firstName:n,lastName:o,principalName:r,userHash:e.user_hash??"",idHash:e.id_hash??"",countryCode:e.country_code??"",sub:e.sub??""}:null}function d(e){return"session"===e?sessionStorage:localStorage}function u(e,t){try{const n=t.getItem(e);if(null===n)return;return JSON.parse(n)}catch{return void console.warn(`Failed to parse stored value for '${e}'. Returning undefined.`)}}function f(e,t,n){try{void 0===t?n.removeItem(e):n.setItem(e,JSON.stringify(t))}catch(t){console.error(`Failed to store value for key '${e}':`,t)}}function h(e,t){try{t.removeItem(e)}catch{}}function p(e="local",t="ROCP_"){try{const n=d(e).getItem(`${t}token`);return n?JSON.parse(n):null}catch{return null}}function g(e){return""===e||null==e}function w(e){const t={redirectUri:void 0,autoLogin:!1,clearURL:!0,decodeToken:!0,scope:void 0,preLogin:void 0,postLogin:void 0,loginMethod:"redirect",onRefreshTokenExpire:void 0,onTokenRefresh:void 0,onSessionInvalidated:void 0,onError:void 0,storage:"local",storageKeyPrefix:"ROCP_",refreshWithScope:!0,refreshTokenExpiryStrategy:"renewable",tokenRequestCredentials:"include",...e};return function(e){if(g(e.clientId))throw new Error("'clientId' must be set in AuthClientConfig");if(g(e.authorizationEndpoint))throw new Error("'authorizationEndpoint' must be set in AuthClientConfig");if(g(e.tokenEndpoint))throw new Error("'tokenEndpoint' must be set in AuthClientConfig");if(!["session","local"].includes(e.storage))throw new Error("'storage' must be one of ('session', 'local')");if(e.google&&g(e.google.clientId))throw new Error("'google.clientId' must be set when 'google' is configured in AuthClientConfig")}(t),t}n.r(t),n.d(t,{createAuthClient:()=>U,createInternalConfig:()=>w,decodeAccessToken:()=>a,decodeIdToken:()=>c,decodeJWT:()=>s,extractUser:()=>l,generateCodeChallenge:()=>i,generateCodeVerifier:()=>r,getAuthClient:()=>N,getStoredToken:()=>p,setAuthClient:()=>F});const m=600;function k(e){const t=Number(e),n=Number.isFinite(t)?t:0;return Math.round(Date.now()/1e3+n)}function v(e){return Date.now()/1e3+30>=e}const _=["refresh_expires_in","refresh_token_expires_in"];class y extends Error{constructor(e,t,n){super(t),this.name="AuthError",this.code=e,this.status=null==n?void 0:n.status,this.statusText=null==n?void 0:n.statusText}}class E extends y{constructor(e,t,n){super("fetch_error",n,{status:e,statusText:t}),this.name="FetchError"}}const T="googleOneTapClient";let x=null;function S(){var e;const t=window.google;return(null==(e=null==t?void 0:t.accounts)?void 0:e.id)?t:void 0}function b(){return S()}const $="loginPopup",I="wego-auth:popup-callback";function P(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}const C="ROCP_auth_state";async function R(e,t,n,o="redirect"){const s=d(e.storage),a="replace"===o?"replace":"assign",c=r(96);s.setItem(e.storageKeyPrefix+"PKCE_code_verifier",c);const l=await i(c),u=new URLSearchParams({response_type:"code",client_id:e.clientId,code_challenge:l,code_challenge_method:"S256",...e.extraAuthParameters,...n});void 0===e.scope||u.has("scope")||u.append("scope",e.scope),void 0===e.redirectUri||u.has("redirect_uri")||u.append("redirect_uri",e.redirectUri),s.removeItem(e.storageKeyPrefix+C);const f=t??e.state??r(32);s.setItem(e.storageKeyPrefix+C,f),u.append("state",f);const h=`${e.authorizationEndpoint}?${u.toString()}`;if(e.preLogin&&e.preLogin(),"popup"===o){if(function(e){const{width:t,height:n,left:o,top:r}=function(e=800,t=650){return{left:window.screenLeft+window.innerWidth/2-e/2,top:window.screenTop+window.innerHeight/2-t/2,width:e,height:t}}(800,650);let i;i=P()?e:function(e){const t=`<!DOCTYPE html>\n<html lang="en">\n<head>\n  <title>Wego Auth</title>\n  <meta charset="UTF-8">\n  <style>\n    body {\n      font-family: system-ui, -apple-system, sans-serif;\n      display: flex;\n      align-items: center;\n      justify-content: center;\n      height: 100vh;\n      margin: 0;\n      background: #f5f5f5;\n    }\n    .spinner {\n      border: 3px solid #f3f3f3;\n      border-top: 3px solid #1a8271;\n      border-radius: 50%;\n      width: 40px;\n      height: 40px;\n      animation: spin 1s linear infinite;\n      margin: 0 auto 1rem;\n    }\n    @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }\n    p { color: #555; margin: 0; text-align: center; }\n  </style>\n</head>\n<body>\n  <div><div class="spinner"></div><p>Redirecting...</p></div>\n  <script>\n    try { window.location.replace('${e.replace(/'/g,"\\'")}'); }\n    catch (e) { document.querySelector('p').textContent = 'Redirect failed. Please try again.'; }\n  <\/script>\n</body>\n</html>`,n=new Blob([t],{type:"text/html"});return URL.createObjectURL(n)}(e);const s=window.open(i,$,`popup=true,width=${t},height=${n},left=${o},top=${r}`);return!P()&&i.startsWith("blob:")&&setTimeout(()=>URL.revokeObjectURL(i),1e3),s}(h))return;console.warn("Popup blocked. Falling back to redirect.")}window.location[a](h)}function A(e){let t="";for(const[n,o]of Object.entries(e))t+=`${t?"&":""}${n}=${encodeURIComponent(o)}`;return t}async function L(e,t,n){const o=await fetch(e,{method:"POST",body:A(t),headers:{"Content-Type":"application/x-www-form-urlencoded"},credentials:n});if(!o.ok){const e=await o.text();throw new E(o.status,o.statusText,e)}const r=await o.json();if(void 0!==r.access_token)return r;throw new Error(`Unexpected token response: ${JSON.stringify(r)}`)}function U(e){const t=w(e),n=d(t.storage),o=t.storageKeyPrefix;let r,i=u(`${o}token`,n)??"",p=u(`${o}refreshToken`,n),g=u(`${o}idToken`,n),P=u(`${o}tokenExpire`,n)??k(m),A=u(`${o}refreshTokenExpire`,n),U=u(`${o}loginInProgress`,n)??!1,O=null,F=0,N=null,D=!1,M=!1,j=!1,W=null;const z=new Set;function H(){return c(g)}function J(){return l(H())}function G(){return{token:i,refreshToken:p,idToken:g,tokenData:t.decodeToken?a(i):void 0,idTokenData:H(),user:J(),isAuthenticated:!!i&&!N,isLoading:U||M||null!==O,error:N,tokenExpire:P,refreshTokenExpire:A}}function K(){const e=G();for(const t of z)t(e)}function q(e,t){f(`${o}${e}`,t,n)}function B(e){U=e,q("loginInProgress",e)}function V(){F+=1;const e=["token","refreshToken","idToken","tokenExpire","refreshTokenExpire","loginInProgress","loginMethod","loginProvider","tokenResponse","PKCE_code_verifier","ROCP_auth_state"];for(const t of e)h(`${o}${t}`,n);i="",p=void 0,g=void 0,P=k(m),A=void 0,U=!1}function Y(e){var r;r=e.access_token,i=r,q("token",r),e.id_token&&function(e){g=e,void 0===e?h(`${o}idToken`,n):q("idToken",e)}(e.id_token);const{access_token:a,refresh_token:c,id_token:l,authentication_token:d,...f}=e,w={...u(`${o}tokenResponse`,n)??{},...f};
1delete w.authentication_token,q("tokenResponse",w);let v=m;try{if(e.id_token){const t=s(e.id_token);v=Math.round(Number(t.exp)-Date.now()/1e3)}}catch{}const y=t.tokenExpiresIn??e.expires_in??v;!function(e){P=e,q("tokenExpire",e)}(k(y));const E=t.refreshTokenExpiresIn??function(e,t){for(const e of _){const n=Number(t[e]);if(Number.isFinite(n))return n}return t.refresh_token?e+m:e}(y,e);e.refresh_token&&(function(e){p=e,void 0===e?h(`${o}refreshToken`,n):q("refreshToken",e)}(e.refresh_token),A&&"absolute"===t.refreshTokenExpiryStrategy||function(e){A=e,void 0===e?h(`${o}refreshTokenExpire`,n):q("refreshTokenExpire",e)}(k(E))),N=null}function Q(e,n){return F!==n?null:(Y(e),t.onTokenRefresh&&t.onTokenRefresh(e),e.access_token)}async function X(e){if(!t.refreshAccessTokenEndpoint)return null;try{return Q(await function(e){return e.refreshAccessTokenEndpoint?async function(e,t){const n=await fetch(e,{method:"GET",headers:{Accept:"application/json"},credentials:t});if(!n.ok){const e=await n.text();throw new E(n.status,n.statusText,e)}const o=await n.json();if(void 0!==o.access_token)return o;throw new Error(`Unexpected token response: ${JSON.stringify(o)}`)}(e.refreshAccessTokenEndpoint,e.tokenRequestCredentials):Promise.reject(new Error("refreshAccessTokenEndpoint is not configured"))}(t),e)}catch(e){if(!(e instanceof E)||429===(n=e).status||"number"==typeof n.status&&n.status>=500)throw console.error("Fallback token refresh failed (transient/unknown):",e),e;return console.error("Fallback token refresh rejected:",e),null}var n}function Z(e=!1){if(O)return O;const n=F,o=p,r=te();return O=(async()=>{if(r&&o)try{const e=await function(e,t){const n={grant_type:"refresh_token",refresh_token:t,client_id:e.clientId,...void 0!==e.redirectUri&&{redirect_uri:e.redirectUri},...e.extraTokenParameters};return e.refreshWithScope&&e.scope&&(n.scope=e.scope),L(e.tokenEndpoint,n,e.tokenRequestCredentials)}(t,o);return Q(e,n)}catch(o){if(function(e){if(!e||"object"!=typeof e)return!1;const t=e;if(400!==t.status)return!1;try{return"invalid_grant"===JSON.parse(t.message||"{}").error}catch{return String(t.message).includes("invalid_grant")}}(o)){let e;try{e=await X(n)}catch(e){return console.error("Token refresh failed:",e),N=e instanceof Error?e.message:String(e),null}return e||(F!==n||(V(),t.onSessionInvalidated&&t.onSessionInvalidated("invalid_grant")),null)}return console.error("Token refresh failed:",o),N=o instanceof Error?o.message:String(o),e&&t.autoLogin&&oe({method:t.loginMethod}),null}let i;try{i=await X(n)}catch(e){return console.error("Token refresh failed:",e),N=e instanceof Error?e.message:String(e),null}return i||(F!==n||(V(),K(),t.onRefreshTokenExpire?t.onRefreshTokenExpire():t.onSessionInvalidated&&t.onSessionInvalidated("refresh_token_expired")),null)})().finally(()=>{O=null,K()}),K(),O}async function ee(){return i||p?O?(await O,i&&!v(P)?i:null):i&&!v(P)?i:p||t.refreshAccessTokenEndpoint?(await Z(),i&&!v(P)?i:null):i&&!v(P)?i:null:null}function te(){return!(!p||A&&v(A))}function ne(){r&&clearInterval(r);const e=1e4*Math.random();r=setInterval(()=>{i&&v(P)&&Z()},5e3+e)}function oe(e){const n=(null==e?void 0:e.method)??t.loginMethod;V(),D=!1,B(!0),K(),R(t,null==e?void 0:e.state,null==e?void 0:e.additionalParameters,n).catch(e=>{console.error(e),N=e.message,B(!1),K()})}function re(e,n){try{!function(e,t,n){const o=d(t);if(e.get("state")!==o.getItem(n+C))throw new Error('"state" value received from authentication server does not match client request. Possible cross-site request forgery.')}(e,t.storage,o)}catch(e){return console.error(e),N=e.message,V(),void K()}(function(e,t){const n=d(e.storage),o=t??new URLSearchParams(window.location.search).get("code"),r=n.getItem(e.storageKeyPrefix+"PKCE_code_verifier");if(!o)throw new Error("Parameter 'code' not found in URL. Has authentication taken place?");if(!r)throw new Error("Can't get tokens without the CodeVerifier. Has authentication taken place?");const i={grant_type:"authorization_code",code:o,client_id:e.clientId,...void 0!==e.redirectUri&&{redirect_uri:e.redirectUri},code_verifier:r,...e.extraTokenParameters};return L(e.tokenEndpoint,i,e.tokenRequestCredentials)})(t,n).then(async e=>{Y(e),t.postLogin&&await t.postLogin(e),window.opener&&window.name===$&&window.close()}).catch(e=>{console.error(e),N=e.message}).finally(()=>
1{if(t.clearURL){const e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("state"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}B(!1),ne(),K()})}function ie(){return!!i&&!N}function se(e){var t;e.storageArea===n&&(null==(t=e.key)?void 0:t.startsWith(o))&&(i=u(`${o}token`,n)??"",p=u(`${o}refreshToken`,n),g=u(`${o}idToken`,n),P=u(`${o}tokenExpire`,n)??k(m),A=u(`${o}refreshTokenExpire`,n),U=u(`${o}loginInProgress`,n)??!1,K())}function ae(e){if(e.origin!==window.location.origin)return;const t=e.data;if(!t||t.type!==I||!t.code)return;if(!U||D)return;D=!0;const n=new URLSearchParams;n.set("code",t.code),null!=t.state&&n.set("state",t.state),re(n,t.code)}function ce(){V(),t.onSessionInvalidated&&t.onSessionInvalidated("refresh_token_expired"),K()}async function le(e){M=!0,K();try{const n=await function(e,t,n){const o={grant_type:"password",client_id:e.clientId,provider:"google",provider_access_token:n,...void 0!==e.scope&&{scope:e.scope},...e.extraTokenParameters};return L(e.tokenEndpoint,o,e.tokenRequestCredentials)}(t,0,e);return V(),Y(n),q("loginProvider","google"),t.postLogin&&await t.postLogin(n),ne(),M=!1,K(),G()}catch(e){throw console.error("Google sign-in failed:",e),N=e instanceof Error?e.message:String(e),M=!1,K(),e}}async function de(e){const n=function(e){const n=function(){if(!t.google)throw new y("configuration_error","'google' must be configured in AuthClientConfig to use Google Sign-In");return t.google}(),o=(null==e?void 0:e.cancelOnTapOutside)??n.cancelOnTapOutside,r=(null==e?void 0:e.promptParentId)??n.promptParentId;return{client_id:n.clientId,auto_select:(null==e?void 0:e.autoSelect)??n.autoSelect??!1,context:(null==e?void 0:e.context)??n.context??"signin",itp_support:n.itpSupport??!0,use_fedcm_for_prompt:n.useFedcmForPrompt??!0,...void 0!==o&&{cancel_on_tap_outside:o},...void 0!==r&&{prompt_parent_id:r},...void 0!==n.stateCookieDomain&&{state_cookie_domain:n.stateCookieDomain},...void 0!==n.nonce&&{nonce:n.nonce},callback:e=>{ue=!1,le(e.credential).catch(()=>{})}}}(e),o=await(x||(x=new Promise((e,t)=>{const n=S();if(n)return void e(n);let o=document.getElementById(T);o||(o=document.createElement("script"),o.id=T,o.async=!0,o.defer=!0,o.src="https://accounts.google.com/gsi/client",document.head.appendChild(o)),o.addEventListener("load",()=>{const n=S();n?e(n):(x=null,t(new y("network_error","Google Identity Services script loaded but google.accounts.id is unavailable")))}),o.addEventListener("error",()=>
1{x=null,null==o||o.remove(),t(new y("network_error","Failed to load Google Identity Services script"))})}),x));return o.accounts.id.initialize(n),o}window.addEventListener("storage",se),window.addEventListener("message",ae);let ue=!1;return{login:oe,logout:function(e){var r;if(!t.logoutEndpoint)throw new Error("'logoutEndpoint' must be configured to perform logout redirect");const s=i,a=p,c=g,l=u(`${o}loginProvider`,n),d=!(!s&&!a);V(),d&&(f(`${o}logoutAt`,Date.now(),n),j=!0),N=null,K(),"google"===l&&(null==(r=b())||r.accounts.id.disableAutoSelect()),(s||a)&&function(e,t,n,o,r,i,s){const a=new URLSearchParams({token:n||t,token_type_hint:n?"refresh_token":"access_token",client_id:e.clientId,ui_locales:window.navigator.languages.join(" "),...e.extraLogoutParameters,...s});o&&a.append("id_token_hint",o),r&&a.append("state",r),i&&a.append("logout_hint",i);const c=e.logoutRedirect??e.redirectUri;if(c&&a.append("post_logout_redirect_uri",c),!e.logoutEndpoint)throw new Error("'logoutEndpoint' must be configured to perform logout redirect");window.location.assign(`${e.logoutEndpoint}?${a.toString()}`)}
1(t,s,a,c,null==e?void 0:e.state,null==e?void 0:e.logoutHint,null==e?void 0:e.additionalParameters)},handleCallback:function(){const e=new URLSearchParams(window.location.search);if("true"===e.get("re-authenticate"))return void function(){V(),D=!1,N=null;const e=new URLSearchParams(window.location.search);e.delete("re-authenticate");const n=e.toString(),o=window.location.pathname+(n?`?${n}`:"")+window.location.hash;B(!0),K(),R(t,void 0,{redirect_path:o},"redirect").catch(e=>{console.error(e),N=e.message,B(!1),K()})}();const n=e.has("code");if(U&&!n){const t=e.get("error_description")||"Bad authorization state. Refreshing the page and logging in again might solve the issue.";return console.error(t),N=t,V(),void K()}if(n){if(window.opener&&window.name===$){const t={type:I,code:e.get("code")??"",state:e.get("state")};try{window.opener.postMessage(t,window.location.origin)}catch{window.opener.location.href=window.location.href}return void window.close()}D||(D=!0,re(e))}else i||!t.autoLogin?(i&&v(P)&&Z(!0),ne(),K()):oe({method:t.loginMethod})},getState:G,getToken:function(){return i||null},getTokenResponseMetadata:function(){return u(`${o}tokenResponse`,n)??null},getUser:J,isAuthenticated:ie,subscribe:function(e){return z.add(e),()=>z.delete(e)},destroy:function(){r&&clearInterval(r),z.clear(),window.removeEventListener("storage",se),window.removeEventListener("message",ae)},getAuthHeaders:function(){return i?{Authorization:`Bearer ${i}`}:{}},authenticatedFetch:async function(e,n){const o=await ee(),r=new Headers(null==n?void 0:n.headers);o&&r.set("Authorization",`Bearer ${o}`);const s=await fetch(e,{...n,headers:r});if(401!==s.status)return s;if(!p&&!t.refreshAccessTokenEndpoint)return ce(),s;const a=await Z();if(!a)return i?ce():K(),s;const c=new Headers(null==n?void 0:n.headers);c.set("Authorization",`Bearer ${a}`);const l=await fetch(e,{...n,headers:c});return 401===l.status&&ce(),l},getValidAccessToken:ee,hasRefreshToken:function(){return!!p},invalidateSession:function(e="refresh_token_expired"){V(),t.onSessionInvalidated&&t.onSessionInvalidated(e),K()},refreshAccessToken:Z,signInWithGoogleCredential:le,promptGoogleOneTap:async function(e,r){var i,s;if(!ue&&(!(null==(i=t.google)?void 0:i.shouldPrompt)||t.google.shouldPrompt())&&!ie()&&!te()&&!function(){if(j)return!0;if(null!==W)return Date.now()-W<6e4;const e=u(`${o}logoutAt`,n);if("number"!=typeof e)return!1;h(`${o}logoutAt`,n);const t=Date.now()-e;return!(t<0||t>=6e4||(W=Date.now(),0))}()){ue=!0;try{const n=await de(e),o=(null==(s=t.google)?void 0:s.useFedcmForPrompt)??!0;n.accounts.id.prompt(e=>{(o?e.isDismissedMoment():e.isSkippedMoment()||e.isDismissedMoment()||e.isNotDisplayed())&&(ue=!1),r&&r(e)})}catch(e){throw ue=!1,e}}},renderGoogleButton:async function(e,t,n){(await de(n)).accounts.id.renderButton(e,t??{})},cancelGoogleOneTap:function(){var e;ue=!1,null==(e=b())||e.accounts.id.cancel()}}}let O=null;function F(e){O=e}function N(){return O}}}]);

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.