Guardient JS SDK
Our JavaScript SDK is versatile and can be seamlessly integrated with virtually any Node.js-supported backend framework. This wide compatibility ensures that developers can efficiently use the SDK with popular frameworks and libraries such as Next.js, SvelteKit, Express.js, and Qwik. The list of compatible environments is extensive, ensuring that whether your project is web-based, server-side, or hybrid, our SDK provides a reliable and efficient solution.
Add guardient before or after signing up an user
Make sure to verify with Guardient before allowing user sign-ups. If that's not possible (Using a sign-up framework like Clerk or Supabase), sign them up first, then verify, and then block any accounts that don't meet your expectations.
Replace
<API_KEY>with your real API key. Check our introduction page for help on getting it.
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,
}
}As you can see, Guardian lets you decide if you want to block the user or not; it is very flexible. You can write your own logic to decide whether to block the user, unlike our competitors.
We would like to note that this is an example of how you can use Guardian in your web service. You are still required to code the part to take the action; we can't do that for you since every framework differs from each other. We are planning to provide examples for the most popular frameworks in the future,
Last updated
Was this helpful?

