File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -106,4 +106,8 @@ ANTHROPIC_API_KEY=
106106NEXT_PUBLIC_IS_DUB =
107107
108108# For cron jobs
109- CRON_SECRET =
109+ CRON_SECRET =
110+
111+ # Pangea - Retrieve reputation for a domain.
112+ # Get your Pange API Key here: https://pangea.cloud/docs/admin-guide/tokens/
113+ PANGEA_API_KEY =
Original file line number Diff line number Diff line change @@ -26,6 +26,11 @@ export async function POST(req: NextRequest) {
2626 const { workspaceId } = searchParams ;
2727 const workspace = await getWorkspaceViaEdge ( workspaceId ) ;
2828
29+ if ( ! anthropic ) {
30+ console . error ( "Anthropic is not configured. Skipping the request." ) ;
31+ return new Response ( null , { status : 200 } ) ;
32+ }
33+
2934 if ( ! workspace ) {
3035 return new Response ( "Workspace not found" , { status : 404 } ) ;
3136 }
Original file line number Diff line number Diff line change @@ -8,6 +8,11 @@ import { NextRequest } from "next/server";
88export const runtime = "edge" ;
99
1010export async function POST ( req : NextRequest ) {
11+ if ( ! anthropic ) {
12+ console . error ( "Anthropic is not configured. Skipping the request." ) ;
13+ return new Response ( null , { status : 200 } ) ;
14+ }
15+
1116 try {
1217 const session = await getToken ( {
1318 req,
Original file line number Diff line number Diff line change 11import Anthropic from "@anthropic-ai/sdk" ;
22
3- export const anthropic = new Anthropic ( {
4- apiKey : process . env . ANTHROPIC_API_KEY || "" ,
5- } ) ;
3+ const apiKey = process . env . ANTHROPIC_API_KEY ;
4+
5+ export const anthropic = apiKey ? new Anthropic ( { apiKey } ) : null ;
Original file line number Diff line number Diff line change @@ -323,35 +323,38 @@ async function maliciousLinkCheck(url: string) {
323323 return false ;
324324 }
325325
326- try {
327- const response = await getPangeaDomainIntel ( domain ) ;
326+ // Check with Pangea for domain reputation
327+ if ( process . env . PANGEA_API_KEY ) {
328+ try {
329+ const response = await getPangeaDomainIntel ( domain ) ;
328330
329- const verdict = response . result . data [ apexDomain ] . verdict ;
330- console . log ( "Pangea verdict for domain" , apexDomain , verdict ) ;
331+ const verdict = response . result . data [ apexDomain ] . verdict ;
332+ console . log ( "Pangea verdict for domain" , apexDomain , verdict ) ;
331333
332- if ( verdict === "benign" ) {
333- await updateConfig ( {
334- key : "whitelistedDomains" ,
335- value : domain ,
336- } ) ;
337- return false ;
338- } else if ( verdict === "malicious" || verdict === "suspicious" ) {
339- await Promise . all ( [
340- updateConfig ( {
341- key : "domains" ,
334+ if ( verdict === "benign" ) {
335+ await updateConfig ( {
336+ key : "whitelistedDomains" ,
342337 value : domain ,
343- } ) ,
344- log ( {
345- message : `Suspicious link detected via Pangea → ${ url } ` ,
346- type : "links" ,
347- mention : true ,
348- } ) ,
349- ] ) ;
338+ } ) ;
339+ return false ;
340+ } else if ( verdict === "malicious" || verdict === "suspicious" ) {
341+ await Promise . all ( [
342+ updateConfig ( {
343+ key : "domains" ,
344+ value : domain ,
345+ } ) ,
346+ log ( {
347+ message : `Suspicious link detected via Pangea → ${ url } ` ,
348+ type : "links" ,
349+ mention : true ,
350+ } ) ,
351+ ] ) ;
350352
351- return true ;
353+ return true ;
354+ }
355+ } catch ( e ) {
356+ console . error ( "Error checking domain with Pangea" , e ) ;
352357 }
353- } catch ( e ) {
354- console . error ( "Error checking domain with Pangea" , e ) ;
355358 }
356359
357360 return false ;
You can’t perform that action at this time.
0 commit comments