@aiquants/auth-react-router 0.38.0 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +133 -55
- package/dist/admin.d.mts +6 -4
- package/dist/admin.d.ts +6 -4
- package/dist/admin.js +1 -1
- package/dist/admin.mjs +1 -1
- package/dist/client.js +1 -1
- package/dist/client.mjs +1 -1
- package/dist/server.d.mts +55 -18
- package/dist/server.d.ts +55 -18
- package/dist/server.js +1 -1
- package/dist/server.mjs +1 -1
- package/dist/styles/auth-react-router.standalone.css +1 -1
- package/package.json +4 -4
package/dist/server.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{GOOGLE_PROVIDER as Fe}from"@aiquants/auth-core";import{redirect as Se}from"react-router";import{GOOGLE_PROVIDER as Pe}from"@aiquants/auth-core";var Ge="https://oauth2.googleapis.com/revoke",ue=5e3,j=2147483647,Ee="invalid_token",_e=400,de=e=>{if(e===void 0)return ue;if(!Number.isInteger(e)||e<1||e>j)throw new RangeError(`google.revocationTimeoutMs must be an integer from 1 to ${j} (milliseconds); got ${String(e)}`);return e},be=e=>{if(typeof e.refreshToken=="string"&&e.refreshToken!=="")return e.refreshToken;if(typeof e.accessToken=="string"&&e.accessToken!=="")return e.accessToken},Oe=async e=>{let t=await e.json().catch(()=>{});return typeof t=="object"&&t!==null&&"error"in t&&typeof t.error=="string"?t.error:void 0},Ie=e=>e instanceof Error?e.cause instanceof Error?`${e.message} (${e.cause.message})`:e.message:String(e),xe=async(e,t,n)=>{try{let r=await t(Ge,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({token:e}).toString(),signal:n});if(r.ok)return await r.body?.cancel(),{outcome:"revoked"};let a=await Oe(r);return r.status===_e&&a===Ee?{outcome:"already-invalid"}:{outcome:"failed",reason:a===void 0?`Google answered ${r.status}`:`Google answered ${r.status} ${a}`}}catch(r){return{outcome:"failed",reason:Ie(r)}}},le=async(e,t)=>{if(e===void 0)return{outcome:"nothing-to-revoke"};let n=be(e);if(n===void 0)return{outcome:"nothing-to-revoke"};if(e.provider!==Pe)return{outcome:"failed",reason:`the session's provider "${String(e.provider)}" has no revocation endpoint`};let r=new AbortController;return await new Promise(a=>{let v=setTimeout(()=>{a({outcome:"failed",reason:`Google did not answer within ${t.timeoutMs} ms`}),r.abort()},t.timeoutMs);xe(n,t.fetch,r.signal).then(A=>{clearTimeout(v),a(A)})})};var N="generation",he=15e3,ge=3e3,Ne=6e4,H=class extends Error{constructor(t,n){super(t,n),this.name="SessionGenerationUnavailableError"}},x=e=>typeof e=="string"?JSON.stringify(e):typeof e=="function"?"a function":typeof e=="object"&&e!==null?Array.isArray(e)?"an array":"an object":typeof e=="bigint"?`${e}n`:String(e),Ue=e=>{if(typeof e!="object"||e===null||Array.isArray(e))return x(e);let t="store"in e?e.store:void 0;if(typeof t!="object"||t===null)return`an object whose store is ${x(t)}`;let n="current"in t?t.current:void 0,r="advance"in t?t.advance:void 0;return`an object whose store.current is ${x(n)} and store.advance is ${x(r)}`},Le=e=>typeof e=="object"&&e!==null&&"current"in e&&typeof e.current=="function"&&"advance"in e&&typeof e.advance=="function",fe=(e,t,n,r)=>{if(t===void 0)return r;if(typeof t!="number"||!Number.isInteger(t)||t<n||t>j)throw new RangeError(`${e} must be an integer from ${n} to ${j} (milliseconds); got ${x(t)}`);return t},Me=e=>{if(e===!1)return!1;let t=e;if(typeof t!="object"||t===null||!("store"in t)||!Le(t.store))throw new TypeError(`sessionGeneration must be { store, cacheTtlMs?, timeoutMs? } or false; got ${Ue(t)}`);return{store:t.store,cacheTtlMs:fe("sessionGeneration.cacheTtlMs","cacheTtlMs"in t?t.cacheTtlMs:void 0,0,he),timeoutMs:fe("sessionGeneration.timeoutMs","timeoutMs"in t?t.timeoutMs:void 0,1,ge)}},$=e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>=0,X=e=>typeof e.provider=="string"&&e.provider!==""&&typeof e.id=="string"&&e.id!=="",pe=e=>new TypeError(`a session generation identity needs a non-empty provider and id; got provider ${x(e.provider)} and id ${x(e.id)}`),Ce=e=>$(e)&&$(e+1),$e=e=>new TypeError(`a session generation advance needs the signed-out session's stamp, an integer from 0 to ${Number.MAX_SAFE_INTEGER-1}; got ${x(e)}`),M=e=>({provider:e.provider,id:e.id}),me=(e,t)=>{let n=Me(e);if(n===!1)return null;let{store:r,cacheTtlMs:a,timeoutMs:v}=n,A=new Map,G=new Map,m=new Map,w=new Map,T=Number.NEGATIVE_INFINITY,s=c=>`${c.provider}\0${c.id}`,u=(c,o)=>{let p=A.get(c);if(p!==void 0){if(o-p.at<a)return p;A.delete(c)}},i=(c,o,p)=>{if(p!==void 0&&o.at<=p.answeredAt&&o.value<p.value)return;let P=u(c,performance.now());if(P===void 0){A.set(c,o);return}o.value<P.value||A.set(c,{value:o.value,at:Math.max(P.at,o.at)})},d=c=>{let o=w.get(c);if(o!==void 0)return o.count+=1,o;let p={count:1,floor:void 0};return w.set(c,p),p},h=(c,o)=>{o.count-=1,o.count===0&&w.delete(c)},S=(c,o)=>{c.floor={value:c.floor===void 0?o:Math.max(c.floor.value,o),answeredAt:performance.now()}},y=(c,o)=>{let p=m.get(c);return p===void 0?!1:o<p?!0:(m.delete(c),!1)},k=(c,o)=>{let p=performance.now();return m.set(c,p+a),p-T>=Ne&&(T=p,t.warn("Session generation store unavailable; skipping the sign-out generation check:",o)),"unavailable"},g=(c,o,p)=>new Promise((P,_)=>{let{operation:E}=c,O=c.operation==="advance"?c.from+1:0,Te=performance.now(),D=d(p),L=!1,ce=setTimeout(()=>{L=!0,P({kind:"unavailable",error:new H(`sessionGeneration.store.${E} did not settle within ${v} ms`)})},v);new Promise(b=>b(c.operation==="advance"?r.advance(o,c.from):r.current(o))).then(b=>{if(clearTimeout(ce),!($(b)&&b>=O)){h(p,D),L||(L=!0,_(new TypeError(`sessionGeneration.store.${E} must resolve to an integer >= ${O}; got ${x(b)}`)));return}E==="advance"&&(S(D,b),G.delete(p)),i(p,{value:b,at:Te},D.floor),h(p,D),!L&&(L=!0,m.delete(p),P({kind:"value",value:b}))},b=>{if(clearTimeout(ce),h(p,D),!L){if(L=!0,b instanceof H){P({kind:"unavailable",error:b});return}_(b)}})}),f=(c,o,p)=>{let P=G.get(o);if(P!==void 0&&p-P.startedAt<a)return P.read;let _={read:g({operation:"current"},c,o),startedAt:p};G.set(o,_);let E=()=>{G.get(o)===_&&G.delete(o)};return _.read.then(E,E),_.read},l=async(c,o,p)=>{let P=await g({operation:"current"},c,o);return P.kind==="unavailable"?k(o,P.error):p===P.value?"current":"stale"};return{check:async(c,o)=>{if(!($(o)&&X(c)))return"stale";let p=performance.now(),P=s(c),_=u(P,p);if(_!==void 0){if(o===_.value)return"current";if(o<_.value)return"stale"}if(y(P,p))return"unavailable";if(_!==void 0)return await l(c,P,o);let E=await f(c,P,p);return E.kind==="unavailable"?k(P,E.error):o===E.value?"current":o<E.value?"stale":await l(c,P,o)},stamp:async c=>{if(!X(c))throw pe(c);let o=await g({operation:"current"},c,s(c));if(o.kind==="unavailable")throw o.error;return o.value},advance:async(c,o)=>{if(!X(c))return{kind:"failed",error:pe(c)};if(!Ce(o))return{kind:"failed",error:$e(o)};try{let p=await g({operation:"advance",from:o},c,s(c));return p.kind==="value"?{kind:"advanced",generation:p.value}:{kind:"unavailable",error:p.error}}catch(p){return{kind:"failed",error:p}}}}};var C=class extends Error{constructor(t){super(t),this.name="TokenRefreshError"}},K=class extends C{constructor(){super("Google refresh token invalid or revoked"),this.name="GoogleInvalidGrantError"}},F=class extends Error{constructor(t){super("Authentication required"),this.name="AuthRequiredError",this.setCookie=t}},qe=["access_token","expires_in"],B=(e,t,n)=>{let r=e.loginPath??"/auth/login",a=t.sessionKey,v=async m=>{let T=m.get(a)?.refreshToken;if(!T)throw new Error("Refresh token not found in session");try{let s="https://www.googleapis.com/oauth2/v4/token",u={client_id:e.google.clientId,client_secret:e.google.clientSecret,grant_type:"refresh_token",refresh_token:T},d=await(e.fetch??globalThis.fetch)(s,{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify(u)});if(!d.ok){let g=await d.json().catch(()=>{});if(d.status===400&&typeof g=="object"&&!!g&&"error"in g&&g.error==="invalid_grant")throw new K;let l=typeof g=="object"&&g&&"error_description"in g?String(g.error_description):"Unknown error";throw new C(`Google token refresh failed: ${d.status} ${l}`)}let h=await d.json(),S=qe.filter(g=>!h?.[g]);if(S.length>0)throw n.error("Invalid token response from Google; missing or empty keys:",S.join(", ")),new Error("Invalid token response from Google");let{access_token:y,expires_in:k}=h;return{accessToken:y,refreshToken:T,expirationDateMs:Number(Date.now())+k*1e3}}catch(s){if(s instanceof C)throw s;let u=s instanceof Error?s.message:"Unknown error";throw new C(`Failed to refresh Google access token: ${u}`)}},A=async m=>{let T=m.get(a).provider;if(!T)throw new Error("Provider not found in session");if(T===Fe)return await v(m);throw new Error("Provider not supported")};return{authenticate:async(m,w,T)=>{let{failureRedirect:s}=T||{},u=i=>{if(s===null)return new F(i);if(s==="")throw new TypeError("failureRedirect must not be an empty string; pass null to skip redirecting");let d=s??r;return i!==void 0?Se(d,{headers:{"Set-Cookie":i}}):Se(d)};try{if(e.mockUser?.enabled(m)){let{accessToken:k,refreshToken:g,expirationDateMs:f}=e.mockUser.resolve(m);return{accessToken:k,refreshToken:g,expirationDateMs:f}}let i=w.get(a),d=t.sessionGenerationGate;if(i!==void 0&&d!==null&&await d.check(M(i),w.get(N))==="stale")throw u(await t.destroySession(w));if(!(i?.accessToken&&i.expirationDateMs))throw u();let{accessToken:h,refreshToken:S,expirationDateMs:y}=i;if(y<Date.now())throw S?new Error("Expired"):u();return{accessToken:h,refreshToken:S,expirationDateMs:y}}catch(i){if(i instanceof Error&&i.message==="Expired")try{let d=await A(w),h=w.get(a);return w.set(a,{...h,...d}),d}catch(d){if(d instanceof K)n.warn("Google refresh token invalid or revoked");else{let S=d instanceof Error?d.message:"Unknown error";n.error("Failed to refresh token:",S)}let h=await t.destroySession(w);throw u(h)}throw i}},refreshedAccessToken:A}};import{redirect as ye}from"react-router";var V=({refreshToken:e,...t})=>t;var Q=(e,t,n,r)=>{let a=new Map,v=new Map,A=async s=>{let u=JSON.stringify([s.provider,s.id]),i=a.get(u);if(i!==void 0)return i;let d=v.get(u);if(d!==void 0)return d;let h=(async()=>{try{let S=e.getUserPhoto?await e.getUserPhoto(s):"";return a.set(u,S),S}catch(S){throw a.delete(u),S}finally{v.delete(u)}})();return v.set(u,h),h},G=new WeakMap,m=async s=>{e.warmup&&await e.warmup();let u=await t.resolveSession(s);if(u.kind==="revoked")return{kind:"unauthenticated",cookie:await t.destroySession(u.session)};if(u.kind!=="signed-in")return{kind:"unauthenticated"};let{user:i,session:d}=u,h;try{h=await n.authenticate(s,d,{failureRedirect:null})}catch(R){if(R instanceof F)return R.setCookie!==void 0?{kind:"unauthenticated",cookie:R.setCookie}:{kind:"unauthenticated"};throw r.error("Error in authenticateInLoader:",R),R}let S={accessToken:h.accessToken,refreshToken:h.refreshToken,expirationDateMs:h.expirationDateMs,provider:i.provider},y={id:i.id,displayName:i.displayName,name:i.name,emails:i.emails,...S,role:i.role},k=await A(i),g=V({...i,...S,photo:k}),l=h.accessToken!==i.accessToken?await t.saveSession(s,y):void 0;return l!==void 0?{kind:"authenticated",user:g,cookie:l}:{kind:"authenticated",user:g}},w=s=>{let u=G.get(s);if(u!==void 0)return u;let i=m(s);return G.set(s,i),i};async function T(s,u){let{failureRedirect:i}=u;if(i==="")throw new TypeError("failureRedirect must not be an empty string; pass null to skip redirecting");let d=await w(s);if(d.kind==="authenticated")return d.cookie!==void 0?{user:d.user,cookie:d.cookie}:{user:d.user};if(i===null)return d.cookie!==void 0?{cookie:d.cookie}:{};throw d.cookie!==void 0?ye(i,{headers:{"Set-Cookie":d.cookie}}):ye(i)}return T};import{GOOGLE_PROVIDER as Ve,resolveAuthMessages as Ye}from"@aiquants/auth-core";import{redirect as W}from"react-router";import{Authenticator as Je}from"remix-auth";import{OAuth2Strategy as De}from"remix-auth-oauth2";var je=["openid","https://www.googleapis.com/auth/userinfo.profile","https://www.googleapis.com/auth/userinfo.email"],He="google",Ke="https://www.googleapis.com/oauth2/v3/userinfo",Y=class extends De{constructor({clientId:n,clientSecret:r,redirectURI:a,scopes:v,accessType:A,includeGrantedScopes:G,prompt:m,hd:w,loginHint:T,additionalScopes:s},u){let i=v??je;super({clientId:n,clientSecret:r,redirectURI:a,authorizationEndpoint:"https://accounts.google.com/o/oauth2/v2/auth",tokenEndpoint:"https://oauth2.googleapis.com/token",scopes:i},u);this.name=He;this.scopes=i,this.accessType=A??"online",this.includeGrantedScopes=G??!1,this.prompt=m,this.hd=w,this.loginHint=T,this.additionalScopes=s}authorizationParams(n,r){n.set("access_type",this.accessType),n.set("include_granted_scopes",String(this.includeGrantedScopes));let a=r===void 0||this.additionalScopes===void 0?[]:this.additionalScopes(r);for(let A of a)if(A===""||/\s/u.test(A))throw new RangeError(`[auth-react-router] an additional scope must be a non-empty string without white space; got ${JSON.stringify(A)}`);let v=[...new Set([...this.scopes,...a])];return v.length>0&&n.set("scope",v.join(" ")),this.prompt&&n.set("prompt",this.prompt),this.hd&&n.set("hd",this.hd),this.loginHint&&n.set("login_hint",this.loginHint),n}static async userProfile(n){let r=await fetch(Ke,{headers:{Authorization:`Bearer ${n.accessToken()}`}});if(!r.ok)throw new Error(`Failed to fetch user profile: ${r.statusText}`);let a=await r.json();return{id:a.sub,displayName:a.name,name:{familyName:a.family_name,givenName:a.given_name},emails:[{value:a.email}],photos:[{value:a.picture}],_json:a}}};var q={info:(...e)=>console.info("[Auth]",...e),warn:(...e)=>console.warn("[Auth]",...e),error:(...e)=>console.error("[Auth]",...e)};var Z=e=>{let t=e.logger??q,n=Ye(e.messages),r=e.loginPath??"/auth/login",a=new Y({clientId:e.google.clientId,clientSecret:e.google.clientSecret,redirectURI:e.google.redirectURI,scopes:e.google.scopes,accessType:e.google.accessType??"offline",includeGrantedScopes:e.google.includeGrantedScopes??!0,prompt:e.google.prompt??"consent",additionalScopes:e.google.additionalScopes},async({request:A,tokens:G})=>{let{access_token:m,refresh_token:w,expires_in:T,scope:s,id_token:u}=G.data,{_json:{sub:i,email:d,picture:h,hd:S,email_verified:y},photos:k,...g}=await Y.userProfile(G),{id:f,displayName:l,name:{familyName:R,givenName:I},emails:U}=g,c=Ve;if(m===void 0||w===void 0||T===void 0||s===void 0||f===void 0||l===void 0||i===void 0||d===void 0||y===void 0){if(y===!1){let p=encodeURIComponent(n.emailNotVerified);throw W(`${r}?error=${p}`)}let o=encodeURIComponent(n.googleFailed);throw W(`${r}?error=${o}`)}t.info("Authenticated on Google: ",g.displayName);try{if(e.backendAuth){if(!await e.backendAuth.verify(c,m)){t.error("Backend verification returned false for user:",g.displayName);let O=encodeURIComponent(n.backendFailed);throw W(`${r}?error=${O}`)}t.info("Authenticated on Backend: ",g.displayName)}let o=g.emails[0]?.value;if(!await e.isEmailAllowed(o)){let E=new Error("You are not allowed to access this application");throw t.error(E),E}if(e.isUserActive&&!await e.isUserActive({...g,provider:c})){let E=new Error("You are not allowed to access this application");throw t.error("Deactivated account attempted to sign in:",o),E}e.backendAuth&&await e.backendAuth.signup(c,m,g),t.info("Authenticated complete: ",g.displayName);let p=Date.now()+T*1e3;return{...g,...{accessToken:m,refreshToken:w,expirationDateMs:p,provider:c},photo:h}}catch(o){let p=o;typeof o=="object"&&o!==null&&"cause"in o&&(p=o.cause||o),t.error("Error during backend authentication or subsequent processing:",p);let P=n.unexpected,_=!1;if(typeof o=="object"&&o!==null&&"cause"in o){let O=o.cause;O&&typeof O=="object"&&"message"in O&&typeof O.message=="string"&&O.message.includes("getaddrinfo ENOTFOUND")&&(P=n.backendUnreachable,_=!0)}if(!_&&o instanceof Error&&o.message.includes("You are not allowed to access this application")&&(P=n.notAllowed,_=!0),!_&&o instanceof Response&&o.headers.get("Location")?.startsWith(r))throw o;let E=encodeURIComponent(P);throw W(`${r}?error=${E}`)}}),v=new Je;return v.use(a),v};import{redirect as J}from"react-router";var ee="returnTo",z=(e,t)=>{let n=e.indexOf("?"),r=n===-1?e:e.slice(0,n),a=new URLSearchParams(n===-1?"":e.slice(n+1));return a.set(ee,t),`${r}?${a.toString()}`};import{createCookie as We}from"react-router";var ze="__return_to.",Xe=300,we=/^[A-Za-z0-9_-]{1,128}$/,ke="https://return-to.invalid",ve=Object.freeze({path:void 0,deletion:void 0}),Be=e=>{if(e.includes("%"))return!1;let t=new URL(e,ke);return t.origin===ke&&t.pathname===e},Qe=e=>{if(e===void 0)return new Set;let t=e;if(typeof t!="object"||t===null||!Array.isArray(t.allowedPaths))throw new TypeError(`returnTo must be { allowedPaths: string[] }; got ${JSON.stringify(t)}`);let n=t.allowedPaths;if(n.length===0)throw new RangeError("returnTo.allowedPaths must name at least one path; omit returnTo to allow none");for(let r of n){if(typeof r!="string")throw new TypeError(`returnTo.allowedPaths must hold strings; got ${JSON.stringify(r)}`);if(!Be(r))throw new RangeError(`returnTo.allowedPaths must hold canonical same-origin paths (one leading "/", no query, fragment, percent-encoding, backslash, white space, control or non-ASCII character, or dot segment); got ${JSON.stringify(r)}`)}return new Set(n)},Ze=()=>new Response("The sign-in's return-to is not a path this application allows.",{status:400,headers:{"Content-Type":"text/plain; charset=utf-8","Cache-Control":"no-store"}}),et=(e,t)=>e===null?!1:e.split(";").some(n=>n.trim().startsWith(`${t}=`)),te=(e,t)=>new Response(e.body,{status:e.status,statusText:e.statusText,headers:t}),Re=(e,t,n,r)=>{let a=Qe(e),v=s=>We(`${ze}${s}`,{secrets:[...t.secrets],httpOnly:!0,sameSite:"lax",path:"/",secure:t.secure,maxAge:Xe}),A=(s,u,i)=>{let d=s.headers.get("Location");if(d===null)return s;let h=new URL(d,i.url);if(h.origin!==new URL(i.url).origin||h.pathname!==n)return s;let S=new Headers(s.headers);return S.set("Location",`${z(`${h.pathname}${h.search}`,u)}${h.hash}`),te(s,S)};return{requested:s=>{let u=new URL(s.url).searchParams.getAll(ee);if(u.length!==0){if(u.length===1&&a.has(u[0]))return u[0];throw Ze()}},bindToFlow:async(s,u,i)=>{let d=s.headers.get("Location"),h=d===null?null:new URL(d,i.url).searchParams.get("state");if(h===null)return A(s,u,i);if(!we.test(h))throw new Error(`The authorization redirect's state cannot name the return-to cookie; got ${JSON.stringify(h)}`);let S=new Headers(s.headers);return S.append("Set-Cookie",await v(h).serialize(u)),te(s,S)},flowOf:async s=>{let u=new URL(s.url).searchParams.get("state");if(u===null||!we.test(u))return ve;let i=v(u),d=s.headers.get("Cookie");if(!et(d,i.name))return ve;let h=await i.serialize("",{maxAge:0}),S=await i.parse(d);return typeof S=="string"&&a.has(S)?{path:S,deletion:h}:(r.warn(`The sign-in's return-to cookie ${i.name} names no allowed path; the sign-in returns to the post-login path instead`),{path:void 0,deletion:h})},endFailedFlow:(s,u,i)=>{if(u.deletion===void 0)return s;let d=u.path===void 0?s:A(s,u.path,i),h=new Headers(d.headers);return h.append("Set-Cookie",u.deletion),te(d,h)}}};import{createCookieSessionStorage as tt,redirect as ne}from"react-router";var Ae=3600*24*30,nt=e=>{if(e===void 0)return Ae;if(!Number.isSafeInteger(e)||e<1)throw new RangeError(`session.maxAge must be a safe integer of seconds >= 1; got ${String(e)}`);return e},oe=e=>e.secure??process.env.NODE_ENV==="production",re=(e,t)=>{if(!e.secrets||e.secrets.length===0||e.secrets.some(y=>!y))throw new Error("REMIX_SESSION_SECRET must be set");let n=e.sessionKey??"user";if(n===N)throw new RangeError(`session.sessionKey must not be ${JSON.stringify(N)}, the key the session generation is stored under; got ${JSON.stringify(n)}`);let r=nt(e.maxAge),a=t.loginPath??"/auth/login",v=t.postLoginRedirect??"/",A=t.mockUser,G=t.isUserActive,m=me(t.sessionGeneration,t.logger??q),w=tt({cookie:{name:e.cookieName??"__session",httpOnly:!0,path:"/",sameSite:"lax",secrets:e.secrets,secure:oe(e),maxAge:r}}),T=async y=>await w.getSession(y.headers.get("Cookie")),s=async y=>{if(A?.enabled(y))return{kind:"signed-in",user:V(A.resolve(y)),session:await T(y)};let k=await T(y),g=k.get(n);if(g===void 0)return{kind:"signed-out"};let f=V(g),[l,R]=await Promise.all([G===void 0?!0:G(f),m===null?"current":m.check(M(g),k.get(N))]);return R==="stale"?{kind:"revoked",session:k}:l?{kind:"signed-in",user:f,session:k}:{kind:"inactive"}},u=async y=>{let k=await s(y);return k.kind==="signed-in"?k.user:void 0},i=async(y,k)=>{let g=await T(y);return g.set(n,k),await w.commitSession(g)},d=async(y,k)=>{let g=m===null?void 0:await m.stamp(M(k)),f=await T(y);return f.set(n,k),g!==void 0&&f.set(N,g),await w.commitSession(f)},h=async y=>{let k=await s(y);switch(k.kind){case"signed-in":return k.user;case"revoked":throw ne(a,{headers:{"Set-Cookie":await w.destroySession(k.session)}});case"signed-out":case"inactive":throw ne(a)}};return{sessionStorage:w,sessionKey:n,sessionMaxAgeSeconds:r,sessionGenerationGate:m,getSession:T,resolveSession:s,getSessionUser:u,saveSession:i,saveSignedInSession:d,requireUser:h,requireAdminUser:async y=>{let k=await h(y);if(k.role!=="admin")throw ne(v);return k},commitSession:w.commitSession,destroySession:w.destroySession}};var ot=new Map([["document",new Set(["none","same-origin","same-site"])],["empty",new Set(["same-origin"])]]),se=e=>{let t=e.headers.get("Sec-Fetch-Dest");if(t!==null){let r=ot.get(t);if(r===void 0)return`its fetch destination is "${t}"`;let a=e.headers.get("Sec-Fetch-Site");if(a===null)return`its "${t}" request states no site`;if(!r.has(a))return`its "${t}" request comes from a "${a}" page`}let n=e.headers.get("Sec-Purpose");if(n!==null)return`it is speculative ("${n}")`},ie=e=>new Response(`Signing out is refused because ${e}: only a navigation that does not come from another site, or a script's request from this origin, signs out.`,{status:403,headers:{"Cache-Control":"no-store","Content-Type":"text/plain; charset=utf-8"}});var ae=(e,t,n,r)=>{let a=e.loginPath??"/auth/login",v=e.postLoginRedirect??"/",A=e.postLogoutRedirect??"/",G=de(e.google.revocationTimeoutMs),m=Re(e.returnTo,{secrets:e.session.secrets,secure:oe(e.session)},a,r),w=async({request:f})=>{let l=m.requested(f);if(await t.getSessionUser(f))throw J(l??v);return{error:new URL(f.url).searchParams.get("error")}},T=async f=>{let l=m.requested(f);try{await n.authenticate("google",f)}catch(R){throw l===void 0||!(R instanceof Response)?R:await m.bindToFlow(R,l,f)}throw J(l===void 0?a:z(a,l))},s=async({request:f})=>(await f.clone().formData()).get("_action")!=="Sign In with Google"?null:await T(f),u=(f,l)=>{switch(f.outcome){case"failed":r.error(`Sign-out could not revoke the Google grant of user ${String(l)}; the session cookie is destroyed, but the grant stays valid until it expires or is revoked elsewhere:`,f.reason);return;case"already-invalid":r.info(`Sign-out found the Google grant of user ${String(l)} already unusable`);return;case"revoked":case"nothing-to-revoke":return}},i=(f,l)=>{f.kind!=="advanced"&&r.error(`Sign-out could not advance the session generation of ${l.provider} user ${l.id}; a session cookie refreshed before this sign-out stays valid until a later sign-out advances the generation or the cookie expires:`,f.error)},d=async(f,l)=>{let R=t.sessionGenerationGate;if(R!==null){if(!$(l)){r.info(`Sign-out found no usable session generation stamp in the session of ${f.provider} user ${f.id}; every guard already rejects that cookie, so the generation is not advanced`);return}i(await R.advance(f,l),f)}},h=async f=>{let l=await t.getSession(f),R=l.get(t.sessionKey),[I]=await Promise.all([le(R,{fetch:e.fetch??globalThis.fetch,timeoutMs:G}),R===void 0?void 0:d(M(R),l.get(N))]);return u(I,R?.id),await t.destroySession(l)},S=async f=>{let l=await h(f),R=new Headers;return R.append("Set-Cookie",l),J(A,{headers:R})},y=async({request:f})=>{let l=se(f);throw l!==void 0?ie(l):await S(f)},k=async f=>{let l=await n.authenticate("google",f),U=(await t.getSession(f)).get(t.sessionKey)?.refreshToken,c={accessToken:l.accessToken,refreshToken:l.refreshToken||U,expirationDateMs:l.expirationDateMs,provider:l.provider},o={id:l.id,displayName:l.displayName,name:l.name,emails:l.emails,...c,role:l.role};return await t.saveSignedInSession(f,o)};return{loginLoader:w,loginAction:s,startGoogleSignIn:T,logoutLoader:y,logout:h,logoutAndRedirect:S,googleCallbackLoader:async({request:f})=>{let l=await m.flowOf(f),R;try{R=await k(f)}catch(U){throw U instanceof Response?m.endFailedFlow(U,l,f):(r.error("Authentication error:",U),m.endFailedFlow(J(a),l,f))}let I=new Headers;throw I.append("Set-Cookie",R),l.deletion!==void 0&&I.append("Set-Cookie",l.deletion),J(l.path??v,{headers:I})}}};var rt=e=>{let t=e.logger??q,n=re(e.session,{sessionGeneration:e.sessionGeneration,logger:t,mockUser:e.mockUser,loginPath:e.loginPath,postLoginRedirect:e.postLoginRedirect,isUserActive:e.isUserActive}),r=Z(e),a=B(e,n,t),v=Q(e,n,a,t),A=ae(e,n,r,t);return{authenticator:r,storage:n,authFns:a,sessionStorage:n.sessionStorage,getSession:n.getSession,getSessionUser:n.getSessionUser,saveSession:n.saveSession,requireUser:n.requireUser,requireAdminUser:n.requireAdminUser,commitSession:n.commitSession,destroySession:n.destroySession,sessionMaxAgeSeconds:n.sessionMaxAgeSeconds,authenticate:a.authenticate,refreshedAccessToken:a.refreshedAccessToken,authenticateInLoader:v,...A}};export{F as AuthRequiredError,ue as DEFAULT_GOOGLE_REVOCATION_TIMEOUT_MS,he as DEFAULT_SESSION_GENERATION_CACHE_TTL_MS,ge as DEFAULT_SESSION_GENERATION_TIMEOUT_MS,Ae as DEFAULT_SESSION_MAX_AGE_SECONDS,K as GoogleInvalidGrantError,H as SessionGenerationUnavailableError,C as TokenRefreshError,ae as createAuthHandlers,rt as createAuthServer,re as createAuthSessionStorage,B as createAuthenticate,Q as createAuthenticateInLoader,Z as createGoogleAuthenticator,se as signOutRefusal,ie as signOutRefusalResponse};
|
|
1
|
+
import{GOOGLE_PROVIDER as De}from"@aiquants/auth-core";import{GOOGLE_PROVIDER as Ge}from"@aiquants/auth-core";var xe="https://oauth2.googleapis.com/revoke",fe=5e3,H=2147483647,be="invalid_token",_e=400,he=e=>{if(e===void 0)return fe;if(!Number.isInteger(e)||e<1||e>H)throw new RangeError(`google.revocationTimeoutMs must be an integer from 1 to ${H} (milliseconds); got ${String(e)}`);return e},Oe=e=>{if(typeof e.refreshToken=="string"&&e.refreshToken!=="")return e.refreshToken;if(typeof e.accessToken=="string"&&e.accessToken!=="")return e.accessToken},Ie=async e=>{let t=await e.json().catch(()=>{});return typeof t=="object"&&t!==null&&"error"in t&&typeof t.error=="string"?t.error:void 0},Ne=e=>e instanceof Error?e.cause instanceof Error?`${e.message} (${e.cause.message})`:e.message:String(e),Le=async(e,t,n)=>{try{let o=await t(xe,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({token:e}).toString(),signal:n});if(o.ok)return await o.body?.cancel(),{outcome:"revoked"};let a=await Ie(o);return o.status===_e&&a===be?{outcome:"already-invalid"}:{outcome:"failed",reason:a===void 0?`Google answered ${o.status}`:`Google answered ${o.status} ${a}`}}catch(o){return{outcome:"failed",reason:Ne(o)}}},ge=async(e,t)=>{if(e===void 0)return{outcome:"nothing-to-revoke"};let n=Oe(e);if(n===void 0)return{outcome:"nothing-to-revoke"};if(e.provider!==Ge)return{outcome:"failed",reason:`the session's provider "${String(e.provider)}" has no revocation endpoint`};let o=new AbortController;return await new Promise(a=>{let y=setTimeout(()=>{a({outcome:"failed",reason:`Google did not answer within ${t.timeoutMs} ms`}),o.abort()},t.timeoutMs);Le(n,t.fetch,o.signal).then(A=>{clearTimeout(y),a(A)})})};var N="generation",ye=15e3,Se=3e3,Ue=6e4,C=class extends Error{constructor(t,n){super(t,n),this.name="SessionGenerationUnavailableError"}},I=e=>typeof e=="string"?JSON.stringify(e):typeof e=="function"?"a function":typeof e=="object"&&e!==null?Array.isArray(e)?"an array":"an object":typeof e=="bigint"?`${e}n`:String(e),Ce=e=>{if(typeof e!="object"||e===null||Array.isArray(e))return I(e);let t="store"in e?e.store:void 0;if(typeof t!="object"||t===null)return`an object whose store is ${I(t)}`;let n="current"in t?t.current:void 0,o="advance"in t?t.advance:void 0;return`an object whose store.current is ${I(n)} and store.advance is ${I(o)}`},Me=e=>typeof e=="object"&&e!==null&&"current"in e&&typeof e.current=="function"&&"advance"in e&&typeof e.advance=="function",pe=(e,t,n,o)=>{if(t===void 0)return o;if(typeof t!="number"||!Number.isInteger(t)||t<n||t>H)throw new RangeError(`${e} must be an integer from ${n} to ${H} (milliseconds); got ${I(t)}`);return t},Fe=e=>{if(e===!1)return!1;let t=e;if(typeof t!="object"||t===null||!("store"in t)||!Me(t.store))throw new TypeError(`sessionGeneration must be { store, cacheTtlMs?, timeoutMs? } or false; got ${Ce(t)}`);return{store:t.store,cacheTtlMs:pe("sessionGeneration.cacheTtlMs","cacheTtlMs"in t?t.cacheTtlMs:void 0,0,ye),timeoutMs:pe("sessionGeneration.timeoutMs","timeoutMs"in t?t.timeoutMs:void 0,1,Se)}},$=e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>=0,Q=e=>typeof e.provider=="string"&&e.provider!==""&&typeof e.id=="string"&&e.id!=="",me=e=>new TypeError(`a session generation identity needs a non-empty provider and id; got provider ${I(e.provider)} and id ${I(e.id)}`),$e=e=>$(e)&&$(e+1),qe=e=>new TypeError(`a session generation advance needs the signed-out session's stamp, an integer from 0 to ${Number.MAX_SAFE_INTEGER-1}; got ${I(e)}`),M=e=>({provider:e.provider,id:e.id}),we=(e,t)=>{let n=Fe(e);if(n===!1)return null;let{store:o,cacheTtlMs:a,timeoutMs:y}=n,A=new Map,k=new Map,T=new Map,S=new Map,P=Number.NEGATIVE_INFINITY,l=r=>`${r.provider}\0${r.id}`,p=(r,s)=>{let g=A.get(r);if(g!==void 0){if(s-g.at<a)return g;A.delete(r)}},f=(r,s,g)=>{if(g!==void 0&&s.at<=g.answeredAt&&s.value<g.value)return;let v=p(r,performance.now());if(v===void 0){A.set(r,s);return}s.value<v.value||A.set(r,{value:s.value,at:Math.max(v.at,s.at)})},x=r=>{let s=S.get(r);if(s!==void 0)return s.count+=1,s;let g={count:1,floor:void 0};return S.set(r,g),g},u=(r,s)=>{s.count-=1,s.count===0&&S.delete(r)},d=(r,s)=>{r.floor={value:r.floor===void 0?s:Math.max(r.floor.value,s),answeredAt:performance.now()}},R=(r,s)=>{let g=T.get(r);return g===void 0?!1:s<g?!0:(T.delete(r),!1)},m=(r,s)=>{let g=performance.now();return T.set(r,g+a),g-P>=Ue&&(P=g,t.warn("Session generation store unavailable; skipping the sign-out generation check:",s)),"unavailable"},h=(r,s,g)=>new Promise((v,G)=>{let{operation:O}=r,de=r.operation==="advance"?r.from+1:0,Ee=performance.now(),j=x(g),U=!1,le=setTimeout(()=>{U=!0,v({kind:"unavailable",error:new C(`sessionGeneration.store.${O} did not settle within ${y} ms`)})},y);new Promise(_=>_(r.operation==="advance"?o.advance(s,r.from):o.current(s))).then(_=>{if(clearTimeout(le),!($(_)&&_>=de)){u(g,j),U||(U=!0,G(new TypeError(`sessionGeneration.store.${O} must resolve to an integer >= ${de}; got ${I(_)}`)));return}O==="advance"&&(d(j,_),k.delete(g)),f(g,{value:_,at:Ee},j.floor),u(g,j),!U&&(U=!0,T.delete(g),v({kind:"value",value:_}))},_=>{if(clearTimeout(le),u(g,j),!U){if(U=!0,_ instanceof C){v({kind:"unavailable",error:_});return}G(_)}})}),w=(r,s,g)=>{let v=k.get(s);if(v!==void 0&&g-v.startedAt<a)return v.read;let G={read:h({operation:"current"},r,s),startedAt:g};k.set(s,G);let O=()=>{k.get(s)===G&&k.delete(s)};return G.read.then(O,O),G.read},i=async(r,s,g)=>{let v=await h({operation:"current"},r,s);return v.kind==="unavailable"?m(s,v.error):g===v.value?"current":"stale"};return{check:async(r,s)=>{if(!($(s)&&Q(r)))return"stale";let g=performance.now(),v=l(r),G=p(v,g);if(G!==void 0){if(s===G.value)return"current";if(s<G.value)return"stale"}if(R(v,g))return"unavailable";if(G!==void 0)return await i(r,v,s);let O=await w(r,v,g);return O.kind==="unavailable"?m(v,O.error):s===O.value?"current":s<O.value?"stale":await i(r,v,s)},stamp:async r=>{if(!Q(r))throw me(r);let s=await h({operation:"current"},r,l(r));if(s.kind==="unavailable")throw s.error;return s.value},advance:async(r,s)=>{if(!Q(r))return{kind:"failed",error:me(r)};if(!$e(s))return{kind:"failed",error:qe(s)};try{let g=await h({operation:"advance",from:s},r,l(r));return g.kind==="value"?{kind:"advanced",generation:g.value}:{kind:"unavailable",error:g.error}}catch(g){return{kind:"failed",error:g}}}}};var F=class extends Error{constructor(t){super(t),this.name="TokenRefreshError"}},V=class extends F{constructor(){super("Google refresh token invalid or revoked"),this.name="GoogleInvalidGrantError"}},q=class extends Error{constructor(t){super("Authentication required"),this.name="AuthRequiredError",this.setCookie=t}},Ke=["access_token","expires_in"],Z=(e,t,n)=>{let o=t.sessionKey,a=async k=>{let S=k.get(o)?.refreshToken;if(!S)throw new Error("Refresh token not found in session");try{let P="https://www.googleapis.com/oauth2/v4/token",l={client_id:e.google.clientId,client_secret:e.google.clientSecret,grant_type:"refresh_token",refresh_token:S},f=await(e.fetch??globalThis.fetch)(P,{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify(l)});if(!f.ok){let m=await f.json().catch(()=>{});if(f.status===400&&typeof m=="object"&&!!m&&"error"in m&&m.error==="invalid_grant")throw new V;let w=typeof m=="object"&&m&&"error_description"in m?String(m.error_description):"Unknown error";throw new F(`Google token refresh failed: ${f.status} ${w}`)}let x=await f.json(),u=Ke.filter(m=>!x?.[m]);if(u.length>0)throw n.error("Invalid token response from Google; missing or empty keys:",u.join(", ")),new Error("Invalid token response from Google");let{access_token:d,expires_in:R}=x;return{accessToken:d,refreshToken:S,expirationDateMs:Number(Date.now())+R*1e3}}catch(P){if(P instanceof F)throw P;let l=P instanceof Error?P.message:"Unknown error";throw new F(`Failed to refresh Google access token: ${l}`)}},y=async k=>{let S=k.get(o).provider;if(!S)throw new Error("Provider not found in session");if(S===De)return await a(k);throw new Error("Provider not supported")};return{authenticate:async(k,T,S)=>{S.failureRedirect!==null&&t.returnToPolicy.checkRedirectMode(k,S);let P=l=>S.failureRedirect===null?new q(l):t.returnToPolicy.signInRedirect(S.returnTo,l!==void 0?{headers:{"Set-Cookie":l}}:void 0);try{if(e.mockUser?.enabled(k)){let{accessToken:d,refreshToken:R,expirationDateMs:m}=e.mockUser.resolve(k);return{accessToken:d,refreshToken:R,expirationDateMs:m}}let l=T.get(o),p=t.sessionGenerationGate;if(l!==void 0&&p!==null&&await p.check(M(l),T.get(N))==="stale")throw P(await t.destroySession(T));if(!(l?.accessToken&&l.expirationDateMs))throw P();let{accessToken:f,refreshToken:x,expirationDateMs:u}=l;if(u<Date.now())throw x?new Error("Expired"):P();return{accessToken:f,refreshToken:x,expirationDateMs:u}}catch(l){if(l instanceof Error&&l.message==="Expired")try{let p=await y(T),f=T.get(o);return T.set(o,{...f,...p}),p}catch(p){if(p instanceof V)n.warn("Google refresh token invalid or revoked");else{let x=p instanceof Error?p.message:"Unknown error";n.error("Failed to refresh token:",x)}let f=await t.destroySession(T);throw P(f)}throw l}},refreshedAccessToken:y}};var J=({refreshToken:e,...t})=>t;var ee=(e,t,n,o)=>{let a=new Map,y=new Map,A=async l=>{let p=JSON.stringify([l.provider,l.id]),f=a.get(p);if(f!==void 0)return f;let x=y.get(p);if(x!==void 0)return x;let u=(async()=>{try{let d=e.getUserPhoto?await e.getUserPhoto(l):"";return a.set(p,d),d}catch(d){throw a.delete(p),d}finally{y.delete(p)}})();return y.set(p,u),u},k=new WeakMap,T=async l=>{e.warmup&&await e.warmup();let p=await t.resolveSession(l);if(p.kind==="revoked")return{kind:"unauthenticated",cookie:await t.destroySession(p.session)};if(p.kind!=="signed-in")return{kind:"unauthenticated"};let{user:f,session:x}=p,u;try{u=await n.authenticate(l,x,{failureRedirect:null})}catch(c){if(c instanceof q)return c.setCookie!==void 0?{kind:"unauthenticated",cookie:c.setCookie}:{kind:"unauthenticated"};throw o.error("Error in authenticateInLoader:",c),c}let d={accessToken:u.accessToken,refreshToken:u.refreshToken,expirationDateMs:u.expirationDateMs,provider:f.provider},R={id:f.id,displayName:f.displayName,name:f.name,emails:f.emails,...d,role:f.role},m=await A(f),h=J({...f,...d,photo:m}),i=u.accessToken!==f.accessToken?await t.saveSession(l,R):void 0;return i!==void 0?{kind:"authenticated",user:h,cookie:i}:{kind:"authenticated",user:h}},S=l=>{let p=k.get(l);if(p!==void 0)return p;let f=T(l);return k.set(l,f),f};async function P(l,p){p.failureRedirect!==null&&t.returnToPolicy.checkRedirectMode(l,p);let f=await S(l);if(f.kind==="authenticated")return f.cookie!==void 0?{user:f.user,cookie:f.cookie}:{user:f.user};if(p.failureRedirect===null)return f.cookie!==void 0?{cookie:f.cookie}:{};throw t.returnToPolicy.signInRedirect(p.returnTo,f.cookie!==void 0?{headers:{"Set-Cookie":f.cookie}}:void 0)}return P};import{GOOGLE_PROVIDER as We}from"@aiquants/auth-core";import{redirect as ne}from"react-router";import{Authenticator as ze}from"remix-auth";import{OAuth2Strategy as je}from"remix-auth-oauth2";var He=["openid","https://www.googleapis.com/auth/userinfo.profile","https://www.googleapis.com/auth/userinfo.email"],Ve="google",Je="https://www.googleapis.com/oauth2/v3/userinfo",W=class extends je{constructor({clientId:n,clientSecret:o,redirectURI:a,scopes:y,accessType:A,includeGrantedScopes:k,prompt:T,hd:S,loginHint:P,additionalScopes:l},p){let f=y??He;super({clientId:n,clientSecret:o,redirectURI:a,authorizationEndpoint:"https://accounts.google.com/o/oauth2/v2/auth",tokenEndpoint:"https://oauth2.googleapis.com/token",scopes:f},p);this.name=Ve;this.scopes=f,this.accessType=A??"online",this.includeGrantedScopes=k??!1,this.prompt=T,this.hd=S,this.loginHint=P,this.additionalScopes=l}authorizationParams(n,o){n.set("access_type",this.accessType),n.set("include_granted_scopes",String(this.includeGrantedScopes));let a=o===void 0||this.additionalScopes===void 0?[]:this.additionalScopes(o);for(let A of a)if(A===""||/\s/u.test(A))throw new RangeError(`[auth-react-router] an additional scope must be a non-empty string without white space; got ${JSON.stringify(A)}`);let y=[...new Set([...this.scopes,...a])];return y.length>0&&n.set("scope",y.join(" ")),this.prompt&&n.set("prompt",this.prompt),this.hd&&n.set("hd",this.hd),this.loginHint&&n.set("login_hint",this.loginHint),n}static async userProfile(n){let o=await fetch(Je,{headers:{Authorization:`Bearer ${n.accessToken()}`}});if(!o.ok)throw new Error(`Failed to fetch user profile: ${o.statusText}`);let a=await o.json();return{id:a.sub,displayName:a.name,name:{familyName:a.family_name,givenName:a.given_name},emails:[{value:a.email}],photos:[{value:a.picture}],_json:a}}};var D={info:(...e)=>console.info("[Auth]",...e),warn:(...e)=>console.warn("[Auth]",...e),error:(...e)=>console.error("[Auth]",...e)};var te="error",L=(e,t)=>`${e}?${new URLSearchParams({[te]:t}).toString()}`;var Re=e=>e instanceof Error&&e.code==="access_denied"?"consentDenied":"googleFailed",re=e=>{let t=e.logger??D,n=e.loginPath??"/auth/login",o=new W({clientId:e.google.clientId,clientSecret:e.google.clientSecret,redirectURI:e.google.redirectURI,scopes:e.google.scopes,accessType:e.google.accessType??"offline",includeGrantedScopes:e.google.includeGrantedScopes??!0,prompt:e.google.prompt??"consent",additionalScopes:e.google.additionalScopes},async({request:y,tokens:A})=>{let{access_token:k,refresh_token:T,expires_in:S,scope:P,id_token:l}=A.data,{_json:{sub:p,email:f,picture:x,hd:u,email_verified:d},photos:R,...m}=await W.userProfile(A),{id:h,displayName:w,name:{familyName:i,givenName:c},emails:E}=m,b=We;if(k===void 0||T===void 0||S===void 0||P===void 0||h===void 0||w===void 0||p===void 0||f===void 0||d===void 0)throw ne(L(n,d===!1?"emailNotVerified":"googleFailed"));t.info("Authenticated on Google: ",m.displayName);try{if(e.backendAuth){if(!await e.backendAuth.verify(b,k))throw t.error("Backend verification returned false for user:",m.displayName),ne(L(n,"backendFailed"));t.info("Authenticated on Backend: ",m.displayName)}let r=m.emails[0]?.value;if(!await e.isEmailAllowed(r)){let G=new Error("You are not allowed to access this application");throw t.error(G),G}if(e.isUserActive&&!await e.isUserActive({...m,provider:b})){let G=new Error("You are not allowed to access this application");throw t.error("Deactivated account attempted to sign in:",r),G}e.backendAuth&&await e.backendAuth.signup(b,k,m),t.info("Authenticated complete: ",m.displayName);let s=Date.now()+S*1e3;return{...m,...{accessToken:k,refreshToken:T,expirationDateMs:s,provider:b},photo:x}}catch(r){let s=r;typeof r=="object"&&r!==null&&"cause"in r&&(s=r.cause||r),t.error("Error during backend authentication or subsequent processing:",s);let g="unexpected",v=!1;if(typeof r=="object"&&r!==null&&"cause"in r){let G=r.cause;G&&typeof G=="object"&&"message"in G&&typeof G.message=="string"&&G.message.includes("getaddrinfo ENOTFOUND")&&(g="backendUnreachable",v=!0)}throw!v&&r instanceof Error&&r.message.includes("You are not allowed to access this application")&&(g="notAllowed",v=!0),!v&&r instanceof Response&&r.headers.get("Location")?.startsWith(n)?r:ne(L(n,g))}}),a=new ze;return a.use(o),a};import{isSignInFailureKey as Be,resolveAuthMessages as Xe}from"@aiquants/auth-core";import{redirect as K}from"react-router";var oe="returnTo",z=(e,t)=>{let n=e.indexOf("?"),o=n===-1?e:e.slice(0,n),a=new URLSearchParams(n===-1?"":e.slice(n+1));return a.set(oe,t),`${o}?${a.toString()}`};var Ye=new Map([["document",new Set(["none","same-origin","same-site"])],["empty",new Set(["same-origin"])]]),se=e=>{let t=e.headers.get("Sec-Fetch-Dest");if(t!==null){let o=Ye.get(t);if(o===void 0)return`its fetch destination is "${t}"`;let a=e.headers.get("Sec-Fetch-Site");if(a===null)return`its "${t}" request states no site`;if(!o.has(a))return`its "${t}" request comes from a "${a}" page`}let n=e.headers.get("Sec-Purpose");if(n!==null)return`it is speculative ("${n}")`},ie=e=>new Response(e.signOutRefused,{status:403,headers:{"Cache-Control":"no-store","Content-Type":"text/plain; charset=utf-8"}});var ae=(e,t,n,o)=>{let a=e.loginPath??"/auth/login",y=e.postLoginRedirect??"/",A=e.postLogoutRedirect??"/",k=he(e.google.revocationTimeoutMs),T=Xe(e.messages),S=t.returnToPolicy,P=async({request:i})=>{let c=S.requested(i),E=new URL(i.url).searchParams.get(te),b=Be(E)?E:null;if(b===null&&await t.getSessionUser(i))throw K(c??y);return{error:b===null?null:T[b]}},l=async i=>{let c=S.requested(i);try{await n.authenticate("google",i)}catch(E){throw c===void 0||!(E instanceof Response)?E:await S.bindToFlow(E,c,i)}throw K(c===void 0?a:z(a,c))},p=async({request:i})=>(await i.clone().formData()).get("_action")!=="Sign In with Google"?null:await l(i),f=(i,c)=>{switch(i.outcome){case"failed":o.error(`Sign-out could not revoke the Google grant of user ${String(c)}; the session cookie is destroyed, but the grant stays valid until it expires or is revoked elsewhere:`,i.reason);return;case"already-invalid":o.info(`Sign-out found the Google grant of user ${String(c)} already unusable`);return;case"revoked":case"nothing-to-revoke":return}},x=(i,c)=>{i.kind!=="advanced"&&o.error(`Sign-out could not advance the session generation of ${c.provider} user ${c.id}; a session cookie refreshed before this sign-out stays valid until a later sign-out advances the generation or the cookie expires:`,i.error)},u=async(i,c)=>{let E=t.sessionGenerationGate;if(E!==null){if(!$(c)){o.info(`Sign-out found no usable session generation stamp in the session of ${i.provider} user ${i.id}; every guard already rejects that cookie, so the generation is not advanced`);return}x(await E.advance(i,c),i)}},d=async i=>{let c=await t.getSession(i),E=c.get(t.sessionKey),[b]=await Promise.all([ge(E,{fetch:e.fetch??globalThis.fetch,timeoutMs:k}),E===void 0?void 0:u(M(E),c.get(N))]);return f(b,E?.id),await t.destroySession(c)},R=async i=>{let c=await d(i),E=new Headers;return E.append("Set-Cookie",c),K(A,{headers:E})},m=async({request:i})=>{let c=se(i);throw c!==void 0?(o.warn(`Signing out is refused because ${c}`),ie(T)):await R(i)},h=async(i,c)=>{let r=(await t.getSession(i)).get(t.sessionKey)?.refreshToken,s={accessToken:c.accessToken,refreshToken:c.refreshToken||r,expirationDateMs:c.expirationDateMs,provider:c.provider},g={id:c.id,displayName:c.displayName,name:c.name,emails:c.emails,...s,role:c.role};return await t.saveSignedInSession(i,g)};return{loginLoader:P,loginAction:p,startGoogleSignIn:l,logoutLoader:m,logout:d,logoutAndRedirect:R,googleCallbackLoader:async({request:i})=>{let c=await S.flowOf(i),E;try{E=await n.authenticate("google",i)}catch(s){throw s instanceof Response?S.endFailedFlow(s,c,i):(o.error("Authentication error:",s),S.endFailedFlow(K(L(a,Re(s))),c,i))}let b;try{b=await h(i,E)}catch(s){throw o.error("Saving the signed-in session failed:",s),S.endFailedFlow(K(L(a,s instanceof C?"backendUnreachable":"unexpected")),c,i)}let r=new Headers;throw r.append("Set-Cookie",b),c.deletion!==void 0&&r.append("Set-Cookie",c.deletion),K(c.path??y,{headers:r})},messages:T}};import{createCookieSessionStorage as ct,redirect as ut}from"react-router";import{createCookie as Qe,redirect as Y}from"react-router";var Ze="__return_to.",et=300,ke=/^[A-Za-z0-9_-]{1,128}$/,tt=/%(?![0-9A-Fa-f]{2})/,B="https://return-to.invalid",Te=Object.freeze({path:void 0,deletion:void 0}),nt=e=>{if(e.includes("%"))return!1;let t=new URL(e,B);return t.origin===B&&t.pathname===e},rt=e=>{for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<=31||n>=127&&n<=159||e[t]==="\\"||e[t]==="#")return!0}return!1},ot=e=>{if(e[0]!=="/"||e[1]==="/"||e[1]==="\\")return{malformed:'it does not start with a single "/"'};if(rt(e))return{malformed:'it holds a control character, a backslash or a "#"'};if(tt.test(e))return{malformed:'it holds a "%" that two hexadecimal digits do not follow'};let t=new URL(e,B);if(t.origin!==B||`${t.pathname}${t.search}`!==e)return{malformed:"the URL parser normalizes it"};let n;try{n=decodeURIComponent(t.pathname)}catch{return{malformed:"its path does not decode as UTF-8"}}return n.startsWith("//")||n.startsWith("/\\")?{malformed:'its decoded path starts with "//" or "/\\"'}:{decodedPath:n}},st=e=>{if(e===null)return null;let t="returnTo.pages must be null or { excludedPathPrefixes: string[], maxLength: number }";if(typeof e!="object"||Array.isArray(e))throw new TypeError(`${t}; got ${JSON.stringify(e)}`);let{excludedPathPrefixes:n,maxLength:o}=e;if(!Array.isArray(n))throw new TypeError(`${t}; got excludedPathPrefixes ${JSON.stringify(n)}`);for(let y of n){if(typeof y!="string")throw new TypeError(`returnTo.pages.excludedPathPrefixes must hold strings; got ${JSON.stringify(y)}`);if(!y.startsWith("/"))throw new RangeError(`returnTo.pages.excludedPathPrefixes must hold path prefixes starting with "/"; got ${JSON.stringify(y)}`)}if(typeof o!="number")throw new TypeError(`${t}; got maxLength ${JSON.stringify(o)}`);if(!Number.isSafeInteger(o)||o<1)throw new RangeError(`returnTo.pages.maxLength must be a safe integer >= 1; got ${String(o)}`);let a=Object.freeze([...n]);return Object.freeze({excludedPathPrefixes:a,maxLength:o,lowerCasePrefixes:Object.freeze(a.map(y=>y.toLowerCase()))})},it=e=>{if(e===void 0)return{allowedPaths:new Set,pages:null};let t=e;if(typeof t!="object"||t===null||!Array.isArray(t.allowedPaths))throw new TypeError(`returnTo must be { allowedPaths: string[], pages: { excludedPathPrefixes: string[], maxLength: number } | null }; got ${JSON.stringify(t)}`);let n=t.allowedPaths;for(let a of n){if(typeof a!="string")throw new TypeError(`returnTo.allowedPaths must hold strings; got ${JSON.stringify(a)}`);if(!nt(a))throw new RangeError(`returnTo.allowedPaths must hold canonical same-origin paths (one leading "/", no query, fragment, percent-encoding, backslash, white space, control or non-ASCII character, or dot segment); got ${JSON.stringify(a)}`)}let o=st(t.pages);if(n.length===0&&o===null)throw new RangeError("returnTo allows no return-to (allowedPaths is empty and pages is null); omit returnTo to allow none");return{allowedPaths:new Set(n),pages:o}},X=e=>{if(typeof e!="string")throw new TypeError(`[auth-react-router] returnTo must be the page's path and query to return to after the sign-in; got ${JSON.stringify(e)}`);return e},at=(e,t)=>e===null?!1:e.split(";").some(n=>n.trim().startsWith(`${t}=`)),ce=(e,t)=>new Response(e.body,{status:e.status,statusText:e.statusText,headers:t}),Ae=(e,t,n,o)=>{let{allowedPaths:a,pages:y}=it(e),A=u=>{if(a.has(u))return{kind:"accepted"};if(y===null)return{kind:"closed"};let d=ot(u);if("malformed"in d)return{kind:"malformed",reason:d.malformed};let R=d.decodedPath.toLowerCase(),m=y.lowerCasePrefixes.findIndex(h=>R.startsWith(h));return m!==-1?{kind:"excluded",prefix:y.excludedPathPrefixes[m]}:u.length>y.maxLength?{kind:"tooLong",length:u.length}:{kind:"accepted"}},k=u=>Qe(`${Ze}${u}`,{secrets:[...t.secrets],httpOnly:!0,sameSite:"lax",path:"/",secure:t.secure,maxAge:et}),T=(u,d,R)=>{let m=u.headers.get("Location");if(m===null)return u;let h=new URL(m,R.url);if(h.origin!==new URL(R.url).origin||h.pathname!==n)return u;let w=new Headers(u.headers);return w.set("Location",`${z(`${h.pathname}${h.search}`,d)}${h.hash}`),ce(u,w)};return{requested:u=>{let d=new URL(u.url).searchParams.getAll(oe);if(d.length!==0){if(d.length===1&&A(d[0]).kind==="accepted")return d[0];throw Y(L(n,"returnToRefused"))}},bindToFlow:async(u,d,R)=>{let m=u.headers.get("Location"),h=m===null?null:new URL(m,R.url).searchParams.get("state");if(h===null)return T(u,d,R);if(!ke.test(h))throw new Error(`The authorization redirect's state cannot name the return-to cookie; got ${JSON.stringify(h)}`);let w=new Headers(u.headers);return w.append("Set-Cookie",await k(h).serialize(d)),ce(u,w)},flowOf:async u=>{let d=new URL(u.url).searchParams.get("state");if(d===null||!ke.test(d))return Te;let R=k(d),m=u.headers.get("Cookie");if(!at(m,R.name))return Te;let h=await R.serialize("",{maxAge:0}),w=await R.parse(m);return typeof w=="string"&&A(w).kind==="accepted"?{path:w,deletion:h}:(o.warn(`The sign-in's return-to cookie ${R.name} names no accepted return-to; the sign-in returns to the post-login path instead`),{path:void 0,deletion:h})},endFailedFlow:(u,d,R)=>{if(d.deletion===void 0)return u;let m=d.path===void 0?u:T(u,d.path,R),h=new Headers(m.headers);return h.append("Set-Cookie",d.deletion),ce(m,h)},signInRedirect:(u,d)=>{let R=A(X(u));switch(R.kind){case"accepted":return Y(z(n,u),d);case"closed":return Y(n,d);case"malformed":return o.warn(`The sign-in redirect leaves its return-to out because ${R.reason}; the sign-in returns to the post-login path instead`),Y(n,d);case"tooLong":return o.warn(`The sign-in redirect leaves its return-to out because its ${R.length} characters exceed returnTo.pages.maxLength; the sign-in returns to the post-login path instead`),Y(n,d);case"excluded":throw new TypeError(`[auth-react-router] a page under the excluded prefix ${JSON.stringify(R.prefix)} redirected to the sign-in page; a route there answers 401 instead (pass failureRedirect: null)`)}},checkRedirectMode:(u,d)=>{if(d.failureRedirect!==n)throw new TypeError(`[auth-react-router] failureRedirect must be the sign-in page ${JSON.stringify(n)}, where the redirect mode sends an unauthenticated request; got ${JSON.stringify(d.failureRedirect)} (pass null to skip redirecting)`);if(X(d.returnTo),u.method!=="GET"&&u.method!=="HEAD")throw new TypeError("[auth-react-router] the redirect mode serves only GET and HEAD loaders; an action answers 401 data")}}};var Pe=3600*24*30,dt=e=>{if(e===void 0)return Pe;if(!Number.isSafeInteger(e)||e<1)throw new RangeError(`session.maxAge must be a safe integer of seconds >= 1; got ${String(e)}`);return e},ve=e=>e.secure??process.env.NODE_ENV==="production",ue=(e,t)=>{if(!e.secrets||e.secrets.length===0||e.secrets.some(h=>!h))throw new Error("REMIX_SESSION_SECRET must be set");let n=e.sessionKey??"user";if(n===N)throw new RangeError(`session.sessionKey must not be ${JSON.stringify(N)}, the key the session generation is stored under; got ${JSON.stringify(n)}`);let o=dt(e.maxAge),a=t.loginPath??"/auth/login",y=t.postLoginRedirect??"/",A=t.mockUser,k=t.isUserActive,T=t.logger??D,S=we(t.sessionGeneration,T),P=Ae(t.returnTo,{secrets:e.secrets,secure:ve(e)},a,T),l=ct({cookie:{name:e.cookieName??"__session",httpOnly:!0,path:"/",sameSite:"lax",secrets:e.secrets,secure:ve(e),maxAge:o}}),p=async h=>await l.getSession(h.headers.get("Cookie")),f=async h=>{if(A?.enabled(h))return{kind:"signed-in",user:J(A.resolve(h)),session:await p(h)};let w=await p(h),i=w.get(n);if(i===void 0)return{kind:"signed-out"};let c=J(i),[E,b]=await Promise.all([k===void 0?!0:k(c),S===null?"current":S.check(M(i),w.get(N))]);return b==="stale"?{kind:"revoked",session:w}:E?{kind:"signed-in",user:c,session:w}:{kind:"inactive"}},x=async h=>{let w=await f(h);return w.kind==="signed-in"?w.user:void 0},u=async(h,w)=>{let i=await p(h);return i.set(n,w),await l.commitSession(i)},d=async(h,w)=>{let i=S===null?void 0:await S.stamp(M(w)),c=await p(h);return c.set(n,w),i!==void 0&&c.set(N,i),await l.commitSession(c)},R=async(h,w)=>{X(w);let i=await f(h);switch(i.kind){case"signed-in":return i.user;case"revoked":throw P.signInRedirect(w,{headers:{"Set-Cookie":await l.destroySession(i.session)}});case"signed-out":case"inactive":throw P.signInRedirect(w)}};return{sessionStorage:l,sessionKey:n,sessionMaxAgeSeconds:o,sessionGenerationGate:S,returnToPolicy:P,getSession:p,resolveSession:f,getSessionUser:x,saveSession:u,saveSignedInSession:d,requireUser:R,requireAdminUser:async(h,w)=>{let i=await R(h,w);if(i.role!=="admin")throw ut(y);return i},commitSession:l.commitSession,destroySession:l.destroySession}};var lt=e=>{let t=e.logger??D,n=ue(e.session,{sessionGeneration:e.sessionGeneration,logger:t,mockUser:e.mockUser,loginPath:e.loginPath,postLoginRedirect:e.postLoginRedirect,isUserActive:e.isUserActive,returnTo:e.returnTo}),o=re(e),a=Z(e,n,t),y=ee(e,n,a,t),A=ae(e,n,o,t);return{authenticator:o,storage:n,authFns:a,sessionStorage:n.sessionStorage,getSession:n.getSession,getSessionUser:n.getSessionUser,saveSession:n.saveSession,requireUser:n.requireUser,requireAdminUser:n.requireAdminUser,signInRedirect:n.returnToPolicy.signInRedirect,commitSession:n.commitSession,destroySession:n.destroySession,sessionMaxAgeSeconds:n.sessionMaxAgeSeconds,authenticate:a.authenticate,refreshedAccessToken:a.refreshedAccessToken,authenticateInLoader:y,...A}};export{q as AuthRequiredError,fe as DEFAULT_GOOGLE_REVOCATION_TIMEOUT_MS,ye as DEFAULT_SESSION_GENERATION_CACHE_TTL_MS,Se as DEFAULT_SESSION_GENERATION_TIMEOUT_MS,Pe as DEFAULT_SESSION_MAX_AGE_SECONDS,V as GoogleInvalidGrantError,C as SessionGenerationUnavailableError,F as TokenRefreshError,ae as createAuthHandlers,lt as createAuthServer,ue as createAuthSessionStorage,Z as createAuthenticate,ee as createAuthenticateInLoader,re as createGoogleAuthenticator,se as signOutRefusal,ie as signOutRefusalResponse};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */
|
|
2
2
|
/*! @aiquants/auth-react-router standalone CSS — 非 Tailwind ホスト専用。ホストの Tailwind ビルドと混在させないこと */
|
|
3
|
-
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-
|
|
3
|
+
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial}}}@layer theme{:root,:host{--spacing:.25rem;--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--font-weight-bold:700;--tracking-wide:.025em;--radius-2xl:1rem}}@layer base,components;@layer utilities{.invisible{visibility:hidden}.visible{visibility:visible}.fixed{position:fixed}.static{position:static}.container{width:100%}@media (min-width:40rem){.container{max-width:40rem}}@media (min-width:48rem){.container{max-width:48rem}}@media (min-width:64rem){.container{max-width:64rem}}@media (min-width:80rem){.container{max-width:80rem}}@media (min-width:96rem){.container{max-width:96rem}}.my-4{margin-block:calc(var(--spacing) * 4)}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.table{display:table}.min-h-11{min-height:calc(var(--spacing) * 11)}.w-full{width:100%}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.cursor-pointer{cursor:pointer}.resize{resize:both}.items-center{align-items:center}.justify-center{justify-content:center}.gap-3{gap:calc(var(--spacing) * 3)}.rounded-2xl{border-radius:var(--radius-2xl)}.px-6{padding-inline:calc(var(--spacing) * 6)}.py-3{padding-block:calc(var(--spacing) * 3)}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.uppercase{text-transform:uppercase}.ring{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.focus-visible\:outline-2:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px}.focus-visible\:outline-offset-2:focus-visible{outline-offset:2px}}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiquants/auth-react-router",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.40.0",
|
|
4
4
|
"description": "React Router v7 / v8 auth adapter for @aiquants/auth-core: Google OAuth strategy factory (remix-auth), cookie session storage with DI test backdoor, a loader guard that authenticates at most once per request (token refresh + photo cache), auth route handlers, and a <GoogleForm> login button.",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"**/*.css"
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@aiquants/auth-core": "0.8.0",
|
|
58
|
-
"@aiquants/console-ui": "0.
|
|
58
|
+
"@aiquants/console-ui": "0.7.0",
|
|
59
59
|
"@aiquants/fuzzy-search": "3.2.1",
|
|
60
|
-
"@aiquants/select-box": "0.22.
|
|
60
|
+
"@aiquants/select-box": "0.22.2",
|
|
61
61
|
"@aiquants/virtualscroll": "3.24.0",
|
|
62
62
|
"@tailwindcss/cli": "^4.1.18",
|
|
63
63
|
"@testing-library/react": "^16.3.2",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
},
|
|
79
79
|
"peerDependencies": {
|
|
80
80
|
"@aiquants/auth-core": "^0.8.0",
|
|
81
|
-
"@aiquants/console-ui": "^0.
|
|
81
|
+
"@aiquants/console-ui": "^0.7.0",
|
|
82
82
|
"@aiquants/fuzzy-search": "^3.2.1",
|
|
83
83
|
"@aiquants/select-box": "^0.22.0",
|
|
84
84
|
"@aiquants/virtualscroll": "^3.22.1",
|