better-auth 0.3.0 → 0.3.1
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/adapters/drizzle.d.ts +1 -1
- package/dist/adapters/mongodb.d.ts +1 -1
- package/dist/adapters/prisma.d.ts +1 -1
- package/dist/api.d.ts +1 -1
- package/dist/api.js +0 -12
- package/dist/client/plugins.d.ts +3 -3
- package/dist/client.d.ts +1 -1
- package/dist/{index-BkvPZOrg.d.ts → index-B-Rb8u6d.d.ts} +1 -1
- package/dist/{index-L1yd6IfX.d.ts → index-BRcc7HbO.d.ts} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +0 -12
- package/dist/next-js.d.ts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/plugins.d.ts +6 -9
- package/dist/plugins.js +17 -65
- package/dist/react.d.ts +1 -1
- package/dist/solid-start.d.ts +1 -1
- package/dist/solid.d.ts +1 -1
- package/dist/svelte-kit.d.ts +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/vue.d.ts +1 -1
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { f as AuthEndpoint, g as AuthMiddleware, n as callbackOAuth, L as changePassword, e as createAuthEndpoint, d as createAuthMiddleware, D as createEmailVerificationToken, V as csrfMiddleware, N as deleteUser, Q as error, y as forgetPassword, z as forgetPasswordCallback, O as getCSRFToken, l as getEndpoints, p as getSession, q as getSessionFromCtx, u as listSessions, T as ok, o as optionsMiddleware, C as resetPassword, v as revokeSession, w as revokeSessions, r as router, E as sendVerificationEmail, t as sessionMiddleware, M as setPassword, m as signInEmail, s as signInOAuth, x as signOut, U as signUpEmail, K as updateUser, J as verifyEmail } from './index-BRcc7HbO.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import './helper-DPDj8Nix.js';
|
|
4
4
|
import 'better-call';
|
package/dist/api.js
CHANGED
|
@@ -773,17 +773,6 @@ function getIp(req) {
|
|
|
773
773
|
}
|
|
774
774
|
|
|
775
775
|
// src/api/routes/session.ts
|
|
776
|
-
function getRequestUniqueKey(ctx, token) {
|
|
777
|
-
if (!ctx.request) {
|
|
778
|
-
return "";
|
|
779
|
-
}
|
|
780
|
-
const { method, url, headers } = ctx.request;
|
|
781
|
-
const userAgent = ctx.request.headers.get("User-Agent") || "";
|
|
782
|
-
const ip = getIp(ctx.request) || "";
|
|
783
|
-
const headerString = JSON.stringify(headers);
|
|
784
|
-
const uniqueString = `${method}:${url}:${headerString}:${userAgent}:${ip}:${token}`;
|
|
785
|
-
return uniqueString;
|
|
786
|
-
}
|
|
787
776
|
var getSession = () => createAuthEndpoint(
|
|
788
777
|
"/session",
|
|
789
778
|
{
|
|
@@ -801,7 +790,6 @@ var getSession = () => createAuthEndpoint(
|
|
|
801
790
|
status: 401
|
|
802
791
|
});
|
|
803
792
|
}
|
|
804
|
-
const key = getRequestUniqueKey(ctx, sessionCookieToken);
|
|
805
793
|
const session = await ctx.context.internalAdapter.findSession(sessionCookieToken);
|
|
806
794
|
if (!session || session.session.expiresAt < /* @__PURE__ */ new Date()) {
|
|
807
795
|
deleteSessionCookie(ctx);
|
package/dist/client/plugins.d.ts
CHANGED
|
@@ -2,14 +2,14 @@ import * as nanostores from 'nanostores';
|
|
|
2
2
|
import { A as AccessControl, S as StatementsPrimitive, R as Role } from '../statement-CfnyN34h.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, f as Organization, M as Member, I as Invitation, u as username, m as magicLink, d as phoneNumber, e as anonymous } from '../index-
|
|
6
|
-
export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-
|
|
5
|
+
import { o as organization, f as Organization, M as Member, I as Invitation, u as username, m as magicLink, d as phoneNumber, e as anonymous } from '../index-B-Rb8u6d.js';
|
|
6
|
+
export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-B-Rb8u6d.js';
|
|
7
7
|
import { P as Prettify } from '../helper-DPDj8Nix.js';
|
|
8
8
|
import '../index-JM-i6hLs.js';
|
|
9
9
|
import 'arctic';
|
|
10
10
|
import 'zod';
|
|
11
11
|
import 'better-call';
|
|
12
|
-
import '../index-
|
|
12
|
+
import '../index-BRcc7HbO.js';
|
|
13
13
|
import 'kysely';
|
|
14
14
|
import 'better-sqlite3';
|
|
15
15
|
import 'mysql2';
|
package/dist/client.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { BetterFetch, BetterFetchError, BetterFetchOption } from '@better-fetch/
|
|
|
6
6
|
import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from './helper-DPDj8Nix.js';
|
|
7
7
|
import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, InferSessionFromClient, InferUserFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
|
|
8
8
|
export { AtomListener, InferPluginsFromClient } from './types.js';
|
|
9
|
-
import './index-
|
|
9
|
+
import './index-BRcc7HbO.js';
|
|
10
10
|
import 'kysely';
|
|
11
11
|
import './index-JM-i6hLs.js';
|
|
12
12
|
import 'arctic';
|
|
@@ -5,7 +5,7 @@ import { P as Prettify } from './helper-DPDj8Nix.js';
|
|
|
5
5
|
import { A as AccessControl, R as Role, S as StatementsPrimitive, g as defaultRoles } from './statement-CfnyN34h.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-
|
|
8
|
+
import { H as HookEndpointContext } from './index-BRcc7HbO.js';
|
|
9
9
|
import * as nanostores from 'nanostores';
|
|
10
10
|
import { atom } from 'nanostores';
|
|
11
11
|
import * as _simplewebauthn_types from '@simplewebauthn/types';
|
|
@@ -5590,4 +5590,4 @@ type Auth = {
|
|
|
5590
5590
|
options: BetterAuthOptions;
|
|
5591
5591
|
};
|
|
5592
5592
|
|
|
5593
|
-
export { type Adapter as A, type BetterAuthOptions as B, resetPassword as C, createEmailVerificationToken as D, sendVerificationEmail as E, type FieldAttribute as F, type GenericEndpointContext as G, type HookEndpointContext as H, type InferFieldOutput as I, verifyEmail as J, updateUser as K, changePassword as L, setPassword as M, deleteUser as N, getCSRFToken as O, type PluginSchema as P, error as Q, type RateLimit as R, type SessionAdapter as S, ok as T, signUpEmail as U, csrfMiddleware as V, type Where as W, betterAuth as X, type Auth as a, type
|
|
5593
|
+
export { type Adapter as A, type BetterAuthOptions as B, resetPassword as C, createEmailVerificationToken as D, sendVerificationEmail as E, type FieldAttribute as F, type GenericEndpointContext as G, type HookEndpointContext as H, type InferFieldOutput as I, verifyEmail as J, updateUser as K, changePassword as L, setPassword as M, deleteUser as N, getCSRFToken as O, type PluginSchema as P, error as Q, type RateLimit as R, type SessionAdapter as S, ok as T, signUpEmail as U, csrfMiddleware as V, type Where as W, betterAuth as X, type Auth as a, type AuthContext as b, type BetterAuthPlugin as c, createAuthMiddleware as d, createAuthEndpoint as e, type AuthEndpoint as f, type AuthMiddleware as g, type InferUser as h, type InferSession as i, type InferPluginTypes as j, init as k, getEndpoints as l, signInEmail as m, callbackOAuth as n, optionsMiddleware as o, getSession as p, getSessionFromCtx as q, router as r, signInOAuth as s, sessionMiddleware as t, listSessions as u, revokeSession as v, revokeSessions as w, signOut as x, forgetPassword as y, forgetPasswordCallback as z };
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -863,17 +863,6 @@ function getIp(req) {
|
|
|
863
863
|
}
|
|
864
864
|
|
|
865
865
|
// src/api/routes/session.ts
|
|
866
|
-
function getRequestUniqueKey(ctx, token) {
|
|
867
|
-
if (!ctx.request) {
|
|
868
|
-
return "";
|
|
869
|
-
}
|
|
870
|
-
const { method, url, headers } = ctx.request;
|
|
871
|
-
const userAgent = ctx.request.headers.get("User-Agent") || "";
|
|
872
|
-
const ip = getIp(ctx.request) || "";
|
|
873
|
-
const headerString = JSON.stringify(headers);
|
|
874
|
-
const uniqueString = `${method}:${url}:${headerString}:${userAgent}:${ip}:${token}`;
|
|
875
|
-
return uniqueString;
|
|
876
|
-
}
|
|
877
866
|
var getSession = () => createAuthEndpoint(
|
|
878
867
|
"/session",
|
|
879
868
|
{
|
|
@@ -891,7 +880,6 @@ var getSession = () => createAuthEndpoint(
|
|
|
891
880
|
status: 401
|
|
892
881
|
});
|
|
893
882
|
}
|
|
894
|
-
const key = getRequestUniqueKey(ctx, sessionCookieToken);
|
|
895
883
|
const session = await ctx.context.internalAdapter.findSession(sessionCookieToken);
|
|
896
884
|
if (!session || session.session.expiresAt < /* @__PURE__ */ new Date()) {
|
|
897
885
|
deleteSessionCookie(ctx);
|
package/dist/next-js.d.ts
CHANGED
package/dist/node.d.ts
CHANGED
package/dist/plugins.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { O as OrganizationOptions, b as Passkey, P as PasskeyOptions, e as anonymous, g as getPasskeyActions, m as magicLink, o as organization, p as passkey, c as passkeyClient, d as phoneNumber, t as twoFactor, a as twoFactorClient, u as username } from './index-
|
|
1
|
+
export { O as OrganizationOptions, b as Passkey, P as PasskeyOptions, e as anonymous, g as getPasskeyActions, m as magicLink, o as organization, p as passkey, c as passkeyClient, d as phoneNumber, t as twoFactor, a as twoFactorClient, u as username } from './index-B-Rb8u6d.js';
|
|
2
2
|
export { i as ac } from './index-DfAHOgpj.js';
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
3
|
+
import { b as AuthContext } from './index-BRcc7HbO.js';
|
|
4
|
+
export { f as AuthEndpoint, g as AuthMiddleware, c as BetterAuthPlugin, P as PluginSchema, e as createAuthEndpoint, d as createAuthMiddleware, o as optionsMiddleware } from './index-BRcc7HbO.js';
|
|
5
5
|
import './index-JM-i6hLs.js';
|
|
6
6
|
import 'arctic';
|
|
7
7
|
import 'zod';
|
|
@@ -20,12 +20,9 @@ import 'mysql2';
|
|
|
20
20
|
*/
|
|
21
21
|
declare const bearer: () => {
|
|
22
22
|
id: "bearer";
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
handler: (ctx: HookEndpointContext) => Promise<void>;
|
|
27
|
-
}[];
|
|
28
|
-
};
|
|
23
|
+
onRequest(request: Request, ctx: AuthContext): Promise<{
|
|
24
|
+
request: Request;
|
|
25
|
+
} | undefined>;
|
|
29
26
|
};
|
|
30
27
|
|
|
31
28
|
declare const HIDE_METADATA: {
|
package/dist/plugins.js
CHANGED
|
@@ -682,46 +682,6 @@ function deleteSessionCookie(ctx) {
|
|
|
682
682
|
|
|
683
683
|
// src/api/routes/session.ts
|
|
684
684
|
import { z as z2 } from "zod";
|
|
685
|
-
|
|
686
|
-
// src/utils/get-request-ip.ts
|
|
687
|
-
function getIp(req) {
|
|
688
|
-
const testIP = "127.0.0.1";
|
|
689
|
-
if (process.env.NODE_ENV === "test") {
|
|
690
|
-
return testIP;
|
|
691
|
-
}
|
|
692
|
-
const headers = [
|
|
693
|
-
"x-client-ip",
|
|
694
|
-
"x-forwarded-for",
|
|
695
|
-
"cf-connecting-ip",
|
|
696
|
-
"fastly-client-ip",
|
|
697
|
-
"x-real-ip",
|
|
698
|
-
"x-cluster-client-ip",
|
|
699
|
-
"x-forwarded",
|
|
700
|
-
"forwarded-for",
|
|
701
|
-
"forwarded"
|
|
702
|
-
];
|
|
703
|
-
for (const header of headers) {
|
|
704
|
-
const value = req.headers.get(header);
|
|
705
|
-
if (typeof value === "string") {
|
|
706
|
-
const ip = value.split(",")[0].trim();
|
|
707
|
-
if (ip) return ip;
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
return null;
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
// src/api/routes/session.ts
|
|
714
|
-
function getRequestUniqueKey(ctx, token) {
|
|
715
|
-
if (!ctx.request) {
|
|
716
|
-
return "";
|
|
717
|
-
}
|
|
718
|
-
const { method, url, headers } = ctx.request;
|
|
719
|
-
const userAgent = ctx.request.headers.get("User-Agent") || "";
|
|
720
|
-
const ip = getIp(ctx.request) || "";
|
|
721
|
-
const headerString = JSON.stringify(headers);
|
|
722
|
-
const uniqueString = `${method}:${url}:${headerString}:${userAgent}:${ip}:${token}`;
|
|
723
|
-
return uniqueString;
|
|
724
|
-
}
|
|
725
685
|
var getSession = () => createAuthEndpoint(
|
|
726
686
|
"/session",
|
|
727
687
|
{
|
|
@@ -739,7 +699,6 @@ var getSession = () => createAuthEndpoint(
|
|
|
739
699
|
status: 401
|
|
740
700
|
});
|
|
741
701
|
}
|
|
742
|
-
const key = getRequestUniqueKey(ctx, sessionCookieToken);
|
|
743
702
|
const session = await ctx.context.internalAdapter.findSession(sessionCookieToken);
|
|
744
703
|
if (!session || session.session.expiresAt < /* @__PURE__ */ new Date()) {
|
|
745
704
|
deleteSessionCookie(ctx);
|
|
@@ -5614,30 +5573,23 @@ import { serializeSigned } from "better-call";
|
|
|
5614
5573
|
var bearer = () => {
|
|
5615
5574
|
return {
|
|
5616
5575
|
id: "bearer",
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
headers.set(
|
|
5635
|
-
"cookie",
|
|
5636
|
-
`${ctx.context.authCookies.sessionToken.name}=${signedToken.replace("=", "")}`
|
|
5637
|
-
);
|
|
5638
|
-
}
|
|
5639
|
-
}
|
|
5640
|
-
]
|
|
5576
|
+
async onRequest(request, ctx) {
|
|
5577
|
+
const token = request.headers.get("authorization")?.replace("Bearer ", "");
|
|
5578
|
+
if (!token) {
|
|
5579
|
+
return;
|
|
5580
|
+
}
|
|
5581
|
+
const headers = request.headers || new Headers();
|
|
5582
|
+
const signedToken = await serializeSigned("", token, ctx.secret);
|
|
5583
|
+
headers.set(
|
|
5584
|
+
"cookie",
|
|
5585
|
+
`${ctx.authCookies.sessionToken.name}=${signedToken.replace("=", "")}`
|
|
5586
|
+
);
|
|
5587
|
+
return {
|
|
5588
|
+
request: new Request(request.url, {
|
|
5589
|
+
method: request.method,
|
|
5590
|
+
headers
|
|
5591
|
+
})
|
|
5592
|
+
};
|
|
5641
5593
|
}
|
|
5642
5594
|
};
|
|
5643
5595
|
};
|
package/dist/react.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from
|
|
|
3
3
|
import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
|
|
4
4
|
import { useStore } from '@nanostores/react';
|
|
5
5
|
import 'zod';
|
|
6
|
-
import './index-
|
|
6
|
+
import './index-BRcc7HbO.js';
|
|
7
7
|
import 'kysely';
|
|
8
8
|
import './index-JM-i6hLs.js';
|
|
9
9
|
import 'arctic';
|
package/dist/solid-start.d.ts
CHANGED
package/dist/solid.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from
|
|
|
3
3
|
import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
|
|
4
4
|
import { Accessor } from 'solid-js';
|
|
5
5
|
import 'zod';
|
|
6
|
-
import './index-
|
|
6
|
+
import './index-BRcc7HbO.js';
|
|
7
7
|
import 'kysely';
|
|
8
8
|
import './index-JM-i6hLs.js';
|
|
9
9
|
import 'arctic';
|
package/dist/svelte-kit.d.ts
CHANGED
package/dist/svelte.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
|
3
3
|
import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from './helper-DPDj8Nix.js';
|
|
4
4
|
import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
|
|
5
5
|
import 'zod';
|
|
6
|
-
import './index-
|
|
6
|
+
import './index-BRcc7HbO.js';
|
|
7
7
|
import 'kysely';
|
|
8
8
|
import './index-JM-i6hLs.js';
|
|
9
9
|
import 'arctic';
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as Adapter,
|
|
1
|
+
import { c as BetterAuthPlugin, a as Auth, F as FieldAttribute, I as InferFieldOutput } from './index-BRcc7HbO.js';
|
|
2
|
+
export { A as Adapter, b as AuthContext, B as BetterAuthOptions, G as GenericEndpointContext, H as HookEndpointContext, j as InferPluginTypes, i as InferSession, h as InferUser, P as PluginSchema, R as RateLimit, S as SessionAdapter, W as Where, k as init } from './index-BRcc7HbO.js';
|
|
3
3
|
import { U as UnionToIntersection, H as HasRequiredKeys, P as Prettify, S as StripEmptyObjects, L as LiteralString } from './helper-DPDj8Nix.js';
|
|
4
4
|
export { D as DeepPartial, a as LiteralUnion, R as RequiredKeysOf, W as WithoutEmpty } from './helper-DPDj8Nix.js';
|
|
5
5
|
import { S as Session, U as User } from './index-JM-i6hLs.js';
|
package/dist/vue.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { U as UnionToIntersection, P as Prettify, S as StripEmptyObjects } from
|
|
|
3
3
|
import { ClientOptions, InferClientAPI, InferActions, InferAdditionalFromClient, BetterAuthClientPlugin, IsSignal } from './types.js';
|
|
4
4
|
import { Ref, DeepReadonly } from 'vue';
|
|
5
5
|
import 'zod';
|
|
6
|
-
import './index-
|
|
6
|
+
import './index-BRcc7HbO.js';
|
|
7
7
|
import 'kysely';
|
|
8
8
|
import './index-JM-i6hLs.js';
|
|
9
9
|
import 'arctic';
|