@syncello/auth 4.1.0 → 4.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
@@ -251,6 +251,14 @@ interface ResendWebhookPayload {
251
251
  interface EmailBranding {
252
252
  /** Full URL to the header logo. Default: `${appUrl}/email-header-image.png` */
253
253
  logoUrl?: string;
254
+ /**
255
+ * Logo width in CSS px. With `logoHeight`, the logo renders at that fixed size with `width`
256
+ * and `height` attributes, so clients reserve its space and Outlook sizes it right. Default:
257
+ * unset, and the logo fills half the email's width.
258
+ */
259
+ logoWidth?: number;
260
+ /** Logo height in CSS px; required with `logoWidth`. */
261
+ logoHeight?: number;
254
262
  /** CTA button background. Default: '#00fe9a' */
255
263
  buttonBgColor?: string;
256
264
  /** CTA button text color. Default: '#000004' */
@@ -2855,6 +2863,52 @@ declare function generate2faEnabledEmail(data: TwoFactorEnabledEmailData, appNam
2855
2863
  */
2856
2864
  declare function generate2faDisabledEmail(data: TwoFactorDisabledEmailData, appName?: string, appUrl?: string, branding?: EmailBranding): EmailTemplate;
2857
2865
 
2866
+ /**
2867
+ * The HTML email template: a white card on a light page, the logo, heading, body, an optional
2868
+ * button with its link to copy, an optional notice, a footer note and the footer band, coloured
2869
+ * from the branding options. Tables and inline styles throughout, and a VML button for Outlook.
2870
+ */
2871
+
2872
+ /** A consumer's own email, in plain text: {@link renderEmail} escapes every value. */
2873
+ interface EmailContent {
2874
+ /** The heading, also the document title. */
2875
+ heading: string;
2876
+ /** Body paragraphs; a newline inside one becomes a line break. */
2877
+ paragraphs: readonly string[];
2878
+ /** Lists after the paragraphs, such as a digest's records. */
2879
+ sections?: readonly EmailSection[];
2880
+ /** A button after the body, with its link to copy underneath. */
2881
+ button?: {
2882
+ label: string;
2883
+ url: string;
2884
+ };
2885
+ /** A neutral callout under the button, such as a link's lifetime. */
2886
+ notice?: string;
2887
+ /** Small print at the end of the card. */
2888
+ footerNote?: string;
2889
+ /** The app's base URL: the default logo's host, and the host every link must be on. */
2890
+ appUrl: string;
2891
+ /** Named in the logo's alt text and the footer (default: "App"). */
2892
+ appName?: string;
2893
+ branding?: EmailBranding;
2894
+ }
2895
+ /** A titled list in an {@link EmailContent}; each `url` must be on the app's host. */
2896
+ interface EmailSection {
2897
+ title: string;
2898
+ url?: string;
2899
+ rows: readonly {
2900
+ text: string;
2901
+ url?: string;
2902
+ }[];
2903
+ }
2904
+ /**
2905
+ * Render a consumer's own email in the template the auth emails use, so it matches them and
2906
+ * follows their branding. Every value is plain text and escaped here; every URL must be http(s)
2907
+ * on `appUrl`'s host or a subdomain.
2908
+ * @throws If a URL is not http(s) on `appUrl`'s host, or the logo size is invalid
2909
+ */
2910
+ declare function renderEmail(content: EmailContent): string;
2911
+
2858
2912
  type EmailEventsTable$1 = PgTableWithColumns<any>;
2859
2913
  type UsersTable = PgTableWithColumns<any>;
2860
2914
  /**
@@ -2890,4 +2944,4 @@ declare function calculateBounceRate(db: PostgresJsDatabase<Record<string, unkno
2890
2944
  */
2891
2945
  declare function calculateComplaintRate(db: PostgresJsDatabase<Record<string, unknown>>, emailEventsTable: EmailEventsTable, hoursAgo?: number): Promise<number>;
2892
2946
 
2893
- 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, type InvitationHookUser, type InvitationHooks, MAX_CHALLENGE_ATTEMPTS, PASSWORDLESS_MAX_ATTEMPTS, PASSWORDLESS_TTL_MS, type PasswordResetEmailData, type PasswordlessCodeResult, type PasswordlessLinkResult, type PasswordlessSuccess, type PasswordlessTables, type ProblemDetails, ProblemTypes, ResendAdapter, type ResendEventType, type ResendWebhookPayload, type SendEmailBinding, type SendEmailResult, type SessionData, type SessionTables, type SignupMode, type SvixHeaders, 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, cleanupExpiredPasswordlessChallenges, clearAccountLockout, clearChallengeCookie, clearSessionCookie, clearTrustedDeviceCookie, confirmEmailChange, createAuth, createAuthMiddleware, createChallengeToken, createDeviceToken, createEmailAdapter, createPasswordlessChallenge, createProblemDetails, createSession, csrf, decryptTotpSecret, deleteAllUserSessions, deleteChallengeToken, deleteSession, encryptTotpSecret, extractAppUrl, formatBackupCode, generate2faCodeEmail, generate2faDisabledEmail, generate2faEnabledEmail, generateApiKey, generateBackupCodes, generateCode, 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, passwordlessEmail, problemJson, problems, rateLimit, recentPasswordlessFailures, refreshSession, requestEmailChange, requireAuth, requireVerifiedEmail, retrieveChallengeToken, sessionRefreshDue, setChallengeCookie, setSessionCookie, setTrustedDeviceCookie, storeChallengeToken, updateChallengeAttempts, validateChallengePayload, validateOrigin, validatePassword, validatePasswordWithBreachCheck, validateSession, validateTrustedDevice, verifyBackupCode, verifyCodeChallenge, verifyPassword, verifyPasswordWithRotation, verifyPasswordlessCode, verifyPasswordlessLink, verifyTotpCode, verifyTurnstileToken, verifyWebhookSignature };
2947
+ 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 EmailContent, type EmailSection, type EmailSendOptions, type EmailSendResult, EmailService, type EmailTemplate, type EmailType, type Env, type InferNewSession, type InferNewUser, type InferSession, type InferUser, type InvitationHookUser, type InvitationHooks, MAX_CHALLENGE_ATTEMPTS, PASSWORDLESS_MAX_ATTEMPTS, PASSWORDLESS_TTL_MS, type PasswordResetEmailData, type PasswordlessCodeResult, type PasswordlessLinkResult, type PasswordlessSuccess, type PasswordlessTables, type ProblemDetails, ProblemTypes, ResendAdapter, type ResendEventType, type ResendWebhookPayload, type SendEmailBinding, type SendEmailResult, type SessionData, type SessionTables, type SignupMode, type SvixHeaders, 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, cleanupExpiredPasswordlessChallenges, clearAccountLockout, clearChallengeCookie, clearSessionCookie, clearTrustedDeviceCookie, confirmEmailChange, createAuth, createAuthMiddleware, createChallengeToken, createDeviceToken, createEmailAdapter, createPasswordlessChallenge, createProblemDetails, createSession, csrf, decryptTotpSecret, deleteAllUserSessions, deleteChallengeToken, deleteSession, encryptTotpSecret, extractAppUrl, formatBackupCode, generate2faCodeEmail, generate2faDisabledEmail, generate2faEnabledEmail, generateApiKey, generateBackupCodes, generateCode, 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, passwordlessEmail, problemJson, problems, rateLimit, recentPasswordlessFailures, refreshSession, renderEmail, requestEmailChange, requireAuth, requireVerifiedEmail, retrieveChallengeToken, sessionRefreshDue, setChallengeCookie, setSessionCookie, setTrustedDeviceCookie, storeChallengeToken, updateChallengeAttempts, validateChallengePayload, validateOrigin, validatePassword, validatePasswordWithBreachCheck, validateSession, validateTrustedDevice, verifyBackupCode, verifyCodeChallenge, verifyPassword, verifyPasswordWithRotation, verifyPasswordlessCode, verifyPasswordlessLink, verifyTotpCode, verifyTurnstileToken, verifyWebhookSignature };
package/dist/index.d.ts CHANGED
@@ -251,6 +251,14 @@ interface ResendWebhookPayload {
251
251
  interface EmailBranding {
252
252
  /** Full URL to the header logo. Default: `${appUrl}/email-header-image.png` */
253
253
  logoUrl?: string;
254
+ /**
255
+ * Logo width in CSS px. With `logoHeight`, the logo renders at that fixed size with `width`
256
+ * and `height` attributes, so clients reserve its space and Outlook sizes it right. Default:
257
+ * unset, and the logo fills half the email's width.
258
+ */
259
+ logoWidth?: number;
260
+ /** Logo height in CSS px; required with `logoWidth`. */
261
+ logoHeight?: number;
254
262
  /** CTA button background. Default: '#00fe9a' */
255
263
  buttonBgColor?: string;
256
264
  /** CTA button text color. Default: '#000004' */
@@ -2855,6 +2863,52 @@ declare function generate2faEnabledEmail(data: TwoFactorEnabledEmailData, appNam
2855
2863
  */
2856
2864
  declare function generate2faDisabledEmail(data: TwoFactorDisabledEmailData, appName?: string, appUrl?: string, branding?: EmailBranding): EmailTemplate;
2857
2865
 
2866
+ /**
2867
+ * The HTML email template: a white card on a light page, the logo, heading, body, an optional
2868
+ * button with its link to copy, an optional notice, a footer note and the footer band, coloured
2869
+ * from the branding options. Tables and inline styles throughout, and a VML button for Outlook.
2870
+ */
2871
+
2872
+ /** A consumer's own email, in plain text: {@link renderEmail} escapes every value. */
2873
+ interface EmailContent {
2874
+ /** The heading, also the document title. */
2875
+ heading: string;
2876
+ /** Body paragraphs; a newline inside one becomes a line break. */
2877
+ paragraphs: readonly string[];
2878
+ /** Lists after the paragraphs, such as a digest's records. */
2879
+ sections?: readonly EmailSection[];
2880
+ /** A button after the body, with its link to copy underneath. */
2881
+ button?: {
2882
+ label: string;
2883
+ url: string;
2884
+ };
2885
+ /** A neutral callout under the button, such as a link's lifetime. */
2886
+ notice?: string;
2887
+ /** Small print at the end of the card. */
2888
+ footerNote?: string;
2889
+ /** The app's base URL: the default logo's host, and the host every link must be on. */
2890
+ appUrl: string;
2891
+ /** Named in the logo's alt text and the footer (default: "App"). */
2892
+ appName?: string;
2893
+ branding?: EmailBranding;
2894
+ }
2895
+ /** A titled list in an {@link EmailContent}; each `url` must be on the app's host. */
2896
+ interface EmailSection {
2897
+ title: string;
2898
+ url?: string;
2899
+ rows: readonly {
2900
+ text: string;
2901
+ url?: string;
2902
+ }[];
2903
+ }
2904
+ /**
2905
+ * Render a consumer's own email in the template the auth emails use, so it matches them and
2906
+ * follows their branding. Every value is plain text and escaped here; every URL must be http(s)
2907
+ * on `appUrl`'s host or a subdomain.
2908
+ * @throws If a URL is not http(s) on `appUrl`'s host, or the logo size is invalid
2909
+ */
2910
+ declare function renderEmail(content: EmailContent): string;
2911
+
2858
2912
  type EmailEventsTable$1 = PgTableWithColumns<any>;
2859
2913
  type UsersTable = PgTableWithColumns<any>;
2860
2914
  /**
@@ -2890,4 +2944,4 @@ declare function calculateBounceRate(db: PostgresJsDatabase<Record<string, unkno
2890
2944
  */
2891
2945
  declare function calculateComplaintRate(db: PostgresJsDatabase<Record<string, unknown>>, emailEventsTable: EmailEventsTable, hoursAgo?: number): Promise<number>;
2892
2946
 
2893
- 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, type InvitationHookUser, type InvitationHooks, MAX_CHALLENGE_ATTEMPTS, PASSWORDLESS_MAX_ATTEMPTS, PASSWORDLESS_TTL_MS, type PasswordResetEmailData, type PasswordlessCodeResult, type PasswordlessLinkResult, type PasswordlessSuccess, type PasswordlessTables, type ProblemDetails, ProblemTypes, ResendAdapter, type ResendEventType, type ResendWebhookPayload, type SendEmailBinding, type SendEmailResult, type SessionData, type SessionTables, type SignupMode, type SvixHeaders, 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, cleanupExpiredPasswordlessChallenges, clearAccountLockout, clearChallengeCookie, clearSessionCookie, clearTrustedDeviceCookie, confirmEmailChange, createAuth, createAuthMiddleware, createChallengeToken, createDeviceToken, createEmailAdapter, createPasswordlessChallenge, createProblemDetails, createSession, csrf, decryptTotpSecret, deleteAllUserSessions, deleteChallengeToken, deleteSession, encryptTotpSecret, extractAppUrl, formatBackupCode, generate2faCodeEmail, generate2faDisabledEmail, generate2faEnabledEmail, generateApiKey, generateBackupCodes, generateCode, 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, passwordlessEmail, problemJson, problems, rateLimit, recentPasswordlessFailures, refreshSession, requestEmailChange, requireAuth, requireVerifiedEmail, retrieveChallengeToken, sessionRefreshDue, setChallengeCookie, setSessionCookie, setTrustedDeviceCookie, storeChallengeToken, updateChallengeAttempts, validateChallengePayload, validateOrigin, validatePassword, validatePasswordWithBreachCheck, validateSession, validateTrustedDevice, verifyBackupCode, verifyCodeChallenge, verifyPassword, verifyPasswordWithRotation, verifyPasswordlessCode, verifyPasswordlessLink, verifyTotpCode, verifyTurnstileToken, verifyWebhookSignature };
2947
+ 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 EmailContent, type EmailSection, type EmailSendOptions, type EmailSendResult, EmailService, type EmailTemplate, type EmailType, type Env, type InferNewSession, type InferNewUser, type InferSession, type InferUser, type InvitationHookUser, type InvitationHooks, MAX_CHALLENGE_ATTEMPTS, PASSWORDLESS_MAX_ATTEMPTS, PASSWORDLESS_TTL_MS, type PasswordResetEmailData, type PasswordlessCodeResult, type PasswordlessLinkResult, type PasswordlessSuccess, type PasswordlessTables, type ProblemDetails, ProblemTypes, ResendAdapter, type ResendEventType, type ResendWebhookPayload, type SendEmailBinding, type SendEmailResult, type SessionData, type SessionTables, type SignupMode, type SvixHeaders, 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, cleanupExpiredPasswordlessChallenges, clearAccountLockout, clearChallengeCookie, clearSessionCookie, clearTrustedDeviceCookie, confirmEmailChange, createAuth, createAuthMiddleware, createChallengeToken, createDeviceToken, createEmailAdapter, createPasswordlessChallenge, createProblemDetails, createSession, csrf, decryptTotpSecret, deleteAllUserSessions, deleteChallengeToken, deleteSession, encryptTotpSecret, extractAppUrl, formatBackupCode, generate2faCodeEmail, generate2faDisabledEmail, generate2faEnabledEmail, generateApiKey, generateBackupCodes, generateCode, 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, passwordlessEmail, problemJson, problems, rateLimit, recentPasswordlessFailures, refreshSession, renderEmail, requestEmailChange, requireAuth, requireVerifiedEmail, retrieveChallengeToken, sessionRefreshDue, setChallengeCookie, setSessionCookie, setTrustedDeviceCookie, storeChallengeToken, updateChallengeAttempts, validateChallengePayload, validateOrigin, validatePassword, validatePasswordWithBreachCheck, validateSession, validateTrustedDevice, verifyBackupCode, verifyCodeChallenge, verifyPassword, verifyPasswordWithRotation, verifyPasswordlessCode, verifyPasswordlessLink, verifyTotpCode, verifyTurnstileToken, verifyWebhookSignature };