Back to Documentation
JavaScript SDK

QIVERS JavaScript SDK

Integrate zero-knowledge identity verification into your JavaScript and TypeScript applications.

Installation

npm
npm install @qivers/sdk
yarn
yarn add @qivers/sdk

Usage

JavaScript / TypeScript
import { QiversClient } from '@qivers/sdk';

// Initialize the client
const client = new QiversClient({
  apiKey: 'YOUR_API_KEY',
  environment: 'production' // or 'sandbox' for testing
});

// Generate a zero-knowledge proof
async function generateProof() {
  const proof = await client.generateProof({
    attributes: {
      age: 25,
      country: 'US'
    },
    reveal: ['country'] // Only reveal country, keep age private
  });
  
  return proof;
}

// Verify a proof
async function verifyProof(proof) {
  const result = await client.verifyProof(proof);
  
  if (result.valid) {
    console.log('Proof is valid!');
    console.log('Revealed attributes:', result.attributes);
  } else {
    console.error('Invalid proof');
  }
}

React Integration

React Component
import { useState } from 'react';
import { useQivers } from '@qivers/react';

function IdentityVerification() {
  const [isVerified, setIsVerified] = useState(false);
  const [attributes, setAttributes] = useState(null);
  const { generateProof, verifyProof } = useQivers();

  const handleVerify = async () => {
    try {
      const proof = await generateProof({
        attributes: {
          age: 25,
          country: 'US'
        },
        reveal: ['country']
      });
      
      const result = await verifyProof(proof);
      
      if (result.valid) {
        setIsVerified(true);
        setAttributes(result.attributes);
      }
    } catch (error) {
      console.error('Verification failed:', error);
    }
  };

  return (
    <div>
      <button onClick={handleVerify}>
        Verify Identity
      </button>
      
      {isVerified && (
        <div>
          <p>Identity verified!</p>
          <p>Country: {attributes.country}</p>
        </div>
      )}
    </div>
  );
}

API Reference

QiversClient

The main client for interacting with the QIVERS API.

Constructor

new QiversClient(options: {
  apiKey: string;
  environment?: 'production' | 'sandbox';
})

Methods

generateProof

Generates a zero-knowledge proof for the given attributes.

async generateProof(options: {
  attributes: Record<string, any>;
  reveal: string[];
}): Promise<string>

verifyProof

Verifies a zero-knowledge proof.

async verifyProof(proof: string): Promise<{
  valid: boolean;
  attributes: Record<string, any>;
}>

Ready to Get Started?

Download the JavaScript SDK and start integrating zero-knowledge identity verification into your applications.