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

token-h

v1.0.2

Published

Esta é uma lib baseada em token e semelhante ao jsonwebtoken.

Readme

token-h @1.0.0

token-h:

Uma biblioteca JavaScript simples para JSON Web Tokens (jwts). IntroduçãoJSON Web Token (tkn-H) é um padrão da indústria para representar reivindicações de forma segura entre duas partes.

Este projeto fornece uma implementação leve do token-H (jwt) em JavaScript, adequada para fins de aprendizagem e uso em projetos onde uma biblioteca token-H completa pode ser excessiva.

Funcionalidades de Codificação de payload para JwtDecodificação de token-H e verificação de assinaturaSuporte para o algoritmo de assinatura HS256. Opções para emissor, assunto, audiência e tempo de expiração, Tratamento de erros. Instalação Para usar esta biblioteca, simplesmente inclua o arquivo token-H .js no seu projeto desta forma:

npm install token-h

COMO USAR:

const { encode, decode } = require('token-h');

const payload = {
  userId: 123,
  nome: 'João da Silva',
  email: '[email protected]',
  // Outros dados do utilizador
};

const secret = 'seuSegredoSecreto'; // Mantenha isto em segredo!

const options = {
  algorithm: 'HS256', // Opcional, padrão é HS256
  issuer: 'meuServidor.com', // Opcional
  expiresIn: '1h', // Opcional, pode ser '1h', '30m', '5s', '1d', '3w', '1a' .
};
/**
 * h: equivale a hora
 * m: equivale a minuto
 * s: equivale a segundos
 * d: equivale a dia
 * w: equivale a semana (em inglês)
 * a: equivale a ano
*/

const token = encode(payload, secret, options);
console.log('Token H:', token);

const token =
  'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjEyMywibm9tZSI6Ikp...'; // Um token H real
const secret = 'seuSegredoSecreto'; // Deve corresponder ao segredo usado para codificar

const options = {
  algorithms: ['HS256'], // Opcional, padrão é ['HS256']
  ignoreExpiration: false, // Opcional, padrão é false
  issuer: 'meuServidor.com', // Opcional
};

const decodificar_payload = decode(token, secret, options);

if (decodificar_payload) {
  console.log('Payload Decodificado:', decodificar_payload);
  // Verifique se o utilizador existe na sua base de dados, etc.
} else {
  console.error('Token inválido!');
}

API

encode(payload, secret, options)

Codifica um payload em um token H.

  • payload {object} Payload a ser codificado.
  • secret {string} Chave secreta para a assinatura.
  • options {object} Opções para a codificação.
  • algorithm {string} Algoritmo de assinatura a usar.

Padrão:

  • 'HS256'.issuer {string} Emissor do token.
  • subject {string} Assunto do token.
  • audience {string | string[]} Audiência do token.
  • expiresIn {string | number} Tempo de expiração do token em segundos (por exemplo, '1h', 60 * 60).
  • notBefore {string | number} Tempo em que o token se torna válido (por exemplo, '10s', 10).
  • Retorna: {string} O token H.

decode(token, secret, options)

Decodifica um token H e verifica a assinatura e a expiração.

  • token {string} O token H a ser decodificado.
  • secret {string} A chave secreta para a verificação.
  • options {object} Opções para a decodificação.
  • algorithms {string[]} Algoritmos de assinatura esperados. Padrão: ['HS256']. ignoreExpiration {boolean} Se a expiração do token deve ser ignorada. Padrão: false. issuer {string} Emissor esperado do token. subject {string} Assunto esperado do token. audience {string | string[]} Audiência esperada do token.
  • Retorna: {object | null} O payload decodificado se o token for válido, caso contrário, null.

Segurança

A chave secreta é crucial para a segurança. Mantenha-a segura e nunca a exponha. Inclua sempre um tempo de expiração (exp) no payload para limitar o tempo que o token é válido. Esta biblioteca suporta o algoritmo HMAC SHA256 (HS256).

Contribuir

Contribuições são bem-vindas! Sinta-se à vontade para enviar pull requests ou abrir problemas para relatar bugs ou sugerir novos recursos.

From Hamuyela.

  • token-h - Biblioteca JWT Simplificada
  • Copyright (c) 2025 "Hamuyela.".
  • Todos os direitos reservados.
  • Licenciado sob a Licença MIT
  • https://opensource.org/licenses/MIT

LicençaMIT