SDKS
Node SDK
TypeScript-native client with full type definitions. Promise API, no callback style. Validates JWTs locally on the verify path. Works in Node 18+ and modern serverless runtimes.
Install
npm install lorica-node
# or
yarn add lorica-node
pnpm add lorica-node Basic usage
import { Lorica } from 'lorica-node';
const lorica = new Lorica({
apiKey: process.env.LORICA_API_KEY!,
signingSecret: process.env.LORICA_SIGNING_SECRET!,
});
// Enroll
await lorica.enroll({ userId: 'usr_abc', frames: [frameJpegB64] });
// Verify
const result = await lorica.verify({
userId: 'usr_abc',
action: 'withdrawal',
amt: '50000',
asset: 'USDT',
frames: [frame1B64, frame2B64],
});
if (result.match && result.score >= 0.9) {
await processWithdrawal({ userId: 'usr_abc', loricaJwt: result.jwt });
}
// Delete
await lorica.deleteUser({ userId: 'usr_abc' }); Type definitions
Every method returns a strongly-typed Promise. VerifyResult
is exported as a TypeScript type with jwt, match,
score, claims, and verificationId
fields. Errors are typed exception classes — pattern-match with
instanceof.
Error handling
import { Lorica, LoricaLowConfidence, LoricaRateLimited } from 'lorica-node';
try {
const result = await lorica.verify(...);
} catch (err) {
if (err instanceof LoricaLowConfidence) {
await queueForReview(userId, err.score);
} else if (err instanceof LoricaRateLimited) {
await sleep(err.retryAfter * 1000);
return retry();
} else {
throw err;
}
} Edge runtimes
The SDK works in Vercel Edge, Cloudflare Workers, and Deno without
polyfills. Uses the standard fetch API, no Node-specific
crypto modules — JWT validation runs on the Web Crypto API.