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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@prava-sdk/core

v0.1.0

Published

Prava SDK — PCI-compliant card enrollment for merchants

Downloads

54

Readme

@prava-sdk/core

PCI-compliant card enrollment SDK for AI Apps or merchant. Securely collect card data via an isolated iframe — your servers never touch raw PANs. This enables cards to be used for secure agentic payments

Install

npm install @prava-sdk/core

Quick Start

import { PravaSDK } from '@prava-sdk/core';

// 1. Initialize with your publishable key
const prava = new PravaSDK({
  publishableKey: 'pk_live_xxx',
});

// 2. Create a session via Prava backend (server-side, using your secret key)
const session = await fetch('/api/create-session', {
  method: 'POST',
  body: JSON.stringify({ userId: 'user_123' }),
}).then(res => res.json());

// 3. Collect card data
const result = await prava.collectPAN({
  sessionToken: session.session_token,
  iframeUrl: session.iframe_url,
  container: '#card-form',       // DOM element or selector
  onReady: () => {
    console.log('Card form loaded');
  },
  onChange: (state) => {
    // Real-time validation
    console.log('Valid:', state.isComplete);
  },
  onSuccess: (data) => {
    console.log('Enrolled!', data.enrollmentId, data.last4);
  },
  onError: (error) => {
    console.error(error.code, error.message);
  },
});
<!-- In your HTML -->
<div id="card-form"></div>

How It Works

  1. Your backend creates a session using your secret key → returns session_token + iframe_url
  2. The SDK mounts a sandboxed iframe from iframe_url into your page
  3. The user enters card details inside the iframe (your page never sees raw card data)
  4. The iframe tokenizes the card and communicates the result back via PostMessage
  5. You receive an enrollmentId + last4 + brand — no PCI scope for your servers

API

new PravaSDK(config)

| Parameter | Type | Required | Description | |-----------|------|----------|-------------| | publishableKey | string | ✅ | Your publishable key (pk_live_... or pk_test_...) |

prava.collectPAN(options)

Returns Promise<CollectPANResult>.

| Option | Type | Required | Description | |--------|------|----------|-------------| | sessionToken | string | ✅ | Session token from your backend | | iframeUrl | string | ✅ | Iframe URL from your backend session response | | container | string \| HTMLElement | ✅ | CSS selector or DOM element to mount the card form | | onReady | () => void | | Called when iframe is loaded and ready | | onChange | (state: CardValidationState) => void | | Called on every input change with validation state | | onSuccess | (result: CollectPANResult) => void | | Called on successful card enrollment | | onError | (error: PravaError) => void | | Called on error | | styles | CardFormStyles | | Custom styles for the card form |

prava.destroy()

Cleanup the SDK instance, remove the iframe, and release resources.

Types

interface CollectPANResult {
  enrollmentId: string;
  last4: string;
  brand: string;
  expMonth: number;
  expYear: number;
}

interface CardValidationState {
  cardNumber: FieldState;
  expiry: FieldState;
  cvv: FieldState;
  isComplete: boolean;
}

interface PravaError {
  code: string;
  message: string;
  details?: Record<string, unknown>;
}

Framework Examples

React

import { useRef, useEffect } from 'react';
import { PravaSDK } from '@prava-sdk/core';

function CardForm({ session }) {
  const containerRef = useRef<HTMLDivElement>(null);
  const sdkRef = useRef<PravaSDK | null>(null);

  useEffect(() => {
    if (!session || !containerRef.current) return;

    const sdk = new PravaSDK({ publishableKey: 'pk_live_xxx' });
    sdkRef.current = sdk;

    sdk.collectPAN({
      sessionToken: session.session_token,
      iframeUrl: session.iframe_url,
      container: containerRef.current,
      onSuccess: (data) => console.log('Enrolled:', data.enrollmentId),
    });

    return () => sdk.destroy();
  }, [session]);

  return <div ref={containerRef} />;
}

Vanilla JS

<div id="card-form"></div>
<script type="module">
  import { PravaSDK } from '@prava-sdk/core';

  const prava = new PravaSDK({ publishableKey: 'pk_live_xxx' });
  const session = await fetch('/api/session').then(r => r.json());

  prava.collectPAN({
    sessionToken: session.session_token,
    iframeUrl: session.iframe_url,
    container: '#card-form',
    onSuccess: (data) => alert(`Card enrolled: •••• ${data.last4}`),
  });
</script>

Security

  • Card data is entered inside a ** PCI compliant iframe** — your page never accesses raw card numbers
  • The SDK validates publishable keys and session tokens

Requirements

  • Modern browser (Chrome 80+, Firefox 80+, Safari 14+, Edge 80+)
  • Your backend must implement the Prava session API