-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 60f0134
Showing
28 changed files
with
7,318 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
|
||
[*.js] | ||
insert_final_newline=false | ||
|
||
[*.md] | ||
insert_final_newline=false | ||
|
||
[package.json] | ||
indent_style = space | ||
indent_size = 2 | ||
insert_final_newline=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"env": { | ||
"browser": false, | ||
"es2021": true | ||
}, | ||
"extends": [ | ||
"plugin:compat/recommended", | ||
"plugin:sonarjs/recommended" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": 2016 | ||
}, | ||
"plugins": [ | ||
"@typescript-eslint", | ||
"sonarjs" | ||
], | ||
"rules": { | ||
"no-multiple-empty-lines": "error", | ||
"no-console": "error", | ||
"no-empty": "error", | ||
"no-irregular-whitespace": "error", | ||
"no-unused-vars": "off", | ||
"no-alert": "error", | ||
"no-unreachable": "error", | ||
"sonarjs/cognitive-complexity": "warn", | ||
"sonarjs/no-small-switch": "warn", | ||
"sonarjs/no-identical-functions": "warn", | ||
"sonarjs/prefer-while": "off" | ||
}, | ||
"settings": { | ||
"polyfills": [ | ||
"Promise", | ||
"fetch" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
# Created by .ignore support plugin (hsz.mobi) | ||
### Node template | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Snowpack dependency directory (https://snowpack.dev/) | ||
web_modules/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
.env.test | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
.parcel-cache | ||
|
||
# Next.js build output | ||
.next | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and not Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# TernJS port file | ||
.tern-port | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
.vscode-test | ||
|
||
# yarn v2 | ||
|
||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.pnp.* | ||
|
||
*.iml | ||
.idea | ||
/.vs | ||
/.vscode | ||
/pipelines |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npm test | ||
lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Queue-it | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
[![NPM](https://nodeico.herokuapp.com/@queue-it/queue-token.svg)](https://www.npmjs.com/package/@queue-it/queue-token) | ||
|
||
# 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 can be issued by any application that supports JAVA 1.6+. | ||
## 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 "QFT1". 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 the user the token is issued to. If provided, the IP address is validated before issuing the token. Optional. | ||
- `xff`: The X-Forwarded-For headerof the request when the token is issued. If provided, the X-Forwarded-For header is validated before issuing the token. 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 | ||
|
||
```javascript | ||
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. | ||
|
||
```javascript | ||
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. |
Oops, something went wrong.