@lunora/auth 1.0.0-alpha.210 → 1.0.0-alpha.211
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/email-guard.mjs +1 -1
- package/package.json +4 -4
package/dist/email-guard.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LunoraError as r}from"@lunora/errors";import{
|
|
1
|
+
import{LunoraError as r}from"@lunora/errors";import{assertListLoaded as c,isDisposableDomain as u,setDomains as w}from"@visulima/disposable-email-domains";import{extractDomain as h,assertListLoaded as f,isFreeDomain as D,setDomains as y}from"@visulima/free-email-domains";const n=a=>{const s=a.default??a;return Array.isArray(s)?s:[]};let i;const L=async()=>{if(i)return i;const a=(async()=>{const[s,e]=await Promise.all([import("@visulima/disposable-email-domains/domains"),import("@visulima/free-email-domains/domains")]);w(n(s)),y(n(e))})();return i=a,a.catch(()=>{i=void 0}),a},m=a=>{try{return new URL(`https://${a}`).hostname}catch{return a.toLowerCase()}},l=a=>a&&a.length>0?new Set(a.map(s=>m(s))):void 0,p=(a,s={})=>{const e=h(a);if(e===void 0)return{domain:void 0,emailClass:"business"};try{c(),f()}catch(d){throw new Error("@lunora/auth: the email domain lists are not loaded; `await loadEmailDomainLists()` before calling classifyEmail (assertEmailAllowed does this for you).",{cause:d})}const t=m(e),o=l(s.allowDomains);return u(t,{allowDomains:o,customDomains:l(s.denyDomains)})?{domain:t,emailClass:"disposable"}:D(t,{allowDomains:o})?{domain:t,emailClass:"free"}:{domain:t,emailClass:"business"}},E=async a=>{const{checkMxRecords:s}=await import("@visulima/email-verifier/checks/mx"),e=await s(a);return e.valid||e.deferred===!0},v=async(a,s={})=>{if(s.requireValidSyntax!==!1){const{validateSyntax:t}=await import("@visulima/email-verifier/checks/syntax");if(!t(a))throw new r("VALIDATION_ERROR",`@lunora/auth: "${a}" is not a valid email address.`)}await L();const e=p(a,s);if(e.emailClass==="disposable"&&s.blockDisposable!==!1)throw new r("EMAIL_DOMAIN_BLOCKED",`@lunora/auth: signups from the disposable/throwaway domain "${e.domain??a}" are not allowed.`);if(s.mx===!0&&e.domain!==void 0&&!await E(e.domain))throw new r("EMAIL_UNDELIVERABLE",`@lunora/auth: the domain "${e.domain}" publishes no MX records, so mail to it cannot be delivered.`);return e},R=a=>async({ctx:s,next:e})=>{const t=a.email(s);if(t===void 0||t==="")throw new r("VALIDATION_ERROR","@lunora/auth: emailGateMiddleware received no email to check.");const o=await v(t,a);return a.onClassify?.(o,s),e()};export{v as assertEmailAllowed,p as classifyEmail,R as emailGateMiddleware,L as loadEmailDomainLists};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/auth",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.211",
|
|
4
4
|
"description": "Auth for Lunora — a thin better-auth wrapper: email/password, OAuth, plugins, D1-backed",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"auth",
|
|
@@ -114,9 +114,9 @@
|
|
|
114
114
|
"@better-auth/scim": "1.7.7",
|
|
115
115
|
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
|
|
116
116
|
"@lunora/values": "1.0.0-alpha.64",
|
|
117
|
-
"@visulima/disposable-email-domains": "1.1.
|
|
118
|
-
"@visulima/email-verifier": "1.0.
|
|
119
|
-
"@visulima/free-email-domains": "1.0.
|
|
117
|
+
"@visulima/disposable-email-domains": "1.1.25",
|
|
118
|
+
"@visulima/email-verifier": "1.0.42",
|
|
119
|
+
"@visulima/free-email-domains": "1.0.2",
|
|
120
120
|
"@visulima/redact": "5.0.0"
|
|
121
121
|
},
|
|
122
122
|
"peerDependencies": {
|