@syncello/auth 2.5.1 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,8 +1,9 @@
1
1
  export { ColumnDefinition, ColumnType, EnumDefinition, EnumName, IndexDefinition, SCHEMA_VERSION, TableDefinition, TableName, enums, tableNames, tables } from './schema/index.cjs';
2
- import { PgTableWithColumns, PgTable } from 'drizzle-orm/pg-core';
2
+ import { PgTableWithColumns } from 'drizzle-orm/pg-core';
3
3
  import * as hono from 'hono';
4
4
  import { Context } from 'hono';
5
5
  import { InferInsertModel, InferSelectModel } from 'drizzle-orm';
6
+ import * as hono_types from 'hono/types';
6
7
  import { OpenAPIHono } from '@hono/zod-openapi';
7
8
  import * as hono_utils_types from 'hono/utils/types';
8
9
  import { PostgresJsDatabase } from 'drizzle-orm/postgres-js';
@@ -67,33 +68,8 @@ declare function validatePasswordWithBreachCheck(password: string, checkBreaches
67
68
 
68
69
  type DrizzleDB$2 = any;
69
70
 
70
- type SessionsTable = PgTableWithColumns<{
71
- name: string;
72
- schema: undefined;
73
- columns: {
74
- id: any;
75
- userId: any;
76
- expiresAt: any;
77
- createdAt: any;
78
- lastActiveAt: any;
79
- fingerprint: any;
80
- ipAddress: any;
81
- };
82
- dialect: 'pg';
83
- }>;
84
- type UsersTable$4 = PgTableWithColumns<{
85
- name: string;
86
- schema: undefined;
87
- columns: {
88
- id: any;
89
- email: any;
90
- emailVerified: any;
91
- sessionVersion: any;
92
- createdAt: any;
93
- updatedAt: any;
94
- };
95
- dialect: 'pg';
96
- }>;
71
+ type SessionsTable = PgTableWithColumns<any>;
72
+ type UsersTable$4 = PgTableWithColumns<any>;
97
73
  interface SessionTables {
98
74
  sessions: SessionsTable;
99
75
  users: UsersTable$4;
@@ -193,9 +169,15 @@ declare const AUTH_DEFAULTS: {
193
169
  };
194
170
 
195
171
  /**
196
- * Base type for auth tables - any Postgres table
172
+ * Base type for auth tables.
173
+ *
174
+ * The library is schema-agnostic: consumers inject their own Drizzle tables,
175
+ * so the concrete column types are not known at compile time within the
176
+ * library. `PgTableWithColumns<any>` keeps column access available (e.g.
177
+ * `schema.users.email`) and stays assignable to the column-specific table
178
+ * types declared by the core modules.
197
179
  */
198
- type AuthTable = PgTable;
180
+ type AuthTable = PgTableWithColumns<any>;
199
181
  /**
200
182
  * Schema interface that consumers must provide.
201
183
  * Each property must be a Drizzle PgTable with the expected columns.
@@ -233,14 +215,19 @@ type InferSession<TSchema extends AuthSchema> = InferSelectModel<TSchema['sessio
233
215
  type InferNewSession<TSchema extends AuthSchema> = InferInsertModel<TSchema['sessions']>;
234
216
  /**
235
217
  * Database interface - accepts any Drizzle Postgres database.
218
+ *
236
219
  * Uses duck typing for flexibility across different Drizzle configurations.
220
+ * Because the consumer's concrete schema is injected at runtime, the query
221
+ * builder chains cannot be statically typed against specific tables here; the
222
+ * methods are intentionally permissive and rely on the consumer's real Drizzle
223
+ * instance for correctness.
237
224
  */
238
225
  interface AuthDatabase {
239
- select: <T extends PgTable>(from?: T) => unknown;
240
- insert: <T extends PgTable>(into: T) => unknown;
241
- update: <T extends PgTable>(table: T) => unknown;
242
- delete: <T extends PgTable>(from: T) => unknown;
243
- query: Record<string, unknown>;
226
+ select: (...args: any[]) => any;
227
+ insert: (...args: any[]) => any;
228
+ update: (...args: any[]) => any;
229
+ delete: (...args: any[]) => any;
230
+ query: Record<string, any>;
244
231
  }
245
232
  /**
246
233
  * Configuration for createAuth
@@ -334,6 +321,51 @@ declare function createAuthMiddleware<TEnv = Record<string, unknown>>(auth: Auth
334
321
  */
335
322
  declare function getAuthContext<TEnv = Record<string, unknown>>(c: Context): AuthContext<TEnv>;
336
323
 
324
+ /**
325
+ * Email adapter interface for provider abstraction
326
+ * Allows for provider abstraction (currently Resend)
327
+ */
328
+ interface EmailSendOptions {
329
+ from: string;
330
+ to: string;
331
+ subject: string;
332
+ html: string;
333
+ text?: string;
334
+ tags?: Record<string, string>;
335
+ }
336
+ interface EmailSendResult {
337
+ success: boolean;
338
+ emailId?: string;
339
+ error?: string;
340
+ }
341
+ interface EmailAdapter {
342
+ /**
343
+ * Send an email through the provider
344
+ */
345
+ send(options: EmailSendOptions): Promise<EmailSendResult>;
346
+ /**
347
+ * Provider name for logging
348
+ */
349
+ readonly providerName: string;
350
+ }
351
+ /**
352
+ * Structural type for the Cloudflare Email Service `send_email` Workers binding.
353
+ * Defined locally so consumers do not need a specific @cloudflare/workers-types
354
+ * version that includes Email Service (beta) types.
355
+ */
356
+ interface SendEmailBinding {
357
+ send(message: {
358
+ to: string;
359
+ from: string;
360
+ subject: string;
361
+ html?: string;
362
+ text?: string;
363
+ headers?: Record<string, string>;
364
+ }): Promise<{
365
+ messageId: string;
366
+ }>;
367
+ }
368
+
337
369
  /**
338
370
  * Environment variables available in Cloudflare Workers
339
371
  */
@@ -343,8 +375,11 @@ type Env = {
343
375
  SESSION_SECRET: string;
344
376
  PASSWORD_PEPPER_V1: string;
345
377
  PASSWORD_PEPPER_V2?: string;
378
+ EMAIL_PROVIDER?: 'resend' | 'cloudflare';
379
+ EMAIL_FROM?: string;
346
380
  RESEND_API_KEY?: string;
347
381
  RESEND_WEBHOOK_SECRET?: string;
382
+ EMAIL?: SendEmailBinding;
348
383
  DB: {
349
384
  connectionString: string;
350
385
  };
@@ -426,16 +461,7 @@ declare function generateFingerprint(request: Request): Promise<string>;
426
461
  declare function getClientIp(request: Request): string;
427
462
 
428
463
  type DrizzleDB$1 = any;
429
- type UsersTable$3 = PgTableWithColumns<{
430
- name: string;
431
- schema: undefined;
432
- columns: {
433
- id: any;
434
- lockedUntil: any;
435
- failedLoginCount: any;
436
- };
437
- dialect: 'pg';
438
- }>;
464
+ type UsersTable$3 = PgTableWithColumns<any>;
439
465
  interface AccountLockoutTables {
440
466
  users: UsersTable$3;
441
467
  }
@@ -485,31 +511,8 @@ declare function getMinutesUntilUnlock(unlockAt: number): number;
485
511
  declare function verifyTurnstileToken(token: string, secretKey: string, remoteIp?: string, environment?: 'development' | 'staging' | 'production'): Promise<boolean>;
486
512
 
487
513
  type DrizzleDB = any;
488
- type UsersTable$2 = PgTableWithColumns<{
489
- name: string;
490
- schema: undefined;
491
- columns: {
492
- id: any;
493
- email: any;
494
- hashedPassword: any;
495
- updatedAt: any;
496
- };
497
- dialect: 'pg';
498
- }>;
499
- type EmailChangeTokensTable = PgTableWithColumns<{
500
- name: string;
501
- schema: undefined;
502
- columns: {
503
- id: any;
504
- userId: any;
505
- newEmail: any;
506
- tokenHash: any;
507
- cancelTokenHash: any;
508
- expiresAt: any;
509
- createdAt: any;
510
- };
511
- dialect: 'pg';
512
- }>;
514
+ type UsersTable$2 = PgTableWithColumns<any>;
515
+ type EmailChangeTokensTable = PgTableWithColumns<any>;
513
516
  interface EmailChangeTables {
514
517
  users: UsersTable$2;
515
518
  emailChangeTokens: EmailChangeTokensTable;
@@ -850,10 +853,1354 @@ declare const requireVerifiedEmail: hono.MiddlewareHandler<{
850
853
  Variables: Variables;
851
854
  }, string, {}, Response>;
852
855
 
853
- declare const auth: OpenAPIHono<{
856
+ declare const authRoutes: OpenAPIHono<{
854
857
  Bindings: Env;
855
858
  Variables: Variables;
856
- }, {}, "/">;
859
+ }, hono_types.MergeSchemaPath<{
860
+ "/:provider/authorize": {
861
+ $get: {
862
+ input: {
863
+ param: {
864
+ provider: "google" | "microsoft";
865
+ };
866
+ } & {
867
+ query: {
868
+ redirect?: string | undefined;
869
+ invitationToken?: string | undefined;
870
+ code_challenge?: string | undefined;
871
+ code_challenge_method?: "S256" | undefined;
872
+ redirect_uri?: string | undefined;
873
+ };
874
+ };
875
+ output: {};
876
+ outputFormat: string;
877
+ status: 302;
878
+ };
879
+ };
880
+ } & {
881
+ "/:provider/callback": {
882
+ $get: {
883
+ input: {
884
+ param: {
885
+ provider: "google" | "microsoft";
886
+ };
887
+ } & {
888
+ query: {
889
+ code?: string | undefined;
890
+ state?: string | undefined;
891
+ error?: string | undefined;
892
+ };
893
+ };
894
+ output: {};
895
+ outputFormat: string;
896
+ status: 302;
897
+ };
898
+ };
899
+ } & {
900
+ "/complete": {
901
+ $post: {
902
+ input: {
903
+ json: {
904
+ code: string;
905
+ };
906
+ };
907
+ output: {
908
+ type: string;
909
+ title: string;
910
+ status: number;
911
+ detail?: string | undefined;
912
+ };
913
+ outputFormat: "json";
914
+ status: 401;
915
+ } | {
916
+ input: {
917
+ json: {
918
+ code: string;
919
+ };
920
+ };
921
+ output: {
922
+ message: string;
923
+ redirect: string;
924
+ user: {
925
+ id: string;
926
+ email: string;
927
+ emailVerified: boolean;
928
+ };
929
+ };
930
+ outputFormat: "json";
931
+ status: 200;
932
+ };
933
+ };
934
+ }, "/oauth"> & hono_types.MergeSchemaPath<{
935
+ "/status": {
936
+ $get: {
937
+ input: {};
938
+ output: {
939
+ type: string;
940
+ title: string;
941
+ status: number;
942
+ detail?: string | undefined;
943
+ instance?: string | undefined;
944
+ traceId?: string | undefined;
945
+ requestId?: string | undefined;
946
+ };
947
+ outputFormat: "json";
948
+ status: 401;
949
+ } | {
950
+ input: {};
951
+ output: {
952
+ enabled: boolean;
953
+ methods: ("email" | "totp")[];
954
+ backupCodesRemaining: number;
955
+ };
956
+ outputFormat: "json";
957
+ status: 200;
958
+ };
959
+ };
960
+ } & {
961
+ "/totp/setup": {
962
+ $post: {
963
+ input: {};
964
+ output: {
965
+ type: string;
966
+ title: string;
967
+ status: number;
968
+ detail?: string | undefined;
969
+ instance?: string | undefined;
970
+ traceId?: string | undefined;
971
+ requestId?: string | undefined;
972
+ };
973
+ outputFormat: "json";
974
+ status: 401;
975
+ } | {
976
+ input: {};
977
+ output: {
978
+ type: string;
979
+ title: string;
980
+ status: number;
981
+ detail?: string | undefined;
982
+ instance?: string | undefined;
983
+ traceId?: string | undefined;
984
+ requestId?: string | undefined;
985
+ };
986
+ outputFormat: "json";
987
+ status: 400;
988
+ } | {
989
+ input: {};
990
+ output: {
991
+ type: string;
992
+ title: string;
993
+ status: number;
994
+ detail?: string | undefined;
995
+ instance?: string | undefined;
996
+ traceId?: string | undefined;
997
+ requestId?: string | undefined;
998
+ };
999
+ outputFormat: "json";
1000
+ status: 404;
1001
+ } | {
1002
+ input: {};
1003
+ output: {
1004
+ secret: string;
1005
+ qrCodeUri: string;
1006
+ };
1007
+ outputFormat: "json";
1008
+ status: 200;
1009
+ };
1010
+ };
1011
+ } & {
1012
+ "/totp/verify": {
1013
+ $post: {
1014
+ input: {
1015
+ json: {
1016
+ code: string;
1017
+ };
1018
+ };
1019
+ output: {
1020
+ type: string;
1021
+ title: string;
1022
+ status: number;
1023
+ detail?: string | undefined;
1024
+ instance?: string | undefined;
1025
+ traceId?: string | undefined;
1026
+ requestId?: string | undefined;
1027
+ };
1028
+ outputFormat: "json";
1029
+ status: 401;
1030
+ } | {
1031
+ input: {
1032
+ json: {
1033
+ code: string;
1034
+ };
1035
+ };
1036
+ output: {
1037
+ type: string;
1038
+ title: string;
1039
+ status: number;
1040
+ detail?: string | undefined;
1041
+ instance?: string | undefined;
1042
+ traceId?: string | undefined;
1043
+ requestId?: string | undefined;
1044
+ };
1045
+ outputFormat: "json";
1046
+ status: 400;
1047
+ } | {
1048
+ input: {
1049
+ json: {
1050
+ code: string;
1051
+ };
1052
+ };
1053
+ output: {
1054
+ type: string;
1055
+ title: string;
1056
+ status: number;
1057
+ detail?: string | undefined;
1058
+ instance?: string | undefined;
1059
+ traceId?: string | undefined;
1060
+ requestId?: string | undefined;
1061
+ };
1062
+ outputFormat: "json";
1063
+ status: 500;
1064
+ } | {
1065
+ input: {
1066
+ json: {
1067
+ code: string;
1068
+ };
1069
+ };
1070
+ output: {
1071
+ success: boolean;
1072
+ backupCodes?: string[] | undefined;
1073
+ };
1074
+ outputFormat: "json";
1075
+ status: 200;
1076
+ };
1077
+ };
1078
+ } & {
1079
+ "/totp/disable": {
1080
+ $post: {
1081
+ input: {
1082
+ json: {
1083
+ code: string;
1084
+ method: "email" | "totp" | "backup";
1085
+ };
1086
+ };
1087
+ output: {
1088
+ type: string;
1089
+ title: string;
1090
+ status: number;
1091
+ detail?: string | undefined;
1092
+ instance?: string | undefined;
1093
+ traceId?: string | undefined;
1094
+ requestId?: string | undefined;
1095
+ };
1096
+ outputFormat: "json";
1097
+ status: 401;
1098
+ } | {
1099
+ input: {
1100
+ json: {
1101
+ code: string;
1102
+ method: "email" | "totp" | "backup";
1103
+ };
1104
+ };
1105
+ output: {
1106
+ type: string;
1107
+ title: string;
1108
+ status: number;
1109
+ detail?: string | undefined;
1110
+ instance?: string | undefined;
1111
+ traceId?: string | undefined;
1112
+ requestId?: string | undefined;
1113
+ };
1114
+ outputFormat: "json";
1115
+ status: 400;
1116
+ } | {
1117
+ input: {
1118
+ json: {
1119
+ code: string;
1120
+ method: "email" | "totp" | "backup";
1121
+ };
1122
+ };
1123
+ output: {
1124
+ success: boolean;
1125
+ sessionInvalidated?: boolean | undefined;
1126
+ };
1127
+ outputFormat: "json";
1128
+ status: 200;
1129
+ };
1130
+ };
1131
+ } & {
1132
+ "/email/setup": {
1133
+ $post: {
1134
+ input: {};
1135
+ output: {
1136
+ type: string;
1137
+ title: string;
1138
+ status: number;
1139
+ detail?: string | undefined;
1140
+ instance?: string | undefined;
1141
+ traceId?: string | undefined;
1142
+ requestId?: string | undefined;
1143
+ };
1144
+ outputFormat: "json";
1145
+ status: 401;
1146
+ } | {
1147
+ input: {};
1148
+ output: {
1149
+ type: string;
1150
+ title: string;
1151
+ status: number;
1152
+ detail?: string | undefined;
1153
+ instance?: string | undefined;
1154
+ traceId?: string | undefined;
1155
+ requestId?: string | undefined;
1156
+ };
1157
+ outputFormat: "json";
1158
+ status: 400;
1159
+ } | {
1160
+ input: {};
1161
+ output: {
1162
+ type: string;
1163
+ title: string;
1164
+ status: number;
1165
+ detail?: string | undefined;
1166
+ instance?: string | undefined;
1167
+ traceId?: string | undefined;
1168
+ requestId?: string | undefined;
1169
+ };
1170
+ outputFormat: "json";
1171
+ status: 404;
1172
+ } | {
1173
+ input: {};
1174
+ output: {
1175
+ success: boolean;
1176
+ };
1177
+ outputFormat: "json";
1178
+ status: 200;
1179
+ };
1180
+ };
1181
+ } & {
1182
+ "/email/verify": {
1183
+ $post: {
1184
+ input: {
1185
+ json: {
1186
+ code: string;
1187
+ };
1188
+ };
1189
+ output: {
1190
+ type: string;
1191
+ title: string;
1192
+ status: number;
1193
+ detail?: string | undefined;
1194
+ instance?: string | undefined;
1195
+ traceId?: string | undefined;
1196
+ requestId?: string | undefined;
1197
+ };
1198
+ outputFormat: "json";
1199
+ status: 401;
1200
+ } | {
1201
+ input: {
1202
+ json: {
1203
+ code: string;
1204
+ };
1205
+ };
1206
+ output: {
1207
+ type: string;
1208
+ title: string;
1209
+ status: number;
1210
+ detail?: string | undefined;
1211
+ instance?: string | undefined;
1212
+ traceId?: string | undefined;
1213
+ requestId?: string | undefined;
1214
+ };
1215
+ outputFormat: "json";
1216
+ status: 400;
1217
+ } | {
1218
+ input: {
1219
+ json: {
1220
+ code: string;
1221
+ };
1222
+ };
1223
+ output: {
1224
+ success: boolean;
1225
+ backupCodes?: string[] | undefined;
1226
+ };
1227
+ outputFormat: "json";
1228
+ status: 200;
1229
+ };
1230
+ };
1231
+ } & {
1232
+ "/email/send-code": {
1233
+ $post: {
1234
+ input: {};
1235
+ output: {
1236
+ type: string;
1237
+ title: string;
1238
+ status: number;
1239
+ detail?: string | undefined;
1240
+ instance?: string | undefined;
1241
+ traceId?: string | undefined;
1242
+ requestId?: string | undefined;
1243
+ };
1244
+ outputFormat: "json";
1245
+ status: 401;
1246
+ } | {
1247
+ input: {};
1248
+ output: {
1249
+ type: string;
1250
+ title: string;
1251
+ status: number;
1252
+ detail?: string | undefined;
1253
+ instance?: string | undefined;
1254
+ traceId?: string | undefined;
1255
+ requestId?: string | undefined;
1256
+ };
1257
+ outputFormat: "json";
1258
+ status: 400;
1259
+ } | {
1260
+ input: {};
1261
+ output: {
1262
+ type: string;
1263
+ title: string;
1264
+ status: number;
1265
+ detail?: string | undefined;
1266
+ instance?: string | undefined;
1267
+ traceId?: string | undefined;
1268
+ requestId?: string | undefined;
1269
+ };
1270
+ outputFormat: "json";
1271
+ status: 404;
1272
+ } | {
1273
+ input: {};
1274
+ output: {
1275
+ success: boolean;
1276
+ };
1277
+ outputFormat: "json";
1278
+ status: 200;
1279
+ };
1280
+ };
1281
+ } & {
1282
+ "/email/disable": {
1283
+ $post: {
1284
+ input: {
1285
+ json: {
1286
+ code: string;
1287
+ method: "email" | "totp" | "backup";
1288
+ };
1289
+ };
1290
+ output: {
1291
+ type: string;
1292
+ title: string;
1293
+ status: number;
1294
+ detail?: string | undefined;
1295
+ instance?: string | undefined;
1296
+ traceId?: string | undefined;
1297
+ requestId?: string | undefined;
1298
+ };
1299
+ outputFormat: "json";
1300
+ status: 401;
1301
+ } | {
1302
+ input: {
1303
+ json: {
1304
+ code: string;
1305
+ method: "email" | "totp" | "backup";
1306
+ };
1307
+ };
1308
+ output: {
1309
+ type: string;
1310
+ title: string;
1311
+ status: number;
1312
+ detail?: string | undefined;
1313
+ instance?: string | undefined;
1314
+ traceId?: string | undefined;
1315
+ requestId?: string | undefined;
1316
+ };
1317
+ outputFormat: "json";
1318
+ status: 400;
1319
+ } | {
1320
+ input: {
1321
+ json: {
1322
+ code: string;
1323
+ method: "email" | "totp" | "backup";
1324
+ };
1325
+ };
1326
+ output: {
1327
+ success: boolean;
1328
+ sessionInvalidated?: boolean | undefined;
1329
+ };
1330
+ outputFormat: "json";
1331
+ status: 200;
1332
+ };
1333
+ };
1334
+ } & {
1335
+ "/trusted-devices": {
1336
+ $get: {
1337
+ input: {};
1338
+ output: {
1339
+ type: string;
1340
+ title: string;
1341
+ status: number;
1342
+ detail?: string | undefined;
1343
+ instance?: string | undefined;
1344
+ traceId?: string | undefined;
1345
+ requestId?: string | undefined;
1346
+ };
1347
+ outputFormat: "json";
1348
+ status: 401;
1349
+ } | {
1350
+ input: {};
1351
+ output: {
1352
+ devices: {
1353
+ id: string;
1354
+ deviceName: string;
1355
+ deviceType: "desktop" | "mobile" | "tablet";
1356
+ ipAddress: string;
1357
+ lastUsedAt: number;
1358
+ createdAt: number;
1359
+ }[];
1360
+ };
1361
+ outputFormat: "json";
1362
+ status: 200;
1363
+ };
1364
+ };
1365
+ } & {
1366
+ "/trusted-devices/:id": {
1367
+ $delete: {
1368
+ input: {
1369
+ param: {
1370
+ id: string;
1371
+ };
1372
+ };
1373
+ output: {
1374
+ type: string;
1375
+ title: string;
1376
+ status: number;
1377
+ detail?: string | undefined;
1378
+ instance?: string | undefined;
1379
+ traceId?: string | undefined;
1380
+ requestId?: string | undefined;
1381
+ };
1382
+ outputFormat: "json";
1383
+ status: 401;
1384
+ } | {
1385
+ input: {
1386
+ param: {
1387
+ id: string;
1388
+ };
1389
+ };
1390
+ output: {
1391
+ type: string;
1392
+ title: string;
1393
+ status: number;
1394
+ detail?: string | undefined;
1395
+ instance?: string | undefined;
1396
+ traceId?: string | undefined;
1397
+ requestId?: string | undefined;
1398
+ };
1399
+ outputFormat: "json";
1400
+ status: 404;
1401
+ } | {
1402
+ input: {
1403
+ param: {
1404
+ id: string;
1405
+ };
1406
+ };
1407
+ output: {
1408
+ success: boolean;
1409
+ };
1410
+ outputFormat: "json";
1411
+ status: 200;
1412
+ };
1413
+ };
1414
+ } & {
1415
+ "/backup-codes/regenerate": {
1416
+ $post: {
1417
+ input: {
1418
+ json: {
1419
+ code: string;
1420
+ method: "email" | "totp" | "backup";
1421
+ };
1422
+ };
1423
+ output: {
1424
+ type: string;
1425
+ title: string;
1426
+ status: number;
1427
+ detail?: string | undefined;
1428
+ instance?: string | undefined;
1429
+ traceId?: string | undefined;
1430
+ requestId?: string | undefined;
1431
+ };
1432
+ outputFormat: "json";
1433
+ status: 401;
1434
+ } | {
1435
+ input: {
1436
+ json: {
1437
+ code: string;
1438
+ method: "email" | "totp" | "backup";
1439
+ };
1440
+ };
1441
+ output: {
1442
+ type: string;
1443
+ title: string;
1444
+ status: number;
1445
+ detail?: string | undefined;
1446
+ instance?: string | undefined;
1447
+ traceId?: string | undefined;
1448
+ requestId?: string | undefined;
1449
+ };
1450
+ outputFormat: "json";
1451
+ status: 400;
1452
+ } | {
1453
+ input: {
1454
+ json: {
1455
+ code: string;
1456
+ method: "email" | "totp" | "backup";
1457
+ };
1458
+ };
1459
+ output: {
1460
+ success: boolean;
1461
+ backupCodes: string[];
1462
+ };
1463
+ outputFormat: "json";
1464
+ status: 200;
1465
+ };
1466
+ };
1467
+ } & {
1468
+ "/challenge": {
1469
+ $post: {
1470
+ input: {
1471
+ json: {
1472
+ code: string;
1473
+ method: "email" | "totp" | "backup";
1474
+ rememberDevice?: boolean | undefined;
1475
+ };
1476
+ };
1477
+ output: {
1478
+ type: string;
1479
+ title: string;
1480
+ status: number;
1481
+ detail?: string | undefined;
1482
+ instance?: string | undefined;
1483
+ traceId?: string | undefined;
1484
+ requestId?: string | undefined;
1485
+ };
1486
+ outputFormat: "json";
1487
+ status: 400;
1488
+ } | {
1489
+ input: {
1490
+ json: {
1491
+ code: string;
1492
+ method: "email" | "totp" | "backup";
1493
+ rememberDevice?: boolean | undefined;
1494
+ };
1495
+ };
1496
+ output: {
1497
+ type: string;
1498
+ title: string;
1499
+ status: number;
1500
+ detail?: string | undefined;
1501
+ instance?: string | undefined;
1502
+ traceId?: string | undefined;
1503
+ requestId?: string | undefined;
1504
+ };
1505
+ outputFormat: "json";
1506
+ status: 404;
1507
+ } | {
1508
+ input: {
1509
+ json: {
1510
+ code: string;
1511
+ method: "email" | "totp" | "backup";
1512
+ rememberDevice?: boolean | undefined;
1513
+ };
1514
+ };
1515
+ output: {
1516
+ user: {
1517
+ id: string;
1518
+ email: string;
1519
+ name: string | null;
1520
+ };
1521
+ };
1522
+ outputFormat: "json";
1523
+ status: 200;
1524
+ };
1525
+ };
1526
+ } & {
1527
+ "/challenge/resend": {
1528
+ $post: {
1529
+ input: {};
1530
+ output: {
1531
+ type: string;
1532
+ title: string;
1533
+ status: number;
1534
+ detail?: string | undefined;
1535
+ instance?: string | undefined;
1536
+ traceId?: string | undefined;
1537
+ requestId?: string | undefined;
1538
+ };
1539
+ outputFormat: "json";
1540
+ status: 400;
1541
+ } | {
1542
+ input: {};
1543
+ output: {
1544
+ type: string;
1545
+ title: string;
1546
+ status: number;
1547
+ detail?: string | undefined;
1548
+ instance?: string | undefined;
1549
+ traceId?: string | undefined;
1550
+ requestId?: string | undefined;
1551
+ };
1552
+ outputFormat: "json";
1553
+ status: 404;
1554
+ } | {
1555
+ input: {};
1556
+ output: {
1557
+ success: boolean;
1558
+ };
1559
+ outputFormat: "json";
1560
+ status: 200;
1561
+ };
1562
+ };
1563
+ }, "/2fa"> & {
1564
+ "/signup": {
1565
+ $post: {
1566
+ input: {
1567
+ json: {
1568
+ email: string;
1569
+ password?: string | undefined;
1570
+ name?: string | undefined;
1571
+ turnstileToken?: string | undefined;
1572
+ oauthToken?: string | undefined;
1573
+ };
1574
+ };
1575
+ output: {
1576
+ type: string;
1577
+ title: string;
1578
+ status: number;
1579
+ detail?: string | undefined;
1580
+ instance?: string | undefined;
1581
+ traceId?: string | undefined;
1582
+ requestId?: string | undefined;
1583
+ };
1584
+ outputFormat: "json";
1585
+ status: 400;
1586
+ } | {
1587
+ input: {
1588
+ json: {
1589
+ email: string;
1590
+ password?: string | undefined;
1591
+ name?: string | undefined;
1592
+ turnstileToken?: string | undefined;
1593
+ oauthToken?: string | undefined;
1594
+ };
1595
+ };
1596
+ output: {
1597
+ type: string;
1598
+ title: string;
1599
+ status: number;
1600
+ detail?: string | undefined;
1601
+ instance?: string | undefined;
1602
+ traceId?: string | undefined;
1603
+ requestId?: string | undefined;
1604
+ };
1605
+ outputFormat: "json";
1606
+ status: 409;
1607
+ } | {
1608
+ input: {
1609
+ json: {
1610
+ email: string;
1611
+ password?: string | undefined;
1612
+ name?: string | undefined;
1613
+ turnstileToken?: string | undefined;
1614
+ oauthToken?: string | undefined;
1615
+ };
1616
+ };
1617
+ output: {
1618
+ user: {
1619
+ id: string;
1620
+ email: string;
1621
+ name: string | null;
1622
+ emailVerified: boolean;
1623
+ avatarUrl?: string | null | undefined;
1624
+ theme?: "light" | "dark" | "system" | null | undefined;
1625
+ timezone?: string | null | undefined;
1626
+ createdAt?: string | undefined;
1627
+ };
1628
+ redirect: string;
1629
+ };
1630
+ outputFormat: "json";
1631
+ status: 200;
1632
+ };
1633
+ };
1634
+ } & {
1635
+ "/login": {
1636
+ $post: {
1637
+ input: {
1638
+ json: {
1639
+ email: string;
1640
+ password: string;
1641
+ turnstileToken?: string | undefined;
1642
+ };
1643
+ };
1644
+ output: {
1645
+ type: string;
1646
+ title: string;
1647
+ status: number;
1648
+ detail?: string | undefined;
1649
+ instance?: string | undefined;
1650
+ traceId?: string | undefined;
1651
+ requestId?: string | undefined;
1652
+ };
1653
+ outputFormat: "json";
1654
+ status: 400;
1655
+ } | {
1656
+ input: {
1657
+ json: {
1658
+ email: string;
1659
+ password: string;
1660
+ turnstileToken?: string | undefined;
1661
+ };
1662
+ };
1663
+ output: {
1664
+ type: string;
1665
+ title: string;
1666
+ status: number;
1667
+ detail?: string | undefined;
1668
+ instance?: string | undefined;
1669
+ traceId?: string | undefined;
1670
+ requestId?: string | undefined;
1671
+ };
1672
+ outputFormat: "json";
1673
+ status: 401;
1674
+ } | {
1675
+ input: {
1676
+ json: {
1677
+ email: string;
1678
+ password: string;
1679
+ turnstileToken?: string | undefined;
1680
+ };
1681
+ };
1682
+ output: {
1683
+ type: string;
1684
+ title: string;
1685
+ status: number;
1686
+ detail?: string | undefined;
1687
+ instance?: string | undefined;
1688
+ traceId?: string | undefined;
1689
+ requestId?: string | undefined;
1690
+ };
1691
+ outputFormat: "json";
1692
+ status: 429;
1693
+ } | {
1694
+ input: {
1695
+ json: {
1696
+ email: string;
1697
+ password: string;
1698
+ turnstileToken?: string | undefined;
1699
+ };
1700
+ };
1701
+ output: {
1702
+ user?: {
1703
+ id: string;
1704
+ email: string;
1705
+ name: string | null;
1706
+ emailVerified: boolean;
1707
+ avatarUrl?: string | null | undefined;
1708
+ theme?: "light" | "dark" | "system" | null | undefined;
1709
+ timezone?: string | null | undefined;
1710
+ createdAt?: string | undefined;
1711
+ } | undefined;
1712
+ redirect?: string | undefined;
1713
+ requires2fa?: boolean | undefined;
1714
+ methods?: ("email" | "totp")[] | undefined;
1715
+ };
1716
+ outputFormat: "json";
1717
+ status: 200;
1718
+ };
1719
+ };
1720
+ } & {
1721
+ "/logout": {
1722
+ $post: {
1723
+ input: {};
1724
+ output: {
1725
+ success: boolean;
1726
+ };
1727
+ outputFormat: "json";
1728
+ status: 200;
1729
+ };
1730
+ };
1731
+ } & {
1732
+ "/me": {
1733
+ $get: {
1734
+ input: {};
1735
+ output: {
1736
+ type: string;
1737
+ title: string;
1738
+ status: number;
1739
+ detail?: string | undefined;
1740
+ instance?: string | undefined;
1741
+ traceId?: string | undefined;
1742
+ requestId?: string | undefined;
1743
+ };
1744
+ outputFormat: "json";
1745
+ status: 401;
1746
+ } | {
1747
+ input: {};
1748
+ output: {
1749
+ type: string;
1750
+ title: string;
1751
+ status: number;
1752
+ detail?: string | undefined;
1753
+ instance?: string | undefined;
1754
+ traceId?: string | undefined;
1755
+ requestId?: string | undefined;
1756
+ };
1757
+ outputFormat: "json";
1758
+ status: 404;
1759
+ } | {
1760
+ input: {};
1761
+ output: {
1762
+ user: {
1763
+ id: string;
1764
+ email: string;
1765
+ name: string | null;
1766
+ emailVerified: boolean;
1767
+ avatarUrl?: string | null | undefined;
1768
+ theme?: "light" | "dark" | "system" | null | undefined;
1769
+ timezone?: string | null | undefined;
1770
+ createdAt?: string | undefined;
1771
+ };
1772
+ twoFactorEnabled: boolean;
1773
+ twoFactorMethods: ("email" | "totp")[];
1774
+ emailBounced: boolean;
1775
+ };
1776
+ outputFormat: "json";
1777
+ status: 200;
1778
+ };
1779
+ };
1780
+ } & {
1781
+ "/verify-email": {
1782
+ $post: {
1783
+ input: {
1784
+ json: {
1785
+ token: string;
1786
+ };
1787
+ };
1788
+ output: {
1789
+ type: string;
1790
+ title: string;
1791
+ status: number;
1792
+ detail?: string | undefined;
1793
+ instance?: string | undefined;
1794
+ traceId?: string | undefined;
1795
+ requestId?: string | undefined;
1796
+ };
1797
+ outputFormat: "json";
1798
+ status: 400;
1799
+ } | {
1800
+ input: {
1801
+ json: {
1802
+ token: string;
1803
+ };
1804
+ };
1805
+ output: {
1806
+ success: boolean;
1807
+ redirect: string;
1808
+ };
1809
+ outputFormat: "json";
1810
+ status: 200;
1811
+ };
1812
+ };
1813
+ } & {
1814
+ "/forgot-password": {
1815
+ $post: {
1816
+ input: {
1817
+ json: {
1818
+ email: string;
1819
+ turnstileToken?: string | undefined;
1820
+ };
1821
+ };
1822
+ output: {
1823
+ type: string;
1824
+ title: string;
1825
+ status: number;
1826
+ detail?: string | undefined;
1827
+ instance?: string | undefined;
1828
+ traceId?: string | undefined;
1829
+ requestId?: string | undefined;
1830
+ };
1831
+ outputFormat: "json";
1832
+ status: 400;
1833
+ } | {
1834
+ input: {
1835
+ json: {
1836
+ email: string;
1837
+ turnstileToken?: string | undefined;
1838
+ };
1839
+ };
1840
+ output: {
1841
+ success: boolean;
1842
+ };
1843
+ outputFormat: "json";
1844
+ status: 200;
1845
+ };
1846
+ };
1847
+ } & {
1848
+ "/reset-password": {
1849
+ $post: {
1850
+ input: {
1851
+ json: {
1852
+ token: string;
1853
+ password: string;
1854
+ turnstileToken?: string | undefined;
1855
+ };
1856
+ };
1857
+ output: {
1858
+ type: string;
1859
+ title: string;
1860
+ status: number;
1861
+ detail?: string | undefined;
1862
+ instance?: string | undefined;
1863
+ traceId?: string | undefined;
1864
+ requestId?: string | undefined;
1865
+ };
1866
+ outputFormat: "json";
1867
+ status: 400;
1868
+ } | {
1869
+ input: {
1870
+ json: {
1871
+ token: string;
1872
+ password: string;
1873
+ turnstileToken?: string | undefined;
1874
+ };
1875
+ };
1876
+ output: {
1877
+ success: boolean;
1878
+ redirect: string;
1879
+ };
1880
+ outputFormat: "json";
1881
+ status: 200;
1882
+ };
1883
+ };
1884
+ } & {
1885
+ "/change-password": {
1886
+ $post: {
1887
+ input: {
1888
+ json: {
1889
+ currentPassword: string;
1890
+ newPassword: string;
1891
+ };
1892
+ };
1893
+ output: {
1894
+ type: string;
1895
+ title: string;
1896
+ status: number;
1897
+ detail?: string | undefined;
1898
+ instance?: string | undefined;
1899
+ traceId?: string | undefined;
1900
+ requestId?: string | undefined;
1901
+ };
1902
+ outputFormat: "json";
1903
+ status: 400;
1904
+ } | {
1905
+ input: {
1906
+ json: {
1907
+ currentPassword: string;
1908
+ newPassword: string;
1909
+ };
1910
+ };
1911
+ output: {
1912
+ type: string;
1913
+ title: string;
1914
+ status: number;
1915
+ detail?: string | undefined;
1916
+ instance?: string | undefined;
1917
+ traceId?: string | undefined;
1918
+ requestId?: string | undefined;
1919
+ };
1920
+ outputFormat: "json";
1921
+ status: 401;
1922
+ } | {
1923
+ input: {
1924
+ json: {
1925
+ currentPassword: string;
1926
+ newPassword: string;
1927
+ };
1928
+ };
1929
+ output: {
1930
+ success: boolean;
1931
+ };
1932
+ outputFormat: "json";
1933
+ status: 200;
1934
+ };
1935
+ };
1936
+ } & {
1937
+ "/heartbeat": {
1938
+ $post: {
1939
+ input: {};
1940
+ output: {
1941
+ type: string;
1942
+ title: string;
1943
+ status: number;
1944
+ detail?: string | undefined;
1945
+ instance?: string | undefined;
1946
+ traceId?: string | undefined;
1947
+ requestId?: string | undefined;
1948
+ };
1949
+ outputFormat: "json";
1950
+ status: 401;
1951
+ } | {
1952
+ input: {};
1953
+ output: {
1954
+ success: boolean;
1955
+ timestamp: number;
1956
+ };
1957
+ outputFormat: "json";
1958
+ status: 200;
1959
+ };
1960
+ };
1961
+ } & {
1962
+ "/change-email": {
1963
+ $post: {
1964
+ input: {
1965
+ json: {
1966
+ password: string;
1967
+ newEmail: string;
1968
+ };
1969
+ };
1970
+ output: {
1971
+ type: string;
1972
+ title: string;
1973
+ status: number;
1974
+ detail?: string | undefined;
1975
+ instance?: string | undefined;
1976
+ traceId?: string | undefined;
1977
+ requestId?: string | undefined;
1978
+ };
1979
+ outputFormat: "json";
1980
+ status: 400;
1981
+ } | {
1982
+ input: {
1983
+ json: {
1984
+ password: string;
1985
+ newEmail: string;
1986
+ };
1987
+ };
1988
+ output: {
1989
+ type: string;
1990
+ title: string;
1991
+ status: number;
1992
+ detail?: string | undefined;
1993
+ instance?: string | undefined;
1994
+ traceId?: string | undefined;
1995
+ requestId?: string | undefined;
1996
+ };
1997
+ outputFormat: "json";
1998
+ status: 401;
1999
+ } | {
2000
+ input: {
2001
+ json: {
2002
+ password: string;
2003
+ newEmail: string;
2004
+ };
2005
+ };
2006
+ output: {
2007
+ success: boolean;
2008
+ };
2009
+ outputFormat: "json";
2010
+ status: 200;
2011
+ };
2012
+ };
2013
+ } & {
2014
+ "/confirm-email-change": {
2015
+ $post: {
2016
+ input: {
2017
+ json: {
2018
+ token: string;
2019
+ };
2020
+ };
2021
+ output: {
2022
+ type: string;
2023
+ title: string;
2024
+ status: number;
2025
+ detail?: string | undefined;
2026
+ instance?: string | undefined;
2027
+ traceId?: string | undefined;
2028
+ requestId?: string | undefined;
2029
+ };
2030
+ outputFormat: "json";
2031
+ status: 400;
2032
+ } | {
2033
+ input: {
2034
+ json: {
2035
+ token: string;
2036
+ };
2037
+ };
2038
+ output: {
2039
+ success: boolean;
2040
+ };
2041
+ outputFormat: "json";
2042
+ status: 200;
2043
+ };
2044
+ };
2045
+ } & {
2046
+ "/cancel-email-change": {
2047
+ $post: {
2048
+ input: {
2049
+ json: {
2050
+ token: string;
2051
+ };
2052
+ };
2053
+ output: {
2054
+ type: string;
2055
+ title: string;
2056
+ status: number;
2057
+ detail?: string | undefined;
2058
+ instance?: string | undefined;
2059
+ traceId?: string | undefined;
2060
+ requestId?: string | undefined;
2061
+ };
2062
+ outputFormat: "json";
2063
+ status: 400;
2064
+ } | {
2065
+ input: {
2066
+ json: {
2067
+ token: string;
2068
+ };
2069
+ };
2070
+ output: {
2071
+ success: boolean;
2072
+ };
2073
+ outputFormat: "json";
2074
+ status: 200;
2075
+ };
2076
+ };
2077
+ } & {
2078
+ "/account": {
2079
+ $delete: {
2080
+ input: {
2081
+ json: {
2082
+ password: string;
2083
+ };
2084
+ };
2085
+ output: {
2086
+ type: string;
2087
+ title: string;
2088
+ status: number;
2089
+ detail?: string | undefined;
2090
+ instance?: string | undefined;
2091
+ traceId?: string | undefined;
2092
+ requestId?: string | undefined;
2093
+ };
2094
+ outputFormat: "json";
2095
+ status: 400;
2096
+ } | {
2097
+ input: {
2098
+ json: {
2099
+ password: string;
2100
+ };
2101
+ };
2102
+ output: {
2103
+ type: string;
2104
+ title: string;
2105
+ status: number;
2106
+ detail?: string | undefined;
2107
+ instance?: string | undefined;
2108
+ traceId?: string | undefined;
2109
+ requestId?: string | undefined;
2110
+ };
2111
+ outputFormat: "json";
2112
+ status: 401;
2113
+ } | {
2114
+ input: {
2115
+ json: {
2116
+ password: string;
2117
+ };
2118
+ };
2119
+ output: {
2120
+ message: string;
2121
+ purgeAt: string;
2122
+ recoveryWindowDays: number;
2123
+ };
2124
+ outputFormat: "json";
2125
+ status: 200;
2126
+ };
2127
+ };
2128
+ } & {
2129
+ "/refresh": {
2130
+ $post: {
2131
+ input: {
2132
+ json: {
2133
+ refreshToken: string;
2134
+ };
2135
+ };
2136
+ output: {
2137
+ type: string;
2138
+ title: string;
2139
+ status: number;
2140
+ detail?: string | undefined;
2141
+ instance?: string | undefined;
2142
+ traceId?: string | undefined;
2143
+ requestId?: string | undefined;
2144
+ };
2145
+ outputFormat: "json";
2146
+ status: 401;
2147
+ } | {
2148
+ input: {
2149
+ json: {
2150
+ refreshToken: string;
2151
+ };
2152
+ };
2153
+ output: {
2154
+ accessToken: string;
2155
+ expiresIn: number;
2156
+ };
2157
+ outputFormat: "json";
2158
+ status: 200;
2159
+ };
2160
+ };
2161
+ } & {
2162
+ "/resend-verification": {
2163
+ $post: {
2164
+ input: {};
2165
+ output: {
2166
+ type: string;
2167
+ title: string;
2168
+ status: number;
2169
+ detail?: string | undefined;
2170
+ };
2171
+ outputFormat: "json";
2172
+ status: 400;
2173
+ } | {
2174
+ input: {};
2175
+ output: {
2176
+ type: string;
2177
+ title: string;
2178
+ status: number;
2179
+ detail?: string | undefined;
2180
+ };
2181
+ outputFormat: "json";
2182
+ status: 401;
2183
+ } | {
2184
+ input: {};
2185
+ output: {
2186
+ type: string;
2187
+ title: string;
2188
+ status: number;
2189
+ detail?: string | undefined;
2190
+ };
2191
+ outputFormat: "json";
2192
+ status: 429;
2193
+ } | {
2194
+ input: {};
2195
+ output: {
2196
+ success: boolean;
2197
+ message: string;
2198
+ };
2199
+ outputFormat: "json";
2200
+ status: 200;
2201
+ };
2202
+ };
2203
+ }, "/">;
857
2204
 
858
2205
  /**
859
2206
  * RFC 9457 Problem Details interface
@@ -1181,39 +2528,15 @@ interface ResendWebhookPayload {
1181
2528
  }
1182
2529
 
1183
2530
  /**
1184
- * Email adapter interface for provider abstraction
1185
- * Allows for provider abstraction (currently Resend)
1186
- */
1187
- interface EmailSendOptions {
1188
- from: string;
1189
- to: string;
1190
- subject: string;
1191
- html: string;
1192
- text?: string;
1193
- tags?: Record<string, string>;
1194
- }
1195
- interface EmailSendResult {
1196
- success: boolean;
1197
- emailId?: string;
1198
- error?: string;
1199
- }
1200
- interface EmailAdapter {
1201
- /**
1202
- * Send an email through the provider
1203
- */
1204
- send(options: EmailSendOptions): Promise<EmailSendResult>;
1205
- /**
1206
- * Provider name for logging
1207
- */
1208
- readonly providerName: string;
1209
- }
1210
-
1211
- /**
1212
- * Create the Resend email adapter
2531
+ * Create the configured email adapter.
1213
2532
  *
1214
- * @param env - Environment variables
1215
- * @returns ResendAdapter instance
1216
- * @throws Error if RESEND_API_KEY is missing
2533
+ * Provider is selected by EMAIL_PROVIDER (defaults to 'resend' for backward
2534
+ * compatibility):
2535
+ * - 'resend': requires RESEND_API_KEY
2536
+ * - 'cloudflare': requires the EMAIL send_email Workers binding; dry-runs
2537
+ * (logs instead of sending) outside production/staging
2538
+ *
2539
+ * @throws Error if the selected provider's configuration is missing
1217
2540
  */
1218
2541
  declare function createEmailAdapter(env: Env): EmailAdapter;
1219
2542
 
@@ -1228,6 +2551,26 @@ declare class ResendAdapter implements EmailAdapter {
1228
2551
  send(options: EmailSendOptions): Promise<EmailSendResult>;
1229
2552
  }
1230
2553
 
2554
+ /**
2555
+ * Cloudflare Email Service adapter
2556
+ * Sends through the Workers `send_email` binding. Cloudflare manages bounce and
2557
+ * complaint suppression at the account level; a send to a suppressed address is
2558
+ * rejected with error code E_RECIPIENT_SUPPRESSED.
2559
+ *
2560
+ * In dry-run mode (any environment other than production/staging) it logs the
2561
+ * email and reports success without sending: Cloudflare has no test inbox and
2562
+ * real bounces damage sender reputation.
2563
+ */
2564
+ declare class CloudflareEmailAdapter implements EmailAdapter {
2565
+ private readonly binding;
2566
+ private readonly options;
2567
+ readonly providerName = "cloudflare";
2568
+ constructor(binding: SendEmailBinding, options: {
2569
+ dryRun: boolean;
2570
+ });
2571
+ send(options: EmailSendOptions): Promise<EmailSendResult>;
2572
+ }
2573
+
1231
2574
  type UsersTable$1 = PgTableWithColumns<any>;
1232
2575
  declare class EmailService {
1233
2576
  private adapter;
@@ -1247,31 +2590,31 @@ declare class EmailService {
1247
2590
  /**
1248
2591
  * Send verification email
1249
2592
  */
1250
- sendVerificationEmail(data: VerificationEmailData, db: PostgresJsDatabase<Record<string, unknown>>, usersTable: UsersTable$1): Promise<SendEmailResult>;
2593
+ sendVerificationEmail(data: VerificationEmailData, db: AuthDatabase, usersTable: UsersTable$1): Promise<SendEmailResult>;
1251
2594
  /**
1252
2595
  * Send password reset email
1253
2596
  */
1254
- sendPasswordResetEmail(data: PasswordResetEmailData, db: PostgresJsDatabase<Record<string, unknown>>, usersTable: UsersTable$1): Promise<SendEmailResult>;
2597
+ sendPasswordResetEmail(data: PasswordResetEmailData, db: AuthDatabase, usersTable: UsersTable$1): Promise<SendEmailResult>;
1255
2598
  /**
1256
2599
  * Send email change confirmation email (to new email address)
1257
2600
  */
1258
- sendEmailChangeConfirmation(data: EmailChangeConfirmationData, db: PostgresJsDatabase<Record<string, unknown>>, usersTable: UsersTable$1): Promise<SendEmailResult>;
2601
+ sendEmailChangeConfirmation(data: EmailChangeConfirmationData, db: AuthDatabase, usersTable: UsersTable$1): Promise<SendEmailResult>;
1259
2602
  /**
1260
2603
  * Send email change notification email (to old email address)
1261
2604
  */
1262
- sendEmailChangeNotification(data: EmailChangeNotificationData, db: PostgresJsDatabase<Record<string, unknown>>, usersTable: UsersTable$1): Promise<SendEmailResult>;
2605
+ sendEmailChangeNotification(data: EmailChangeNotificationData, db: AuthDatabase, usersTable: UsersTable$1): Promise<SendEmailResult>;
1263
2606
  /**
1264
2607
  * Send 2FA verification code email
1265
2608
  */
1266
- send2faCodeEmail(data: TwoFactorCodeEmailData, db: PostgresJsDatabase<Record<string, unknown>>, usersTable: UsersTable$1): Promise<SendEmailResult>;
2609
+ send2faCodeEmail(data: TwoFactorCodeEmailData, db: AuthDatabase, usersTable: UsersTable$1): Promise<SendEmailResult>;
1267
2610
  /**
1268
2611
  * Send 2FA enabled confirmation email
1269
2612
  */
1270
- send2faEnabledEmail(data: TwoFactorEnabledEmailData, db: PostgresJsDatabase<Record<string, unknown>>, usersTable: UsersTable$1): Promise<SendEmailResult>;
2613
+ send2faEnabledEmail(data: TwoFactorEnabledEmailData, db: AuthDatabase, usersTable: UsersTable$1): Promise<SendEmailResult>;
1271
2614
  /**
1272
2615
  * Send 2FA disabled notification email
1273
2616
  */
1274
- send2faDisabledEmail(data: TwoFactorDisabledEmailData, db: PostgresJsDatabase<Record<string, unknown>>, usersTable: UsersTable$1): Promise<SendEmailResult>;
2617
+ send2faDisabledEmail(data: TwoFactorDisabledEmailData, db: AuthDatabase, usersTable: UsersTable$1): Promise<SendEmailResult>;
1275
2618
  }
1276
2619
 
1277
2620
  /**
@@ -1336,4 +2679,4 @@ declare function calculateBounceRate(db: PostgresJsDatabase<Record<string, unkno
1336
2679
  */
1337
2680
  declare function calculateComplaintRate(db: PostgresJsDatabase<Record<string, unknown>>, emailEventsTable: EmailEventsTable, hoursAgo?: number): Promise<number>;
1338
2681
 
1339
- export { AUTH_DEFAULTS, type AccountLockoutTables, type Auth, type AuthConfig, type AuthContext, type AuthDatabase, type AuthSchema, CHALLENGE_TTL_MS, type ChallengePayload, type DeviceType, type EmailAdapter, type EmailChangeConfirmationData, type EmailChangeNotificationData, type EmailChangeTables, type EmailSendOptions, type EmailSendResult, EmailService, type EmailTemplate, type EmailType, type Env, type InferNewSession, type InferNewUser, type InferSession, type InferUser, MAX_CHALLENGE_ATTEMPTS, type PasswordResetEmailData, type ProblemDetails, ProblemTypes, ResendAdapter, type ResendEventType, type ResendWebhookPayload, type SendEmailResult, type SessionData, type SessionTables, TRUSTED_DEVICE_COOKIE_BASE, TRUSTED_DEVICE_TTL_MS, type TotpVerifyResult, type TwoFactorCodeEmailData, type TwoFactorDisabledEmailData, type TwoFactorEnabledEmailData, type ValidationResult, type Variables, type VerificationEmailData, auth as authRoutes, calculateBounceRate, calculateComplaintRate, cancelEmailChange, checkAccountLocked, checkBreachedPassword, clearAccountLockout, clearChallengeCookie, clearSessionCookie, clearTrustedDeviceCookie, confirmEmailChange, createAuth, createAuthMiddleware, createChallengeToken, createDeviceToken, createEmailAdapter, createProblemDetails, createSession, csrf, decryptTotpSecret, deleteAllUserSessions, deleteChallengeToken, deleteSession, encryptTotpSecret, extractAppUrl, formatBackupCode, generate2faCodeEmail, generate2faDisabledEmail, generate2faEnabledEmail, generateApiKey, generateBackupCodes, generateCodeChallenge, generateCodeVerifier, generateEmailChangeConfirmation, generateEmailChangeNotification, generateFingerprint, generatePasswordResetEmail, generateQrCodeUri, generateSecureToken, generateTotpSecret, generateTraceId, generateVerificationEmail, getAllowedOrigins, getAuthContext, getChallengeCookieName, getClientIp, getKeyPrefix, getMinutesUntilUnlock, getSessionCookieName, getTotpCounter, getTrustedDeviceCookieName, handleWebhookEvent, hashApiKey, hashBackupCode, hashPassword, hashToken, incrementFailedAttempts, invalidateAllUserSessions, isCapacitorApp, isCloudflarePreviewUrl, isDeepLinkUri, isValidApiKeyFormat, logError, logSecurityEvent, logger, normalizeBackupCode, optionalAuth, parseDeviceName, parseDeviceType, problemJson, problems, rateLimit, refreshSession, requestEmailChange, requireAuth, requireVerifiedEmail, retrieveChallengeToken, setChallengeCookie, setSessionCookie, setTrustedDeviceCookie, storeChallengeToken, updateChallengeAttempts, validateChallengePayload, validateOrigin, validatePassword, validatePasswordWithBreachCheck, validateSession, validateTrustedDevice, verifyBackupCode, verifyCodeChallenge, verifyPassword, verifyPasswordWithRotation, verifyTotpCode, verifyTurnstileToken, verifyWebhookSignature };
2682
+ export { AUTH_DEFAULTS, type AccountLockoutTables, type Auth, type AuthConfig, type AuthContext, type AuthDatabase, type AuthSchema, CHALLENGE_TTL_MS, type ChallengePayload, CloudflareEmailAdapter, type DeviceType, type EmailAdapter, type EmailChangeConfirmationData, type EmailChangeNotificationData, type EmailChangeTables, type EmailSendOptions, type EmailSendResult, EmailService, type EmailTemplate, type EmailType, type Env, type InferNewSession, type InferNewUser, type InferSession, type InferUser, MAX_CHALLENGE_ATTEMPTS, type PasswordResetEmailData, type ProblemDetails, ProblemTypes, ResendAdapter, type ResendEventType, type ResendWebhookPayload, type SendEmailBinding, type SendEmailResult, type SessionData, type SessionTables, TRUSTED_DEVICE_COOKIE_BASE, TRUSTED_DEVICE_TTL_MS, type TotpVerifyResult, type TwoFactorCodeEmailData, type TwoFactorDisabledEmailData, type TwoFactorEnabledEmailData, type ValidationResult, type Variables, type VerificationEmailData, authRoutes, calculateBounceRate, calculateComplaintRate, cancelEmailChange, checkAccountLocked, checkBreachedPassword, clearAccountLockout, clearChallengeCookie, clearSessionCookie, clearTrustedDeviceCookie, confirmEmailChange, createAuth, createAuthMiddleware, createChallengeToken, createDeviceToken, createEmailAdapter, createProblemDetails, createSession, csrf, decryptTotpSecret, deleteAllUserSessions, deleteChallengeToken, deleteSession, encryptTotpSecret, extractAppUrl, formatBackupCode, generate2faCodeEmail, generate2faDisabledEmail, generate2faEnabledEmail, generateApiKey, generateBackupCodes, generateCodeChallenge, generateCodeVerifier, generateEmailChangeConfirmation, generateEmailChangeNotification, generateFingerprint, generatePasswordResetEmail, generateQrCodeUri, generateSecureToken, generateTotpSecret, generateTraceId, generateVerificationEmail, getAllowedOrigins, getAuthContext, getChallengeCookieName, getClientIp, getKeyPrefix, getMinutesUntilUnlock, getSessionCookieName, getTotpCounter, getTrustedDeviceCookieName, handleWebhookEvent, hashApiKey, hashBackupCode, hashPassword, hashToken, incrementFailedAttempts, invalidateAllUserSessions, isCapacitorApp, isCloudflarePreviewUrl, isDeepLinkUri, isValidApiKeyFormat, logError, logSecurityEvent, logger, normalizeBackupCode, optionalAuth, parseDeviceName, parseDeviceType, problemJson, problems, rateLimit, refreshSession, requestEmailChange, requireAuth, requireVerifiedEmail, retrieveChallengeToken, setChallengeCookie, setSessionCookie, setTrustedDeviceCookie, storeChallengeToken, updateChallengeAttempts, validateChallengePayload, validateOrigin, validatePassword, validatePasswordWithBreachCheck, validateSession, validateTrustedDevice, verifyBackupCode, verifyCodeChallenge, verifyPassword, verifyPasswordWithRotation, verifyTotpCode, verifyTurnstileToken, verifyWebhookSignature };