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

@queue-it/queue-token

v1.0.4

Published

Ensures that end users cannot enter the queue without a valid token and to be a container which can carry sensitive user information from integrating system into the queue

Downloads

1,493

Readme

npm

Queue-it Queue Token SDK for JavaScript

The Queue-it Queue Token SDK is used to ensure that end users cannot enter the queue without a valid token and to be a container which can car-ry sensitive user information from integrating system into the queue.

The Token

The token consists of two parts. Firstly, a header containing non-sensitive metadata. Secondly the payload of the token. Both header and payload are in JSON format.

Token Header

{
  "typ": "QT1",
  "enc": "AES256",
  "iss": 1526464517,
  "exp": 1526524517,
  "ti": "159aba3e-55e1-4f54-b6ee-e5b943d7e885",
  "c": "ticketania",
  "e": "demoevent",
  "ip": "75.86.129.4",
  "xff": "45.67.2.4,34.56.3.2"
}
  • typ: The type of the token. Value must be "QT1". Required.
  • enc: Payload encryption algorithm. Value must be "AES256". Required.
  • iss: NumericDate of when token was issued. Required.
  • exp: NumericDate of when token expires. Optional.
  • ti: Unique Token ID (e.g. uuid). Used to uniquely identify tokens and restrict replay attacks. Required.
  • c: The Customer ID of the issuer. Token will only be valid on events on this account. Required.
  • e: The Event ID. If provided, token will only be valid on this event. Optional.
  • ip: The IP address of user the token is issued for. If provided, the IP address in the token is validated against the client IP before issuing a new Queue id. Optional.
  • xff: The X-Forwarded-For header of the request when the token is issued. Only used for logging. Optional.

Token Payload

{
  "r": 0.4578,
  "k": "XKDI42W",
  "cd": { "size": "medium" }
}
  • r: The relative quality of the key. Must be a decimal value. Used for determining the quality of the token. Optional
  • k: A unique key that holds value to the integrating system (e.g. email or user id). Used to restrict users from issuing multiple queue ids. Optional.
  • cd: Any custom data of the user. This is a set of key-value pairs. Optional

Usage

const secretKey = '...';
const token = Token
    .Enqueue("ticketania")
    .WithPayload(Payload
        .Enqueue()
        .WithKey("XKDI42W")
        .WithRelativeQuality(0.4578)
        .WithCustomData("size", "medium")
        .Generate())
    .WithEventId("demoevent")
    .WithIpAddress("75.86.129.4", "45.67.2.4,34.56.3.2")
    .WithValidity(60000)
    .Generate(secretKey);

const tokenValue = token.Token;

Specifying token identifier prefix

A prefix for the token identifier can optionally be provided to restrict the user session after getting through the queue to the one used before entering the queue. Once the user is through the queue the token identifier is provided to the target application in the Known User token. The format of the token identifier is then [YOUR PREFIX]~[GUID], e.g: AnfTDnpwazllYmnmgaCJ8tErV80YHv77ni5NgqQNhfWwxNqrNcHb~e937ef0d-48ec-4ff7-866e-52033273cb3d.

const tokenIdentifierPrefix = "AnfTDnpwazllYmnmgaCJ8tErV80YHv77ni5NgqQNhfWwxNqrNcHb";
const token = Token
    .Enqueue("ticketania", tokenIdentifierPrefix)
    .Generate(secretKey);

const tokenIdentifier = token.TokenIdentifier;
// tokenIdentifier example: AnfTDnpwazllYmnmgaCJ8tErV80YHv77ni5NgqQNhfWwxNqrNcHb~e937ef0d-48ec-4ff7-866e-52033273cb3d

Serialized Token

eyJ0eXAiOiJRVDEiLCJlbmMiOiJBRVMyNTYiLCJpc3MiOjE1MzQ3MjMyMDAwMDAsImV4cCI6MTUzOTEyOTYwMDAwMCwidGkiOiJhMjFkNDIzYS00M2ZkLTQ4MjEtODRmYS00MzkwZjZhMmZkM2UiLCJjIjoidGlja2V0YW5pYSIsImUiOiJteWV2ZW50In0.0rDlI69F1Dx4Twps5qD4cQrbXbCRiezBd6fH1PVm6CnVY456FALkAhN3rgVrh_PGCJHcEXN5zoqFg65MH8WZc_CQdD63hJre3Sedu0-9zIs.aZgzkJm57etFaXjjME_-9LjOgPNTTqkp1aJ057HuEiU

The format of the token is [header].[payload].[hash] where each part is Base64Url encoded. The payload is AES 256 encrypted with the secret key supplied in the .Generate(secretKey) method. If the "e" key is provided in the header, the secret key on the event must be used. If no "e" key is provided the default key on the customer account must be used. The token is signed with SHA 256 using the same secret key.