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

@validapay/tokenize

v1.4.0

Published

Tokenização de cartão e identificação do dispositivo para antifraude ValidaPay

Readme

@validapay/tokenize

Salva o cartão do comprador na ValidaPay e identifica o dispositivo para a análise antifraude. Roda no navegador, na sua página de pagamento: o cartão vai direto para a ValidaPay, sem passar pelo seu servidor.

npm install @validapay/tokenize

O publicId é o identificador público da sua conta, no painel em Gerenciamento > Minha Conta > Id Público. Ele pode ficar no código da página.

1. Identificar o dispositivo

Chame assim que a página de pagamento abrir, uma vez por pedido: a identificação precisa desse tempo antes do pagamento.

import { collectDevice } from "@validapay/tokenize/browser";

const { deviceId } = await collectDevice({ publicId: "3f1c2a8e-8a4b-4c1e-9d3a-2b7e6f5a4c10" });
  • Não coleta dados pessoais nem dados do cartão.
  • Guarde o deviceId: ele vai junto na cobrança.

2. Tokenizar o cartão

import { tokenize } from "@validapay/tokenize/browser";

const { cardToken, cardTokenExpiresAt, cardBrand, cardLastFour } = await tokenize({
  publicId: "3f1c2a8e-8a4b-4c1e-9d3a-2b7e6f5a4c10",
  card: { number: "4111111111111111", holderName: "MARIA SILVA", cvv: "123", expiration: "12/2030" },
  customer: { name: "Maria Silva", document: "12345678901", email: "[email protected]" },
});
  • Devolve cardToken, cardTokenExpiresAt, cardBrand e cardLastFour.
  • O cardToken vale 5 minutos e só funciona na conta que o gerou.
  • environment: production (padrão), sandbox ou development.
  • Aceita cartões de 13 a 19 dígitos.

Comprador estrangeiro

Informe customer.country com o código ISO 3166-1 alfa-2 do país do comprador (sem ele, o SDK usa customer.address.country, então o mesmo customer do 3DS serve). Com país diferente de BR, o document é opcional e, se enviado (passaporte, por exemplo), segue com letras:

const { cardToken } = await tokenize({
  publicId,
  card: { number: "4111111111111111", holderName: "JOHN SMITH", cvv: "123", expiration: "12/2030" },
  customer: { name: "John Smith", email: "[email protected]", country: "US" },
});

Na cobrança, envie o cliente sem documentNumber, com phone em E.164 e address.country do mesmo país.

Com autenticação do portador

Se usar @validapay/3ds, passe o resultado em authentication:

const { cardToken } = await tokenize({ publicId, card, customer, authentication });

3. Cobrar

Envie cardToken, deviceId e, se usou 3DS, authentication ao seu servidor. Ele cria a cobrança dentro dos 5 minutos:

POST /v1/charges
{
  "paymentMethod": "creditcard",
  "amount": 149.9,
  "cardToken": "ctk_…",
  "deviceId": "…",
  "authentication": { … },
  "customer": { … }
}

Depois de 5 minutos o cardToken vence e a cobrança responde CARD_TOKEN_EXPIRED: tokenize o cartão de novo.

Documentação

https://docs.validapay.com.br/sdks/tokenizacao