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

@cibel/opentoken

v0.7.9

Published

OpenToken implementation

Readme

opentoken

CircleCI Known Vulnerabilities codecov npm GitHub

About

OpenToken implementation

https://tools.ietf.org/html/draft-smith-opentoken-02

Installation

npm install --save @cibel/opentoken

Usage

Example

Import

const OpenToken = require('@cibel/opentoken');

Encoding

Instantiation
// instantiate with pbe password
const otk = new OpenToken('mypassword');

//or instantiate with options
const otk = new OpenToken('mypassword',{notAfter: 300,renewUntil: 300, cipher: OpenToken.CIPHER_AES_256_CBC});
Encoding from raw data
//Encode from raw OpenToken format
const subject = 'Alice';
const payload = 'foo=bar\nbar=baz';
const token = otk.encode(payload, subject);
console.log(token); 
//T1RLAQHYWXG5ELaGj5iUPQr-Enh5Jnm1jxB1xYzddUN5Et3jhYtn4coNAABwodDZZuXqG-lAHs9QGYeyjILE-KmR3lqnD-0wTpEUmQH98WaW0x0fscslpO8A8uqyfWaCuTkeSQOvkit7on1Sb-qg_dnGKLmt0sWigzPhRnNfv5RnpN8lByqwZgL8VIDq3IbSrHGVyvtZ55KC6n1ttQ**
Encoding from Map
// Encode from map
const subject = 'Alice';
const payload =  new Map(['foo','bar'],['bar','baz']);
const token = otk.encodeMap(payload, subject);
console.log(token);
//T1RLAQHYWXG5ELaGj5iUPQr-Enh5Jnm1jxB1xYzddUN5Et3jhYtn4coNAABwodDZZuXqG-lAHs9QGYeyjILE-KmR3lqnD-0wTpEUmQH98WaW0x0fscslpO8A8uqyfWaCuTkeSQOvkit7on1Sb-qg_dnGKLmt0sWigzPhRnNfv5RnpN8lByqwZgL8VIDq3IbSrHGVyvtZ55KC6n1ttQ**

Decoding

Instantiation
const otk = new OpenToken('mypassword');
Decode to OpenToken format
const data = otk.decode(token);
console.log(data);
Decode to Map
const data = otk.decodeAsMap(token);
console.log(data);
//Map { 'subject' => 'Alice','not-before' => '2019-12-06T14:12:53Z','not-on-or-after' => '2019-12-06T14:17:53Z','renew-until' => '2019-12-06T14:17:53Z','foo' => 'bar','bar' => 'baz'
  }

Validation

const otk = new OpenToken('mypassword');
const data = otk.validate(token);

//If we want to validate the subject as well
const subject = 'Alice';
const data = otk.validate(token,subject);
console.log(data);

Configuration

Constants
  • OpenToken.CIPHER_AES_256_CBC
  • OpenToken.CIPHER_AES_128_CBC
  • OpenToken.CIPHER_DES_TRIPLE_168_CBC
Constructor

| Arguments | Type | Required | Description | Default Value |
| ------------ | ------------------------|------------|-------------------------------| --------------------------- | password | string |Yes | Password | N/A | | options {} | {notAfter, renewUntil, cipher} | No | OpenToken validation options | {notAfter:300,renewUntil:300,OpenToken.CIPHER_AES_256_CBC}|

Encoding parameters

[token]=encode(payload, subject)

| Argument | Required | Type | Default | Description | Default value | |------------|-----------|---------------------------|-------|---------------------------------|-----------------| |payload | Yes |string | N/A | Raw OpenToken payload | N/A | |subject | No |string | 'opentoken' | OpenToken subject to match with | N/A |

[token]=encodeMap(payload, subject)

| Argument | Required | Value | Default | Description | Default value | |------------|-----------|---------------------------|-------|---------------------------------|-----------------| |payload | Yes |Map | N/A | Key value Opentoken format | N/A | |subject | No |string | 'opentoken' | OpenToken subject to match with | N/A |

Decoding parameters

[payload]=decode(token)

| Argument | Required | Type | Default | Description | Default value | |------------|-----------|---------------------------|-------|---------------------------------|-----------------| |token | Yes |string | N/A | OpenToken payload | N/A |

[payloadAsMap]=decodeAsMap(token)

| Argument | Required | Type | Default | Description | Default value | |------------|-----------|---------------------------|-------|---------------------------------|-----------------| |token | Yes |string | N/A | OpenToken payload as Map | N/A |

Validate parameters

[payload]=validate(token,subject)

| Argument | Required | Value | Default | Description | Default value | |------------|-----------|---------------------------|-------|---------------------------------|-----------------| |token | Yes |string | N/A | OpenToken payload | N/A | |subject | No |string | N/A | OpenToken subject to match with | N/A |

References

https://tools.ietf.org/html/draft-smith-opentoken-02

License

@cibel/opentoken is MIT licensed