better-convex 0.0.3 → 0.0.5
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/auth/index.d.ts +60 -60
- package/dist/auth/index.js +2 -2
- package/dist/auth-client/index.d.ts +9 -6
- package/dist/auth-client/index.js +144 -50
- package/dist/auth-nextjs/index.d.ts +10 -10
- package/dist/auth-nextjs/index.js +17 -13
- package/dist/{auth-store-DPj6Z0Xl.js → auth-store-DANFmEdk.js} +41 -89
- package/dist/{error-DwOaXhPE.js → caller-factory-DxmuY355.js} +8 -135
- package/dist/cli.cjs +1 -1
- package/dist/{codegen-P6NmBpvG.cjs → codegen-DN-vbQih.cjs} +1 -1
- package/dist/crpc/index.d.ts +4 -2
- package/dist/crpc/index.js +3 -23
- package/dist/error-CsSzFKod.js +32 -0
- package/dist/react/index.d.ts +75 -36
- package/dist/react/index.js +1149 -1044
- package/dist/rsc/index.d.ts +1 -1
- package/dist/rsc/index.js +1 -1
- package/dist/server/index.d.ts +13 -15
- package/dist/server/index.js +128 -1
- package/dist/watcher.cjs +1 -1
- package/package.json +3 -2
- /package/dist/{create-schema-CiLdn4rr.js → create-schema-DzQEFNJW.js} +0 -0
- /package/dist/{query-options-lmbltN6P.js → query-options-sK2n1Ioe.js} +0 -0
- /package/dist/{types-h8_JnBVZ.d.ts → types-CotWvon8.d.ts} +0 -0
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as better_auth_adapters1 from "better-auth/adapters";
|
|
2
2
|
import { DBAdapterDebugLogOption } from "better-auth/adapters";
|
|
3
3
|
import { BetterAuthDBSchema } from "better-auth/db";
|
|
4
|
-
import * as
|
|
4
|
+
import * as convex_server24 from "convex/server";
|
|
5
5
|
import { DocumentByName, FunctionReference, GenericDataModel, GenericMutationCtx, GenericQueryCtx, GenericSchema, HttpRouter, IdField, PaginationOptions, PaginationResult, SchemaDefinition, SystemFields, TableNamesInDataModel, internalMutationGeneric } from "convex/server";
|
|
6
6
|
import * as convex_values0 from "convex/values";
|
|
7
7
|
import { Infer } from "convex/values";
|
|
@@ -47,28 +47,28 @@ declare const createClient: <DataModel extends GenericDataModel, Schema$1 extend
|
|
|
47
47
|
adapter: (ctx: GenericCtx<DataModel>, createAuthOptions: (ctx: any) => BetterAuthOptions) => better_auth_adapters1.AdapterFactory;
|
|
48
48
|
httpAdapter: (ctx: GenericCtx<DataModel>) => better_auth_adapters1.AdapterFactory;
|
|
49
49
|
triggersApi: () => {
|
|
50
|
-
beforeCreate:
|
|
50
|
+
beforeCreate: convex_server24.RegisteredMutation<"internal", {
|
|
51
51
|
data: any;
|
|
52
52
|
model: string;
|
|
53
53
|
}, Promise<any>>;
|
|
54
|
-
beforeDelete:
|
|
54
|
+
beforeDelete: convex_server24.RegisteredMutation<"internal", {
|
|
55
55
|
model: string;
|
|
56
56
|
doc: any;
|
|
57
57
|
}, Promise<any>>;
|
|
58
|
-
beforeUpdate:
|
|
58
|
+
beforeUpdate: convex_server24.RegisteredMutation<"internal", {
|
|
59
59
|
update: any;
|
|
60
60
|
model: string;
|
|
61
61
|
doc: any;
|
|
62
62
|
}, Promise<any>>;
|
|
63
|
-
onCreate:
|
|
63
|
+
onCreate: convex_server24.RegisteredMutation<"internal", {
|
|
64
64
|
model: string;
|
|
65
65
|
doc: any;
|
|
66
66
|
}, Promise<void>>;
|
|
67
|
-
onDelete:
|
|
67
|
+
onDelete: convex_server24.RegisteredMutation<"internal", {
|
|
68
68
|
model: string;
|
|
69
69
|
doc: any;
|
|
70
70
|
}, Promise<void>>;
|
|
71
|
-
onUpdate:
|
|
71
|
+
onUpdate: convex_server24.RegisteredMutation<"internal", {
|
|
72
72
|
model: string;
|
|
73
73
|
newDoc: any;
|
|
74
74
|
oldDoc: any;
|
|
@@ -163,20 +163,20 @@ declare const dbAdapter: <DataModel extends GenericDataModel, Schema$1 extends S
|
|
|
163
163
|
//#endregion
|
|
164
164
|
//#region src/auth/adapter-utils.d.ts
|
|
165
165
|
declare const adapterWhereValidator: convex_values0.VObject<{
|
|
166
|
-
operator?: "
|
|
166
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
167
167
|
connector?: "AND" | "OR" | undefined;
|
|
168
168
|
value: string | number | boolean | string[] | number[] | null;
|
|
169
169
|
field: string;
|
|
170
170
|
}, {
|
|
171
171
|
connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
|
|
172
172
|
field: convex_values0.VString<string, "required">;
|
|
173
|
-
operator: convex_values0.VUnion<"
|
|
173
|
+
operator: convex_values0.VUnion<"eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined, [convex_values0.VLiteral<"lt", "required">, convex_values0.VLiteral<"lte", "required">, convex_values0.VLiteral<"gt", "required">, convex_values0.VLiteral<"gte", "required">, convex_values0.VLiteral<"eq", "required">, convex_values0.VLiteral<"in", "required">, convex_values0.VLiteral<"not_in", "required">, convex_values0.VLiteral<"ne", "required">, convex_values0.VLiteral<"contains", "required">, convex_values0.VLiteral<"starts_with", "required">, convex_values0.VLiteral<"ends_with", "required">], "optional", never>;
|
|
174
174
|
value: convex_values0.VUnion<string | number | boolean | string[] | number[] | null, [convex_values0.VString<string, "required">, convex_values0.VFloat64<number, "required">, convex_values0.VBoolean<boolean, "required">, convex_values0.VArray<string[], convex_values0.VString<string, "required">, "required">, convex_values0.VArray<number[], convex_values0.VFloat64<number, "required">, "required">, convex_values0.VNull<null, "required">], "required", never>;
|
|
175
|
-
}, "required", "
|
|
175
|
+
}, "required", "operator" | "value" | "field" | "connector">;
|
|
176
176
|
declare const adapterArgsValidator: convex_values0.VObject<{
|
|
177
177
|
limit?: number | undefined;
|
|
178
178
|
where?: {
|
|
179
|
-
operator?: "
|
|
179
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
180
180
|
connector?: "AND" | "OR" | undefined;
|
|
181
181
|
value: string | number | boolean | string[] | number[] | null;
|
|
182
182
|
field: string;
|
|
@@ -201,21 +201,21 @@ declare const adapterArgsValidator: convex_values0.VObject<{
|
|
|
201
201
|
field: convex_values0.VString<string, "required">;
|
|
202
202
|
}, "optional", "field" | "direction">;
|
|
203
203
|
where: convex_values0.VArray<{
|
|
204
|
-
operator?: "
|
|
204
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
205
205
|
connector?: "AND" | "OR" | undefined;
|
|
206
206
|
value: string | number | boolean | string[] | number[] | null;
|
|
207
207
|
field: string;
|
|
208
208
|
}[] | undefined, convex_values0.VObject<{
|
|
209
|
-
operator?: "
|
|
209
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
210
210
|
connector?: "AND" | "OR" | undefined;
|
|
211
211
|
value: string | number | boolean | string[] | number[] | null;
|
|
212
212
|
field: string;
|
|
213
213
|
}, {
|
|
214
214
|
connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
|
|
215
215
|
field: convex_values0.VString<string, "required">;
|
|
216
|
-
operator: convex_values0.VUnion<"
|
|
216
|
+
operator: convex_values0.VUnion<"eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined, [convex_values0.VLiteral<"lt", "required">, convex_values0.VLiteral<"lte", "required">, convex_values0.VLiteral<"gt", "required">, convex_values0.VLiteral<"gte", "required">, convex_values0.VLiteral<"eq", "required">, convex_values0.VLiteral<"in", "required">, convex_values0.VLiteral<"not_in", "required">, convex_values0.VLiteral<"ne", "required">, convex_values0.VLiteral<"contains", "required">, convex_values0.VLiteral<"starts_with", "required">, convex_values0.VLiteral<"ends_with", "required">], "optional", never>;
|
|
217
217
|
value: convex_values0.VUnion<string | number | boolean | string[] | number[] | null, [convex_values0.VString<string, "required">, convex_values0.VFloat64<number, "required">, convex_values0.VBoolean<boolean, "required">, convex_values0.VArray<string[], convex_values0.VString<string, "required">, "required">, convex_values0.VArray<number[], convex_values0.VFloat64<number, "required">, "required">, convex_values0.VNull<null, "required">], "required", never>;
|
|
218
|
-
}, "required", "
|
|
218
|
+
}, "required", "operator" | "value" | "field" | "connector">, "optional">;
|
|
219
219
|
}, "required", "limit" | "where" | "model" | "select" | "offset" | "sortBy" | "sortBy.field" | "sortBy.direction">;
|
|
220
220
|
declare const hasUniqueFields: (betterAuthSchema: BetterAuthDBSchema, model: string, input: Record<string, any>) => boolean;
|
|
221
221
|
declare const checkUniqueFields: <Schema$1 extends SchemaDefinition<any, any>>(ctx: GenericQueryCtx<GenericDataModel>, schema: Schema$1, betterAuthSchema: BetterAuthDBSchema, table: string, input: Record<string, any>, doc?: Record<string, any>) => Promise<void>;
|
|
@@ -244,7 +244,7 @@ declare const findOneHandler: (ctx: any, args: {
|
|
|
244
244
|
model: string;
|
|
245
245
|
select?: string[];
|
|
246
246
|
where?: any[];
|
|
247
|
-
}, schema: Schema, betterAuthSchema: any) => Promise<
|
|
247
|
+
}, schema: Schema, betterAuthSchema: any) => Promise<convex_server24.GenericDocument | null>;
|
|
248
248
|
declare const findManyHandler: (ctx: any, args: {
|
|
249
249
|
model: string;
|
|
250
250
|
paginationOpts: any;
|
|
@@ -255,7 +255,7 @@ declare const findManyHandler: (ctx: any, args: {
|
|
|
255
255
|
field: string;
|
|
256
256
|
};
|
|
257
257
|
where?: any[];
|
|
258
|
-
}, schema: Schema, betterAuthSchema: any) => Promise<
|
|
258
|
+
}, schema: Schema, betterAuthSchema: any) => Promise<convex_server24.PaginationResult<convex_server24.GenericDocument>>;
|
|
259
259
|
declare const updateOneHandler: (ctx: any, args: {
|
|
260
260
|
input: {
|
|
261
261
|
model: string;
|
|
@@ -278,8 +278,8 @@ declare const updateManyHandler: (ctx: any, args: {
|
|
|
278
278
|
count: number;
|
|
279
279
|
ids: any[];
|
|
280
280
|
isDone: boolean;
|
|
281
|
-
continueCursor:
|
|
282
|
-
splitCursor?:
|
|
281
|
+
continueCursor: convex_server24.Cursor;
|
|
282
|
+
splitCursor?: convex_server24.Cursor | null;
|
|
283
283
|
pageStatus?: "SplitRecommended" | "SplitRequired" | null;
|
|
284
284
|
}>;
|
|
285
285
|
declare const deleteOneHandler: (ctx: any, args: {
|
|
@@ -290,7 +290,7 @@ declare const deleteOneHandler: (ctx: any, args: {
|
|
|
290
290
|
beforeDeleteHandle?: string;
|
|
291
291
|
skipBeforeHooks?: boolean;
|
|
292
292
|
onDeleteHandle?: string;
|
|
293
|
-
}, schema: Schema, betterAuthSchema: any) => Promise<
|
|
293
|
+
}, schema: Schema, betterAuthSchema: any) => Promise<convex_server24.GenericDocument | undefined>;
|
|
294
294
|
declare const deleteManyHandler: (ctx: any, args: {
|
|
295
295
|
input: {
|
|
296
296
|
model: string;
|
|
@@ -304,8 +304,8 @@ declare const deleteManyHandler: (ctx: any, args: {
|
|
|
304
304
|
count: number;
|
|
305
305
|
ids: any[];
|
|
306
306
|
isDone: boolean;
|
|
307
|
-
continueCursor:
|
|
308
|
-
splitCursor?:
|
|
307
|
+
continueCursor: convex_server24.Cursor;
|
|
308
|
+
splitCursor?: convex_server24.Cursor | null;
|
|
309
309
|
pageStatus?: "SplitRecommended" | "SplitRequired" | null;
|
|
310
310
|
}>;
|
|
311
311
|
declare const createApi: <Schema$1 extends SchemaDefinition<any, any>>(schema: Schema$1, createAuth: CreateAuth, options?: {
|
|
@@ -313,7 +313,7 @@ declare const createApi: <Schema$1 extends SchemaDefinition<any, any>>(schema: S
|
|
|
313
313
|
/** Skip input validation for smaller generated types. Since these are internal functions, validation is optional. */
|
|
314
314
|
skipValidation?: boolean;
|
|
315
315
|
}) => {
|
|
316
|
-
create:
|
|
316
|
+
create: convex_server24.RegisteredMutation<"internal", {
|
|
317
317
|
select?: string[] | undefined;
|
|
318
318
|
beforeCreateHandle?: string | undefined;
|
|
319
319
|
onCreateHandle?: string | undefined;
|
|
@@ -329,38 +329,38 @@ declare const createApi: <Schema$1 extends SchemaDefinition<any, any>>(schema: S
|
|
|
329
329
|
model: string;
|
|
330
330
|
};
|
|
331
331
|
}, Promise<any>>;
|
|
332
|
-
deleteMany:
|
|
332
|
+
deleteMany: convex_server24.RegisteredMutation<"internal", {
|
|
333
333
|
beforeDeleteHandle?: string | undefined;
|
|
334
334
|
onDeleteHandle?: string | undefined;
|
|
335
|
+
paginationOpts: {
|
|
336
|
+
id?: number;
|
|
337
|
+
endCursor?: string | null;
|
|
338
|
+
maximumRowsRead?: number;
|
|
339
|
+
maximumBytesRead?: number;
|
|
340
|
+
numItems: number;
|
|
341
|
+
cursor: string | null;
|
|
342
|
+
};
|
|
335
343
|
input: {
|
|
336
344
|
where?: any[] | undefined;
|
|
337
345
|
model: string;
|
|
338
346
|
} | {
|
|
339
347
|
where?: {
|
|
340
|
-
operator?: "
|
|
348
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
341
349
|
connector?: "AND" | "OR" | undefined;
|
|
342
350
|
value: string | number | boolean | string[] | number[] | null;
|
|
343
351
|
field: string;
|
|
344
352
|
}[] | undefined;
|
|
345
353
|
model: string;
|
|
346
354
|
};
|
|
347
|
-
paginationOpts: {
|
|
348
|
-
id?: number;
|
|
349
|
-
endCursor?: string | null;
|
|
350
|
-
maximumRowsRead?: number;
|
|
351
|
-
maximumBytesRead?: number;
|
|
352
|
-
numItems: number;
|
|
353
|
-
cursor: string | null;
|
|
354
|
-
};
|
|
355
355
|
}, Promise<{
|
|
356
356
|
count: number;
|
|
357
357
|
ids: any[];
|
|
358
358
|
isDone: boolean;
|
|
359
|
-
continueCursor:
|
|
360
|
-
splitCursor?:
|
|
359
|
+
continueCursor: convex_server24.Cursor;
|
|
360
|
+
splitCursor?: convex_server24.Cursor | null;
|
|
361
361
|
pageStatus?: "SplitRecommended" | "SplitRequired" | null;
|
|
362
362
|
}>>;
|
|
363
|
-
deleteOne:
|
|
363
|
+
deleteOne: convex_server24.RegisteredMutation<"internal", {
|
|
364
364
|
beforeDeleteHandle?: string | undefined;
|
|
365
365
|
onDeleteHandle?: string | undefined;
|
|
366
366
|
input: {
|
|
@@ -368,19 +368,19 @@ declare const createApi: <Schema$1 extends SchemaDefinition<any, any>>(schema: S
|
|
|
368
368
|
model: string;
|
|
369
369
|
} | {
|
|
370
370
|
where?: {
|
|
371
|
-
operator?: "
|
|
371
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
372
372
|
connector?: "AND" | "OR" | undefined;
|
|
373
373
|
value: string | number | boolean | string[] | number[] | null;
|
|
374
374
|
field: string;
|
|
375
375
|
}[] | undefined;
|
|
376
376
|
model: string;
|
|
377
377
|
};
|
|
378
|
-
}, Promise<
|
|
379
|
-
findMany:
|
|
378
|
+
}, Promise<convex_server24.GenericDocument | undefined>>;
|
|
379
|
+
findMany: convex_server24.RegisteredQuery<"internal", {
|
|
380
380
|
limit?: number | undefined;
|
|
381
381
|
join?: any;
|
|
382
382
|
where?: {
|
|
383
|
-
operator?: "
|
|
383
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
384
384
|
connector?: "AND" | "OR" | undefined;
|
|
385
385
|
value: string | number | boolean | string[] | number[] | null;
|
|
386
386
|
field: string;
|
|
@@ -399,28 +399,36 @@ declare const createApi: <Schema$1 extends SchemaDefinition<any, any>>(schema: S
|
|
|
399
399
|
cursor: string | null;
|
|
400
400
|
};
|
|
401
401
|
model: string;
|
|
402
|
-
}, Promise<
|
|
403
|
-
findOne:
|
|
402
|
+
}, Promise<convex_server24.PaginationResult<convex_server24.GenericDocument>>>;
|
|
403
|
+
findOne: convex_server24.RegisteredQuery<"internal", {
|
|
404
404
|
join?: any;
|
|
405
405
|
where?: {
|
|
406
|
-
operator?: "
|
|
406
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
407
407
|
connector?: "AND" | "OR" | undefined;
|
|
408
408
|
value: string | number | boolean | string[] | number[] | null;
|
|
409
409
|
field: string;
|
|
410
410
|
}[] | undefined;
|
|
411
411
|
select?: string[] | undefined;
|
|
412
412
|
model: string;
|
|
413
|
-
}, Promise<
|
|
414
|
-
updateMany:
|
|
413
|
+
}, Promise<convex_server24.GenericDocument | null>>;
|
|
414
|
+
updateMany: convex_server24.RegisteredMutation<"internal", {
|
|
415
415
|
beforeUpdateHandle?: string | undefined;
|
|
416
416
|
onUpdateHandle?: string | undefined;
|
|
417
|
+
paginationOpts: {
|
|
418
|
+
id?: number;
|
|
419
|
+
endCursor?: string | null;
|
|
420
|
+
maximumRowsRead?: number;
|
|
421
|
+
maximumBytesRead?: number;
|
|
422
|
+
numItems: number;
|
|
423
|
+
cursor: string | null;
|
|
424
|
+
};
|
|
417
425
|
input: {
|
|
418
426
|
where?: any[] | undefined;
|
|
419
427
|
update: any;
|
|
420
428
|
model: string;
|
|
421
429
|
} | {
|
|
422
430
|
where?: {
|
|
423
|
-
operator?: "
|
|
431
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
424
432
|
connector?: "AND" | "OR" | undefined;
|
|
425
433
|
value: string | number | boolean | string[] | number[] | null;
|
|
426
434
|
field: string;
|
|
@@ -432,23 +440,15 @@ declare const createApi: <Schema$1 extends SchemaDefinition<any, any>>(schema: S
|
|
|
432
440
|
};
|
|
433
441
|
model: string;
|
|
434
442
|
};
|
|
435
|
-
paginationOpts: {
|
|
436
|
-
id?: number;
|
|
437
|
-
endCursor?: string | null;
|
|
438
|
-
maximumRowsRead?: number;
|
|
439
|
-
maximumBytesRead?: number;
|
|
440
|
-
numItems: number;
|
|
441
|
-
cursor: string | null;
|
|
442
|
-
};
|
|
443
443
|
}, Promise<{
|
|
444
444
|
count: number;
|
|
445
445
|
ids: any[];
|
|
446
446
|
isDone: boolean;
|
|
447
|
-
continueCursor:
|
|
448
|
-
splitCursor?:
|
|
447
|
+
continueCursor: convex_server24.Cursor;
|
|
448
|
+
splitCursor?: convex_server24.Cursor | null;
|
|
449
449
|
pageStatus?: "SplitRecommended" | "SplitRequired" | null;
|
|
450
450
|
}>>;
|
|
451
|
-
updateOne:
|
|
451
|
+
updateOne: convex_server24.RegisteredMutation<"internal", {
|
|
452
452
|
beforeUpdateHandle?: string | undefined;
|
|
453
453
|
onUpdateHandle?: string | undefined;
|
|
454
454
|
input: {
|
|
@@ -457,7 +457,7 @@ declare const createApi: <Schema$1 extends SchemaDefinition<any, any>>(schema: S
|
|
|
457
457
|
model: string;
|
|
458
458
|
} | {
|
|
459
459
|
where?: {
|
|
460
|
-
operator?: "
|
|
460
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
461
461
|
connector?: "AND" | "OR" | undefined;
|
|
462
462
|
value: string | number | boolean | string[] | number[] | null;
|
|
463
463
|
field: string;
|
|
@@ -470,8 +470,8 @@ declare const createApi: <Schema$1 extends SchemaDefinition<any, any>>(schema: S
|
|
|
470
470
|
model: string;
|
|
471
471
|
};
|
|
472
472
|
}, Promise<any>>;
|
|
473
|
-
getLatestJwks:
|
|
474
|
-
rotateKeys:
|
|
473
|
+
getLatestJwks: convex_server24.RegisteredAction<"internal", {}, Promise<any>>;
|
|
474
|
+
rotateKeys: convex_server24.RegisteredAction<"internal", {}, Promise<any>>;
|
|
475
475
|
};
|
|
476
476
|
//#endregion
|
|
477
477
|
//#region src/auth/helpers.d.ts
|
package/dist/auth/index.js
CHANGED
|
@@ -630,7 +630,7 @@ const httpAdapter = (ctx, { authFunctions, debugLogs, triggers }) => {
|
|
|
630
630
|
});
|
|
631
631
|
},
|
|
632
632
|
createSchema: async ({ file, tables }) => {
|
|
633
|
-
const { createSchema } = await import("../create-schema-
|
|
633
|
+
const { createSchema } = await import("../create-schema-DzQEFNJW.js");
|
|
634
634
|
return createSchema({
|
|
635
635
|
file,
|
|
636
636
|
tables
|
|
@@ -766,7 +766,7 @@ const dbAdapter = (ctx, createAuthOptions, { authFunctions, debugLogs, schema, t
|
|
|
766
766
|
}, schema, betterAuthSchema);
|
|
767
767
|
},
|
|
768
768
|
createSchema: async ({ file, tables }) => {
|
|
769
|
-
const { createSchema } = await import("../create-schema-
|
|
769
|
+
const { createSchema } = await import("../create-schema-DzQEFNJW.js");
|
|
770
770
|
return createSchema({
|
|
771
771
|
file,
|
|
772
772
|
tables
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { AuthClient } from "@convex-dev/better-auth/react";
|
|
3
2
|
import { ConvexReactClient } from "convex/react";
|
|
4
3
|
import { ReactNode } from "react";
|
|
5
4
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
5
|
+
import { AuthClient, AuthClient as AuthClient$1 } from "@convex-dev/better-auth/react";
|
|
6
6
|
|
|
7
7
|
//#region src/auth-client/convex-auth-provider.d.ts
|
|
8
8
|
type ConvexAuthProviderProps = {
|
|
@@ -10,7 +10,7 @@ type ConvexAuthProviderProps = {
|
|
|
10
10
|
/** Convex client instance */
|
|
11
11
|
client: ConvexReactClient;
|
|
12
12
|
/** Better Auth client instance */
|
|
13
|
-
authClient: AuthClient;
|
|
13
|
+
authClient: AuthClient$1;
|
|
14
14
|
/** Initial session token (from SSR) */
|
|
15
15
|
initialToken?: string;
|
|
16
16
|
/** Callback when mutation called while unauthorized */
|
|
@@ -19,10 +19,12 @@ type ConvexAuthProviderProps = {
|
|
|
19
19
|
onQueryUnauthorized?: (info: {
|
|
20
20
|
queryName: string;
|
|
21
21
|
}) => void;
|
|
22
|
+
/** Custom function to detect UNAUTHORIZED errors. Default checks code property. */
|
|
23
|
+
isUnauthorized?: (error: unknown) => boolean;
|
|
22
24
|
};
|
|
23
25
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
+
* Unified auth provider for Convex + Better Auth.
|
|
27
|
+
* Handles token sync, HMR persistence, and auth callbacks.
|
|
26
28
|
*/
|
|
27
29
|
declare function ConvexAuthProvider({
|
|
28
30
|
children,
|
|
@@ -30,7 +32,8 @@ declare function ConvexAuthProvider({
|
|
|
30
32
|
authClient,
|
|
31
33
|
initialToken,
|
|
32
34
|
onMutationUnauthorized,
|
|
33
|
-
onQueryUnauthorized
|
|
35
|
+
onQueryUnauthorized,
|
|
36
|
+
isUnauthorized
|
|
34
37
|
}: ConvexAuthProviderProps): react_jsx_runtime0.JSX.Element;
|
|
35
38
|
//#endregion
|
|
36
|
-
export { ConvexAuthProvider, ConvexAuthProviderProps };
|
|
39
|
+
export { type AuthClient, ConvexAuthProvider, ConvexAuthProviderProps };
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { _ as defaultIsUnauthorized, c as persistToken, f as useAuthStore, g as CRPCClientError, p as useAuthValue, s as getPersistedToken, t as AuthProvider } from "../auth-store-DANFmEdk.js";
|
|
3
3
|
import { c } from "react/compiler-runtime";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { ConvexProviderWithAuth } from "convex/react";
|
|
5
|
+
import { useCallback, useEffect, useMemo } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
|
|
7
8
|
//#region src/auth-client/convex-auth-provider.tsx
|
|
9
|
+
/**
|
|
10
|
+
* Unified Convex + Better Auth provider
|
|
11
|
+
*/
|
|
8
12
|
const defaultMutationHandler = () => {
|
|
9
13
|
throw new CRPCClientError({
|
|
10
14
|
code: "UNAUTHORIZED",
|
|
@@ -12,12 +16,12 @@ const defaultMutationHandler = () => {
|
|
|
12
16
|
});
|
|
13
17
|
};
|
|
14
18
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
19
|
+
* Unified auth provider for Convex + Better Auth.
|
|
20
|
+
* Handles token sync, HMR persistence, and auth callbacks.
|
|
17
21
|
*/
|
|
18
22
|
function ConvexAuthProvider(t0) {
|
|
19
|
-
const $ = c(
|
|
20
|
-
const { children, client, authClient, initialToken, onMutationUnauthorized, onQueryUnauthorized } = t0;
|
|
23
|
+
const $ = c(17);
|
|
24
|
+
const { children, client, authClient, initialToken, onMutationUnauthorized, onQueryUnauthorized, isUnauthorized } = t0;
|
|
21
25
|
let t1;
|
|
22
26
|
if ($[0] !== initialToken) {
|
|
23
27
|
t1 = initialToken ?? getPersistedToken();
|
|
@@ -26,55 +30,145 @@ function ConvexAuthProvider(t0) {
|
|
|
26
30
|
} else t1 = $[1];
|
|
27
31
|
const effectiveToken = t1;
|
|
28
32
|
if (effectiveToken) persistToken(effectiveToken);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
let t3;
|
|
37
|
-
if ($[2] !== t2) {
|
|
38
|
-
t3 = {
|
|
33
|
+
const useAuth = useCreateConvexAuth(authClient);
|
|
34
|
+
useOTTHandler(authClient);
|
|
35
|
+
const t2 = client;
|
|
36
|
+
const t3 = effectiveToken ?? null;
|
|
37
|
+
let t4;
|
|
38
|
+
if ($[2] !== t3) {
|
|
39
|
+
t4 = {
|
|
39
40
|
isLoading: true,
|
|
40
|
-
token:
|
|
41
|
+
token: t3
|
|
41
42
|
};
|
|
42
|
-
$[2] =
|
|
43
|
-
$[3] =
|
|
44
|
-
} else
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
$[2] = t3;
|
|
44
|
+
$[3] = t4;
|
|
45
|
+
} else t4 = $[3];
|
|
46
|
+
const t5 = isUnauthorized ?? defaultIsUnauthorized;
|
|
47
|
+
const t6 = onMutationUnauthorized ?? defaultMutationHandler;
|
|
48
|
+
const t7 = onQueryUnauthorized ?? _temp;
|
|
49
|
+
let t8;
|
|
50
|
+
if ($[4] !== authClient) {
|
|
51
|
+
t8 = /* @__PURE__ */ jsx(AuthSyncEffect, { authClient });
|
|
52
|
+
$[4] = authClient;
|
|
53
|
+
$[5] = t8;
|
|
54
|
+
} else t8 = $[5];
|
|
55
|
+
let t9;
|
|
56
|
+
if ($[6] !== children || $[7] !== t4 || $[8] !== t5 || $[9] !== t6 || $[10] !== t7 || $[11] !== t8) {
|
|
57
|
+
t9 = /* @__PURE__ */ jsxs(AuthProvider, {
|
|
58
|
+
initialValues: t4,
|
|
59
|
+
isUnauthorized: t5,
|
|
60
|
+
onMutationUnauthorized: t6,
|
|
61
|
+
onQueryUnauthorized: t7,
|
|
62
|
+
children: [t8, children]
|
|
54
63
|
});
|
|
55
|
-
$[
|
|
56
|
-
$[
|
|
57
|
-
$[
|
|
58
|
-
$[
|
|
59
|
-
$[
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
$[6] = children;
|
|
65
|
+
$[7] = t4;
|
|
66
|
+
$[8] = t5;
|
|
67
|
+
$[9] = t6;
|
|
68
|
+
$[10] = t7;
|
|
69
|
+
$[11] = t8;
|
|
70
|
+
$[12] = t9;
|
|
71
|
+
} else t9 = $[12];
|
|
72
|
+
let t10;
|
|
73
|
+
if ($[13] !== t2 || $[14] !== t9 || $[15] !== useAuth) {
|
|
74
|
+
t10 = /* @__PURE__ */ jsx(ConvexProviderWithAuth, {
|
|
75
|
+
client: t2,
|
|
76
|
+
useAuth,
|
|
77
|
+
children: t9
|
|
68
78
|
});
|
|
69
|
-
$[
|
|
70
|
-
$[
|
|
71
|
-
$[
|
|
72
|
-
$[
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return t7;
|
|
79
|
+
$[13] = t2;
|
|
80
|
+
$[14] = t9;
|
|
81
|
+
$[15] = useAuth;
|
|
82
|
+
$[16] = t10;
|
|
83
|
+
} else t10 = $[16];
|
|
84
|
+
return t10;
|
|
76
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Syncs Better Auth session to auth-store.
|
|
88
|
+
* Automatically handles login/logout token updates.
|
|
89
|
+
*/
|
|
77
90
|
function _temp() {}
|
|
91
|
+
function AuthSyncEffect({ authClient }) {
|
|
92
|
+
const session = authClient.useSession();
|
|
93
|
+
const authStore = useAuthStore();
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
if (!session.isPending) {
|
|
96
|
+
const token = session.data?.session.token ?? null;
|
|
97
|
+
if (token !== authStore.get("token")) {
|
|
98
|
+
authStore.set("token", token);
|
|
99
|
+
persistToken(token);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}, [
|
|
103
|
+
session.data,
|
|
104
|
+
session.isPending,
|
|
105
|
+
authStore
|
|
106
|
+
]);
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Creates useAuth hook for ConvexProviderWithAuth.
|
|
111
|
+
* Uses auth-store token as single source of truth.
|
|
112
|
+
*/
|
|
113
|
+
function useCreateConvexAuth(authClient) {
|
|
114
|
+
return useMemo(() => function useConvexAuth$1() {
|
|
115
|
+
const { data: session, isPending: isSessionPending } = authClient.useSession();
|
|
116
|
+
const token = useAuthValue("token");
|
|
117
|
+
const sessionId = session?.session?.id;
|
|
118
|
+
const fetchAccessToken = useCallback(async ({ forceRefreshToken = false } = {}) => {
|
|
119
|
+
if (token && !forceRefreshToken) return token;
|
|
120
|
+
try {
|
|
121
|
+
const { data } = await authClient.convex.token();
|
|
122
|
+
return data?.token || null;
|
|
123
|
+
} catch {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
}, [sessionId, token]);
|
|
127
|
+
return useMemo(() => ({
|
|
128
|
+
isLoading: isSessionPending,
|
|
129
|
+
isAuthenticated: session !== null,
|
|
130
|
+
fetchAccessToken
|
|
131
|
+
}), [
|
|
132
|
+
isSessionPending,
|
|
133
|
+
sessionId,
|
|
134
|
+
fetchAccessToken
|
|
135
|
+
]);
|
|
136
|
+
}, [authClient]);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Handles cross-domain one-time token (OTT) verification.
|
|
140
|
+
*/
|
|
141
|
+
function useOTTHandler(authClient) {
|
|
142
|
+
const $ = c(3);
|
|
143
|
+
let t0;
|
|
144
|
+
let t1;
|
|
145
|
+
if ($[0] !== authClient) {
|
|
146
|
+
t0 = () => {
|
|
147
|
+
(async () => {
|
|
148
|
+
const url = new URL(window.location?.href);
|
|
149
|
+
const token = url.searchParams.get("ott");
|
|
150
|
+
if (token) {
|
|
151
|
+
const authClientWithCrossDomain = authClient;
|
|
152
|
+
url.searchParams.delete("ott");
|
|
153
|
+
const session = (await authClientWithCrossDomain.crossDomain.oneTimeToken.verify({ token })).data?.session;
|
|
154
|
+
if (session) {
|
|
155
|
+
await authClient.getSession({ fetchOptions: { headers: { Authorization: `Bearer ${session.token}` } } });
|
|
156
|
+
authClientWithCrossDomain.updateSession();
|
|
157
|
+
}
|
|
158
|
+
window.history.replaceState({}, "", url);
|
|
159
|
+
}
|
|
160
|
+
})();
|
|
161
|
+
};
|
|
162
|
+
t1 = [authClient];
|
|
163
|
+
$[0] = authClient;
|
|
164
|
+
$[1] = t0;
|
|
165
|
+
$[2] = t1;
|
|
166
|
+
} else {
|
|
167
|
+
t0 = $[1];
|
|
168
|
+
t1 = $[2];
|
|
169
|
+
}
|
|
170
|
+
useEffect(t0, t1);
|
|
171
|
+
}
|
|
78
172
|
|
|
79
173
|
//#endregion
|
|
80
174
|
export { ConvexAuthProvider };
|
|
@@ -3,20 +3,20 @@ import { GetTokenOptions } from "@convex-dev/better-auth/utils";
|
|
|
3
3
|
|
|
4
4
|
//#region src/auth-nextjs/index.d.ts
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
type
|
|
8
|
-
/** Enable JWT caching
|
|
9
|
-
|
|
6
|
+
/** Auth options for server-side calls. */
|
|
7
|
+
type AuthOptions = {
|
|
8
|
+
/** Enable/disable JWT caching. Default: true */
|
|
9
|
+
jwtCache?: boolean;
|
|
10
|
+
/** Custom function to detect UNAUTHORIZED errors. Default checks code property. */
|
|
11
|
+
isUnauthorized?: (error: unknown) => boolean;
|
|
10
12
|
/** Expiration tolerance in seconds. */
|
|
11
13
|
expirationToleranceSeconds?: number;
|
|
12
|
-
/** Custom function to detect auth errors. Default checks for "auth" in error message. */
|
|
13
|
-
isAuthError?: (error: unknown) => boolean;
|
|
14
14
|
};
|
|
15
15
|
type ConvexBetterAuthOptions<TApi> = Omit<GetTokenOptions, 'jwtCache'> & {
|
|
16
16
|
api: TApi;
|
|
17
17
|
convexSiteUrl: string;
|
|
18
|
-
/** JWT caching
|
|
19
|
-
|
|
18
|
+
/** Auth options. JWT caching is enabled by default (set `auth.jwtCache: false` to disable). */
|
|
19
|
+
auth?: AuthOptions;
|
|
20
20
|
meta: CallerMeta;
|
|
21
21
|
};
|
|
22
22
|
/**
|
|
@@ -28,8 +28,8 @@ type ConvexBetterAuthOptions<TApi> = Omit<GetTokenOptions, 'jwtCache'> & {
|
|
|
28
28
|
* export const { createContext, createCaller, handler } = convexBetterAuth({
|
|
29
29
|
* api,
|
|
30
30
|
* convexSiteUrl: env.NEXT_PUBLIC_CONVEX_SITE_URL,
|
|
31
|
-
*
|
|
32
|
-
* });
|
|
31
|
+
* meta,
|
|
32
|
+
* }); // JWT caching enabled by default
|
|
33
33
|
*
|
|
34
34
|
* // rsc.tsx
|
|
35
35
|
* const createRSCContext = cache(async () => {
|