JavaScript SDK¶
TypeScript/JavaScript library for verifying Auths attestations using WASM.
Installation¶
Requirements: Node.js 18+
Quick start¶
import { init, verifyAttestation, verifyChain } from '@auths/verifier';
// Initialize WASM module (required once)
await init();
// Verify a single attestation
const result = verifyAttestation(attestationJson, issuerPublicKeyHex);
if (result.valid) {
console.log('Attestation is valid!');
} else {
console.error('Verification failed:', result.error);
}
Verify a chain¶
const report = verifyChain(attestationsArray, rootPublicKeyHex);
if (report.status.type === 'Valid') {
console.log('Chain verified!');
} else {
console.error('Chain verification failed:', report.status);
}
// Check individual links
report.chain.forEach((link, i) => {
console.log(`Link ${i}: ${link.valid ? 'OK' : link.error}`);
});
API reference¶
Functions¶
init(): Promise<void>¶
Initialize the WASM module. Must be called once before any verification.
verifyAttestation(json, pkHex): VerificationResult¶
Verify a single attestation.
verifyChain(attestations, rootPkHex): VerificationReport¶
Verify a chain of attestations. Accepts JSON strings or objects.
interface VerificationReport {
status: VerificationStatus;
chain: ChainLink[];
warnings: string[];
}
type VerificationStatus =
| { type: "Valid" }
| { type: "Expired"; at: string }
| { type: "Revoked"; at?: string }
| { type: "InvalidSignature"; step: number }
| { type: "BrokenChain"; missing_link: string };
verifyAttestationOrThrow(json, pkHex): void¶
Same as verifyAttestation but throws on failure.
isInitialized(): boolean¶
Check if the WASM module has been initialized.
isVerificationValid(report): boolean¶
Helper to check if a report indicates success.
Browser usage¶
<script type="module">
import init, { verifyAttestation } from './pkg/auths_verifier.js';
await init();
const result = verifyAttestation(json, pkHex);
</script>
The WASM module works in modern browsers with ES module support.
Web Component¶
For a drop-in verification badge (no code required), use the auths-verify web component:
<script type="module" src="https://unpkg.com/auths-verify/dist/auths-verify.mjs"></script>
<auths-verify
attestation='{"version":1,...}'
public-key="aabbccdd..."
></auths-verify>
It wraps @auths/verifier WASM in a custom element with badge, detail, and tooltip display modes. See the GitHub repo and npm package for full documentation.