better-auth 0.2.2 → 0.2.3-beta.2

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.
@@ -1,15 +1,27 @@
1
- import { A as Adapter, W as Where } from './adapter-D-m9-hQp.js';
2
- import './schema-D9o3OF80.js';
1
+ import { f as Adapter, W as Where, F as FieldAttribute } from './index-BMYcrOqA.js';
2
+ import { Kysely } from 'kysely';
3
+ import './index-CE92ti2Z.js';
4
+ import 'arctic';
3
5
  import 'zod';
6
+ import './helper-C1ihmerM.js';
7
+ import 'better-call';
4
8
 
5
- declare const prismaAdapter: (prisma: any) => Adapter;
9
+ declare const prismaAdapter: ({ db: prisma, provider, }: {
10
+ db: any;
11
+ provider: "sqlite" | "cockroachdb" | "mysql" | "postgresql" | "sqlserver";
12
+ }) => Adapter;
6
13
 
7
14
  interface DrizzleAdapterOptions {
8
- schema: Record<string, any>;
15
+ schema?: Record<string, any>;
16
+ provider: "pg" | "mysql" | "sqlite";
9
17
  }
10
- declare const drizzleAdapter: (db: Record<string, any>, { schema }: DrizzleAdapterOptions) => Adapter;
18
+ interface DB {
19
+ [key: string]: any;
20
+ }
21
+ declare const drizzleAdapter: (db: DB, options: DrizzleAdapterOptions) => Adapter;
11
22
 
12
23
  declare const mongodbAdapter: (mongo: any) => {
24
+ id: string;
13
25
  create<T, R = T>(data: {
14
26
  model: string;
15
27
  data: T;
@@ -35,4 +47,18 @@ declare const mongodbAdapter: (mongo: any) => {
35
47
  }): Promise<any>;
36
48
  };
37
49
 
38
- export { type DrizzleAdapterOptions, drizzleAdapter, mongodbAdapter, prismaAdapter };
50
+ interface KyselyAdapterConfig {
51
+ /**
52
+ * Transform dates and booleans for sqlite.
53
+ */
54
+ transform?: {
55
+ schema: {
56
+ [table: string]: Record<string, FieldAttribute>;
57
+ };
58
+ boolean: boolean;
59
+ date: boolean;
60
+ };
61
+ }
62
+ declare const kyselyAdapter: (db: Kysely<any>, config?: KyselyAdapterConfig) => Adapter;
63
+
64
+ export { type DrizzleAdapterOptions, type KyselyAdapterConfig, drizzleAdapter, kyselyAdapter, mongodbAdapter, prismaAdapter };
package/dist/adapters.js CHANGED
@@ -1 +1,22 @@
1
- var D=Object.defineProperty,R=Object.defineProperties;var x=Object.getOwnPropertyDescriptors;var m=Object.getOwnPropertySymbols;var O=Object.prototype.hasOwnProperty,M=Object.prototype.propertyIsEnumerable;var C=(r,o,c)=>o in r?D(r,o,{enumerable:!0,configurable:!0,writable:!0,value:c}):r[o]=c,u=(r,o)=>{for(var c in o||(o={}))O.call(o,c)&&C(r,c,o[c]);if(m)for(var c of m(o))M.call(o,c)&&C(r,c,o[c]);return r},f=(r,o)=>R(r,x(o));var P=(r,o)=>{var c={};for(var t in r)O.call(r,t)&&o.indexOf(t)<0&&(c[t]=r[t]);if(r!=null&&m)for(var t of m(r))o.indexOf(t)<0&&M.call(r,t)&&(c[t]=r[t]);return c};var l=(r,o,c)=>new Promise((t,s)=>{var n=i=>{try{a(c.next(i))}catch(d){s(d)}},e=i=>{try{a(c.throw(i))}catch(d){s(d)}},a=i=>i.done?t(i.value):Promise.resolve(i.value).then(n,e);a((c=c.apply(r,o)).next())});function h(r){if(!r)return{};if(r.length===1){let n=r[0];return n?{[n.field]:n.value}:void 0}let o=r.filter(n=>n.connector==="AND"||!n.connector),c=r.filter(n=>n.connector==="OR"),t=o.map(n=>({[n.field]:n.operator==="eq"||!n.operator?n.value:{[n.operator]:n.value}})),s=c.map(n=>({[n.field]:{[n.operator||"eq"]:n.value}}));return{AND:t.length?t:void 0,OR:s.length?s:void 0}}var q=r=>{let o=r;return{create(t){return l(this,null,function*(){let{model:s,data:n,select:e}=t;return yield o[s].create(u({data:n},e!=null&&e.length?{select:e.reduce((a,i)=>f(u({},a),{[i]:!0}),{})}:{}))})},findOne(t){return l(this,null,function*(){let{model:s,where:n,select:e}=t,a=h(n);return yield o[s].findFirst(u({where:a},e!=null&&e.length?{select:e.reduce((i,d)=>f(u({},i),{[d]:!0}),{})}:{}))})},findMany(t){return l(this,null,function*(){let{model:s,where:n}=t,e=h(n);return yield o[s].findMany({where:e})})},update(t){return l(this,null,function*(){let{model:s,where:n,update:e}=t,a=h(n);return yield o[s].update({where:a,data:e})})},delete(t){return l(this,null,function*(){let{model:s,where:n}=t,e=h(n);return yield o[s].delete({where:e})})}}};import{and as z,eq as v,or as N}from"drizzle-orm";function p(r,o){let c=Object.keys(o).find(t=>{let s=o[t].name;return s===s});if(!c)throw new Error("Model not found");return o[c]}function w(r,o){if(!r)return[];if(r.length===1){let a=r[0];return a?[v(o[a.field],a.value)]:[]}let c=r.filter(a=>a.connector==="AND"||!a.connector),t=r.filter(a=>a.connector==="OR"),s=z(...c.map(a=>v(o[a.field],a.value))),n=N(...t.map(a=>v(o[a.field],a.value))),e=[];return c.length&&e.push(s),t.length&&e.push(n),e}var G=(r,{schema:o})=>({create(t){return l(this,null,function*(){let{model:s,data:n}=t,e=p(s,o);return(yield r.insert(e).values(n).returning())[0]})},findOne(t){return l(this,null,function*(){let{model:s,where:n,select:e}=t,a=p(s,o),i=w(n,a),d=null;return e!=null&&e.length?d=yield r.select(...e.map(y=>({[y]:a[y]}))).from(a).where(...i):d=yield r.select().from(a).where(...i),d.length?d[0]:null})},findMany(t){return l(this,null,function*(){let{model:s,where:n}=t,e=p(s,o),a=n?w(n,e):[];return yield r.select().from(e).findMany(...a)})},update(t){return l(this,null,function*(){let{model:s,where:n,update:e}=t,a=p(s,o),i=w(n,a);return(yield r.update(a).set(e).where(...i).returning())[0]})},delete(t){return l(this,null,function*(){let{model:s,where:n}=t,e=p(s,o),a=w(n,e);return(yield r.delete(e).where(...a))[0]})}});function g(r){if(!r)return{};if(r.length===1){let e=r[0];return e?{[e.field]:e.value}:void 0}let o=r.filter(e=>e.connector==="AND"||!e.connector),c=r.filter(e=>e.connector==="OR"),t=o.map(e=>({[e.field]:e.operator==="eq"||!e.operator?e.value:{[e.field]:e.value}})),s=c.map(e=>({[e.field]:e.value})),n={};return t.length&&(n=f(u({},n),{$and:t})),s.length&&(n=f(u({},n),{$or:s})),n}function A(r){let t=r,{_id:o}=t;return P(t,["_id"])}function W(r){return r.reduce((c,t)=>(c[t]=1,c),{})}var Q=r=>{let o=r;return{create(t){return l(this,null,function*(){let{model:s,data:n}=t,a=(yield o.collection(s).insertOne(u({},n))).insertedId,i=u({id:a},n);return A(i)})},findOne(t){return l(this,null,function*(){let{model:s,where:n,select:e}=t,a=g(n),i={};e&&(i=W(e));let y=(yield o.collection(s).find(u({},a),{projection:i}).toArray())[0];return y?A(y):null})},findMany(t){return l(this,null,function*(){let{model:s,where:n}=t,e=g(n),a=yield o.collection(s).findMany(e);return A(a)})},update(t){return l(this,null,function*(){let{model:s,where:n,update:e}=t,a=g(n),i=yield o.collection(s).findOneAndUpdate(a,{$set:e},{returnDocument:"after"});return A(i)})},delete(t){return l(this,null,function*(){let{model:s,where:n}=t,e=g(n);return yield o.collection(s).findOneAndDelete(e)})}}};export{G as drizzleAdapter,Q as mongodbAdapter,q as prismaAdapter};
1
+ var Z=Object.defineProperty,ee=Object.defineProperties;var te=Object.getOwnPropertyDescriptors;var R=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable;var I=(e,t,a)=>t in e?Z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,m=(e,t)=>{for(var a in t||(t={}))F.call(t,a)&&I(e,a,t[a]);if(R)for(var a of R(t))U.call(t,a)&&I(e,a,t[a]);return e},C=(e,t)=>ee(e,te(t));var re=(e=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(e,{get:(t,a)=>(typeof require!="undefined"?require:t)[a]}):e)(function(e){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var S=(e,t)=>{var a={};for(var s in e)F.call(e,s)&&t.indexOf(s)<0&&(a[s]=e[s]);if(e!=null&&R)for(var s of R(e))t.indexOf(s)<0&&U.call(e,s)&&(a[s]=e[s]);return a};var f=(e,t,a)=>new Promise((s,i)=>{var n=c=>{try{o(a.next(c))}catch(l){i(l)}},r=c=>{try{o(a.throw(c))}catch(l){i(l)}},o=c=>c.done?s(c.value):Promise.resolve(c.value).then(n,r);o((a=a.apply(e,t)).next())});import{existsSync as se}from"fs";import z from"path";var $=e=>{var c,l,u,h,b,A;let t=(c=e.plugins)==null?void 0:c.reduce((p,y)=>{var g;let w=y.schema;if(!w)return p;for(let[x,k]of Object.entries(w))p[x]={fields:m(m({},(g=p[x])==null?void 0:g.fields),k.fields),tableName:x};return p},{}),a=((l=e.rateLimit)==null?void 0:l.storage)==="database",s={rateLimit:{tableName:((u=e.rateLimit)==null?void 0:u.tableName)||"rateLimit",fields:{key:{type:"string"},count:{type:"number"},lastRequest:{type:"number"}}}},d=t||{},{user:i,session:n,account:r}=d,o=S(d,["user","session","account"]);return m(m({user:{tableName:((h=e.user)==null?void 0:h.modelName)||"user",fields:m({name:{type:"string",required:!0},email:{type:"string",unique:!0,required:!0},emailVerified:{type:"boolean",defaultValue:()=>!1,required:!0},image:{type:"string",required:!1},createdAt:{type:"date",defaultValue:()=>new Date,required:!0},updatedAt:{type:"date",defaultValue:()=>new Date,required:!0}},i==null?void 0:i.fields),order:0},session:{tableName:((b=e.session)==null?void 0:b.modelName)||"session",fields:m({expiresAt:{type:"date",required:!0},ipAddress:{type:"string",required:!1},userAgent:{type:"string",required:!1},userId:{type:"string",references:{model:"user",field:"id",onDelete:"cascade"},required:!0}},n==null?void 0:n.fields),order:1},account:{tableName:((A=e.account)==null?void 0:A.modelName)||"account",fields:m({accountId:{type:"string",required:!0},providerId:{type:"string",required:!0},userId:{type:"string",references:{model:"user",field:"id",onDelete:"cascade"},required:!0},accessToken:{type:"string",required:!1},refreshToken:{type:"string",required:!1},idToken:{type:"string",required:!1},expiresAt:{type:"date",required:!1},password:{type:"string",required:!1}},r==null?void 0:r.fields),order:2}},o),a?s:{})};import ae from"fs/promises";import{produceSchema as ie}from"@mrleebo/prisma-ast";var O=class extends Error{constructor(t,a,s){super(t),this.name="BetterAuthError",this.message=t,this.cause=a}};import{TimeSpan as _e}from"oslo";import{alphabet as je,generateRandomString as ze}from"oslo/crypto";import{createConsola as ne}from"consola";var q=ne({formatOptions:{date:!1,colors:!0,compact:!0},defaults:{tag:"Better Auth"}}),oe=e=>({log:(...t)=>{!(e!=null&&e.disabled)&&q.log("",...t)},error:(...t)=>{!(e!=null&&e.disabled)&&q.error("",...t)},warn:(...t)=>{!(e!=null&&e.disabled)&&q.warn("",...t)},info:(...t)=>{!(e!=null&&e.disabled)&&q.info("",...t)},debug:(...t)=>{!(e!=null&&e.disabled)&&q.debug("",...t)},box:(...t)=>{!(e!=null&&e.disabled)&&q.box("",...t)},success:(...t)=>{!(e!=null&&e.disabled)&&q.success("",...t)},break:(...t)=>{!(e!=null&&e.disabled)&&console.log(`
2
+ `)}}),M=oe();function j(e){return e.charAt(0).toUpperCase()+e.slice(1)}import{generateState as et}from"oslo/oauth2";import{z as rt}from"zod";function N(e){if(!e)return{};if(e.length===1){let n=e[0];return n?{[n.field]:n.value}:void 0}let t=e.filter(n=>n.connector==="AND"||!n.connector),a=e.filter(n=>n.connector==="OR"),s=t.map(n=>({[n.field]:n.operator==="eq"||!n.operator?n.value:{[n.operator]:n.value}})),i=a.map(n=>({[n.field]:{[n.operator||"eq"]:n.value}}));return{AND:s.length?s:void 0,OR:i.length?i:void 0}}var Tt=({db:e,provider:t})=>{let a=e;return{id:"prisma",create(i){return f(this,null,function*(){let{model:n,data:r,select:o}=i;return yield a[n].create(m({data:r},o!=null&&o.length?{select:o.reduce((c,l)=>C(m({},c),{[l]:!0}),{})}:{}))})},findOne(i){return f(this,null,function*(){let{model:n,where:r,select:o}=i,c=N(r);return yield a[n].findFirst(m({where:c},o!=null&&o.length?{select:o.reduce((l,u)=>C(m({},l),{[u]:!0}),{})}:{}))})},findMany(i){return f(this,null,function*(){let{model:n,where:r}=i,o=N(r);return yield a[n].findMany({where:o})})},update(i){return f(this,null,function*(){let{model:n,where:r,update:o}=i,c=N(r);return yield a[n].update({where:c,data:o})})},delete(i){return f(this,null,function*(){let{model:n,where:r}=i,o=N(r);return yield a[n].delete({where:o})})},createSchema(i,n){return f(this,null,function*(){let r=$(i),o=n||"./prisma/schema.prisma",c=se(z.join(process.cwd(),o)),l="";return c?l=yield ae.readFile(z.join(process.cwd(),o),"utf-8"):l=ce(t),{code:ie(l,d=>{for(let b in r){let y=function(g,x){if(g==="string")return x?"String?":"String";if(g==="number")return x?"Int?":"Int";if(g==="boolean")return x?"Boolean?":"Boolean";if(g==="date")return x?"DateTime?":"DateTime"};var h=y;let A=r[b].fields,p=r[b].tableName,w=d.findByType("model",{name:p});!w&&d.model(p).field("id","String").attribute("id");for(let g in A){let x=A[g];if(w){let k=d.findByType("field",{name:g,within:w.properties});if(console.log(g,"exists"),k)continue}d.model(p).field(g,y(x.type,!x.required)),x.unique&&d.model(p).blockAttribute(`unique([${g}])`),x.references&&d.model(p).field(j(x.references.model),x.references.model).attribute(`relation(fields: [${g}], references: [${x.references.field}], onDelete: Cascade)`)}}}),fileName:o}})}}},ce=e=>`generator client {
3
+ provider = "prisma-client-js"
4
+ }
5
+
6
+ datasource db {
7
+ provider = "${e}"
8
+ url = ${e==="sqlite"?'"file:./dev.db"':'env("DATABASE_URL")'}
9
+ }`;import{and as le,eq as L,or as de}from"drizzle-orm";import*as V from"prettier";import{existsSync as ue}from"fs";import fe from"fs/promises";function v(e,t){let a=Object.keys(t).find(s=>{let i=t[s].name;return i===i});if(!a)throw new Error("Model not found");return t[a]}function B(e,t){if(!e)return[];if(e.length===1){let o=e[0];return o?[L(t[o.field],o.value)]:[]}let a=e.filter(o=>o.connector==="AND"||!o.connector),s=e.filter(o=>o.connector==="OR"),i=le(...a.map(o=>L(t[o.field],o.value))),n=de(...s.map(o=>L(t[o.field],o.value))),r=[];return a.length&&r.push(i),s.length&&r.push(n),r}var Dt=(e,t)=>{let a=(t==null?void 0:t.schema)||e._.schema;if(!a)throw new O("Drizzle adapter failed to initialize. Schema not found. Please provide a schema object in the adapter options object.");let s=t==null?void 0:t.provider;return{id:"drizzle",create(n){return f(this,null,function*(){let{model:r,data:o}=n,c=v(r,a);return(yield e.insert(c).values(o).returning())[0]})},findOne(n){return f(this,null,function*(){let{model:r,where:o,select:c}=n,l=v(r,a),u=B(o,l),d=null;return c!=null&&c.length?d=yield e.select(...c.map(h=>({[h]:l[h]}))).from(l).where(...u):d=yield e.select().from(l).where(...u),d.length?d[0]:null})},findMany(n){return f(this,null,function*(){let{model:r,where:o}=n,c=v(r,a),l=o?B(o,c):[];return yield e.select().from(c).findMany(...l)})},update(n){return f(this,null,function*(){let{model:r,where:o,update:c}=n,l=v(r,a),u=B(o,l);return(yield e.update(l).set(c).where(...u).returning())[0]})},delete(n){return f(this,null,function*(){let{model:r,where:o}=n,c=v(r,a),l=B(o,c);return(yield e.delete(c).where(...l))[0]})},createSchema(n,r){return f(this,null,function*(){let o=$(n),c=r||"./schema.ts",l=s!=="sqlite"?"timestamp, boolean":"",u=s==="mysql"?"int":"integer",d="",h=ue(c);if(h){let p=yield fe.readFile(c,"utf-8");p.includes("import")?d=p:d=`import { ${s}Table, text, ${u}, ${l} } from "drizzle-orm/${s}-core";
10
+ `}else d=`import { ${s}Table, text, ${u}, ${l} } from "drizzle-orm/${s}-core";
11
+ `;for(let p in o){let g=function(k,T){if(T==="string")return`text('${k}')`;if(T==="number")return`${u}('${k}')`;if(T==="boolean")return s==="sqlite"?`integer('${k}', {
12
+ mode: "boolean"
13
+ })`:`boolean('${k}')`;if(T==="date")return s==="sqlite"?`integer('${k}', {
14
+ mode: "timestamp"
15
+ })`:`timestamp('${k}')`};var A=g;let y=o[p].tableName,w=o[p].fields,x=`export const ${p} = ${s}Table("${y}", {
16
+ id: text("id").primaryKey(),
17
+ ${Object.keys(w).map(k=>{let T=w[k];return`${k}: ${g(k,T.type)}${T.required?".notNull()":""}${T.unique?".unique()":""}${T.references?`.references(()=> ${T.references.model}.${T.references.field})`:""}`}).join()}
18
+ });`;d+=`
19
+ ${x}
20
+ `}return{code:yield V.format(d,{semi:!0,parser:"typescript",tabWidth:4}),fileName:c,append:h}})}}};function D(e){if(!e)return{};if(e.length===1){let r=e[0];return r?{[r.field]:r.value}:void 0}let t=e.filter(r=>r.connector==="AND"||!r.connector),a=e.filter(r=>r.connector==="OR"),s=t.map(r=>({[r.field]:r.operator==="eq"||!r.operator?r.value:{[r.field]:r.value}})),i=a.map(r=>({[r.field]:r.value})),n={};return s.length&&(n=C(m({},n),{$and:s})),i.length&&(n=C(m({},n),{$or:i})),n}function E(e){let s=e,{_id:t}=s;return S(s,["_id"])}function me(e){return e.reduce((a,s)=>(a[s]=1,a),{})}var Pt=e=>{let t=e;return{id:"mongodb",create(s){return f(this,null,function*(){let{model:i,data:n}=s,o=(yield t.collection(i).insertOne(m({},n))).insertedId,c=m({id:o},n);return E(c)})},findOne(s){return f(this,null,function*(){let{model:i,where:n,select:r}=s,o=D(n),c={};r&&(c=me(r));let u=(yield t.collection(i).find(m({},o),{projection:c}).toArray())[0];return u?E(u):null})},findMany(s){return f(this,null,function*(){let{model:i,where:n}=s,r=D(n),o=yield t.collection(i).findMany(r);return E(o)})},update(s){return f(this,null,function*(){let{model:i,where:n,update:r}=s,o=D(n),c=yield t.collection(i).findOneAndUpdate(o,{$set:r},{returnDocument:"after"});return E(c)})},delete(s){return f(this,null,function*(){let{model:i,where:n}=s,r=D(n);return yield t.collection(i).findOneAndDelete(r)})}}};import"kysely";function pe(e){var a;return((a=e.plugins)==null?void 0:a.flatMap(s=>Object.keys(s.schema||{}).map(i=>{let r=(s.schema||{})[i];if(!(r!=null&&r.disableMigration))return{tableName:i,fields:r==null?void 0:r.fields}}).filter(i=>i!==void 0)))||[]}function G(e){let t=$(e),a=pe(e);return[t.user,t.session,t.account,...a].reduce((i,n)=>{var r;return i[n.tableName]={fields:m(m({},(r=i[n.tableName])==null?void 0:r.fields),n.fields)},i},{})}import{Kysely as ye}from"kysely";import{MysqlDialect as K,PostgresDialect as W,SqliteDialect as H}from"kysely";import{createPool as he}from"mysql2";import be from"pg";var{Pool:ge}=be,Ae=e=>{var a,s;if(!e.database)return;if("createDriver"in e.database)return e.database;let t;if("provider"in e.database){let i=e.database.provider,n=(s=(a=e.database)==null?void 0:a.url)==null?void 0:s.trim();if(i==="postgres"&&(t=new W({pool:new ge({connectionString:n})})),i==="mysql")try{let r=new URL(n),o=he({host:r.hostname,user:r.username,password:r.password,database:r.pathname.split("/")[1],port:Number(r.port)});t=new K({pool:o})}catch(r){if(r instanceof TypeError)throw new O("Invalid database URL")}if(i==="sqlite"){let r=re("better-sqlite3"),o=new r(n);t=new H({database:o})}}return t},X=e=>{let t=Ae(e);return t&&new ye({dialect:t})},J=e=>{if("provider"in e.database)return e.database.provider;if("dialect"in e.database){if(e.database.dialect instanceof W)return"postgres";if(e.database.dialect instanceof K)return"mysql";if(e.database.dialect instanceof H)return"sqlite"}return"sqlite"};var xe={string:["character varying","text"],number:["int4","integer","bigint","smallint","numeric","real","double precision"],boolean:["bool","boolean"],date:["timestamp","date"]},we={string:["varchar","text"],number:["integer","int","bigint","smallint","decimal","float","double"],boolean:["boolean"],date:["date","datetime"]},ke={string:["TEXT"],number:["INTEGER","REAL"],boolean:["INTEGER","BOOLEAN"],date:["DATE","INTEGER"]},Ce={postgres:xe,mysql:we,sqlite:ke};function Te(e,t,a){return Ce[a][t].map(r=>r.toLowerCase()).includes(e.toLowerCase())}function Q(e){return f(this,null,function*(){let t=G(e),a=J(e),s=X(e);s||(M.error("Invalid database configuration."),process.exit(1));let i=yield s.introspection.getTables(),n=[],r=[];for(let[d,h]of Object.entries(t)){let b=i.find(p=>p.name===d);if(!b){let p=n.findIndex(g=>g.table===d),y={table:d,fields:h.fields,order:h.order||1/0},w=n.findIndex(g=>(g.order||1/0)>y.order);w===-1?p===-1?n.push(y):n[p].fields=m(m({},n[p].fields),h.fields):n.splice(w,0,y);continue}let A={};for(let[p,y]of Object.entries(h.fields)){let w=b.columns.find(g=>g.name===p);if(!w){A[p]=y;continue}Te(w.dataType,y.type,a)||M.warn(`Field ${p} in table ${d} has a different type in the database. Expected ${y.type} but got ${w.dataType}.`)}Object.keys(A).length>0&&r.push({table:d,fields:A,order:h.order||1/0})}let o=[];function c(d){let h={string:"text",boolean:"boolean",number:"integer",date:"date"};return a==="mysql"&&d==="string"?"varchar(255)":h[d]}if(r.length)for(let d of r)for(let[h,b]of Object.entries(d.fields)){let A=c(b.type),p=s.schema.alterTable(d.table).addColumn(h,A,y=>(y=b.required!==!1?y.notNull():y,b.references&&(y=y.references(`${b.references.model}.${b.references.field}`)),y));o.push(p)}if(n.length)for(let d of n){let h=s.schema.createTable(d.table).addColumn("id",c("string"),b=>b.primaryKey());for(let[b,A]of Object.entries(d.fields)){let p=c(A.type);h=h.addColumn(b,p,y=>(y=A.required!==!1?y.notNull():y,A.references&&(y=y.references(`${A.references.model}.${A.references.field}`)),A.unique&&(y=y.unique()),y))}o.push(h)}function l(){return f(this,null,function*(){for(let d of o)yield d.execute()})}function u(){return f(this,null,function*(){return o.map(h=>h.compile().sql).join(`;
21
+
22
+ `)})}return{toBeCreated:n,toBeAdded:r,runMigrations:l,compileMigrations:u}})}function _(e){if(!e)return{and:null,or:null};let t=e==null?void 0:e.filter(s=>s.connector==="AND"||!s.connector).reduce((s,i)=>C(m({},s),{[i.field]:i.value}),{}),a=e==null?void 0:e.filter(s=>s.connector==="OR").reduce((s,i)=>C(m({},s),{[i.field]:i.value}),{});return{and:Object.keys(t).length?t:null,or:Object.keys(a).length?a:null}}function P(e,t,a){var s,i,n;for(let r in e)e[r]===0&&((s=t[r])==null?void 0:s.type)==="boolean"&&(a!=null&&a.boolean)&&(e[r]=!1),e[r]===1&&((i=t[r])==null?void 0:i.type)==="boolean"&&(a!=null&&a.boolean)&&(e[r]=!0),((n=t[r])==null?void 0:n.type)==="date"&&(e[r]instanceof Date||(e[r]=new Date(e[r])));return e}function Y(e,t){for(let a in e)typeof e[a]=="boolean"&&(t!=null&&t.boolean)&&(e[a]=e[a]?1:0),e[a]instanceof Date&&(e[a]=e[a].toISOString());return e}var rr=(e,t)=>({id:"kysely",create(s){return f(this,null,function*(){let{model:i,data:n,select:r}=s;t!=null&&t.transform&&(n=Y(n,t.transform));let o=yield e.insertInto(i).values(n).returningAll().executeTakeFirst();if(t!=null&&t.transform){let c=t.transform.schema[i];o=c?P(n,c,t.transform):o}return r!=null&&r.length&&(o=o?r.reduce((l,u)=>o!=null&&o[u]?C(m({},l),{[u]:o[u]}):l,{}):null),o})},findOne(s){return f(this,null,function*(){let{model:i,where:n,select:r}=s,{and:o,or:c}=_(n),l=e.selectFrom(i).selectAll();c&&(l=l.where(d=>d.or(c))),o&&(l=l.where(d=>d.and(o)));let u=yield l.executeTakeFirst();if(r!=null&&r.length&&(u=u?r.reduce((h,b)=>u!=null&&u[b]?C(m({},h),{[b]:u[b]}):h,{}):null),t!=null&&t.transform){let d=t.transform.schema[i];return u=u&&d?P(u,d,t.transform):u,u||null}return u||null})},findMany(s){return f(this,null,function*(){let{model:i,where:n}=s,r=e.selectFrom(i),{and:o,or:c}=_(n);o&&(r=r.where(u=>u.and(o))),c&&(r=r.where(u=>u.or(c)));let l=yield r.selectAll().execute();if(t!=null&&t.transform){let u=t.transform.schema[i];return u?l.map(d=>P(d,u,t.transform)):l}return l})},update(s){return f(this,null,function*(){let{model:i,where:n,update:r}=s,{and:o,or:c}=_(n);t!=null&&t.transform&&(r=Y(r,t.transform));let l=e.updateTable(i).set(r);o&&(l=l.where(d=>d.and(o))),c&&(l=l.where(d=>d.or(c)));let u=(yield l.returningAll().executeTakeFirst())||null;if(t!=null&&t.transform){let d=t.transform.schema[i];return d?P(u,d,t.transform):u}return u})},delete(s){return f(this,null,function*(){let{model:i,where:n}=s,{and:r,or:o}=_(n),c=e.deleteFrom(i);r&&(c=c.where(l=>l.and(r))),o&&(c=c.where(l=>l.or(o))),yield c.execute()})},createSchema(s){return f(this,null,function*(){let{compileMigrations:i}=yield Q(s);return console.log(i),{code:yield i(),fileName:`./better-auth_migrations/${new Date().toISOString()}.sql`}})}});export{Dt as drizzleAdapter,rr as kyselyAdapter,Pt as mongodbAdapter,Tt as prismaAdapter};
package/dist/api.d.ts CHANGED
@@ -1,9 +1,7 @@
1
- export { A as AuthEndpoint, b as AuthMiddleware, x as callbackOAuth, U as changePassword, a as createAuthEndpoint, c as createAuthMiddleware, O as createEmailVerificationToken, _ as csrfMiddleware, X as error, L as forgetPassword, M as forgetPasswordCallback, W as getCSRFToken, t as getEndpoints, y as getSession, z as getSessionFromCtx, D as listSessions, Y as ok, o as optionsMiddleware, N as resetPassword, E as revokeSession, J as revokeSessions, u as router, Q as sendVerificationEmail, C as sessionMiddleware, V as setPassword, w as signInEmail, v as signInOAuth, K as signOut, Z as signUpEmail, T as updateUser, S as verifyEmail } from './index-D_ohe9r9.js';
1
+ export { A as AuthEndpoint, b as AuthMiddleware, y as callbackOAuth, X as changePassword, a as createAuthEndpoint, c as createAuthMiddleware, Q as createEmailVerificationToken, a1 as csrfMiddleware, _ as error, M as forgetPassword, N as forgetPasswordCallback, Z as getCSRFToken, u as getEndpoints, z as getSession, C as getSessionFromCtx, E as listSessions, $ as ok, o as optionsMiddleware, O as resetPassword, J as revokeSession, K as revokeSessions, v as router, T as sendVerificationEmail, D as sessionMiddleware, Y as setPassword, x as signInEmail, w as signInOAuth, L as signOut, a0 as signUpEmail, V as updateUser, U as verifyEmail } from './index-BMYcrOqA.js';
2
2
  import 'zod';
3
3
  import './helper-C1ihmerM.js';
4
4
  import 'better-call';
5
5
  import 'kysely';
6
- import './schema-D9o3OF80.js';
7
- import './social.js';
6
+ import './index-CE92ti2Z.js';
8
7
  import 'arctic';
9
- import './adapter-D-m9-hQp.js';
package/dist/cli.js CHANGED
@@ -1,3 +1,5 @@
1
1
  #!/usr/bin/env node
2
- var X=Object.defineProperty;var O=Object.getOwnPropertySymbols;var R=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable;var D=(e,t,r)=>t in e?X(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,h=(e,t)=>{for(var r in t||(t={}))R.call(t,r)&&D(e,r,t[r]);if(O)for(var r of O(t))I.call(t,r)&&D(e,r,t[r]);return e};var M=(e,t)=>{var r={};for(var n in e)R.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&O)for(var n of O(e))t.indexOf(n)<0&&I.call(e,n)&&(r[n]=e[n]);return r};var g=(e,t,r)=>new Promise((n,o)=>{var s=l=>{try{u(r.next(l))}catch(f){o(f)}},a=l=>{try{u(r.throw(l))}catch(f){o(f)}},u=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,a);u((r=r.apply(e,t)).next())});import{Command as be}from"commander";import"dotenv/config";import{Command as ue}from"commander";import{loadConfig as j}from"c12";import{createConsola as z}from"consola";var T=z({formatOptions:{date:!1,colors:!0,compact:!0},defaults:{tag:"Better Auth"}}),H=e=>({log:(...t)=>{!(e!=null&&e.disabled)&&T.log("",...t)},error:(...t)=>{!(e!=null&&e.disabled)&&T.error("",...t)},warn:(...t)=>{!(e!=null&&e.disabled)&&T.warn("",...t)},info:(...t)=>{!(e!=null&&e.disabled)&&T.info("",...t)},debug:(...t)=>{!(e!=null&&e.disabled)&&T.debug("",...t)},box:(...t)=>{!(e!=null&&e.disabled)&&T.box("",...t)},success:(...t)=>{!(e!=null&&e.disabled)&&T.success("",...t)},break:(...t)=>{!(e!=null&&e.disabled)&&console.log(`
3
- `)}}),c=H();import J from"path";import Q from"@babel/preset-typescript";import Y from"@babel/preset-react";var w=["auth.ts","auth.tsx"];w=[...w,...w.map(e=>`lib/${e}`),...w.map(e=>`utils/${e}`)];w=[...w,...w.map(e=>`src/${e}`)];var S={transformOptions:{babel:{presets:[[Q,{isTSX:!0,allExtensions:!0}],[Y,{runtime:"automatic"}]]}},extensions:[".ts",".tsx",".js",".jsx"]};function E(r){return g(this,arguments,function*({cwd:e,configPath:t}){var n,o,s,a;try{let u=null;if(t){let{config:l}=yield j({configFile:J.join(e,t),dotenv:!0,jitiOptions:S});!l.auth&&!l.default&&(c.error("[#better-auth]: Couldn't read your auth config. Make sure to default export your auth instance or to export as a variable named auth."),process.exit(1)),u=((n=l.auth)==null?void 0:n.options)||((o=l.default)==null?void 0:o.options)||null}if(!u)for(let l of w)try{let{config:f}=yield j({configFile:l,jitiOptions:S});if(Object.keys(f).length>0){u=((s=f.auth)==null?void 0:s.options)||((a=f.default)==null?void 0:a.options)||null,u||(c.error("[#better-auth]: Couldn't read your auth config."),c.break(),c.info("[#better-auth]: Make sure to default export your auth instance or to export as a variable named auth."),process.exit(1));break}}catch(f){c.error(f),process.exit(1)}return u}catch(u){c.error("Error while reading your auth config.",u),process.exit(1)}})}import{z as C}from"zod";import{existsSync as ce}from"fs";import fe from"path";import Z from"better-sqlite3";import{Kysely as _}from"kysely";import{MysqlDialect as L,PostgresDialect as $,SqliteDialect as v}from"kysely";import{createPool as ee}from"mysql2";import te from"pg";var B=class extends Error{constructor(t,r,n){super(t),this.name="BetterAuthError",this.message=t,this.cause=r}};var{Pool:re}=te;var ae=e=>{var r,n;if(!e.database)return;if("createDriver"in e.database)return e.database;let t;if("provider"in e.database){let o=e.database.provider,s=(n=(r=e.database)==null?void 0:r.url)==null?void 0:n.trim();if(o==="postgres"&&(t=new $({pool:new re({connectionString:s})})),o==="mysql")try{let a=new URL(s),u=ee({host:a.hostname,user:a.username,password:a.password,database:a.pathname.split("/")[1],port:Number(a.port)});t=new L({pool:u})}catch(a){if(a instanceof TypeError)throw new B("Invalid database URL")}if(o==="sqlite"){let a=new Z(s);t=new v({database:a})}}return t},q=e=>{let t=ae(e);return t&&new _({dialect:t})},K=e=>{if("provider"in e.database)return e.database.provider;if("dialect"in e.database){if(e.database.dialect instanceof $)return"postgres";if(e.database.dialect instanceof L)return"mysql";if(e.database.dialect instanceof v)return"sqlite"}return"sqlite"};import me from"ora";import F from"chalk";import pe from"prompts";import"kysely";var P=e=>{var l,f,d,b,y,p;let t=(l=e.plugins)==null?void 0:l.reduce((i,A)=>{var k;let x=A.schema;if(!x)return i;for(let[N,U]of Object.entries(x))i[N]={fields:h(h({},(k=i[N])==null?void 0:k.fields),U.fields),tableName:N};return i},{}),r=((f=e.rateLimit)==null?void 0:f.storage)==="database",n={rateLimit:{tableName:((d=e.rateLimit)==null?void 0:d.tableName)||"rateLimit",fields:{key:{type:"string"},count:{type:"number"},lastRequest:{type:"number"}}}},m=t||{},{user:o,session:s,account:a}=m,u=M(m,["user","session","account"]);return h(h({user:{tableName:((b=e.user)==null?void 0:b.modelName)||"user",fields:h({name:{type:"string"},email:{type:"string"},emailVerified:{type:"boolean",defaultValue:()=>!1},image:{type:"string",required:!1},createdAt:{type:"date",defaultValue:()=>new Date},updatedAt:{type:"date",defaultValue:()=>new Date}},o==null?void 0:o.fields),order:0},session:{tableName:((y=e.session)==null?void 0:y.modelName)||"session",fields:h({expiresAt:{type:"date"},ipAddress:{type:"string",required:!1},userAgent:{type:"string",required:!1},userId:{type:"string",references:{model:"user",field:"id",onDelete:"cascade"}}},s==null?void 0:s.fields),order:1},account:{tableName:((p=e.account)==null?void 0:p.modelName)||"account",fields:h({accountId:{type:"string"},providerId:{type:"string"},userId:{type:"string",references:{model:"user",field:"id",onDelete:"cascade"}},accessToken:{type:"string",required:!1},refreshToken:{type:"string",required:!1},idToken:{type:"string",required:!1},expiresAt:{type:"date",required:!1},password:{type:"string",required:!1}},a==null?void 0:a.fields),order:2}},u),r?n:{})};function se(e){var r;return((r=e.plugins)==null?void 0:r.flatMap(n=>Object.keys(n.schema||{}).map(o=>{let a=(n.schema||{})[o];if(!(a!=null&&a.disableMigration))return{tableName:o,fields:a==null?void 0:a.fields}}).filter(o=>o!==void 0)))||[]}function V(e){let t=P(e),r=se(e);return[t.user,t.session,t.account,...r].reduce((o,s)=>{var a;return o[s.tableName]={fields:h(h({},(a=o[s.tableName])==null?void 0:a.fields),s.fields)},o},{})}var ne={string:["character varying","text"],number:["int4","integer","bigint","smallint","numeric","real","double precision"],boolean:["bool","boolean"],date:["timestamp","date"]},ie={string:["varchar","text"],number:["integer","int","bigint","smallint","decimal","float","double"],boolean:["boolean"],date:["date","datetime"]},oe={string:["TEXT"],number:["INTEGER","REAL"],boolean:["INTEGER","BOOLEAN"],date:["DATE","INTEGER"]},le={postgres:ne,mysql:ie,sqlite:oe};function de(e,t,r){return le[r][t].map(a=>a.toLowerCase()).includes(e.toLowerCase())}function G(e){return g(this,null,function*(){let t=V(e),r=K(e),n=q(e);n||(c.error("Invalid database configuration."),process.exit(1));let o=yield n.introspection.getTables(),s=[],a=[];for(let[d,m]of Object.entries(t)){let b=o.find(p=>p.name===d);if(!b){let p=s.findIndex(x=>x.table===d),i={table:d,fields:m.fields,order:m.order||1/0},A=s.findIndex(x=>(x.order||1/0)>i.order);A===-1?p===-1?s.push(i):s[p].fields=h(h({},s[p].fields),m.fields):s.splice(A,0,i);continue}let y={};for(let[p,i]of Object.entries(m.fields)){let A=b.columns.find(x=>x.name===p);if(!A){y[p]=i;continue}de(A.dataType,i.type,r)||c.warn(`Field ${p} in table ${d} has a different type in the database. Expected ${i.type} but got ${A.dataType}.`)}Object.keys(y).length>0&&a.push({table:d,fields:y,order:m.order||1/0})}let u=[];function l(d){let m={string:"text",boolean:"boolean",number:"integer",date:"date"};return r==="mysql"&&d==="string"?"varchar(255)":m[d]}if(a.length)for(let d of a)for(let[m,b]of Object.entries(d.fields)){let y=l(b.type),p=n.schema.alterTable(d.table).addColumn(m,y,i=>(i=b.required!==!1?i.notNull():i,b.references&&(i=i.references(`${b.references.model}.${b.references.field}`)),i));u.push(p)}if(s.length)for(let d of s){let m=n.schema.createTable(d.table).addColumn("id",l("string"),b=>b.primaryKey());for(let[b,y]of Object.entries(d.fields)){let p=l(y.type);m=m.addColumn(b,p,i=>(i=y.required!==!1?i.notNull():i,y.references&&(i=i.references(`${y.references.model}.${y.references.field}`)),y.unique&&(i=i.unique()),i))}u.push(m)}function f(){return g(this,null,function*(){for(let d of u)yield d.execute()})}return{toBeCreated:s,toBeAdded:a,runMigrations:f}})}var W=new ue("migrate").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("--config <config>","the path to the configuration file. defaults to the first configuration file found.").option("--y","").action(e=>g(void 0,null,function*(){let t=C.object({cwd:C.string(),config:C.string().optional()}).parse(e),r=fe.resolve(t.cwd);ce(r)||(c.error(`The directory "${r}" does not exist.`),process.exit(1));let n=yield E({cwd:r,configPath:t.config});if(!n){c.error("No configuration file found. Add a `auth.ts` file to your project or pass the path to the configuration file using the `--config` flag.");return}q(n)||(c.error("Invalid database configuration."),process.exit(1));let s=me("preparing migration...").start(),{toBeAdded:a,toBeCreated:u,runMigrations:l}=yield G(n);!a.length&&!u.length&&(s.stop(),c.success("\u{1F680} No migrations needed."),process.exit(0)),s.stop(),c.info("\u{1F511} The migration will affect the following:");for(let d of[...u,...a])c.info("->",F.magenta(Object.keys(d.fields).join(", ")),F.white("fields on"),F.yellow(`${d.table}`),F.white("table."));let{migrate:f}=yield pe({type:"confirm",name:"migrate",message:"Are you sure you want to run these migrations?",initial:!1});f||(c.info("Migration cancelled."),process.exit(0)),s==null||s.start("migrating..."),yield l(),s.stop(),c.success("\u{1F680} migration was completed successfully!"),process.exit(0)}));function ye(){return g(this,null,function*(){let e=new be().name("better-auth");e.addCommand(W),e.parse()})}ye();
2
+ var ie=Object.defineProperty,se=Object.defineProperties;var ne=Object.getOwnPropertyDescriptors;var D=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var K=(e,t,a)=>t in e?ie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,h=(e,t)=>{for(var a in t||(t={}))P.call(t,a)&&K(e,a,t[a]);if(D)for(var a of D(t))V.call(t,a)&&K(e,a,t[a]);return e},k=(e,t)=>se(e,ne(t));var le=(e=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(e,{get:(t,a)=>(typeof require!="undefined"?require:t)[a]}):e)(function(e){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var z=(e,t)=>{var a={};for(var o in e)P.call(e,o)&&t.indexOf(o)<0&&(a[o]=e[o]);if(e!=null&&D)for(var o of D(e))t.indexOf(o)<0&&V.call(e,o)&&(a[o]=e[o]);return a};var b=(e,t,a)=>new Promise((o,i)=>{var n=l=>{try{s(a.next(l))}catch(d){i(d)}},r=l=>{try{s(a.throw(l))}catch(d){i(d)}},s=l=>l.done?o(l.value):Promise.resolve(l.value).then(n,r);s((a=a.apply(e,t)).next())});import{Command as Se}from"commander";import"dotenv/config";import{Command as Be}from"commander";import{loadConfig as G}from"c12";import{createConsola as de}from"consola";var T=de({formatOptions:{date:!1,colors:!0,compact:!0},defaults:{tag:"Better Auth"}}),ce=e=>({log:(...t)=>{!(e!=null&&e.disabled)&&T.log("",...t)},error:(...t)=>{!(e!=null&&e.disabled)&&T.error("",...t)},warn:(...t)=>{!(e!=null&&e.disabled)&&T.warn("",...t)},info:(...t)=>{!(e!=null&&e.disabled)&&T.info("",...t)},debug:(...t)=>{!(e!=null&&e.disabled)&&T.debug("",...t)},box:(...t)=>{!(e!=null&&e.disabled)&&T.box("",...t)},success:(...t)=>{!(e!=null&&e.disabled)&&T.success("",...t)},break:(...t)=>{!(e!=null&&e.disabled)&&console.log(`
3
+ `)}}),m=ce();import ue from"path";import me from"@babel/preset-typescript";import fe from"@babel/preset-react";var q=["auth.ts","auth.tsx"];q=[...q,...q.map(e=>`lib/${e}`),...q.map(e=>`utils/${e}`)];q=[...q,...q.map(e=>`src/${e}`)];var W={transformOptions:{babel:{presets:[[me,{isTSX:!0,allExtensions:!0}],[fe,{runtime:"automatic"}]]}},extensions:[".ts",".tsx",".js",".jsx"]};function N(a){return b(this,arguments,function*({cwd:e,configPath:t}){var o,i,n,r;try{let s=null;if(t){let{config:l}=yield G({configFile:ue.join(e,t),dotenv:!0,jitiOptions:W});!l.auth&&!l.default&&(m.error("[#better-auth]: Couldn't read your auth config. Make sure to default export your auth instance or to export as a variable named auth."),process.exit(1)),s=((o=l.auth)==null?void 0:o.options)||((i=l.default)==null?void 0:i.options)||null}if(!s)for(let l of q)try{let{config:d}=yield G({configFile:l,jitiOptions:W});if(Object.keys(d).length>0){s=((n=d.auth)==null?void 0:n.options)||((r=d.default)==null?void 0:r.options)||null,s||(m.error("[#better-auth]: Couldn't read your auth config."),m.break(),m.info("[#better-auth]: Make sure to default export your auth instance or to export as a variable named auth."),process.exit(1));break}}catch(d){m.error(d),process.exit(1)}return s}catch(s){m.error("Error while reading your auth config.",s),process.exit(1)}})}import{z as v}from"zod";import{existsSync as Fe}from"fs";import ke from"path";import{Kysely as pe}from"kysely";import{MysqlDialect as U,PostgresDialect as X,SqliteDialect as _}from"kysely";import{createPool as ye}from"mysql2";import he from"pg";var O=class extends Error{constructor(t,a,o){super(t),this.name="BetterAuthError",this.message=t,this.cause=a}};var{Pool:be}=he,ge=e=>{var a,o;if(!e.database)return;if("createDriver"in e.database)return e.database;let t;if("provider"in e.database){let i=e.database.provider,n=(o=(a=e.database)==null?void 0:a.url)==null?void 0:o.trim();if(i==="postgres"&&(t=new X({pool:new be({connectionString:n})})),i==="mysql")try{let r=new URL(n),s=ye({host:r.hostname,user:r.username,password:r.password,database:r.pathname.split("/")[1],port:Number(r.port)});t=new U({pool:s})}catch(r){if(r instanceof TypeError)throw new O("Invalid database URL")}if(i==="sqlite"){let r=le("better-sqlite3"),s=new r(n);t=new _({database:s})}}return t},F=e=>{let t=ge(e);return t&&new pe({dialect:t})},C=e=>{if("provider"in e.database)return e.database.provider;if("dialect"in e.database){if(e.database.dialect instanceof X)return"postgres";if(e.database.dialect instanceof U)return"mysql";if(e.database.dialect instanceof _)return"sqlite"}return"sqlite"};import De from"ora";import M from"chalk";import Ne from"prompts";import"kysely";var j=e=>{var l,d,u,p,y,A;let t=(l=e.plugins)==null?void 0:l.reduce((g,f)=>{var x;let w=f.schema;if(!w)return g;for(let[$,oe]of Object.entries(w))g[$]={fields:h(h({},(x=g[$])==null?void 0:x.fields),oe.fields),tableName:$};return g},{}),a=((d=e.rateLimit)==null?void 0:d.storage)==="database",o={rateLimit:{tableName:((u=e.rateLimit)==null?void 0:u.tableName)||"rateLimit",fields:{key:{type:"string"},count:{type:"number"},lastRequest:{type:"number"}}}},c=t||{},{user:i,session:n,account:r}=c,s=z(c,["user","session","account"]);return h(h({user:{tableName:((p=e.user)==null?void 0:p.modelName)||"user",fields:h({name:{type:"string",required:!0},email:{type:"string",unique:!0,required:!0},emailVerified:{type:"boolean",defaultValue:()=>!1,required:!0},image:{type:"string",required:!1},createdAt:{type:"date",defaultValue:()=>new Date,required:!0},updatedAt:{type:"date",defaultValue:()=>new Date,required:!0}},i==null?void 0:i.fields),order:0},session:{tableName:((y=e.session)==null?void 0:y.modelName)||"session",fields:h({expiresAt:{type:"date",required:!0},ipAddress:{type:"string",required:!1},userAgent:{type:"string",required:!1},userId:{type:"string",references:{model:"user",field:"id",onDelete:"cascade"},required:!0}},n==null?void 0:n.fields),order:1},account:{tableName:((A=e.account)==null?void 0:A.modelName)||"account",fields:h({accountId:{type:"string",required:!0},providerId:{type:"string",required:!0},userId:{type:"string",references:{model:"user",field:"id",onDelete:"cascade"},required:!0},accessToken:{type:"string",required:!1},refreshToken:{type:"string",required:!1},idToken:{type:"string",required:!1},expiresAt:{type:"date",required:!1},password:{type:"string",required:!1}},r==null?void 0:r.fields),order:2}},s),a?o:{})};function Ae(e){var a;return((a=e.plugins)==null?void 0:a.flatMap(o=>Object.keys(o.schema||{}).map(i=>{let r=(o.schema||{})[i];if(!(r!=null&&r.disableMigration))return{tableName:i,fields:r==null?void 0:r.fields}}).filter(i=>i!==void 0)))||[]}function H(e){let t=j(e),a=Ae(e);return[t.user,t.session,t.account,...a].reduce((i,n)=>{var r;return i[n.tableName]={fields:h(h({},(r=i[n.tableName])==null?void 0:r.fields),n.fields)},i},{})}var we={string:["character varying","text"],number:["int4","integer","bigint","smallint","numeric","real","double precision"],boolean:["bool","boolean"],date:["timestamp","date"]},xe={string:["varchar","text"],number:["integer","int","bigint","smallint","decimal","float","double"],boolean:["boolean"],date:["date","datetime"]},qe={string:["TEXT"],number:["INTEGER","REAL"],boolean:["INTEGER","BOOLEAN"],date:["DATE","INTEGER"]},Te={postgres:we,mysql:xe,sqlite:qe};function Oe(e,t,a){return Te[a][t].map(r=>r.toLowerCase()).includes(e.toLowerCase())}function S(e){return b(this,null,function*(){let t=H(e),a=C(e),o=F(e);o||(m.error("Invalid database configuration."),process.exit(1));let i=yield o.introspection.getTables(),n=[],r=[];for(let[c,p]of Object.entries(t)){let y=i.find(g=>g.name===c);if(!y){let g=n.findIndex(x=>x.table===c),f={table:c,fields:p.fields,order:p.order||1/0},w=n.findIndex(x=>(x.order||1/0)>f.order);w===-1?g===-1?n.push(f):n[g].fields=h(h({},n[g].fields),p.fields):n.splice(w,0,f);continue}let A={};for(let[g,f]of Object.entries(p.fields)){let w=y.columns.find(x=>x.name===g);if(!w){A[g]=f;continue}Oe(w.dataType,f.type,a)||m.warn(`Field ${g} in table ${c} has a different type in the database. Expected ${f.type} but got ${w.dataType}.`)}Object.keys(A).length>0&&r.push({table:c,fields:A,order:p.order||1/0})}let s=[];function l(c){let p={string:"text",boolean:"boolean",number:"integer",date:"date"};return a==="mysql"&&c==="string"?"varchar(255)":p[c]}if(r.length)for(let c of r)for(let[p,y]of Object.entries(c.fields)){let A=l(y.type),g=o.schema.alterTable(c.table).addColumn(p,A,f=>(f=y.required!==!1?f.notNull():f,y.references&&(f=f.references(`${y.references.model}.${y.references.field}`)),f));s.push(g)}if(n.length)for(let c of n){let p=o.schema.createTable(c.table).addColumn("id",l("string"),y=>y.primaryKey());for(let[y,A]of Object.entries(c.fields)){let g=l(A.type);p=p.addColumn(y,g,f=>(f=A.required!==!1?f.notNull():f,A.references&&(f=f.references(`${A.references.model}.${A.references.field}`)),A.unique&&(f=f.unique()),f))}s.push(p)}function d(){return b(this,null,function*(){for(let c of s)yield c.execute()})}function u(){return b(this,null,function*(){return s.map(p=>p.compile().sql).join(`;
4
+
5
+ `)})}return{toBeCreated:n,toBeAdded:r,runMigrations:d,compileMigrations:u}})}var J=new Be("migrate").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("--config <config>","the path to the configuration file. defaults to the first configuration file found.").option("--y","").action(e=>b(void 0,null,function*(){let t=v.object({cwd:v.string(),config:v.string().optional()}).parse(e),a=ke.resolve(t.cwd);Fe(a)||(m.error(`The directory "${a}" does not exist.`),process.exit(1));let o=yield N({cwd:a,configPath:t.config});if(!o){m.error("No configuration file found. Add a `auth.ts` file to your project or pass the path to the configuration file using the `--config` flag.");return}F(o)||(m.error("Invalid database configuration."),process.exit(1));let n=De("preparing migration...").start(),{toBeAdded:r,toBeCreated:s,runMigrations:l}=yield S(o);!r.length&&!s.length&&(n.stop(),m.success("\u{1F680} No migrations needed."),process.exit(0)),n.stop(),m.info("\u{1F511} The migration will affect the following:");for(let u of[...s,...r])m.info("->",M.magenta(Object.keys(u.fields).join(", ")),M.white("fields on"),M.yellow(`${u.table}`),M.white("table."));let{migrate:d}=yield Ne({type:"confirm",name:"migrate",message:"Are you sure you want to run these migrations?",initial:!1});d||(m.info("Migration cancelled."),process.exit(0)),n==null||n.start("migrating..."),yield l(),n.stop(),m.success("\u{1F680} migration was completed successfully!"),process.exit(0)}));import{Command as Ce}from"commander";import{z as E}from"zod";import{existsSync as ee}from"fs";import B from"path";import je from"ora";import te from"prompts";function R(e){if(!e)return{and:null,or:null};let t=e==null?void 0:e.filter(o=>o.connector==="AND"||!o.connector).reduce((o,i)=>k(h({},o),{[i.field]:i.value}),{}),a=e==null?void 0:e.filter(o=>o.connector==="OR").reduce((o,i)=>k(h({},o),{[i.field]:i.value}),{});return{and:Object.keys(t).length?t:null,or:Object.keys(a).length?a:null}}function I(e,t,a){var o,i,n;for(let r in e)e[r]===0&&((o=t[r])==null?void 0:o.type)==="boolean"&&(a!=null&&a.boolean)&&(e[r]=!1),e[r]===1&&((i=t[r])==null?void 0:i.type)==="boolean"&&(a!=null&&a.boolean)&&(e[r]=!0),((n=t[r])==null?void 0:n.type)==="date"&&(e[r]instanceof Date||(e[r]=new Date(e[r])));return e}function Q(e,t){for(let a in e)typeof e[a]=="boolean"&&(t!=null&&t.boolean)&&(e[a]=e[a]?1:0),e[a]instanceof Date&&(e[a]=e[a].toISOString());return e}var Y=(e,t)=>({id:"kysely",create(o){return b(this,null,function*(){let{model:i,data:n,select:r}=o;t!=null&&t.transform&&(n=Q(n,t.transform));let s=yield e.insertInto(i).values(n).returningAll().executeTakeFirst();if(t!=null&&t.transform){let l=t.transform.schema[i];s=l?I(n,l,t.transform):s}return r!=null&&r.length&&(s=s?r.reduce((d,u)=>s!=null&&s[u]?k(h({},d),{[u]:s[u]}):d,{}):null),s})},findOne(o){return b(this,null,function*(){let{model:i,where:n,select:r}=o,{and:s,or:l}=R(n),d=e.selectFrom(i).selectAll();l&&(d=d.where(c=>c.or(l))),s&&(d=d.where(c=>c.and(s)));let u=yield d.executeTakeFirst();if(r!=null&&r.length&&(u=u?r.reduce((p,y)=>u!=null&&u[y]?k(h({},p),{[y]:u[y]}):p,{}):null),t!=null&&t.transform){let c=t.transform.schema[i];return u=u&&c?I(u,c,t.transform):u,u||null}return u||null})},findMany(o){return b(this,null,function*(){let{model:i,where:n}=o,r=e.selectFrom(i),{and:s,or:l}=R(n);s&&(r=r.where(u=>u.and(s))),l&&(r=r.where(u=>u.or(l)));let d=yield r.selectAll().execute();if(t!=null&&t.transform){let u=t.transform.schema[i];return u?d.map(c=>I(c,u,t.transform)):d}return d})},update(o){return b(this,null,function*(){let{model:i,where:n,update:r}=o,{and:s,or:l}=R(n);t!=null&&t.transform&&(r=Q(r,t.transform));let d=e.updateTable(i).set(r);s&&(d=d.where(c=>c.and(s))),l&&(d=d.where(c=>c.or(l)));let u=(yield d.returningAll().executeTakeFirst())||null;if(t!=null&&t.transform){let c=t.transform.schema[i];return c?I(u,c,t.transform):u}return u})},delete(o){return b(this,null,function*(){let{model:i,where:n}=o,{and:r,or:s}=R(n),l=e.deleteFrom(i);r&&(l=l.where(d=>d.and(r))),s&&(l=l.where(d=>d.or(s))),yield l.execute()})},createSchema(o){return b(this,null,function*(){let{compileMigrations:i}=yield S(o);return console.log(i),{code:yield i(),fileName:`./better-auth_migrations/${new Date().toISOString()}.sql`}})}});function Z(e){if(!e.database)throw new O("Database configuration is required");if("create"in e.database)return e.database;let t=F(e);if(!t)throw new O("Failed to initialize database adapter");let a=j(e),o={};for(let i of Object.values(a))o[i.tableName]=i.fields;return Y(t,{transform:{schema:o,date:!0,boolean:C(e)==="sqlite"}})}import L from"fs/promises";import re from"chalk";var ae=new Ce("generate").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("--config <config>","the path to the configuration file. defaults to the first configuration file found.").option("--out <output>","the file to output to the generated schema").option("--y","").action(e=>b(void 0,null,function*(){let t=E.object({cwd:E.string(),config:E.string().optional(),out:E.string().optional()}).parse(e),a=B.resolve(t.cwd);ee(a)||(m.error(`The directory "${a}" does not exist.`),process.exit(1));let o=yield N({cwd:a,configPath:t.config});if(!o){m.error("No configuration file found. Add a `auth.ts` file to your project or pass the path to the configuration file using the `--config` flag.");return}let i=Z(o);i.createSchema||(m.error("The adapter does not support schema generation."),process.exit(1));let n=je("preparing schema...").start(),{code:r,fileName:s,append:l}=yield i.createSchema(o,t.out);if(n.stop(),l){let{append:c}=yield te({type:"confirm",name:"append",message:`The file ${s} already exists. Do you want to ${re.yellow("append")} the schema to the file?`});c?(yield L.appendFile(B.join(a,s),r),m.success("\u{1F680} schema was appended successfully!"),process.exit(0)):(m.error("Schema generation aborted."),process.exit(1))}let{confirm:d}=yield te({type:"confirm",name:"confirm",message:`Do you want to generate the schema to ${re.yellow(s)}?`});d||(m.error("Schema generation aborted."),process.exit(1)),ee(B.dirname(B.join(a,s)))||(yield L.mkdir(B.dirname(B.join(a,s)),{recursive:!0})),yield L.writeFile(t.out||B.join(a,s),r),m.success("\u{1F680} schema was generated successfully!"),process.exit(0)}));function Me(){return b(this,null,function*(){let e=new Se().name("better-auth");e.addCommand(J).addCommand(ae),e.parse()})}Me();
@@ -2,17 +2,15 @@ import * as nanostores from 'nanostores';
2
2
  import { A as AccessControl, S as StatementsPrimitive, R as Role } from '../statement-CU-fdHXK.js';
3
3
  import * as _better_fetch_fetch from '@better-fetch/fetch';
4
4
  import { BetterFetchOption } from '@better-fetch/fetch';
5
- import { o as organization, d as Organization, M as Member, I as Invitation, u as username, m as magicLink } from '../index-DsEvbKjm.js';
6
- export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-DsEvbKjm.js';
5
+ import { o as organization, d as Organization, M as Member, I as Invitation, u as username, m as magicLink } from '../index-3B6zGicM.js';
6
+ export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-3B6zGicM.js';
7
7
  import { P as Prettify } from '../helper-C1ihmerM.js';
8
- import '../schema-D9o3OF80.js';
8
+ import '../index-CE92ti2Z.js';
9
+ import 'arctic';
9
10
  import 'zod';
10
11
  import 'better-call';
11
- import '../index-D_ohe9r9.js';
12
+ import '../index-BMYcrOqA.js';
12
13
  import 'kysely';
13
- import '../social.js';
14
- import 'arctic';
15
- import '../adapter-D-m9-hQp.js';
16
14
  import '@simplewebauthn/types';
17
15
 
18
16
  interface OrganizationClientOptions {
package/dist/client.d.ts CHANGED
@@ -3,16 +3,14 @@ import * as nanostores from 'nanostores';
3
3
  import { PreinitializedWritableAtom } from 'nanostores';
4
4
  import * as _better_fetch_fetch from '@better-fetch/fetch';
5
5
  import { BetterFetch, BetterFetchError, BetterFetchOption } from '@better-fetch/fetch';
6
- import { B as BetterAuthPlugin, F as FieldAttribute, I as InferFieldOutput } from './index-D_ohe9r9.js';
6
+ import { B as BetterAuthPlugin, F as FieldAttribute, I as InferFieldOutput } from './index-BMYcrOqA.js';
7
7
  import { U as UnionToIntersection, P as Prettify } from './helper-C1ihmerM.js';
8
8
  import { ClientOptions, InferClientAPI, InferActions, BetterAuthClientPlugin, InferSessionFromClient, InferUserFromClient, IsSignal } from './types.js';
9
9
  export { AtomListener, InferPluginsFromClient } from './types.js';
10
10
  import 'kysely';
11
- import './schema-D9o3OF80.js';
12
- import 'better-call';
13
- import './social.js';
11
+ import './index-CE92ti2Z.js';
14
12
  import 'arctic';
15
- import './adapter-D-m9-hQp.js';
13
+ import 'better-call';
16
14
 
17
15
  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> ? {
18
16
  [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: Atoms[key];
@@ -1,11 +1,11 @@
1
- import { U as User, S as Session } from './schema-D9o3OF80.js';
1
+ import { U as User, S as Session } from './index-CE92ti2Z.js';
2
2
  import * as better_call from 'better-call';
3
3
  import { z, ZodObject, ZodOptional, ZodArray, ZodLiteral } from 'zod';
4
4
  import { P as Prettify } from './helper-C1ihmerM.js';
5
5
  import { A as AccessControl, R as Role, S as StatementsPrimitive, g as defaultRoles } from './statement-CU-fdHXK.js';
6
6
  import * as _better_fetch_fetch from '@better-fetch/fetch';
7
7
  import { BetterFetch, BetterFetchOption } from '@better-fetch/fetch';
8
- import { H as HookEndpointContext } from './index-D_ohe9r9.js';
8
+ import { H as HookEndpointContext } from './index-BMYcrOqA.js';
9
9
  import * as nanostores from 'nanostores';
10
10
  import { atom } from 'nanostores';
11
11
  import * as _simplewebauthn_types from '@simplewebauthn/types';
@@ -2357,6 +2357,7 @@ declare const organization: <O extends OrganizationOptions>(options?: O) => {
2357
2357
  fields: {
2358
2358
  name: {
2359
2359
  type: "string";
2360
+ required: true;
2360
2361
  };
2361
2362
  slug: {
2362
2363
  type: "string";
@@ -2430,6 +2431,7 @@ declare const organization: <O extends OrganizationOptions>(options?: O) => {
2430
2431
  model: string;
2431
2432
  field: string;
2432
2433
  };
2434
+ required: true;
2433
2435
  };
2434
2436
  };
2435
2437
  };
@@ -4009,6 +4011,7 @@ declare const passkey: (options?: PasskeyOptions) => {
4009
4011
  };
4010
4012
  publicKey: {
4011
4013
  type: "string";
4014
+ required: true;
4012
4015
  };
4013
4016
  userId: {
4014
4017
  type: "string";
@@ -4016,18 +4019,23 @@ declare const passkey: (options?: PasskeyOptions) => {
4016
4019
  model: string;
4017
4020
  field: string;
4018
4021
  };
4022
+ required: true;
4019
4023
  };
4020
4024
  webauthnUserID: {
4021
4025
  type: "string";
4026
+ required: true;
4022
4027
  };
4023
4028
  counter: {
4024
4029
  type: "number";
4030
+ required: true;
4025
4031
  };
4026
4032
  deviceType: {
4027
4033
  type: "string";
4034
+ required: true;
4028
4035
  };
4029
4036
  backedUp: {
4030
4037
  type: "boolean";
4038
+ required: true;
4031
4039
  };
4032
4040
  transports: {
4033
4041
  type: "string";
@@ -1,14 +1,75 @@
1
1
  import * as kysely from 'kysely';
2
2
  import { Kysely, Migration, Dialect } from 'kysely';
3
- import { U as User, A as Account, S as Session } from './schema-D9o3OF80.js';
3
+ import { S as Session, U as User, A as Account, O as OAuthProvider, a as AppleProfile, D as DiscordProfile, F as FacebookProfile, G as GithubProfile, b as GoogleProfile, c as SpotifyProfile, T as TwitchProfile, d as TwitterProfile, e as SocialProviders, f as OAuthProviderList } from './index-CE92ti2Z.js';
4
4
  import * as better_call from 'better-call';
5
5
  import { ContextTools, CookieOptions, Endpoint, EndpointResponse, Context, Prettify as Prettify$1 } from 'better-call';
6
6
  import * as zod from 'zod';
7
7
  import { ZodSchema, z } from 'zod';
8
8
  import { L as LiteralString, U as UnionToIntersection, P as Prettify } from './helper-C1ihmerM.js';
9
- import { OAuthProvider, AppleProfile, DiscordProfile, FacebookProfile, GithubProfile, GoogleProfile, SpotifyProfile, TwitchProfile, TwitterProfile, SocialProviders, OAuthProviderList } from './social.js';
10
9
  import * as arctic from 'arctic';
11
- import { A as Adapter } from './adapter-D-m9-hQp.js';
10
+
11
+ /**
12
+ * Adapter where clause
13
+ */
14
+ type Where = {
15
+ operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte";
16
+ value: string;
17
+ field: string;
18
+ connector?: "AND" | "OR";
19
+ };
20
+ /**
21
+ * Adapter Interface
22
+ */
23
+ interface Adapter {
24
+ id: string;
25
+ create: <T, R = T>(data: {
26
+ model: string;
27
+ data: T;
28
+ select?: string[];
29
+ }) => Promise<R>;
30
+ findOne: <T>(data: {
31
+ model: string;
32
+ where: Where[];
33
+ select?: string[];
34
+ }) => Promise<T | null>;
35
+ findMany: <T>(data: {
36
+ model: string;
37
+ where?: Where[];
38
+ }) => Promise<T[]>;
39
+ update: <T>(data: {
40
+ model: string;
41
+ where: Where[];
42
+ update: Record<string, any>;
43
+ }) => Promise<T | null>;
44
+ delete: <T>(data: {
45
+ model: string;
46
+ where: Where[];
47
+ }) => Promise<void>;
48
+ /**
49
+ *
50
+ * @param options
51
+ * @param file - file path if provided by the user
52
+ * @returns
53
+ */
54
+ createSchema?: (options: BetterAuthOptions, file?: string) => Promise<{
55
+ code: string;
56
+ fileName: string;
57
+ append?: boolean;
58
+ }>;
59
+ }
60
+ interface SessionAdapter {
61
+ create: (data: {
62
+ userId: string;
63
+ expiresAt: Date;
64
+ }) => Promise<Session>;
65
+ findOne: (data: {
66
+ userId: string;
67
+ }) => Promise<Session | null>;
68
+ update: (data: Session) => Promise<Session>;
69
+ delete: (data: {
70
+ sessionId: string;
71
+ }) => Promise<void>;
72
+ }
12
73
 
13
74
  declare const createInternalAdapter: (adapter: Adapter, options: BetterAuthOptions) => {
14
75
  createOAuthUser: (user: User, account: Account) => Promise<{
@@ -225,115 +286,13 @@ type RequiredKeysOf<BaseType extends object> = Exclude<{
225
286
  }[keyof BaseType], undefined>;
226
287
  type HasRequiredKeys<BaseType extends object> = RequiredKeysOf<BaseType> extends never ? false : true;
227
288
 
228
- declare const getAuthTables: (options: BetterAuthOptions) => {
229
- rateLimit?: {
230
- tableName: string;
231
- fields: {
232
- key: {
233
- type: "string";
234
- };
235
- count: {
236
- type: "number";
237
- };
238
- lastRequest: {
239
- type: "number";
240
- };
241
- };
242
- } | undefined;
243
- user: {
244
- tableName: string;
245
- fields: {
246
- name: {
247
- type: "string";
248
- };
249
- email: {
250
- type: "string";
251
- };
252
- emailVerified: {
253
- type: "boolean";
254
- defaultValue: () => false;
255
- };
256
- image: {
257
- type: "string";
258
- required: false;
259
- };
260
- createdAt: {
261
- type: "date";
262
- defaultValue: () => Date;
263
- };
264
- updatedAt: {
265
- type: "date";
266
- defaultValue: () => Date;
267
- };
268
- };
269
- order: number;
270
- };
271
- session: {
272
- tableName: string;
273
- fields: {
274
- expiresAt: {
275
- type: "date";
276
- };
277
- ipAddress: {
278
- type: "string";
279
- required: false;
280
- };
281
- userAgent: {
282
- type: "string";
283
- required: false;
284
- };
285
- userId: {
286
- type: "string";
287
- references: {
288
- model: string;
289
- field: string;
290
- onDelete: "cascade";
291
- };
292
- };
293
- };
294
- order: number;
295
- };
296
- account: {
297
- tableName: string;
298
- fields: {
299
- accountId: {
300
- type: "string";
301
- };
302
- providerId: {
303
- type: "string";
304
- };
305
- userId: {
306
- type: "string";
307
- references: {
308
- model: string;
309
- field: string;
310
- onDelete: "cascade";
311
- };
312
- };
313
- accessToken: {
314
- type: "string";
315
- required: false;
316
- };
317
- refreshToken: {
318
- type: "string";
319
- required: false;
320
- };
321
- idToken: {
322
- type: "string";
323
- required: false;
324
- };
325
- expiresAt: {
326
- type: "date";
327
- required: false;
328
- };
329
- password: {
330
- type: "string";
331
- required: false;
332
- };
333
- };
334
- order: number;
335
- };
336
- };
289
+ type BetterAuthDbSchema = Record<string, {
290
+ tableName: string;
291
+ fields: Record<string, FieldAttribute>;
292
+ disableMigrations?: boolean;
293
+ order?: number;
294
+ }>;
295
+ declare const getAuthTables: (options: BetterAuthOptions) => BetterAuthDbSchema;
337
296
 
338
297
  declare function getAdapter(options: BetterAuthOptions): Adapter;
339
298
 
@@ -5421,4 +5380,4 @@ type Auth = {
5421
5380
  options: BetterAuthOptions;
5422
5381
  };
5423
5382
 
5424
- export { betterAuth as $, type AuthEndpoint as A, type BetterAuthPlugin as B, sessionMiddleware as C, listSessions as D, revokeSession as E, type FieldAttribute as F, type GenericEndpointContext as G, type HookEndpointContext as H, type InferFieldOutput as I, revokeSessions as J, signOut as K, forgetPassword as L, forgetPasswordCallback as M, resetPassword as N, createEmailVerificationToken as O, type PluginSchema as P, sendVerificationEmail as Q, type RateLimit as R, verifyEmail as S, updateUser as T, changePassword as U, setPassword as V, getCSRFToken as W, error as X, ok as Y, signUpEmail as Z, csrfMiddleware as _, createAuthEndpoint as a, type AuthMiddleware as b, createAuthMiddleware as c, type Auth as d, type BetterAuthOptions as e, type AuthContext as f, getCookies as g, createCookieGetter as h, type BetterAuthCookies as i, deleteSessionCookie as j, createLogger as k, logger as l, type InferSession as m, type InferUser as n, optionsMiddleware as o, parseSetCookieHeader as p, type InferPluginTypes as q, init as r, setSessionCookie as s, getEndpoints as t, router as u, signInOAuth as v, signInEmail as w, callbackOAuth as x, getSession as y, getSessionFromCtx as z };
5383
+ export { ok as $, type AuthEndpoint as A, type BetterAuthPlugin as B, getSessionFromCtx as C, sessionMiddleware as D, listSessions as E, type FieldAttribute as F, type GenericEndpointContext as G, type HookEndpointContext as H, type InferFieldOutput as I, revokeSession as J, revokeSessions as K, signOut as L, forgetPassword as M, forgetPasswordCallback as N, resetPassword as O, type PluginSchema as P, createEmailVerificationToken as Q, type RateLimit as R, type SessionAdapter as S, sendVerificationEmail as T, verifyEmail as U, updateUser as V, type Where as W, changePassword as X, setPassword as Y, getCSRFToken as Z, error as _, createAuthEndpoint as a, signUpEmail as a0, csrfMiddleware as a1, betterAuth as a2, type AuthMiddleware as b, createAuthMiddleware as c, type Auth as d, type BetterAuthOptions as e, type Adapter as f, type AuthContext as g, getCookies as h, createCookieGetter as i, type BetterAuthCookies as j, deleteSessionCookie as k, createLogger as l, logger as m, type InferSession as n, optionsMiddleware as o, parseSetCookieHeader as p, type InferUser as q, type InferPluginTypes as r, setSessionCookie as s, init as t, getEndpoints as u, router as v, signInOAuth as w, signInEmail as x, callbackOAuth as y, getSession as z };