Guardient JS SDK
1
2
Add guardient before or after signing up an user
import { verifyWithGuardient } from "guardient-sdk"
// This is an example of how you can use the Guardient SDK to verify a user during sign-up.
export async function verifySignUp(email: string, ip: string, phone: string) {
const response = await verifyWithGuardient(
{
email,
ip,
phone,
},
"<API_KEY>"
)
// Something went wrong, we are throwing an error for example
if (!response.success) {
return {
allow: false,
error: response.error,
}
}
// If the trust score is below 70, we don't allow the user to proceed.
if (response.data!.trustScore < 70) {
return {
allow: false,
error: "Trust score is too low, you cannot proceed.",
}
}
// Let's block the user if they have vpn enabled no matter the trust score.
else if (response.data!.signals.includes("vpn_ips")) {
return {
allow: false,
error: "VPN detected, you cannot proceed.",
}
}
// Everything looks good, we can allow the user to proceed.
return {
allow: true,
}
}Last updated
Was this helpful?

