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

wallet-pass

v1.0.2

Published

A library for managing wallet passes

Readme

wallet-pass

A library for managing wallet passes.

Installation

npm install wallet-pass

Usage

const walletPass = require('wallet-pass');
// Your usage examples here

Wallet Pass

A TypeScript library for generating Google Wallet passes.

Installation

npm install wallet-pass

Usage

import { GoogleGenericPass } from 'wallet-pass';

// Initialize the pass
const pass = new GoogleGenericPass('issuer_id', 'pass_id', 'class_id');

// Configure service account
pass.setServiceAccountCredentials('[email protected]', 'path/to/key.json');

// Set up the pass
pass
  .setPassClass('Issuer Name')
  .setCardTitle('My Pass')
  .setHeaderInfo('Pass Header', 'Subheader info')
  .setBarcode('https://example.com/1234', 'QR_CODE', 'Scan this code')
  .addTextModule('info', 'Additional information about the pass.');

// Generate JWT or link
const jwt = pass.generateJwt(['https://your-website.com']);
const walletLink = pass.generateAddToWalletLink(['https://your-website.com']);

API Documentation

GoogleGenericPass

Main class for creating Google Wallet passes.

Constructor

new GoogleGenericPass(issuerId: string, passId: string, classId: string)

Example usage

import { GoogleGenericPass } from './lib/google-generic-pass';
import path from 'path';
import fs from 'fs';

try {
  // Create a new generic pass with issuer ID, pass ID and class ID
  const issuerId = '3388000000022926467';
  const passId = 'pass-' + Date.now(); // Unique identifier for each pass
  const classId = 'generic-class-1';

  const pass = new GoogleGenericPass(issuerId, passId, classId);

  // Set service account credentials (required for JWT signing)
  const keyFilePath = path.join(__dirname, '../keys/service-account.json');
  if (!fs.existsSync(keyFilePath)) {
    throw new Error(`Service account key file not found at ${keyFilePath}`);
  }

  console.log(`Using service account key from: ${keyFilePath}`);
  pass.setServiceAccountCredentials(
    '[email protected]',
    keyFilePath,
  );

  // ===== SIMPLIFIED IMPLEMENTATION - MINIMAL FIELDS FOR DEBUGGING =====

  // 1. First set up the pass class
  pass.setPassClass('Your Company Name');
  pass.setClassTemplateInfo([
    pass.createTwoItemsRow(
      "object.textModulesData['points']",
      "object.textModulesData['contacts']",
    ),
  ]);

  // 2. Then set up the minimal pass object fields required
  pass.setBasicInfo('GENERIC_TYPE_UNSPECIFIED', '#2F2F31');

  // Set exactly the required fields to match Google's example
  pass.setCardTitle('DMI Cards');
  pass.setHeaderInfo('Nipuna Nishan', 'Software Engineer');

  // Add exact text modules matching Google's example
  pass.addTextModule('Web', 'https://example.com', 'WEB');

  // Add barcode with empty alternateText as shown in Google's example
  pass.setBarcode('BARCODE_VALUE', 'QR_CODE', '');

  // Add logo and hero image
  pass.setLogo('https://dmi.cards.xleron.io/logo/logo.webp', 'LOGO_IMAGE_DESCRIPTION');
  pass.setHeroImage(
    'https://s3.eu-north-1.amazonaws.com/app.toolgenie.io-dev/3a1016a2-fd91-4594-ae2f-86ce563d33bc',
    'HERO_IMAGE_DESCRIPTION',
  );

  // // Add Links Module Data
  pass.addLinks([
    {
      id: 'website',
      uri: 'https://example.com',
      description: 'Visit our website',
    },
    {
      id: 'support',
      uri: 'https://example.com/support',
      description: 'Contact support',
    },
    {
      id: 'terms',
      uri: 'https://example.com/terms',
      description: 'Terms and conditions',
    },
  ]);

  const passObj = pass.getPassObject();
  if (passObj.additionalInfo && passObj.additionalInfo.length > 0) {
    passObj.additionalInfo = [];
  }

  // Debug output - log the full payload to see what's being sent
  console.log('\n----- DEBUG: PAYLOAD STRUCTURE -----');
  pass.debugPayload();

  // Generate link with allowed origins
  const allowedOrigins = ['https://example.com']; // Add valid origins here
  const addToWalletLink = pass.generateAddToWalletLink(allowedOrigins);

  console.log('\nAdd to Google Wallet link:');
  console.log(addToWalletLink);
} catch (error) {
  console.error('Error creating pass:', error);
}