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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@passninja/passninja-js

v0.6.0

Published

PassNinja pass creation helper library.

Downloads

80

Readme

Contents

Installation

Use npm or yarn to install the passninja-js module:

npm install @passninja/passninja-js

Usage

PassNinjaClient

This function returns a newly created PassNinjaClient object. Make sure to pass your user credentials to make any authenticated requests.

const {PassNinjaClient} = require('@passninja/passninja-js');

const accountId = '**your-account-id**';
const apiKey = '**your-api-key**';

const passNinjaClient = new PassNinjaClient(accountId, apiKey);

We’ve placed our demo user API credentials in this example. Replace it with your actual API credentials to test this code through your PassNinja account and don't hesitate to contact PassNinja with our built in chat system if you'd like to subscribe and create your own custom pass type(s).

For more information on how to use passninja-js once it loads, please refer to the PassNinja JS API reference

PassNinjaClientMethods

This library currently supports methods for creating, getting, updating, and deleting passes via the PassNinja api. The methods are outlined below. Note that each method returns a promise.

Create

const simplePassObject = await passNinjaClient.pass.create(
  'ptk_0x14', // passType
  {discount: '50%', memberName: 'John'} // passData
);
console.log(simplePassObject.url);
console.log(simplePassObject.passType);
console.log(simplePassObject.serialNumber);

Find

Finds issued passes for a given pass template key

const passObjects = await passNinjaClient.pass.find(
  'ptk_0x14' // passType or pass template key
);

Decrypt

Decrypts issued passes payload for a given pass template key

const decryptedPass = await passNinjaClient.pass.decrypt(
  'ptk_0x14',  // passType or pass template key
  '55166a9700250a8c51382dd16822b0c763136090b91099c16385f2961b7d9392d31b386cae133dca1b2faf10e93a1f8f26343ef56c4b35d5bf6cb8cd9ff45177e1ea070f0d4fe88887' // payload
);

Get

const detailedPassObject = await passNinjaClient.pass.get(
  'ptk_0x14', // passType
  '840a0562-f22d-4ecf-a2d7-9ac785bed8e4' // serialNumber
);

Get Pass Template Details

const passTemplate = await passNinjaClient.passTemplates.find(
  'ptk_0x14', // passTemplate key
);
console.log(passTemplate.pass_type_id);

Update

const simplePassObject = await passNinjaClient.pass.put(
  'ptk_0x14', // passType
  '840a0562-f22d-4ecf-a2d7-9ac785bed8e4', // serialNumber
  {discount: '100%', memberName: 'Ted'} // passData
);

Delete

const deletedPassSerialNumber = await passninja.pass.delete(
    'ptk_0x14', // passType,
    '840a0562-f22d-4ecf-a2d7-9ac785bed8e4' // serialNumber
);
console.log(`Pass deleted. serial_number: ${deletedPassSerialNumber})); })();

Script Tag

Manually add the passninja-js script tag to the <head> of each page on your site in order to use PassNinjaClient.

<!-- Somewhere in your site's <head> -->
<script src="https://js.passninja.com/v1" async></script>

Examples

Feel free to browse the Examples Folder for implementations

TypeScript support

This package includes TypeScript declarations for passninja-js. We support projects using TypeScript versions >= 3.1.

Documentation