better-convex 0.8.0 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/index.d.ts +80 -75
- package/dist/auth/index.js +16 -1
- package/dist/plugins/ratelimit/index.js +23 -17
- package/package.json +1 -1
package/dist/auth/index.d.ts
CHANGED
|
@@ -182,28 +182,28 @@ type AdapterPaginationOptions = PaginationOptions & {
|
|
|
182
182
|
};
|
|
183
183
|
declare const adapterWhereValidator: convex_values0.VObject<{
|
|
184
184
|
connector?: "AND" | "OR" | undefined;
|
|
185
|
-
operator?: "
|
|
186
|
-
value: string | number | boolean | string[] | number[] | null;
|
|
185
|
+
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
187
186
|
field: string;
|
|
187
|
+
value: string | number | boolean | string[] | number[] | null;
|
|
188
188
|
}, {
|
|
189
189
|
connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
|
|
190
190
|
field: convex_values0.VString<string, "required">;
|
|
191
|
-
operator: convex_values0.VUnion<"
|
|
191
|
+
operator: convex_values0.VUnion<"lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "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>;
|
|
192
192
|
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>;
|
|
193
|
-
}, "required", "
|
|
193
|
+
}, "required", "connector" | "field" | "operator" | "value">;
|
|
194
194
|
declare const adapterArgsValidator: convex_values0.VObject<{
|
|
195
195
|
limit?: number | undefined;
|
|
196
196
|
select?: string[] | undefined;
|
|
197
197
|
offset?: number | undefined;
|
|
198
198
|
sortBy?: {
|
|
199
|
-
direction: "asc" | "desc";
|
|
200
199
|
field: string;
|
|
200
|
+
direction: "asc" | "desc";
|
|
201
201
|
} | undefined;
|
|
202
202
|
where?: {
|
|
203
203
|
connector?: "AND" | "OR" | undefined;
|
|
204
|
-
operator?: "
|
|
205
|
-
value: string | number | boolean | string[] | number[] | null;
|
|
204
|
+
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
206
205
|
field: string;
|
|
206
|
+
value: string | number | boolean | string[] | number[] | null;
|
|
207
207
|
}[] | undefined;
|
|
208
208
|
model: string;
|
|
209
209
|
}, {
|
|
@@ -212,29 +212,29 @@ declare const adapterArgsValidator: convex_values0.VObject<{
|
|
|
212
212
|
offset: convex_values0.VFloat64<number | undefined, "optional">;
|
|
213
213
|
select: convex_values0.VArray<string[] | undefined, convex_values0.VString<string, "required">, "optional">;
|
|
214
214
|
sortBy: convex_values0.VObject<{
|
|
215
|
-
direction: "asc" | "desc";
|
|
216
215
|
field: string;
|
|
216
|
+
direction: "asc" | "desc";
|
|
217
217
|
} | undefined, {
|
|
218
218
|
direction: convex_values0.VUnion<"asc" | "desc", [convex_values0.VLiteral<"asc", "required">, convex_values0.VLiteral<"desc", "required">], "required", never>;
|
|
219
219
|
field: convex_values0.VString<string, "required">;
|
|
220
|
-
}, "optional", "
|
|
220
|
+
}, "optional", "field" | "direction">;
|
|
221
221
|
where: convex_values0.VArray<{
|
|
222
222
|
connector?: "AND" | "OR" | undefined;
|
|
223
|
-
operator?: "
|
|
224
|
-
value: string | number | boolean | string[] | number[] | null;
|
|
223
|
+
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
225
224
|
field: string;
|
|
225
|
+
value: string | number | boolean | string[] | number[] | null;
|
|
226
226
|
}[] | undefined, convex_values0.VObject<{
|
|
227
227
|
connector?: "AND" | "OR" | undefined;
|
|
228
|
-
operator?: "
|
|
229
|
-
value: string | number | boolean | string[] | number[] | null;
|
|
228
|
+
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
230
229
|
field: string;
|
|
230
|
+
value: string | number | boolean | string[] | number[] | null;
|
|
231
231
|
}, {
|
|
232
232
|
connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
|
|
233
233
|
field: convex_values0.VString<string, "required">;
|
|
234
|
-
operator: convex_values0.VUnion<"
|
|
234
|
+
operator: convex_values0.VUnion<"lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "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>;
|
|
235
235
|
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>;
|
|
236
|
-
}, "required", "
|
|
237
|
-
}, "required", "limit" | "model" | "select" | "offset" | "sortBy" | "where" | "sortBy.
|
|
236
|
+
}, "required", "connector" | "field" | "operator" | "value">, "optional">;
|
|
237
|
+
}, "required", "limit" | "model" | "select" | "offset" | "sortBy" | "where" | "sortBy.field" | "sortBy.direction">;
|
|
238
238
|
declare const hasUniqueFields: (betterAuthSchema: BetterAuthDBSchema, model: string, input: Record<string, any>) => boolean;
|
|
239
239
|
declare const checkUniqueFields: <Schema extends SchemaDefinition<any, any>>(ctx: GenericQueryCtx<GenericDataModel>, schema: Schema, betterAuthSchema: BetterAuthDBSchema, table: string, input: Record<string, any>, doc?: Record<string, any>) => Promise<void>;
|
|
240
240
|
declare const selectFields: <T extends TableNamesInDataModel<GenericDataModel>, D extends DocumentByName<GenericDataModel, T>>(doc: D | null, select?: string[]) => Promise<D | null>;
|
|
@@ -359,26 +359,26 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
|
|
|
359
359
|
};
|
|
360
360
|
}, Promise<any>>;
|
|
361
361
|
deleteMany: convex_server0.RegisteredMutation<"internal", {
|
|
362
|
+
paginationOpts: {
|
|
363
|
+
id?: number;
|
|
364
|
+
endCursor?: string | null;
|
|
365
|
+
maximumRowsRead?: number;
|
|
366
|
+
maximumBytesRead?: number;
|
|
367
|
+
numItems: number;
|
|
368
|
+
cursor: string | null;
|
|
369
|
+
};
|
|
362
370
|
input: {
|
|
363
371
|
where?: {
|
|
364
372
|
connector?: "AND" | "OR" | undefined;
|
|
365
|
-
operator?: "
|
|
366
|
-
value: string | number | boolean | string[] | number[] | null;
|
|
373
|
+
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
367
374
|
field: string;
|
|
375
|
+
value: string | number | boolean | string[] | number[] | null;
|
|
368
376
|
}[] | undefined;
|
|
369
377
|
model: string;
|
|
370
378
|
} | {
|
|
371
379
|
where?: any[] | undefined;
|
|
372
380
|
model: string;
|
|
373
381
|
};
|
|
374
|
-
paginationOpts: {
|
|
375
|
-
id?: number;
|
|
376
|
-
endCursor?: string | null;
|
|
377
|
-
maximumRowsRead?: number;
|
|
378
|
-
maximumBytesRead?: number;
|
|
379
|
-
numItems: number;
|
|
380
|
-
cursor: string | null;
|
|
381
|
-
};
|
|
382
382
|
}, Promise<{
|
|
383
383
|
count: number;
|
|
384
384
|
ids: any[];
|
|
@@ -391,9 +391,9 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
|
|
|
391
391
|
input: {
|
|
392
392
|
where?: {
|
|
393
393
|
connector?: "AND" | "OR" | undefined;
|
|
394
|
-
operator?: "
|
|
395
|
-
value: string | number | boolean | string[] | number[] | null;
|
|
394
|
+
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
396
395
|
field: string;
|
|
396
|
+
value: string | number | boolean | string[] | number[] | null;
|
|
397
397
|
}[] | undefined;
|
|
398
398
|
model: string;
|
|
399
399
|
} | {
|
|
@@ -406,14 +406,14 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
|
|
|
406
406
|
join?: any;
|
|
407
407
|
offset?: number | undefined;
|
|
408
408
|
sortBy?: {
|
|
409
|
-
direction: "asc" | "desc";
|
|
410
409
|
field: string;
|
|
410
|
+
direction: "asc" | "desc";
|
|
411
411
|
} | undefined;
|
|
412
412
|
where?: {
|
|
413
413
|
connector?: "AND" | "OR" | undefined;
|
|
414
|
-
operator?: "
|
|
415
|
-
value: string | number | boolean | string[] | number[] | null;
|
|
414
|
+
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
416
415
|
field: string;
|
|
416
|
+
value: string | number | boolean | string[] | number[] | null;
|
|
417
417
|
}[] | undefined;
|
|
418
418
|
paginationOpts: {
|
|
419
419
|
id?: number;
|
|
@@ -430,19 +430,27 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
|
|
|
430
430
|
select?: string[] | undefined;
|
|
431
431
|
where?: {
|
|
432
432
|
connector?: "AND" | "OR" | undefined;
|
|
433
|
-
operator?: "
|
|
434
|
-
value: string | number | boolean | string[] | number[] | null;
|
|
433
|
+
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
435
434
|
field: string;
|
|
435
|
+
value: string | number | boolean | string[] | number[] | null;
|
|
436
436
|
}[] | undefined;
|
|
437
437
|
model: string;
|
|
438
438
|
}, Promise<convex_server0.GenericDocument | null>>;
|
|
439
439
|
updateMany: convex_server0.RegisteredMutation<"internal", {
|
|
440
|
+
paginationOpts: {
|
|
441
|
+
id?: number;
|
|
442
|
+
endCursor?: string | null;
|
|
443
|
+
maximumRowsRead?: number;
|
|
444
|
+
maximumBytesRead?: number;
|
|
445
|
+
numItems: number;
|
|
446
|
+
cursor: string | null;
|
|
447
|
+
};
|
|
440
448
|
input: {
|
|
441
449
|
where?: {
|
|
442
450
|
connector?: "AND" | "OR" | undefined;
|
|
443
|
-
operator?: "
|
|
444
|
-
value: string | number | boolean | string[] | number[] | null;
|
|
451
|
+
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
445
452
|
field: string;
|
|
453
|
+
value: string | number | boolean | string[] | number[] | null;
|
|
446
454
|
}[] | undefined;
|
|
447
455
|
update: {
|
|
448
456
|
[x: string]: unknown;
|
|
@@ -455,14 +463,6 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
|
|
|
455
463
|
update: any;
|
|
456
464
|
model: string;
|
|
457
465
|
};
|
|
458
|
-
paginationOpts: {
|
|
459
|
-
id?: number;
|
|
460
|
-
endCursor?: string | null;
|
|
461
|
-
maximumRowsRead?: number;
|
|
462
|
-
maximumBytesRead?: number;
|
|
463
|
-
numItems: number;
|
|
464
|
-
cursor: string | null;
|
|
465
|
-
};
|
|
466
466
|
}, Promise<{
|
|
467
467
|
count: number;
|
|
468
468
|
ids: any[];
|
|
@@ -475,9 +475,9 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
|
|
|
475
475
|
input: {
|
|
476
476
|
where?: {
|
|
477
477
|
connector?: "AND" | "OR" | undefined;
|
|
478
|
-
operator?: "
|
|
479
|
-
value: string | number | boolean | string[] | number[] | null;
|
|
478
|
+
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
480
479
|
field: string;
|
|
480
|
+
value: string | number | boolean | string[] | number[] | null;
|
|
481
481
|
}[] | undefined;
|
|
482
482
|
update: {
|
|
483
483
|
[x: string]: unknown;
|
|
@@ -19155,26 +19155,26 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
|
|
|
19155
19155
|
};
|
|
19156
19156
|
}, Promise<any>>;
|
|
19157
19157
|
deleteMany: convex_server0.RegisteredMutation<"internal", {
|
|
19158
|
+
paginationOpts: {
|
|
19159
|
+
id?: number;
|
|
19160
|
+
endCursor?: string | null;
|
|
19161
|
+
maximumRowsRead?: number;
|
|
19162
|
+
maximumBytesRead?: number;
|
|
19163
|
+
numItems: number;
|
|
19164
|
+
cursor: string | null;
|
|
19165
|
+
};
|
|
19158
19166
|
input: {
|
|
19159
19167
|
where?: {
|
|
19160
19168
|
connector?: "AND" | "OR" | undefined;
|
|
19161
|
-
operator?: "
|
|
19162
|
-
value: string | number | boolean | string[] | number[] | null;
|
|
19169
|
+
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
19163
19170
|
field: string;
|
|
19171
|
+
value: string | number | boolean | string[] | number[] | null;
|
|
19164
19172
|
}[] | undefined;
|
|
19165
19173
|
model: string;
|
|
19166
19174
|
} | {
|
|
19167
19175
|
where?: any[] | undefined;
|
|
19168
19176
|
model: string;
|
|
19169
19177
|
};
|
|
19170
|
-
paginationOpts: {
|
|
19171
|
-
id?: number;
|
|
19172
|
-
endCursor?: string | null;
|
|
19173
|
-
maximumRowsRead?: number;
|
|
19174
|
-
maximumBytesRead?: number;
|
|
19175
|
-
numItems: number;
|
|
19176
|
-
cursor: string | null;
|
|
19177
|
-
};
|
|
19178
19178
|
}, Promise<{
|
|
19179
19179
|
count: number;
|
|
19180
19180
|
ids: any[];
|
|
@@ -19187,9 +19187,9 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
|
|
|
19187
19187
|
input: {
|
|
19188
19188
|
where?: {
|
|
19189
19189
|
connector?: "AND" | "OR" | undefined;
|
|
19190
|
-
operator?: "
|
|
19191
|
-
value: string | number | boolean | string[] | number[] | null;
|
|
19190
|
+
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
19192
19191
|
field: string;
|
|
19192
|
+
value: string | number | boolean | string[] | number[] | null;
|
|
19193
19193
|
}[] | undefined;
|
|
19194
19194
|
model: string;
|
|
19195
19195
|
} | {
|
|
@@ -19202,14 +19202,14 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
|
|
|
19202
19202
|
join?: any;
|
|
19203
19203
|
offset?: number | undefined;
|
|
19204
19204
|
sortBy?: {
|
|
19205
|
-
direction: "asc" | "desc";
|
|
19206
19205
|
field: string;
|
|
19206
|
+
direction: "asc" | "desc";
|
|
19207
19207
|
} | undefined;
|
|
19208
19208
|
where?: {
|
|
19209
19209
|
connector?: "AND" | "OR" | undefined;
|
|
19210
|
-
operator?: "
|
|
19211
|
-
value: string | number | boolean | string[] | number[] | null;
|
|
19210
|
+
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
19212
19211
|
field: string;
|
|
19212
|
+
value: string | number | boolean | string[] | number[] | null;
|
|
19213
19213
|
}[] | undefined;
|
|
19214
19214
|
paginationOpts: {
|
|
19215
19215
|
id?: number;
|
|
@@ -19226,19 +19226,27 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
|
|
|
19226
19226
|
select?: string[] | undefined;
|
|
19227
19227
|
where?: {
|
|
19228
19228
|
connector?: "AND" | "OR" | undefined;
|
|
19229
|
-
operator?: "
|
|
19230
|
-
value: string | number | boolean | string[] | number[] | null;
|
|
19229
|
+
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
19231
19230
|
field: string;
|
|
19231
|
+
value: string | number | boolean | string[] | number[] | null;
|
|
19232
19232
|
}[] | undefined;
|
|
19233
19233
|
model: string;
|
|
19234
19234
|
}, Promise<convex_server0.GenericDocument | null>>;
|
|
19235
19235
|
updateMany: convex_server0.RegisteredMutation<"internal", {
|
|
19236
|
+
paginationOpts: {
|
|
19237
|
+
id?: number;
|
|
19238
|
+
endCursor?: string | null;
|
|
19239
|
+
maximumRowsRead?: number;
|
|
19240
|
+
maximumBytesRead?: number;
|
|
19241
|
+
numItems: number;
|
|
19242
|
+
cursor: string | null;
|
|
19243
|
+
};
|
|
19236
19244
|
input: {
|
|
19237
19245
|
where?: {
|
|
19238
19246
|
connector?: "AND" | "OR" | undefined;
|
|
19239
|
-
operator?: "
|
|
19240
|
-
value: string | number | boolean | string[] | number[] | null;
|
|
19247
|
+
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
19241
19248
|
field: string;
|
|
19249
|
+
value: string | number | boolean | string[] | number[] | null;
|
|
19242
19250
|
}[] | undefined;
|
|
19243
19251
|
update: {
|
|
19244
19252
|
[x: string]: unknown;
|
|
@@ -19251,14 +19259,6 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
|
|
|
19251
19259
|
update: any;
|
|
19252
19260
|
model: string;
|
|
19253
19261
|
};
|
|
19254
|
-
paginationOpts: {
|
|
19255
|
-
id?: number;
|
|
19256
|
-
endCursor?: string | null;
|
|
19257
|
-
maximumRowsRead?: number;
|
|
19258
|
-
maximumBytesRead?: number;
|
|
19259
|
-
numItems: number;
|
|
19260
|
-
cursor: string | null;
|
|
19261
|
-
};
|
|
19262
19262
|
}, Promise<{
|
|
19263
19263
|
count: number;
|
|
19264
19264
|
ids: any[];
|
|
@@ -19271,9 +19271,9 @@ declare const createAuthRuntime: <DataModel extends GenericDataModel, Schema ext
|
|
|
19271
19271
|
input: {
|
|
19272
19272
|
where?: {
|
|
19273
19273
|
connector?: "AND" | "OR" | undefined;
|
|
19274
|
-
operator?: "
|
|
19275
|
-
value: string | number | boolean | string[] | number[] | null;
|
|
19274
|
+
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
19276
19275
|
field: string;
|
|
19276
|
+
value: string | number | boolean | string[] | number[] | null;
|
|
19277
19277
|
}[] | undefined;
|
|
19278
19278
|
update: {
|
|
19279
19279
|
[x: string]: unknown;
|
|
@@ -19334,6 +19334,10 @@ declare const createDisabledAuthRuntime: <DataModel extends GenericDataModel, Sc
|
|
|
19334
19334
|
type SessionDoc<TCtx extends GenericQueryCtx<any>> = DocByCtx<TCtx, 'session'>;
|
|
19335
19335
|
type SessionResult<TCtx extends GenericQueryCtx<any>> = LookupByIdResultByCtx<TCtx, 'session'>;
|
|
19336
19336
|
type SessionLookupCtx<TCtx extends GenericQueryCtx<any>> = QueryCtxWithPreferredOrmQueryTable<TCtx, 'session'>;
|
|
19337
|
+
type SessionClientSignals = {
|
|
19338
|
+
ip?: string;
|
|
19339
|
+
userAgent?: string;
|
|
19340
|
+
};
|
|
19337
19341
|
declare const getAuthUserIdentity: <DataModel extends GenericDataModel>(ctx: GenericQueryCtx<DataModel>) => Promise<{
|
|
19338
19342
|
sessionId: DocumentByName<DataModel, "session">["_id"];
|
|
19339
19343
|
userId: DocumentByName<DataModel, "user">["_id"];
|
|
@@ -19360,6 +19364,7 @@ declare const getAuthUserIdentity: <DataModel extends GenericDataModel>(ctx: Gen
|
|
|
19360
19364
|
} | null>;
|
|
19361
19365
|
declare const getAuthUserId: <DataModel extends GenericDataModel>(ctx: GenericQueryCtx<DataModel>) => Promise<string | null>;
|
|
19362
19366
|
declare function getSession<TCtx extends GenericQueryCtx<any>>(ctx: TCtx & SessionLookupCtx<TCtx>, _sessionId?: SessionDoc<TCtx>['_id']): Promise<SessionResult<TCtx>>;
|
|
19367
|
+
declare const getSessionNetworkSignals: <TCtx extends GenericQueryCtx<any>>(ctx: TCtx & QueryCtxWithPreferredOrmQueryTable<TCtx, "session">, session?: SessionResult<TCtx> | null) => Promise<SessionClientSignals>;
|
|
19363
19368
|
declare const getHeaders: <TCtx extends GenericQueryCtx<any>>(ctx: TCtx & QueryCtxWithPreferredOrmQueryTable<TCtx, "session">, session?: SessionResult<TCtx> | null) => Promise<Headers>;
|
|
19364
19369
|
//#endregion
|
|
19365
|
-
export { type AuthFunctions, BetterAuthOptionsWithoutDatabase, ConvexCleanedWhere, GeneratedAuthDisabledReasonKind, GenericAuthBeforeResult, GenericAuthDefinition, GenericAuthTriggerChange, GenericAuthTriggerHandlers, GenericAuthTriggers, GetAuth, type Triggers, adapterArgsValidator, adapterConfig, adapterWhereValidator, checkUniqueFields, convex, createApi, createAuthRuntime, createClient, createDisabledAuthRuntime, createHandler, dbAdapter, defineAuth, deleteManyHandler, deleteOneHandler, findManyHandler, findOneHandler, getAuthUserId, getAuthUserIdentity, getGeneratedAuthDisabledReason, getHeaders, getSession, handlePagination, hasUniqueFields, httpAdapter, listOne, paginate, resolveGeneratedAuthDefinition, selectFields, updateManyHandler, updateOneHandler };
|
|
19370
|
+
export { type AuthFunctions, BetterAuthOptionsWithoutDatabase, ConvexCleanedWhere, GeneratedAuthDisabledReasonKind, GenericAuthBeforeResult, GenericAuthDefinition, GenericAuthTriggerChange, GenericAuthTriggerHandlers, GenericAuthTriggers, GetAuth, SessionClientSignals, type Triggers, adapterArgsValidator, adapterConfig, adapterWhereValidator, checkUniqueFields, convex, createApi, createAuthRuntime, createClient, createDisabledAuthRuntime, createHandler, dbAdapter, defineAuth, deleteManyHandler, deleteOneHandler, findManyHandler, findOneHandler, getAuthUserId, getAuthUserIdentity, getGeneratedAuthDisabledReason, getHeaders, getSession, getSessionNetworkSignals, handlePagination, hasUniqueFields, httpAdapter, listOne, paginate, resolveGeneratedAuthDefinition, selectFields, updateManyHandler, updateOneHandler };
|
package/dist/auth/index.js
CHANGED
|
@@ -1148,6 +1148,11 @@ const createDisabledAuthRuntime = (config) => {
|
|
|
1148
1148
|
//#endregion
|
|
1149
1149
|
//#region src/auth/helpers.ts
|
|
1150
1150
|
const SESSION_TOKEN_COOKIE_NAME = "better-auth.session_token";
|
|
1151
|
+
const normalizeSignal = (value) => {
|
|
1152
|
+
if (typeof value !== "string") return;
|
|
1153
|
+
const trimmed = value.trim();
|
|
1154
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
1155
|
+
};
|
|
1151
1156
|
const parseSessionTokenFromCookie = (cookieHeader) => {
|
|
1152
1157
|
if (!cookieHeader) return null;
|
|
1153
1158
|
const parts = cookieHeader.split(";");
|
|
@@ -1194,6 +1199,16 @@ async function getSession(ctx, _sessionId) {
|
|
|
1194
1199
|
if (!sessionId) return null;
|
|
1195
1200
|
return await getByIdWithOrmQueryFallback(ctx, "session", sessionId);
|
|
1196
1201
|
}
|
|
1202
|
+
const getSessionNetworkSignals = async (ctx, session) => {
|
|
1203
|
+
const resolvedSession = session ?? await getSession(ctx);
|
|
1204
|
+
if (!resolvedSession) return {};
|
|
1205
|
+
const ip = normalizeSignal(resolvedSession.ipAddress);
|
|
1206
|
+
const userAgent = normalizeSignal(resolvedSession.userAgent);
|
|
1207
|
+
return {
|
|
1208
|
+
...ip ? { ip } : {},
|
|
1209
|
+
...userAgent ? { userAgent } : {}
|
|
1210
|
+
};
|
|
1211
|
+
};
|
|
1197
1212
|
const getHeaders = async (ctx, session) => {
|
|
1198
1213
|
const resolvedSession = session ?? await getSession(ctx);
|
|
1199
1214
|
if (!resolvedSession) {
|
|
@@ -1208,4 +1223,4 @@ const getHeaders = async (ctx, session) => {
|
|
|
1208
1223
|
};
|
|
1209
1224
|
|
|
1210
1225
|
//#endregion
|
|
1211
|
-
export { adapterArgsValidator, adapterConfig, adapterWhereValidator, checkUniqueFields, convex, createApi, createAuthRuntime, createClient, createDisabledAuthRuntime, createHandler, dbAdapter, defineAuth, deleteManyHandler, deleteOneHandler, findManyHandler, findOneHandler, getAuthUserId, getAuthUserIdentity, getGeneratedAuthDisabledReason, getHeaders, getSession, handlePagination, hasUniqueFields, httpAdapter, listOne, paginate, resolveGeneratedAuthDefinition, selectFields, updateManyHandler, updateOneHandler };
|
|
1226
|
+
export { adapterArgsValidator, adapterConfig, adapterWhereValidator, checkUniqueFields, convex, createApi, createAuthRuntime, createClient, createDisabledAuthRuntime, createHandler, dbAdapter, defineAuth, deleteManyHandler, deleteOneHandler, findManyHandler, findOneHandler, getAuthUserId, getAuthUserIdentity, getGeneratedAuthDisabledReason, getHeaders, getSession, getSessionNetworkSignals, handlePagination, hasUniqueFields, httpAdapter, listOne, paginate, resolveGeneratedAuthDefinition, selectFields, updateManyHandler, updateOneHandler };
|
|
@@ -511,8 +511,7 @@ var Ratelimit = class Ratelimit {
|
|
|
511
511
|
while (Date.now() <= deadline) {
|
|
512
512
|
latest = await this.limit(identifier);
|
|
513
513
|
if (latest.success) return latest;
|
|
514
|
-
|
|
515
|
-
await new Promise((resolve) => setTimeout(resolve, waitMs));
|
|
514
|
+
await sleep(Math.max(1, Math.min(latest.reset, deadline) - Date.now()));
|
|
516
515
|
}
|
|
517
516
|
return latest;
|
|
518
517
|
}
|
|
@@ -707,22 +706,14 @@ var Ratelimit = class Ratelimit {
|
|
|
707
706
|
}
|
|
708
707
|
async runWithTimeout(operation) {
|
|
709
708
|
if (this.timeout <= 0) return operation();
|
|
710
|
-
|
|
711
|
-
const timeoutResult = this.timeoutResponse(this.failureMode === "open");
|
|
712
|
-
let timerUnavailable = false;
|
|
713
|
-
const timeoutPromise = new Promise((resolve) => {
|
|
714
|
-
try {
|
|
715
|
-
timeoutHandle = setTimeout(() => resolve(timeoutResult), this.timeout);
|
|
716
|
-
} catch {
|
|
717
|
-
timerUnavailable = true;
|
|
718
|
-
resolve(timeoutResult);
|
|
719
|
-
}
|
|
720
|
-
});
|
|
721
|
-
if (timerUnavailable) return operation();
|
|
709
|
+
const startedAt = Date.now();
|
|
722
710
|
try {
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
711
|
+
const result = await operation();
|
|
712
|
+
if (Date.now() - startedAt > this.timeout) return this.timeoutResponse(this.failureMode === "open");
|
|
713
|
+
return result;
|
|
714
|
+
} catch (error) {
|
|
715
|
+
if (Date.now() - startedAt > this.timeout) return this.timeoutResponse(this.failureMode === "open");
|
|
716
|
+
throw error;
|
|
726
717
|
}
|
|
727
718
|
}
|
|
728
719
|
timeoutResponse(success) {
|
|
@@ -767,6 +758,21 @@ function pickSampleShards(total, sample) {
|
|
|
767
758
|
}
|
|
768
759
|
return selected.length > 0 ? selected : [0];
|
|
769
760
|
}
|
|
761
|
+
async function sleep(ms) {
|
|
762
|
+
try {
|
|
763
|
+
await new Promise((resolve) => {
|
|
764
|
+
setTimeout(resolve, ms);
|
|
765
|
+
});
|
|
766
|
+
} catch (error) {
|
|
767
|
+
if (isTimerUnsupportedError(error)) throw new Error("blockUntilReady is not supported in Convex queries/mutations. Use an action or non-Convex runtime.");
|
|
768
|
+
throw error;
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
function isTimerUnsupportedError(error) {
|
|
772
|
+
if (!(error instanceof Error)) return false;
|
|
773
|
+
const message = error.message.toLowerCase();
|
|
774
|
+
return message.includes("can't use settimeout in queries and mutations") || message.includes("settimeout");
|
|
775
|
+
}
|
|
770
776
|
async function resolveIdentifier(identifierOption, ctx, fromClient) {
|
|
771
777
|
if (!identifierOption) {
|
|
772
778
|
if (!fromClient) throw new Error("hookAPI requires identifier in options or request args");
|