@fonderie/auth 5.0.3 → 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.
@@ -94,6 +94,8 @@ const MESSAGE_KEYS: { readonly emailRegistration: "email-registration"; readonly
94
94
 
95
95
  type AuthMessageKey = (typeof MESSAGE_KEYS)[keyof typeof MESSAGE_KEYS];
96
96
 
97
+ const DEFAULT_TEMPLATES: { "email-registration": { subject: string; html: string; text: string; }; "email-verification": { subject: string; html: string; text: string; }; "password-reset": { subject: string; html: string; text: string; }; "phone-otp": { text: string; }; "mfa-enabled": { subject: string; html: string; text: string; }; "mfa-disabled": { subject: string; html: string; text: string; }; "mfa-backup-codes-regenerated": { subject: string; html: string; text: string; }; "email-changed": { subject: string; html: string; text: string; }; "phone-changed": { subject: string; html: string; text: string; }; }
98
+
97
99
  interface IUserDTO {
98
100
  id: string;
99
101
  email: string;
package/dist/index.cjs CHANGED
@@ -70,6 +70,7 @@ var index_exports = {};
70
70
  __export(index_exports, {
71
71
  AUTH_CONFIG_KEYS: () => AUTH_CONFIG_KEYS,
72
72
  AuthModule: () => AuthModule,
73
+ DEFAULT_TEMPLATES: () => DEFAULT_TEMPLATES,
73
74
  MESSAGE_KEYS: () => MESSAGE_KEYS,
74
75
  buildAuthAccountLimiter: () => buildAuthAccountLimiter,
75
76
  buildAuthIpLimiter: () => buildAuthIpLimiter,
@@ -2296,6 +2297,122 @@ var AuthModule = class {
2296
2297
  }
2297
2298
  };
2298
2299
 
2300
+ // src/templates.ts
2301
+ var DEFAULT_TEMPLATES = {
2302
+ [MESSAGE_KEYS.emailRegistration]: {
2303
+ subject: "Confirm your account",
2304
+ html: `<h1>Welcome aboard</h1>
2305
+ <p>Hi {{firstName}},</p>
2306
+ <p>Thanks for signing up. Confirm your account with this code:</p>
2307
+ <p><span class="pin-code">{{pin}}</span></p>
2308
+ <p class="muted">This code expires in 24 hours. If you didn&rsquo;t create an account, you can safely ignore this email.</p>`,
2309
+ text: `Welcome aboard
2310
+
2311
+ Hi {{firstName}},
2312
+
2313
+ Thanks for signing up. Confirm your account with this code: {{pin}}
2314
+
2315
+ This code expires in 24 hours. If you didn't create an account, you can safely ignore this email.`
2316
+ },
2317
+ [MESSAGE_KEYS.emailVerification]: {
2318
+ subject: "Your verification code",
2319
+ html: `<h1>Verify your email</h1>
2320
+ <p>Hi {{firstName}},</p>
2321
+ <p>Use this code to finish setting up your account:</p>
2322
+ <p><span class="pin-code">{{pin}}</span></p>
2323
+ <p class="muted">This code expires in 24 hours. If you didn&rsquo;t create an account, you can safely ignore this email.</p>`,
2324
+ text: `Verify your email
2325
+
2326
+ Hi {{firstName}},
2327
+
2328
+ Use this code to finish setting up your account: {{pin}}
2329
+
2330
+ This code expires in 24 hours. If you didn't create an account, you can safely ignore this email.`
2331
+ },
2332
+ [MESSAGE_KEYS.passwordReset]: {
2333
+ subject: "Reset your password",
2334
+ html: `<h1>Reset your password</h1>
2335
+ <p>We received a request to reset your password. Use this code to continue:</p>
2336
+ <p><span class="pin-code">{{pin}}</span></p>
2337
+ <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>`,
2338
+ text: `Reset your password
2339
+
2340
+ We received a request to reset your password. Use this code to continue: {{pin}}
2341
+
2342
+ This code expires soon. If you didn't request a reset, no action is needed \u2014 your password stays the same.`
2343
+ },
2344
+ // SMS — text only, no subject/html.
2345
+ [MESSAGE_KEYS.phoneOtp]: {
2346
+ text: "{{otp}} is your verification code. It expires in 10 minutes."
2347
+ },
2348
+ [MESSAGE_KEYS.mfaEnabled]: {
2349
+ subject: "Two-factor authentication is on",
2350
+ html: `<h1>Two-factor authentication enabled</h1>
2351
+ <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>
2352
+ <p class="muted">If you didn&rsquo;t do this, contact support right away &mdash; someone may have access to your account.</p>`,
2353
+ text: `Two-factor authentication enabled
2354
+
2355
+ 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.
2356
+
2357
+ If you didn't do this, contact support right away \u2014 someone may have access to your account.`
2358
+ },
2359
+ [MESSAGE_KEYS.mfaDisabled]: {
2360
+ subject: "Two-factor authentication is off",
2361
+ html: `<h1>Two-factor authentication disabled</h1>
2362
+ <p>Two-factor authentication was just turned off for your account. Your account is now protected by your password alone.</p>
2363
+ <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>`,
2364
+ text: `Two-factor authentication disabled
2365
+
2366
+ Two-factor authentication was just turned off for your account. Your account is now protected by your password alone.
2367
+
2368
+ If you didn't do this, contact support right away and re-enable two-factor authentication \u2014 someone may have access to your account.`
2369
+ },
2370
+ [MESSAGE_KEYS.mfaBackupCodesRegenerated]: {
2371
+ subject: "Your backup codes were regenerated",
2372
+ html: `<h1>New backup codes generated</h1>
2373
+ <p>A new set of two-factor backup codes was just generated for your account. Your previous backup codes no longer work.</p>
2374
+ <p class="muted">If you didn&rsquo;t do this, contact support right away &mdash; someone may have access to your account.</p>`,
2375
+ text: `New backup codes generated
2376
+
2377
+ A new set of two-factor backup codes was just generated for your account. Your previous backup codes no longer work.
2378
+
2379
+ If you didn't do this, contact support right away \u2014 someone may have access to your account.`
2380
+ },
2381
+ [MESSAGE_KEYS.emailChanged]: {
2382
+ subject: "Your email address was changed",
2383
+ html: `<h1>Your email was changed</h1>
2384
+ <p>The email address on your account was just changed to <strong>{{newEmail}}</strong>.</p>
2385
+ <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>`,
2386
+ text: `Your email was changed
2387
+
2388
+ The email address on your account was just changed to {{newEmail}}.
2389
+
2390
+ If you made this change, you're all set. If not, contact support right away \u2014 someone may have access to your account.`
2391
+ },
2392
+ [MESSAGE_KEYS.phoneChanged]: {
2393
+ subject: "Your phone number was changed",
2394
+ html: `<h1>Your phone number was changed</h1>
2395
+ <p>The phone number on your account was just updated.</p>
2396
+ <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>`,
2397
+ text: `Your phone number was changed
2398
+
2399
+ The phone number on your account was just updated.
2400
+
2401
+ If you made this change, you're all set. If not, contact support right away \u2014 someone may have access to your account.`
2402
+ }
2403
+ };
2404
+ var SAMPLE_PAYLOADS = {
2405
+ [MESSAGE_KEYS.emailRegistration]: { firstName: "", pin: "123456" },
2406
+ [MESSAGE_KEYS.emailVerification]: { firstName: "Ada", pin: "123456" },
2407
+ [MESSAGE_KEYS.passwordReset]: { pin: "123456" },
2408
+ [MESSAGE_KEYS.phoneOtp]: { otp: "123456" },
2409
+ [MESSAGE_KEYS.mfaEnabled]: {},
2410
+ [MESSAGE_KEYS.mfaDisabled]: {},
2411
+ [MESSAGE_KEYS.mfaBackupCodesRegenerated]: {},
2412
+ [MESSAGE_KEYS.emailChanged]: { newEmail: "new@example.com" },
2413
+ [MESSAGE_KEYS.phoneChanged]: {}
2414
+ };
2415
+
2299
2416
  // src/middlewares/require-auth.ts
2300
2417
  var import_middlewares3 = require("@fonderie/core/middlewares");
2301
2418
 
@@ -2369,6 +2486,7 @@ function startUserRetention(store, options) {
2369
2486
  0 && (module.exports = {
2370
2487
  AUTH_CONFIG_KEYS,
2371
2488
  AuthModule,
2489
+ DEFAULT_TEMPLATES,
2372
2490
  MESSAGE_KEYS,
2373
2491
  buildAuthAccountLimiter,
2374
2492
  buildAuthIpLimiter,