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

@constemi/itsdangerjs

v0.0.2

Published

Javascript port of the Python itsdangerous module with influence from the ReallyDangerous javascript module

Downloads

8

Readme

itsdangerjs

Javascript port of the Python itsdangerous module with influence from the ReallyDangerous javascript module

Features

  • Timestamp Signer
  • URL Safe Signer
  • Timestamp URL Safe Signer

Usage

Signer

const itsdanger = require('itsdangerjs');
const signer = itsdanger.Signer('my-secret')
console.log(signer.sign('test'))
// 'test.XxfCnMKrwrLCgGzDnlXCjcKgw4vCjh8ow7oAfMOALxxAwoHCrnrCtcOswojCuVYBwp0DX8KlcW7ClMO7wpUeTWTDu8OOwofDhMO3wpgaQzpSw4Ukw6vCv8OoXl7Dig7DksKp'
console.log(signer.unsign('test.XxfCnMKrwrLCgGzDnlXCjcKgw4vCjh8ow7oAfMOALxxAwoHCrnrCtcOswojCuVYBwp0DX8KlcW7ClMO7wpUeTWTDu8OOwofDhMO3wpgaQzpSw4Ukw6vCv8OoXl7Dig7DksKp'))
// 'test'

itsdanger.Signer(secretKey[, salt, sep, digestMethod, algorithm])

  • secretKey {String} Secret to be used
  • salt {String} (default is 'itsdangerjs.Signer')
  • sep {String} (default is '.')
  • digestMethod {String} Digest method for signing (default is 'sha512')
  • algorithm {Function|Class} Algorithm to use for hashing (default is HMAC) - see signer.js for details

signer.sign(value)

  • value {String} The value to be signed

Returns signed string

signer.unsign(signedValue)

  • signedValue {String} Signed value

Returns original value if signature is correct

TimestampSigner

const itsdanger = require('itsdangerjs');
const signer = new itsdanger.TimestampSigner('my-secret');

console.log(signer.sign('test'));
// 'test.AWmhAxll.MGV2wprCk2FkDgfCpsK8w6AZwoAAHwtYwofCjMKrwqwQSAAWOMKYZsKPw5tjFgbCg8KrOcOJwotgY3grW34lecKiaDvCkMOYNxfDuS9CZi8Mw4ksKMKH'
console.log(signer.unsign('test.AWmhAxll.MGV2wprCk2FkDgfCpsK8w6AZwoAAHwtYwofCjMKrwqwQSAAWOMKYZsKPw5tjFgbCg8KrOcOJwotgY3grW34lecKiaDvCkMOYNxfDuS9CZi8Mw4ksKMKH'));
// 'test'
console.log(signer.getTimestamp('test.AWmhAxll.MGV2wprCk2FkDgfCpsK8w6AZwoAAHwtYwofCjMKrwqwQSAAWOMKYZsKPw5tjFgbCg8KrOcOJwotgY3grW34lecKiaDvCkMOYNxfDuS9CZi8Mw4ksKMKH'));
// 1553184596753

itsdanger.TimestampSigner(secretKey[, salt, sep, digestMethod, algorithm])

  • secretKey {String} Secret to be used
  • salt {String} (default is 'itsdangerjs.Signer')
  • sep {String} (default is '.')
  • digestMethod {String} Digest method for signing (default is 'sha512')
  • algorithm {Function|Class} Algorithm to use for hashing (default is HMAC) - see signer.js for details

signer.sign(value)

  • value {String} The value to be signed

Returns signed string with timestamp

signer.unsign(signedValue[, maxAge, returnTimestamp])

  • signedValue {String} Signed value
  • maxAge {Number} Max age time in milliseconds
  • returnTimestamp {Boolean} Return the timestamp used at creation (default is false)

Returns original value if signature is correct and age is less than maxAge (if defined)

URLSafeSerializer

const itsdanger = require('itsdangerjs');
const serializer = new itsdanger.URLSafeSerializer('my-secret');

console.log(serializer.dumps('test'));
// 'dGVzdA.TsKHw5E3w4fDh8O1w7PCv8Oxw4pYUDfDpcKfw5vDqABsMMK1EsOsw6MFWcOUwrbClcKYPCl7D1cNeTRtw48mwrDDuzzCuwvDkzIJHcKlC8OgJsK_H8OOw4bCoMOawofDvTU'
console.log(serializer.loads('dGVzdA.TsKHw5E3w4fDh8O1w7PCv8Oxw4pYUDfDpcKfw5vDqABsMMK1EsOsw6MFWcOUwrbClcKYPCl7D1cNeTRtw48mwrDDuzzCuwvDkzIJHcKlC8OgJsK_H8OOw4bCoMOawofDvTU'));
// 'test'

itsdanger.URLSafeSerializer(secretKey[, salt, serializer, signer])

  • secretKey {String} Secret to be used
  • salt {String} (default is 'itsdangerjs')
  • serializer {Function|Class} A function or class that exposes both loads and dumps methods(default is itsdanger.json.Json) - see json.js for details
  • signer {Function|Class} A fuction or class that will be used to sign values (default is itsdanger.Signer) - see signer.js for details

serializer.dumps(obj[, salt])

  • obj {String|Object} The value to be signed and serialized
  • salt {String} (default is inherited from the constructor)

Returns signed and serialized object

serializer.loads(s[, salt])

  • s {String} Signed and Serialized value to unsign and deserializer
  • salt {String} (default is inherited from the constructor)

Returns original object if signature is correct

URLSafeTimedSerializer

const itsdanger = require('itsdangerjs');
const serializer = new itsdanger.URLSafeTimedSerializer('my-secret');

console.log(serializer.dumps('test'));
// 'dGVzdA.AWmhGTQv.w6MERcO6CDvCqcKBwr0eMMKGNF7Ci8OPwpVVwpPCisKdw7ZKacOZGcORH8OLw7xzMMOwwrJdLcOhTRpnw7PDv2DDtMOSwpVUCDdbH8OqwqfDozDDh8KXPTTCvGFlwop1'
console.log(serializer.loads('dGVzdA.AWmhGTQv.w6MERcO6CDvCqcKBwr0eMMKGNF7Ci8OPwpVVwpPCisKdw7ZKacOZGcORH8OLw7xzMMOwwrJdLcOhTRpnw7PDv2DDtMOSwpVUCDdbH8OqwqfDozDDh8KXPTTCvGFlwop1'));
// 'test'
console.log(serializer.loads('dGVzdA.AWmhGTQv.w6MERcO6CDvCqcKBwr0eMMKGNF7Ci8OPwpVVwpPCisKdw7ZKacOZGcORH8OLw7xzMMOwwrJdLcOhTRpnw7PDv2DDtMOSwpVUCDdbH8OqwqfDozDDh8KXPTTCvGFlwop1', null, true)
[ 'test', 2019-04-05T15:56:57.391Z ])

itsdanger.URLSafeTimedSerializer(secretKey[, salt, serializer, signer])

  • secretKey {String} Secret to be used
  • salt {String} (default is 'itsdangerjs')
  • serializer {Function|Class} A function or class that exposes both loads and dumps methods(default is itsdanger.json.Json) - see json.js for details
  • signer {Function|Class} A fuction or class that will be used to sign values (default is itsdanger.TimestampSigner) - see timed.js for details

serializer.dumps(obj[, salt])

  • obj {String|Object} The value to be signed and serialized
  • salt {String} (default is inherited from the constructor)

Returns signed and serialized object

serializer.loads(s[, maxAge, returnTimestamp, salt])

  • s {String} Signed and Serialized value to unsign and deserializer
  • maxAge {Number} Max age time in milliseconds
  • returnTimestamp {Boolean} Return the timestamp used at creation (default is false)
  • salt {String} (default is inherited from the constructor)

Returns original object if signature is correct