@convex-dev/better-auth 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +44 -0
- package/dist/commonjs/client/adapter.d.ts +4 -0
- package/dist/commonjs/client/adapter.d.ts.map +1 -0
- package/dist/commonjs/client/adapter.js +189 -0
- package/dist/commonjs/client/adapter.js.map +1 -0
- package/dist/commonjs/client/cors.d.ts +72 -0
- package/dist/commonjs/client/cors.d.ts.map +1 -0
- package/dist/commonjs/client/cors.js +281 -0
- package/dist/commonjs/client/cors.js.map +1 -0
- package/dist/commonjs/client/index.d.ts +302 -0
- package/dist/commonjs/client/index.d.ts.map +1 -0
- package/dist/commonjs/client/index.js +232 -0
- package/dist/commonjs/client/index.js.map +1 -0
- package/dist/commonjs/client/plugins/index.d.ts +3 -0
- package/dist/commonjs/client/plugins/index.d.ts.map +1 -0
- package/dist/commonjs/client/plugins/index.js +3 -0
- package/dist/commonjs/client/plugins/index.js.map +1 -0
- package/dist/commonjs/component/_generated/api.d.ts +12 -0
- package/dist/commonjs/component/_generated/api.d.ts.map +1 -0
- package/dist/commonjs/component/_generated/api.js +22 -0
- package/dist/commonjs/component/_generated/api.js.map +1 -0
- package/dist/commonjs/component/_generated/server.d.ts +64 -0
- package/dist/commonjs/component/_generated/server.d.ts.map +1 -0
- package/dist/commonjs/component/_generated/server.js +74 -0
- package/dist/commonjs/component/_generated/server.js.map +1 -0
- package/dist/commonjs/component/convex.config.d.ts +3 -0
- package/dist/commonjs/component/convex.config.d.ts.map +1 -0
- package/dist/commonjs/component/convex.config.js +4 -0
- package/dist/commonjs/component/convex.config.js.map +1 -0
- package/dist/commonjs/component/lib.d.ts +584 -0
- package/dist/commonjs/component/lib.d.ts.map +1 -0
- package/dist/commonjs/component/lib.js +323 -0
- package/dist/commonjs/component/lib.js.map +1 -0
- package/dist/commonjs/component/schema.d.ts +116 -0
- package/dist/commonjs/component/schema.d.ts.map +1 -0
- package/dist/commonjs/component/schema.js +68 -0
- package/dist/commonjs/component/schema.js.map +1 -0
- package/dist/commonjs/component/util.d.ts +394 -0
- package/dist/commonjs/component/util.d.ts.map +1 -0
- package/dist/commonjs/component/util.js +4 -0
- package/dist/commonjs/component/util.js.map +1 -0
- package/dist/commonjs/nextjs/index.d.ts +10 -0
- package/dist/commonjs/nextjs/index.d.ts.map +1 -0
- package/dist/commonjs/nextjs/index.js +23 -0
- package/dist/commonjs/nextjs/index.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/plugins/convex/client.d.ts +6 -0
- package/dist/commonjs/plugins/convex/client.d.ts.map +1 -0
- package/dist/commonjs/plugins/convex/client.js +7 -0
- package/dist/commonjs/plugins/convex/client.js.map +1 -0
- package/dist/commonjs/plugins/convex/index.d.ts +280 -0
- package/dist/commonjs/plugins/convex/index.d.ts.map +1 -0
- package/dist/commonjs/plugins/convex/index.js +253 -0
- package/dist/commonjs/plugins/convex/index.js.map +1 -0
- package/dist/commonjs/plugins/cross-domain/client.d.ts +123 -0
- package/dist/commonjs/plugins/cross-domain/client.d.ts.map +1 -0
- package/dist/commonjs/plugins/cross-domain/client.js +164 -0
- package/dist/commonjs/plugins/cross-domain/client.js.map +1 -0
- package/dist/commonjs/plugins/cross-domain/index.d.ts +81 -0
- package/dist/commonjs/plugins/cross-domain/index.d.ts.map +1 -0
- package/dist/commonjs/plugins/cross-domain/index.js +135 -0
- package/dist/commonjs/plugins/cross-domain/index.js.map +1 -0
- package/dist/commonjs/plugins/index.d.ts +3 -0
- package/dist/commonjs/plugins/index.d.ts.map +1 -0
- package/dist/commonjs/plugins/index.js +3 -0
- package/dist/commonjs/plugins/index.js.map +1 -0
- package/dist/commonjs/react/client.d.ts +31 -0
- package/dist/commonjs/react/client.d.ts.map +1 -0
- package/dist/commonjs/react/client.js +102 -0
- package/dist/commonjs/react/client.js.map +1 -0
- package/dist/commonjs/react/index.d.ts +9 -0
- package/dist/commonjs/react/index.d.ts.map +1 -0
- package/dist/commonjs/react/index.js +15 -0
- package/dist/commonjs/react/index.js.map +1 -0
- package/dist/commonjs/react-start/index.d.ts +10 -0
- package/dist/commonjs/react-start/index.d.ts.map +1 -0
- package/dist/commonjs/react-start/index.js +32 -0
- package/dist/commonjs/react-start/index.js.map +1 -0
- package/dist/esm/client/adapter.d.ts +4 -0
- package/dist/esm/client/adapter.d.ts.map +1 -0
- package/dist/esm/client/adapter.js +189 -0
- package/dist/esm/client/adapter.js.map +1 -0
- package/dist/esm/client/cors.d.ts +72 -0
- package/dist/esm/client/cors.d.ts.map +1 -0
- package/dist/esm/client/cors.js +281 -0
- package/dist/esm/client/cors.js.map +1 -0
- package/dist/esm/client/index.d.ts +302 -0
- package/dist/esm/client/index.d.ts.map +1 -0
- package/dist/esm/client/index.js +232 -0
- package/dist/esm/client/index.js.map +1 -0
- package/dist/esm/client/plugins/index.d.ts +3 -0
- package/dist/esm/client/plugins/index.d.ts.map +1 -0
- package/dist/esm/client/plugins/index.js +3 -0
- package/dist/esm/client/plugins/index.js.map +1 -0
- package/dist/esm/component/_generated/api.d.ts +12 -0
- package/dist/esm/component/_generated/api.d.ts.map +1 -0
- package/dist/esm/component/_generated/api.js +22 -0
- package/dist/esm/component/_generated/api.js.map +1 -0
- package/dist/esm/component/_generated/server.d.ts +64 -0
- package/dist/esm/component/_generated/server.d.ts.map +1 -0
- package/dist/esm/component/_generated/server.js +74 -0
- package/dist/esm/component/_generated/server.js.map +1 -0
- package/dist/esm/component/convex.config.d.ts +3 -0
- package/dist/esm/component/convex.config.d.ts.map +1 -0
- package/dist/esm/component/convex.config.js +4 -0
- package/dist/esm/component/convex.config.js.map +1 -0
- package/dist/esm/component/lib.d.ts +584 -0
- package/dist/esm/component/lib.d.ts.map +1 -0
- package/dist/esm/component/lib.js +323 -0
- package/dist/esm/component/lib.js.map +1 -0
- package/dist/esm/component/schema.d.ts +116 -0
- package/dist/esm/component/schema.d.ts.map +1 -0
- package/dist/esm/component/schema.js +68 -0
- package/dist/esm/component/schema.js.map +1 -0
- package/dist/esm/component/util.d.ts +394 -0
- package/dist/esm/component/util.d.ts.map +1 -0
- package/dist/esm/component/util.js +4 -0
- package/dist/esm/component/util.js.map +1 -0
- package/dist/esm/nextjs/index.d.ts +10 -0
- package/dist/esm/nextjs/index.d.ts.map +1 -0
- package/dist/esm/nextjs/index.js +23 -0
- package/dist/esm/nextjs/index.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/plugins/convex/client.d.ts +6 -0
- package/dist/esm/plugins/convex/client.d.ts.map +1 -0
- package/dist/esm/plugins/convex/client.js +7 -0
- package/dist/esm/plugins/convex/client.js.map +1 -0
- package/dist/esm/plugins/convex/index.d.ts +280 -0
- package/dist/esm/plugins/convex/index.d.ts.map +1 -0
- package/dist/esm/plugins/convex/index.js +253 -0
- package/dist/esm/plugins/convex/index.js.map +1 -0
- package/dist/esm/plugins/cross-domain/client.d.ts +123 -0
- package/dist/esm/plugins/cross-domain/client.d.ts.map +1 -0
- package/dist/esm/plugins/cross-domain/client.js +164 -0
- package/dist/esm/plugins/cross-domain/client.js.map +1 -0
- package/dist/esm/plugins/cross-domain/index.d.ts +81 -0
- package/dist/esm/plugins/cross-domain/index.d.ts.map +1 -0
- package/dist/esm/plugins/cross-domain/index.js +135 -0
- package/dist/esm/plugins/cross-domain/index.js.map +1 -0
- package/dist/esm/plugins/index.d.ts +3 -0
- package/dist/esm/plugins/index.d.ts.map +1 -0
- package/dist/esm/plugins/index.js +3 -0
- package/dist/esm/plugins/index.js.map +1 -0
- package/dist/esm/react/client.d.ts +31 -0
- package/dist/esm/react/client.d.ts.map +1 -0
- package/dist/esm/react/client.js +102 -0
- package/dist/esm/react/client.js.map +1 -0
- package/dist/esm/react/index.d.ts +9 -0
- package/dist/esm/react/index.d.ts.map +1 -0
- package/dist/esm/react/index.js +15 -0
- package/dist/esm/react/index.js.map +1 -0
- package/dist/esm/react-start/index.d.ts +10 -0
- package/dist/esm/react-start/index.d.ts.map +1 -0
- package/dist/esm/react-start/index.js +32 -0
- package/dist/esm/react-start/index.js.map +1 -0
- package/package.json +161 -0
- package/plugins/package.json +5 -0
- package/react/package.json +5 -0
- package/src/client/adapter.ts +236 -0
- package/src/client/cors.ts +403 -0
- package/src/client/index.ts +381 -0
- package/src/client/plugins/index.ts +2 -0
- package/src/component/_generated/api.d.ts +313 -0
- package/src/component/_generated/api.js +23 -0
- package/src/component/_generated/dataModel.d.ts +60 -0
- package/src/component/_generated/server.d.ts +149 -0
- package/src/component/_generated/server.js +90 -0
- package/src/component/convex.config.ts +5 -0
- package/src/component/lib.ts +391 -0
- package/src/component/schema.ts +74 -0
- package/src/component/util.ts +4 -0
- package/src/nextjs/index.ts +30 -0
- package/src/plugins/convex/client.ts +9 -0
- package/src/plugins/convex/index.ts +296 -0
- package/src/plugins/cross-domain/client.ts +209 -0
- package/src/plugins/cross-domain/index.ts +156 -0
- package/src/plugins/index.ts +2 -0
- package/src/react/client.tsx +184 -0
- package/src/react/index.tsx +38 -0
- package/src/react-start/index.ts +51 -0
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { type Auth as ConvexAuth, type DefaultFunctionArgs, type Expand, type FunctionReference, GenericActionCtx, type GenericDataModel, GenericMutationCtx, type GenericQueryCtx, type HttpRouter } from "convex/server";
|
|
2
|
+
import { type GenericId, Infer } from "convex/values";
|
|
3
|
+
import type { api } from "../component/_generated/api.js";
|
|
4
|
+
import schema from "../component/schema.js";
|
|
5
|
+
import { convexAdapter } from "./adapter.js";
|
|
6
|
+
import { betterAuth } from "better-auth";
|
|
7
|
+
export { convexAdapter };
|
|
8
|
+
declare const createUserValidator: import("convex/values").VObject<{
|
|
9
|
+
image?: string | undefined;
|
|
10
|
+
twoFactorEnabled?: boolean | undefined;
|
|
11
|
+
name: string;
|
|
12
|
+
email: string;
|
|
13
|
+
emailVerified: boolean;
|
|
14
|
+
createdAt: number;
|
|
15
|
+
updatedAt: number;
|
|
16
|
+
}, {
|
|
17
|
+
name: import("convex/values").VString<string, "required">;
|
|
18
|
+
email: import("convex/values").VString<string, "required">;
|
|
19
|
+
emailVerified: import("convex/values").VBoolean<boolean, "required">;
|
|
20
|
+
image: import("convex/values").VString<string | undefined, "optional">;
|
|
21
|
+
twoFactorEnabled: import("convex/values").VBoolean<boolean | undefined, "optional">;
|
|
22
|
+
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
23
|
+
updatedAt: import("convex/values").VFloat64<number, "required">;
|
|
24
|
+
}, "required", "name" | "email" | "emailVerified" | "image" | "twoFactorEnabled" | "createdAt" | "updatedAt">;
|
|
25
|
+
declare const createUserArgsValidator: import("convex/values").VObject<{
|
|
26
|
+
input: {
|
|
27
|
+
image?: string | undefined;
|
|
28
|
+
twoFactorEnabled?: boolean | undefined;
|
|
29
|
+
name: string;
|
|
30
|
+
email: string;
|
|
31
|
+
emailVerified: boolean;
|
|
32
|
+
createdAt: number;
|
|
33
|
+
updatedAt: number;
|
|
34
|
+
table: "user";
|
|
35
|
+
};
|
|
36
|
+
}, {
|
|
37
|
+
input: import("convex/values").VObject<{
|
|
38
|
+
image?: string | undefined;
|
|
39
|
+
twoFactorEnabled?: boolean | undefined;
|
|
40
|
+
name: string;
|
|
41
|
+
email: string;
|
|
42
|
+
emailVerified: boolean;
|
|
43
|
+
createdAt: number;
|
|
44
|
+
updatedAt: number;
|
|
45
|
+
table: "user";
|
|
46
|
+
}, {
|
|
47
|
+
table: import("convex/values").VLiteral<"user", "required">;
|
|
48
|
+
name: import("convex/values").VString<string, "required">;
|
|
49
|
+
email: import("convex/values").VString<string, "required">;
|
|
50
|
+
emailVerified: import("convex/values").VBoolean<boolean, "required">;
|
|
51
|
+
image: import("convex/values").VString<string | undefined, "optional">;
|
|
52
|
+
twoFactorEnabled: import("convex/values").VBoolean<boolean | undefined, "optional">;
|
|
53
|
+
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
54
|
+
updatedAt: import("convex/values").VFloat64<number, "required">;
|
|
55
|
+
}, "required", "name" | "email" | "emailVerified" | "image" | "twoFactorEnabled" | "createdAt" | "updatedAt" | "table">;
|
|
56
|
+
}, "required", "input" | "input.table" | "input.name" | "input.email" | "input.emailVerified" | "input.image" | "input.twoFactorEnabled" | "input.createdAt" | "input.updatedAt">;
|
|
57
|
+
declare const updateUserArgsValidator: import("convex/values").VObject<{
|
|
58
|
+
input: {
|
|
59
|
+
value: Record<string, any>;
|
|
60
|
+
table: "user";
|
|
61
|
+
where: {
|
|
62
|
+
value: string | number | boolean | number[] | string[] | null;
|
|
63
|
+
field: string;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
}, {
|
|
67
|
+
input: import("convex/values").VObject<{
|
|
68
|
+
value: Record<string, any>;
|
|
69
|
+
table: "user";
|
|
70
|
+
where: {
|
|
71
|
+
value: string | number | boolean | number[] | string[] | null;
|
|
72
|
+
field: string;
|
|
73
|
+
};
|
|
74
|
+
}, {
|
|
75
|
+
table: import("convex/values").VLiteral<"user", "required">;
|
|
76
|
+
where: import("convex/values").VObject<{
|
|
77
|
+
value: string | number | boolean | number[] | string[] | null;
|
|
78
|
+
field: string;
|
|
79
|
+
}, {
|
|
80
|
+
field: import("convex/values").VString<string, "required">;
|
|
81
|
+
value: import("convex/values").VUnion<string | number | boolean | number[] | string[] | null, [import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">, import("convex/values").VBoolean<boolean, "required">, import("convex/values").VArray<string[], import("convex/values").VString<string, "required">, "required">, import("convex/values").VArray<number[], import("convex/values").VFloat64<number, "required">, "required">, import("convex/values").VNull<null, "required">], "required", never>;
|
|
82
|
+
}, "required", "value" | "field">;
|
|
83
|
+
value: import("convex/values").VRecord<Record<string, any>, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "required", string>;
|
|
84
|
+
}, "required", "value" | "table" | "where" | `value.${string}` | "where.value" | "where.field">;
|
|
85
|
+
}, "required", "input" | "input.table" | "input.value" | "input.where" | `input.value.${string}` | "input.where.value" | "input.where.field">;
|
|
86
|
+
declare const deleteUserArgsValidator: import("convex/values").VObject<{
|
|
87
|
+
unique?: boolean | undefined;
|
|
88
|
+
value: string | number | boolean | number[] | string[] | null;
|
|
89
|
+
table: string;
|
|
90
|
+
field: string;
|
|
91
|
+
}, {
|
|
92
|
+
table: import("convex/values").VString<string, "required">;
|
|
93
|
+
field: import("convex/values").VString<string, "required">;
|
|
94
|
+
unique: import("convex/values").VBoolean<boolean | undefined, "optional">;
|
|
95
|
+
value: import("convex/values").VUnion<string | number | boolean | number[] | string[] | null, [import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">, import("convex/values").VBoolean<boolean, "required">, import("convex/values").VArray<string[], import("convex/values").VString<string, "required">, "required">, import("convex/values").VArray<number[], import("convex/values").VFloat64<number, "required">, "required">, import("convex/values").VNull<null, "required">], "required", never>;
|
|
96
|
+
}, "required", "value" | "table" | "field" | "unique">;
|
|
97
|
+
declare const createSessionArgsValidator: import("convex/values").VObject<{
|
|
98
|
+
input: {
|
|
99
|
+
ipAddress?: string | undefined;
|
|
100
|
+
userAgent?: string | undefined;
|
|
101
|
+
userId: string;
|
|
102
|
+
createdAt: number;
|
|
103
|
+
updatedAt: number;
|
|
104
|
+
expiresAt: number;
|
|
105
|
+
token: string;
|
|
106
|
+
table: "session";
|
|
107
|
+
};
|
|
108
|
+
}, {
|
|
109
|
+
input: import("convex/values").VObject<{
|
|
110
|
+
ipAddress?: string | undefined;
|
|
111
|
+
userAgent?: string | undefined;
|
|
112
|
+
userId: string;
|
|
113
|
+
createdAt: number;
|
|
114
|
+
updatedAt: number;
|
|
115
|
+
expiresAt: number;
|
|
116
|
+
token: string;
|
|
117
|
+
table: "session";
|
|
118
|
+
}, {
|
|
119
|
+
expiresAt: import("convex/values").VFloat64<number, "required">;
|
|
120
|
+
token: import("convex/values").VString<string, "required">;
|
|
121
|
+
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
122
|
+
updatedAt: import("convex/values").VFloat64<number, "required">;
|
|
123
|
+
ipAddress: import("convex/values").VString<string | undefined, "optional">;
|
|
124
|
+
userAgent: import("convex/values").VString<string | undefined, "optional">;
|
|
125
|
+
userId: import("convex/values").VString<string, "required">;
|
|
126
|
+
table: import("convex/values").VLiteral<"session", "required">;
|
|
127
|
+
}, "required", "userId" | "createdAt" | "updatedAt" | "expiresAt" | "token" | "ipAddress" | "userAgent" | "table">;
|
|
128
|
+
}, "required", "input" | "input.table" | "input.createdAt" | "input.updatedAt" | "input.userId" | "input.expiresAt" | "input.token" | "input.ipAddress" | "input.userAgent">;
|
|
129
|
+
export type EventFunction<T extends DefaultFunctionArgs> = FunctionReference<"mutation", "internal" | "public", T>;
|
|
130
|
+
export type AuthFunctions = {
|
|
131
|
+
createUser: FunctionReference<"mutation", "internal", Infer<typeof createUserArgsValidator>>;
|
|
132
|
+
deleteUser: FunctionReference<"mutation", "internal", Infer<typeof deleteUserArgsValidator>>;
|
|
133
|
+
updateUser: FunctionReference<"mutation", "internal", Infer<typeof updateUserArgsValidator>>;
|
|
134
|
+
createSession: FunctionReference<"mutation", "internal", Infer<typeof createSessionArgsValidator>>;
|
|
135
|
+
};
|
|
136
|
+
export type PublicAuthFunctions = {
|
|
137
|
+
isAuthenticated: FunctionReference<"query", "public">;
|
|
138
|
+
};
|
|
139
|
+
export declare class BetterAuth<UserId extends string = string> {
|
|
140
|
+
component: UseApi<typeof api>;
|
|
141
|
+
config: {
|
|
142
|
+
authFunctions: AuthFunctions;
|
|
143
|
+
publicAuthFunctions?: PublicAuthFunctions;
|
|
144
|
+
verbose?: boolean;
|
|
145
|
+
};
|
|
146
|
+
constructor(component: UseApi<typeof api>, config: {
|
|
147
|
+
authFunctions: AuthFunctions;
|
|
148
|
+
publicAuthFunctions?: PublicAuthFunctions;
|
|
149
|
+
verbose?: boolean;
|
|
150
|
+
});
|
|
151
|
+
isAuthenticated(token?: string | null): Promise<any>;
|
|
152
|
+
getHeaders(ctx: RunQueryCtx & {
|
|
153
|
+
auth: ConvexAuth;
|
|
154
|
+
}): Promise<Headers>;
|
|
155
|
+
getAuthUserId(ctx: RunQueryCtx & {
|
|
156
|
+
auth: ConvexAuth;
|
|
157
|
+
}): Promise<UserId | null>;
|
|
158
|
+
getAuthUser(ctx: RunQueryCtx & {
|
|
159
|
+
auth: ConvexAuth;
|
|
160
|
+
}): Promise<{
|
|
161
|
+
image?: string | undefined;
|
|
162
|
+
twoFactorEnabled?: boolean | undefined;
|
|
163
|
+
name: string;
|
|
164
|
+
email: string;
|
|
165
|
+
emailVerified: boolean;
|
|
166
|
+
userId: string;
|
|
167
|
+
createdAt: number;
|
|
168
|
+
updatedAt: number;
|
|
169
|
+
} | null>;
|
|
170
|
+
getIdTokenCookieName(createAuth: (ctx: GenericActionCtx<any>) => ReturnType<typeof betterAuth>): Promise<string>;
|
|
171
|
+
createAuthFunctions<DataModel extends GenericDataModel>(opts: {
|
|
172
|
+
onCreateUser: (ctx: GenericMutationCtx<DataModel>, user: Infer<typeof createUserValidator>) => Promise<UserId>;
|
|
173
|
+
onDeleteUser?: (ctx: GenericMutationCtx<DataModel>, id: UserId) => void | Promise<void>;
|
|
174
|
+
onUpdateUser?: (ctx: GenericMutationCtx<DataModel>, user: Infer<typeof schema.tables.user.validator>) => void | Promise<void>;
|
|
175
|
+
onCreateSession?: (ctx: GenericMutationCtx<DataModel>, session: Infer<typeof schema.tables.session.validator>) => void | Promise<void>;
|
|
176
|
+
}): {
|
|
177
|
+
isAuthenticated: import("convex/server").RegisteredQuery<"public", {}, Promise<boolean>>;
|
|
178
|
+
createUser: import("convex/server").RegisteredMutation<"internal", {
|
|
179
|
+
input: {
|
|
180
|
+
image?: string | undefined;
|
|
181
|
+
twoFactorEnabled?: boolean | undefined;
|
|
182
|
+
name: string;
|
|
183
|
+
email: string;
|
|
184
|
+
emailVerified: boolean;
|
|
185
|
+
createdAt: number;
|
|
186
|
+
updatedAt: number;
|
|
187
|
+
table: "user";
|
|
188
|
+
};
|
|
189
|
+
}, Promise<{
|
|
190
|
+
image?: string | undefined;
|
|
191
|
+
twoFactorEnabled?: boolean | undefined;
|
|
192
|
+
name: string;
|
|
193
|
+
email: string;
|
|
194
|
+
emailVerified: boolean;
|
|
195
|
+
userId: string;
|
|
196
|
+
createdAt: number;
|
|
197
|
+
updatedAt: number;
|
|
198
|
+
id: string;
|
|
199
|
+
} | {
|
|
200
|
+
ipAddress?: string | undefined;
|
|
201
|
+
userAgent?: string | undefined;
|
|
202
|
+
userId: string;
|
|
203
|
+
createdAt: number;
|
|
204
|
+
updatedAt: number;
|
|
205
|
+
expiresAt: number;
|
|
206
|
+
token: string;
|
|
207
|
+
id: string;
|
|
208
|
+
} | {
|
|
209
|
+
accessToken?: string | undefined;
|
|
210
|
+
refreshToken?: string | undefined;
|
|
211
|
+
idToken?: string | undefined;
|
|
212
|
+
accessTokenExpiresAt?: number | undefined;
|
|
213
|
+
refreshTokenExpiresAt?: number | undefined;
|
|
214
|
+
scope?: string | undefined;
|
|
215
|
+
password?: string | undefined;
|
|
216
|
+
userId: string;
|
|
217
|
+
createdAt: number;
|
|
218
|
+
updatedAt: number;
|
|
219
|
+
accountId: string;
|
|
220
|
+
providerId: string;
|
|
221
|
+
id: string;
|
|
222
|
+
} | {
|
|
223
|
+
userId: string;
|
|
224
|
+
secret: string;
|
|
225
|
+
backupCodes: string;
|
|
226
|
+
id: string;
|
|
227
|
+
} | {
|
|
228
|
+
createdAt?: number | undefined;
|
|
229
|
+
updatedAt?: number | undefined;
|
|
230
|
+
expiresAt: number;
|
|
231
|
+
identifier: string;
|
|
232
|
+
value: string;
|
|
233
|
+
id: string;
|
|
234
|
+
} | {
|
|
235
|
+
id: string;
|
|
236
|
+
createdAt: number;
|
|
237
|
+
publicKey: string;
|
|
238
|
+
privateKey: string;
|
|
239
|
+
}>>;
|
|
240
|
+
deleteUser: import("convex/server").RegisteredMutation<"internal", {
|
|
241
|
+
unique?: boolean | undefined;
|
|
242
|
+
value: string | number | boolean | number[] | string[] | null;
|
|
243
|
+
table: string;
|
|
244
|
+
field: string;
|
|
245
|
+
}, Promise<void>>;
|
|
246
|
+
updateUser: import("convex/server").RegisteredMutation<"internal", {
|
|
247
|
+
input: {
|
|
248
|
+
value: Record<string, any>;
|
|
249
|
+
table: "user";
|
|
250
|
+
where: {
|
|
251
|
+
value: string | number | boolean | number[] | string[] | null;
|
|
252
|
+
field: string;
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
}, Promise<{
|
|
256
|
+
image?: string | undefined;
|
|
257
|
+
twoFactorEnabled?: boolean | undefined;
|
|
258
|
+
name: string;
|
|
259
|
+
email: string;
|
|
260
|
+
emailVerified: boolean;
|
|
261
|
+
userId: string;
|
|
262
|
+
createdAt: number;
|
|
263
|
+
updatedAt: number;
|
|
264
|
+
id: string;
|
|
265
|
+
}>>;
|
|
266
|
+
createSession: import("convex/server").RegisteredMutation<"internal", {
|
|
267
|
+
input: {
|
|
268
|
+
ipAddress?: string | undefined;
|
|
269
|
+
userAgent?: string | undefined;
|
|
270
|
+
userId: string;
|
|
271
|
+
createdAt: number;
|
|
272
|
+
updatedAt: number;
|
|
273
|
+
expiresAt: number;
|
|
274
|
+
token: string;
|
|
275
|
+
table: "session";
|
|
276
|
+
};
|
|
277
|
+
}, Promise<{
|
|
278
|
+
ipAddress?: string | undefined;
|
|
279
|
+
userAgent?: string | undefined;
|
|
280
|
+
userId: string;
|
|
281
|
+
createdAt: number;
|
|
282
|
+
updatedAt: number;
|
|
283
|
+
expiresAt: number;
|
|
284
|
+
token: string;
|
|
285
|
+
id: string;
|
|
286
|
+
}>>;
|
|
287
|
+
};
|
|
288
|
+
registerRoutes(http: HttpRouter, createAuth: (ctx: GenericActionCtx<any>) => ReturnType<typeof betterAuth>, opts?: {
|
|
289
|
+
path?: string;
|
|
290
|
+
allowedOrigins?: string[];
|
|
291
|
+
}): void;
|
|
292
|
+
}
|
|
293
|
+
type RunQueryCtx = {
|
|
294
|
+
runQuery: GenericQueryCtx<GenericDataModel>["runQuery"];
|
|
295
|
+
};
|
|
296
|
+
export type OpaqueIds<T> = T extends GenericId<infer _T> ? string : T extends (infer U)[] ? OpaqueIds<U>[] : T extends ArrayBuffer ? ArrayBuffer : T extends object ? {
|
|
297
|
+
[K in keyof T]: OpaqueIds<T[K]>;
|
|
298
|
+
} : T;
|
|
299
|
+
export type UseApi<API> = Expand<{
|
|
300
|
+
[mod in keyof API]: API[mod] extends FunctionReference<infer FType, "public", infer FArgs, infer FReturnType, infer FComponentPath> ? FunctionReference<FType, "internal", OpaqueIds<FArgs>, OpaqueIds<FReturnType>, FComponentPath> : UseApi<API[mod]>;
|
|
301
|
+
}>;
|
|
302
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,IAAI,UAAU,EACvB,KAAK,mBAAmB,EACxB,KAAK,MAAM,EACX,KAAK,iBAAiB,EACtB,gBAAgB,EAChB,KAAK,gBAAgB,EACrB,kBAAkB,EAClB,KAAK,eAAe,EACpB,KAAK,UAAU,EAIhB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,EAAK,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAG1C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIzC,OAAO,EAAE,aAAa,EAAE,CAAC;AAGzB,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;6GAA6B,CAAC;AACvD,QAAA,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iLAK3B,CAAC;AACH,QAAA,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;6IAE3B,CAAC;AACH,QAAA,MAAM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
|
2
|
+
import { v } from "convex/values";
|
|
3
|
+
import schema from "../component/schema.js";
|
|
4
|
+
import { convexAdapter } from "./adapter.js";
|
|
5
|
+
import corsRouter from "./cors.js";
|
|
6
|
+
import { getByArgsValidator, updateArgsInputValidator } from "../component/lib.js";
|
|
7
|
+
import { omit } from "convex-helpers";
|
|
8
|
+
import { createCookieGetter } from "better-auth/cookies";
|
|
9
|
+
import { fetchQuery } from "convex/nextjs";
|
|
10
|
+
export { convexAdapter };
|
|
11
|
+
const createUserFields = omit(schema.tables.user.validator.fields, ["userId"]);
|
|
12
|
+
const createUserValidator = v.object(createUserFields);
|
|
13
|
+
const createUserArgsValidator = v.object({
|
|
14
|
+
input: v.object({
|
|
15
|
+
...createUserFields,
|
|
16
|
+
table: v.literal("user"),
|
|
17
|
+
}),
|
|
18
|
+
});
|
|
19
|
+
const updateUserArgsValidator = v.object({
|
|
20
|
+
input: updateArgsInputValidator("user"),
|
|
21
|
+
});
|
|
22
|
+
const deleteUserArgsValidator = v.object(getByArgsValidator);
|
|
23
|
+
const createSessionArgsValidator = v.object({
|
|
24
|
+
input: v.object({
|
|
25
|
+
table: v.literal("session"),
|
|
26
|
+
...schema.tables.session.validator.fields,
|
|
27
|
+
}),
|
|
28
|
+
});
|
|
29
|
+
export class BetterAuth {
|
|
30
|
+
component;
|
|
31
|
+
config;
|
|
32
|
+
constructor(component, config) {
|
|
33
|
+
this.component = component;
|
|
34
|
+
this.config = config;
|
|
35
|
+
}
|
|
36
|
+
async isAuthenticated(token) {
|
|
37
|
+
if (!this.config.publicAuthFunctions?.isAuthenticated) {
|
|
38
|
+
throw new Error("isAuthenticated function not found. It must be a named export in convex/auth.ts");
|
|
39
|
+
}
|
|
40
|
+
return fetchQuery(this.config.publicAuthFunctions.isAuthenticated, {}, { token: token ?? undefined });
|
|
41
|
+
}
|
|
42
|
+
async getHeaders(ctx) {
|
|
43
|
+
const identity = await ctx.auth.getUserIdentity();
|
|
44
|
+
if (!identity) {
|
|
45
|
+
return new Headers();
|
|
46
|
+
}
|
|
47
|
+
const session = await ctx.runQuery(this.component.lib.getCurrentSession);
|
|
48
|
+
return new Headers({
|
|
49
|
+
authorization: `Bearer ${session?.token}`,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
// TODO: use the proper id type for auth functions
|
|
53
|
+
async getAuthUserId(ctx) {
|
|
54
|
+
const identity = await ctx.auth.getUserIdentity();
|
|
55
|
+
if (!identity) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
return identity.subject;
|
|
59
|
+
}
|
|
60
|
+
// Convenience function for getting the Better Auth user
|
|
61
|
+
async getAuthUser(ctx) {
|
|
62
|
+
const identity = await ctx.auth.getUserIdentity();
|
|
63
|
+
if (!identity) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
const doc = await ctx.runQuery(this.component.lib.getBy, {
|
|
67
|
+
table: "user",
|
|
68
|
+
field: "userId",
|
|
69
|
+
value: identity.subject,
|
|
70
|
+
});
|
|
71
|
+
if (!doc) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
// Type narrowing
|
|
75
|
+
if (!("emailVerified" in doc)) {
|
|
76
|
+
throw new Error("invalid user");
|
|
77
|
+
}
|
|
78
|
+
const { id: _id, ...user } = doc;
|
|
79
|
+
return user;
|
|
80
|
+
}
|
|
81
|
+
async getIdTokenCookieName(createAuth) {
|
|
82
|
+
const auth = createAuth({});
|
|
83
|
+
const createCookie = createCookieGetter(auth.options);
|
|
84
|
+
const cookie = createCookie("convex_jwt");
|
|
85
|
+
return cookie.name;
|
|
86
|
+
}
|
|
87
|
+
createAuthFunctions(opts) {
|
|
88
|
+
return {
|
|
89
|
+
isAuthenticated: queryGeneric({
|
|
90
|
+
args: v.object({}),
|
|
91
|
+
handler: async (ctx) => {
|
|
92
|
+
const identity = await ctx.auth.getUserIdentity();
|
|
93
|
+
return identity !== null;
|
|
94
|
+
},
|
|
95
|
+
}),
|
|
96
|
+
createUser: internalMutationGeneric({
|
|
97
|
+
args: createUserArgsValidator,
|
|
98
|
+
handler: async (ctx, args) => {
|
|
99
|
+
const userId = await opts.onCreateUser(ctx, args.input);
|
|
100
|
+
const input = { ...args.input, table: "user", userId };
|
|
101
|
+
return ctx.runMutation(this.component.lib.create, {
|
|
102
|
+
input,
|
|
103
|
+
});
|
|
104
|
+
},
|
|
105
|
+
}),
|
|
106
|
+
deleteUser: internalMutationGeneric({
|
|
107
|
+
args: deleteUserArgsValidator,
|
|
108
|
+
handler: async (ctx, args) => {
|
|
109
|
+
const doc = await ctx.runMutation(this.component.lib.deleteBy, args);
|
|
110
|
+
if (opts.onDeleteUser) {
|
|
111
|
+
await opts.onDeleteUser(ctx, doc.userId);
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
}),
|
|
115
|
+
updateUser: internalMutationGeneric({
|
|
116
|
+
args: updateUserArgsValidator,
|
|
117
|
+
handler: async (ctx, args) => {
|
|
118
|
+
const updatedUser = await ctx.runMutation(this.component.lib.update, args);
|
|
119
|
+
// Type narrowing
|
|
120
|
+
if (!("emailVerified" in updatedUser)) {
|
|
121
|
+
throw new Error("invalid user");
|
|
122
|
+
}
|
|
123
|
+
if (opts.onUpdateUser) {
|
|
124
|
+
await opts.onUpdateUser(ctx, omit(updatedUser, ["id"]));
|
|
125
|
+
}
|
|
126
|
+
return updatedUser;
|
|
127
|
+
},
|
|
128
|
+
}),
|
|
129
|
+
createSession: internalMutationGeneric({
|
|
130
|
+
args: createSessionArgsValidator,
|
|
131
|
+
handler: async (ctx, args) => {
|
|
132
|
+
const session = await ctx.runMutation(this.component.lib.create, args);
|
|
133
|
+
// Type narrowing
|
|
134
|
+
if (!("ipAddress" in session)) {
|
|
135
|
+
throw new Error("invalid session");
|
|
136
|
+
}
|
|
137
|
+
await opts.onCreateSession?.(ctx, session);
|
|
138
|
+
return session;
|
|
139
|
+
},
|
|
140
|
+
}),
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
registerRoutes(http, createAuth, opts) {
|
|
144
|
+
const path = opts?.path ?? "/api/auth";
|
|
145
|
+
const options = createAuth({}).options;
|
|
146
|
+
const trustedOriginsOption = Array.isArray(options.trustedOrigins)
|
|
147
|
+
? options.trustedOrigins
|
|
148
|
+
: [];
|
|
149
|
+
const trustedOrigins = createAuth({}).options.plugins?.reduce((acc, plugin) => {
|
|
150
|
+
if (plugin.options?.trustedOrigins) {
|
|
151
|
+
acc.push(...plugin.options.trustedOrigins);
|
|
152
|
+
}
|
|
153
|
+
return acc;
|
|
154
|
+
}, [...trustedOriginsOption, options.baseURL].filter(Boolean));
|
|
155
|
+
// Reuse trustedOrigins as default for allowedOrigins
|
|
156
|
+
const allowedOrigins = opts?.allowedOrigins ??
|
|
157
|
+
trustedOrigins?.map((origin) =>
|
|
158
|
+
// Strip trailing wildcards, unsupported for allowedOrigins
|
|
159
|
+
origin.endsWith("*") && origin.length > 1 ? origin.slice(0, -1) : origin);
|
|
160
|
+
const requireEnv = (name) => {
|
|
161
|
+
const value = process.env[name];
|
|
162
|
+
if (value === undefined) {
|
|
163
|
+
throw new Error(`Missing environment variable \`${name}\``);
|
|
164
|
+
}
|
|
165
|
+
return value;
|
|
166
|
+
};
|
|
167
|
+
const authRequestHandler = httpActionGeneric(async (ctx, request) => {
|
|
168
|
+
const auth = createAuth(ctx);
|
|
169
|
+
const response = await auth.handler(request);
|
|
170
|
+
if (this.config?.verbose) {
|
|
171
|
+
console.log("response headers", response.headers);
|
|
172
|
+
}
|
|
173
|
+
return response;
|
|
174
|
+
});
|
|
175
|
+
const cors = corsRouter(http, {
|
|
176
|
+
allowedOrigins,
|
|
177
|
+
allowCredentials: true,
|
|
178
|
+
allowedHeaders: ["Authorization", "Content-Type", "Better-Auth-Cookie"],
|
|
179
|
+
verbose: this.config?.verbose,
|
|
180
|
+
exposedHeaders: ["Set-Better-Auth-Cookie"],
|
|
181
|
+
});
|
|
182
|
+
http.route({
|
|
183
|
+
path: "/.well-known/openid-configuration",
|
|
184
|
+
method: "GET",
|
|
185
|
+
handler: httpActionGeneric(async () => {
|
|
186
|
+
const url = `${requireEnv("CONVEX_SITE_URL")}/api/auth/convex/.well-known/openid-configuration`;
|
|
187
|
+
return Response.redirect(url);
|
|
188
|
+
}),
|
|
189
|
+
});
|
|
190
|
+
http.route({
|
|
191
|
+
path: `${path}/convex/.well-known/openid-configuration`,
|
|
192
|
+
method: "GET",
|
|
193
|
+
handler: authRequestHandler,
|
|
194
|
+
});
|
|
195
|
+
http.route({
|
|
196
|
+
path: `${path}/convex/jwks`,
|
|
197
|
+
method: "GET",
|
|
198
|
+
handler: authRequestHandler,
|
|
199
|
+
});
|
|
200
|
+
http.route({
|
|
201
|
+
pathPrefix: `${path}/callback/`,
|
|
202
|
+
method: "GET",
|
|
203
|
+
handler: authRequestHandler,
|
|
204
|
+
});
|
|
205
|
+
http.route({
|
|
206
|
+
path: `${path}/magic-link/verify`,
|
|
207
|
+
method: "GET",
|
|
208
|
+
handler: authRequestHandler,
|
|
209
|
+
});
|
|
210
|
+
http.route({
|
|
211
|
+
path: `${path}/verify-email`,
|
|
212
|
+
method: "GET",
|
|
213
|
+
handler: authRequestHandler,
|
|
214
|
+
});
|
|
215
|
+
http.route({
|
|
216
|
+
pathPrefix: `${path}/reset-password/`,
|
|
217
|
+
method: "GET",
|
|
218
|
+
handler: authRequestHandler,
|
|
219
|
+
});
|
|
220
|
+
cors.route({
|
|
221
|
+
pathPrefix: `${path}/`,
|
|
222
|
+
method: "GET",
|
|
223
|
+
handler: authRequestHandler,
|
|
224
|
+
});
|
|
225
|
+
cors.route({
|
|
226
|
+
pathPrefix: `${path}/`,
|
|
227
|
+
method: "POST",
|
|
228
|
+
handler: authRequestHandler,
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OA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,KAAK;YACb,OAAO,EAAE,kBAAkB;SAC5B,CAAC,CAAC;QAEH,IAAI,CAAC,KAAK,CAAC;YACT,UAAU,EAAE,GAAG,IAAI,kBAAkB;YACrC,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,kBAAkB;SAC5B,CAAC,CAAC;QAEH,IAAI,CAAC,KAAK,CAAC;YACT,UAAU,EAAE,GAAG,IAAI,GAAG;YACtB,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,kBAAkB;SAC5B,CAAC,CAAC;QAEH,IAAI,CAAC,KAAK,CAAC;YACT,UAAU,EAAE,GAAG,IAAI,GAAG;YACtB,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,kBAAkB;SAC5B,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/plugins/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/client/plugins/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A utility for referencing Convex functions in your app's API.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* ```js
|
|
6
|
+
* const myFunctionReference = api.myModule.myFunction;
|
|
7
|
+
* ```
|
|
8
|
+
*/
|
|
9
|
+
export const api: import("convex/server").AnyApi;
|
|
10
|
+
export const internal: import("convex/server").AnyApi;
|
|
11
|
+
export const components: import("convex/server").AnyChildComponents;
|
|
12
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../../src/component/_generated/api.js"],"names":[],"mappings":"AAYA;;;;;;;GAOG;AACH,iDAA0B;AAC1B,sDAA+B;AAC/B,oEAA8C"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Generated `api` utility.
|
|
4
|
+
*
|
|
5
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
+
*
|
|
7
|
+
* To regenerate, run `npx convex dev`.
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { anyApi, componentsGeneric } from "convex/server";
|
|
11
|
+
/**
|
|
12
|
+
* A utility for referencing Convex functions in your app's API.
|
|
13
|
+
*
|
|
14
|
+
* Usage:
|
|
15
|
+
* ```js
|
|
16
|
+
* const myFunctionReference = api.myModule.myFunction;
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export const api = anyApi;
|
|
20
|
+
export const internal = anyApi;
|
|
21
|
+
export const components = componentsGeneric();
|
|
22
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../../src/component/_generated/api.js"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE1D;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,MAAM,CAAC;AAC1B,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC;AAC/B,MAAM,CAAC,MAAM,UAAU,GAAG,iBAAiB,EAAE,CAAC"}
|