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/access.js +1 -1
- package/dist/adapters.d.ts +32 -6
- package/dist/adapters.js +22 -1
- package/dist/api.d.ts +2 -4
- package/dist/api.js +3 -3
- package/dist/cli.js +4 -2
- package/dist/client/plugins.d.ts +5 -7
- package/dist/client/plugins.js +2 -2
- package/dist/client.d.ts +3 -5
- package/dist/client.js +1 -1
- package/dist/index-CE92ti2Z.d.ts +827 -0
- package/dist/{index-DsEvbKjm.d.ts → index-CmzUOocy.d.ts} +10 -2
- package/dist/{index-D_ohe9r9.d.ts → index-gO-yM4kI.d.ts} +77 -120
- package/dist/index.d.ts +4 -6
- package/dist/index.js +5 -3
- package/dist/next-js.d.ts +2 -4
- package/dist/next-js.js +1 -1
- package/dist/node.d.ts +4 -6
- package/dist/plugins.d.ts +6 -8
- package/dist/plugins.js +3 -3
- package/dist/react.d.ts +3 -5
- package/dist/react.js +1 -1
- package/dist/social.d.ts +3 -742
- package/dist/social.js +2 -2
- package/dist/solid-start.d.ts +4 -6
- package/dist/solid-start.js +1 -1
- package/dist/solid.d.ts +3 -5
- package/dist/solid.js +1 -1
- package/dist/svelte-kit.d.ts +4 -6
- package/dist/svelte.d.ts +3 -5
- package/dist/svelte.js +1 -1
- package/dist/types.d.ts +3 -5
- package/dist/utils.d.ts +5 -7
- package/dist/utils.js +2 -2
- package/dist/vue.d.ts +3 -5
- package/dist/vue.js +1 -1
- package/package.json +6 -4
- package/dist/.DS_Store +0 -0
- package/dist/adapter-D-m9-hQp.d.ts +0 -54
- package/dist/schema-D9o3OF80.d.ts +0 -88
package/dist/social.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
`)}}),
|
|
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};
|
package/dist/solid-start.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { d as Auth } from './index-
|
|
1
|
+
import { d as Auth } from './index-gO-yM4kI.js';
|
|
2
2
|
import 'kysely';
|
|
3
|
-
import './
|
|
3
|
+
import './index-CE92ti2Z.js';
|
|
4
|
+
import 'arctic';
|
|
4
5
|
import 'zod';
|
|
5
|
-
import 'better-call';
|
|
6
6
|
import './helper-C1ihmerM.js';
|
|
7
|
-
import '
|
|
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: {
|
package/dist/solid-start.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
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-
|
|
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 './
|
|
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
|
-
|
|
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};
|
package/dist/svelte-kit.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { d as Auth, e as BetterAuthOptions } from './index-
|
|
1
|
+
import { d as Auth, e as BetterAuthOptions } from './index-gO-yM4kI.js';
|
|
2
2
|
import 'kysely';
|
|
3
|
-
import './
|
|
3
|
+
import './index-CE92ti2Z.js';
|
|
4
|
+
import 'arctic';
|
|
4
5
|
import 'zod';
|
|
5
|
-
import 'better-call';
|
|
6
6
|
import './helper-C1ihmerM.js';
|
|
7
|
-
import '
|
|
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-
|
|
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 './
|
|
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
|
-
|
|
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,
|
|
2
|
-
export { f as AuthContext, e as BetterAuthOptions, G as GenericEndpointContext, H as HookEndpointContext,
|
|
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 './
|
|
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 {
|
|
2
|
-
export {
|
|
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 './
|
|
7
|
-
import 'better-call';
|
|
8
|
-
import './helper-C1ihmerM.js';
|
|
9
|
-
import './social.js';
|
|
6
|
+
import './index-CE92ti2Z.js';
|
|
10
7
|
import 'arctic';
|
|
11
|
-
import './
|
|
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
|
|
2
|
-
`)}}),
|
|
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-
|
|
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 './
|
|
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
|
-
|
|
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.
|
|
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 };
|