@fonderie/auth 5.0.4 → 5.1.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
@@ -19,6 +19,52 @@ declare class AuthModule implements IFonderieModule {
19
19
  install(app: IFonderieApp): void;
20
20
  }
21
21
 
22
+ declare const DEFAULT_TEMPLATES: {
23
+ "email-registration": {
24
+ subject: string;
25
+ html: string;
26
+ text: string;
27
+ };
28
+ "email-verification": {
29
+ subject: string;
30
+ html: string;
31
+ text: string;
32
+ };
33
+ "password-reset": {
34
+ subject: string;
35
+ html: string;
36
+ text: string;
37
+ };
38
+ "phone-otp": {
39
+ text: string;
40
+ };
41
+ "mfa-enabled": {
42
+ subject: string;
43
+ html: string;
44
+ text: string;
45
+ };
46
+ "mfa-disabled": {
47
+ subject: string;
48
+ html: string;
49
+ text: string;
50
+ };
51
+ "mfa-backup-codes-regenerated": {
52
+ subject: string;
53
+ html: string;
54
+ text: string;
55
+ };
56
+ "email-changed": {
57
+ subject: string;
58
+ html: string;
59
+ text: string;
60
+ };
61
+ "phone-changed": {
62
+ subject: string;
63
+ html: string;
64
+ text: string;
65
+ };
66
+ };
67
+
22
68
  declare const registerSchema: z.ZodUnion<readonly [z.ZodObject<{
23
69
  email: z.ZodPipe<z.ZodString, z.ZodEmail>;
24
70
  password: z.ZodString;
@@ -137,4 +183,4 @@ declare function startUserRetention(store: IStoreAdapter, options: IUserRetentio
137
183
 
138
184
  declare function validateAuthConfig(config: IAuthConfig): void;
139
185
 
140
- export { AuthModule, type ChangePasswordInput, IAuthConfig, type IImportUser, type IPurgeOptions, type IUserRetentionScheduleOptions, type LoginInput, type RegisterInput, type ResetPasswordInput, importUser, normalizeEmail, normalizeEmailSafe, purgeSoftDeletedUsers, schemas, startUserRetention, validateAuthConfig };
186
+ export { AuthModule, type ChangePasswordInput, DEFAULT_TEMPLATES, IAuthConfig, type IImportUser, type IPurgeOptions, type IUserRetentionScheduleOptions, type LoginInput, type RegisterInput, type ResetPasswordInput, importUser, normalizeEmail, normalizeEmailSafe, purgeSoftDeletedUsers, schemas, startUserRetention, validateAuthConfig };
package/dist/index.d.ts CHANGED
@@ -19,6 +19,52 @@ declare class AuthModule implements IFonderieModule {
19
19
  install(app: IFonderieApp): void;
20
20
  }
21
21
 
22
+ declare const DEFAULT_TEMPLATES: {
23
+ "email-registration": {
24
+ subject: string;
25
+ html: string;
26
+ text: string;
27
+ };
28
+ "email-verification": {
29
+ subject: string;
30
+ html: string;
31
+ text: string;
32
+ };
33
+ "password-reset": {
34
+ subject: string;
35
+ html: string;
36
+ text: string;
37
+ };
38
+ "phone-otp": {
39
+ text: string;
40
+ };
41
+ "mfa-enabled": {
42
+ subject: string;
43
+ html: string;
44
+ text: string;
45
+ };
46
+ "mfa-disabled": {
47
+ subject: string;
48
+ html: string;
49
+ text: string;
50
+ };
51
+ "mfa-backup-codes-regenerated": {
52
+ subject: string;
53
+ html: string;
54
+ text: string;
55
+ };
56
+ "email-changed": {
57
+ subject: string;
58
+ html: string;
59
+ text: string;
60
+ };
61
+ "phone-changed": {
62
+ subject: string;
63
+ html: string;
64
+ text: string;
65
+ };
66
+ };
67
+
22
68
  declare const registerSchema: z.ZodUnion<readonly [z.ZodObject<{
23
69
  email: z.ZodPipe<z.ZodString, z.ZodEmail>;
24
70
  password: z.ZodString;
@@ -137,4 +183,4 @@ declare function startUserRetention(store: IStoreAdapter, options: IUserRetentio
137
183
 
138
184
  declare function validateAuthConfig(config: IAuthConfig): void;
139
185
 
140
- export { AuthModule, type ChangePasswordInput, IAuthConfig, type IImportUser, type IPurgeOptions, type IUserRetentionScheduleOptions, type LoginInput, type RegisterInput, type ResetPasswordInput, importUser, normalizeEmail, normalizeEmailSafe, purgeSoftDeletedUsers, schemas, startUserRetention, validateAuthConfig };
186
+ export { AuthModule, type ChangePasswordInput, DEFAULT_TEMPLATES, IAuthConfig, type IImportUser, type IPurgeOptions, type IUserRetentionScheduleOptions, type LoginInput, type RegisterInput, type ResetPasswordInput, importUser, normalizeEmail, normalizeEmailSafe, purgeSoftDeletedUsers, schemas, startUserRetention, validateAuthConfig };
package/dist/index.js CHANGED
@@ -2257,6 +2257,122 @@ var AuthModule = class {
2257
2257
  }
2258
2258
  };
2259
2259
 
2260
+ // src/templates.ts
2261
+ var DEFAULT_TEMPLATES = {
2262
+ [MESSAGE_KEYS.emailRegistration]: {
2263
+ subject: "Confirm your account",
2264
+ html: `<h1>Welcome aboard</h1>
2265
+ <p>Hi {{firstName}},</p>
2266
+ <p>Thanks for signing up. Confirm your account with this code:</p>
2267
+ <p><span class="pin-code">{{pin}}</span></p>
2268
+ <p class="muted">This code expires in 24 hours. If you didn&rsquo;t create an account, you can safely ignore this email.</p>`,
2269
+ text: `Welcome aboard
2270
+
2271
+ Hi {{firstName}},
2272
+
2273
+ Thanks for signing up. Confirm your account with this code: {{pin}}
2274
+
2275
+ This code expires in 24 hours. If you didn't create an account, you can safely ignore this email.`
2276
+ },
2277
+ [MESSAGE_KEYS.emailVerification]: {
2278
+ subject: "Your verification code",
2279
+ html: `<h1>Verify your email</h1>
2280
+ <p>Hi {{firstName}},</p>
2281
+ <p>Use this code to finish setting up your account:</p>
2282
+ <p><span class="pin-code">{{pin}}</span></p>
2283
+ <p class="muted">This code expires in 24 hours. If you didn&rsquo;t create an account, you can safely ignore this email.</p>`,
2284
+ text: `Verify your email
2285
+
2286
+ Hi {{firstName}},
2287
+
2288
+ Use this code to finish setting up your account: {{pin}}
2289
+
2290
+ This code expires in 24 hours. If you didn't create an account, you can safely ignore this email.`
2291
+ },
2292
+ [MESSAGE_KEYS.passwordReset]: {
2293
+ subject: "Reset your password",
2294
+ html: `<h1>Reset your password</h1>
2295
+ <p>We received a request to reset your password. Use this code to continue:</p>
2296
+ <p><span class="pin-code">{{pin}}</span></p>
2297
+ <p class="muted">This code expires soon. If you didn&rsquo;t request a reset, no action is needed &mdash; your password stays the same.</p>`,
2298
+ text: `Reset your password
2299
+
2300
+ We received a request to reset your password. Use this code to continue: {{pin}}
2301
+
2302
+ This code expires soon. If you didn't request a reset, no action is needed \u2014 your password stays the same.`
2303
+ },
2304
+ // SMS — text only, no subject/html.
2305
+ [MESSAGE_KEYS.phoneOtp]: {
2306
+ text: "{{otp}} is your verification code. It expires in 10 minutes."
2307
+ },
2308
+ [MESSAGE_KEYS.mfaEnabled]: {
2309
+ subject: "Two-factor authentication is on",
2310
+ html: `<h1>Two-factor authentication enabled</h1>
2311
+ <p>Two-factor authentication was just turned on for your account. From now on you&rsquo;ll enter a code from your authenticator app when you sign in.</p>
2312
+ <p class="muted">If you didn&rsquo;t do this, contact support right away &mdash; someone may have access to your account.</p>`,
2313
+ text: `Two-factor authentication enabled
2314
+
2315
+ Two-factor authentication was just turned on for your account. From now on you'll enter a code from your authenticator app when you sign in.
2316
+
2317
+ If you didn't do this, contact support right away \u2014 someone may have access to your account.`
2318
+ },
2319
+ [MESSAGE_KEYS.mfaDisabled]: {
2320
+ subject: "Two-factor authentication is off",
2321
+ html: `<h1>Two-factor authentication disabled</h1>
2322
+ <p>Two-factor authentication was just turned off for your account. Your account is now protected by your password alone.</p>
2323
+ <p class="muted">If you didn&rsquo;t do this, contact support right away and re-enable two-factor authentication &mdash; someone may have access to your account.</p>`,
2324
+ text: `Two-factor authentication disabled
2325
+
2326
+ Two-factor authentication was just turned off for your account. Your account is now protected by your password alone.
2327
+
2328
+ If you didn't do this, contact support right away and re-enable two-factor authentication \u2014 someone may have access to your account.`
2329
+ },
2330
+ [MESSAGE_KEYS.mfaBackupCodesRegenerated]: {
2331
+ subject: "Your backup codes were regenerated",
2332
+ html: `<h1>New backup codes generated</h1>
2333
+ <p>A new set of two-factor backup codes was just generated for your account. Your previous backup codes no longer work.</p>
2334
+ <p class="muted">If you didn&rsquo;t do this, contact support right away &mdash; someone may have access to your account.</p>`,
2335
+ text: `New backup codes generated
2336
+
2337
+ A new set of two-factor backup codes was just generated for your account. Your previous backup codes no longer work.
2338
+
2339
+ If you didn't do this, contact support right away \u2014 someone may have access to your account.`
2340
+ },
2341
+ [MESSAGE_KEYS.emailChanged]: {
2342
+ subject: "Your email address was changed",
2343
+ html: `<h1>Your email was changed</h1>
2344
+ <p>The email address on your account was just changed to <strong>{{newEmail}}</strong>.</p>
2345
+ <p class="muted">If you made this change, you&rsquo;re all set. If not, contact support right away &mdash; someone may have access to your account.</p>`,
2346
+ text: `Your email was changed
2347
+
2348
+ The email address on your account was just changed to {{newEmail}}.
2349
+
2350
+ If you made this change, you're all set. If not, contact support right away \u2014 someone may have access to your account.`
2351
+ },
2352
+ [MESSAGE_KEYS.phoneChanged]: {
2353
+ subject: "Your phone number was changed",
2354
+ html: `<h1>Your phone number was changed</h1>
2355
+ <p>The phone number on your account was just updated.</p>
2356
+ <p class="muted">If you made this change, you&rsquo;re all set. If not, contact support right away &mdash; someone may have access to your account.</p>`,
2357
+ text: `Your phone number was changed
2358
+
2359
+ The phone number on your account was just updated.
2360
+
2361
+ If you made this change, you're all set. If not, contact support right away \u2014 someone may have access to your account.`
2362
+ }
2363
+ };
2364
+ var SAMPLE_PAYLOADS = {
2365
+ [MESSAGE_KEYS.emailRegistration]: { firstName: "", pin: "123456" },
2366
+ [MESSAGE_KEYS.emailVerification]: { firstName: "Ada", pin: "123456" },
2367
+ [MESSAGE_KEYS.passwordReset]: { pin: "123456" },
2368
+ [MESSAGE_KEYS.phoneOtp]: { otp: "123456" },
2369
+ [MESSAGE_KEYS.mfaEnabled]: {},
2370
+ [MESSAGE_KEYS.mfaDisabled]: {},
2371
+ [MESSAGE_KEYS.mfaBackupCodesRegenerated]: {},
2372
+ [MESSAGE_KEYS.emailChanged]: { newEmail: "new@example.com" },
2373
+ [MESSAGE_KEYS.phoneChanged]: {}
2374
+ };
2375
+
2260
2376
  // src/middlewares/require-auth.ts
2261
2377
  import { requireAuth as requireAuth2, requireAnyAuth as requireAnyAuth2 } from "@fonderie/core/middlewares";
2262
2378
 
@@ -2329,6 +2445,7 @@ function startUserRetention(store, options) {
2329
2445
  export {
2330
2446
  AUTH_CONFIG_KEYS,
2331
2447
  AuthModule,
2448
+ DEFAULT_TEMPLATES,
2332
2449
  MESSAGE_KEYS,
2333
2450
  buildAuthAccountLimiter,
2334
2451
  buildAuthIpLimiter,