@poh-kit/gaas-client
v0.1.0
Published
TypeScript client for the Foundation Proof-of-Humanity verification API (GaaS)
Maintainers
Readme
@poh-kit/gaas-client
TypeScript SDK client for the Foundation Proof of Humanity API.
Install
npm install @poh-kit/gaas-clientQuick start
import { PohClient, PohApiError } from "@poh-kit/gaas-client";
const client = new PohClient("poh_live_your_api_key", {
baseUrl: "https://your-poh-api.example.com", // your verification-API deployment
});
// 1. Verify an ePassport ZK proof
const result = await client.verifyPassport(
"att_9f3a2b1c",
{ pi_a: "...", pi_b: "...", pi_c: "..." },
{ nullifier: "0x...", timestamp: 1234567890 },
);
console.log(result.nullifier, result.trustTier);
// 2. Attach a Semaphore commitment (requires Bearer JWT)
await client.attachCommitment("12345678901234567890", bearerToken);
// 3. Retrieve the Semaphore group
const group = await client.getGroup();
console.log(group.memberCount, group.merkleRoot);
// 4. Cast an anonymous vote
const vote = await client.anonymousVote(
"prop_abc123",
"opt_yes",
semaphoreProof,
nullifier,
signal,
externalNullifier,
);
console.log(vote.transactionSignature);
// 5. Check verification status
const status = await client.getProofStatus(result.nullifier);
console.log(status.exists, status.hasCommitment);Error handling
All API errors throw a PohApiError with status, code, and message fields:
try {
await client.verifyPassport(/* ... */);
} catch (err) {
if (err instanceof PohApiError) {
console.error(`API error ${err.status}: ${err.message}`);
}
}Custom base URL
const client = new PohClient("poh_live_key", {
baseUrl: "http://localhost:3000",
});Open client, closed service
This SDK and the API spec are
MIT/Apache-2.0. You point baseUrl at any deployment of the spec — implement it
yourself, or use Foundation's hosted multi-tenant service (its commercial
offering) once its URL is published. There is no baked-in default endpoint.
