@naughtbot/sdk
v0.1.5
Published
NaughtBot captcha SDK — cryptographic proof of human interaction via biometric verification
Maintainers
Readme
NaughtBot SDK
TypeScript SDK for the NaughtBot CAPTCHA widget. Provides cryptographic proof of human interaction via biometric verification.
Install
npm install @naughtbot/sdkUsage
The SDK provides two entrypoints: @naughtbot/sdk/browser for client-side UI and @naughtbot/sdk/server for server-side proof verification.
Browser — Widget
import { createWidget } from "@naughtbot/sdk/browser";
const widget = await createWidget("#captcha", {
nonce: "server-generated-nonce",
relayUrl: "https://relay.naughtbot.com",
onVerified: (result) => {
// Send result.proof to your server for verification
fetch("/api/verify", {
method: "POST",
body: JSON.stringify(result),
});
},
});Browser — Headless Session
import { createSession } from "@naughtbot/sdk/browser";
const session = await createSession({
nonce: "server-generated-nonce",
relayUrl: "https://relay.naughtbot.com",
});
// Display session.qrCodeUrl as a QR code
const result = await session.waitForResult();Browser — BLE Transport
import { createBLESession, isBLEAvailable } from "@naughtbot/sdk/browser";
if (await isBLEAvailable()) {
// Must be called from a user gesture (click handler)
const session = await createBLESession({ nonce: "server-generated-nonce" });
const result = await session.waitForResult();
}Server — Proof Verification
import { verifyCaptchaProof } from "@naughtbot/sdk/server";
const result = await verifyCaptchaProof(captchaResult, {
issuerPublicKey: {
keyId: "key-001",
publicKey: "<base64url-encoded BLS12-381 G2 public key>",
},
expectedDomain: "example.com",
logger: console, // optional, defaults to console
});
if (result.valid) {
// Proof is valid
}Development
# Build
pnpm install && pnpm build
# Run tests
pnpm test
# Lint
pnpm lintRelated Repos
- ackagent/web-sdk — AckAgent Web SDK (peer dependency)
- naughtbot/api — NaughtBot API types
- naughtbot/relay — NaughtBot relay service
License
MIT
