Comparing version 1.0.0-alpha.18 to 1.0.0-alpha.19
16
index.js
@@ -73,2 +73,9 @@ import { ArcjetRuleResult, ArcjetEmailReason, ArcjetBotType, ArcjetErrorReason, ArcjetBotReason, ArcjetErrorDecision, ArcjetReason, ArcjetDenyDecision } from '@arcjet/protocol'; | ||
} | ||
function isEmailType(type) { | ||
return (type === "FREE" || | ||
type === "DISPOSABLE" || | ||
type === "NO_MX_RECORDS" || | ||
type === "NO_GRAVATAR" || | ||
type === "INVALID"); | ||
} | ||
function toString(value) { | ||
@@ -196,5 +203,6 @@ if (typeof value === "string") { | ||
const allowDomainLiteral = opt.allowDomainLiteral ?? false; | ||
const analyzeOpts = { | ||
const emailOpts = { | ||
requireTopLevelDomain, | ||
allowDomainLiteral, | ||
blockedEmails: block, | ||
}; | ||
@@ -212,3 +220,4 @@ rules.push({ | ||
async protect(context, { email }) { | ||
if (await analyze.isValidEmail(context, email, analyzeOpts)) { | ||
const result = await analyze.isValidEmail(context, email, emailOpts); | ||
if (result.validity === "valid") { | ||
return new ArcjetRuleResult({ | ||
@@ -222,2 +231,3 @@ ttl: 0, | ||
else { | ||
const typedEmailTypes = result.blocked.filter(isEmailType); | ||
return new ArcjetRuleResult({ | ||
@@ -228,3 +238,3 @@ ttl: 0, | ||
reason: new ArcjetEmailReason({ | ||
emailTypes: ["INVALID"], | ||
emailTypes: typedEmailTypes, | ||
}), | ||
@@ -231,0 +241,0 @@ }); |
20
index.ts
@@ -185,2 +185,12 @@ import { | ||
function isEmailType(type: string): type is ArcjetEmailType { | ||
return ( | ||
type === "FREE" || | ||
type === "DISPOSABLE" || | ||
type === "NO_MX_RECORDS" || | ||
type === "NO_GRAVATAR" || | ||
type === "INVALID" | ||
); | ||
} | ||
function toString(value: unknown) { | ||
@@ -531,5 +541,6 @@ if (typeof value === "string") { | ||
const analyzeOpts = { | ||
const emailOpts = { | ||
requireTopLevelDomain, | ||
allowDomainLiteral, | ||
blockedEmails: block, | ||
}; | ||
@@ -559,3 +570,4 @@ | ||
): Promise<ArcjetRuleResult> { | ||
if (await analyze.isValidEmail(context, email, analyzeOpts)) { | ||
const result = await analyze.isValidEmail(context, email, emailOpts); | ||
if (result.validity === "valid") { | ||
return new ArcjetRuleResult({ | ||
@@ -568,2 +580,4 @@ ttl: 0, | ||
} else { | ||
const typedEmailTypes = result.blocked.filter(isEmailType); | ||
return new ArcjetRuleResult({ | ||
@@ -574,3 +588,3 @@ ttl: 0, | ||
reason: new ArcjetEmailReason({ | ||
emailTypes: ["INVALID"], | ||
emailTypes: typedEmailTypes, | ||
}), | ||
@@ -577,0 +591,0 @@ }); |
{ | ||
"name": "arcjet", | ||
"version": "1.0.0-alpha.18", | ||
"version": "1.0.0-alpha.19", | ||
"description": "Arcjet TypeScript and JavaScript SDK core", | ||
@@ -43,18 +43,18 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@arcjet/analyze": "1.0.0-alpha.18", | ||
"@arcjet/duration": "1.0.0-alpha.18", | ||
"@arcjet/headers": "1.0.0-alpha.18", | ||
"@arcjet/protocol": "1.0.0-alpha.18", | ||
"@arcjet/runtime": "1.0.0-alpha.18" | ||
"@arcjet/analyze": "1.0.0-alpha.19", | ||
"@arcjet/duration": "1.0.0-alpha.19", | ||
"@arcjet/headers": "1.0.0-alpha.19", | ||
"@arcjet/protocol": "1.0.0-alpha.19", | ||
"@arcjet/runtime": "1.0.0-alpha.19" | ||
}, | ||
"devDependencies": { | ||
"@arcjet/eslint-config": "1.0.0-alpha.18", | ||
"@arcjet/rollup-config": "1.0.0-alpha.18", | ||
"@arcjet/tsconfig": "1.0.0-alpha.18", | ||
"@edge-runtime/jest-environment": "2.3.10", | ||
"@arcjet/eslint-config": "1.0.0-alpha.19", | ||
"@arcjet/rollup-config": "1.0.0-alpha.19", | ||
"@arcjet/tsconfig": "1.0.0-alpha.19", | ||
"@edge-runtime/jest-environment": "3.0.1", | ||
"@jest/globals": "29.7.0", | ||
"@rollup/wasm-node": "4.18.0", | ||
"@rollup/wasm-node": "4.18.1", | ||
"@types/node": "18.18.0", | ||
"jest": "29.7.0", | ||
"typescript": "5.5.2" | ||
"typescript": "5.5.3" | ||
}, | ||
@@ -61,0 +61,0 @@ "publishConfig": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
83951
1914
+ Added@arcjet/analyze@1.0.0-alpha.19(transitive)
+ Added@arcjet/duration@1.0.0-alpha.19(transitive)
+ Added@arcjet/headers@1.0.0-alpha.19(transitive)
+ Added@arcjet/protocol@1.0.0-alpha.19(transitive)
+ Added@arcjet/runtime@1.0.0-alpha.19(transitive)
+ Addedtypeid-js@1.0.0(transitive)
- Removed@arcjet/analyze@1.0.0-alpha.18(transitive)
- Removed@arcjet/duration@1.0.0-alpha.18(transitive)
- Removed@arcjet/headers@1.0.0-alpha.18(transitive)
- Removed@arcjet/protocol@1.0.0-alpha.18(transitive)
- Removed@arcjet/runtime@1.0.0-alpha.18(transitive)
- Removedtypeid-js@0.7.0(transitive)