aboutsummaryrefslogtreecommitdiffstats
path: root/backend/node_modules/jsonwebtoken
diff options
context:
space:
mode:
Diffstat (limited to 'backend/node_modules/jsonwebtoken')
-rw-r--r--backend/node_modules/jsonwebtoken/LICENSE21
-rw-r--r--backend/node_modules/jsonwebtoken/README.md396
-rw-r--r--backend/node_modules/jsonwebtoken/decode.js30
-rw-r--r--backend/node_modules/jsonwebtoken/index.js8
-rw-r--r--backend/node_modules/jsonwebtoken/lib/JsonWebTokenError.js14
-rw-r--r--backend/node_modules/jsonwebtoken/lib/NotBeforeError.js13
-rw-r--r--backend/node_modules/jsonwebtoken/lib/TokenExpiredError.js13
-rw-r--r--backend/node_modules/jsonwebtoken/lib/asymmetricKeyDetailsSupported.js3
-rw-r--r--backend/node_modules/jsonwebtoken/lib/psSupported.js3
-rw-r--r--backend/node_modules/jsonwebtoken/lib/rsaPssKeyDetailsSupported.js3
-rw-r--r--backend/node_modules/jsonwebtoken/lib/timespan.js18
-rw-r--r--backend/node_modules/jsonwebtoken/lib/validateAsymmetricKey.js66
l---------backend/node_modules/jsonwebtoken/node_modules/.bin/semver1
-rw-r--r--backend/node_modules/jsonwebtoken/package.json71
-rw-r--r--backend/node_modules/jsonwebtoken/sign.js253
-rw-r--r--backend/node_modules/jsonwebtoken/verify.js263
16 files changed, 0 insertions, 1176 deletions
diff --git a/backend/node_modules/jsonwebtoken/LICENSE b/backend/node_modules/jsonwebtoken/LICENSE
deleted file mode 100644
index bcd1854..0000000
--- a/backend/node_modules/jsonwebtoken/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2015 Auth0, Inc. <support@auth0.com> (http://auth0.com)
-
-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.
diff --git a/backend/node_modules/jsonwebtoken/README.md b/backend/node_modules/jsonwebtoken/README.md
deleted file mode 100644
index 4e20dd9..0000000
--- a/backend/node_modules/jsonwebtoken/README.md
+++ /dev/null
@@ -1,396 +0,0 @@
-# jsonwebtoken
-
-| **Build** | **Dependency** |
-|-----------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------|
-| [![Build Status](https://secure.travis-ci.org/auth0/node-jsonwebtoken.svg?branch=master)](http://travis-ci.org/auth0/node-jsonwebtoken) | [![Dependency Status](https://david-dm.org/auth0/node-jsonwebtoken.svg)](https://david-dm.org/auth0/node-jsonwebtoken) |
-
-
-An implementation of [JSON Web Tokens](https://tools.ietf.org/html/rfc7519).
-
-This was developed against `draft-ietf-oauth-json-web-token-08`. It makes use of [node-jws](https://github.com/brianloveswords/node-jws)
-
-# Install
-
-```bash
-$ npm install jsonwebtoken
-```
-
-# Migration notes
-
-* [From v8 to v9](https://github.com/auth0/node-jsonwebtoken/wiki/Migration-Notes:-v8-to-v9)
-* [From v7 to v8](https://github.com/auth0/node-jsonwebtoken/wiki/Migration-Notes:-v7-to-v8)
-
-# Usage
-
-### jwt.sign(payload, secretOrPrivateKey, [options, callback])
-
-(Asynchronous) If a callback is supplied, the callback is called with the `err` or the JWT.
-
-(Synchronous) Returns the JsonWebToken as string
-
-`payload` could be an object literal, buffer or string representing valid JSON.
-> **Please _note_ that** `exp` or any other claim is only set if the payload is an object literal. Buffer or string payloads are not checked for JSON validity.
-
-> If `payload` is not a buffer or a string, it will be coerced into a string using `JSON.stringify`.
-
-`secretOrPrivateKey` is a string (utf-8 encoded), buffer, object, or KeyObject containing either the secret for HMAC algorithms or the PEM
-encoded private key for RSA and ECDSA. In case of a private key with passphrase an object `{ key, passphrase }` can be used (based on [crypto documentation](https://nodejs.org/api/crypto.html#crypto_sign_sign_private_key_output_format)), in this case be sure you pass the `algorithm` option.
-When signing with RSA algorithms the minimum modulus length is 2048 except when the allowInsecureKeySizes option is set to true. Private keys below this size will be rejected with an error.
-
-`options`:
-
-* `algorithm` (default: `HS256`)
-* `expiresIn`: expressed in seconds or a string describing a time span [vercel/ms](https://github.com/vercel/ms).
- > Eg: `60`, `"2 days"`, `"10h"`, `"7d"`. A numeric value is interpreted as a seconds count. If you use a string be sure you provide the time units (days, hours, etc), otherwise milliseconds unit is used by default (`"120"` is equal to `"120ms"`).
-* `notBefore`: expressed in seconds or a string describing a time span [vercel/ms](https://github.com/vercel/ms).
- > Eg: `60`, `"2 days"`, `"10h"`, `"7d"`. A numeric value is interpreted as a seconds count. If you use a string be sure you provide the time units (days, hours, etc), otherwise milliseconds unit is used by default (`"120"` is equal to `"120ms"`).
-* `audience`
-* `issuer`
-* `jwtid`
-* `subject`
-* `noTimestamp`
-* `header`
-* `keyid`
-* `mutatePayload`: if true, the sign function will modify the payload object directly. This is useful if you need a raw reference to the payload after claims have been applied to it but before it has been encoded into a token.
-* `allowInsecureKeySizes`: if true allows private keys with a modulus below 2048 to be used for RSA
-* `allowInvalidAsymmetricKeyTypes`: if true, allows asymmetric keys which do not match the specified algorithm. This option is intended only for backwards compatability and should be avoided.
-
-
-
-> There are no default values for `expiresIn`, `notBefore`, `audience`, `subject`, `issuer`. These claims can also be provided in the payload directly with `exp`, `nbf`, `aud`, `sub` and `iss` respectively, but you **_can't_** include in both places.
-
-Remember that `exp`, `nbf` and `iat` are **NumericDate**, see related [Token Expiration (exp claim)](#token-expiration-exp-claim)
-
-
-The header can be customized via the `options.header` object.
-
-Generated jwts will include an `iat` (issued at) claim by default unless `noTimestamp` is specified. If `iat` is inserted in the payload, it will be used instead of the real timestamp for calculating other things like `exp` given a timespan in `options.expiresIn`.
-
-Synchronous Sign with default (HMAC SHA256)
-
-```js
-var jwt = require('jsonwebtoken');
-var token = jwt.sign({ foo: 'bar' }, 'shhhhh');
-```
-
-Synchronous Sign with RSA SHA256
-```js
-// sign with RSA SHA256
-var privateKey = fs.readFileSync('private.key');
-var token = jwt.sign({ foo: 'bar' }, privateKey, { algorithm: 'RS256' });
-```
-
-Sign asynchronously
-```js
-jwt.sign({ foo: 'bar' }, privateKey, { algorithm: 'RS256' }, function(err, token) {
- console.log(token);
-});
-```
-
-Backdate a jwt 30 seconds
-```js
-var older_token = jwt.sign({ foo: 'bar', iat: Math.floor(Date.now() / 1000) - 30 }, 'shhhhh');
-```
-
-#### Token Expiration (exp claim)
-
-The standard for JWT defines an `exp` claim for expiration. The expiration is represented as a **NumericDate**:
-
-> A JSON numeric value representing the number of seconds from 1970-01-01T00:00:00Z UTC until the specified UTC date/time, ignoring leap seconds. This is equivalent to the IEEE Std 1003.1, 2013 Edition [POSIX.1] definition "Seconds Since the Epoch", in which each day is accounted for by exactly 86400 seconds, other than that non-integer values can be represented. See RFC 3339 [RFC3339] for details regarding date/times in general and UTC in particular.
-
-This means that the `exp` field should contain the number of seconds since the epoch.
-
-Signing a token with 1 hour of expiration:
-
-```javascript
-jwt.sign({
- exp: Math.floor(Date.now() / 1000) + (60 * 60),
- data: 'foobar'
-}, 'secret');
-```
-
-Another way to generate a token like this with this library is:
-
-```javascript
-jwt.sign({
- data: 'foobar'
-}, 'secret', { expiresIn: 60 * 60 });
-
-//or even better:
-
-jwt.sign({
- data: 'foobar'
-}, 'secret', { expiresIn: '1h' });
-```
-
-### jwt.verify(token, secretOrPublicKey, [options, callback])
-
-(Asynchronous) If a callback is supplied, function acts asynchronously. The callback is called with the decoded payload if the signature is valid and optional expiration, audience, or issuer are valid. If not, it will be called with the error.
-
-(Synchronous) If a callback is not supplied, function acts synchronously. Returns the payload decoded if the signature is valid and optional expiration, audience, or issuer are valid. If not, it will throw the error.
-
-> __Warning:__ When the token comes from an untrusted source (e.g. user input or external requests), the returned decoded payload should be treated like any other user input; please make sure to sanitize and only work with properties that are expected
-
-`token` is the JsonWebToken string
-
-`secretOrPublicKey` is a string (utf-8 encoded), buffer, or KeyObject containing either the secret for HMAC algorithms, or the PEM
-encoded public key for RSA and ECDSA.
-If `jwt.verify` is called asynchronous, `secretOrPublicKey` can be a function that should fetch the secret or public key. See below for a detailed example
-
-As mentioned in [this comment](https://github.com/auth0/node-jsonwebtoken/issues/208#issuecomment-231861138), there are other libraries that expect base64 encoded secrets (random bytes encoded using base64), if that is your case you can pass `Buffer.from(secret, 'base64')`, by doing this the secret will be decoded using base64 and the token verification will use the original random bytes.
-
-`options`
-
-* `algorithms`: List of strings with the names of the allowed algorithms. For instance, `["HS256", "HS384"]`.
- > If not specified a defaults will be used based on the type of key provided
- > * secret - ['HS256', 'HS384', 'HS512']
- > * rsa - ['RS256', 'RS384', 'RS512']
- > * ec - ['ES256', 'ES384', 'ES512']
- > * default - ['RS256', 'RS384', 'RS512']
-* `audience`: if you want to check audience (`aud`), provide a value here. The audience can be checked against a string, a regular expression or a list of strings and/or regular expressions.
- > Eg: `"urn:foo"`, `/urn:f[o]{2}/`, `[/urn:f[o]{2}/, "urn:bar"]`
-* `complete`: return an object with the decoded `{ payload, header, signature }` instead of only the usual content of the payload.
-* `issuer` (optional): string or array of strings of valid values for the `iss` field.
-* `jwtid` (optional): if you want to check JWT ID (`jti`), provide a string value here.
-* `ignoreExpiration`: if `true` do not validate the expiration of the token.
-* `ignoreNotBefore`...
-* `subject`: if you want to check subject (`sub`), provide a value here
-* `clockTolerance`: number of seconds to tolerate when checking the `nbf` and `exp` claims, to deal with small clock differences among different servers
-* `maxAge`: the maximum allowed age for tokens to still be valid. It is expressed in seconds or a string describing a time span [vercel/ms](https://github.com/vercel/ms).
- > Eg: `1000`, `"2 days"`, `"10h"`, `"7d"`. A numeric value is interpreted as a seconds count. If you use a string be sure you provide the time units (days, hours, etc), otherwise milliseconds unit is used by default (`"120"` is equal to `"120ms"`).
-* `clockTimestamp`: the time in seconds that should be used as the current time for all necessary comparisons.
-* `nonce`: if you want to check `nonce` claim, provide a string value here. It is used on Open ID for the ID Tokens. ([Open ID implementation notes](https://openid.net/specs/openid-connect-core-1_0.html#NonceNotes))
-* `allowInvalidAsymmetricKeyTypes`: if true, allows asymmetric keys which do not match the specified algorithm. This option is intended only for backwards compatability and should be avoided.
-
-```js
-// verify a token symmetric - synchronous
-var decoded = jwt.verify(token, 'shhhhh');
-console.log(decoded.foo) // bar
-
-// verify a token symmetric
-jwt.verify(token, 'shhhhh', function(err, decoded) {
- console.log(decoded.foo) // bar
-});
-
-// invalid token - synchronous
-try {
- var decoded = jwt.verify(token, 'wrong-secret');
-} catch(err) {
- // err
-}
-
-// invalid token
-jwt.verify(token, 'wrong-secret', function(err, decoded) {
- // err
- // decoded undefined
-});
-
-// verify a token asymmetric
-var cert = fs.readFileSync('public.pem'); // get public key
-jwt.verify(token, cert, function(err, decoded) {
- console.log(decoded.foo) // bar
-});
-
-// verify audience
-var cert = fs.readFileSync('public.pem'); // get public key
-jwt.verify(token, cert, { audience: 'urn:foo' }, function(err, decoded) {
- // if audience mismatch, err == invalid audience
-});
-
-// verify issuer
-var cert = fs.readFileSync('public.pem'); // get public key
-jwt.verify(token, cert, { audience: 'urn:foo', issuer: 'urn:issuer' }, function(err, decoded) {
- // if issuer mismatch, err == invalid issuer
-});
-
-// verify jwt id
-var cert = fs.readFileSync('public.pem'); // get public key
-jwt.verify(token, cert, { audience: 'urn:foo', issuer: 'urn:issuer', jwtid: 'jwtid' }, function(err, decoded) {
- // if jwt id mismatch, err == invalid jwt id
-});
-
-// verify subject
-var cert = fs.readFileSync('public.pem'); // get public key
-jwt.verify(token, cert, { audience: 'urn:foo', issuer: 'urn:issuer', jwtid: 'jwtid', subject: 'subject' }, function(err, decoded) {
- // if subject mismatch, err == invalid subject
-});
-
-// alg mismatch
-var cert = fs.readFileSync('public.pem'); // get public key
-jwt.verify(token, cert, { algorithms: ['RS256'] }, function (err, payload) {
- // if token alg != RS256, err == invalid signature
-});
-
-// Verify using getKey callback
-// Example uses https://github.com/auth0/node-jwks-rsa as a way to fetch the keys.
-var jwksClient = require('jwks-rsa');
-var client = jwksClient({
- jwksUri: 'https://sandrino.auth0.com/.well-known/jwks.json'
-});
-function getKey(header, callback){
- client.getSigningKey(header.kid, function(err, key) {
- var signingKey = key.publicKey || key.rsaPublicKey;
- callback(null, signingKey);
- });
-}
-
-jwt.verify(token, getKey, options, function(err, decoded) {
- console.log(decoded.foo) // bar
-});
-
-```
-
-<details>
-<summary><em></em>Need to peek into a JWT without verifying it? (Click to expand)</summary>
-
-### jwt.decode(token [, options])
-
-(Synchronous) Returns the decoded payload without verifying if the signature is valid.
-
-> __Warning:__ This will __not__ verify whether the signature is valid. You should __not__ use this for untrusted messages. You most likely want to use `jwt.verify` instead.
-
-> __Warning:__ When the token comes from an untrusted source (e.g. user input or external request), the returned decoded payload should be treated like any other user input; please make sure to sanitize and only work with properties that are expected
-
-
-`token` is the JsonWebToken string
-
-`options`:
-
-* `json`: force JSON.parse on the payload even if the header doesn't contain `"typ":"JWT"`.
-* `complete`: return an object with the decoded payload and header.
-
-Example
-
-```js
-// get the decoded payload ignoring signature, no secretOrPrivateKey needed
-var decoded = jwt.decode(token);
-
-// get the decoded payload and header
-var decoded = jwt.decode(token, {complete: true});
-console.log(decoded.header);
-console.log(decoded.payload)
-```
-
-</details>
-
-## Errors & Codes
-Possible thrown errors during verification.
-Error is the first argument of the verification callback.
-
-### TokenExpiredError
-
-Thrown error if the token is expired.
-
-Error object:
-
-* name: 'TokenExpiredError'
-* message: 'jwt expired'
-* expiredAt: [ExpDate]
-
-```js
-jwt.verify(token, 'shhhhh', function(err, decoded) {
- if (err) {
- /*
- err = {
- name: 'TokenExpiredError',
- message: 'jwt expired',
- expiredAt: 1408621000
- }
- */
- }
-});
-```
-
-### JsonWebTokenError
-Error object:
-
-* name: 'JsonWebTokenError'
-* message:
- * 'invalid token' - the header or payload could not be parsed
- * 'jwt malformed' - the token does not have three components (delimited by a `.`)
- * 'jwt signature is required'
- * 'invalid signature'
- * 'jwt audience invalid. expected: [OPTIONS AUDIENCE]'
- * 'jwt issuer invalid. expected: [OPTIONS ISSUER]'
- * 'jwt id invalid. expected: [OPTIONS JWT ID]'
- * 'jwt subject invalid. expected: [OPTIONS SUBJECT]'
-
-```js
-jwt.verify(token, 'shhhhh', function(err, decoded) {
- if (err) {
- /*
- err = {
- name: 'JsonWebTokenError',
- message: 'jwt malformed'
- }
- */
- }
-});
-```
-
-### NotBeforeError
-Thrown if current time is before the nbf claim.
-
-Error object:
-
-* name: 'NotBeforeError'
-* message: 'jwt not active'
-* date: 2018-10-04T16:10:44.000Z
-
-```js
-jwt.verify(token, 'shhhhh', function(err, decoded) {
- if (err) {
- /*
- err = {
- name: 'NotBeforeError',
- message: 'jwt not active',
- date: 2018-10-04T16:10:44.000Z
- }
- */
- }
-});
-```
-
-
-## Algorithms supported
-
-Array of supported algorithms. The following algorithms are currently supported.
-
-| alg Parameter Value | Digital Signature or MAC Algorithm |
-|---------------------|------------------------------------------------------------------------|
-| HS256 | HMAC using SHA-256 hash algorithm |
-| HS384 | HMAC using SHA-384 hash algorithm |
-| HS512 | HMAC using SHA-512 hash algorithm |
-| RS256 | RSASSA-PKCS1-v1_5 using SHA-256 hash algorithm |
-| RS384 | RSASSA-PKCS1-v1_5 using SHA-384 hash algorithm |
-| RS512 | RSASSA-PKCS1-v1_5 using SHA-512 hash algorithm |
-| PS256 | RSASSA-PSS using SHA-256 hash algorithm (only node ^6.12.0 OR >=8.0.0) |
-| PS384 | RSASSA-PSS using SHA-384 hash algorithm (only node ^6.12.0 OR >=8.0.0) |
-| PS512 | RSASSA-PSS using SHA-512 hash algorithm (only node ^6.12.0 OR >=8.0.0) |
-| ES256 | ECDSA using P-256 curve and SHA-256 hash algorithm |
-| ES384 | ECDSA using P-384 curve and SHA-384 hash algorithm |
-| ES512 | ECDSA using P-521 curve and SHA-512 hash algorithm |
-| none | No digital signature or MAC value included |
-
-## Refreshing JWTs
-
-First of all, we recommend you to think carefully if auto-refreshing a JWT will not introduce any vulnerability in your system.
-
-We are not comfortable including this as part of the library, however, you can take a look at [this example](https://gist.github.com/ziluvatar/a3feb505c4c0ec37059054537b38fc48) to show how this could be accomplished.
-Apart from that example there are [an issue](https://github.com/auth0/node-jsonwebtoken/issues/122) and [a pull request](https://github.com/auth0/node-jsonwebtoken/pull/172) to get more knowledge about this topic.
-
-# TODO
-
-* X.509 certificate chain is not checked
-
-## Issue Reporting
-
-If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/whitehat) details the procedure for disclosing security issues.
-
-## Author
-
-[Auth0](https://auth0.com)
-
-## License
-
-This project is licensed under the MIT license. See the [LICENSE](LICENSE) file for more info.
diff --git a/backend/node_modules/jsonwebtoken/decode.js b/backend/node_modules/jsonwebtoken/decode.js
deleted file mode 100644
index 8fe1adc..0000000
--- a/backend/node_modules/jsonwebtoken/decode.js
+++ /dev/null
@@ -1,30 +0,0 @@
-var jws = require('jws');
-
-module.exports = function (jwt, options) {
- options = options || {};
- var decoded = jws.decode(jwt, options);
- if (!decoded) { return null; }
- var payload = decoded.payload;
-
- //try parse the payload
- if(typeof payload === 'string') {
- try {
- var obj = JSON.parse(payload);
- if(obj !== null && typeof obj === 'object') {
- payload = obj;
- }
- } catch (e) { }
- }
-
- //return header if `complete` option is enabled. header includes claims
- //such as `kid` and `alg` used to select the key within a JWKS needed to
- //verify the signature
- if (options.complete === true) {
- return {
- header: decoded.header,
- payload: payload,
- signature: decoded.signature
- };
- }
- return payload;
-};
diff --git a/backend/node_modules/jsonwebtoken/index.js b/backend/node_modules/jsonwebtoken/index.js
deleted file mode 100644
index 161eb2d..0000000
--- a/backend/node_modules/jsonwebtoken/index.js
+++ /dev/null
@@ -1,8 +0,0 @@
-module.exports = {
- decode: require('./decode'),
- verify: require('./verify'),
- sign: require('./sign'),
- JsonWebTokenError: require('./lib/JsonWebTokenError'),
- NotBeforeError: require('./lib/NotBeforeError'),
- TokenExpiredError: require('./lib/TokenExpiredError'),
-};
diff --git a/backend/node_modules/jsonwebtoken/lib/JsonWebTokenError.js b/backend/node_modules/jsonwebtoken/lib/JsonWebTokenError.js
deleted file mode 100644
index e068222..0000000
--- a/backend/node_modules/jsonwebtoken/lib/JsonWebTokenError.js
+++ /dev/null
@@ -1,14 +0,0 @@
-var JsonWebTokenError = function (message, error) {
- Error.call(this, message);
- if(Error.captureStackTrace) {
- Error.captureStackTrace(this, this.constructor);
- }
- this.name = 'JsonWebTokenError';
- this.message = message;
- if (error) this.inner = error;
-};
-
-JsonWebTokenError.prototype = Object.create(Error.prototype);
-JsonWebTokenError.prototype.constructor = JsonWebTokenError;
-
-module.exports = JsonWebTokenError;
diff --git a/backend/node_modules/jsonwebtoken/lib/NotBeforeError.js b/backend/node_modules/jsonwebtoken/lib/NotBeforeError.js
deleted file mode 100644
index 7b30084..0000000
--- a/backend/node_modules/jsonwebtoken/lib/NotBeforeError.js
+++ /dev/null
@@ -1,13 +0,0 @@
-var JsonWebTokenError = require('./JsonWebTokenError');
-
-var NotBeforeError = function (message, date) {
- JsonWebTokenError.call(this, message);
- this.name = 'NotBeforeError';
- this.date = date;
-};
-
-NotBeforeError.prototype = Object.create(JsonWebTokenError.prototype);
-
-NotBeforeError.prototype.constructor = NotBeforeError;
-
-module.exports = NotBeforeError; \ No newline at end of file
diff --git a/backend/node_modules/jsonwebtoken/lib/TokenExpiredError.js b/backend/node_modules/jsonwebtoken/lib/TokenExpiredError.js
deleted file mode 100644
index abb704f..0000000
--- a/backend/node_modules/jsonwebtoken/lib/TokenExpiredError.js
+++ /dev/null
@@ -1,13 +0,0 @@
-var JsonWebTokenError = require('./JsonWebTokenError');
-
-var TokenExpiredError = function (message, expiredAt) {
- JsonWebTokenError.call(this, message);
- this.name = 'TokenExpiredError';
- this.expiredAt = expiredAt;
-};
-
-TokenExpiredError.prototype = Object.create(JsonWebTokenError.prototype);
-
-TokenExpiredError.prototype.constructor = TokenExpiredError;
-
-module.exports = TokenExpiredError; \ No newline at end of file
diff --git a/backend/node_modules/jsonwebtoken/lib/asymmetricKeyDetailsSupported.js b/backend/node_modules/jsonwebtoken/lib/asymmetricKeyDetailsSupported.js
deleted file mode 100644
index a6ede56..0000000
--- a/backend/node_modules/jsonwebtoken/lib/asymmetricKeyDetailsSupported.js
+++ /dev/null
@@ -1,3 +0,0 @@
-const semver = require('semver');
-
-module.exports = semver.satisfies(process.version, '>=15.7.0');
diff --git a/backend/node_modules/jsonwebtoken/lib/psSupported.js b/backend/node_modules/jsonwebtoken/lib/psSupported.js
deleted file mode 100644
index 8c04144..0000000
--- a/backend/node_modules/jsonwebtoken/lib/psSupported.js
+++ /dev/null
@@ -1,3 +0,0 @@
-var semver = require('semver');
-
-module.exports = semver.satisfies(process.version, '^6.12.0 || >=8.0.0');
diff --git a/backend/node_modules/jsonwebtoken/lib/rsaPssKeyDetailsSupported.js b/backend/node_modules/jsonwebtoken/lib/rsaPssKeyDetailsSupported.js
deleted file mode 100644
index 7fcf368..0000000
--- a/backend/node_modules/jsonwebtoken/lib/rsaPssKeyDetailsSupported.js
+++ /dev/null
@@ -1,3 +0,0 @@
-const semver = require('semver');
-
-module.exports = semver.satisfies(process.version, '>=16.9.0');
diff --git a/backend/node_modules/jsonwebtoken/lib/timespan.js b/backend/node_modules/jsonwebtoken/lib/timespan.js
deleted file mode 100644
index e509869..0000000
--- a/backend/node_modules/jsonwebtoken/lib/timespan.js
+++ /dev/null
@@ -1,18 +0,0 @@
-var ms = require('ms');
-
-module.exports = function (time, iat) {
- var timestamp = iat || Math.floor(Date.now() / 1000);
-
- if (typeof time === 'string') {
- var milliseconds = ms(time);
- if (typeof milliseconds === 'undefined') {
- return;
- }
- return Math.floor(timestamp + milliseconds / 1000);
- } else if (typeof time === 'number') {
- return timestamp + time;
- } else {
- return;
- }
-
-}; \ No newline at end of file
diff --git a/backend/node_modules/jsonwebtoken/lib/validateAsymmetricKey.js b/backend/node_modules/jsonwebtoken/lib/validateAsymmetricKey.js
deleted file mode 100644
index c10340b..0000000
--- a/backend/node_modules/jsonwebtoken/lib/validateAsymmetricKey.js
+++ /dev/null
@@ -1,66 +0,0 @@
-const ASYMMETRIC_KEY_DETAILS_SUPPORTED = require('./asymmetricKeyDetailsSupported');
-const RSA_PSS_KEY_DETAILS_SUPPORTED = require('./rsaPssKeyDetailsSupported');
-
-const allowedAlgorithmsForKeys = {
- 'ec': ['ES256', 'ES384', 'ES512'],
- 'rsa': ['RS256', 'PS256', 'RS384', 'PS384', 'RS512', 'PS512'],
- 'rsa-pss': ['PS256', 'PS384', 'PS512']
-};
-
-const allowedCurves = {
- ES256: 'prime256v1',
- ES384: 'secp384r1',
- ES512: 'secp521r1',
-};
-
-module.exports = function(algorithm, key) {
- if (!algorithm || !key) return;
-
- const keyType = key.asymmetricKeyType;
- if (!keyType) return;
-
- const allowedAlgorithms = allowedAlgorithmsForKeys[keyType];
-
- if (!allowedAlgorithms) {
- throw new Error(`Unknown key type "${keyType}".`);
- }
-
- if (!allowedAlgorithms.includes(algorithm)) {
- throw new Error(`"alg" parameter for "${keyType}" key type must be one of: ${allowedAlgorithms.join(', ')}.`)
- }
-
- /*
- * Ignore the next block from test coverage because it gets executed
- * conditionally depending on the Node version. Not ignoring it would
- * prevent us from reaching the target % of coverage for versions of
- * Node under 15.7.0.
- */
- /* istanbul ignore next */
- if (ASYMMETRIC_KEY_DETAILS_SUPPORTED) {
- switch (keyType) {
- case 'ec':
- const keyCurve = key.asymmetricKeyDetails.namedCurve;
- const allowedCurve = allowedCurves[algorithm];
-
- if (keyCurve !== allowedCurve) {
- throw new Error(`"alg" parameter "${algorithm}" requires curve "${allowedCurve}".`);
- }
- break;
-
- case 'rsa-pss':
- if (RSA_PSS_KEY_DETAILS_SUPPORTED) {
- const length = parseInt(algorithm.slice(-3), 10);
- const { hashAlgorithm, mgf1HashAlgorithm, saltLength } = key.asymmetricKeyDetails;
-
- if (hashAlgorithm !== `sha${length}` || mgf1HashAlgorithm !== hashAlgorithm) {
- throw new Error(`Invalid key for this operation, its RSA-PSS parameters do not meet the requirements of "alg" ${algorithm}.`);
- }
-
- if (saltLength !== undefined && saltLength > length >> 3) {
- throw new Error(`Invalid key for this operation, its RSA-PSS parameter saltLength does not meet the requirements of "alg" ${algorithm}.`)
- }
- }
- break;
- }
- }
-}
diff --git a/backend/node_modules/jsonwebtoken/node_modules/.bin/semver b/backend/node_modules/jsonwebtoken/node_modules/.bin/semver
deleted file mode 120000
index c3277a7..0000000
--- a/backend/node_modules/jsonwebtoken/node_modules/.bin/semver
+++ /dev/null
@@ -1 +0,0 @@
-../../../semver/bin/semver.js \ No newline at end of file
diff --git a/backend/node_modules/jsonwebtoken/package.json b/backend/node_modules/jsonwebtoken/package.json
deleted file mode 100644
index 81f78da..0000000
--- a/backend/node_modules/jsonwebtoken/package.json
+++ /dev/null
@@ -1,71 +0,0 @@
-{
- "name": "jsonwebtoken",
- "version": "9.0.2",
- "description": "JSON Web Token implementation (symmetric and asymmetric)",
- "main": "index.js",
- "nyc": {
- "check-coverage": true,
- "lines": 95,
- "statements": 95,
- "functions": 100,
- "branches": 95,
- "exclude": [
- "./test/**"
- ],
- "reporter": [
- "json",
- "lcov",
- "text-summary"
- ]
- },
- "scripts": {
- "lint": "eslint .",
- "coverage": "nyc mocha --use_strict",
- "test": "npm run lint && npm run coverage && cost-of-modules"
- },
- "repository": {
- "type": "git",
- "url": "https://github.com/auth0/node-jsonwebtoken"
- },
- "keywords": [
- "jwt"
- ],
- "author": "auth0",
- "license": "MIT",
- "bugs": {
- "url": "https://github.com/auth0/node-jsonwebtoken/issues"
- },
- "dependencies": {
- "jws": "^3.2.2",
- "lodash.includes": "^4.3.0",
- "lodash.isboolean": "^3.0.3",
- "lodash.isinteger": "^4.0.4",
- "lodash.isnumber": "^3.0.3",
- "lodash.isplainobject": "^4.0.6",
- "lodash.isstring": "^4.0.1",
- "lodash.once": "^4.0.0",
- "ms": "^2.1.1",
- "semver": "^7.5.4"
- },
- "devDependencies": {
- "atob": "^2.1.2",
- "chai": "^4.1.2",
- "conventional-changelog": "~1.1.0",
- "cost-of-modules": "^1.0.1",
- "eslint": "^4.19.1",
- "mocha": "^5.2.0",
- "nsp": "^2.6.2",
- "nyc": "^11.9.0",
- "sinon": "^6.0.0"
- },
- "engines": {
- "npm": ">=6",
- "node": ">=12"
- },
- "files": [
- "lib",
- "decode.js",
- "sign.js",
- "verify.js"
- ]
-}
diff --git a/backend/node_modules/jsonwebtoken/sign.js b/backend/node_modules/jsonwebtoken/sign.js
deleted file mode 100644
index 82bf526..0000000
--- a/backend/node_modules/jsonwebtoken/sign.js
+++ /dev/null
@@ -1,253 +0,0 @@
-const timespan = require('./lib/timespan');
-const PS_SUPPORTED = require('./lib/psSupported');
-const validateAsymmetricKey = require('./lib/validateAsymmetricKey');
-const jws = require('jws');
-const includes = require('lodash.includes');
-const isBoolean = require('lodash.isboolean');
-const isInteger = require('lodash.isinteger');
-const isNumber = require('lodash.isnumber');
-const isPlainObject = require('lodash.isplainobject');
-const isString = require('lodash.isstring');
-const once = require('lodash.once');
-const { KeyObject, createSecretKey, createPrivateKey } = require('crypto')
-
-const SUPPORTED_ALGS = ['RS256', 'RS384', 'RS512', 'ES256', 'ES384', 'ES512', 'HS256', 'HS384', 'HS512', 'none'];
-if (PS_SUPPORTED) {
- SUPPORTED_ALGS.splice(3, 0, 'PS256', 'PS384', 'PS512');
-}
-
-const sign_options_schema = {
- expiresIn: { isValid: function(value) { return isInteger(value) || (isString(value) && value); }, message: '"expiresIn" should be a number of seconds or string representing a timespan' },
- notBefore: { isValid: function(value) { return isInteger(value) || (isString(value) && value); }, message: '"notBefore" should be a number of seconds or string representing a timespan' },
- audience: { isValid: function(value) { return isString(value) || Array.isArray(value); }, message: '"audience" must be a string or array' },
- algorithm: { isValid: includes.bind(null, SUPPORTED_ALGS), message: '"algorithm" must be a valid string enum value' },
- header: { isValid: isPlainObject, message: '"header" must be an object' },
- encoding: { isValid: isString, message: '"encoding" must be a string' },
- issuer: { isValid: isString, message: '"issuer" must be a string' },
- subject: { isValid: isString, message: '"subject" must be a string' },
- jwtid: { isValid: isString, message: '"jwtid" must be a string' },
- noTimestamp: { isValid: isBoolean, message: '"noTimestamp" must be a boolean' },
- keyid: { isValid: isString, message: '"keyid" must be a string' },
- mutatePayload: { isValid: isBoolean, message: '"mutatePayload" must be a boolean' },
- allowInsecureKeySizes: { isValid: isBoolean, message: '"allowInsecureKeySizes" must be a boolean'},
- allowInvalidAsymmetricKeyTypes: { isValid: isBoolean, message: '"allowInvalidAsymmetricKeyTypes" must be a boolean'}
-};
-
-const registered_claims_schema = {
- iat: { isValid: isNumber, message: '"iat" should be a number of seconds' },
- exp: { isValid: isNumber, message: '"exp" should be a number of seconds' },
- nbf: { isValid: isNumber, message: '"nbf" should be a number of seconds' }
-};
-
-function validate(schema, allowUnknown, object, parameterName) {
- if (!isPlainObject(object)) {
- throw new Error('Expected "' + parameterName + '" to be a plain object.');
- }
- Object.keys(object)
- .forEach(function(key) {
- const validator = schema[key];
- if (!validator) {
- if (!allowUnknown) {
- throw new Error('"' + key + '" is not allowed in "' + parameterName + '"');
- }
- return;
- }
- if (!validator.isValid(object[key])) {
- throw new Error(validator.message);
- }
- });
-}
-
-function validateOptions(options) {
- return validate(sign_options_schema, false, options, 'options');
-}
-
-function validatePayload(payload) {
- return validate(registered_claims_schema, true, payload, 'payload');
-}
-
-const options_to_payload = {
- 'audience': 'aud',
- 'issuer': 'iss',
- 'subject': 'sub',
- 'jwtid': 'jti'
-};
-
-const options_for_objects = [
- 'expiresIn',
- 'notBefore',
- 'noTimestamp',
- 'audience',
- 'issuer',
- 'subject',
- 'jwtid',
-];
-
-module.exports = function (payload, secretOrPrivateKey, options, callback) {
- if (typeof options === 'function') {
- callback = options;
- options = {};
- } else {
- options = options || {};
- }
-
- const isObjectPayload = typeof payload === 'object' &&
- !Buffer.isBuffer(payload);
-
- const header = Object.assign({
- alg: options.algorithm || 'HS256',
- typ: isObjectPayload ? 'JWT' : undefined,
- kid: options.keyid
- }, options.header);
-
- function failure(err) {
- if (callback) {
- return callback(err);
- }
- throw err;
- }
-
- if (!secretOrPrivateKey && options.algorithm !== 'none') {
- return failure(new Error('secretOrPrivateKey must have a value'));
- }
-
- if (secretOrPrivateKey != null && !(secretOrPrivateKey instanceof KeyObject)) {
- try {
- secretOrPrivateKey = createPrivateKey(secretOrPrivateKey)
- } catch (_) {
- try {
- secretOrPrivateKey = createSecretKey(typeof secretOrPrivateKey === 'string' ? Buffer.from(secretOrPrivateKey) : secretOrPrivateKey)
- } catch (_) {
- return failure(new Error('secretOrPrivateKey is not valid key material'));
- }
- }
- }
-
- if (header.alg.startsWith('HS') && secretOrPrivateKey.type !== 'secret') {
- return failure(new Error((`secretOrPrivateKey must be a symmetric key when using ${header.alg}`)))
- } else if (/^(?:RS|PS|ES)/.test(header.alg)) {
- if (secretOrPrivateKey.type !== 'private') {
- return failure(new Error((`secretOrPrivateKey must be an asymmetric key when using ${header.alg}`)))
- }
- if (!options.allowInsecureKeySizes &&
- !header.alg.startsWith('ES') &&
- secretOrPrivateKey.asymmetricKeyDetails !== undefined && //KeyObject.asymmetricKeyDetails is supported in Node 15+
- secretOrPrivateKey.asymmetricKeyDetails.modulusLength < 2048) {
- return failure(new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${header.alg}`));
- }
- }
-
- if (typeof payload === 'undefined') {
- return failure(new Error('payload is required'));
- } else if (isObjectPayload) {
- try {
- validatePayload(payload);
- }
- catch (error) {
- return failure(error);
- }
- if (!options.mutatePayload) {
- payload = Object.assign({},payload);
- }
- } else {
- const invalid_options = options_for_objects.filter(function (opt) {
- return typeof options[opt] !== 'undefined';
- });
-
- if (invalid_options.length > 0) {
- return failure(new Error('invalid ' + invalid_options.join(',') + ' option for ' + (typeof payload ) + ' payload'));
- }
- }
-
- if (typeof payload.exp !== 'undefined' && typeof options.expiresIn !== 'undefined') {
- return failure(new Error('Bad "options.expiresIn" option the payload already has an "exp" property.'));
- }
-
- if (typeof payload.nbf !== 'undefined' && typeof options.notBefore !== 'undefined') {
- return failure(new Error('Bad "options.notBefore" option the payload already has an "nbf" property.'));
- }
-
- try {
- validateOptions(options);
- }
- catch (error) {
- return failure(error);
- }
-
- if (!options.allowInvalidAsymmetricKeyTypes) {
- try {
- validateAsymmetricKey(header.alg, secretOrPrivateKey);
- } catch (error) {
- return failure(error);
- }
- }
-
- const timestamp = payload.iat || Math.floor(Date.now() / 1000);
-
- if (options.noTimestamp) {
- delete payload.iat;
- } else if (isObjectPayload) {
- payload.iat = timestamp;
- }
-
- if (typeof options.notBefore !== 'undefined') {
- try {
- payload.nbf = timespan(options.notBefore, timestamp);
- }
- catch (err) {
- return failure(err);
- }
- if (typeof payload.nbf === 'undefined') {
- return failure(new Error('"notBefore" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));
- }
- }
-
- if (typeof options.expiresIn !== 'undefined' && typeof payload === 'object') {
- try {
- payload.exp = timespan(options.expiresIn, timestamp);
- }
- catch (err) {
- return failure(err);
- }
- if (typeof payload.exp === 'undefined') {
- return failure(new Error('"expiresIn" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));
- }
- }
-
- Object.keys(options_to_payload).forEach(function (key) {
- const claim = options_to_payload[key];
- if (typeof options[key] !== 'undefined') {
- if (typeof payload[claim] !== 'undefined') {
- return failure(new Error('Bad "options.' + key + '" option. The payload already has an "' + claim + '" property.'));
- }
- payload[claim] = options[key];
- }
- });
-
- const encoding = options.encoding || 'utf8';
-
- if (typeof callback === 'function') {
- callback = callback && once(callback);
-
- jws.createSign({
- header: header,
- privateKey: secretOrPrivateKey,
- payload: payload,
- encoding: encoding
- }).once('error', callback)
- .once('done', function (signature) {
- // TODO: Remove in favor of the modulus length check before signing once node 15+ is the minimum supported version
- if(!options.allowInsecureKeySizes && /^(?:RS|PS)/.test(header.alg) && signature.length < 256) {
- return callback(new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${header.alg}`))
- }
- callback(null, signature);
- });
- } else {
- let signature = jws.sign({header: header, payload: payload, secret: secretOrPrivateKey, encoding: encoding});
- // TODO: Remove in favor of the modulus length check before signing once node 15+ is the minimum supported version
- if(!options.allowInsecureKeySizes && /^(?:RS|PS)/.test(header.alg) && signature.length < 256) {
- throw new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${header.alg}`)
- }
- return signature
- }
-};
diff --git a/backend/node_modules/jsonwebtoken/verify.js b/backend/node_modules/jsonwebtoken/verify.js
deleted file mode 100644
index cdbfdc4..0000000
--- a/backend/node_modules/jsonwebtoken/verify.js
+++ /dev/null
@@ -1,263 +0,0 @@
-const JsonWebTokenError = require('./lib/JsonWebTokenError');
-const NotBeforeError = require('./lib/NotBeforeError');
-const TokenExpiredError = require('./lib/TokenExpiredError');
-const decode = require('./decode');
-const timespan = require('./lib/timespan');
-const validateAsymmetricKey = require('./lib/validateAsymmetricKey');
-const PS_SUPPORTED = require('./lib/psSupported');
-const jws = require('jws');
-const {KeyObject, createSecretKey, createPublicKey} = require("crypto");
-
-const PUB_KEY_ALGS = ['RS256', 'RS384', 'RS512'];
-const EC_KEY_ALGS = ['ES256', 'ES384', 'ES512'];
-const RSA_KEY_ALGS = ['RS256', 'RS384', 'RS512'];
-const HS_ALGS = ['HS256', 'HS384', 'HS512'];
-
-if (PS_SUPPORTED) {
- PUB_KEY_ALGS.splice(PUB_KEY_ALGS.length, 0, 'PS256', 'PS384', 'PS512');
- RSA_KEY_ALGS.splice(RSA_KEY_ALGS.length, 0, 'PS256', 'PS384', 'PS512');
-}
-
-module.exports = function (jwtString, secretOrPublicKey, options, callback) {
- if ((typeof options === 'function') && !callback) {
- callback = options;
- options = {};
- }
-
- if (!options) {
- options = {};
- }
-
- //clone this object since we are going to mutate it.
- options = Object.assign({}, options);
-
- let done;
-
- if (callback) {
- done = callback;
- } else {
- done = function(err, data) {
- if (err) throw err;
- return data;
- };
- }
-
- if (options.clockTimestamp && typeof options.clockTimestamp !== 'number') {
- return done(new JsonWebTokenError('clockTimestamp must be a number'));
- }
-
- if (options.nonce !== undefined && (typeof options.nonce !== 'string' || options.nonce.trim() === '')) {
- return done(new JsonWebTokenError('nonce must be a non-empty string'));
- }
-
- if (options.allowInvalidAsymmetricKeyTypes !== undefined && typeof options.allowInvalidAsymmetricKeyTypes !== 'boolean') {
- return done(new JsonWebTokenError('allowInvalidAsymmetricKeyTypes must be a boolean'));
- }
-
- const clockTimestamp = options.clockTimestamp || Math.floor(Date.now() / 1000);
-
- if (!jwtString){
- return done(new JsonWebTokenError('jwt must be provided'));
- }
-
- if (typeof jwtString !== 'string') {
- return done(new JsonWebTokenError('jwt must be a string'));
- }
-
- const parts = jwtString.split('.');
-
- if (parts.length !== 3){
- return done(new JsonWebTokenError('jwt malformed'));
- }
-
- let decodedToken;
-
- try {
- decodedToken = decode(jwtString, { complete: true });
- } catch(err) {
- return done(err);
- }
-
- if (!decodedToken) {
- return done(new JsonWebTokenError('invalid token'));
- }
-
- const header = decodedToken.header;
- let getSecret;
-
- if(typeof secretOrPublicKey === 'function') {
- if(!callback) {
- return done(new JsonWebTokenError('verify must be called asynchronous if secret or public key is provided as a callback'));
- }
-
- getSecret = secretOrPublicKey;
- }
- else {
- getSecret = function(header, secretCallback) {
- return secretCallback(null, secretOrPublicKey);
- };
- }
-
- return getSecret(header, function(err, secretOrPublicKey) {
- if(err) {
- return done(new JsonWebTokenError('error in secret or public key callback: ' + err.message));
- }
-
- const hasSignature = parts[2].trim() !== '';
-
- if (!hasSignature && secretOrPublicKey){
- return done(new JsonWebTokenError('jwt signature is required'));
- }
-
- if (hasSignature && !secretOrPublicKey) {
- return done(new JsonWebTokenError('secret or public key must be provided'));
- }
-
- if (!hasSignature && !options.algorithms) {
- return done(new JsonWebTokenError('please specify "none" in "algorithms" to verify unsigned tokens'));
- }
-
- if (secretOrPublicKey != null && !(secretOrPublicKey instanceof KeyObject)) {
- try {
- secretOrPublicKey = createPublicKey(secretOrPublicKey);
- } catch (_) {
- try {
- secretOrPublicKey = createSecretKey(typeof secretOrPublicKey === 'string' ? Buffer.from(secretOrPublicKey) : secretOrPublicKey);
- } catch (_) {
- return done(new JsonWebTokenError('secretOrPublicKey is not valid key material'))
- }
- }
- }
-
- if (!options.algorithms) {
- if (secretOrPublicKey.type === 'secret') {
- options.algorithms = HS_ALGS;
- } else if (['rsa', 'rsa-pss'].includes(secretOrPublicKey.asymmetricKeyType)) {
- options.algorithms = RSA_KEY_ALGS
- } else if (secretOrPublicKey.asymmetricKeyType === 'ec') {
- options.algorithms = EC_KEY_ALGS
- } else {
- options.algorithms = PUB_KEY_ALGS
- }
- }
-
- if (options.algorithms.indexOf(decodedToken.header.alg) === -1) {
- return done(new JsonWebTokenError('invalid algorithm'));
- }
-
- if (header.alg.startsWith('HS') && secretOrPublicKey.type !== 'secret') {
- return done(new JsonWebTokenError((`secretOrPublicKey must be a symmetric key when using ${header.alg}`)))
- } else if (/^(?:RS|PS|ES)/.test(header.alg) && secretOrPublicKey.type !== 'public') {
- return done(new JsonWebTokenError((`secretOrPublicKey must be an asymmetric key when using ${header.alg}`)))
- }
-
- if (!options.allowInvalidAsymmetricKeyTypes) {
- try {
- validateAsymmetricKey(header.alg, secretOrPublicKey);
- } catch (e) {
- return done(e);
- }
- }
-
- let valid;
-
- try {
- valid = jws.verify(jwtString, decodedToken.header.alg, secretOrPublicKey);
- } catch (e) {
- return done(e);
- }
-
- if (!valid) {
- return done(new JsonWebTokenError('invalid signature'));
- }
-
- const payload = decodedToken.payload;
-
- if (typeof payload.nbf !== 'undefined' && !options.ignoreNotBefore) {
- if (typeof payload.nbf !== 'number') {
- return done(new JsonWebTokenError('invalid nbf value'));
- }
- if (payload.nbf > clockTimestamp + (options.clockTolerance || 0)) {
- return done(new NotBeforeError('jwt not active', new Date(payload.nbf * 1000)));
- }
- }
-
- if (typeof payload.exp !== 'undefined' && !options.ignoreExpiration) {
- if (typeof payload.exp !== 'number') {
- return done(new JsonWebTokenError('invalid exp value'));
- }
- if (clockTimestamp >= payload.exp + (options.clockTolerance || 0)) {
- return done(new TokenExpiredError('jwt expired', new Date(payload.exp * 1000)));
- }
- }
-
- if (options.audience) {
- const audiences = Array.isArray(options.audience) ? options.audience : [options.audience];
- const target = Array.isArray(payload.aud) ? payload.aud : [payload.aud];
-
- const match = target.some(function (targetAudience) {
- return audiences.some(function (audience) {
- return audience instanceof RegExp ? audience.test(targetAudience) : audience === targetAudience;
- });
- });
-
- if (!match) {
- return done(new JsonWebTokenError('jwt audience invalid. expected: ' + audiences.join(' or ')));
- }
- }
-
- if (options.issuer) {
- const invalid_issuer =
- (typeof options.issuer === 'string' && payload.iss !== options.issuer) ||
- (Array.isArray(options.issuer) && options.issuer.indexOf(payload.iss) === -1);
-
- if (invalid_issuer) {
- return done(new JsonWebTokenError('jwt issuer invalid. expected: ' + options.issuer));
- }
- }
-
- if (options.subject) {
- if (payload.sub !== options.subject) {
- return done(new JsonWebTokenError('jwt subject invalid. expected: ' + options.subject));
- }
- }
-
- if (options.jwtid) {
- if (payload.jti !== options.jwtid) {
- return done(new JsonWebTokenError('jwt jwtid invalid. expected: ' + options.jwtid));
- }
- }
-
- if (options.nonce) {
- if (payload.nonce !== options.nonce) {
- return done(new JsonWebTokenError('jwt nonce invalid. expected: ' + options.nonce));
- }
- }
-
- if (options.maxAge) {
- if (typeof payload.iat !== 'number') {
- return done(new JsonWebTokenError('iat required when maxAge is specified'));
- }
-
- const maxAgeTimestamp = timespan(options.maxAge, payload.iat);
- if (typeof maxAgeTimestamp === 'undefined') {
- return done(new JsonWebTokenError('"maxAge" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));
- }
- if (clockTimestamp >= maxAgeTimestamp + (options.clockTolerance || 0)) {
- return done(new TokenExpiredError('maxAge exceeded', new Date(maxAgeTimestamp * 1000)));
- }
- }
-
- if (options.complete === true) {
- const signature = decodedToken.signature;
-
- return done(null, {
- header: header,
- payload: payload,
- signature: signature
- });
- }
-
- return done(null, payload);
- });
-};