@syncello/auth 3.3.0 → 3.4.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.cjs +96 -71
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +100 -81
- package/dist/index.d.ts +100 -81
- package/dist/index.js +96 -71
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -170,6 +170,93 @@ declare const AUTH_DEFAULTS: {
|
|
|
170
170
|
readonly APP_NAME: "App";
|
|
171
171
|
};
|
|
172
172
|
|
|
173
|
+
/**
|
|
174
|
+
* Email service types for Resend email provider integration
|
|
175
|
+
*/
|
|
176
|
+
interface EmailTemplate {
|
|
177
|
+
to: string;
|
|
178
|
+
subject: string;
|
|
179
|
+
html: string;
|
|
180
|
+
text?: string;
|
|
181
|
+
tags?: Record<string, string>;
|
|
182
|
+
}
|
|
183
|
+
interface VerificationEmailData {
|
|
184
|
+
email: string;
|
|
185
|
+
token: string;
|
|
186
|
+
verificationUrl: string;
|
|
187
|
+
firstName?: string;
|
|
188
|
+
}
|
|
189
|
+
interface PasswordResetEmailData {
|
|
190
|
+
email: string;
|
|
191
|
+
token: string;
|
|
192
|
+
resetUrl: string;
|
|
193
|
+
}
|
|
194
|
+
interface EmailChangeConfirmationData {
|
|
195
|
+
newEmail: string;
|
|
196
|
+
confirmUrl: string;
|
|
197
|
+
}
|
|
198
|
+
interface EmailChangeNotificationData {
|
|
199
|
+
oldEmail: string;
|
|
200
|
+
newEmail: string;
|
|
201
|
+
cancelUrl: string;
|
|
202
|
+
}
|
|
203
|
+
interface TwoFactorCodeEmailData {
|
|
204
|
+
email: string;
|
|
205
|
+
firstName: string | null;
|
|
206
|
+
code: string;
|
|
207
|
+
}
|
|
208
|
+
interface TwoFactorEnabledEmailData {
|
|
209
|
+
email: string;
|
|
210
|
+
firstName: string | null;
|
|
211
|
+
method: 'totp' | 'email';
|
|
212
|
+
}
|
|
213
|
+
interface TwoFactorDisabledEmailData {
|
|
214
|
+
email: string;
|
|
215
|
+
firstName: string | null;
|
|
216
|
+
}
|
|
217
|
+
type EmailType = 'verification' | 'password_reset' | 'email_change_confirmation' | 'email_change_notification' | '2fa_code' | '2fa_enabled' | '2fa_disabled';
|
|
218
|
+
interface SendEmailResult {
|
|
219
|
+
success: boolean;
|
|
220
|
+
emailId?: string;
|
|
221
|
+
error?: string;
|
|
222
|
+
}
|
|
223
|
+
type ResendEventType = 'email.sent' | 'email.delivered' | 'email.delivery_delayed' | 'email.complained' | 'email.bounced' | 'email.opened' | 'email.clicked' | 'email.failed';
|
|
224
|
+
interface ResendWebhookPayload {
|
|
225
|
+
type: ResendEventType;
|
|
226
|
+
created_at: string;
|
|
227
|
+
data: {
|
|
228
|
+
email_id: string;
|
|
229
|
+
from: string;
|
|
230
|
+
to: string[];
|
|
231
|
+
subject: string;
|
|
232
|
+
created_at: string;
|
|
233
|
+
tags?: Record<string, string>;
|
|
234
|
+
bounce?: {
|
|
235
|
+
message: string;
|
|
236
|
+
subType: string;
|
|
237
|
+
type: 'Permanent' | 'Transient';
|
|
238
|
+
};
|
|
239
|
+
failed?: {
|
|
240
|
+
reason: string;
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
/** Consumer-supplied branding tokens for transactional emails. */
|
|
245
|
+
interface EmailBranding {
|
|
246
|
+
/** Full URL to the header logo. Default: `${appUrl}/email-header-image.png` */
|
|
247
|
+
logoUrl?: string;
|
|
248
|
+
/** CTA button background. Default: '#00fe9a' */
|
|
249
|
+
buttonBgColor?: string;
|
|
250
|
+
/** CTA button text color. Default: '#000004' */
|
|
251
|
+
buttonTextColor?: string;
|
|
252
|
+
/** CTA button font weight. Default: 500 */
|
|
253
|
+
buttonFontWeight?: number;
|
|
254
|
+
/** CTA button border-radius. Default: '6px' */
|
|
255
|
+
buttonRadius?: string;
|
|
256
|
+
/** Footer band background color. Default: '#1e1b4b' */
|
|
257
|
+
footerColor?: string;
|
|
258
|
+
}
|
|
259
|
+
|
|
173
260
|
/**
|
|
174
261
|
* Base type for auth tables.
|
|
175
262
|
*
|
|
@@ -241,6 +328,8 @@ interface AuthConfig<TEnv = Record<string, unknown>> {
|
|
|
241
328
|
schema: AuthSchema;
|
|
242
329
|
/** Environment variables accessor */
|
|
243
330
|
getEnv: (c: Context) => TEnv;
|
|
331
|
+
/** Optional email branding tokens */
|
|
332
|
+
emailBranding?: EmailBranding;
|
|
244
333
|
}
|
|
245
334
|
/**
|
|
246
335
|
* Auth context available in all auth operations.
|
|
@@ -250,6 +339,7 @@ interface AuthContext<TEnv = Record<string, unknown>> {
|
|
|
250
339
|
db: AuthDatabase;
|
|
251
340
|
schema: AuthSchema;
|
|
252
341
|
env: TEnv;
|
|
342
|
+
emailBranding?: EmailBranding;
|
|
253
343
|
}
|
|
254
344
|
/**
|
|
255
345
|
* Creates an auth instance with injected database and schema.
|
|
@@ -2457,78 +2547,6 @@ declare function logError(error: Error | unknown, context?: LogMetadata): void;
|
|
|
2457
2547
|
*/
|
|
2458
2548
|
declare function logSecurityEvent(event: string, severity: 'low' | 'medium' | 'high' | 'critical', metadata?: LogMetadata): void;
|
|
2459
2549
|
|
|
2460
|
-
/**
|
|
2461
|
-
* Email service types for Resend email provider integration
|
|
2462
|
-
*/
|
|
2463
|
-
interface EmailTemplate {
|
|
2464
|
-
to: string;
|
|
2465
|
-
subject: string;
|
|
2466
|
-
html: string;
|
|
2467
|
-
text?: string;
|
|
2468
|
-
tags?: Record<string, string>;
|
|
2469
|
-
}
|
|
2470
|
-
interface VerificationEmailData {
|
|
2471
|
-
email: string;
|
|
2472
|
-
token: string;
|
|
2473
|
-
verificationUrl: string;
|
|
2474
|
-
firstName?: string;
|
|
2475
|
-
}
|
|
2476
|
-
interface PasswordResetEmailData {
|
|
2477
|
-
email: string;
|
|
2478
|
-
token: string;
|
|
2479
|
-
resetUrl: string;
|
|
2480
|
-
}
|
|
2481
|
-
interface EmailChangeConfirmationData {
|
|
2482
|
-
newEmail: string;
|
|
2483
|
-
confirmUrl: string;
|
|
2484
|
-
}
|
|
2485
|
-
interface EmailChangeNotificationData {
|
|
2486
|
-
oldEmail: string;
|
|
2487
|
-
newEmail: string;
|
|
2488
|
-
cancelUrl: string;
|
|
2489
|
-
}
|
|
2490
|
-
interface TwoFactorCodeEmailData {
|
|
2491
|
-
email: string;
|
|
2492
|
-
firstName: string | null;
|
|
2493
|
-
code: string;
|
|
2494
|
-
}
|
|
2495
|
-
interface TwoFactorEnabledEmailData {
|
|
2496
|
-
email: string;
|
|
2497
|
-
firstName: string | null;
|
|
2498
|
-
method: 'totp' | 'email';
|
|
2499
|
-
}
|
|
2500
|
-
interface TwoFactorDisabledEmailData {
|
|
2501
|
-
email: string;
|
|
2502
|
-
firstName: string | null;
|
|
2503
|
-
}
|
|
2504
|
-
type EmailType = 'verification' | 'password_reset' | 'email_change_confirmation' | 'email_change_notification' | '2fa_code' | '2fa_enabled' | '2fa_disabled';
|
|
2505
|
-
interface SendEmailResult {
|
|
2506
|
-
success: boolean;
|
|
2507
|
-
emailId?: string;
|
|
2508
|
-
error?: string;
|
|
2509
|
-
}
|
|
2510
|
-
type ResendEventType = 'email.sent' | 'email.delivered' | 'email.delivery_delayed' | 'email.complained' | 'email.bounced' | 'email.opened' | 'email.clicked' | 'email.failed';
|
|
2511
|
-
interface ResendWebhookPayload {
|
|
2512
|
-
type: ResendEventType;
|
|
2513
|
-
created_at: string;
|
|
2514
|
-
data: {
|
|
2515
|
-
email_id: string;
|
|
2516
|
-
from: string;
|
|
2517
|
-
to: string[];
|
|
2518
|
-
subject: string;
|
|
2519
|
-
created_at: string;
|
|
2520
|
-
tags?: Record<string, string>;
|
|
2521
|
-
bounce?: {
|
|
2522
|
-
message: string;
|
|
2523
|
-
subType: string;
|
|
2524
|
-
type: 'Permanent' | 'Transient';
|
|
2525
|
-
};
|
|
2526
|
-
failed?: {
|
|
2527
|
-
reason: string;
|
|
2528
|
-
};
|
|
2529
|
-
};
|
|
2530
|
-
}
|
|
2531
|
-
|
|
2532
2550
|
/**
|
|
2533
2551
|
* Create the configured email adapter.
|
|
2534
2552
|
*
|
|
@@ -2577,8 +2595,9 @@ type UsersTable$1 = PgTableWithColumns<any>;
|
|
|
2577
2595
|
declare class EmailService {
|
|
2578
2596
|
private adapter;
|
|
2579
2597
|
private env;
|
|
2598
|
+
private branding?;
|
|
2580
2599
|
private get fromAddress();
|
|
2581
|
-
constructor(env: Env, adapter?: EmailAdapter);
|
|
2600
|
+
constructor(env: Env, adapter?: EmailAdapter, branding?: EmailBranding);
|
|
2582
2601
|
/**
|
|
2583
2602
|
* Check if email address has bounced or complained
|
|
2584
2603
|
*/
|
|
@@ -2626,31 +2645,31 @@ declare function extractAppUrl(url: string): string;
|
|
|
2626
2645
|
/**
|
|
2627
2646
|
* Generate email verification email
|
|
2628
2647
|
*/
|
|
2629
|
-
declare function generateVerificationEmail(data: VerificationEmailData, appName?: string, configuredAppUrl?: string): EmailTemplate;
|
|
2648
|
+
declare function generateVerificationEmail(data: VerificationEmailData, appName?: string, configuredAppUrl?: string, branding?: EmailBranding): EmailTemplate;
|
|
2630
2649
|
/**
|
|
2631
2650
|
* Generate password reset email
|
|
2632
2651
|
*/
|
|
2633
|
-
declare function generatePasswordResetEmail(data: PasswordResetEmailData, appName?: string, configuredAppUrl?: string): EmailTemplate;
|
|
2652
|
+
declare function generatePasswordResetEmail(data: PasswordResetEmailData, appName?: string, configuredAppUrl?: string, branding?: EmailBranding): EmailTemplate;
|
|
2634
2653
|
/**
|
|
2635
2654
|
* Generate email change confirmation email (sent to NEW email)
|
|
2636
2655
|
*/
|
|
2637
|
-
declare function generateEmailChangeConfirmation(data: EmailChangeConfirmationData, appName?: string, configuredAppUrl?: string): EmailTemplate;
|
|
2656
|
+
declare function generateEmailChangeConfirmation(data: EmailChangeConfirmationData, appName?: string, configuredAppUrl?: string, branding?: EmailBranding): EmailTemplate;
|
|
2638
2657
|
/**
|
|
2639
2658
|
* Generate email change notification email (sent to OLD email)
|
|
2640
2659
|
*/
|
|
2641
|
-
declare function generateEmailChangeNotification(data: EmailChangeNotificationData, appName?: string, configuredAppUrl?: string): EmailTemplate;
|
|
2660
|
+
declare function generateEmailChangeNotification(data: EmailChangeNotificationData, appName?: string, configuredAppUrl?: string, branding?: EmailBranding): EmailTemplate;
|
|
2642
2661
|
/**
|
|
2643
2662
|
* Generate 2FA verification code email
|
|
2644
2663
|
*/
|
|
2645
|
-
declare function generate2faCodeEmail(data: TwoFactorCodeEmailData, appName?: string, appUrl?: string): EmailTemplate;
|
|
2664
|
+
declare function generate2faCodeEmail(data: TwoFactorCodeEmailData, appName?: string, appUrl?: string, branding?: EmailBranding): EmailTemplate;
|
|
2646
2665
|
/**
|
|
2647
2666
|
* Generate 2FA enabled confirmation email
|
|
2648
2667
|
*/
|
|
2649
|
-
declare function generate2faEnabledEmail(data: TwoFactorEnabledEmailData, appName?: string, appUrl?: string): EmailTemplate;
|
|
2668
|
+
declare function generate2faEnabledEmail(data: TwoFactorEnabledEmailData, appName?: string, appUrl?: string, branding?: EmailBranding): EmailTemplate;
|
|
2650
2669
|
/**
|
|
2651
2670
|
* Generate 2FA disabled notification email
|
|
2652
2671
|
*/
|
|
2653
|
-
declare function generate2faDisabledEmail(data: TwoFactorDisabledEmailData, appName?: string, appUrl?: string): EmailTemplate;
|
|
2672
|
+
declare function generate2faDisabledEmail(data: TwoFactorDisabledEmailData, appName?: string, appUrl?: string, branding?: EmailBranding): EmailTemplate;
|
|
2654
2673
|
|
|
2655
2674
|
type EmailEventsTable$1 = PgTableWithColumns<any>;
|
|
2656
2675
|
type UsersTable = PgTableWithColumns<any>;
|
|
@@ -2681,4 +2700,4 @@ declare function calculateBounceRate(db: PostgresJsDatabase<Record<string, unkno
|
|
|
2681
2700
|
*/
|
|
2682
2701
|
declare function calculateComplaintRate(db: PostgresJsDatabase<Record<string, unknown>>, emailEventsTable: EmailEventsTable, hoursAgo?: number): Promise<number>;
|
|
2683
2702
|
|
|
2684
|
-
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 };
|
|
2703
|
+
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 EmailBranding, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -170,6 +170,93 @@ declare const AUTH_DEFAULTS: {
|
|
|
170
170
|
readonly APP_NAME: "App";
|
|
171
171
|
};
|
|
172
172
|
|
|
173
|
+
/**
|
|
174
|
+
* Email service types for Resend email provider integration
|
|
175
|
+
*/
|
|
176
|
+
interface EmailTemplate {
|
|
177
|
+
to: string;
|
|
178
|
+
subject: string;
|
|
179
|
+
html: string;
|
|
180
|
+
text?: string;
|
|
181
|
+
tags?: Record<string, string>;
|
|
182
|
+
}
|
|
183
|
+
interface VerificationEmailData {
|
|
184
|
+
email: string;
|
|
185
|
+
token: string;
|
|
186
|
+
verificationUrl: string;
|
|
187
|
+
firstName?: string;
|
|
188
|
+
}
|
|
189
|
+
interface PasswordResetEmailData {
|
|
190
|
+
email: string;
|
|
191
|
+
token: string;
|
|
192
|
+
resetUrl: string;
|
|
193
|
+
}
|
|
194
|
+
interface EmailChangeConfirmationData {
|
|
195
|
+
newEmail: string;
|
|
196
|
+
confirmUrl: string;
|
|
197
|
+
}
|
|
198
|
+
interface EmailChangeNotificationData {
|
|
199
|
+
oldEmail: string;
|
|
200
|
+
newEmail: string;
|
|
201
|
+
cancelUrl: string;
|
|
202
|
+
}
|
|
203
|
+
interface TwoFactorCodeEmailData {
|
|
204
|
+
email: string;
|
|
205
|
+
firstName: string | null;
|
|
206
|
+
code: string;
|
|
207
|
+
}
|
|
208
|
+
interface TwoFactorEnabledEmailData {
|
|
209
|
+
email: string;
|
|
210
|
+
firstName: string | null;
|
|
211
|
+
method: 'totp' | 'email';
|
|
212
|
+
}
|
|
213
|
+
interface TwoFactorDisabledEmailData {
|
|
214
|
+
email: string;
|
|
215
|
+
firstName: string | null;
|
|
216
|
+
}
|
|
217
|
+
type EmailType = 'verification' | 'password_reset' | 'email_change_confirmation' | 'email_change_notification' | '2fa_code' | '2fa_enabled' | '2fa_disabled';
|
|
218
|
+
interface SendEmailResult {
|
|
219
|
+
success: boolean;
|
|
220
|
+
emailId?: string;
|
|
221
|
+
error?: string;
|
|
222
|
+
}
|
|
223
|
+
type ResendEventType = 'email.sent' | 'email.delivered' | 'email.delivery_delayed' | 'email.complained' | 'email.bounced' | 'email.opened' | 'email.clicked' | 'email.failed';
|
|
224
|
+
interface ResendWebhookPayload {
|
|
225
|
+
type: ResendEventType;
|
|
226
|
+
created_at: string;
|
|
227
|
+
data: {
|
|
228
|
+
email_id: string;
|
|
229
|
+
from: string;
|
|
230
|
+
to: string[];
|
|
231
|
+
subject: string;
|
|
232
|
+
created_at: string;
|
|
233
|
+
tags?: Record<string, string>;
|
|
234
|
+
bounce?: {
|
|
235
|
+
message: string;
|
|
236
|
+
subType: string;
|
|
237
|
+
type: 'Permanent' | 'Transient';
|
|
238
|
+
};
|
|
239
|
+
failed?: {
|
|
240
|
+
reason: string;
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
/** Consumer-supplied branding tokens for transactional emails. */
|
|
245
|
+
interface EmailBranding {
|
|
246
|
+
/** Full URL to the header logo. Default: `${appUrl}/email-header-image.png` */
|
|
247
|
+
logoUrl?: string;
|
|
248
|
+
/** CTA button background. Default: '#00fe9a' */
|
|
249
|
+
buttonBgColor?: string;
|
|
250
|
+
/** CTA button text color. Default: '#000004' */
|
|
251
|
+
buttonTextColor?: string;
|
|
252
|
+
/** CTA button font weight. Default: 500 */
|
|
253
|
+
buttonFontWeight?: number;
|
|
254
|
+
/** CTA button border-radius. Default: '6px' */
|
|
255
|
+
buttonRadius?: string;
|
|
256
|
+
/** Footer band background color. Default: '#1e1b4b' */
|
|
257
|
+
footerColor?: string;
|
|
258
|
+
}
|
|
259
|
+
|
|
173
260
|
/**
|
|
174
261
|
* Base type for auth tables.
|
|
175
262
|
*
|
|
@@ -241,6 +328,8 @@ interface AuthConfig<TEnv = Record<string, unknown>> {
|
|
|
241
328
|
schema: AuthSchema;
|
|
242
329
|
/** Environment variables accessor */
|
|
243
330
|
getEnv: (c: Context) => TEnv;
|
|
331
|
+
/** Optional email branding tokens */
|
|
332
|
+
emailBranding?: EmailBranding;
|
|
244
333
|
}
|
|
245
334
|
/**
|
|
246
335
|
* Auth context available in all auth operations.
|
|
@@ -250,6 +339,7 @@ interface AuthContext<TEnv = Record<string, unknown>> {
|
|
|
250
339
|
db: AuthDatabase;
|
|
251
340
|
schema: AuthSchema;
|
|
252
341
|
env: TEnv;
|
|
342
|
+
emailBranding?: EmailBranding;
|
|
253
343
|
}
|
|
254
344
|
/**
|
|
255
345
|
* Creates an auth instance with injected database and schema.
|
|
@@ -2457,78 +2547,6 @@ declare function logError(error: Error | unknown, context?: LogMetadata): void;
|
|
|
2457
2547
|
*/
|
|
2458
2548
|
declare function logSecurityEvent(event: string, severity: 'low' | 'medium' | 'high' | 'critical', metadata?: LogMetadata): void;
|
|
2459
2549
|
|
|
2460
|
-
/**
|
|
2461
|
-
* Email service types for Resend email provider integration
|
|
2462
|
-
*/
|
|
2463
|
-
interface EmailTemplate {
|
|
2464
|
-
to: string;
|
|
2465
|
-
subject: string;
|
|
2466
|
-
html: string;
|
|
2467
|
-
text?: string;
|
|
2468
|
-
tags?: Record<string, string>;
|
|
2469
|
-
}
|
|
2470
|
-
interface VerificationEmailData {
|
|
2471
|
-
email: string;
|
|
2472
|
-
token: string;
|
|
2473
|
-
verificationUrl: string;
|
|
2474
|
-
firstName?: string;
|
|
2475
|
-
}
|
|
2476
|
-
interface PasswordResetEmailData {
|
|
2477
|
-
email: string;
|
|
2478
|
-
token: string;
|
|
2479
|
-
resetUrl: string;
|
|
2480
|
-
}
|
|
2481
|
-
interface EmailChangeConfirmationData {
|
|
2482
|
-
newEmail: string;
|
|
2483
|
-
confirmUrl: string;
|
|
2484
|
-
}
|
|
2485
|
-
interface EmailChangeNotificationData {
|
|
2486
|
-
oldEmail: string;
|
|
2487
|
-
newEmail: string;
|
|
2488
|
-
cancelUrl: string;
|
|
2489
|
-
}
|
|
2490
|
-
interface TwoFactorCodeEmailData {
|
|
2491
|
-
email: string;
|
|
2492
|
-
firstName: string | null;
|
|
2493
|
-
code: string;
|
|
2494
|
-
}
|
|
2495
|
-
interface TwoFactorEnabledEmailData {
|
|
2496
|
-
email: string;
|
|
2497
|
-
firstName: string | null;
|
|
2498
|
-
method: 'totp' | 'email';
|
|
2499
|
-
}
|
|
2500
|
-
interface TwoFactorDisabledEmailData {
|
|
2501
|
-
email: string;
|
|
2502
|
-
firstName: string | null;
|
|
2503
|
-
}
|
|
2504
|
-
type EmailType = 'verification' | 'password_reset' | 'email_change_confirmation' | 'email_change_notification' | '2fa_code' | '2fa_enabled' | '2fa_disabled';
|
|
2505
|
-
interface SendEmailResult {
|
|
2506
|
-
success: boolean;
|
|
2507
|
-
emailId?: string;
|
|
2508
|
-
error?: string;
|
|
2509
|
-
}
|
|
2510
|
-
type ResendEventType = 'email.sent' | 'email.delivered' | 'email.delivery_delayed' | 'email.complained' | 'email.bounced' | 'email.opened' | 'email.clicked' | 'email.failed';
|
|
2511
|
-
interface ResendWebhookPayload {
|
|
2512
|
-
type: ResendEventType;
|
|
2513
|
-
created_at: string;
|
|
2514
|
-
data: {
|
|
2515
|
-
email_id: string;
|
|
2516
|
-
from: string;
|
|
2517
|
-
to: string[];
|
|
2518
|
-
subject: string;
|
|
2519
|
-
created_at: string;
|
|
2520
|
-
tags?: Record<string, string>;
|
|
2521
|
-
bounce?: {
|
|
2522
|
-
message: string;
|
|
2523
|
-
subType: string;
|
|
2524
|
-
type: 'Permanent' | 'Transient';
|
|
2525
|
-
};
|
|
2526
|
-
failed?: {
|
|
2527
|
-
reason: string;
|
|
2528
|
-
};
|
|
2529
|
-
};
|
|
2530
|
-
}
|
|
2531
|
-
|
|
2532
2550
|
/**
|
|
2533
2551
|
* Create the configured email adapter.
|
|
2534
2552
|
*
|
|
@@ -2577,8 +2595,9 @@ type UsersTable$1 = PgTableWithColumns<any>;
|
|
|
2577
2595
|
declare class EmailService {
|
|
2578
2596
|
private adapter;
|
|
2579
2597
|
private env;
|
|
2598
|
+
private branding?;
|
|
2580
2599
|
private get fromAddress();
|
|
2581
|
-
constructor(env: Env, adapter?: EmailAdapter);
|
|
2600
|
+
constructor(env: Env, adapter?: EmailAdapter, branding?: EmailBranding);
|
|
2582
2601
|
/**
|
|
2583
2602
|
* Check if email address has bounced or complained
|
|
2584
2603
|
*/
|
|
@@ -2626,31 +2645,31 @@ declare function extractAppUrl(url: string): string;
|
|
|
2626
2645
|
/**
|
|
2627
2646
|
* Generate email verification email
|
|
2628
2647
|
*/
|
|
2629
|
-
declare function generateVerificationEmail(data: VerificationEmailData, appName?: string, configuredAppUrl?: string): EmailTemplate;
|
|
2648
|
+
declare function generateVerificationEmail(data: VerificationEmailData, appName?: string, configuredAppUrl?: string, branding?: EmailBranding): EmailTemplate;
|
|
2630
2649
|
/**
|
|
2631
2650
|
* Generate password reset email
|
|
2632
2651
|
*/
|
|
2633
|
-
declare function generatePasswordResetEmail(data: PasswordResetEmailData, appName?: string, configuredAppUrl?: string): EmailTemplate;
|
|
2652
|
+
declare function generatePasswordResetEmail(data: PasswordResetEmailData, appName?: string, configuredAppUrl?: string, branding?: EmailBranding): EmailTemplate;
|
|
2634
2653
|
/**
|
|
2635
2654
|
* Generate email change confirmation email (sent to NEW email)
|
|
2636
2655
|
*/
|
|
2637
|
-
declare function generateEmailChangeConfirmation(data: EmailChangeConfirmationData, appName?: string, configuredAppUrl?: string): EmailTemplate;
|
|
2656
|
+
declare function generateEmailChangeConfirmation(data: EmailChangeConfirmationData, appName?: string, configuredAppUrl?: string, branding?: EmailBranding): EmailTemplate;
|
|
2638
2657
|
/**
|
|
2639
2658
|
* Generate email change notification email (sent to OLD email)
|
|
2640
2659
|
*/
|
|
2641
|
-
declare function generateEmailChangeNotification(data: EmailChangeNotificationData, appName?: string, configuredAppUrl?: string): EmailTemplate;
|
|
2660
|
+
declare function generateEmailChangeNotification(data: EmailChangeNotificationData, appName?: string, configuredAppUrl?: string, branding?: EmailBranding): EmailTemplate;
|
|
2642
2661
|
/**
|
|
2643
2662
|
* Generate 2FA verification code email
|
|
2644
2663
|
*/
|
|
2645
|
-
declare function generate2faCodeEmail(data: TwoFactorCodeEmailData, appName?: string, appUrl?: string): EmailTemplate;
|
|
2664
|
+
declare function generate2faCodeEmail(data: TwoFactorCodeEmailData, appName?: string, appUrl?: string, branding?: EmailBranding): EmailTemplate;
|
|
2646
2665
|
/**
|
|
2647
2666
|
* Generate 2FA enabled confirmation email
|
|
2648
2667
|
*/
|
|
2649
|
-
declare function generate2faEnabledEmail(data: TwoFactorEnabledEmailData, appName?: string, appUrl?: string): EmailTemplate;
|
|
2668
|
+
declare function generate2faEnabledEmail(data: TwoFactorEnabledEmailData, appName?: string, appUrl?: string, branding?: EmailBranding): EmailTemplate;
|
|
2650
2669
|
/**
|
|
2651
2670
|
* Generate 2FA disabled notification email
|
|
2652
2671
|
*/
|
|
2653
|
-
declare function generate2faDisabledEmail(data: TwoFactorDisabledEmailData, appName?: string, appUrl?: string): EmailTemplate;
|
|
2672
|
+
declare function generate2faDisabledEmail(data: TwoFactorDisabledEmailData, appName?: string, appUrl?: string, branding?: EmailBranding): EmailTemplate;
|
|
2654
2673
|
|
|
2655
2674
|
type EmailEventsTable$1 = PgTableWithColumns<any>;
|
|
2656
2675
|
type UsersTable = PgTableWithColumns<any>;
|
|
@@ -2681,4 +2700,4 @@ declare function calculateBounceRate(db: PostgresJsDatabase<Record<string, unkno
|
|
|
2681
2700
|
*/
|
|
2682
2701
|
declare function calculateComplaintRate(db: PostgresJsDatabase<Record<string, unknown>>, emailEventsTable: EmailEventsTable, hoursAgo?: number): Promise<number>;
|
|
2683
2702
|
|
|
2684
|
-
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 };
|
|
2703
|
+
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 EmailBranding, 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 };
|