npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

astra-sdk-protocol

v0.3.16

Published

A comprehensive KYC (Know Your Customer) SDK with web and mobile support, featuring face capture, document upload, and seamless device switching.

Downloads

2,179

Readme

Astra KYC SDK

A comprehensive KYC (Know Your Customer) SDK with web and mobile support, featuring face capture, document upload, and seamless device switching.

Features

  • Face Capture: Live camera capture with web
  • Document Upload: Support for CNIC and Passport documents
  • Device Switching: QR code-based switching from web to mobile
  • Session Management: Automatic session validation and expiry handling
  • TypeScript Support: Full type definitions included
  • React Integration: Ready-to-use React components

Installation

npm install astra-sdk-astra

Quick Start

Basic Usage (Modal flow)

import React, { useState } from "react";
import { VerificationSDK, KycModal } from "astra-sdk-astra";
import "astra-sdk-astra/kycModal.css";

const sdk = new VerificationSDK({ serverKey: "your-server-key" });

function App() {
  const [showModal, setShowModal] = useState(false);
  const [loading, setLoading] = useState(false);
  const [error, setError] = useState<string | null>(null);

  const startKyc = async () => {
    setError(null);
    setLoading(true);
    try {
      await sdk.init({
        reference: "user123",
        email: "[email protected]",
        callback_url: "https://your-app.com/callback",
        redirect_url: "https://your-app.com/redirect",
        device_type: "WEB"
      });
      setShowModal(true);
    } catch (err: any) {
      setError(err?.message || "Failed to initialize KYC");
    } finally {
      setLoading(false);
    }
  };

  return (
    <div>
      <button onClick={startKyc} disabled={loading}>
        {loading ? "Starting..." : "Start KYC"}
      </button>
      {error && <div style={{ color: "red" }}>{error}</div>}
      {showModal && (
        <KycModal
          sdk={sdk}
          onClose={() => setShowModal(false)}
        />
      )}
    </div>
  );
}

What users see in the modal:

  • Face capture step (with QR to switch to mobile)
  • Document step with CNIC/Passport selector; if an upload fails, an "Upload again" button appears so users can retry immediately
  • Status step showing the verification outcome

Turnkey Flow (optional)

If you prefer an out-of-the-box flow with a start button, init form, terms screen, and modal managed for you:

import { KycFlow } from "astra-sdk-astra";
import "astra-sdk-astra/kycModal.css";

function App() {
  return (
    <KycFlow serverKey="your-server-key" startLabel="Start KYC" />
  );
}

Button → Init Form → Modal (previous structure)

If you want a simple "Start KYC" button that opens the init form first and, on success, opens the KYC modal:

import { useState } from "react";
import { VerificationSDK, KycInitForm, KycModal } from "astra-sdk-astra";
import "astra-sdk-astra/kycModal.css";

const sdk = new VerificationSDK({ serverKey: "your-server-key" });

function App() {
  const [showInit, setShowInit] = useState(false);
  const [showModal, setShowModal] = useState(false);

  return (
    <div>
      <button
        type="button"
        className="kyc-input"
        style={{
          background: "linear-gradient(90deg, #FF8A00 0%, #FF3D77 100%)",
          color: "#fff",
          border: "none",
          borderRadius: 8,
          padding: 10,
          cursor: "pointer"
        }}
        onClick={() => setShowInit(true)}
      >
        Start KYC
      </button>

      {showInit && (
        <div className="kyc-backdrop">
          <div className="kyc-container">
            <KycInitForm
              sdk={sdk}
              onStarted={() => {
                setShowInit(false);
                setShowModal(true);
              }}
            />
          </div>
        </div>
      )}

      {showModal && (
        <KycModal sdk={sdk} onClose={() => setShowModal(false)} />
      )}
    </div>
  );
}

API Reference

VerificationSDK

Constructor

new VerificationSDK({ serverKey: string })

Methods

init(options: InitOptions): Promise<InitResponse>

Initialize a new KYC session.

interface InitOptions {
  reference: string;
  email: string;
  callback_url: string;
  redirect_url: string;
  device_type?: "WEB" | "MOBILE";
}
uploadFace(faceBlob: Blob): Promise<any>

Upload face capture image.

uploadDocument(docBlob: Blob, type: string): Promise<any>

Upload document (CNIC or PASSPORT).

getStatus(): Promise<any>

Get current session status.

Components

KycModal

Main KYC modal component for web usage.

interface KycModalProps {
  sdk: VerificationSDK;
  onClose: () => void;
  classNames?: KycModalClassNames;
  styles?: KycModalStyleOverrides;
}

CSS Classes

  • kyc-backdrop - Modal backdrop
  • kyc-container - Modal container
  • kyc-close - Close button
  • kyc-title - Step titles
  • kyc-input - Input elements
  • kyc-status - Status display
  • kyc-error - Error messages
  • kyc-loading - Loading indicators

Custom Styling

<KycModal
  sdk={sdk}
  onClose={() => setShowModal(false)}
  styles={{
    backdrop: { backgroundColor: "rgba(0,0,0,0.7)" },
    container: { maxWidth: 520 },
    title: { color: "#1f2937" }
  }}
  classNames={{
    container: "my-custom-modal",
    title: "my-custom-title"
  }}
/>

Error Handling

The SDK handles various error scenarios:

  • Session Expired: Automatic detection and user notification
  • Face Already Registered: Graceful handling with user feedback
  • Document Already Exists: Prevents duplicate uploads
  • Network Errors: Proper error messages and retry options

Browser Support

  • Web: Modern browsers with camera support

TypeScript

Full TypeScript support with exported types:

import type { 
  InitOptions, 
  InitResponse, 
  InitResponseData 
} from "astra-sdk-astra";

Development

Building the SDK

npm run build:lib

Testing

npm test

License

MIT License - see LICENSE file for details.

Support

For support and questions, please contact the development team.