@convex-dev/better-auth 0.7.13 → 0.8.0-alpha.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.
Files changed (42) hide show
  1. package/README.md +4 -0
  2. package/dist/commonjs/client/cors.d.ts +77 -0
  3. package/dist/commonjs/client/cors.d.ts.map +1 -0
  4. package/dist/commonjs/client/cors.js +297 -0
  5. package/dist/commonjs/client/cors.js.map +1 -0
  6. package/dist/commonjs/client/index.d.ts +9 -103
  7. package/dist/commonjs/client/index.d.ts.map +1 -1
  8. package/dist/commonjs/client/index.js +18 -5
  9. package/dist/commonjs/client/index.js.map +1 -1
  10. package/dist/commonjs/component/adapterTest.js +2 -2
  11. package/dist/commonjs/component/adapterTest.js.map +1 -1
  12. package/dist/commonjs/component/lib.d.ts +0 -6
  13. package/dist/commonjs/component/lib.d.ts.map +1 -1
  14. package/dist/commonjs/component/lib.js +22 -6
  15. package/dist/commonjs/component/lib.js.map +1 -1
  16. package/dist/commonjs/util.d.ts +2 -0
  17. package/dist/commonjs/util.d.ts.map +1 -0
  18. package/dist/commonjs/util.js +8 -0
  19. package/dist/commonjs/util.js.map +1 -0
  20. package/dist/esm/client/cors.d.ts +77 -0
  21. package/dist/esm/client/cors.d.ts.map +1 -0
  22. package/dist/esm/client/cors.js +297 -0
  23. package/dist/esm/client/cors.js.map +1 -0
  24. package/dist/esm/client/index.d.ts +9 -103
  25. package/dist/esm/client/index.d.ts.map +1 -1
  26. package/dist/esm/client/index.js +18 -5
  27. package/dist/esm/client/index.js.map +1 -1
  28. package/dist/esm/component/adapterTest.js +2 -2
  29. package/dist/esm/component/adapterTest.js.map +1 -1
  30. package/dist/esm/component/lib.d.ts +0 -6
  31. package/dist/esm/component/lib.d.ts.map +1 -1
  32. package/dist/esm/component/lib.js +22 -6
  33. package/dist/esm/component/lib.js.map +1 -1
  34. package/dist/esm/util.d.ts +2 -0
  35. package/dist/esm/util.d.ts.map +1 -0
  36. package/dist/esm/util.js +8 -0
  37. package/dist/esm/util.js.map +1 -0
  38. package/package.json +3 -3
  39. package/src/client/adapter.test.ts +34 -26
  40. package/src/client/index.ts +34 -7
  41. package/src/component/adapterTest.ts +2 -2
  42. package/src/component/lib.ts +30 -6
package/README.md CHANGED
@@ -21,6 +21,10 @@ Use [Better Auth](https://better-auth.com) with [Convex](https://www.convex.dev)
21
21
  locally within this repo. They can be adapted for standalone use, but are
22
22
  intentionally not set up for it.
23
23
 
24
+ **Note:** Examples on the `main` branch may not match your version of the Better
25
+ Auth component. Use the `latest` branch for the latest stable release and the
26
+ `alpha` branch for the latest alpha release.
27
+
24
28
  1. Clone or fork the repo
25
29
  2. Install root dependencies
26
30
 
@@ -0,0 +1,77 @@
1
+ /**
2
+ * This file defines a CorsHttpRouter class that extends Convex's HttpRouter.
3
+ * It provides CORS (Cross-Origin Resource Sharing) support for HTTP routes.
4
+ *
5
+ * The CorsHttpRouter:
6
+ * 1. Allows specifying allowed origins for CORS.
7
+ * 2. Overrides the route method to add CORS headers to all non-OPTIONS requests.
8
+ * 3. Automatically adds an OPTIONS route to handle CORS preflight requests.
9
+ * 4. Uses the handleCors helper function to apply CORS headers consistently.
10
+ *
11
+ * This router simplifies the process of making Convex HTTP endpoints
12
+ * accessible to web applications hosted on different domains while
13
+ * maintaining proper CORS configuration.
14
+ */
15
+ import { HttpRouter, type RouteSpec } from "convex/server";
16
+ export declare const DEFAULT_EXPOSED_HEADERS: string[];
17
+ export type CorsConfig = {
18
+ /**
19
+ * Whether to allow credentials in the request.
20
+ * When true, the request can include cookies and authentication headers.
21
+ * @default false
22
+ */
23
+ allowCredentials?: boolean;
24
+ /**
25
+ * An array of allowed origins: what domains are allowed to make requests.
26
+ * For example, ["https://example.com"] would only allow requests from
27
+ * https://example.com.
28
+ * You can also use wildcards to allow all subdomains of a given domain.
29
+ * E.g. ["*.example.com"] would allow requests from:
30
+ * - https://subdomain.example.com
31
+ * - https://example.com
32
+ * @default ["*"]
33
+ */
34
+ allowedOrigins?: string[] | ((req: Request) => Promise<string[]>);
35
+ /**
36
+ * An array of allowed headers: what headers are allowed to be sent in
37
+ * the request.
38
+ * @default ["Content-Type"]
39
+ */
40
+ allowedHeaders?: string[];
41
+ /**
42
+ * An array of exposed headers: what headers are allowed to be sent in
43
+ * the response.
44
+ * Note: if you pass in an empty array, it will not expose any headers.
45
+ * If you want to extend the default exposed headers, you can do so by
46
+ * passing in [...DEFAULT_EXPOSED_HEADERS, ...yourHeaders].
47
+ * @default {@link DEFAULT_EXPOSED_HEADERS}
48
+ */
49
+ exposedHeaders?: string[];
50
+ /**
51
+ * The maximum age of the preflight request in seconds.
52
+ * @default 86400 (1 day)
53
+ */
54
+ browserCacheMaxAge?: number;
55
+ /**
56
+ * Whether to block requests from origins that are not in the allowedOrigins list.
57
+ * @default true
58
+ */
59
+ enforceAllowOrigins?: boolean;
60
+ /**
61
+ * Whether to log debugging information about CORS requests.
62
+ * @default false
63
+ */
64
+ debug?: boolean;
65
+ };
66
+ type RouteSpecWithCors = RouteSpec & CorsConfig;
67
+ /**
68
+ * Factory function to create a router that adds CORS support to routes.
69
+ * @param allowedOrigins An array of allowed origins for CORS.
70
+ * @returns A function to use instead of http.route when you want CORS.
71
+ */
72
+ export declare const corsRouter: (http: HttpRouter, corsConfig?: CorsConfig) => {
73
+ http: HttpRouter;
74
+ route: (routeSpec: RouteSpecWithCors) => void;
75
+ };
76
+ export default corsRouter;
77
+ //# sourceMappingURL=cors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cors.d.ts","sourceRoot":"","sources":["../../../src/client/cors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAIL,UAAU,EAIV,KAAK,SAAS,EAGf,MAAM,eAAe,CAAC;AAEvB,eAAO,MAAM,uBAAuB,UAInC,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;;;;;OASG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAClE;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,KAAK,iBAAiB,GAAG,SAAS,GAAG,UAAU,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,MAAM,UAAU,EAAE,aAAa,UAAU;;uBAK7C,iBAAiB,KAAG,IAAI;CAsD9C,CAAC;AA+DF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,297 @@
1
+ /**
2
+ * This file defines a CorsHttpRouter class that extends Convex's HttpRouter.
3
+ * It provides CORS (Cross-Origin Resource Sharing) support for HTTP routes.
4
+ *
5
+ * The CorsHttpRouter:
6
+ * 1. Allows specifying allowed origins for CORS.
7
+ * 2. Overrides the route method to add CORS headers to all non-OPTIONS requests.
8
+ * 3. Automatically adds an OPTIONS route to handle CORS preflight requests.
9
+ * 4. Uses the handleCors helper function to apply CORS headers consistently.
10
+ *
11
+ * This router simplifies the process of making Convex HTTP endpoints
12
+ * accessible to web applications hosted on different domains while
13
+ * maintaining proper CORS configuration.
14
+ */
15
+ import { httpActionGeneric, httpRouter, ROUTABLE_HTTP_METHODS, } from "convex/server";
16
+ export const DEFAULT_EXPOSED_HEADERS = [
17
+ // For Range requests
18
+ "Content-Range",
19
+ "Accept-Ranges",
20
+ ];
21
+ /**
22
+ * Factory function to create a router that adds CORS support to routes.
23
+ * @param allowedOrigins An array of allowed origins for CORS.
24
+ * @returns A function to use instead of http.route when you want CORS.
25
+ */
26
+ export const corsRouter = (http, corsConfig) => {
27
+ const allowedExactMethodsByPath = new Map();
28
+ const allowedPrefixMethodsByPath = new Map();
29
+ return {
30
+ http,
31
+ route: (routeSpec) => {
32
+ const tempRouter = httpRouter();
33
+ tempRouter.exactRoutes = http.exactRoutes;
34
+ tempRouter.prefixRoutes = http.prefixRoutes;
35
+ const config = {
36
+ ...corsConfig,
37
+ ...routeSpec,
38
+ };
39
+ const httpCorsHandler = handleCors({
40
+ originalHandler: routeSpec.handler,
41
+ allowedMethods: [routeSpec.method],
42
+ ...config,
43
+ });
44
+ /**
45
+ * Figure out what kind of route we're adding: exact or prefix and handle
46
+ * accordingly.
47
+ */
48
+ if ("path" in routeSpec) {
49
+ let methods = allowedExactMethodsByPath.get(routeSpec.path);
50
+ if (!methods) {
51
+ methods = new Set();
52
+ allowedExactMethodsByPath.set(routeSpec.path, methods);
53
+ }
54
+ methods.add(routeSpec.method);
55
+ tempRouter.route({
56
+ path: routeSpec.path,
57
+ method: routeSpec.method,
58
+ handler: httpCorsHandler,
59
+ });
60
+ handleExactRoute(tempRouter, routeSpec, config, Array.from(methods));
61
+ }
62
+ else {
63
+ let methods = allowedPrefixMethodsByPath.get(routeSpec.pathPrefix);
64
+ if (!methods) {
65
+ methods = new Set();
66
+ allowedPrefixMethodsByPath.set(routeSpec.pathPrefix, methods);
67
+ }
68
+ methods.add(routeSpec.method);
69
+ tempRouter.route({
70
+ pathPrefix: routeSpec.pathPrefix,
71
+ method: routeSpec.method,
72
+ handler: httpCorsHandler,
73
+ });
74
+ handlePrefixRoute(tempRouter, routeSpec, config, Array.from(methods));
75
+ }
76
+ /**
77
+ * Copy the routes from the temporary router to the main router.
78
+ */
79
+ http.exactRoutes = new Map(tempRouter.exactRoutes);
80
+ http.prefixRoutes = new Map(tempRouter.prefixRoutes);
81
+ },
82
+ };
83
+ };
84
+ /**
85
+ * Handles exact route matching and adds OPTIONS handler.
86
+ * @param tempRouter Temporary router instance.
87
+ * @param routeSpec Route specification for exact matching.
88
+ */
89
+ function handleExactRoute(tempRouter, routeSpec, config, allowedMethods) {
90
+ const currentMethodsForPath = tempRouter.exactRoutes.get(routeSpec.path);
91
+ /**
92
+ * Add the OPTIONS handler for the given path
93
+ */
94
+ const optionsHandler = createOptionsHandlerForMethods(allowedMethods, config);
95
+ currentMethodsForPath?.set("OPTIONS", optionsHandler);
96
+ tempRouter.exactRoutes.set(routeSpec.path, new Map(currentMethodsForPath));
97
+ }
98
+ /**
99
+ * Handles prefix route matching and adds OPTIONS handler.
100
+ * @param tempRouter Temporary router instance.
101
+ * @param routeSpec Route specification for prefix matching.
102
+ */
103
+ function handlePrefixRoute(tempRouter, routeSpec, config, allowedMethods) {
104
+ /**
105
+ * prefixRoutes is structured differently than exactRoutes. It's defined as
106
+ * a Map<string, Map<string, PublicHttpAction>> where the KEY is the
107
+ * METHOD and the VALUE is a map of paths and handlers.
108
+ */
109
+ const optionsHandler = createOptionsHandlerForMethods(allowedMethods, config);
110
+ const optionsPrefixes = tempRouter.prefixRoutes.get("OPTIONS") ||
111
+ new Map();
112
+ optionsPrefixes.set(routeSpec.pathPrefix, optionsHandler);
113
+ tempRouter.prefixRoutes.set("OPTIONS", optionsPrefixes);
114
+ }
115
+ /**
116
+ * Creates an OPTIONS handler for the given HTTP methods.
117
+ * @param methods Array of HTTP methods to be allowed.
118
+ * @returns A CORS-enabled OPTIONS handler.
119
+ */
120
+ function createOptionsHandlerForMethods(methods, config) {
121
+ return handleCors({
122
+ ...config,
123
+ allowedMethods: methods,
124
+ });
125
+ }
126
+ export default corsRouter;
127
+ /**
128
+ * handleCors() is a higher-order function that wraps a Convex HTTP action handler to add CORS support.
129
+ * It allows for customization of allowed HTTP methods and origins for cross-origin requests.
130
+ *
131
+ * The function:
132
+ * 1. Validates and normalizes the allowed HTTP methods.
133
+ * 2. Generates appropriate CORS headers based on the provided configuration.
134
+ * 3. Handles preflight OPTIONS requests automatically.
135
+ * 4. Wraps the original handler to add CORS headers to its response.
136
+ *
137
+ * This helper simplifies the process of making Convex HTTP actions accessible
138
+ * to web applications hosted on different domains.
139
+ */
140
+ const SECONDS_IN_A_DAY = 60 * 60 * 24;
141
+ /**
142
+ * Example CORS origins:
143
+ * - "*" (allow all origins)
144
+ * - "https://example.com" (allow a specific domain)
145
+ * - "https://*.example.com" (allow all subdomains of example.com)
146
+ * - "https://example1.com, https://example2.com" (allow multiple specific domains)
147
+ * - "null" (allow requests from data URLs or local files)
148
+ */
149
+ const handleCors = ({ originalHandler, allowedMethods = ["OPTIONS"], allowedOrigins = ["*"], allowedHeaders = ["Content-Type"], exposedHeaders = DEFAULT_EXPOSED_HEADERS, allowCredentials = false, browserCacheMaxAge = SECONDS_IN_A_DAY, enforceAllowOrigins = true, debug = false, }) => {
150
+ const uniqueMethods = Array.from(new Set(allowedMethods.map((method) => method.toUpperCase())));
151
+ const filteredMethods = uniqueMethods.filter((method) => ROUTABLE_HTTP_METHODS.includes(method));
152
+ if (filteredMethods.length === 0) {
153
+ throw new Error("No valid HTTP methods provided");
154
+ }
155
+ /**
156
+ * Ensure OPTIONS is not duplicated if it was passed in
157
+ * E.g. if allowedMethods = ["GET", "OPTIONS"]
158
+ */
159
+ const allowMethods = filteredMethods.includes("OPTIONS")
160
+ ? filteredMethods.join(", ")
161
+ : [...filteredMethods].join(", ");
162
+ /**
163
+ * Build up the set of CORS headers
164
+ */
165
+ const commonHeaders = {
166
+ Vary: "Origin",
167
+ };
168
+ if (allowCredentials) {
169
+ commonHeaders["Access-Control-Allow-Credentials"] = "true";
170
+ }
171
+ if (exposedHeaders.length > 0) {
172
+ commonHeaders["Access-Control-Expose-Headers"] = exposedHeaders.join(", ");
173
+ }
174
+ async function parseAllowedOrigins(request) {
175
+ return Array.isArray(allowedOrigins)
176
+ ? allowedOrigins
177
+ : await allowedOrigins(request);
178
+ }
179
+ // Helper function to check if origin is allowed (including wildcard subdomain matching)
180
+ async function isAllowedOrigin(request) {
181
+ const requestOrigin = request.headers.get("origin");
182
+ if (!requestOrigin)
183
+ return false;
184
+ return (await parseAllowedOrigins(request)).some((allowed) => {
185
+ if (allowed === "*")
186
+ return true;
187
+ if (allowed === requestOrigin)
188
+ return true;
189
+ if (allowed.startsWith("*.")) {
190
+ const wildcardDomain = allowed.slice(1); // ".bar.com"
191
+ const rootDomain = allowed.slice(2); // "bar.com"
192
+ try {
193
+ const url = new URL(requestOrigin);
194
+ return (url.protocol === "https:" &&
195
+ (url.hostname.endsWith(wildcardDomain) ||
196
+ url.hostname === rootDomain));
197
+ }
198
+ catch {
199
+ return false; // Invalid URL format
200
+ }
201
+ }
202
+ return false;
203
+ });
204
+ }
205
+ /**
206
+ * Return our modified HTTP action
207
+ */
208
+ return httpActionGeneric(async (ctx, request) => {
209
+ if (debug) {
210
+ console.log("CORS request", {
211
+ path: request.url,
212
+ origin: request.headers.get("origin"),
213
+ headers: request.headers,
214
+ method: request.method,
215
+ body: request.body,
216
+ });
217
+ }
218
+ const requestOrigin = request.headers.get("origin");
219
+ const parsedAllowedOrigins = await parseAllowedOrigins(request);
220
+ if (debug) {
221
+ console.log("allowed origins", parsedAllowedOrigins);
222
+ }
223
+ // Handle origin matching
224
+ let allowOrigins = null;
225
+ if (parsedAllowedOrigins.includes("*") && !allowCredentials) {
226
+ allowOrigins = "*";
227
+ }
228
+ else if (requestOrigin) {
229
+ // Check if the request origin matches any of the allowed origins
230
+ // (including wildcard subdomain matching if configured)
231
+ if (await isAllowedOrigin(request)) {
232
+ allowOrigins = requestOrigin;
233
+ }
234
+ }
235
+ if (enforceAllowOrigins && !allowOrigins) {
236
+ // Origin not allowed
237
+ console.error(`Request from origin ${requestOrigin} blocked, missing from allowed origins: ${parsedAllowedOrigins.join()}`);
238
+ return new Response(null, { status: 403 });
239
+ }
240
+ /**
241
+ * OPTIONS has no handler and just returns headers
242
+ */
243
+ if (request.method === "OPTIONS") {
244
+ const responseHeaders = new Headers({
245
+ ...commonHeaders,
246
+ "Access-Control-Allow-Origin": allowOrigins ?? "",
247
+ "Access-Control-Allow-Methods": allowMethods,
248
+ "Access-Control-Allow-Headers": allowedHeaders.join(", "),
249
+ "Access-Control-Max-Age": browserCacheMaxAge.toString(),
250
+ });
251
+ if (debug) {
252
+ console.log("CORS OPTIONS response headers", responseHeaders);
253
+ }
254
+ return new Response(null, {
255
+ status: 204,
256
+ headers: responseHeaders,
257
+ });
258
+ }
259
+ /**
260
+ * If the method is not OPTIONS, it must pass a handler
261
+ */
262
+ if (!originalHandler) {
263
+ throw new Error("No PublicHttpAction provider to CORS handler");
264
+ }
265
+ /**
266
+ * First, execute the original handler
267
+ */
268
+ const innerHandler = ("_handler" in originalHandler
269
+ ? originalHandler["_handler"]
270
+ : originalHandler);
271
+ const originalResponse = await innerHandler(ctx, request);
272
+ /**
273
+ * Second, get a copy of the original response's headers
274
+ */
275
+ const newHeaders = new Headers(originalResponse.headers);
276
+ newHeaders.set("Access-Control-Allow-Origin", allowOrigins ?? "");
277
+ /**
278
+ * Third, add or update our CORS headers
279
+ */
280
+ Object.entries(commonHeaders).forEach(([key, value]) => {
281
+ newHeaders.set(key, value);
282
+ });
283
+ if (debug) {
284
+ console.log("CORS response headers", newHeaders);
285
+ }
286
+ /**
287
+ * Fourth, return the modified Response.
288
+ * A Response object is immutable, so we create a new one to return here.
289
+ */
290
+ return new Response(originalResponse.body, {
291
+ status: originalResponse.status,
292
+ statusText: originalResponse.statusText,
293
+ headers: newHeaders,
294
+ });
295
+ });
296
+ };
297
+ //# sourceMappingURL=cors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cors.js","sourceRoot":"","sources":["../../../src/client/cors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAEL,iBAAiB,EACjB,UAAU,EAEV,qBAAqB,GAMtB,MAAM,eAAe,CAAC;AAEvB,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,qBAAqB;IACrB,eAAe;IACf,eAAe;CAChB,CAAC;AAsDF;;;;GAIG;AACH,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EAAE,GAAG;gBACX,OAAO,EAAE,eAAe;aACzB,CAAC,CAAC;QACL,CAAC;QAED;;WAEG;QACH,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;QAClE,CAAC;QAED;;WAEG;QACH,MAAM,YAAY,GAAG,CAAC,UAAU,IAAI,eAAe;YACjD,CAAC,CAAE,eAAe,CAAC,UAAU,CAAsB;YACnD,CAAC,CAAC,eAAe,CAGG,CAAC;QACvB,MAAM,gBAAgB,GAAG,MAAM,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAE1D;;WAEG;QACH,MAAM,UAAU,GAAG,IAAI,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;QACzD,UAAU,CAAC,GAAG,CAAC,6BAA6B,EAAE,YAAY,IAAI,EAAE,CAAC,CAAC;QAElE;;WAEG;QACH,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YACrD,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;QAEH,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,UAAU,CAAC,CAAC;QACnD,CAAC;QAED;;;WAGG;QACH,OAAO,IAAI,QAAQ,CAAC,gBAAgB,CAAC,IAAI,EAAE;YACzC,MAAM,EAAE,gBAAgB,CAAC,MAAM;YAC/B,UAAU,EAAE,gBAAgB,CAAC,UAAU;YACvC,OAAO,EAAE,UAAU;SACpB,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACJ,CAAC,CAAC"}
@@ -45,96 +45,20 @@ declare const createUserValidator: import("convex/values").VObject<{
45
45
  stripeCustomerId: import("convex/values").VUnion<string | null | undefined, [import("convex/values").VNull<null, "required">, import("convex/values").VString<string, "required">], "optional", never>;
46
46
  teamId: import("convex/values").VUnion<string | null | undefined, [import("convex/values").VNull<null, "required">, import("convex/values").VString<string, "required">], "optional", never>;
47
47
  }, "required", "name" | "email" | "emailVerified" | "image" | "createdAt" | "updatedAt" | "twoFactorEnabled" | "isAnonymous" | "username" | "displayUsername" | "phoneNumber" | "phoneNumberVerified" | "role" | "banned" | "banReason" | "banExpires" | "stripeCustomerId" | "teamId">;
48
- declare const createUserArgsValidator: import("convex/values").VObject<{
48
+ declare const createPermissiveArgsValidator: import("convex/values").VObject<{
49
49
  input: {
50
50
  model: "user";
51
- data: {
52
- image?: string | null | undefined;
53
- twoFactorEnabled?: boolean | null | undefined;
54
- isAnonymous?: boolean | null | undefined;
55
- username?: string | null | undefined;
56
- displayUsername?: string | null | undefined;
57
- phoneNumber?: string | null | undefined;
58
- phoneNumberVerified?: boolean | null | undefined;
59
- role?: string | null | undefined;
60
- banned?: boolean | null | undefined;
61
- banReason?: string | null | undefined;
62
- banExpires?: number | null | undefined;
63
- stripeCustomerId?: string | null | undefined;
64
- teamId?: string | null | undefined;
65
- name: string;
66
- email: string;
67
- emailVerified: boolean;
68
- createdAt: number;
69
- updatedAt: number;
70
- };
51
+ data: Record<string, string | number | boolean | string[] | number[] | null>;
71
52
  };
72
53
  }, {
73
54
  input: import("convex/values").VObject<{
74
55
  model: "user";
75
- data: {
76
- image?: string | null | undefined;
77
- twoFactorEnabled?: boolean | null | undefined;
78
- isAnonymous?: boolean | null | undefined;
79
- username?: string | null | undefined;
80
- displayUsername?: string | null | undefined;
81
- phoneNumber?: string | null | undefined;
82
- phoneNumberVerified?: boolean | null | undefined;
83
- role?: string | null | undefined;
84
- banned?: boolean | null | undefined;
85
- banReason?: string | null | undefined;
86
- banExpires?: number | null | undefined;
87
- stripeCustomerId?: string | null | undefined;
88
- teamId?: string | null | undefined;
89
- name: string;
90
- email: string;
91
- emailVerified: boolean;
92
- createdAt: number;
93
- updatedAt: number;
94
- };
56
+ data: Record<string, string | number | boolean | string[] | number[] | null>;
95
57
  }, {
96
58
  model: import("convex/values").VLiteral<"user", "required">;
97
- data: import("convex/values").VObject<{
98
- image?: string | null | undefined;
99
- twoFactorEnabled?: boolean | null | undefined;
100
- isAnonymous?: boolean | null | undefined;
101
- username?: string | null | undefined;
102
- displayUsername?: string | null | undefined;
103
- phoneNumber?: string | null | undefined;
104
- phoneNumberVerified?: boolean | null | undefined;
105
- role?: string | null | undefined;
106
- banned?: boolean | null | undefined;
107
- banReason?: string | null | undefined;
108
- banExpires?: number | null | undefined;
109
- stripeCustomerId?: string | null | undefined;
110
- teamId?: string | null | undefined;
111
- name: string;
112
- email: string;
113
- emailVerified: boolean;
114
- createdAt: number;
115
- updatedAt: number;
116
- }, {
117
- name: import("convex/values").VString<string, "required">;
118
- email: import("convex/values").VString<string, "required">;
119
- emailVerified: import("convex/values").VBoolean<boolean, "required">;
120
- image: import("convex/values").VUnion<string | null | undefined, [import("convex/values").VNull<null, "required">, import("convex/values").VString<string, "required">], "optional", never>;
121
- createdAt: import("convex/values").VFloat64<number, "required">;
122
- updatedAt: import("convex/values").VFloat64<number, "required">;
123
- twoFactorEnabled: import("convex/values").VUnion<boolean | null | undefined, [import("convex/values").VNull<null, "required">, import("convex/values").VBoolean<boolean, "required">], "optional", never>;
124
- isAnonymous: import("convex/values").VUnion<boolean | null | undefined, [import("convex/values").VNull<null, "required">, import("convex/values").VBoolean<boolean, "required">], "optional", never>;
125
- username: import("convex/values").VUnion<string | null | undefined, [import("convex/values").VNull<null, "required">, import("convex/values").VString<string, "required">], "optional", never>;
126
- displayUsername: import("convex/values").VUnion<string | null | undefined, [import("convex/values").VNull<null, "required">, import("convex/values").VString<string, "required">], "optional", never>;
127
- phoneNumber: import("convex/values").VUnion<string | null | undefined, [import("convex/values").VNull<null, "required">, import("convex/values").VString<string, "required">], "optional", never>;
128
- phoneNumberVerified: import("convex/values").VUnion<boolean | null | undefined, [import("convex/values").VNull<null, "required">, import("convex/values").VBoolean<boolean, "required">], "optional", never>;
129
- role: import("convex/values").VUnion<string | null | undefined, [import("convex/values").VNull<null, "required">, import("convex/values").VString<string, "required">], "optional", never>;
130
- banned: import("convex/values").VUnion<boolean | null | undefined, [import("convex/values").VNull<null, "required">, import("convex/values").VBoolean<boolean, "required">], "optional", never>;
131
- banReason: import("convex/values").VUnion<string | null | undefined, [import("convex/values").VNull<null, "required">, import("convex/values").VString<string, "required">], "optional", never>;
132
- banExpires: import("convex/values").VUnion<number | null | undefined, [import("convex/values").VNull<null, "required">, import("convex/values").VFloat64<number, "required">], "optional", never>;
133
- stripeCustomerId: import("convex/values").VUnion<string | null | undefined, [import("convex/values").VNull<null, "required">, import("convex/values").VString<string, "required">], "optional", never>;
134
- teamId: import("convex/values").VUnion<string | null | undefined, [import("convex/values").VNull<null, "required">, import("convex/values").VString<string, "required">], "optional", never>;
135
- }, "required", "name" | "email" | "emailVerified" | "image" | "createdAt" | "updatedAt" | "twoFactorEnabled" | "isAnonymous" | "username" | "displayUsername" | "phoneNumber" | "phoneNumberVerified" | "role" | "banned" | "banReason" | "banExpires" | "stripeCustomerId" | "teamId">;
136
- }, "required", "model" | "data" | "data.name" | "data.email" | "data.emailVerified" | "data.image" | "data.createdAt" | "data.updatedAt" | "data.twoFactorEnabled" | "data.isAnonymous" | "data.username" | "data.displayUsername" | "data.phoneNumber" | "data.phoneNumberVerified" | "data.role" | "data.banned" | "data.banReason" | "data.banExpires" | "data.stripeCustomerId" | "data.teamId">;
137
- }, "required", "input" | "input.model" | "input.data" | "input.data.name" | "input.data.email" | "input.data.emailVerified" | "input.data.image" | "input.data.createdAt" | "input.data.updatedAt" | "input.data.twoFactorEnabled" | "input.data.isAnonymous" | "input.data.username" | "input.data.displayUsername" | "input.data.phoneNumber" | "input.data.phoneNumberVerified" | "input.data.role" | "input.data.banned" | "input.data.banReason" | "input.data.banExpires" | "input.data.stripeCustomerId" | "input.data.teamId">;
59
+ data: import("convex/values").VRecord<Record<string, string | number | boolean | string[] | number[] | null>, import("convex/values").VString<string, "required">, import("convex/values").VUnion<string | number | boolean | string[] | number[] | 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>, "required", string>;
60
+ }, "required", "model" | "data" | `data.${string}`>;
61
+ }, "required", "input" | "input.model" | "input.data" | `input.data.${string}`>;
138
62
  declare const updateUserArgsValidator: import("convex/values").VObject<{
139
63
  input: {
140
64
  where?: {
@@ -313,7 +237,7 @@ declare const createSessionArgsValidator: import("convex/values").VObject<{
313
237
  }, "required", "input" | "input.model" | "input.data" | "input.data.createdAt" | "input.data.updatedAt" | "input.data.userId" | "input.data.expiresAt" | "input.data.token" | "input.data.ipAddress" | "input.data.userAgent" | "input.data.impersonatedBy" | "input.data.activeOrganizationId" | "input.data.activeTeamId">;
314
238
  export type EventFunction<T extends DefaultFunctionArgs> = FunctionReference<"mutation", "internal" | "public", T>;
315
239
  export type AuthFunctions = {
316
- createUser: FunctionReference<"mutation", "internal", Infer<typeof createUserArgsValidator>>;
240
+ createUser: FunctionReference<"mutation", "internal", Infer<typeof createPermissiveArgsValidator>>;
317
241
  deleteUser: FunctionReference<"mutation", "internal", Infer<typeof adapterArgsValidator>>;
318
242
  updateUser: FunctionReference<"mutation", "internal", Infer<typeof updateUserArgsValidator>>;
319
243
  createSession: FunctionReference<"mutation", "internal", Infer<typeof createSessionArgsValidator>>;
@@ -560,6 +484,7 @@ export declare class BetterAuth<UserId extends string = string> {
560
484
  lastRequest?: number | null | undefined;
561
485
  count?: number | null | undefined;
562
486
  }>;
487
+ getUserByUsername(ctx: GenericQueryCtx<GenericDataModel>, username: string): Promise<any>;
563
488
  createAuthFunctions<DataModel extends GenericDataModel>(opts: {
564
489
  onCreateUser: (ctx: GenericMutationCtx<DataModel>, user: Infer<typeof createUserValidator>) => Promise<UserId>;
565
490
  onDeleteUser?: (ctx: GenericMutationCtx<DataModel>, id: UserId) => void | Promise<void>;
@@ -570,26 +495,7 @@ export declare class BetterAuth<UserId extends string = string> {
570
495
  createUser: import("convex/server").RegisteredMutation<"internal", {
571
496
  input: {
572
497
  model: "user";
573
- data: {
574
- image?: string | null | undefined;
575
- twoFactorEnabled?: boolean | null | undefined;
576
- isAnonymous?: boolean | null | undefined;
577
- username?: string | null | undefined;
578
- displayUsername?: string | null | undefined;
579
- phoneNumber?: string | null | undefined;
580
- phoneNumberVerified?: boolean | null | undefined;
581
- role?: string | null | undefined;
582
- banned?: boolean | null | undefined;
583
- banReason?: string | null | undefined;
584
- banExpires?: number | null | undefined;
585
- stripeCustomerId?: string | null | undefined;
586
- teamId?: string | null | undefined;
587
- name: string;
588
- email: string;
589
- emailVerified: boolean;
590
- createdAt: number;
591
- updatedAt: number;
592
- };
498
+ data: Record<string, string | number | boolean | string[] | number[] | null>;
593
499
  };
594
500
  }, Promise<any>>;
595
501
  deleteUser: import("convex/server").RegisteredMutation<"internal", {
@@ -1 +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;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAOzC,OAAO,EAAE,oBAAoB,EAAyB,MAAM,kB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,CAAC,CAAC;IACxD,WAAW,EAAE,kBAAkB,CAAC,gBAAgB,CAAC,CAAC,aAAa,CAAC,CAAC;IACjE,SAAS,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC,WAAW,CAAC,CAAC;CAC5D,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,WAAW,GAAG,cAAc,GAAG,YAAY,CAAC;AAEjE,MAAM,MAAM,SAAS,CAAC,CAAC,IACrB,CAAC,SAAS,SAAS,CAAC,MAAM,EAAE,CAAC,GACzB,MAAM,GACN,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GACnB,SAAS,CAAC,CAAC,CAAC,EAAE,GACd,CAAC,SAAS,WAAW,GACnB,WAAW,GACX,CAAC,SAAS,MAAM,GACd;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACnC,CAAC,CAAC;AAEd,MAAM,MAAM,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC;KAC9B,GAAG,IAAI,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,SAAS,iBAAiB,CACpD,MAAM,KAAK,EACX,QAAQ,EACR,MAAM,KAAK,EACX,MAAM,WAAW,EACjB,MAAM,cAAc,CACrB,GACG,iBAAiB,CACf,KAAK,EACL,UAAU,EACV,SAAS,CAAC,KAAK,CAAC,EAChB,SAAS,CAAC,WAAW,CAAC,EACtB,cAAc,CACf,GACD,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CACrB,CAAC,CAAC"}
@@ -7,7 +7,7 @@ import { createCookieGetter } from "better-auth/cookies";
7
7
  import { fetchQuery } from "convex/nextjs";
8
8
  import { JWT_COOKIE_NAME } from "../plugins/convex";
9
9
  import { requireEnv } from "../utils";
10
- import { partial } from "convex-helpers/validators";
10
+ import { parse, partial } from "convex-helpers/validators";
11
11
  import { adapterArgsValidator, adapterWhereValidator } from "../component/lib";
12
12
  import { corsRouter } from "convex-helpers/server/cors";
13
13
  import { version as convexVersion } from "convex";
@@ -18,6 +18,12 @@ if (semver.lt(convexVersion, "1.25.0")) {
18
18
  }
19
19
  const createUserFields = omit(schema.tables.user.validator.fields, ["userId"]);
20
20
  const createUserValidator = v.object(createUserFields);
21
+ const createPermissiveArgsValidator = v.object({
22
+ input: v.object({
23
+ model: v.literal("user"),
24
+ data: v.record(v.string(), v.union(v.string(), v.number(), v.boolean(), v.array(v.string()), v.array(v.number()), v.null())),
25
+ }),
26
+ });
21
27
  const createUserArgsValidator = v.object({
22
28
  input: v.object({
23
29
  model: v.literal("user"),
@@ -105,6 +111,12 @@ export class BetterAuth {
105
111
  },
106
112
  });
107
113
  }
114
+ async getUserByUsername(ctx, username) {
115
+ return ctx.runQuery(this.component.lib.findOne, {
116
+ model: "user",
117
+ where: [{ field: "username", value: username }],
118
+ });
119
+ }
108
120
  createAuthFunctions(opts) {
109
121
  return {
110
122
  isAuthenticated: queryGeneric({
@@ -115,13 +127,14 @@ export class BetterAuth {
115
127
  },
116
128
  }),
117
129
  createUser: internalMutationGeneric({
118
- args: createUserArgsValidator,
130
+ args: createPermissiveArgsValidator,
119
131
  handler: async (ctx, args) => {
120
132
  const userId = await opts.onCreateUser(ctx, args.input.data);
133
+ const parsedArgs = parse(createUserArgsValidator, args);
121
134
  return ctx.runMutation(this.component.lib.create, {
122
135
  input: {
123
- ...args.input,
124
- data: { ...args.input.data, userId },
136
+ ...parsedArgs.input,
137
+ data: { ...parsedArgs.input.data, userId },
125
138
  },
126
139
  });
127
140
  },
@@ -185,7 +198,7 @@ export class BetterAuth {
185
198
  path: "/.well-known/openid-configuration",
186
199
  method: "GET",
187
200
  handler: httpActionGeneric(async () => {
188
- const url = `${requireEnv("CONVEX_SITE_URL")}/api/auth/convex/.well-known/openid-configuration`;
201
+ const url = `${requireEnv("CONVEX_SITE_URL")}${path}/convex/.well-known/openid-configuration`;
189
202
  return Response.redirect(url);
190
203
  }),
191
204
  });