better-auth 0.2.2 → 0.2.3-beta.10

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/dist/social.js CHANGED
@@ -1,2 +1,2 @@
1
- var a=(e,i,c)=>new Promise((t,r)=>{var o=d=>{try{u(c.next(d))}catch(m){r(m)}},n=d=>{try{u(c.throw(d))}catch(m){r(m)}},u=d=>d.done?t(d.value):Promise.resolve(d.value).then(o,n);u((c=c.apply(e,i)).next())});import"arctic";import{parseJWT as B}from"oslo/jwt";import"@better-fetch/fetch";var f=class extends Error{constructor(i,c,t){super(i),this.name="BetterAuthError",this.message=i,this.cause=c}};import{OAuth2Tokens as S}from"arctic";function E(e){try{return new URL(e).pathname!=="/"}catch(i){throw new f(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function b(e,i="/api/auth"){return E(e)?e:(i=i.startsWith("/")?i:`/${i}`,`${e}${i}`)}function U(e,i){if(e)return b(e,i);let c=(process==null?void 0:process.env)||{},t=c.BETTER_AUTH_URL||c.NEXT_PUBLIC_BETTER_AUTH_URL||c.PUBLIC_BETTER_AUTH_URL||c.NUXT_PUBLIC_BETTER_AUTH_URL||c.NUXT_PUBLIC_AUTH_URL||(c.BASE_URL!=="/"?c.BASE_URL:void 0);if(t)return b(t,i);if(typeof window!="undefined")return b(window.location.origin,i)}import{betterFetch as C}from"@better-fetch/fetch";function s(e,i){return i||`${U()}/callback/${e}`}function l(o){return a(this,arguments,function*({code:e,codeVerifier:i,redirectURI:c,options:t,tokenEndpoint:r}){let n=new URLSearchParams;n.set("grant_type","authorization_code"),n.set("code",e),i&&n.set("code_verifier",i),n.set("redirect_uri",c),n.set("client_id",t.clientId),n.set("client_secret",t.clientSecret);let{data:u,error:d}=yield C(r,{method:"POST",body:n,headers:{"content-type":"application/x-www-form-urlencoded",accept:"application/json","user-agent":"better-auth"}});if(d)throw d;return new S(u)})}var v=e=>{let i="https://appleid.apple.com/auth/token";return{id:"apple",name:"Apple",createAuthorizationURL({state:t,scopes:r,redirectURI:o}){let n=r||["email","name","openid"];return new URL(`https://appleid.apple.com/auth/authorize?client_id=${e.clientId}&response_type=code&redirect_uri=${o||e.redirectURI}&scope=${n.join(" ")}&state=${t}`)},validateAuthorizationCode:(t,r,o)=>a(void 0,null,function*(){return l({code:t,codeVerifier:r,redirectURI:o||s("apple",e.redirectURI),options:e,tokenEndpoint:i})}),getUserInfo(t){return a(this,null,function*(){var o;let r=(o=B(t.idToken()))==null?void 0:o.payload;return r?{user:{id:r.sub,name:r.name,email:r.email,emailVerified:r.email_verified==="true"},data:r}:null})}}};import{betterFetch as G}from"@better-fetch/fetch";import{Discord as F}from"arctic";var R=e=>{let i=new F(e.clientId,e.clientSecret,s("discord",e.redirectURI));return{id:"discord",name:"Discord",createAuthorizationURL({state:t,scopes:r}){let o=r||["email"];return i.createAuthorizationURL(t,o)},validateAuthorizationCode:(t,r,o)=>a(void 0,null,function*(){return l({code:t,codeVerifier:r,redirectURI:o||s("discord",e.redirectURI),options:e,tokenEndpoint:"https://discord.com/api/oauth2/token"})}),getUserInfo(t){return a(this,null,function*(){let{data:r,error:o}=yield G("https://discord.com/api/users/@me",{auth:{type:"Bearer",token:t.accessToken()}});return o?null:{user:{id:r.id,name:r.display_name||r.username||"",email:r.email,emailVerified:r.verified},data:r}})}}};import{betterFetch as V}from"@better-fetch/fetch";import{Facebook as $}from"arctic";var w=e=>{let i=new $(e.clientId,e.clientSecret,s("facebook",e.redirectURI));return{id:"facebook",name:"Facebook",createAuthorizationURL({state:t,scopes:r}){let o=r||["email","public_profile"];return i.createAuthorizationURL(t,o)},validateAuthorizationCode:(t,r,o)=>a(void 0,null,function*(){return l({code:t,codeVerifier:r,redirectURI:o||s("facebook",e.redirectURI),options:e,tokenEndpoint:"https://graph.facebook.com/v16.0/oauth/access_token"})}),getUserInfo(t){return a(this,null,function*(){let{data:r,error:o}=yield V("https://graph.facebook.com/me",{auth:{type:"Bearer",token:t.accessToken()}});return o?null:{user:{id:r.id,name:r.name,email:r.email,emailVerified:r.email_verified},data:r}})}}};import{betterFetch as I}from"@better-fetch/fetch";import{GitHub as D}from"arctic";var P=({clientId:e,clientSecret:i,redirectURI:c})=>{let t=new D(e,i,s("github",c));return{id:"github",name:"Github",createAuthorizationURL({state:o,scopes:n}){let u=n||["user:email"];return t.createAuthorizationURL(o,u)},validateAuthorizationCode:o=>a(void 0,null,function*(){return yield t.validateAuthorizationCode(o)}),getUserInfo(o){return a(this,null,function*(){var m,_,A,y;let{data:n,error:u}=yield I("https://api.github.com/user",{auth:{type:"Bearer",token:o.accessToken()}});if(u)return null;let d=!1;if(!n.email){let{data:p,error:z}=yield I("https://api.github.com/user/emails",{auth:{type:"Bearer",token:o.accessToken()}});z||(n.email=(_=(m=p.find(h=>h.primary))!=null?m:p[0])==null?void 0:_.email,d=(y=(A=p.find(h=>h.email===n.email))==null?void 0:A.verified)!=null?y:!1)}return{user:{id:n.id,name:n.name,email:n.email,image:n.avatar_url,emailVerified:d,createdAt:new Date,updatedAt:new Date},data:n}})}}};import{Google as N}from"arctic";import{parseJWT as W}from"oslo/jwt";import{createConsola as H}from"consola";var g=H({formatOptions:{date:!1,colors:!0,compact:!0},defaults:{tag:"Better Auth"}}),j=e=>({log:(...i)=>{!(e!=null&&e.disabled)&&g.log("",...i)},error:(...i)=>{!(e!=null&&e.disabled)&&g.error("",...i)},warn:(...i)=>{!(e!=null&&e.disabled)&&g.warn("",...i)},info:(...i)=>{!(e!=null&&e.disabled)&&g.info("",...i)},debug:(...i)=>{!(e!=null&&e.disabled)&&g.debug("",...i)},box:(...i)=>{!(e!=null&&e.disabled)&&g.box("",...i)},success:(...i)=>{!(e!=null&&e.disabled)&&g.success("",...i)},break:(...i)=>{!(e!=null&&e.disabled)&&console.log(`
2
- `)}}),k=j();var x=e=>{let i=new N(e.clientId,e.clientSecret,s("google",e.redirectURI));return{id:"google",name:"Google",createAuthorizationURL({state:t,scopes:r,codeVerifier:o,redirectURI:n}){if(!e.clientId||!e.clientSecret)throw k.error("Client Id and Client Secret is required for Google. Make sure to provide them in the options."),new f("CLIENT_ID_AND_SECRET_REQUIRED");if(!o)throw new f("codeVerifier is required for Google");let u=r||["email","profile"];return i.createAuthorizationURL(t,o,u)},validateAuthorizationCode:(t,r,o)=>a(void 0,null,function*(){return l({code:t,codeVerifier:r,redirectURI:o||s("google",e.redirectURI),options:e,tokenEndpoint:"https://oauth2.googleapis.com/token"})}),getUserInfo(t){return a(this,null,function*(){var o;if(!t.idToken)return null;let r=(o=W(t.idToken()))==null?void 0:o.payload;return{user:{id:r.sub,name:r.name,email:r.email,image:r.picture,emailVerified:r.email_verified},data:r}})}}};import{betterFetch as X}from"@better-fetch/fetch";import{Spotify as q}from"arctic";var T=e=>{let i=new q(e.clientId,e.clientSecret,s("spotify",e.redirectURI));return{id:"spotify",name:"Spotify",createAuthorizationURL({state:t,scopes:r}){let o=r||["user-read-email"];return i.createAuthorizationURL(t,o)},validateAuthorizationCode:(t,r,o)=>a(void 0,null,function*(){return l({code:t,codeVerifier:r,redirectURI:o||s("spotify",e.redirectURI),options:e,tokenEndpoint:"https://accounts.spotify.com/api/token"})}),getUserInfo(t){return a(this,null,function*(){var n;let{data:r,error:o}=yield X("https://api.spotify.com/v1/me",{method:"GET",headers:{Authorization:`Bearer ${t.accessToken()}`}});return o?null:{user:{id:r.id,name:r.display_name,email:r.email,image:(n=r.images[0])==null?void 0:n.url,emailVerified:!1},data:r}})}}};import{betterFetch as J}from"@better-fetch/fetch";import{Twitch as K}from"arctic";var O=e=>{let i=new K(e.clientId,e.clientSecret,s("twitch",e.redirectURI));return{id:"twitch",name:"Twitch",createAuthorizationURL({state:t,scopes:r}){let o=r||["activity:write","read"];return i.createAuthorizationURL(t,o)},validateAuthorizationCode:(t,r,o)=>a(void 0,null,function*(){return l({code:t,codeVerifier:r,redirectURI:o||s("twitch",e.redirectURI),options:e,tokenEndpoint:"https://id.twitch.tv/oauth2/token"})}),getUserInfo(t){return a(this,null,function*(){let{data:r,error:o}=yield J("https://api.twitch.tv/helix/users",{method:"GET",headers:{Authorization:`Bearer ${t.accessToken()}`}});return o?null:{user:{id:r.sub,name:r.preferred_username,email:r.email,image:r.picture,emailVerified:!1},data:r}})}}};import{betterFetch as M}from"@better-fetch/fetch";import{Twitter as Q}from"arctic";var L=e=>{let i=new Q(e.clientId,e.clientSecret,s("twitter",e.redirectURI));return{id:"twitter",name:"Twitter",createAuthorizationURL(t){let r=t.scopes||["account_info.read"];return i.createAuthorizationURL(t.state,t.codeVerifier,r)},validateAuthorizationCode:(t,r,o)=>a(void 0,null,function*(){return l({code:t,codeVerifier:r,redirectURI:o||s("twitch",e.redirectURI),options:e,tokenEndpoint:"https://id.twitch.tv/oauth2/token"})}),getUserInfo(t){return a(this,null,function*(){let{data:r,error:o}=yield M("https://api.x.com/2/users/me?user.fields=profile_image_url",{method:"GET",headers:{Authorization:`Bearer ${t.accessToken()}`}});return o||!r.data.email?null:{user:{id:r.data.id,name:r.data.name,email:r.data.email,image:r.data.profile_image_url,emailVerified:r.data.verified||!1},data:r}})}}};import"arctic";var Y={apple:v,discord:R,facebook:w,github:P,google:x,spotify:T,twitch:O,twitter:L},pr=Object.keys(Y);export{v as apple,R as discord,w as facebook,P as github,x as google,pr as oAuthProviderList,Y as oAuthProviders,T as spotify,O as twitch,L as twitter};
1
+ import"arctic";import{parseJWT as O}from"oslo/jwt";import"@better-fetch/fetch";var d=class extends Error{constructor(i,r,e){super(i),this.name="BetterAuthError",this.message=i,this.cause=r}};import{OAuth2Tokens as x}from"arctic";function k(t){try{return new URL(t).pathname!=="/"}catch{throw new d(`Invalid base URL: ${t}. Please provide a valid base URL.`)}}function f(t,i="/api/auth"){return k(t)?t:(i=i.startsWith("/")?i:`/${i}`,`${t}${i}`)}function g(t,i){if(t)return f(t,i);let r=process?.env||{},e=r.BETTER_AUTH_URL||r.NEXT_PUBLIC_BETTER_AUTH_URL||r.PUBLIC_BETTER_AUTH_URL||r.NUXT_PUBLIC_BETTER_AUTH_URL||r.NUXT_PUBLIC_AUTH_URL||(r.BASE_URL!=="/"?r.BASE_URL:void 0);if(e)return f(e,i);if(typeof window<"u")return f(window.location.origin,i)}import{betterFetch as T}from"@better-fetch/fetch";function n(t,i){return i||`${g()}/callback/${t}`}async function s({code:t,codeVerifier:i,redirectURI:r,options:e,tokenEndpoint:o}){let a=new URLSearchParams;a.set("grant_type","authorization_code"),a.set("code",t),i&&a.set("code_verifier",i),a.set("redirect_uri",r),a.set("client_id",e.clientId),a.set("client_secret",e.clientSecret);let{data:c,error:u}=await T(o,{method:"POST",body:a,headers:{"content-type":"application/x-www-form-urlencoded",accept:"application/json","user-agent":"better-auth"}});if(u)throw u;return new x(c)}var h=t=>{let i="https://appleid.apple.com/auth/token";return{id:"apple",name:"Apple",createAuthorizationURL({state:r,scopes:e,redirectURI:o}){let a=e||["email","name","openid"];return new URL(`https://appleid.apple.com/auth/authorize?client_id=${t.clientId}&response_type=code&redirect_uri=${o||t.redirectURI}&scope=${a.join(" ")}&state=${r}`)},validateAuthorizationCode:async(r,e,o)=>s({code:r,codeVerifier:e,redirectURI:o||n("apple",t.redirectURI),options:t,tokenEndpoint:i}),async getUserInfo(r){let e=O(r.idToken())?.payload;return e?{user:{id:e.sub,name:e.name,email:e.email,emailVerified:e.email_verified==="true"},data:e}:null}}};import{betterFetch as L}from"@better-fetch/fetch";import{Discord as z}from"arctic";var b=t=>{let i=new z(t.clientId,t.clientSecret,n("discord",t.redirectURI));return{id:"discord",name:"Discord",createAuthorizationURL({state:r,scopes:e}){let o=e||["email"];return i.createAuthorizationURL(r,o)},validateAuthorizationCode:async(r,e,o)=>s({code:r,codeVerifier:e,redirectURI:o||n("discord",t.redirectURI),options:t,tokenEndpoint:"https://discord.com/api/oauth2/token"}),async getUserInfo(r){let{data:e,error:o}=await L("https://discord.com/api/users/@me",{auth:{type:"Bearer",token:r.accessToken()}});return o?null:{user:{id:e.id,name:e.display_name||e.username||"",email:e.email,emailVerified:e.verified},data:e}}}};import{betterFetch as E}from"@better-fetch/fetch";import{Facebook as S}from"arctic";var _=t=>{let i=new S(t.clientId,t.clientSecret,n("facebook",t.redirectURI));return{id:"facebook",name:"Facebook",createAuthorizationURL({state:r,scopes:e}){let o=e||["email","public_profile"];return i.createAuthorizationURL(r,o)},validateAuthorizationCode:async(r,e,o)=>s({code:r,codeVerifier:e,redirectURI:o||n("facebook",t.redirectURI),options:t,tokenEndpoint:"https://graph.facebook.com/v16.0/oauth/access_token"}),async getUserInfo(r){let{data:e,error:o}=await E("https://graph.facebook.com/me",{auth:{type:"Bearer",token:r.accessToken()}});return o?null:{user:{id:e.id,name:e.name,email:e.email,emailVerified:e.email_verified},data:e}}}};import{betterFetch as A}from"@better-fetch/fetch";import{GitHub as C}from"arctic";var y=({clientId:t,clientSecret:i,redirectURI:r})=>{let e=new C(t,i,n("github",r));return{id:"github",name:"Github",createAuthorizationURL({state:o,scopes:a}){let c=a||["user:email"];return e.createAuthorizationURL(o,c)},validateAuthorizationCode:async o=>await e.validateAuthorizationCode(o),async getUserInfo(o){let{data:a,error:c}=await A("https://api.github.com/user",{auth:{type:"Bearer",token:o.accessToken()}});if(c)return null;let u=!1;if(!a.email){let{data:m,error:P}=await A("https://api.github.com/user/emails",{auth:{type:"Bearer",token:o.accessToken()}});P||(a.email=(m.find(p=>p.primary)??m[0])?.email,u=m.find(p=>p.email===a.email)?.verified??!1)}return{user:{id:a.id,name:a.name,email:a.email,image:a.avatar_url,emailVerified:u,createdAt:new Date,updatedAt:new Date},data:a}}}};import{Google as F}from"arctic";import{parseJWT as V}from"oslo/jwt";import{createConsola as B}from"consola";var l=B({formatOptions:{date:!1,colors:!0,compact:!0},defaults:{tag:"Better Auth"}}),G=t=>({log:(...i)=>{!t?.disabled&&l.log("",...i)},error:(...i)=>{!t?.disabled&&l.error("",...i)},warn:(...i)=>{!t?.disabled&&l.warn("",...i)},info:(...i)=>{!t?.disabled&&l.info("",...i)},debug:(...i)=>{!t?.disabled&&l.debug("",...i)},box:(...i)=>{!t?.disabled&&l.box("",...i)},success:(...i)=>{!t?.disabled&&l.success("",...i)},break:(...i)=>{!t?.disabled&&console.log(`
2
+ `)}}),U=G();var v=t=>{let i=new F(t.clientId,t.clientSecret,n("google",t.redirectURI));return{id:"google",name:"Google",createAuthorizationURL({state:r,scopes:e,codeVerifier:o,redirectURI:a}){if(!t.clientId||!t.clientSecret)throw U.error("Client Id and Client Secret is required for Google. Make sure to provide them in the options."),new d("CLIENT_ID_AND_SECRET_REQUIRED");if(!o)throw new d("codeVerifier is required for Google");let c=e||["email","profile"];return i.createAuthorizationURL(r,o,c)},validateAuthorizationCode:async(r,e,o)=>s({code:r,codeVerifier:e,redirectURI:o||n("google",t.redirectURI),options:t,tokenEndpoint:"https://oauth2.googleapis.com/token"}),async getUserInfo(r){if(!r.idToken)return null;let e=V(r.idToken())?.payload;return{user:{id:e.sub,name:e.name,email:e.email,image:e.picture,emailVerified:e.email_verified},data:e}}}};import{betterFetch as $}from"@better-fetch/fetch";import{Spotify as D}from"arctic";var R=t=>{let i=new D(t.clientId,t.clientSecret,n("spotify",t.redirectURI));return{id:"spotify",name:"Spotify",createAuthorizationURL({state:r,scopes:e}){let o=e||["user-read-email"];return i.createAuthorizationURL(r,o)},validateAuthorizationCode:async(r,e,o)=>s({code:r,codeVerifier:e,redirectURI:o||n("spotify",t.redirectURI),options:t,tokenEndpoint:"https://accounts.spotify.com/api/token"}),async getUserInfo(r){let{data:e,error:o}=await $("https://api.spotify.com/v1/me",{method:"GET",headers:{Authorization:`Bearer ${r.accessToken()}`}});return o?null:{user:{id:e.id,name:e.display_name,email:e.email,image:e.images[0]?.url,emailVerified:!1},data:e}}}};import{betterFetch as H}from"@better-fetch/fetch";import{Twitch as j}from"arctic";var w=t=>{let i=new j(t.clientId,t.clientSecret,n("twitch",t.redirectURI));return{id:"twitch",name:"Twitch",createAuthorizationURL({state:r,scopes:e}){let o=e||["activity:write","read"];return i.createAuthorizationURL(r,o)},validateAuthorizationCode:async(r,e,o)=>s({code:r,codeVerifier:e,redirectURI:o||n("twitch",t.redirectURI),options:t,tokenEndpoint:"https://id.twitch.tv/oauth2/token"}),async getUserInfo(r){let{data:e,error:o}=await H("https://api.twitch.tv/helix/users",{method:"GET",headers:{Authorization:`Bearer ${r.accessToken()}`}});return o?null:{user:{id:e.sub,name:e.preferred_username,email:e.email,image:e.picture,emailVerified:!1},data:e}}}};import{betterFetch as N}from"@better-fetch/fetch";import{Twitter as W}from"arctic";var I=t=>{let i=new W(t.clientId,t.clientSecret,n("twitter",t.redirectURI));return{id:"twitter",name:"Twitter",createAuthorizationURL(r){let e=r.scopes||["account_info.read"];return i.createAuthorizationURL(r.state,r.codeVerifier,e)},validateAuthorizationCode:async(r,e,o)=>s({code:r,codeVerifier:e,redirectURI:o||n("twitch",t.redirectURI),options:t,tokenEndpoint:"https://id.twitch.tv/oauth2/token"}),async getUserInfo(r){let{data:e,error:o}=await N("https://api.x.com/2/users/me?user.fields=profile_image_url",{method:"GET",headers:{Authorization:`Bearer ${r.accessToken()}`}});return o||!e.data.email?null:{user:{id:e.data.id,name:e.data.name,email:e.data.email,image:e.data.profile_image_url,emailVerified:e.data.verified||!1},data:e}}}};import"arctic";var X={apple:h,discord:b,facebook:_,github:y,google:v,spotify:R,twitch:w,twitter:I},Ze=Object.keys(X);export{h as apple,b as discord,_ as facebook,y as github,v as google,Ze as oAuthProviderList,X as oAuthProviders,R as spotify,w as twitch,I as twitter};
@@ -1,12 +1,10 @@
1
- import { d as Auth } from './index-D_ohe9r9.js';
1
+ import { d as Auth } from './index-gO-yM4kI.js';
2
2
  import 'kysely';
3
- import './schema-D9o3OF80.js';
3
+ import './index-CE92ti2Z.js';
4
+ import 'arctic';
4
5
  import 'zod';
5
- import 'better-call';
6
6
  import './helper-C1ihmerM.js';
7
- import './social.js';
8
- import 'arctic';
9
- import './adapter-D-m9-hQp.js';
7
+ import 'better-call';
10
8
 
11
9
  declare function toSolidStartHandler(auth: Auth | Auth["handler"]): {
12
10
  GET: (event: {
@@ -1 +1 @@
1
- var d=(t,n,r)=>new Promise((h,a)=>{var l=e=>{try{u(r.next(e))}catch(o){a(o)}},s=e=>{try{u(r.throw(e))}catch(o){a(o)}},u=e=>e.done?h(e.value):Promise.resolve(e.value).then(l,s);u((r=r.apply(t,n)).next())});function q(t){let n=r=>d(this,null,function*(){return"handler"in t?t.handler(r.request):t(r.request)});return{GET:n,POST:n}}export{q as toSolidStartHandler};
1
+ function n(r){let e=async t=>"handler"in r?r.handler(t.request):r(t.request);return{GET:e,POST:e}}export{n as toSolidStartHandler};
package/dist/solid.d.ts CHANGED
@@ -1,15 +1,13 @@
1
1
  import * as _better_fetch_fetch from '@better-fetch/fetch';
2
- import { B as BetterAuthPlugin, F as FieldAttribute, I as InferFieldOutput } from './index-D_ohe9r9.js';
2
+ import { B as BetterAuthPlugin, F as FieldAttribute, I as InferFieldOutput } from './index-gO-yM4kI.js';
3
3
  import { U as UnionToIntersection, P as Prettify } from './helper-C1ihmerM.js';
4
4
  import { ClientOptions, InferClientAPI, InferActions, BetterAuthClientPlugin, IsSignal } from './types.js';
5
5
  import { Accessor } from 'solid-js';
6
6
  import 'kysely';
7
- import './schema-D9o3OF80.js';
7
+ import './index-CE92ti2Z.js';
8
+ import 'arctic';
8
9
  import 'zod';
9
10
  import 'better-call';
10
- import './social.js';
11
- import 'arctic';
12
- import './adapter-D-m9-hQp.js';
13
11
  import 'nanostores';
14
12
 
15
13
  type InferResolvedHooks<O extends ClientOptions> = O["plugins"] extends Array<infer Plugin> ? Plugin extends BetterAuthClientPlugin ? Plugin["getAtoms"] extends (fetch: any) => infer Atoms ? Atoms extends Record<string, any> ? {
package/dist/solid.js CHANGED
@@ -1 +1 @@
1
- var K=Object.defineProperty,X=Object.defineProperties;var D=Object.getOwnPropertyDescriptors;var R=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable;var C=(e,t,r)=>t in e?K(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,l=(e,t)=>{for(var r in t||(t={}))w.call(t,r)&&C(e,r,t[r]);if(R)for(var r of R(t))x.call(t,r)&&C(e,r,t[r]);return e},m=(e,t)=>X(e,D(t));var B=(e,t)=>{var r={};for(var i in e)w.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(e!=null&&R)for(var i of R(e))t.indexOf(i)<0&&x.call(e,i)&&(r[i]=e[i]);return r};var y=(e,t,r)=>new Promise((i,n)=>{var d=f=>{try{s(r.next(f))}catch(u){n(u)}},c=f=>{try{s(r.throw(f))}catch(u){n(u)}},s=f=>f.done?i(f.value):Promise.resolve(f.value).then(d,c);s((r=r.apply(e,t)).next())});import{useStore as H}from"@nanostores/solid";import{createFetch as V}from"@better-fetch/fetch";var p=class extends Error{constructor(t,r,i){super(t),this.name="BetterAuthError",this.message=t,this.cause=r}};function Q(e){try{return new URL(e).pathname!=="/"}catch(t){throw new p(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function b(e,t="/api/auth"){return Q(e)?e:(t=t.startsWith("/")?t:`/${t}`,`${e}${t}`)}function E(e,t){if(e)return b(e,t);let r=(process==null?void 0:process.env)||{},i=r.BETTER_AUTH_URL||r.NEXT_PUBLIC_BETTER_AUTH_URL||r.PUBLIC_BETTER_AUTH_URL||r.NUXT_PUBLIC_BETTER_AUTH_URL||r.NUXT_PUBLIC_AUTH_URL||(r.BASE_URL!=="/"?r.BASE_URL:void 0);if(i)return b(i,t);if(typeof window!="undefined")return b(window.location.origin,t)}import"nanostores";import{betterFetch as J}from"@better-fetch/fetch";var _={id:"redirect",name:"Redirect",hooks:{onSuccess(e){var t,r;(t=e.data)!=null&&t.url&&((r=e.data)!=null&&r.redirect)&&typeof window!="undefined"&&(window.location.href=e.data.url)}}},k={id:"add-current-url",name:"Add current URL",hooks:{onRequest(e){if(typeof window!="undefined"){let t=new URL(e.url);t.searchParams.set("currentURL",window.location.href),e.url=t}return e}}},I=new Map,v={id:"csrf",name:"CSRF Check",init(e,t){return y(this,null,function*(){if(!(t!=null&&t.baseURL))throw new p("API Base URL on the auth client isn't configured. Please pass it directly to the client `baseURL`");if((t==null?void 0:t.method)!=="GET"){t=t||{};let r=I.get("CSRF_TOKEN");if(!r){let{data:i,error:n}=yield J("/csrf",{body:void 0,baseURL:t.baseURL,plugins:[],method:"GET",credentials:"include",customFetchImpl:t.customFetchImpl});if(n){if(n.status===404)throw new p("CSRF route not found. Make sure the server is running and the base URL is correct and includes the path (e.g. http://localhost:3000/api/auth).");if(n.status===429)return new Response(JSON.stringify({message:"Too many requests. Please try again later."}),{status:429,statusText:"Too Many Requests"});throw new p("Failed to fetch CSRF token: "+n.message)}I.set("CSRF_TOKEN",i.csrfToken)}t.body=m(l({},t==null?void 0:t.body),{csrfToken:r})}return t.credentials="include",{url:e,options:t}})}};var $=e=>{var s,f,u,o,g,P;let t=V(m(l({baseURL:E(((s=e==null?void 0:e.fetchOptions)==null?void 0:s.baseURL)||(e==null?void 0:e.baseURL)),credentials:"include"},e==null?void 0:e.fetchOptions),{plugins:[v,_,k,...((u=(f=e==null?void 0:e.fetchOptions)==null?void 0:f.plugins)==null?void 0:u.filter(a=>a!==void 0))||[],...((o=e==null?void 0:e.plugins)==null?void 0:o.flatMap(a=>a.fetchPlugins).filter(a=>a!==void 0))||[]]})),r=(e==null?void 0:e.plugins)||[],i={},n={},d={"/sign-out":"POST","/user/revoke-sessions":"POST"},c=[{signal:"_sessionSignal",matcher(a){return a==="/sign-out"||a==="sign-up/email"||a==="/user/update"}}];for(let a of r)a.getActions&&Object.assign(i,(g=a.getActions)==null?void 0:g.call(a,t)),a.getAtoms&&Object.assign(n,(P=a.getAtoms)==null?void 0:P.call(a,t)),a.pathMethods&&Object.assign(d,a.pathMethods),a.atomListeners&&c.push(...a.atomListeners);return{pluginsActions:i,pluginsAtoms:n,pluginPathMethods:d,atomListeners:c,$fetch:t}};function Z(e,t,r){let i=t[e],s=r||{},{fetchOptions:n,query:d}=s,c=B(s,["fetchOptions","query"]);return i||(n!=null&&n.method?n.method:c&&Object.keys(c).length>0?"POST":"GET")}function q(e,t,r,i,n){function d(c=[]){return new Proxy(function(){},{get(s,f){let u=[...c,f],o=e;for(let g of u)if(o&&typeof o=="object"&&g in o)o=o[g];else{o=void 0;break}return typeof o=="function"?o:d(u)},apply:(s,f,u)=>y(this,null,function*(){let o="/"+c.map(U=>U.replace(/[A-Z]/g,A=>`-${A.toLowerCase()}`)).join("/"),g=u[0]||{},P=u[1]||{},S=g,{query:a,fetchOptions:T}=S,G=B(S,["query","fetchOptions"]),h=l(l({},P),T),F=Z(o,r,g);return yield t(o,m(l({},h),{body:F==="GET"?void 0:l(l({},G),(h==null?void 0:h.body)||{}),query:a||(h==null?void 0:h.query),method:F,onSuccess(U){return y(this,null,function*(){var L;yield(L=h==null?void 0:h.onSuccess)==null?void 0:L.call(h,U);let A=n==null?void 0:n.find(z=>z.matcher(o));if(!A)return;let O=i[A.signal];if(!O)return;let N=O.get();setTimeout(()=>{O.set(!N)},10)})}}))})})}return d()}function W(e){return e.charAt(0).toUpperCase()+e.slice(1)}import{atom as te}from"nanostores";import"@better-fetch/fetch";import{atom as Y,onMount as ee}from"nanostores";var M=(e,t,r,i)=>{let n=Y({data:null,error:null,isPending:!1}),d=()=>{let s=typeof i=="function"?i({data:n.get().data,error:n.get().error,isPending:n.get().isPending}):i;return r(t,m(l({},s),{onSuccess:u=>y(void 0,null,function*(){var o;n.set({data:u.data,error:null,isPending:!1}),yield(o=s==null?void 0:s.onSuccess)==null?void 0:o.call(s,u)}),onError(u){return y(this,null,function*(){var o;n.set({error:u.error,data:null,isPending:!1}),yield(o=s==null?void 0:s.onError)==null?void 0:o.call(s,u)})},onRequest(u){return y(this,null,function*(){var g;let o=n.get();n.set({isPending:!0,data:o.data,error:o.error}),yield(g=s==null?void 0:s.onRequest)==null?void 0:g.call(s,u)})}}))};e=Array.isArray(e)?e:[e];let c=!1;for(let s of e)s.subscribe(()=>{c?d():ee(n,()=>(d(),c=!0,()=>{n.off(),s.off()}))});return n};function j(e){let t=te(!1);return{$session:M(t,"/session",e,{method:"GET"}),_sessionSignal:t,$Infer:{}}}function re(e){return`use${W(e)}`}function Ie(e){let{pluginPathMethods:t,pluginsActions:r,pluginsAtoms:i,$fetch:n,atomListeners:d}=$(e),c={};for(let[a,T]of Object.entries(i))c[re(a)]=()=>H(T);let{$session:s,_sessionSignal:f,$Infer:u}=j(n);function o(){return H(s)}let g=m(l(l({},r),c),{useSession:o});return q(g,n,t,m(l({},i),{_sessionSignal:f}),d)}export{Ie as createAuthClient};
1
+ import{useStore as E}from"@nanostores/solid";import{createFetch as q}from"@better-fetch/fetch";var f=class extends Error{constructor(t,s,i){super(t),this.name="BetterAuthError",this.message=t,this.cause=s}};function v(e){try{return new URL(e).pathname!=="/"}catch{throw new f(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function A(e,t="/api/auth"){return v(e)?e:(t=t.startsWith("/")?t:`/${t}`,`${e}${t}`)}function U(e,t){if(e)return A(e,t);let s=process?.env||{},i=s.BETTER_AUTH_URL||s.NEXT_PUBLIC_BETTER_AUTH_URL||s.PUBLIC_BETTER_AUTH_URL||s.NUXT_PUBLIC_BETTER_AUTH_URL||s.NUXT_PUBLIC_AUTH_URL||(s.BASE_URL!=="/"?s.BASE_URL:void 0);if(i)return A(i,t);if(typeof window<"u")return A(window.location.origin,t)}import"nanostores";import{betterFetch as $}from"@better-fetch/fetch";var B={id:"redirect",name:"Redirect",hooks:{onSuccess(e){e.data?.url&&e.data?.redirect&&typeof window<"u"&&(window.location.href=e.data.url)}}},b={id:"add-current-url",name:"Add current URL",hooks:{onRequest(e){if(typeof window<"u"){let t=new URL(e.url);t.searchParams.set("currentURL",window.location.href),e.url=t}return e}}},O=new Map,L={id:"csrf",name:"CSRF Check",async init(e,t){if(!t?.baseURL)throw new f("API Base URL on the auth client isn't configured. Please pass it directly to the client `baseURL`");if(t?.method!=="GET"){t=t||{};let s=O.get("CSRF_TOKEN");if(!s){let{data:i,error:r}=await $("/csrf",{body:void 0,baseURL:t.baseURL,plugins:[],method:"GET",credentials:"include",customFetchImpl:t.customFetchImpl});if(r){if(r.status===404)throw new f("CSRF route not found. Make sure the server is running and the base URL is correct and includes the path (e.g. http://localhost:3000/api/auth).");if(r.status===429)return new Response(JSON.stringify({message:"Too many requests. Please try again later."}),{status:429,statusText:"Too Many Requests"});throw new f("Failed to fetch CSRF token: "+r.message)}O.set("CSRF_TOKEN",i.csrfToken)}t.body={...t?.body,csrfToken:s}}return t.credentials="include",{url:e,options:t}}};var F=e=>{let t=q({baseURL:U(e?.fetchOptions?.baseURL||e?.baseURL),credentials:"include",...e?.fetchOptions,plugins:[L,B,b,...e?.fetchOptions?.plugins?.filter(n=>n!==void 0)||[],...e?.plugins?.flatMap(n=>n.fetchPlugins).filter(n=>n!==void 0)||[]]}),s=e?.plugins||[],i={},r={},c={"/sign-out":"POST","/user/revoke-sessions":"POST"},o=[{signal:"_sessionSignal",matcher(n){return n==="/sign-out"||n==="sign-up/email"||n==="/user/update"}}];for(let n of s)n.getActions&&Object.assign(i,n.getActions?.(t)),n.getAtoms&&Object.assign(r,n.getAtoms?.(t)),n.pathMethods&&Object.assign(c,n.pathMethods),n.atomListeners&&o.push(...n.atomListeners);return{pluginsActions:i,pluginsAtoms:r,pluginPathMethods:c,atomListeners:o,$fetch:t}};function W(e,t,s){let i=t[e],{fetchOptions:r,query:c,...o}=s||{};return i||(r?.method?r.method:o&&Object.keys(o).length>0?"POST":"GET")}function S(e,t,s,i,r){function c(o=[]){return new Proxy(function(){},{get(n,u){let l=[...o,u],a=e;for(let d of l)if(a&&typeof a=="object"&&d in a)a=a[d];else{a=void 0;break}return typeof a=="function"?a:c(l)},apply:async(n,u,l)=>{let a="/"+o.map(y=>y.replace(/[A-Z]/g,g=>`-${g.toLowerCase()}`)).join("/"),d=l[0]||{},R=l[1]||{},{query:h,fetchOptions:m,...I}=d,p={...R,...m},T=W(a,s,d);return await t(a,{...p,body:T==="GET"?void 0:{...I,...p?.body||{}},query:h||p?.query,method:T,async onSuccess(y){await p?.onSuccess?.(y);let g=r?.find(k=>k.matcher(a));if(!g)return;let P=i[g.signal];if(!P)return;let _=P.get();setTimeout(()=>{P.set(!_)},10)}})}})}return c()}function C(e){return e.charAt(0).toUpperCase()+e.slice(1)}import{atom as H}from"nanostores";import"@better-fetch/fetch";import{atom as M,onMount as j}from"nanostores";var w=(e,t,s,i)=>{let r=M({data:null,error:null,isPending:!1}),c=()=>{let n=typeof i=="function"?i({data:r.get().data,error:r.get().error,isPending:r.get().isPending}):i;return s(t,{...n,onSuccess:async u=>{r.set({data:u.data,error:null,isPending:!1}),await n?.onSuccess?.(u)},async onError(u){r.set({error:u.error,data:null,isPending:!1}),await n?.onError?.(u)},async onRequest(u){let l=r.get();r.set({isPending:!0,data:l.data,error:l.error}),await n?.onRequest?.(u)}})};e=Array.isArray(e)?e:[e];let o=!1;for(let n of e)n.subscribe(()=>{o?c():j(r,()=>(c(),o=!0,()=>{r.off(),n.off()}))});return r};function x(e){let t=H(!1);return{$session:w(t,"/session",e,{method:"GET"}),_sessionSignal:t,$Infer:{}}}function G(e){return`use${C(e)}`}function he(e){let{pluginPathMethods:t,pluginsActions:s,pluginsAtoms:i,$fetch:r,atomListeners:c}=F(e),o={};for(let[h,m]of Object.entries(i))o[G(h)]=()=>E(m);let{$session:n,_sessionSignal:u,$Infer:l}=x(r);function a(){return E(n)}let d={...s,...o,useSession:a};return S(d,r,t,{...i,_sessionSignal:u},c)}export{he as createAuthClient};
@@ -1,12 +1,10 @@
1
- import { d as Auth, e as BetterAuthOptions } from './index-D_ohe9r9.js';
1
+ import { d as Auth, e as BetterAuthOptions } from './index-gO-yM4kI.js';
2
2
  import 'kysely';
3
- import './schema-D9o3OF80.js';
3
+ import './index-CE92ti2Z.js';
4
+ import 'arctic';
4
5
  import 'zod';
5
- import 'better-call';
6
6
  import './helper-C1ihmerM.js';
7
- import './social.js';
8
- import 'arctic';
9
- import './adapter-D-m9-hQp.js';
7
+ import 'better-call';
10
8
 
11
9
  declare const toSvelteKitHandler: (auth: Auth) => (event: {
12
10
  request: Request;
package/dist/svelte.d.ts CHANGED
@@ -1,15 +1,13 @@
1
1
  import * as nanostores from 'nanostores';
2
2
  import * as _better_fetch_fetch from '@better-fetch/fetch';
3
- import { B as BetterAuthPlugin, F as FieldAttribute, I as InferFieldOutput } from './index-D_ohe9r9.js';
3
+ import { B as BetterAuthPlugin, F as FieldAttribute, I as InferFieldOutput } from './index-gO-yM4kI.js';
4
4
  import { U as UnionToIntersection, P as Prettify } from './helper-C1ihmerM.js';
5
5
  import { ClientOptions, InferClientAPI, InferActions, BetterAuthClientPlugin, IsSignal } from './types.js';
6
6
  import 'kysely';
7
- import './schema-D9o3OF80.js';
7
+ import './index-CE92ti2Z.js';
8
+ import 'arctic';
8
9
  import 'zod';
9
10
  import 'better-call';
10
- import './social.js';
11
- import 'arctic';
12
- import './adapter-D-m9-hQp.js';
13
11
 
14
12
  type InferResolvedHooks<O extends ClientOptions> = O["plugins"] extends Array<infer Plugin> ? Plugin extends BetterAuthClientPlugin ? Plugin["getAtoms"] extends (fetch: any) => infer Atoms ? Atoms extends Record<string, any> ? {
15
13
  [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: () => Atoms[key];
package/dist/svelte.js CHANGED
@@ -1 +1 @@
1
- var z=Object.defineProperty,X=Object.defineProperties;var D=Object.getOwnPropertyDescriptors;var R=Object.getOwnPropertySymbols;var S=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var C=(e,t,r)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,l=(e,t)=>{for(var r in t||(t={}))S.call(t,r)&&C(e,r,t[r]);if(R)for(var r of R(t))w.call(t,r)&&C(e,r,t[r]);return e},m=(e,t)=>X(e,D(t));var O=(e,t)=>{var r={};for(var i in e)S.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(e!=null&&R)for(var i of R(e))t.indexOf(i)<0&&w.call(e,i)&&(r[i]=e[i]);return r};var y=(e,t,r)=>new Promise((i,n)=>{var d=f=>{try{s(r.next(f))}catch(u){n(u)}},c=f=>{try{s(r.throw(f))}catch(u){n(u)}},s=f=>f.done?i(f.value):Promise.resolve(f.value).then(d,c);s((r=r.apply(e,t)).next())});import{createFetch as J}from"@better-fetch/fetch";var p=class extends Error{constructor(t,r,i){super(t),this.name="BetterAuthError",this.message=t,this.cause=r}};function K(e){try{return new URL(e).pathname!=="/"}catch(t){throw new p(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function B(e,t="/api/auth"){return K(e)?e:(t=t.startsWith("/")?t:`/${t}`,`${e}${t}`)}function x(e,t){if(e)return B(e,t);let r=(process==null?void 0:process.env)||{},i=r.BETTER_AUTH_URL||r.NEXT_PUBLIC_BETTER_AUTH_URL||r.PUBLIC_BETTER_AUTH_URL||r.NUXT_PUBLIC_BETTER_AUTH_URL||r.NUXT_PUBLIC_AUTH_URL||(r.BASE_URL!=="/"?r.BASE_URL:void 0);if(i)return B(i,t);if(typeof window!="undefined")return B(window.location.origin,t)}import"nanostores";import{betterFetch as Q}from"@better-fetch/fetch";var I={id:"redirect",name:"Redirect",hooks:{onSuccess(e){var t,r;(t=e.data)!=null&&t.url&&((r=e.data)!=null&&r.redirect)&&typeof window!="undefined"&&(window.location.href=e.data.url)}}},_={id:"add-current-url",name:"Add current URL",hooks:{onRequest(e){if(typeof window!="undefined"){let t=new URL(e.url);t.searchParams.set("currentURL",window.location.href),e.url=t}return e}}},E=new Map,k={id:"csrf",name:"CSRF Check",init(e,t){return y(this,null,function*(){if(!(t!=null&&t.baseURL))throw new p("API Base URL on the auth client isn't configured. Please pass it directly to the client `baseURL`");if((t==null?void 0:t.method)!=="GET"){t=t||{};let r=E.get("CSRF_TOKEN");if(!r){let{data:i,error:n}=yield Q("/csrf",{body:void 0,baseURL:t.baseURL,plugins:[],method:"GET",credentials:"include",customFetchImpl:t.customFetchImpl});if(n){if(n.status===404)throw new p("CSRF route not found. Make sure the server is running and the base URL is correct and includes the path (e.g. http://localhost:3000/api/auth).");if(n.status===429)return new Response(JSON.stringify({message:"Too many requests. Please try again later."}),{status:429,statusText:"Too Many Requests"});throw new p("Failed to fetch CSRF token: "+n.message)}E.set("CSRF_TOKEN",i.csrfToken)}t.body=m(l({},t==null?void 0:t.body),{csrfToken:r})}return t.credentials="include",{url:e,options:t}})}};var v=e=>{var s,f,u,o,h,P;let t=J(m(l({baseURL:x(((s=e==null?void 0:e.fetchOptions)==null?void 0:s.baseURL)||(e==null?void 0:e.baseURL)),credentials:"include"},e==null?void 0:e.fetchOptions),{plugins:[k,I,_,...((u=(f=e==null?void 0:e.fetchOptions)==null?void 0:f.plugins)==null?void 0:u.filter(a=>a!==void 0))||[],...((o=e==null?void 0:e.plugins)==null?void 0:o.flatMap(a=>a.fetchPlugins).filter(a=>a!==void 0))||[]]})),r=(e==null?void 0:e.plugins)||[],i={},n={},d={"/sign-out":"POST","/user/revoke-sessions":"POST"},c=[{signal:"_sessionSignal",matcher(a){return a==="/sign-out"||a==="sign-up/email"||a==="/user/update"}}];for(let a of r)a.getActions&&Object.assign(i,(h=a.getActions)==null?void 0:h.call(a,t)),a.getAtoms&&Object.assign(n,(P=a.getAtoms)==null?void 0:P.call(a,t)),a.pathMethods&&Object.assign(d,a.pathMethods),a.atomListeners&&c.push(...a.atomListeners);return{pluginsActions:i,pluginsAtoms:n,pluginPathMethods:d,atomListeners:c,$fetch:t}};function $(e){return e.charAt(0).toUpperCase()+e.slice(1)}function V(e,t,r){let i=t[e],s=r||{},{fetchOptions:n,query:d}=s,c=O(s,["fetchOptions","query"]);return i||(n!=null&&n.method?n.method:c&&Object.keys(c).length>0?"POST":"GET")}function q(e,t,r,i,n){function d(c=[]){return new Proxy(function(){},{get(s,f){let u=[...c,f],o=e;for(let h of u)if(o&&typeof o=="object"&&h in o)o=o[h];else{o=void 0;break}return typeof o=="function"?o:d(u)},apply:(s,f,u)=>y(this,null,function*(){let o="/"+c.map(T=>T.replace(/[A-Z]/g,A=>`-${A.toLowerCase()}`)).join("/"),h=u[0]||{},P=u[1]||{},F=h,{query:a,fetchOptions:H}=F,j=O(F,["query","fetchOptions"]),g=l(l({},P),H),b=V(o,r,h);return yield t(o,m(l({},g),{body:b==="GET"?void 0:l(l({},j),(g==null?void 0:g.body)||{}),query:a||(g==null?void 0:g.query),method:b,onSuccess(T){return y(this,null,function*(){var L;yield(L=g==null?void 0:g.onSuccess)==null?void 0:L.call(g,T);let A=n==null?void 0:n.find(N=>N.matcher(o));if(!A)return;let U=i[A.signal];if(!U)return;let G=U.get();setTimeout(()=>{U.set(!G)},10)})}}))})})}return d()}import{atom as ee}from"nanostores";import"@better-fetch/fetch";import{atom as Z,onMount as Y}from"nanostores";var W=(e,t,r,i)=>{let n=Z({data:null,error:null,isPending:!1}),d=()=>{let s=typeof i=="function"?i({data:n.get().data,error:n.get().error,isPending:n.get().isPending}):i;return r(t,m(l({},s),{onSuccess:u=>y(void 0,null,function*(){var o;n.set({data:u.data,error:null,isPending:!1}),yield(o=s==null?void 0:s.onSuccess)==null?void 0:o.call(s,u)}),onError(u){return y(this,null,function*(){var o;n.set({error:u.error,data:null,isPending:!1}),yield(o=s==null?void 0:s.onError)==null?void 0:o.call(s,u)})},onRequest(u){return y(this,null,function*(){var h;let o=n.get();n.set({isPending:!0,data:o.data,error:o.error}),yield(h=s==null?void 0:s.onRequest)==null?void 0:h.call(s,u)})}}))};e=Array.isArray(e)?e:[e];let c=!1;for(let s of e)s.subscribe(()=>{c?d():Y(n,()=>(d(),c=!0,()=>{n.off(),s.off()}))});return n};function M(e){let t=ee(!1);return{$session:W(t,"/session",e,{method:"GET"}),_sessionSignal:t,$Infer:{}}}function we(e){let{pluginPathMethods:t,pluginsActions:r,pluginsAtoms:i,$fetch:n,atomListeners:d}=v(e),c={};for(let[P,a]of Object.entries(i))c[`use${$(P)}`]=()=>a;let{$session:s,_sessionSignal:f,$Infer:u}=M(n),o=m(l(l({},r),c),{useSession:()=>s});return q(o,n,t,m(l({},i),{_sessionSignal:f}),d)}export{we as createAuthClient};
1
+ import{createFetch as $}from"@better-fetch/fetch";var f=class extends Error{constructor(t,s,i){super(t),this.name="BetterAuthError",this.message=t,this.cause=s}};function k(e){try{return new URL(e).pathname!=="/"}catch{throw new f(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function A(e,t="/api/auth"){return k(e)?e:(t=t.startsWith("/")?t:`/${t}`,`${e}${t}`)}function T(e,t){if(e)return A(e,t);let s=process?.env||{},i=s.BETTER_AUTH_URL||s.NEXT_PUBLIC_BETTER_AUTH_URL||s.PUBLIC_BETTER_AUTH_URL||s.NUXT_PUBLIC_BETTER_AUTH_URL||s.NUXT_PUBLIC_AUTH_URL||(s.BASE_URL!=="/"?s.BASE_URL:void 0);if(i)return A(i,t);if(typeof window<"u")return A(window.location.origin,t)}import"nanostores";import{betterFetch as v}from"@better-fetch/fetch";var O={id:"redirect",name:"Redirect",hooks:{onSuccess(e){e.data?.url&&e.data?.redirect&&typeof window<"u"&&(window.location.href=e.data.url)}}},B={id:"add-current-url",name:"Add current URL",hooks:{onRequest(e){if(typeof window<"u"){let t=new URL(e.url);t.searchParams.set("currentURL",window.location.href),e.url=t}return e}}},U=new Map,b={id:"csrf",name:"CSRF Check",async init(e,t){if(!t?.baseURL)throw new f("API Base URL on the auth client isn't configured. Please pass it directly to the client `baseURL`");if(t?.method!=="GET"){t=t||{};let s=U.get("CSRF_TOKEN");if(!s){let{data:i,error:r}=await v("/csrf",{body:void 0,baseURL:t.baseURL,plugins:[],method:"GET",credentials:"include",customFetchImpl:t.customFetchImpl});if(r){if(r.status===404)throw new f("CSRF route not found. Make sure the server is running and the base URL is correct and includes the path (e.g. http://localhost:3000/api/auth).");if(r.status===429)return new Response(JSON.stringify({message:"Too many requests. Please try again later."}),{status:429,statusText:"Too Many Requests"});throw new f("Failed to fetch CSRF token: "+r.message)}U.set("CSRF_TOKEN",i.csrfToken)}t.body={...t?.body,csrfToken:s}}return t.credentials="include",{url:e,options:t}}};var L=e=>{let t=$({baseURL:T(e?.fetchOptions?.baseURL||e?.baseURL),credentials:"include",...e?.fetchOptions,plugins:[b,O,B,...e?.fetchOptions?.plugins?.filter(n=>n!==void 0)||[],...e?.plugins?.flatMap(n=>n.fetchPlugins).filter(n=>n!==void 0)||[]]}),s=e?.plugins||[],i={},r={},c={"/sign-out":"POST","/user/revoke-sessions":"POST"},o=[{signal:"_sessionSignal",matcher(n){return n==="/sign-out"||n==="sign-up/email"||n==="/user/update"}}];for(let n of s)n.getActions&&Object.assign(i,n.getActions?.(t)),n.getAtoms&&Object.assign(r,n.getAtoms?.(t)),n.pathMethods&&Object.assign(c,n.pathMethods),n.atomListeners&&o.push(...n.atomListeners);return{pluginsActions:i,pluginsAtoms:r,pluginPathMethods:c,atomListeners:o,$fetch:t}};function F(e){return e.charAt(0).toUpperCase()+e.slice(1)}function q(e,t,s){let i=t[e],{fetchOptions:r,query:c,...o}=s||{};return i||(r?.method?r.method:o&&Object.keys(o).length>0?"POST":"GET")}function C(e,t,s,i,r){function c(o=[]){return new Proxy(function(){},{get(n,u){let l=[...o,u],a=e;for(let d of l)if(a&&typeof a=="object"&&d in a)a=a[d];else{a=void 0;break}return typeof a=="function"?a:c(l)},apply:async(n,u,l)=>{let a="/"+o.map(y=>y.replace(/[A-Z]/g,g=>`-${g.toLowerCase()}`)).join("/"),d=l[0]||{},h=l[1]||{},{query:m,fetchOptions:x,...E}=d,p={...h,...x},R=q(a,s,d);return await t(a,{...p,body:R==="GET"?void 0:{...E,...p?.body||{}},query:m||p?.query,method:R,async onSuccess(y){await p?.onSuccess?.(y);let g=r?.find(_=>_.matcher(a));if(!g)return;let P=i[g.signal];if(!P)return;let I=P.get();setTimeout(()=>{P.set(!I)},10)}})}})}return c()}import{atom as H}from"nanostores";import"@better-fetch/fetch";import{atom as W,onMount as M}from"nanostores";var S=(e,t,s,i)=>{let r=W({data:null,error:null,isPending:!1}),c=()=>{let n=typeof i=="function"?i({data:r.get().data,error:r.get().error,isPending:r.get().isPending}):i;return s(t,{...n,onSuccess:async u=>{r.set({data:u.data,error:null,isPending:!1}),await n?.onSuccess?.(u)},async onError(u){r.set({error:u.error,data:null,isPending:!1}),await n?.onError?.(u)},async onRequest(u){let l=r.get();r.set({isPending:!0,data:l.data,error:l.error}),await n?.onRequest?.(u)}})};e=Array.isArray(e)?e:[e];let o=!1;for(let n of e)n.subscribe(()=>{o?c():M(r,()=>(c(),o=!0,()=>{r.off(),n.off()}))});return r};function w(e){let t=H(!1);return{$session:S(t,"/session",e,{method:"GET"}),_sessionSignal:t,$Infer:{}}}function de(e){let{pluginPathMethods:t,pluginsActions:s,pluginsAtoms:i,$fetch:r,atomListeners:c}=L(e),o={};for(let[h,m]of Object.entries(i))o[`use${F(h)}`]=()=>m;let{$session:n,_sessionSignal:u,$Infer:l}=w(r),a={...s,...o,useSession:()=>n};return C(a,r,t,{...i,_sessionSignal:u},c)}export{de as createAuthClient};
package/dist/types.d.ts CHANGED
@@ -1,13 +1,11 @@
1
- import { B as BetterAuthPlugin, d as Auth, m as InferSession, n as InferUser } from './index-D_ohe9r9.js';
2
- export { f as AuthContext, e as BetterAuthOptions, G as GenericEndpointContext, H as HookEndpointContext, q as InferPluginTypes, P as PluginSchema, R as RateLimit, r as init } from './index-D_ohe9r9.js';
1
+ import { B as BetterAuthPlugin, d as Auth, n as InferSession, q as InferUser } from './index-gO-yM4kI.js';
2
+ export { f as Adapter, g as AuthContext, e as BetterAuthOptions, G as GenericEndpointContext, H as HookEndpointContext, r as InferPluginTypes, P as PluginSchema, R as RateLimit, S as SessionAdapter, W as Where, t as init } from './index-gO-yM4kI.js';
3
3
  import { U as UnionToIntersection, H as HasRequiredKeys, P as Prettify, L as LiteralString } from './helper-C1ihmerM.js';
4
4
  export { a as LiteralUnion, R as RequiredKeysOf, W as WithoutEmpty } from './helper-C1ihmerM.js';
5
- export { OAuthProvider, OAuthProviderList, ProviderOptions } from './social.js';
6
- export { A as Adapter, S as SessionAdapter, W as Where } from './adapter-D-m9-hQp.js';
5
+ export { O as OAuthProvider, f as OAuthProviderList, P as ProviderOptions, S as Session, U as User } from './index-CE92ti2Z.js';
7
6
  import { BetterFetchOption, BetterFetchResponse, BetterFetch, BetterFetchPlugin } from '@better-fetch/fetch';
8
7
  import { Atom } from 'nanostores';
9
8
  import { Endpoint, Context } from 'better-call';
10
- export { S as Session, U as User } from './schema-D9o3OF80.js';
11
9
  import 'kysely';
12
10
  import 'zod';
13
11
  import 'arctic';
package/dist/utils.d.ts CHANGED
@@ -1,14 +1,12 @@
1
- import { f as AuthContext, G as GenericEndpointContext } from './index-D_ohe9r9.js';
2
- export { i as BetterAuthCookies, h as createCookieGetter, k as createLogger, j as deleteSessionCookie, g as getCookies, l as logger, p as parseSetCookieHeader, s as setSessionCookie } from './index-D_ohe9r9.js';
1
+ import { g as AuthContext, G as GenericEndpointContext } from './index-gO-yM4kI.js';
2
+ export { j as BetterAuthCookies, i as createCookieGetter, l as createLogger, k as deleteSessionCookie, h as getCookies, m as logger, p as parseSetCookieHeader, s as setSessionCookie } from './index-gO-yM4kI.js';
3
3
  export { H as HIDE_METADATA } from './hide-metadata-DEHJp1rk.js';
4
4
  import { z } from 'zod';
5
5
  import 'kysely';
6
- import './schema-D9o3OF80.js';
7
- import 'better-call';
8
- import './helper-C1ihmerM.js';
9
- import './social.js';
6
+ import './index-CE92ti2Z.js';
10
7
  import 'arctic';
11
- import './adapter-D-m9-hQp.js';
8
+ import './helper-C1ihmerM.js';
9
+ import 'better-call';
12
10
 
13
11
  declare const shimContext: <T extends Record<string, any>>(originalObject: T, newContext: Record<string, any>) => T;
14
12
  declare const shimEndpoint: (ctx: AuthContext, value: any) => (context: any) => Promise<any>;
package/dist/utils.js CHANGED
@@ -1,2 +1,2 @@
1
- var w=Object.defineProperty,T=Object.defineProperties;var O=Object.getOwnPropertyDescriptors;var C=Object.getOwnPropertySymbols;var E=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable;var b=(e,o,t)=>o in e?w(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t,a=(e,o)=>{for(var t in o||(o={}))E.call(o,t)&&b(e,t,o[t]);if(C)for(var t of C(o))R.call(o,t)&&b(e,t,o[t]);return e},k=(e,o)=>T(e,O(o));var m=(e,o,t)=>new Promise((n,r)=>{var s=i=>{try{c(t.next(i))}catch(p){r(p)}},u=i=>{try{c(t.throw(i))}catch(p){r(p)}},c=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,u);c((t=t.apply(e,o)).next())});var H=(e,o)=>{let t={};for(let[n,r]of Object.entries(e))t[n]=s=>r(k(a({},s),{context:a(a({},o),s.context)})),t[n].path=r.path,t[n].method=r.method,t[n].options=r.options,t[n].headers=r.headers;return t},V=(e,o)=>t=>m(void 0,null,function*(){var s,u;for(let c of e.options.plugins||[])if((s=c.hooks)!=null&&s.before){for(let i of c.hooks.before)if(i.matcher(a(a({},t),o))){let f=yield i.handler(t);f&&"context"in f&&(t=a(a(a({},t),f.context),o))}}let n=o(k(a({},t),{context:a(a({},e),t.context)})),r=n;for(let c of e.options.plugins||[])if((u=c.hooks)!=null&&u.after){for(let i of c.hooks.after)if(i.matcher(t)){let f=Object.assign(t,{returned:n}),l=yield i.handler(f);l&&"response"in l&&(r=l.response)}}return r});var h=class extends Error{constructor(o,t,n){super(o),this.name="BetterAuthError",this.message=o,this.cause=t}};function U(e){try{return new URL(e).pathname!=="/"}catch(o){throw new h(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function x(e,o="/api/auth"){return U(e)?e:(o=o.startsWith("/")?o:`/${o}`,`${e}${o}`)}function X(e,o){if(e)return x(e,o);let t=(process==null?void 0:process.env)||{},n=t.BETTER_AUTH_URL||t.NEXT_PUBLIC_BETTER_AUTH_URL||t.PUBLIC_BETTER_AUTH_URL||t.NUXT_PUBLIC_BETTER_AUTH_URL||t.NUXT_PUBLIC_AUTH_URL||(t.BASE_URL!=="/"?t.BASE_URL:void 0);if(n)return x(n,o);if(typeof window!="undefined")return x(window.location.origin,o)}var A=(e,o)=>{for(let t in e){if(!e.hasOwnProperty(t))continue;let n=e[t];typeof n=="object"&&n!==null?o[t]=A(n,n.constructor()):o[t]=n}return o},y=e=>A(e,e.constructor());import{TimeSpan as S}from"oslo";function W(e){var s;let t=!!((s=e.advanced)!=null&&s.useSecureCookies)||process.env.NODE_ENV!=="development"&&process.env.NODE_ENV!=="test"?"__Secure-":"",n="better-auth",r=new S(7,"d").seconds();return{sessionToken:{name:`${t}${n}.session_token`,options:{httpOnly:!0,sameSite:"lax",path:"/",secure:!!t,maxAge:r}},csrfToken:{name:`${t?"__Host-":""}${n}.csrf_token`,options:{httpOnly:!0,sameSite:"lax",path:"/",secure:!!t,maxAge:60*60*24*7}},state:{name:`${t}${n}.state`,options:{httpOnly:!0,sameSite:"lax",path:"/",secure:!!t,maxAge:60*15}},pkCodeVerifier:{name:`${t}${n}.pk_code_verifier`,options:{httpOnly:!0,sameSite:"lax",path:"/",secure:!!t,maxAge:60*15}},dontRememberToken:{name:`${t}${n}.dont_remember`,options:{httpOnly:!0,sameSite:"lax",path:"/",secure:!!t}},nonce:{name:`${t}${n}.nonce`,options:{httpOnly:!0,sameSite:"lax",path:"/",secure:!!t,maxAge:60*15}}}}function K(e){var s;let t=!!((s=e.advanced)!=null&&s.useSecureCookies)||process.env.NODE_ENV==="production"?"__Secure-":"",n="better-auth";function r(u,c){return{name:process.env.NODE_ENV==="production"?`${t}${n}.${u}`:`${n}.${u}`,options:a({secure:!!t,sameSite:"lax",path:"/",maxAge:60*15},c)}}return r}function Q(e,o,t,n){return m(this,null,function*(){let r=e.context.authCookies.sessionToken.options;r.maxAge=t?void 0:r.maxAge,yield e.setSignedCookie(e.context.authCookies.sessionToken.name,o,e.context.secret,r),t&&(yield e.setSignedCookie(e.context.authCookies.dontRememberToken.name,"true",e.context.secret,e.context.authCookies.dontRememberToken.options))})}function Y(e){e.setCookie(e.context.authCookies.sessionToken.name,"",{maxAge:0}),e.setCookie(e.context.authCookies.dontRememberToken.name,"",{maxAge:0})}function Z(e){let o=new Map;return e.split(", ").forEach(n=>{let[r,...s]=n.split("; "),[u,c]=r.split("="),i={value:c};s.forEach(p=>{let[f,l]=p.split("=");i[f.toLowerCase()]=l||!0}),o.set(u,i)}),o}var oe=(e,o=!1)=>{let t=new Date;return new Date(t.getTime()+(o?e*1e3:e))};function re(e){let o="127.0.0.1";if(process.env.NODE_ENV==="test")return o;let t=["x-client-ip","x-forwarded-for","cf-connecting-ip","fastly-client-ip","x-real-ip","x-cluster-client-ip","x-forwarded","forwarded-for","forwarded"];for(let n of t){let r=e.headers.get(n);if(typeof r=="string"){let s=r.split(",")[0].trim();if(s)return s}}return null}var ie={isAction:!1};import{alphabet as v,generateRandomString as L}from"oslo/crypto";var ue=()=>L(36,v("a-z","0-9"));import{createConsola as P}from"consola";var d=P({formatOptions:{date:!1,colors:!0,compact:!0},defaults:{tag:"Better Auth"}}),$=e=>({log:(...o)=>{!(e!=null&&e.disabled)&&d.log("",...o)},error:(...o)=>{!(e!=null&&e.disabled)&&d.error("",...o)},warn:(...o)=>{!(e!=null&&e.disabled)&&d.warn("",...o)},info:(...o)=>{!(e!=null&&e.disabled)&&d.info("",...o)},debug:(...o)=>{!(e!=null&&e.disabled)&&d.debug("",...o)},box:(...o)=>{!(e!=null&&e.disabled)&&d.box("",...o)},success:(...o)=>{!(e!=null&&e.disabled)&&d.success("",...o)},break:(...o)=>{!(e!=null&&e.disabled)&&console.log(`
2
- `)}}),de=$();var _=(e,o)=>{for(let t in o){if(!o.hasOwnProperty(t)||t==="constructor"||t==="prototype"||t==="__proto__")continue;let n=o[t];N(n)?(n!==void 0||!(t in e))&&(e[t]=n):!e[t]||B(n)?e[t]=y(n):e[t]=_(e[t],n)}return e},B=e=>Array.isArray(e),N=e=>{if(e===null)return!0;let o=typeof e;return o!=="object"&&o!=="function"},ge=e=>{let o=y(e[0]);for(let t=1,n=e.length;t<n;t++)_(o,e[t]);return o};function ke(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ye(e,o){return m(this,null,function*(){let t=yield e.context.internalAdapter.findAccounts(o.userId),n=t==null?void 0:t.find(u=>u.providerId==="credential"),r=n==null?void 0:n.password;return!n||!r?!1:yield e.context.password.verify(r,o.password)})}import{generateState as I}from"oslo/oauth2";import{z as g}from"zod";function we(e,o,t){let n=I();return{state:JSON.stringify({code:n,callbackURL:e,currentURL:o,dontRememberMe:t}),code:n}}function Te(e){return g.object({code:g.string(),callbackURL:g.string().optional(),currentURL:g.string().optional(),dontRememberMe:g.boolean().optional()}).safeParse(JSON.parse(e))}export{ie as HIDE_METADATA,ke as capitalizeFirstLetter,y as clone,K as createCookieGetter,$ as createLogger,Y as deleteSessionCookie,ue as generateId,we as generateState,X as getBaseURL,W as getCookies,oe as getDate,re as getIp,de as logger,ge as merge,Z as parseSetCookieHeader,Te as parseState,Q as setSessionCookie,H as shimContext,V as shimEndpoint,ye as validatePassword};
1
+ var R=(e,o)=>{let t={};for(let[n,r]of Object.entries(e))t[n]=s=>r({...s,context:{...o,...s.context}}),t[n].path=r.path,t[n].method=r.method,t[n].options=r.options,t[n].headers=r.headers;return t},U=(e,o)=>async t=>{for(let s of e.options.plugins||[])if(s.hooks?.before){for(let i of s.hooks.before)if(i.matcher({...t,...o})){let a=await i.handler(t);a&&"context"in a&&(t={...t,...a.context,...o})}}let n=o({...t,context:{...e,...t.context}}),r=n;for(let s of e.options.plugins||[])if(s.hooks?.after){for(let i of s.hooks.after)if(i.matcher(t)){let a=Object.assign(t,{returned:n}),p=await i.handler(a);p&&"response"in p&&(r=p.response)}}return r};var f=class extends Error{constructor(o,t,n){super(o),this.name="BetterAuthError",this.message=o,this.cause=t}};function y(e){try{return new URL(e).pathname!=="/"}catch{throw new f(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function l(e,o="/api/auth"){return y(e)?e:(o=o.startsWith("/")?o:`/${o}`,`${e}${o}`)}function P(e,o){if(e)return l(e,o);let t=process?.env||{},n=t.BETTER_AUTH_URL||t.NEXT_PUBLIC_BETTER_AUTH_URL||t.PUBLIC_BETTER_AUTH_URL||t.NUXT_PUBLIC_BETTER_AUTH_URL||t.NUXT_PUBLIC_AUTH_URL||(t.BASE_URL!=="/"?t.BASE_URL:void 0);if(n)return l(n,o);if(typeof window<"u")return l(window.location.origin,o)}var g=(e,o)=>{for(let t in e){if(!e.hasOwnProperty(t))continue;let n=e[t];typeof n=="object"&&n!==null?o[t]=g(n,n.constructor()):o[t]=n}return o},m=e=>g(e,e.constructor());import{TimeSpan as C}from"oslo";function I(e){let t=!!e.advanced?.useSecureCookies||process.env.NODE_ENV!=="development"&&process.env.NODE_ENV!=="test"?"__Secure-":"",n="better-auth",r=new C(7,"d").seconds();return{sessionToken:{name:`${t}${n}.session_token`,options:{httpOnly:!0,sameSite:"lax",path:"/",secure:!!t,maxAge:r}},csrfToken:{name:`${t?"__Host-":""}${n}.csrf_token`,options:{httpOnly:!0,sameSite:"lax",path:"/",secure:!!t,maxAge:60*60*24*7}},state:{name:`${t}${n}.state`,options:{httpOnly:!0,sameSite:"lax",path:"/",secure:!!t,maxAge:60*15}},pkCodeVerifier:{name:`${t}${n}.pk_code_verifier`,options:{httpOnly:!0,sameSite:"lax",path:"/",secure:!!t,maxAge:60*15}},dontRememberToken:{name:`${t}${n}.dont_remember`,options:{httpOnly:!0,sameSite:"lax",path:"/",secure:!!t}},nonce:{name:`${t}${n}.nonce`,options:{httpOnly:!0,sameSite:"lax",path:"/",secure:!!t,maxAge:60*15}}}}function D(e){let t=!!e.advanced?.useSecureCookies||process.env.NODE_ENV==="production"?"__Secure-":"",n="better-auth";function r(s,i){return{name:process.env.NODE_ENV==="production"?`${t}${n}.${s}`:`${n}.${s}`,options:{secure:!!t,sameSite:"lax",path:"/",maxAge:60*15,...i}}}return r}async function H(e,o,t,n){let r=e.context.authCookies.sessionToken.options;r.maxAge=t?void 0:r.maxAge,await e.setSignedCookie(e.context.authCookies.sessionToken.name,o,e.context.secret,r),t&&await e.setSignedCookie(e.context.authCookies.dontRememberToken.name,"true",e.context.secret,e.context.authCookies.dontRememberToken.options)}function V(e){e.setCookie(e.context.authCookies.sessionToken.name,"",{maxAge:0}),e.setCookie(e.context.authCookies.dontRememberToken.name,"",{maxAge:0})}function j(e){let o=new Map;return e.split(", ").forEach(n=>{let[r,...s]=n.split("; "),[i,d]=r.split("="),a={value:d};s.forEach(p=>{let[k,x]=p.split("=");a[k.toLowerCase()]=x||!0}),o.set(i,a)}),o}var M=(e,o=!1)=>{let t=new Date;return new Date(t.getTime()+(o?e*1e3:e))};function X(e){let o="127.0.0.1";if(process.env.NODE_ENV==="test")return o;let t=["x-client-ip","x-forwarded-for","cf-connecting-ip","fastly-client-ip","x-real-ip","x-cluster-client-ip","x-forwarded","forwarded-for","forwarded"];for(let n of t){let r=e.headers.get(n);if(typeof r=="string"){let s=r.split(",")[0].trim();if(s)return s}}return null}var q={isAction:!1};import{alphabet as b,generateRandomString as A}from"oslo/crypto";var K=()=>A(36,b("a-z","0-9"));import{createConsola as _}from"consola";var c=_({formatOptions:{date:!1,colors:!0,compact:!0},defaults:{tag:"Better Auth"}}),w=e=>({log:(...o)=>{!e?.disabled&&c.log("",...o)},error:(...o)=>{!e?.disabled&&c.error("",...o)},warn:(...o)=>{!e?.disabled&&c.warn("",...o)},info:(...o)=>{!e?.disabled&&c.info("",...o)},debug:(...o)=>{!e?.disabled&&c.debug("",...o)},box:(...o)=>{!e?.disabled&&c.box("",...o)},success:(...o)=>{!e?.disabled&&c.success("",...o)},break:(...o)=>{!e?.disabled&&console.log(`
2
+ `)}}),Z=w();var h=(e,o)=>{for(let t in o){if(!o.hasOwnProperty(t)||t==="constructor"||t==="prototype"||t==="__proto__")continue;let n=o[t];O(n)?(n!==void 0||!(t in e))&&(e[t]=n):!e[t]||T(n)?e[t]=m(n):e[t]=h(e[t],n)}return e},T=e=>Array.isArray(e),O=e=>{if(e===null)return!0;let o=typeof e;return o!=="object"&&o!=="function"},oe=e=>{let o=m(e[0]);for(let t=1,n=e.length;t<n;t++)h(o,e[t]);return o};function re(e){return e.charAt(0).toUpperCase()+e.slice(1)}async function ie(e,o){let n=(await e.context.internalAdapter.findAccounts(o.userId))?.find(i=>i.providerId==="credential"),r=n?.password;return!n||!r?!1:await e.context.password.verify(r,o.password)}import{generateState as E}from"oslo/oauth2";import{z as u}from"zod";function ue(e,o,t){let n=E();return{state:JSON.stringify({code:n,callbackURL:e,currentURL:o,dontRememberMe:t}),code:n}}function fe(e){return u.object({code:u.string(),callbackURL:u.string().optional(),currentURL:u.string().optional(),dontRememberMe:u.boolean().optional()}).safeParse(JSON.parse(e))}export{q as HIDE_METADATA,re as capitalizeFirstLetter,m as clone,D as createCookieGetter,w as createLogger,V as deleteSessionCookie,K as generateId,ue as generateState,P as getBaseURL,I as getCookies,M as getDate,X as getIp,Z as logger,oe as merge,j as parseSetCookieHeader,fe as parseState,H as setSessionCookie,R as shimContext,U as shimEndpoint,ie as validatePassword};
package/dist/vue.d.ts CHANGED
@@ -1,15 +1,13 @@
1
1
  import * as _better_fetch_fetch from '@better-fetch/fetch';
2
- import { B as BetterAuthPlugin, F as FieldAttribute, I as InferFieldOutput } from './index-D_ohe9r9.js';
2
+ import { B as BetterAuthPlugin, F as FieldAttribute, I as InferFieldOutput } from './index-gO-yM4kI.js';
3
3
  import { U as UnionToIntersection, P as Prettify } from './helper-C1ihmerM.js';
4
4
  import { ClientOptions, InferClientAPI, InferActions, BetterAuthClientPlugin, IsSignal } from './types.js';
5
5
  import { Ref, DeepReadonly } from 'vue';
6
6
  import 'kysely';
7
- import './schema-D9o3OF80.js';
7
+ import './index-CE92ti2Z.js';
8
+ import 'arctic';
8
9
  import 'zod';
9
10
  import 'better-call';
10
- import './social.js';
11
- import 'arctic';
12
- import './adapter-D-m9-hQp.js';
13
11
  import 'nanostores';
14
12
 
15
13
  type InferResolvedHooks<O extends ClientOptions> = O["plugins"] extends Array<infer Plugin> ? Plugin extends BetterAuthClientPlugin ? Plugin["getAtoms"] extends (fetch: any) => infer Atoms ? Atoms extends Record<string, any> ? {
package/dist/vue.js CHANGED
@@ -1 +1 @@
1
- var D=Object.defineProperty,K=Object.defineProperties;var X=Object.getOwnPropertyDescriptors;var R=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable;var C=(e,t,r)=>t in e?D(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,l=(e,t)=>{for(var r in t||(t={}))w.call(t,r)&&C(e,r,t[r]);if(R)for(var r of R(t))x.call(t,r)&&C(e,r,t[r]);return e},m=(e,t)=>K(e,X(t));var B=(e,t)=>{var r={};for(var i in e)w.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(e!=null&&R)for(var i of R(e))t.indexOf(i)<0&&x.call(e,i)&&(r[i]=e[i]);return r};var y=(e,t,r)=>new Promise((i,n)=>{var d=f=>{try{s(r.next(f))}catch(u){n(u)}},c=f=>{try{s(r.throw(f))}catch(u){n(u)}},s=f=>f.done?i(f.value):Promise.resolve(f.value).then(d,c);s((r=r.apply(e,t)).next())});import{useStore as j}from"@nanostores/vue";import{createFetch as V}from"@better-fetch/fetch";var p=class extends Error{constructor(t,r,i){super(t),this.name="BetterAuthError",this.message=t,this.cause=r}};function Q(e){try{return new URL(e).pathname!=="/"}catch(t){throw new p(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function b(e,t="/api/auth"){return Q(e)?e:(t=t.startsWith("/")?t:`/${t}`,`${e}${t}`)}function E(e,t){if(e)return b(e,t);let r=(process==null?void 0:process.env)||{},i=r.BETTER_AUTH_URL||r.NEXT_PUBLIC_BETTER_AUTH_URL||r.PUBLIC_BETTER_AUTH_URL||r.NUXT_PUBLIC_BETTER_AUTH_URL||r.NUXT_PUBLIC_AUTH_URL||(r.BASE_URL!=="/"?r.BASE_URL:void 0);if(i)return b(i,t);if(typeof window!="undefined")return b(window.location.origin,t)}import"nanostores";import{betterFetch as J}from"@better-fetch/fetch";var _={id:"redirect",name:"Redirect",hooks:{onSuccess(e){var t,r;(t=e.data)!=null&&t.url&&((r=e.data)!=null&&r.redirect)&&typeof window!="undefined"&&(window.location.href=e.data.url)}}},k={id:"add-current-url",name:"Add current URL",hooks:{onRequest(e){if(typeof window!="undefined"){let t=new URL(e.url);t.searchParams.set("currentURL",window.location.href),e.url=t}return e}}},I=new Map,v={id:"csrf",name:"CSRF Check",init(e,t){return y(this,null,function*(){if(!(t!=null&&t.baseURL))throw new p("API Base URL on the auth client isn't configured. Please pass it directly to the client `baseURL`");if((t==null?void 0:t.method)!=="GET"){t=t||{};let r=I.get("CSRF_TOKEN");if(!r){let{data:i,error:n}=yield J("/csrf",{body:void 0,baseURL:t.baseURL,plugins:[],method:"GET",credentials:"include",customFetchImpl:t.customFetchImpl});if(n){if(n.status===404)throw new p("CSRF route not found. Make sure the server is running and the base URL is correct and includes the path (e.g. http://localhost:3000/api/auth).");if(n.status===429)return new Response(JSON.stringify({message:"Too many requests. Please try again later."}),{status:429,statusText:"Too Many Requests"});throw new p("Failed to fetch CSRF token: "+n.message)}I.set("CSRF_TOKEN",i.csrfToken)}t.body=m(l({},t==null?void 0:t.body),{csrfToken:r})}return t.credentials="include",{url:e,options:t}})}};var $=e=>{var s,f,u,o,g,P;let t=V(m(l({baseURL:E(((s=e==null?void 0:e.fetchOptions)==null?void 0:s.baseURL)||(e==null?void 0:e.baseURL)),credentials:"include"},e==null?void 0:e.fetchOptions),{plugins:[v,_,k,...((u=(f=e==null?void 0:e.fetchOptions)==null?void 0:f.plugins)==null?void 0:u.filter(a=>a!==void 0))||[],...((o=e==null?void 0:e.plugins)==null?void 0:o.flatMap(a=>a.fetchPlugins).filter(a=>a!==void 0))||[]]})),r=(e==null?void 0:e.plugins)||[],i={},n={},d={"/sign-out":"POST","/user/revoke-sessions":"POST"},c=[{signal:"_sessionSignal",matcher(a){return a==="/sign-out"||a==="sign-up/email"||a==="/user/update"}}];for(let a of r)a.getActions&&Object.assign(i,(g=a.getActions)==null?void 0:g.call(a,t)),a.getAtoms&&Object.assign(n,(P=a.getAtoms)==null?void 0:P.call(a,t)),a.pathMethods&&Object.assign(d,a.pathMethods),a.atomListeners&&c.push(...a.atomListeners);return{pluginsActions:i,pluginsAtoms:n,pluginPathMethods:d,atomListeners:c,$fetch:t}};function q(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Z(e,t,r){let i=t[e],s=r||{},{fetchOptions:n,query:d}=s,c=B(s,["fetchOptions","query"]);return i||(n!=null&&n.method?n.method:c&&Object.keys(c).length>0?"POST":"GET")}function W(e,t,r,i,n){function d(c=[]){return new Proxy(function(){},{get(s,f){let u=[...c,f],o=e;for(let g of u)if(o&&typeof o=="object"&&g in o)o=o[g];else{o=void 0;break}return typeof o=="function"?o:d(u)},apply:(s,f,u)=>y(this,null,function*(){let o="/"+c.map(U=>U.replace(/[A-Z]/g,A=>`-${A.toLowerCase()}`)).join("/"),g=u[0]||{},P=u[1]||{},S=g,{query:a,fetchOptions:T}=S,G=B(S,["query","fetchOptions"]),h=l(l({},P),T),F=Z(o,r,g);return yield t(o,m(l({},h),{body:F==="GET"?void 0:l(l({},G),(h==null?void 0:h.body)||{}),query:a||(h==null?void 0:h.query),method:F,onSuccess(U){return y(this,null,function*(){var L;yield(L=h==null?void 0:h.onSuccess)==null?void 0:L.call(h,U);let A=n==null?void 0:n.find(z=>z.matcher(o));if(!A)return;let O=i[A.signal];if(!O)return;let N=O.get();setTimeout(()=>{O.set(!N)},10)})}}))})})}return d()}import{atom as te}from"nanostores";import"@better-fetch/fetch";import{atom as Y,onMount as ee}from"nanostores";var M=(e,t,r,i)=>{let n=Y({data:null,error:null,isPending:!1}),d=()=>{let s=typeof i=="function"?i({data:n.get().data,error:n.get().error,isPending:n.get().isPending}):i;return r(t,m(l({},s),{onSuccess:u=>y(void 0,null,function*(){var o;n.set({data:u.data,error:null,isPending:!1}),yield(o=s==null?void 0:s.onSuccess)==null?void 0:o.call(s,u)}),onError(u){return y(this,null,function*(){var o;n.set({error:u.error,data:null,isPending:!1}),yield(o=s==null?void 0:s.onError)==null?void 0:o.call(s,u)})},onRequest(u){return y(this,null,function*(){var g;let o=n.get();n.set({isPending:!0,data:o.data,error:o.error}),yield(g=s==null?void 0:s.onRequest)==null?void 0:g.call(s,u)})}}))};e=Array.isArray(e)?e:[e];let c=!1;for(let s of e)s.subscribe(()=>{c?d():ee(n,()=>(d(),c=!0,()=>{n.off(),s.off()}))});return n};function H(e){let t=te(!1);return{$session:M(t,"/session",e,{method:"GET"}),_sessionSignal:t,$Infer:{}}}function re(e){return`use${q(e)}`}function Ie(e){let{pluginPathMethods:t,pluginsActions:r,pluginsAtoms:i,$fetch:n,atomListeners:d}=$(e),c={};for(let[a,T]of Object.entries(i))c[re(a)]=()=>j(T);let{$session:s,_sessionSignal:f,$Infer:u}=H(n);function o(){return j(s)}let g=m(l(l({},r),c),{useSession:o});return W(g,n,t,m(l({},i),{_sessionSignal:f}),d)}export{Ie as createAuthClient};
1
+ import{useStore as E}from"@nanostores/vue";import{createFetch as q}from"@better-fetch/fetch";var f=class extends Error{constructor(t,s,i){super(t),this.name="BetterAuthError",this.message=t,this.cause=s}};function v(e){try{return new URL(e).pathname!=="/"}catch{throw new f(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function A(e,t="/api/auth"){return v(e)?e:(t=t.startsWith("/")?t:`/${t}`,`${e}${t}`)}function U(e,t){if(e)return A(e,t);let s=process?.env||{},i=s.BETTER_AUTH_URL||s.NEXT_PUBLIC_BETTER_AUTH_URL||s.PUBLIC_BETTER_AUTH_URL||s.NUXT_PUBLIC_BETTER_AUTH_URL||s.NUXT_PUBLIC_AUTH_URL||(s.BASE_URL!=="/"?s.BASE_URL:void 0);if(i)return A(i,t);if(typeof window<"u")return A(window.location.origin,t)}import"nanostores";import{betterFetch as $}from"@better-fetch/fetch";var B={id:"redirect",name:"Redirect",hooks:{onSuccess(e){e.data?.url&&e.data?.redirect&&typeof window<"u"&&(window.location.href=e.data.url)}}},b={id:"add-current-url",name:"Add current URL",hooks:{onRequest(e){if(typeof window<"u"){let t=new URL(e.url);t.searchParams.set("currentURL",window.location.href),e.url=t}return e}}},O=new Map,L={id:"csrf",name:"CSRF Check",async init(e,t){if(!t?.baseURL)throw new f("API Base URL on the auth client isn't configured. Please pass it directly to the client `baseURL`");if(t?.method!=="GET"){t=t||{};let s=O.get("CSRF_TOKEN");if(!s){let{data:i,error:r}=await $("/csrf",{body:void 0,baseURL:t.baseURL,plugins:[],method:"GET",credentials:"include",customFetchImpl:t.customFetchImpl});if(r){if(r.status===404)throw new f("CSRF route not found. Make sure the server is running and the base URL is correct and includes the path (e.g. http://localhost:3000/api/auth).");if(r.status===429)return new Response(JSON.stringify({message:"Too many requests. Please try again later."}),{status:429,statusText:"Too Many Requests"});throw new f("Failed to fetch CSRF token: "+r.message)}O.set("CSRF_TOKEN",i.csrfToken)}t.body={...t?.body,csrfToken:s}}return t.credentials="include",{url:e,options:t}}};var F=e=>{let t=q({baseURL:U(e?.fetchOptions?.baseURL||e?.baseURL),credentials:"include",...e?.fetchOptions,plugins:[L,B,b,...e?.fetchOptions?.plugins?.filter(n=>n!==void 0)||[],...e?.plugins?.flatMap(n=>n.fetchPlugins).filter(n=>n!==void 0)||[]]}),s=e?.plugins||[],i={},r={},c={"/sign-out":"POST","/user/revoke-sessions":"POST"},o=[{signal:"_sessionSignal",matcher(n){return n==="/sign-out"||n==="sign-up/email"||n==="/user/update"}}];for(let n of s)n.getActions&&Object.assign(i,n.getActions?.(t)),n.getAtoms&&Object.assign(r,n.getAtoms?.(t)),n.pathMethods&&Object.assign(c,n.pathMethods),n.atomListeners&&o.push(...n.atomListeners);return{pluginsActions:i,pluginsAtoms:r,pluginPathMethods:c,atomListeners:o,$fetch:t}};function S(e){return e.charAt(0).toUpperCase()+e.slice(1)}function W(e,t,s){let i=t[e],{fetchOptions:r,query:c,...o}=s||{};return i||(r?.method?r.method:o&&Object.keys(o).length>0?"POST":"GET")}function C(e,t,s,i,r){function c(o=[]){return new Proxy(function(){},{get(n,u){let l=[...o,u],a=e;for(let d of l)if(a&&typeof a=="object"&&d in a)a=a[d];else{a=void 0;break}return typeof a=="function"?a:c(l)},apply:async(n,u,l)=>{let a="/"+o.map(y=>y.replace(/[A-Z]/g,g=>`-${g.toLowerCase()}`)).join("/"),d=l[0]||{},R=l[1]||{},{query:h,fetchOptions:m,...I}=d,p={...R,...m},T=W(a,s,d);return await t(a,{...p,body:T==="GET"?void 0:{...I,...p?.body||{}},query:h||p?.query,method:T,async onSuccess(y){await p?.onSuccess?.(y);let g=r?.find(k=>k.matcher(a));if(!g)return;let P=i[g.signal];if(!P)return;let _=P.get();setTimeout(()=>{P.set(!_)},10)}})}})}return c()}import{atom as j}from"nanostores";import"@better-fetch/fetch";import{atom as M,onMount as H}from"nanostores";var w=(e,t,s,i)=>{let r=M({data:null,error:null,isPending:!1}),c=()=>{let n=typeof i=="function"?i({data:r.get().data,error:r.get().error,isPending:r.get().isPending}):i;return s(t,{...n,onSuccess:async u=>{r.set({data:u.data,error:null,isPending:!1}),await n?.onSuccess?.(u)},async onError(u){r.set({error:u.error,data:null,isPending:!1}),await n?.onError?.(u)},async onRequest(u){let l=r.get();r.set({isPending:!0,data:l.data,error:l.error}),await n?.onRequest?.(u)}})};e=Array.isArray(e)?e:[e];let o=!1;for(let n of e)n.subscribe(()=>{o?c():H(r,()=>(c(),o=!0,()=>{r.off(),n.off()}))});return r};function x(e){let t=j(!1);return{$session:w(t,"/session",e,{method:"GET"}),_sessionSignal:t,$Infer:{}}}function G(e){return`use${S(e)}`}function he(e){let{pluginPathMethods:t,pluginsActions:s,pluginsAtoms:i,$fetch:r,atomListeners:c}=F(e),o={};for(let[h,m]of Object.entries(i))o[G(h)]=()=>E(m);let{$session:n,_sessionSignal:u,$Infer:l}=x(r);function a(){return E(n)}let d={...s,...o,useSession:a};return C(d,r,t,{...i,_sessionSignal:u},c)}export{he as createAuthClient};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-auth",
3
- "version": "0.2.2",
3
+ "version": "0.2.3-beta.10",
4
4
  "description": "The most comprehensive authentication library for TypeScript.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -47,19 +47,19 @@
47
47
  "@types/pg": "^8.11.6",
48
48
  "@types/prompts": "^2.4.9",
49
49
  "@types/react": "^18.3.3",
50
+ "better-sqlite3": "^11.3.0",
50
51
  "drizzle-orm": "^0.33.0",
51
52
  "happy-dom": "^15.7.3",
52
53
  "hono": "^4.5.4",
53
54
  "listhen": "^1.7.2",
54
55
  "mongodb": "^6.9.0",
56
+ "mysql2": "^3.11.0",
55
57
  "next": "^14.2.8",
56
58
  "pg": "^8.12.0",
57
- "better-sqlite3": "^11.3.0",
58
59
  "prisma": "^5.19.1",
59
60
  "react": "^18.3.1",
60
61
  "solid-js": "^1.8.18",
61
62
  "tsup": "^8.2.4",
62
- "mysql2": "^3.11.0",
63
63
  "typescript": "5.6.1-rc",
64
64
  "vitest": "^1.6.0",
65
65
  "vue": "^3.5.0"
@@ -69,11 +69,13 @@
69
69
  "@babel/preset-typescript": "^7.24.7",
70
70
  "@better-fetch/fetch": "^1.1.9",
71
71
  "@better-fetch/logger": "^1.1.3",
72
+ "@mrleebo/prisma-ast": "^0.12.0",
72
73
  "@nanostores/query": "^0.3.4",
73
74
  "@nanostores/react": "^0.7.3",
74
75
  "@nanostores/solid": "^0.4.2",
75
76
  "@nanostores/vue": "^0.10.0",
76
77
  "@noble/ciphers": "^0.6.0",
78
+ "prettier": "^3.3.3",
77
79
  "@noble/hashes": "^1.4.0",
78
80
  "@oslojs/encoding": "^1.0.0",
79
81
  "@paralleldrive/cuid2": "^2.2.2",
@@ -105,7 +107,7 @@
105
107
  "build": "NODE_OPTIONS='--max-old-space-size=16384' tsup --clean --minify",
106
108
  "dev": "NODE_OPTIONS='--max-old-space-size=16384' tsup --watch --sourcemap",
107
109
  "test": "pnpm prisma:push && pnpm typecheck && vitest",
108
- "prisma:push": "prisma db push --schema src/adapters/prisma-adapter/schema.prisma",
110
+ "prisma:push": "prisma db push --schema src/adapters/prisma-adapter/test/schema.prisma",
109
111
  "test:adapters": "pnpm prisma:push && vitest adapters",
110
112
  "bump": "bumpp",
111
113
  "typecheck": "tsc --noEmit"
package/dist/.DS_Store DELETED
Binary file
@@ -1,54 +0,0 @@
1
- import { S as Session } from './schema-D9o3OF80.js';
2
-
3
- /**
4
- * Adapter where clause
5
- */
6
- type Where = {
7
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte";
8
- value: string;
9
- field: string;
10
- connector?: "AND" | "OR";
11
- };
12
- /**
13
- * Adapter Interface
14
- */
15
- interface Adapter {
16
- create: <T, R = T>(data: {
17
- model: string;
18
- data: T;
19
- select?: string[];
20
- }) => Promise<R>;
21
- findOne: <T>(data: {
22
- model: string;
23
- where: Where[];
24
- select?: string[];
25
- }) => Promise<T | null>;
26
- findMany: <T>(data: {
27
- model: string;
28
- where?: Where[];
29
- }) => Promise<T[]>;
30
- update: <T>(data: {
31
- model: string;
32
- where: Where[];
33
- update: Record<string, any>;
34
- }) => Promise<T | null>;
35
- delete: <T>(data: {
36
- model: string;
37
- where: Where[];
38
- }) => Promise<void>;
39
- }
40
- interface SessionAdapter {
41
- create: (data: {
42
- userId: string;
43
- expiresAt: Date;
44
- }) => Promise<Session>;
45
- findOne: (data: {
46
- userId: string;
47
- }) => Promise<Session | null>;
48
- update: (data: Session) => Promise<Session>;
49
- delete: (data: {
50
- sessionId: string;
51
- }) => Promise<void>;
52
- }
53
-
54
- export type { Adapter as A, SessionAdapter as S, Where as W };
@@ -1,88 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- declare const accountSchema: z.ZodObject<{
4
- id: z.ZodString;
5
- providerId: z.ZodString;
6
- accountId: z.ZodString;
7
- userId: z.ZodString;
8
- accessToken: z.ZodOptional<z.ZodNullable<z.ZodString>>;
9
- refreshToken: z.ZodOptional<z.ZodNullable<z.ZodString>>;
10
- idToken: z.ZodOptional<z.ZodNullable<z.ZodString>>;
11
- /**
12
- * Access token expires at
13
- */
14
- expiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
15
- /**
16
- * Password is only stored in the credential provider
17
- */
18
- password: z.ZodNullable<z.ZodOptional<z.ZodString>>;
19
- }, "strip", z.ZodTypeAny, {
20
- id: string;
21
- providerId: string;
22
- accountId: string;
23
- userId: string;
24
- accessToken?: string | null | undefined;
25
- refreshToken?: string | null | undefined;
26
- idToken?: string | null | undefined;
27
- expiresAt?: Date | null | undefined;
28
- password?: string | null | undefined;
29
- }, {
30
- id: string;
31
- providerId: string;
32
- accountId: string;
33
- userId: string;
34
- accessToken?: string | null | undefined;
35
- refreshToken?: string | null | undefined;
36
- idToken?: string | null | undefined;
37
- expiresAt?: Date | null | undefined;
38
- password?: string | null | undefined;
39
- }>;
40
- declare const userSchema: z.ZodObject<{
41
- id: z.ZodString;
42
- email: z.ZodEffects<z.ZodString, string, string>;
43
- emailVerified: z.ZodDefault<z.ZodBoolean>;
44
- name: z.ZodString;
45
- image: z.ZodOptional<z.ZodString>;
46
- createdAt: z.ZodDefault<z.ZodDate>;
47
- updatedAt: z.ZodDefault<z.ZodDate>;
48
- }, "strip", z.ZodTypeAny, {
49
- id: string;
50
- email: string;
51
- emailVerified: boolean;
52
- name: string;
53
- createdAt: Date;
54
- updatedAt: Date;
55
- image?: string | undefined;
56
- }, {
57
- id: string;
58
- email: string;
59
- name: string;
60
- emailVerified?: boolean | undefined;
61
- image?: string | undefined;
62
- createdAt?: Date | undefined;
63
- updatedAt?: Date | undefined;
64
- }>;
65
- declare const sessionSchema: z.ZodObject<{
66
- id: z.ZodString;
67
- userId: z.ZodString;
68
- expiresAt: z.ZodDate;
69
- ipAddress: z.ZodOptional<z.ZodString>;
70
- userAgent: z.ZodOptional<z.ZodString>;
71
- }, "strip", z.ZodTypeAny, {
72
- id: string;
73
- userId: string;
74
- expiresAt: Date;
75
- ipAddress?: string | undefined;
76
- userAgent?: string | undefined;
77
- }, {
78
- id: string;
79
- userId: string;
80
- expiresAt: Date;
81
- ipAddress?: string | undefined;
82
- userAgent?: string | undefined;
83
- }>;
84
- type User = z.infer<typeof userSchema>;
85
- type Account = z.infer<typeof accountSchema>;
86
- type Session = z.infer<typeof sessionSchema>;
87
-
88
- export type { Account as A, Session as S, User as U };