@lunora/auth 1.0.0-alpha.72 → 1.0.0-alpha.74

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.
@@ -91,6 +91,9 @@ declare const loadEmailDomainLists: () => Promise<void>;
91
91
  * The lookup relies on the built-in domain lists being loaded. On Node they
92
92
  * auto-load from disk; on workerd, `await loadEmailDomainLists()` first (or use
93
93
  * {@link assertEmailAllowed} / {@link emailGateMiddleware}, which await it).
94
+ *
95
+ * The returned/compared domain is IDNA-normalized (see {@link toAsciiDomain}) so
96
+ * a Unicode-form internationalized domain matches its `xn--` blocklist entry.
94
97
  */
95
98
  declare const classifyEmail: (email: string, config?: EmailGateConfig) => EmailClassification;
96
99
  /**
@@ -91,6 +91,9 @@ declare const loadEmailDomainLists: () => Promise<void>;
91
91
  * The lookup relies on the built-in domain lists being loaded. On Node they
92
92
  * auto-load from disk; on workerd, `await loadEmailDomainLists()` first (or use
93
93
  * {@link assertEmailAllowed} / {@link emailGateMiddleware}, which await it).
94
+ *
95
+ * The returned/compared domain is IDNA-normalized (see {@link toAsciiDomain}) so
96
+ * a Unicode-form internationalized domain matches its `xn--` blocklist entry.
94
97
  */
95
98
  declare const classifyEmail: (email: string, config?: EmailGateConfig) => EmailClassification;
96
99
  /**
@@ -1 +1 @@
1
- import{LunoraError as e}from"@lunora/errors";import{isDisposableDomain as m,setDomains as d}from"@visulima/disposable-email-domains";import{extractDomain as c,isFreeDomain as w,setDomains as u}from"@visulima/free-email-domains";const t=a=>{const i=a.default??a;return Array.isArray(i)?i:[]};let n;const D=async()=>(n??=(async()=>{const[a,i]=await Promise.all([import("@visulima/disposable-email-domains/domains"),import("@visulima/free-email-domains/domains")]);d(t(a)),u(t(i))})(),n),r=a=>a&&a.length>0?new Set(a.map(i=>i.toLowerCase())):void 0,f=(a,i={})=>{const o=c(a);if(o===void 0)return{domain:void 0,emailClass:"business"};const s=r(i.allowDomains);return m(o,{allowDomains:s,customDomains:r(i.denyDomains)})?{domain:o,emailClass:"disposable"}:w(o,{allowDomains:s})?{domain:o,emailClass:"free"}:{domain:o,emailClass:"business"}},p=async a=>{const{checkMxRecords:i}=await import("@visulima/email-verifier/checks/mx");return(await i(a)).valid},h=async(a,i={})=>{if(i.requireValidSyntax!==!1){const{validateSyntax:s}=await import("@visulima/email-verifier/checks/syntax");if(!s(a))throw new e("VALIDATION_ERROR",`@lunora/auth: "${a}" is not a valid email address.`)}await D();const o=f(a,i);if(o.emailClass==="disposable"&&i.blockDisposable!==!1)throw new e("EMAIL_DOMAIN_BLOCKED",`@lunora/auth: signups from the disposable/throwaway domain "${o.domain??a}" are not allowed.`);if(i.mx===!0&&o.domain!==void 0&&!await p(o.domain))throw new e("EMAIL_UNDELIVERABLE",`@lunora/auth: the domain "${o.domain}" publishes no MX records, so mail to it cannot be delivered.`);return o},b=a=>async({ctx:i,next:o})=>{const s=a.email(i);if(s===void 0||s==="")throw new e("VALIDATION_ERROR","@lunora/auth: emailGateMiddleware received no email to check.");const l=await h(s,a);return a.onClassify?.(l,i),o()};export{h as assertEmailAllowed,f as classifyEmail,b as emailGateMiddleware,D as loadEmailDomainLists};
1
+ import{LunoraError as t}from"@lunora/errors";import{isDisposableDomain as d,setDomains as c}from"@visulima/disposable-email-domains";import{extractDomain as w,isFreeDomain as u,setDomains as D}from"@visulima/free-email-domains";const n=a=>{const i=a.default??a;return Array.isArray(i)?i:[]};let r;const h=async()=>(r??=(async()=>{const[a,i]=await Promise.all([import("@visulima/disposable-email-domains/domains"),import("@visulima/free-email-domains/domains")]);c(n(a)),D(n(i))})(),r),m=a=>{try{return new URL(`https://${a}`).hostname}catch{return a.toLowerCase()}},l=a=>a&&a.length>0?new Set(a.map(i=>m(i))):void 0,p=(a,i={})=>{const o=w(a);if(o===void 0)return{domain:void 0,emailClass:"business"};const s=m(o),e=l(i.allowDomains);return d(s,{allowDomains:e,customDomains:l(i.denyDomains)})?{domain:s,emailClass:"disposable"}:u(s,{allowDomains:e})?{domain:s,emailClass:"free"}:{domain:s,emailClass:"business"}},f=async a=>{const{checkMxRecords:i}=await import("@visulima/email-verifier/checks/mx");return(await i(a)).valid},y=async(a,i={})=>{if(i.requireValidSyntax!==!1){const{validateSyntax:s}=await import("@visulima/email-verifier/checks/syntax");if(!s(a))throw new t("VALIDATION_ERROR",`@lunora/auth: "${a}" is not a valid email address.`)}await h();const o=p(a,i);if(o.emailClass==="disposable"&&i.blockDisposable!==!1)throw new t("EMAIL_DOMAIN_BLOCKED",`@lunora/auth: signups from the disposable/throwaway domain "${o.domain??a}" are not allowed.`);if(i.mx===!0&&o.domain!==void 0&&!await f(o.domain))throw new t("EMAIL_UNDELIVERABLE",`@lunora/auth: the domain "${o.domain}" publishes no MX records, so mail to it cannot be delivered.`);return o},b=a=>async({ctx:i,next:o})=>{const s=a.email(i);if(s===void 0||s==="")throw new t("VALIDATION_ERROR","@lunora/auth: emailGateMiddleware received no email to check.");const e=await y(s,a);return a.onClassify?.(e,i),o()};export{y as assertEmailAllowed,p as classifyEmail,b as emailGateMiddleware,h as loadEmailDomainLists};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/auth",
3
- "version": "1.0.0-alpha.72",
3
+ "version": "1.0.0-alpha.74",
4
4
  "description": "Auth for Lunora — a thin better-auth wrapper: email/password, OAuth, plugins, D1-backed",
5
5
  "keywords": [
6
6
  "auth",
@@ -102,9 +102,9 @@
102
102
  "@better-auth/oauth-provider": "1.7.0-rc.2",
103
103
  "@better-auth/passkey": "1.7.0-rc.2",
104
104
  "@better-auth/scim": "1.7.0-rc.2",
105
- "@lunora/errors": "1.0.0-alpha.15",
106
- "@lunora/server": "1.0.0-alpha.63",
107
- "@lunora/values": "1.0.0-alpha.20",
105
+ "@lunora/errors": "1.0.0-alpha.16",
106
+ "@lunora/server": "1.0.0-alpha.65",
107
+ "@lunora/values": "1.0.0-alpha.21",
108
108
  "@visulima/disposable-email-domains": "1.0.1",
109
109
  "@visulima/email-verifier": "1.0.1",
110
110
  "@visulima/free-email-domains": "1.0.0",