@markwharton/pwa-core 3.4.1 → 3.4.2

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/server.d.ts CHANGED
@@ -481,14 +481,15 @@ export declare function initSessionAuth(config: SessionAuthConfig): void;
481
481
  * Initializes session auth from environment variables.
482
482
  * Reads: SESSION_COOKIE_NAME, APP_BASE_URL, ALLOWED_EMAILS, ALLOWED_DOMAIN, ADMIN_EMAILS.
483
483
  * @param sendEmail - Required callback to send magic link emails
484
+ * @param overrides - Optional config overrides (e.g., isEmailAllowed callback)
484
485
  * @throws Error if sendEmail is not provided
485
486
  * @example
486
487
  * initSessionAuthFromEnv(async (to, magicLink) => {
487
488
  * await resend.emails.send({ to, html: `<a href="${magicLink}">Sign In</a>` });
488
489
  * return true;
489
- * });
490
+ * }, { isEmailAllowed: async (email) => lookupInDatabase(email) });
490
491
  */
491
- export declare function initSessionAuthFromEnv(sendEmail: (to: string, magicLink: string) => Promise<boolean>): void;
492
+ export declare function initSessionAuthFromEnv(sendEmail: (to: string, magicLink: string) => Promise<boolean>, overrides?: Partial<Omit<SessionAuthConfig, 'sendEmail'>>): void;
492
493
  /**
493
494
  * Parses cookies from a request's Cookie header.
494
495
  * @param request - Request object with headers.get() method
package/dist/server.js CHANGED
@@ -754,14 +754,15 @@ function initSessionAuth(config) {
754
754
  * Initializes session auth from environment variables.
755
755
  * Reads: SESSION_COOKIE_NAME, APP_BASE_URL, ALLOWED_EMAILS, ALLOWED_DOMAIN, ADMIN_EMAILS.
756
756
  * @param sendEmail - Required callback to send magic link emails
757
+ * @param overrides - Optional config overrides (e.g., isEmailAllowed callback)
757
758
  * @throws Error if sendEmail is not provided
758
759
  * @example
759
760
  * initSessionAuthFromEnv(async (to, magicLink) => {
760
761
  * await resend.emails.send({ to, html: `<a href="${magicLink}">Sign In</a>` });
761
762
  * return true;
762
- * });
763
+ * }, { isEmailAllowed: async (email) => lookupInDatabase(email) });
763
764
  */
764
- function initSessionAuthFromEnv(sendEmail) {
765
+ function initSessionAuthFromEnv(sendEmail, overrides) {
765
766
  const allowedEmailsStr = process.env.ALLOWED_EMAILS;
766
767
  const adminEmailsStr = process.env.ADMIN_EMAILS;
767
768
  initSessionAuth({
@@ -774,6 +775,7 @@ function initSessionAuthFromEnv(sendEmail) {
774
775
  adminEmails: adminEmailsStr
775
776
  ? adminEmailsStr.split(',').map(e => e.trim().toLowerCase())
776
777
  : undefined,
778
+ ...overrides,
777
779
  sendEmail
778
780
  });
779
781
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markwharton/pwa-core",
3
- "version": "3.4.1",
3
+ "version": "3.4.2",
4
4
  "description": "Shared patterns for Azure PWA projects",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",