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

@pagfinance/sdk

v0.4.0

Published

Client SDK to integrate external apps with the PagFinance payment/KYC API. Token-agnostic and crypto-free.

Readme

@pagfinance/sdk

SDK cliente, framework-agnóstico, para integrar apps externos com a API do PagFinance (pagamentos cripto → PIX/boleto/giftcard, KYC e cotações).

Projetada para ser plugável em qualquer app (Node 18+, browsers, bundlers) e para não conter nenhum segredo, chave ou lógica de criptografia/assinatura - toda essa parte permanece no app host, protegendo a propriedade intelectual e a segurança do PagFinance.

Instalação

npm install @pagfinance/sdk
# ou: pnpm add @pagfinance/sdk

Uso

import { PagFinanceClient } from '@pagfinance/sdk';

const client = new PagFinanceClient({
  baseUrl: 'https://app.pag.finance', // host da API (proxy Next.js)
  clientId: 'meu-app',
  appMeta: { name: 'meu-app', version: '1.0.0', domain: 'meuapp.com' },
  defaultBlockchain: 'solana',
});

// Endpoints públicos (sem auth)
const config = await client.assets.acceptedCryptos();
const price = await client.assets.getAssetPrice({ assetId: 1, fiatCurrency: 'BRL' });
const transfer = await client.payments.validateCode({ code: '00020101...' });

// Endpoints autenticados: forneça o tokenJWT obtido FORA da SDK
client.setToken(tokenJWT);
const me = await client.user.me();

Modelo de autenticação (challenge–response, sem cripto)

O login Web3 é um challenge–response (estilo SIWS). O SDK orquestra tudo; o app host só fornece um signer que assina o desafio com a carteira:

import nacl from 'tweetnacl';

const { tokenJWT } = await client.auth.signIn(
  { address, blockchain: 'solana' },
  (challenge) => wallet.signMessage(new TextEncoder().encode(challenge)),
);
// tokenJWT já fica salvo no client (tokenStore)

Internamente: POST /api/auth/challengesigner(challenge)POST /api/auth/verify. Não há criptografia nem chave no cliente - a única prova é a assinatura, e toda a lógica (nonce, verificação, emissão do token) vive no servidor. O mesmo contrato vale apontando o baseUrl para o app hoje ou para um BFF dedicado amanhã.

Token obtido por fora (ou reaproveitado):

client.setToken(tokenJWT);

Re-login transparente em 401 (opcional):

client.auth.enableAutoRelogin(async () => {
  await client.auth.signIn({ address, blockchain }, signer);
  return true;
});

Recursos

| Recurso | Métodos | | --- | --- | | assets | acceptedCryptos, gatewayConfig, assets, getAssetPrice | | payments | validateCode, quote, create, submit, list, get | | receipts | get({ type, tx, chain }) - agnóstico (pix/boleto/giftcard) | | kyc | naturalProposal, legalProposal, documentUrl, check, cpfValidate, userData | | user | me | | auth | signIn, challenge, verify, setToken, getToken, clearToken, otpSend, otpVerify, enableAutoRelogin |

Erros

Toda falha lança PagFinanceError com messages, fieldErrors, httpStatus e code, já normalizados a partir dos dois envelopes ({ success, data } e { ok, error }).

import { PagFinanceError } from '@pagfinance/sdk';

try {
  await client.payments.quote(req);
} catch (e) {
  if (e instanceof PagFinanceError) {
    console.error(e.messages, e.fieldErrors, e.httpStatus);
  }
}

Exemplo executável

Veja examples/transaction-flow - fluxo ponta-a-ponta real (cotação → criação → recibo) usando um TOKEN_JWT de variável de ambiente.

pnpm --filter @pagfinance/sdk build
PAGFINANCE_BASE_URL=https://app.pag.finance \
PAGFINANCE_CLIENT_ID=exemplo \
TOKEN_JWT=... \
PAYMENT_CODE='00020101...' \
SENDER_WALLET=7NaNvh... \
npx tsx examples/transaction-flow/index.ts