From 3c9d7a6f7498e7061080099bf2ffe950881ec379 Mon Sep 17 00:00:00 2001 From: HappyZombies Date: Fri, 8 Oct 2021 07:48:37 -0400 Subject: [PATCH 01/99] Version 4 with readme, package.json and travis.yml updates --- .travis.yml | 1 - README.md | 26 +- package-lock.json | 748 +--------------------------------------------- package.json | 7 +- 4 files changed, 17 insertions(+), 765 deletions(-) diff --git a/.travis.yml b/.travis.yml index a5896daa2..1bb18b78f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: node_js node_js: - - 4 - 6 - 8 - 10 diff --git a/README.md b/README.md index dc2122371..dfcd31847 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,21 @@ -# oauth2-server +# oauth2-server2 [![npm Version][npm-image]][npm-url] [![npm Downloads][downloads-image]][downloads-url] -[![Test Status][travis-image]][travis-url] [![MIT Licensed][license-image]][license-url] -[![oauthjs Slack][slack-image]][slack-url] Complete, compliant and well tested module for implementing an OAuth2 server in [Node.js](https://nodejs.org). -Note: After a period of hiatus, this project is now back under active maintenance. Dependencies have been updated and bug fixes will land in v3 (current master). v4 will be _mostly backwards compatible_ with no code changes required for users using a supported node release. More details in [#621](https://github.com/oauthjs/node-oauth2-server/issues/621). +NOTE: This project has been forked from [oauthjs/node-oauth2-server](https://github.com/oauthjs/node-oauth2-server) and is a continuition due to the project appearing to be abandoned. Please see [this issue](https://github.com/node-oauth/node-oauth2-server/issues/1) to talk about next steps and the future of this project. ## Installation ```bash -npm install oauth2-server +npm install oauth2-server2 ``` -The *oauth2-server* module is framework-agnostic but there are several officially supported wrappers available for popular HTTP server frameworks such as [Express](https://npmjs.org/package/express-oauth-server) and [Koa](https://npmjs.org/package/koa-oauth-server). If you're using one of those frameworks it is strongly recommended to use the respective wrapper module instead of rolling your own. +The *oauth2-server2* module is framework-agnostic but there are several officially supported wrappers available for popular HTTP server frameworks such as [Express](https://npmjs.org/package/express-oauth-server) and [Koa](https://npmjs.org/package/koa-oauth-server). If you're using one of those frameworks it is strongly recommended to use the respective wrapper module instead of rolling your own. ## Features @@ -26,7 +24,7 @@ The *oauth2-server* module is framework-agnostic but there are several officiall - Can be used with *promises*, *Node-style callbacks*, *ES6 generators* and *async*/*await* (using [Babel](https://babeljs.io)). - Fully [RFC 6749](https://tools.ietf.org/html/rfc6749.html) and [RFC 6750](https://tools.ietf.org/html/rfc6750.html) compliant. - Implicitly supports any form of storage, e.g. *PostgreSQL*, *MySQL*, *MongoDB*, *Redis*, etc. -- Complete [test suite](https://github.com/oauthjs/node-oauth2-server/tree/master/test). +- Complete [test suite](https://github.com/node-oauth/node-oauth2-server/tree/master/test). ## Documentation @@ -57,14 +55,10 @@ npm test ``` -[npm-image]: https://img.shields.io/npm/v/oauth2-server.svg -[npm-url]: https://npmjs.org/package/oauth2-server -[downloads-image]: https://img.shields.io/npm/dm/oauth2-server.svg -[downloads-url]: https://npmjs.org/package/oauth2-server -[travis-image]: https://img.shields.io/travis/oauthjs/node-oauth2-server/master.svg -[travis-url]: https://travis-ci.org/oauthjs/node-oauth2-server +[npm-image]: https://img.shields.io/npm/v/oauth2-server2.svg +[npm-url]: https://npmjs.org/package/oauth2-server2 +[downloads-image]: https://img.shields.io/npm/dm/oauth2-server2.svg +[downloads-url]: https://npmjs.org/package/oauth2-server2 [license-image]: https://img.shields.io/badge/license-MIT-blue.svg -[license-url]: https://raw.githubusercontent.com/oauthjs/node-oauth2-server/master/LICENSE -[slack-image]: https://slack.oauthjs.org/badge.svg -[slack-url]: https://slack.oauthjs.org +[license-url]: https://raw.githubusercontent.com/node-oauth/node-oauth2-server/master/LICENSE diff --git a/package-lock.json b/package-lock.json index e2cb0c1b8..8a3a25a63 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,752 +1,8 @@ { "name": "oauth2-server", - "version": "4.0.0-dev.3", - "lockfileVersion": 2, + "version": "4.0.0", + "lockfileVersion": 1, "requires": true, - "packages": { - "": { - "name": "oauth2-server", - "version": "4.0.0-dev.3", - "license": "MIT", - "dependencies": { - "basic-auth": "2.0.1", - "bluebird": "3.7.2", - "lodash": "4.17.21", - "promisify-any": "2.0.1", - "statuses": "1.5.0", - "type-is": "1.6.18" - }, - "devDependencies": { - "jshint": "2.13.0", - "mocha": "5.2.0", - "should": "13.2.3", - "sinon": "7.5.0" - }, - "engines": { - "node": ">=4.0" - } - }, - "node_modules/@sinonjs/commons": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.0.tgz", - "integrity": "sha512-wEj54PfsZ5jGSwMX68G8ZXFawcSglQSXqCftWX3ec8MDUzQdHgcKvw97awHbY0efQEL5iKUOAmmVtoYgmrSG4Q==", - "dev": true, - "dependencies": { - "type-detect": "4.0.8" - } - }, - "node_modules/@sinonjs/formatio": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/@sinonjs/formatio/-/formatio-3.2.2.tgz", - "integrity": "sha512-B8SEsgd8gArBLMD6zpRw3juQ2FVSsmdd7qlevyDqzS9WTCtvF55/gAL+h6gue8ZvPYcdiPdvueM/qm//9XzyTQ==", - "dev": true, - "dependencies": { - "@sinonjs/commons": "^1", - "@sinonjs/samsam": "^3.1.0" - } - }, - "node_modules/@sinonjs/samsam": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-3.3.3.tgz", - "integrity": "sha512-bKCMKZvWIjYD0BLGnNrxVuw4dkWCYsLqFOUWw8VgKF/+5Y+mE7LfHWPIYoDXowH+3a9LsWDMo0uAP8YDosPvHQ==", - "dev": true, - "dependencies": { - "@sinonjs/commons": "^1.3.0", - "array-from": "^2.1.1", - "lodash": "^4.17.15" - } - }, - "node_modules/@sinonjs/text-encoding": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz", - "integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==", - "dev": true - }, - "node_modules/array-from": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/array-from/-/array-from-2.1.1.tgz", - "integrity": "sha1-z+nYwmYoudxa7MYqn12PHzUsEZU=", - "dev": true - }, - "node_modules/balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true - }, - "node_modules/basic-auth": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", - "integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==", - "dependencies": { - "safe-buffer": "5.1.2" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/bluebird": { - "version": "3.7.2", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", - "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==" - }, - "node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/browser-stdout": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", - "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", - "dev": true - }, - "node_modules/cli": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/cli/-/cli-1.0.1.tgz", - "integrity": "sha1-IoF1NPJL+klQw01TLUjsvGIbjBQ=", - "dev": true, - "dependencies": { - "exit": "0.1.2", - "glob": "^7.1.1" - }, - "engines": { - "node": ">=0.2.5" - } - }, - "node_modules/co-bluebird": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/co-bluebird/-/co-bluebird-1.1.0.tgz", - "integrity": "sha1-yLnzqTIKftMJh9zKGlw8/1llXHw=", - "dependencies": { - "bluebird": "^2.10.0", - "co-use": "^1.1.0" - }, - "engines": { - "node": ">=0.12.0" - } - }, - "node_modules/co-bluebird/node_modules/bluebird": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-2.11.0.tgz", - "integrity": "sha1-U0uQM8AiyVecVro7Plpcqvu2UOE=" - }, - "node_modules/co-use": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/co-use/-/co-use-1.1.0.tgz", - "integrity": "sha1-xrs83xDLc17Kqdru2kbXJclKTmI=", - "engines": { - "node": ">=0.12.0" - } - }, - "node_modules/commander": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", - "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", - "dev": true - }, - "node_modules/concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true - }, - "node_modules/console-browserify": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", - "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", - "dev": true, - "dependencies": { - "date-now": "^0.1.4" - } - }, - "node_modules/core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, - "node_modules/date-now": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", - "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=", - "dev": true - }, - "node_modules/debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/diff": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", - "dev": true, - "engines": { - "node": ">=0.3.1" - } - }, - "node_modules/dom-serializer": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.2.2.tgz", - "integrity": "sha512-2/xPb3ORsQ42nHYiSunXkDjPLBaEj/xTwUO4B7XCZQTRk7EBtTOPaygh10YAAh2OI1Qrp6NWfpAhzswj0ydt9g==", - "dev": true, - "dependencies": { - "domelementtype": "^2.0.1", - "entities": "^2.0.0" - } - }, - "node_modules/dom-serializer/node_modules/domelementtype": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.2.0.tgz", - "integrity": "sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A==", - "dev": true - }, - "node_modules/dom-serializer/node_modules/entities": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", - "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==", - "dev": true - }, - "node_modules/domelementtype": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz", - "integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==", - "dev": true - }, - "node_modules/domhandler": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.3.0.tgz", - "integrity": "sha1-LeWaCCLVAn+r/28DLCsloqir5zg=", - "dev": true, - "dependencies": { - "domelementtype": "1" - } - }, - "node_modules/domutils": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", - "integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=", - "dev": true, - "dependencies": { - "dom-serializer": "0", - "domelementtype": "1" - } - }, - "node_modules/entities": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz", - "integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY=", - "dev": true - }, - "node_modules/escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true, - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/exit": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", - "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", - "dev": true, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, - "node_modules/glob": { - "version": "7.1.7", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", - "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", - "dev": true, - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "engines": { - "node": "*" - } - }, - "node_modules/growl": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", - "dev": true, - "engines": { - "node": ">=4.x" - } - }, - "node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/he": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", - "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", - "dev": true, - "bin": { - "he": "bin/he" - } - }, - "node_modules/htmlparser2": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz", - "integrity": "sha1-mWwosZFRaovoZQGn15dX5ccMEGg=", - "dev": true, - "dependencies": { - "domelementtype": "1", - "domhandler": "2.3", - "domutils": "1.5", - "entities": "1.0", - "readable-stream": "1.1" - } - }, - "node_modules/inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "dependencies": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true - }, - "node_modules/is-generator": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/is-generator/-/is-generator-1.0.3.tgz", - "integrity": "sha1-wUwhBX7TbjKNuANHlmxpP4hjifM=" - }, - "node_modules/isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "node_modules/jshint": { - "version": "2.13.0", - "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.13.0.tgz", - "integrity": "sha512-Nd+md9wIeyfDK+RGrbOBzwLONSTdihGMtyGYU/t7zYcN2EgUa4iuY3VK2oxtPYrW5ycTj18iC+UbhNTxe4C66g==", - "dev": true, - "dependencies": { - "cli": "~1.0.0", - "console-browserify": "1.1.x", - "exit": "0.1.x", - "htmlparser2": "3.8.x", - "lodash": "~4.17.21", - "minimatch": "~3.0.2", - "shelljs": "0.3.x", - "strip-json-comments": "1.0.x" - }, - "bin": { - "jshint": "bin/jshint" - } - }, - "node_modules/jshint/node_modules/lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true - }, - "node_modules/just-extend": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.1.0.tgz", - "integrity": "sha512-ApcjaOdVTJ7y4r08xI5wIqpvwS48Q0PBG4DJROcEkH1f8MdAiNFyFxz3xoL0LWAVwjrwPYZdVHHxhRHcx/uGLA==", - "dev": true - }, - "node_modules/lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" - }, - "node_modules/lolex": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/lolex/-/lolex-4.2.0.tgz", - "integrity": "sha512-gKO5uExCXvSm6zbF562EvM+rd1kQDnB9AZBbiQVzf1ZmdDpxUSvpnAaVOP83N/31mRK8Ml8/VE8DMvsAZQ+7wg==", - "dev": true - }, - "node_modules/media-typer": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-db": { - "version": "1.44.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz", - "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-types": { - "version": "2.1.27", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz", - "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==", - "dependencies": { - "mime-db": "1.44.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true - }, - "node_modules/mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "dev": true, - "dependencies": { - "minimist": "0.0.8" - }, - "bin": { - "mkdirp": "bin/cmd.js" - } - }, - "node_modules/mocha": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", - "integrity": "sha1-bYrlCPWRZ/lA8rWzxKYSrlDJCuY=", - "dev": true, - "dependencies": { - "browser-stdout": "1.3.1", - "commander": "2.15.1", - "debug": "3.1.0", - "diff": "3.5.0", - "escape-string-regexp": "1.0.5", - "glob": "7.1.2", - "growl": "1.10.5", - "he": "1.1.1", - "minimatch": "3.0.4", - "mkdirp": "0.5.1", - "supports-color": "5.4.0" - }, - "bin": { - "_mocha": "bin/_mocha", - "mocha": "bin/mocha" - }, - "engines": { - "node": ">= 4.0.0" - } - }, - "node_modules/mocha/node_modules/glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", - "dev": true, - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "engines": { - "node": "*" - } - }, - "node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - }, - "node_modules/nise": { - "version": "1.5.3", - "resolved": "https://registry.npmjs.org/nise/-/nise-1.5.3.tgz", - "integrity": "sha512-Ymbac/94xeIrMf59REBPOv0thr+CJVFMhrlAkW/gjCIE58BGQdCj0x7KRCb3yz+Ga2Rz3E9XXSvUyyxqqhjQAQ==", - "dev": true, - "dependencies": { - "@sinonjs/formatio": "^3.2.1", - "@sinonjs/text-encoding": "^0.7.1", - "just-extend": "^4.0.2", - "lolex": "^5.0.1", - "path-to-regexp": "^1.7.0" - } - }, - "node_modules/nise/node_modules/lolex": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/lolex/-/lolex-5.1.2.tgz", - "integrity": "sha512-h4hmjAvHTmd+25JSwrtTIuwbKdwg5NzZVRMLn9saij4SZaepCrTCxPr35H/3bjwfMJtN+t3CX8672UIkglz28A==", - "dev": true, - "dependencies": { - "@sinonjs/commons": "^1.7.0" - } - }, - "node_modules/once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "dependencies": { - "wrappy": "1" - } - }, - "node_modules/path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/path-to-regexp": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz", - "integrity": "sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==", - "dev": true, - "dependencies": { - "isarray": "0.0.1" - } - }, - "node_modules/promisify-any": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/promisify-any/-/promisify-any-2.0.1.tgz", - "integrity": "sha1-QD4AqIE/F1JCq1D+M6afjuzkcwU=", - "dependencies": { - "bluebird": "^2.10.0", - "co-bluebird": "^1.1.0", - "is-generator": "^1.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/promisify-any/node_modules/bluebird": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-2.11.0.tgz", - "integrity": "sha1-U0uQM8AiyVecVro7Plpcqvu2UOE=" - }, - "node_modules/readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "dev": true, - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - }, - "node_modules/shelljs": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.3.0.tgz", - "integrity": "sha1-NZbmMHp4FUT1kfN9phg2DzHbV7E=", - "dev": true, - "bin": { - "shjs": "bin/shjs" - }, - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/should": { - "version": "13.2.3", - "resolved": "https://registry.npmjs.org/should/-/should-13.2.3.tgz", - "integrity": "sha512-ggLesLtu2xp+ZxI+ysJTmNjh2U0TsC+rQ/pfED9bUZZ4DKefP27D+7YJVVTvKsmjLpIi9jAa7itwDGkDDmt1GQ==", - "dev": true, - "dependencies": { - "should-equal": "^2.0.0", - "should-format": "^3.0.3", - "should-type": "^1.4.0", - "should-type-adaptors": "^1.0.1", - "should-util": "^1.0.0" - } - }, - "node_modules/should-equal": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/should-equal/-/should-equal-2.0.0.tgz", - "integrity": "sha512-ZP36TMrK9euEuWQYBig9W55WPC7uo37qzAEmbjHz4gfyuXrEUgF8cUvQVO+w+d3OMfPvSRQJ22lSm8MQJ43LTA==", - "dev": true, - "dependencies": { - "should-type": "^1.4.0" - } - }, - "node_modules/should-format": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/should-format/-/should-format-3.0.3.tgz", - "integrity": "sha1-m/yPdPo5IFxT04w01xcwPidxJPE=", - "dev": true, - "dependencies": { - "should-type": "^1.3.0", - "should-type-adaptors": "^1.0.1" - } - }, - "node_modules/should-type": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/should-type/-/should-type-1.4.0.tgz", - "integrity": "sha1-B1bYzoRt/QmEOmlHcZ36DUz/XPM=", - "dev": true - }, - "node_modules/should-type-adaptors": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/should-type-adaptors/-/should-type-adaptors-1.1.0.tgz", - "integrity": "sha512-JA4hdoLnN+kebEp2Vs8eBe9g7uy0zbRo+RMcU0EsNy+R+k049Ki+N5tT5Jagst2g7EAja+euFuoXFCa8vIklfA==", - "dev": true, - "dependencies": { - "should-type": "^1.3.0", - "should-util": "^1.0.0" - } - }, - "node_modules/should-util": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/should-util/-/should-util-1.0.1.tgz", - "integrity": "sha512-oXF8tfxx5cDk8r2kYqlkUJzZpDBqVY/II2WhvU0n9Y3XYvAYRmeaf1PvvIvTgPnv4KJ+ES5M0PyDq5Jp+Ygy2g==", - "dev": true - }, - "node_modules/sinon": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-7.5.0.tgz", - "integrity": "sha1-6UiOpGYHDqkI/USj1keP1JI8Z+w=", - "dev": true, - "dependencies": { - "@sinonjs/commons": "^1.4.0", - "@sinonjs/formatio": "^3.2.1", - "@sinonjs/samsam": "^3.3.3", - "diff": "^3.5.0", - "lolex": "^4.2.0", - "nise": "^1.5.2", - "supports-color": "^5.5.0" - } - }, - "node_modules/sinon/node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha1-4uaaRKyHcveKHsCzW2id9lMO/I8=", - "dev": true, - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/statuses": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", - "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - }, - "node_modules/strip-json-comments": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", - "integrity": "sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E=", - "dev": true, - "bin": { - "strip-json-comments": "cli.js" - }, - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/supports-color": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", - "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", - "dev": true, - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/type-detect": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/type-is": { - "version": "1.6.18", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", - "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", - "dependencies": { - "media-typer": "0.3.0", - "mime-types": "~2.1.24" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true - } - }, "dependencies": { "@sinonjs/commons": { "version": "1.8.0", diff --git a/package.json b/package.json index e4d04f08b..f695832b1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "oauth2-server", "description": "Complete, framework-agnostic, compliant and well tested module for implementing an OAuth2 Server in node.js", - "version": "4.0.0-dev.3", + "version": "4.0.0", "keywords": [ "oauth", "oauth2" @@ -32,6 +32,9 @@ }, { "name": "Max Truxa" + }, + { + "name": "Daniel Reguero" } ], "main": "index.js", @@ -60,6 +63,6 @@ }, "repository": { "type": "git", - "url": "https://github.com/oauthjs/node-oauth2-server.git" + "url": "https://github.com/node-oauth/node-oauth2-server.git" } } From ba02a31efa15d9b22cf5605e165bc8fc4cfd0120 Mon Sep 17 00:00:00 2001 From: HappyZombies Date: Fri, 8 Oct 2021 07:50:56 -0400 Subject: [PATCH 02/99] Remove badges for now --- README.md | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/README.md b/README.md index dfcd31847..5d5b07d12 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,9 @@ # oauth2-server2 -[![npm Version][npm-image]][npm-url] -[![npm Downloads][downloads-image]][downloads-url] -[![MIT Licensed][license-image]][license-url] - Complete, compliant and well tested module for implementing an OAuth2 server in [Node.js](https://nodejs.org). -NOTE: This project has been forked from [oauthjs/node-oauth2-server](https://github.com/oauthjs/node-oauth2-server) and is a continuition due to the project appearing to be abandoned. Please see [this issue](https://github.com/node-oauth/node-oauth2-server/issues/1) to talk about next steps and the future of this project. +NOTE: This project has been forked from [oauthjs/node-oauth2-server](https://github.com/oauthjs/node-oauth2-server) and is a continuition due to the project appearing to be abandoned. Please see [this issue](https://github.com/node-oauth/node-oauth2-server/issues/2) to talk about next steps and the future of this project. ## Installation @@ -53,12 +49,3 @@ To run the test suite, install dependencies, then run `npm test`: npm install npm test ``` - - -[npm-image]: https://img.shields.io/npm/v/oauth2-server2.svg -[npm-url]: https://npmjs.org/package/oauth2-server2 -[downloads-image]: https://img.shields.io/npm/dm/oauth2-server2.svg -[downloads-url]: https://npmjs.org/package/oauth2-server2 -[license-image]: https://img.shields.io/badge/license-MIT-blue.svg -[license-url]: https://raw.githubusercontent.com/node-oauth/node-oauth2-server/master/LICENSE - From aba6a3e13f030945e24fe7b4b91318089b3b2512 Mon Sep 17 00:00:00 2001 From: HappyZombies Date: Fri, 8 Oct 2021 07:55:20 -0400 Subject: [PATCH 03/99] update npm install commands in readme --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5d5b07d12..3862c3ef7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# oauth2-server2 +# @node-oauth/oauth2-server Complete, compliant and well tested module for implementing an OAuth2 server in [Node.js](https://nodejs.org). @@ -8,10 +8,10 @@ NOTE: This project has been forked from [oauthjs/node-oauth2-server](https://git ## Installation ```bash -npm install oauth2-server2 +npm install @node-oauth/oauth2-server ``` -The *oauth2-server2* module is framework-agnostic but there are several officially supported wrappers available for popular HTTP server frameworks such as [Express](https://npmjs.org/package/express-oauth-server) and [Koa](https://npmjs.org/package/koa-oauth-server). If you're using one of those frameworks it is strongly recommended to use the respective wrapper module instead of rolling your own. +The *@node-oauth/oauth2-server* module is framework-agnostic but there are several officially supported wrappers available for popular HTTP server frameworks such as [Express](https://npmjs.org/package/express-oauth-server) and [Koa](https://npmjs.org/package/koa-oauth-server). If you're using one of those frameworks it is strongly recommended to use the respective wrapper module instead of rolling your own. ## Features From a0a6fdb78677393c40a612f72c974e59c17f6dd1 Mon Sep 17 00:00:00 2001 From: HappyZombies Date: Fri, 8 Oct 2021 08:02:20 -0400 Subject: [PATCH 04/99] Ran npm init with scope, new properties added to package.json --- package-lock.json | 2 +- package.json | 55 +++++++++++++++++++---------------------------- 2 files changed, 23 insertions(+), 34 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8a3a25a63..3eb1e4284 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "oauth2-server", + "name": "@node-oauth/oauth2-server", "version": "4.0.0", "lockfileVersion": 1, "requires": true, diff --git a/package.json b/package.json index f695832b1..07ddd233b 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "oauth2-server", + "name": "@node-oauth/oauth2-server", "description": "Complete, framework-agnostic, compliant and well tested module for implementing an OAuth2 Server in node.js", "version": "4.0.0", "keywords": [ @@ -7,35 +7,14 @@ "oauth2" ], "contributors": [ - { - "name": "Thom Seddon", - "email": "thom@seddonmedia.co.uk" - }, - { - "name": "Lars F. Karlström", - "email": "lars@lfk.io" - }, - { - "name": "Rui Marinho", - "email": "ruipmarinho@gmail.com" - }, - { - "name": "Tiago Ribeiro", - "email": "tiago.ribeiro@gmail.com" - }, - { - "name": "Michael Salinger", - "email": "mjsalinger@gmail.com" - }, - { - "name": "Nuno Sousa" - }, - { - "name": "Max Truxa" - }, - { - "name": "Daniel Reguero" - } + "Thom Seddon ", + "Lars F. Karlström ", + "Rui Marinho ", + "Tiago Ribeiro ", + "Michael Salinger ", + "Nuno Sousa", + "Max Truxa", + "Daniel Reguero" ], "main": "index.js", "dependencies": { @@ -57,12 +36,22 @@ "node": ">=4.0" }, "scripts": { - "pretest": "./node_modules/.bin/jshint --config ./.jshintrc lib test", + "pretest": "jshint --config ./.jshintrc lib test", "test": "NODE_ENV=test ./node_modules/.bin/mocha 'test/**/*_test.js'", "test-debug": "NODE_ENV=test ./node_modules/.bin/mocha --inspect --debug-brk 'test/**/*_test.js'" }, "repository": { "type": "git", - "url": "https://github.com/node-oauth/node-oauth2-server.git" - } + "url": "git+https://github.com/node-oauth/node-oauth2-server.git" + }, + "bugs": { + "url": "https://github.com/node-oauth/node-oauth2-server/issues" + }, + "homepage": "https://github.com/node-oauth/node-oauth2-server#readme", + "directories": { + "doc": "docs", + "lib": "lib", + "test": "test" + }, + "author": "" } From b9aae53a8385417bb5b613c801b05bdcd7e3f9d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Sun, 10 Oct 2021 14:17:23 +0200 Subject: [PATCH 05/99] Create SECURITY.md --- SECURITY.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 000000000..697becd48 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,24 @@ +# Security Policy + +## Supported Versions + +Use this section to tell people about which versions of your project are +currently being supported with security updates. + +| Version | Supported | +| ------- | ------------------ | +| 4.x.x | :white_check_mark: | +| 3.x.x | :white_check_mark: but only very critical security issues | +| < 3 | :x: | + +## Reporting a Vulnerability + +Report security vulnerabilities to info[at]jankuester[dot]com + +Please specify exactly how the vulnerability is to be exploited so we can estime how severe the consequences can be (unless you also can specifiy them, too). +Note, that we need to reproduce the vulnerability (as like with bugs) in order to safely fix it. + +A fix will be implemented in private until we can ensure the vulnerability is closed. A new release will immediately be published. +If you want to provide a fix please let us know in the Email so we can setup a completely private repository to work on it together. + +Note, that security fixes will also require to pass all tests and audits. From 17e27291046f142310bbda39149bccbf5e03c751 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Sun, 10 Oct 2021 14:36:37 +0200 Subject: [PATCH 06/99] added test coverage using nyc --- .gitignore | 4 + package-lock.json | 1185 +++++++++++++++++++++++++++++++++++++++++++++ package.json | 4 +- 3 files changed, 1192 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 08b44961f..fc339caaf 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,7 @@ tramp # Org-mode .org-id-locations *_archive + +# coverage +coverage +.nyc_output diff --git a/package-lock.json b/package-lock.json index 3eb1e4284..37b5a3c89 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,300 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@babel/code-frame": { + "version": "7.15.8", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.15.8.tgz", + "integrity": "sha512-2IAnmn8zbvC/jKYhq5Ki9I+DwjlrtMPUCH/CpHvqI4dNnlwHwsxoIhlc8WcYY5LSYknXQtAlFYuHfqAFCvQ4Wg==", + "dev": true, + "requires": { + "@babel/highlight": "^7.14.5" + } + }, + "@babel/compat-data": { + "version": "7.15.0", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.15.0.tgz", + "integrity": "sha512-0NqAC1IJE0S0+lL1SWFMxMkz1pKCNCjI4tr2Zx4LJSXxCLAdr6KyArnY+sno5m3yH9g737ygOyPABDsnXkpxiA==", + "dev": true + }, + "@babel/core": { + "version": "7.15.8", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.15.8.tgz", + "integrity": "sha512-3UG9dsxvYBMYwRv+gS41WKHno4K60/9GPy1CJaH6xy3Elq8CTtvtjT5R5jmNhXfCYLX2mTw+7/aq5ak/gOE0og==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.15.8", + "@babel/generator": "^7.15.8", + "@babel/helper-compilation-targets": "^7.15.4", + "@babel/helper-module-transforms": "^7.15.8", + "@babel/helpers": "^7.15.4", + "@babel/parser": "^7.15.8", + "@babel/template": "^7.15.4", + "@babel/traverse": "^7.15.4", + "@babel/types": "^7.15.6", + "convert-source-map": "^1.7.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.1.2", + "semver": "^6.3.0", + "source-map": "^0.5.0" + }, + "dependencies": { + "debug": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", + "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } + } + }, + "@babel/generator": { + "version": "7.15.8", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.15.8.tgz", + "integrity": "sha512-ECmAKstXbp1cvpTTZciZCgfOt6iN64lR0d+euv3UZisU5awfRawOvg07Utn/qBGuH4bRIEZKrA/4LzZyXhZr8g==", + "dev": true, + "requires": { + "@babel/types": "^7.15.6", + "jsesc": "^2.5.1", + "source-map": "^0.5.0" + } + }, + "@babel/helper-compilation-targets": { + "version": "7.15.4", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.15.4.tgz", + "integrity": "sha512-rMWPCirulnPSe4d+gwdWXLfAXTTBj8M3guAf5xFQJ0nvFY7tfNAFnWdqaHegHlgDZOCT4qvhF3BYlSJag8yhqQ==", + "dev": true, + "requires": { + "@babel/compat-data": "^7.15.0", + "@babel/helper-validator-option": "^7.14.5", + "browserslist": "^4.16.6", + "semver": "^6.3.0" + } + }, + "@babel/helper-function-name": { + "version": "7.15.4", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.15.4.tgz", + "integrity": "sha512-Z91cOMM4DseLIGOnog+Z8OI6YseR9bua+HpvLAQ2XayUGU+neTtX+97caALaLdyu53I/fjhbeCnWnRH1O3jFOw==", + "dev": true, + "requires": { + "@babel/helper-get-function-arity": "^7.15.4", + "@babel/template": "^7.15.4", + "@babel/types": "^7.15.4" + } + }, + "@babel/helper-get-function-arity": { + "version": "7.15.4", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.15.4.tgz", + "integrity": "sha512-1/AlxSF92CmGZzHnC515hm4SirTxtpDnLEJ0UyEMgTMZN+6bxXKg04dKhiRx5Enel+SUA1G1t5Ed/yQia0efrA==", + "dev": true, + "requires": { + "@babel/types": "^7.15.4" + } + }, + "@babel/helper-hoist-variables": { + "version": "7.15.4", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.15.4.tgz", + "integrity": "sha512-VTy085egb3jUGVK9ycIxQiPbquesq0HUQ+tPO0uv5mPEBZipk+5FkRKiWq5apuyTE9FUrjENB0rCf8y+n+UuhA==", + "dev": true, + "requires": { + "@babel/types": "^7.15.4" + } + }, + "@babel/helper-member-expression-to-functions": { + "version": "7.15.4", + "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.15.4.tgz", + "integrity": "sha512-cokOMkxC/BTyNP1AlY25HuBWM32iCEsLPI4BHDpJCHHm1FU2E7dKWWIXJgQgSFiu4lp8q3bL1BIKwqkSUviqtA==", + "dev": true, + "requires": { + "@babel/types": "^7.15.4" + } + }, + "@babel/helper-module-imports": { + "version": "7.15.4", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.15.4.tgz", + "integrity": "sha512-jeAHZbzUwdW/xHgHQ3QmWR4Jg6j15q4w/gCfwZvtqOxoo5DKtLHk8Bsf4c5RZRC7NmLEs+ohkdq8jFefuvIxAA==", + "dev": true, + "requires": { + "@babel/types": "^7.15.4" + } + }, + "@babel/helper-module-transforms": { + "version": "7.15.8", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.15.8.tgz", + "integrity": "sha512-DfAfA6PfpG8t4S6npwzLvTUpp0sS7JrcuaMiy1Y5645laRJIp/LiLGIBbQKaXSInK8tiGNI7FL7L8UvB8gdUZg==", + "dev": true, + "requires": { + "@babel/helper-module-imports": "^7.15.4", + "@babel/helper-replace-supers": "^7.15.4", + "@babel/helper-simple-access": "^7.15.4", + "@babel/helper-split-export-declaration": "^7.15.4", + "@babel/helper-validator-identifier": "^7.15.7", + "@babel/template": "^7.15.4", + "@babel/traverse": "^7.15.4", + "@babel/types": "^7.15.6" + } + }, + "@babel/helper-optimise-call-expression": { + "version": "7.15.4", + "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.15.4.tgz", + "integrity": "sha512-E/z9rfbAOt1vDW1DR7k4SzhzotVV5+qMciWV6LaG1g4jeFrkDlJedjtV4h0i4Q/ITnUu+Pk08M7fczsB9GXBDw==", + "dev": true, + "requires": { + "@babel/types": "^7.15.4" + } + }, + "@babel/helper-replace-supers": { + "version": "7.15.4", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.15.4.tgz", + "integrity": "sha512-/ztT6khaXF37MS47fufrKvIsiQkx1LBRvSJNzRqmbyeZnTwU9qBxXYLaaT/6KaxfKhjs2Wy8kG8ZdsFUuWBjzw==", + "dev": true, + "requires": { + "@babel/helper-member-expression-to-functions": "^7.15.4", + "@babel/helper-optimise-call-expression": "^7.15.4", + "@babel/traverse": "^7.15.4", + "@babel/types": "^7.15.4" + } + }, + "@babel/helper-simple-access": { + "version": "7.15.4", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.15.4.tgz", + "integrity": "sha512-UzazrDoIVOZZcTeHHEPYrr1MvTR/K+wgLg6MY6e1CJyaRhbibftF6fR2KU2sFRtI/nERUZR9fBd6aKgBlIBaPg==", + "dev": true, + "requires": { + "@babel/types": "^7.15.4" + } + }, + "@babel/helper-split-export-declaration": { + "version": "7.15.4", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.15.4.tgz", + "integrity": "sha512-HsFqhLDZ08DxCpBdEVtKmywj6PQbwnF6HHybur0MAnkAKnlS6uHkwnmRIkElB2Owpfb4xL4NwDmDLFubueDXsw==", + "dev": true, + "requires": { + "@babel/types": "^7.15.4" + } + }, + "@babel/helper-validator-identifier": { + "version": "7.15.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.15.7.tgz", + "integrity": "sha512-K4JvCtQqad9OY2+yTU8w+E82ywk/fe+ELNlt1G8z3bVGlZfn/hOcQQsUhGhW/N+tb3fxK800wLtKOE/aM0m72w==", + "dev": true + }, + "@babel/helper-validator-option": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.14.5.tgz", + "integrity": "sha512-OX8D5eeX4XwcroVW45NMvoYaIuFI+GQpA2a8Gi+X/U/cDUIRsV37qQfF905F0htTRCREQIB4KqPeaveRJUl3Ow==", + "dev": true + }, + "@babel/helpers": { + "version": "7.15.4", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.15.4.tgz", + "integrity": "sha512-V45u6dqEJ3w2rlryYYXf6i9rQ5YMNu4FLS6ngs8ikblhu2VdR1AqAd6aJjBzmf2Qzh6KOLqKHxEN9+TFbAkAVQ==", + "dev": true, + "requires": { + "@babel/template": "^7.15.4", + "@babel/traverse": "^7.15.4", + "@babel/types": "^7.15.4" + } + }, + "@babel/highlight": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.14.5.tgz", + "integrity": "sha512-qf9u2WFWVV0MppaL877j2dBtQIDgmidgjGk5VIMw3OadXvYaXn66U1BFlH2t4+t3i+8PhedppRv+i40ABzd+gg==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.14.5", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + } + }, + "@babel/parser": { + "version": "7.15.8", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.15.8.tgz", + "integrity": "sha512-BRYa3wcQnjS/nqI8Ac94pYYpJfojHVvVXJ97+IDCImX4Jc8W8Xv1+47enbruk+q1etOpsQNwnfFcNGw+gtPGxA==", + "dev": true + }, + "@babel/template": { + "version": "7.15.4", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.15.4.tgz", + "integrity": "sha512-UgBAfEa1oGuYgDIPM2G+aHa4Nlo9Lh6mGD2bDBGMTbYnc38vulXPuC1MGjYILIEmlwl6Rd+BPR9ee3gm20CBtg==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.14.5", + "@babel/parser": "^7.15.4", + "@babel/types": "^7.15.4" + } + }, + "@babel/traverse": { + "version": "7.15.4", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.15.4.tgz", + "integrity": "sha512-W6lQD8l4rUbQR/vYgSuCAE75ADyyQvOpFVsvPPdkhf6lATXAsQIG9YdtOcu8BB1dZ0LKu+Zo3c1wEcbKeuhdlA==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.14.5", + "@babel/generator": "^7.15.4", + "@babel/helper-function-name": "^7.15.4", + "@babel/helper-hoist-variables": "^7.15.4", + "@babel/helper-split-export-declaration": "^7.15.4", + "@babel/parser": "^7.15.4", + "@babel/types": "^7.15.4", + "debug": "^4.1.0", + "globals": "^11.1.0" + }, + "dependencies": { + "debug": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", + "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } + } + }, + "@babel/types": { + "version": "7.15.6", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.15.6.tgz", + "integrity": "sha512-BPU+7QhqNjmWyDO0/vitH/CuhpV8ZmK1wpKva8nuyNF5MJfuRNWMc+hc14+u9xT93kvykMdncrJT19h74uB1Ig==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.14.9", + "to-fast-properties": "^2.0.0" + } + }, + "@istanbuljs/load-nyc-config": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", + "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", + "dev": true, + "requires": { + "camelcase": "^5.3.1", + "find-up": "^4.1.0", + "get-package-type": "^0.1.0", + "js-yaml": "^3.13.1", + "resolve-from": "^5.0.0" + } + }, + "@istanbuljs/schema": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", + "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", + "dev": true + }, "@sinonjs/commons": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.0.tgz", @@ -40,6 +334,55 @@ "integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==", "dev": true }, + "aggregate-error": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz", + "integrity": "sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==", + "dev": true, + "requires": { + "clean-stack": "^2.0.0", + "indent-string": "^4.0.0" + } + }, + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "append-transform": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/append-transform/-/append-transform-2.0.0.tgz", + "integrity": "sha512-7yeyCEurROLQJFv5Xj4lEGTy0borxepjFv1g22oAdqFu//SrAlDl1O1Nxx15SH1RoliUml6p8dwJW9jvZughhg==", + "dev": true, + "requires": { + "default-require-extensions": "^3.0.0" + } + }, + "archy": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", + "integrity": "sha1-+cjBN1fMHde8N5rHeyxipcKGjEA=", + "dev": true + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, "array-from": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/array-from/-/array-from-2.1.1.tgz", @@ -81,6 +424,60 @@ "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, + "browserslist": { + "version": "4.17.3", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.17.3.tgz", + "integrity": "sha512-59IqHJV5VGdcJZ+GZ2hU5n4Kv3YiASzW6Xk5g9tf5a/MAzGeFwgGWU39fVzNIOVcgB3+Gp+kiQu0HEfTVU/3VQ==", + "dev": true, + "requires": { + "caniuse-lite": "^1.0.30001264", + "electron-to-chromium": "^1.3.857", + "escalade": "^3.1.1", + "node-releases": "^1.1.77", + "picocolors": "^0.2.1" + } + }, + "caching-transform": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/caching-transform/-/caching-transform-4.0.0.tgz", + "integrity": "sha512-kpqOvwXnjjN44D89K5ccQC+RUrsy7jB/XLlRrx0D7/2HNcTPqzsb6XgYoErwko6QsV184CA2YgS1fxDiiDZMWA==", + "dev": true, + "requires": { + "hasha": "^5.0.0", + "make-dir": "^3.0.0", + "package-hash": "^4.0.0", + "write-file-atomic": "^3.0.0" + } + }, + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + }, + "caniuse-lite": { + "version": "1.0.30001265", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001265.tgz", + "integrity": "sha512-YzBnspggWV5hep1m9Z6sZVLOt7vrju8xWooFAgN6BA5qvy98qPAPb7vNUzypFaoh2pb3vlfzbDO8tB57UPGbtw==", + "dev": true + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "clean-stack": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", + "integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==", + "dev": true + }, "cli": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cli/-/cli-1.0.1.tgz", @@ -91,6 +488,17 @@ "glob": "^7.1.1" } }, + "cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "dev": true, + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + } + }, "co-bluebird": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/co-bluebird/-/co-bluebird-1.1.0.tgz", @@ -112,12 +520,33 @@ "resolved": "https://registry.npmjs.org/co-use/-/co-use-1.1.0.tgz", "integrity": "sha1-xrs83xDLc17Kqdru2kbXJclKTmI=" }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, "commander": { "version": "2.15.1", "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", "dev": true }, + "commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", + "dev": true + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -133,12 +562,32 @@ "date-now": "^0.1.4" } }, + "convert-source-map": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.8.0.tgz", + "integrity": "sha512-+OQdjP49zViI/6i7nIJpA8rAl4sV/JdPfU9nZs3VqOwGIgizICvuN2ru6fMd+4llL0tar18UYJXfZ/TWtmhUjA==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.1" + } + }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, + "cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, "date-now": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", @@ -154,6 +603,21 @@ "ms": "2.0.0" } }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true + }, + "default-require-extensions": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/default-require-extensions/-/default-require-extensions-3.0.0.tgz", + "integrity": "sha512-ek6DpXq/SCpvjhpFsLFRVtIxJCRw6fUR42lYMVZuUMK7n8eMz4Uh5clckdBjEpLhn/gEBZo7hDJnJcwdKLKQjg==", + "dev": true, + "requires": { + "strip-bom": "^4.0.0" + } + }, "diff": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", @@ -209,30 +673,115 @@ "domelementtype": "1" } }, + "electron-to-chromium": { + "version": "1.3.864", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.864.tgz", + "integrity": "sha512-v4rbad8GO6/yVI92WOeU9Wgxc4NA0n4f6P1FvZTY+jyY7JHEhw3bduYu60v3Q1h81Cg6eo4ApZrFPuycwd5hGw==", + "dev": true + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, "entities": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz", "integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY=", "dev": true }, + "es6-error": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz", + "integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==", + "dev": true + }, + "escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "dev": true + }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, "exit": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", "dev": true }, + "find-cache-dir": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.2.tgz", + "integrity": "sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==", + "dev": true, + "requires": { + "commondir": "^1.0.1", + "make-dir": "^3.0.2", + "pkg-dir": "^4.1.0" + } + }, + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "foreground-child": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-2.0.0.tgz", + "integrity": "sha512-dCIq9FpEcyQyXKCkyzmlPTFNgrCzPudOe+mhvJU5zAtlBnGVy2yKxtfsxK2tQBThwq225jcvBjpw1Gr40uzZCA==", + "dev": true, + "requires": { + "cross-spawn": "^7.0.0", + "signal-exit": "^3.0.2" + } + }, + "fromentries": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/fromentries/-/fromentries-1.3.2.tgz", + "integrity": "sha512-cHEpEQHUg0f8XdtZCc2ZAhrHzKzT0MrFUTcvx+hfxYu7rGMDc5SKoXFh+n4YigxsHXRzc6OrCshdR1bWH6HHyg==", + "dev": true + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, + "gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "dev": true + }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true + }, + "get-package-type": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", + "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", + "dev": true + }, "glob": { "version": "7.1.7", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", @@ -247,6 +796,18 @@ "path-is-absolute": "^1.0.0" } }, + "globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true + }, + "graceful-fs": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz", + "integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==", + "dev": true + }, "growl": { "version": "1.10.5", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", @@ -259,12 +820,28 @@ "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true }, + "hasha": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/hasha/-/hasha-5.2.2.tgz", + "integrity": "sha512-Hrp5vIK/xr5SkeN2onO32H0MgNZ0f17HRNH39WfL0SYUNOTZ5Lz1TJ8Pajo/87dYGEFlLMm7mIc/k/s6Bvz9HQ==", + "dev": true, + "requires": { + "is-stream": "^2.0.0", + "type-fest": "^0.8.0" + } + }, "he": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", "dev": true }, + "html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true + }, "htmlparser2": { "version": "3.8.3", "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz", @@ -278,6 +855,18 @@ "readable-stream": "1.1" } }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "dev": true + }, + "indent-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", + "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "dev": true + }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -294,17 +883,183 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true + }, "is-generator": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/is-generator/-/is-generator-1.0.3.tgz", "integrity": "sha1-wUwhBX7TbjKNuANHlmxpP4hjifM=" }, + "is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", + "dev": true + }, + "is-windows": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", + "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", + "dev": true + }, "isarray": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", "dev": true }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "istanbul-lib-coverage": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.0.0.tgz", + "integrity": "sha512-UiUIqxMgRDET6eR+o5HbfRYP1l0hqkWOs7vNxC/mggutCMUIhWMm8gAHb8tHlyfD3/l6rlgNA5cKdDzEAf6hEg==", + "dev": true + }, + "istanbul-lib-hook": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-hook/-/istanbul-lib-hook-3.0.0.tgz", + "integrity": "sha512-Pt/uge1Q9s+5VAZ+pCo16TYMWPBIl+oaNIjgLQxcX0itS6ueeaA+pEfThZpH8WxhFgCiEb8sAJY6MdUKgiIWaQ==", + "dev": true, + "requires": { + "append-transform": "^2.0.0" + } + }, + "istanbul-lib-instrument": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-4.0.3.tgz", + "integrity": "sha512-BXgQl9kf4WTCPCCpmFGoJkz/+uhvm7h7PFKUYxh7qarQd3ER33vHG//qaE8eN25l07YqZPpHXU9I09l/RD5aGQ==", + "dev": true, + "requires": { + "@babel/core": "^7.7.5", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-coverage": "^3.0.0", + "semver": "^6.3.0" + } + }, + "istanbul-lib-processinfo": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-processinfo/-/istanbul-lib-processinfo-2.0.2.tgz", + "integrity": "sha512-kOwpa7z9hme+IBPZMzQ5vdQj8srYgAtaRqeI48NGmAQ+/5yKiHLV0QbYqQpxsdEF0+w14SoB8YbnHKcXE2KnYw==", + "dev": true, + "requires": { + "archy": "^1.0.0", + "cross-spawn": "^7.0.0", + "istanbul-lib-coverage": "^3.0.0-alpha.1", + "make-dir": "^3.0.0", + "p-map": "^3.0.0", + "rimraf": "^3.0.0", + "uuid": "^3.3.3" + } + }, + "istanbul-lib-report": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", + "integrity": "sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw==", + "dev": true, + "requires": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^3.0.0", + "supports-color": "^7.1.0" + }, + "dependencies": { + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "istanbul-lib-source-maps": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.0.tgz", + "integrity": "sha512-c16LpFRkR8vQXyHZ5nLpY35JZtzj1PQY1iZmesUbf1FZHbIupcWfjgOXBY9YHkLEQ6puz1u4Dgj6qmU/DisrZg==", + "dev": true, + "requires": { + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0", + "source-map": "^0.6.1" + }, + "dependencies": { + "debug": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", + "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } + }, + "istanbul-reports": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.0.3.tgz", + "integrity": "sha512-0i77ZFLsb9U3DHi22WzmIngVzfoyxxbQcZRqlF3KoKmCJGq9nhFHoGi8FqBztN2rE8w6hURnZghetn0xpkVb6A==", + "dev": true, + "requires": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + } + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsesc": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", + "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "dev": true + }, "jshint": { "version": "2.13.0", "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.13.0.tgz", @@ -329,23 +1084,64 @@ } } }, + "json5": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz", + "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==", + "dev": true, + "requires": { + "minimist": "^1.2.5" + }, + "dependencies": { + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true + } + } + }, "just-extend": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.1.0.tgz", "integrity": "sha512-ApcjaOdVTJ7y4r08xI5wIqpvwS48Q0PBG4DJROcEkH1f8MdAiNFyFxz3xoL0LWAVwjrwPYZdVHHxhRHcx/uGLA==", "dev": true }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, "lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, + "lodash.flattendeep": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", + "integrity": "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=", + "dev": true + }, "lolex": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/lolex/-/lolex-4.2.0.tgz", "integrity": "sha512-gKO5uExCXvSm6zbF562EvM+rd1kQDnB9AZBbiQVzf1ZmdDpxUSvpnAaVOP83N/31mRK8Ml8/VE8DMvsAZQ+7wg==", "dev": true }, + "make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, + "requires": { + "semver": "^6.0.0" + } + }, "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -453,6 +1249,56 @@ } } }, + "node-preload": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/node-preload/-/node-preload-0.2.1.tgz", + "integrity": "sha512-RM5oyBy45cLEoHqCeh+MNuFAxO0vTFBLskvQbOKnEE7YTTSN4tbN8QWDIPQ6L+WvKsB/qLEGpYe2ZZ9d4W9OIQ==", + "dev": true, + "requires": { + "process-on-spawn": "^1.0.0" + } + }, + "node-releases": { + "version": "1.1.77", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.77.tgz", + "integrity": "sha512-rB1DUFUNAN4Gn9keO2K1efO35IDK7yKHCdCaIMvFO7yUYmmZYeDjnGKle26G4rwj+LKRQpjyUUvMkPglwGCYNQ==", + "dev": true + }, + "nyc": { + "version": "15.1.0", + "resolved": "https://registry.npmjs.org/nyc/-/nyc-15.1.0.tgz", + "integrity": "sha512-jMW04n9SxKdKi1ZMGhvUTHBN0EICCRkHemEoE5jm6mTYcqcdas0ATzgUgejlQUHMvpnOZqGB5Xxsv9KxJW1j8A==", + "dev": true, + "requires": { + "@istanbuljs/load-nyc-config": "^1.0.0", + "@istanbuljs/schema": "^0.1.2", + "caching-transform": "^4.0.0", + "convert-source-map": "^1.7.0", + "decamelize": "^1.2.0", + "find-cache-dir": "^3.2.0", + "find-up": "^4.1.0", + "foreground-child": "^2.0.0", + "get-package-type": "^0.1.0", + "glob": "^7.1.6", + "istanbul-lib-coverage": "^3.0.0", + "istanbul-lib-hook": "^3.0.0", + "istanbul-lib-instrument": "^4.0.0", + "istanbul-lib-processinfo": "^2.0.2", + "istanbul-lib-report": "^3.0.0", + "istanbul-lib-source-maps": "^4.0.0", + "istanbul-reports": "^3.0.2", + "make-dir": "^3.0.0", + "node-preload": "^0.2.1", + "p-map": "^3.0.0", + "process-on-spawn": "^1.0.0", + "resolve-from": "^5.0.0", + "rimraf": "^3.0.0", + "signal-exit": "^3.0.2", + "spawn-wrap": "^2.0.0", + "test-exclude": "^6.0.0", + "yargs": "^15.0.2" + } + }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -462,12 +1308,69 @@ "wrappy": "1" } }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + }, + "p-map": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-map/-/p-map-3.0.0.tgz", + "integrity": "sha512-d3qXVTF/s+W+CdJ5A29wywV2n8CQQYahlgz2bFiA+4eVNJbHJodPZ+/gXwPGh0bOqA+j8S+6+ckmvLGPk1QpxQ==", + "dev": true, + "requires": { + "aggregate-error": "^3.0.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, + "package-hash": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/package-hash/-/package-hash-4.0.0.tgz", + "integrity": "sha512-whdkPIooSu/bASggZ96BWVvZTRMOFxnyUG5PnTSGKoJE2gd5mbVNmR2Nj20QFzxYYgAXpoqC+AiXzl+UMRh7zQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.15", + "hasha": "^5.0.0", + "lodash.flattendeep": "^4.4.0", + "release-zalgo": "^1.0.0" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + }, "path-to-regexp": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz", @@ -477,6 +1380,30 @@ "isarray": "0.0.1" } }, + "picocolors": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-0.2.1.tgz", + "integrity": "sha512-cMlDqaLEqfSaW8Z7N5Jw+lyIW869EzT73/F5lhtY9cLGoVxSXznfgfXMO0Z5K0o0Q2TkTXq+0KFsdnSe3jDViA==", + "dev": true + }, + "pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "requires": { + "find-up": "^4.0.0" + } + }, + "process-on-spawn": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/process-on-spawn/-/process-on-spawn-1.0.0.tgz", + "integrity": "sha512-1WsPDsUSMmZH5LeMLegqkPDrsGgsWwk1Exipy2hvB0o/F0ASzbpIctSCcZIK1ykJvtTJULEH+20WOFjMvGnCTg==", + "dev": true, + "requires": { + "fromentries": "^1.2.0" + } + }, "promisify-any": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/promisify-any/-/promisify-any-2.0.1.tgz", @@ -506,11 +1433,74 @@ "string_decoder": "~0.10.x" } }, + "release-zalgo": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/release-zalgo/-/release-zalgo-1.0.0.tgz", + "integrity": "sha1-CXALflB0Mpc5Mw5TXFqQ+2eFFzA=", + "dev": true, + "requires": { + "es6-error": "^4.0.1" + } + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "dev": true + }, + "require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "dev": true + }, + "resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true + }, + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "dev": true + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true + }, "shelljs": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.3.0.tgz", @@ -571,6 +1561,12 @@ "integrity": "sha512-oXF8tfxx5cDk8r2kYqlkUJzZpDBqVY/II2WhvU0n9Y3XYvAYRmeaf1PvvIvTgPnv4KJ+ES5M0PyDq5Jp+Ygy2g==", "dev": true }, + "signal-exit": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.5.tgz", + "integrity": "sha512-KWcOiKeQj6ZyXx7zq4YxSMgHRlod4czeBQZrPb8OKcohcqAXShm7E20kEMle9WBt26hFcAf0qLOcp5zmY7kOqQ==", + "dev": true + }, "sinon": { "version": "7.5.0", "resolved": "https://registry.npmjs.org/sinon/-/sinon-7.5.0.tgz", @@ -597,17 +1593,69 @@ } } }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + }, + "spawn-wrap": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/spawn-wrap/-/spawn-wrap-2.0.0.tgz", + "integrity": "sha512-EeajNjfN9zMnULLwhZZQU3GWBoFNkbngTUPfaawT4RkMiviTxcX0qfhVbGey39mfctfDHkWtuecgQ8NJcyQWHg==", + "dev": true, + "requires": { + "foreground-child": "^2.0.0", + "is-windows": "^1.0.2", + "make-dir": "^3.0.0", + "rimraf": "^3.0.0", + "signal-exit": "^3.0.2", + "which": "^2.0.1" + } + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, "statuses": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" }, + "string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + } + }, "string_decoder": { "version": "0.10.31", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", "dev": true }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.1" + } + }, + "strip-bom": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", + "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", + "dev": true + }, "strip-json-comments": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", @@ -623,12 +1671,35 @@ "has-flag": "^3.0.0" } }, + "test-exclude": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, + "requires": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + } + }, + "to-fast-properties": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", + "dev": true + }, "type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", "dev": true }, + "type-fest": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", + "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "dev": true + }, "type-is": { "version": "1.6.18", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", @@ -638,11 +1709,125 @@ "mime-types": "~2.1.24" } }, + "typedarray-to-buffer": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", + "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", + "dev": true, + "requires": { + "is-typedarray": "^1.0.0" + } + }, + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "dev": true + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "dev": true + }, + "wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "dev": true, + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + } + } + }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true + }, + "write-file-atomic": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz", + "integrity": "sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==", + "dev": true, + "requires": { + "imurmurhash": "^0.1.4", + "is-typedarray": "^1.0.0", + "signal-exit": "^3.0.2", + "typedarray-to-buffer": "^3.1.5" + } + }, + "y18n": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", + "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", + "dev": true + }, + "yargs": { + "version": "15.4.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", + "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", + "dev": true, + "requires": { + "cliui": "^6.0.0", + "decamelize": "^1.2.0", + "find-up": "^4.1.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^4.2.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^18.1.2" + } + }, + "yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } } } } diff --git a/package.json b/package.json index 07ddd233b..daaa09c64 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "devDependencies": { "jshint": "2.13.0", "mocha": "5.2.0", + "nyc": "^15.1.0", "should": "13.2.3", "sinon": "7.5.0" }, @@ -38,7 +39,8 @@ "scripts": { "pretest": "jshint --config ./.jshintrc lib test", "test": "NODE_ENV=test ./node_modules/.bin/mocha 'test/**/*_test.js'", - "test-debug": "NODE_ENV=test ./node_modules/.bin/mocha --inspect --debug-brk 'test/**/*_test.js'" + "test-debug": "NODE_ENV=test ./node_modules/.bin/mocha --inspect --debug-brk 'test/**/*_test.js'", + "test:coverage": "NODE_ENV=test nyc --reporter=html --reporter=text ./node_modules/.bin/mocha 'test/**/*_test.js'" }, "repository": { "type": "git", From a88bb4d4070dfefd66b40dcc7ca2b10d86322374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Sun, 10 Oct 2021 14:53:28 +0200 Subject: [PATCH 07/99] Create tests.yml --- .github/workflows/tests.yml | 74 +++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 000000000..b77f68762 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,74 @@ +name: Test suite + +on: + push: + branches: + - master # allthough master is push protected we still keep it + - dev + pull_request: # runs on all PR + +jobs: + # ---------------------------------- + # uncomment when a linter is added + # ---------------------------------- + + # lintjs: + # name: Javascript lint + # runs-on: ubuntu-latest + # steps: + # - name: checkout + # uses: actions/checkout@v2 + # + # - name: setup node + # uses: actions/setup-node@v1 + # with: + # node-version: '12.x' + # + # - name: cache dependencies + # uses: actions/cache@v1 + # with: + # path: ~/.npm + # key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + # restore-keys: | + # ${{ runner.os }}-node- + # - run: npm ci + # - run: npm run lint + + unittest: + name: unit tests + runs-on: ubuntu-latest + # uncomment when a linter is added + # needs: [lintjs] + steps: + - name: checkout + uses: actions/checkout@v2 + + - name: setup node + uses: actions/setup-node@v1 + with: + node-version: '12.x' + + - name: cache dependencies + uses: actions/cache@v1 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + - run: npm ci + - run: npm run test + # uncomment when coverage is added + - run: npm run test:coverage + + # ---------------------------------- + # uncomment when a linter is added + # ---------------------------------- + + # - name: check coverage + # uses: devmasx/coverage-check-action@v1.2.0 + # with: + # type: lcov + # result_path: coverage/lcov.info + # min_coverage: 90 + # token: ${{github.token}} + From 917b4b9011c637647e02bb507864e4e87a944093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Sun, 10 Oct 2021 14:57:24 +0200 Subject: [PATCH 08/99] uncomment line for coverage test until cov is added --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b77f68762..ddb46cc8e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -58,7 +58,7 @@ jobs: - run: npm ci - run: npm run test # uncomment when coverage is added - - run: npm run test:coverage + # - run: npm run test:coverage # ---------------------------------- # uncomment when a linter is added From dcd8a3df7d833f066bbc507fa23e2792012def6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Sun, 10 Oct 2021 15:14:56 +0200 Subject: [PATCH 09/99] ci change push branch dev to development --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ddb46cc8e..2bc278608 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,7 +4,7 @@ on: push: branches: - master # allthough master is push protected we still keep it - - dev + - development pull_request: # runs on all PR jobs: From 4a9eb7b22674ab87513c6e92012bf22a268847d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Sun, 10 Oct 2021 17:57:10 +0200 Subject: [PATCH 10/99] docs: added contribution guide draft --- CONTRIBUTING.md | 119 ++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 12 ++--- 2 files changed, 123 insertions(+), 8 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..2a87c4727 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,119 @@ +# Contributing to @node-oauth/oauth2-server + +Thank you for your interest in this project and your aims to improving it. +This guide will give you the most important info on how to contribute properly +in order to get your pull requests accepted. + +## Disclose security vulnerabilities + +First things first: +This project has strong security implications and we appreciate every help to +improve security. + +**However, please read our [security policy](./SECURITY.md), before taking +actions.** + +## Development + +If you want to fix bugs or add new features, please clone the source via + +```bash +$ npm run test +``` + +### No PR without issue + +Please make sure your commitment will be appreciated by first opening an issue +and discuss, whether this is a useful addition to the project. + + +### Run the tests + +Please always make sure your code is passing linter and tests **before** +committing. By doing so you help to make reviews much easier and don't pollute +the history with commits, that are solely targeting lint fixes. + +You can run the tests via + +```bash +$ npm run test +``` + +or + +```bash +$ npm run test:coverage +``` + +to see your coverage. + +### Open a pull request (PR) + +Once you have implemented your changes and tested them locally, please open +a [pull request](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request). + +Note: sometimes a pull request (PR) is also referred to as merge request (MR). + +#### Fundamental PR requirements + +There are a few basic requirements for your pull request to become accepted: + +- Make sure to open your pull request to target the `development` branch and not +`master` +- Make sure you are working on a branch, other than `development`; usually you + can name the branch after the feature or fix you want to provide +- Resolve any merge conflicts (usually by keeping your branch updated with + `development`) +- Have a clear description on what the PR does, including any steps necessary + for testing, reviewing, reproduction etc. +- Link to the existing issue +- Added functions or changed functions need to get documented in compliance with + JSDoc +- Make sure all CI Tests are passing + +Also make sure, to comply with the following list: + +- Do not work on `development` directly +- Do not implement multiple features in one pull request (this includes bumping + versions of dependencies that are not related to the PR/issue) +- Do not bump the release version (unless you are a maintainer) +- Do not edit the Changelog as this will be done after your PR is merged +- Do not introduce tight dependencies to a certain package that has not been + approved during the discussion in the issue + +#### Review process + +Finally your PR needs to pass the review process: + +- A certain amount of maintainers needs to review and accept your PR +- Please **expect change requests**! They will occur and are intended to improve + the overall code quality. +- If your changes have been updated please re-assign the reviewer who asked for + the changes +- Once all reviewers have approved your PR it will be merged by one of the + maintainers :tada: + +## For maintainers + +### When to release a new version? + +- on fixed vulnerabilities +- on fixed dependency-vulnerabilites +- on new added features +- what else? + +### When to decide between major, minor and path release? + +- major = breaking +- minor = features and security fixes +- patch = general fixes and small improvements + +### How to release a new version? + +What's required to publish to npm, which branches are involved, what should not +be done etc. + +## Become a maintainer + +What is required to become a maintainer? + \ No newline at end of file diff --git a/README.md b/README.md index 3862c3ef7..1dd27cd0c 100644 --- a/README.md +++ b/README.md @@ -40,12 +40,8 @@ This module has been rewritten using a promise-based approach, introducing chang Please refer to our [3.0 migration guide](https://oauth2-server.readthedocs.io/en/latest/misc/migrating-v2-to-v3.html) for more information. +## Contributing to this project -## Tests - -To run the test suite, install dependencies, then run `npm test`: - -```bash -npm install -npm test -``` +Please read our [contribution guide](./CONTRIBUTING.md) before taking actions. +In any case, please open an issue before opening a pull request to find out, +whether your intend to contribute will actually have a chance to be merged. From 534b5e7f21ccf036eb1e7d96ffbc02726e62d325 Mon Sep 17 00:00:00 2001 From: HappyZombies Date: Sun, 10 Oct 2021 18:08:01 -0400 Subject: [PATCH 11/99] Remove statuses, use http.STATUS_CODES --- lib/errors/oauth-error.js | 4 ++-- package-lock.json | 5 ----- package.json | 1 - 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/errors/oauth-error.js b/lib/errors/oauth-error.js index cd7d33930..a388cd358 100644 --- a/lib/errors/oauth-error.js +++ b/lib/errors/oauth-error.js @@ -5,7 +5,7 @@ */ var _ = require('lodash'); var util = require('util'); -var statuses = require('statuses'); +var http = require('http'); /** * Constructor. */ @@ -24,7 +24,7 @@ function OAuthError(messageOrError, properties) { properties.inner = error; } if (_.isEmpty(message)) { - message = statuses[properties.code]; + message = http.STATUS_CODES[properties.code]; } this.code = this.status = this.statusCode = properties.code; this.message = message; diff --git a/package-lock.json b/package-lock.json index 37b5a3c89..affd508b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1619,11 +1619,6 @@ "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, - "statuses": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", - "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" - }, "string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", diff --git a/package.json b/package.json index daaa09c64..2e35c20e6 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,6 @@ "bluebird": "3.7.2", "lodash": "4.17.21", "promisify-any": "2.0.1", - "statuses": "1.5.0", "type-is": "1.6.18" }, "devDependencies": { From 172203985021418b87f416786983a9f4d2556a59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Mon, 11 Oct 2021 09:48:56 +0200 Subject: [PATCH 12/99] updated development guidelines --- CONTRIBUTING.md | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2a87c4727..13ce4a856 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,22 +15,44 @@ actions.** ## Development -If you want to fix bugs or add new features, please clone the source via - -```bash -$ npm run test -``` +If you want to fix bugs or add new features, **please read this chapter and it's +sections carefully!** ### No PR without issue Please make sure your commitment will be appreciated by first opening an issue and discuss, whether this is a useful addition to the project. +### Work on a bug or a new feature -### Run the tests +First, clone and install this project from source via -Please always make sure your code is passing linter and tests **before** -committing. By doing so you help to make reviews much easier and don't pollute +```bash +$ git clone git@github.com:node-oauth/node-oauth2-server.git +$ cd node-oauth2-server +$ git checkout developmemt # important! do not work on master! +$ npm install +``` + +From here you can run several scripts for development purposes: + +```bash +$ npm run lint # runs the linter +$ npm run tets # runs the tests once +$ npm run tests:coverage # runs the tests including coverage +$ npm run docs # generates the API docs +``` + +To work on a new feature or a fix please create a new branch: + +```bash +$ git checkout -b feature-xyz # or fix-xyz +``` + +### Run the tests before committing + +Please always make sure your code is passing linter and tests **before +committing**. By doing so you help to make reviews much easier and don't pollute the history with commits, that are solely targeting lint fixes. You can run the tests via @@ -95,6 +117,9 @@ Finally your PR needs to pass the review process: ## For maintainers +Maintainers of this repository have an extended responsibility for security and +integrity. Therefore you have to take extra care on preparing publishing. + ### When to release a new version? - on fixed vulnerabilities From 6a0c93c06af8afbfae8e1d059c7a6d5bfd32182f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Mon, 11 Oct 2021 10:26:01 +0200 Subject: [PATCH 13/99] contribution guidelines added guiding principles --- CONTRIBUTING.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 13ce4a856..e81dd21a7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,6 +13,26 @@ improve security. **However, please read our [security policy](./SECURITY.md), before taking actions.** + + +## Guiding principles + +Before contributing to this project it is important to understand how this +project and it's collaborators views itself regarding it's scope and purpose. + +### OAuth2 standard compliance + +This project aims full standard compliance. All improvements on functionality, +as well as security implications, are done in a way that the standard remains +as the highest reference of choice. + +### Framework agnostic + +Design decisions and implementations are always done with keeping in mind, that +there are multiple frameworks out there that use this project. + + + ## Development If you want to fix bugs or add new features, **please read this chapter and it's @@ -115,6 +135,8 @@ Finally your PR needs to pass the review process: - Once all reviewers have approved your PR it will be merged by one of the maintainers :tada: + + ## For maintainers Maintainers of this repository have an extended responsibility for security and From c833a373854e4376ea2300c1664d3e772fe6e61c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Mon, 11 Oct 2021 10:28:14 +0200 Subject: [PATCH 14/99] pull request template added --- .github/PULL_REQUEST_TEMPLATE.md | 65 ++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..987e9093f --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,65 @@ + + +## Summary + + + + +## Linked issue(s) + + + + +## Involved parts of the project + + + + +## Added tests? + + + + +## OAuth2 standard + + + + +## Reproduction + + From de41dc7c5fe8e5a3cd1d78ae65e3fd78bfce09c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Mon, 11 Oct 2021 15:08:25 +0200 Subject: [PATCH 15/99] docs removed maintainers section from contribution guide --- CONTRIBUTING.md | 41 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e81dd21a7..6b3471c94 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,6 +26,18 @@ This project aims full standard compliance. All improvements on functionality, as well as security implications, are done in a way that the standard remains as the highest reference of choice. +If you are not familiar with the OAuth2 standards, please consult at least the +following documents: + +- [RFC 6749 - The OAuth 2.0 Authorization Framework](https://datatracker.ietf.org/doc/html/rfc6749) +- [RFC 8252 - OAuth 2.0 for Native Apps](https://datatracker.ietf.org/doc/html/rfc8252) + +Extended readings: + +- [RFC 6819 - OAuth 2.0 Threat Model and Security Considerations](https://datatracker.ietf.org/doc/html/rfc6819) +- [RFC 7636 - Proof Key for Code Exchange by OAuth Public Clients](https://datatracker.ietf.org/doc/html/rfc7636) +- [RFC 7591 - OAuth 2.0 Dynamic Client Registration Protocol](https://datatracker.ietf.org/doc/html/rfc7591) + ### Framework agnostic Design decisions and implementations are always done with keeping in mind, that @@ -134,33 +146,4 @@ Finally your PR needs to pass the review process: the changes - Once all reviewers have approved your PR it will be merged by one of the maintainers :tada: - - - -## For maintainers - -Maintainers of this repository have an extended responsibility for security and -integrity. Therefore you have to take extra care on preparing publishing. - -### When to release a new version? - -- on fixed vulnerabilities -- on fixed dependency-vulnerabilites -- on new added features -- what else? - -### When to decide between major, minor and path release? - -- major = breaking -- minor = features and security fixes -- patch = general fixes and small improvements - -### How to release a new version? - -What's required to publish to npm, which branches are involved, what should not -be done etc. - -## Become a maintainer - -What is required to become a maintainer? \ No newline at end of file From e650264958384b280d3fb5ab21a8888272f34348 Mon Sep 17 00:00:00 2001 From: Jonah Werre Date: Mon, 11 Oct 2021 09:32:03 -0600 Subject: [PATCH 16/99] removed jshint added eslint --- .eslintrc | 47 ++ .jshintignore | 1 - .jshintrc | 26 - .../authorization-code-grant-type.js | 24 +- package-lock.json | 710 ++++++++++++++++++ package.json | 3 +- .../handlers/authorize-handler_test.js | 16 +- .../handlers/token-handler_test.js | 14 +- test/integration/server_test.js | 2 +- test/unit/models/token-model_test.js | 8 +- test/unit/response_test.js | 20 +- 11 files changed, 801 insertions(+), 70 deletions(-) create mode 100644 .eslintrc delete mode 100644 .jshintignore delete mode 100644 .jshintrc diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 000000000..a4ac22030 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,47 @@ +{ + "extends": "eslint:recommended", + "env": { + "node": true, + "mocha": true, + "es6": true + }, + "parserOptions": { + "ecmaVersion": 9, + "sourceType": "module", + "ecmaFeatures" : { + "globalReturn": false, + "impliedStrict": true, + "jsx": false + } + }, + "rules": { + "indent": [ + "error", + 2 + ], + "linebreak-style": [ + "error", + "unix" + ], + "quotes": [ + "error", + "single" + ], + "semi": [ + "error", + "always" + ], + "no-control-regex": "off", + "no-prototype-builtins": "off", + "no-console": "off", + "no-unused-vars": [ + "error", + { + "vars": "all", + "args": "none", + "ignoreRestSiblings": false + } + ] + } + } + \ No newline at end of file diff --git a/.jshintignore b/.jshintignore deleted file mode 100644 index 3c3629e64..000000000 --- a/.jshintignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 441e9934f..000000000 --- a/.jshintrc +++ /dev/null @@ -1,26 +0,0 @@ -{ - "bitwise": true, - "curly": true, - "eqeqeq": true, - "esnext": true, - "expr": true, - "globalstrict": false, - "immed": true, - "indent": 2, - "jquery": true, - "latedef": false, - "mocha": true, - "newcap": true, - "noarg": true, - "node": true, - "noyield": true, - "predef": ["-Promise"], - "quotmark": "single", - "regexp": true, - "smarttabs": true, - "strict": false, - "trailing": false, - "undef": true, - "unused": true, - "white": false -} diff --git a/lib/grant-types/authorization-code-grant-type.js b/lib/grant-types/authorization-code-grant-type.js index 7eae70f8f..97c126793 100644 --- a/lib/grant-types/authorization-code-grant-type.js +++ b/lib/grant-types/authorization-code-grant-type.js @@ -133,21 +133,21 @@ AuthorizationCodeGrantType.prototype.getAuthorizationCode = function(request, cl * @see https://tools.ietf.org/html/rfc6749#section-4.1.3 */ - AuthorizationCodeGrantType.prototype.validateRedirectUri = function(request, code) { - if (!code.redirectUri) { - return; - } +AuthorizationCodeGrantType.prototype.validateRedirectUri = function(request, code) { + if (!code.redirectUri) { + return; + } - var redirectUri = request.body.redirect_uri || request.query.redirect_uri; + var redirectUri = request.body.redirect_uri || request.query.redirect_uri; - if (!is.uri(redirectUri)) { - throw new InvalidRequestError('Invalid request: `redirect_uri` is not a valid URI'); - } + if (!is.uri(redirectUri)) { + throw new InvalidRequestError('Invalid request: `redirect_uri` is not a valid URI'); + } - if (redirectUri !== code.redirectUri) { - throw new InvalidRequestError('Invalid request: `redirect_uri` is invalid'); - } - }; + if (redirectUri !== code.redirectUri) { + throw new InvalidRequestError('Invalid request: `redirect_uri` is invalid'); + } +}; /** * Revoke the authorization code. diff --git a/package-lock.json b/package-lock.json index 3eb1e4284..f91d3906e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,90 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@eslint/eslintrc": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.0.2.tgz", + "integrity": "sha512-x1ZXdEFsvTcnbTZgqcWUL9w2ybgZCw/qbKTPQnab+XnYA2bMQpJCh+/bBzCRfDJaJdlrrQlOk49jNtru9gL/6Q==", + "dev": true, + "requires": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^9.0.0", + "globals": "^13.9.0", + "ignore": "^4.0.6", + "import-fresh": "^3.2.1", + "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", + "strip-json-comments": "^3.1.1" + }, + "dependencies": { + "debug": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", + "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true + } + } + }, + "@humanwhocodes/config-array": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.6.0.tgz", + "integrity": "sha512-JQlEKbcgEUjBFhLIF4iqM7u/9lwgHRBcpHrmUNCALK0Q3amXN6lxdoXLnF0sm11E9VqTmBALR87IlUg1bZ8A9A==", + "dev": true, + "requires": { + "@humanwhocodes/object-schema": "^1.2.0", + "debug": "^4.1.1", + "minimatch": "^3.0.4" + }, + "dependencies": { + "debug": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", + "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } + } + }, + "@humanwhocodes/object-schema": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.0.tgz", + "integrity": "sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==", + "dev": true + }, "@sinonjs/commons": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.0.tgz", @@ -40,6 +124,60 @@ "integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==", "dev": true }, + "acorn": { + "version": "8.5.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.5.0.tgz", + "integrity": "sha512-yXbYeFy+jUuYd3/CDcg2NkIYE991XYX/bje7LmjJigUciaeO1JR4XxXgCIV1/Zc/dRuFEyw1L0pbA+qynJkW5Q==", + "dev": true + }, + "acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true + }, + "ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "dev": true + }, + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, "array-from": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/array-from/-/array-from-2.1.1.tgz", @@ -81,6 +219,39 @@ "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, + "callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "dependencies": { + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, "cli": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cli/-/cli-1.0.1.tgz", @@ -112,6 +283,21 @@ "resolved": "https://registry.npmjs.org/co-use/-/co-use-1.1.0.tgz", "integrity": "sha1-xrs83xDLc17Kqdru2kbXJclKTmI=" }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, "commander": { "version": "2.15.1", "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", @@ -139,6 +325,17 @@ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, + "cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, "date-now": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", @@ -154,12 +351,27 @@ "ms": "2.0.0" } }, + "deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true + }, "diff": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", "dev": true }, + "doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dev": true, + "requires": { + "esutils": "^2.0.2" + } + }, "dom-serializer": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.2.2.tgz", @@ -209,6 +421,15 @@ "domelementtype": "1" } }, + "enquirer": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz", + "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==", + "dev": true, + "requires": { + "ansi-colors": "^4.1.1" + } + }, "entities": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz", @@ -221,18 +442,222 @@ "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true }, + "eslint": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.0.0.tgz", + "integrity": "sha512-03spzPzMAO4pElm44m60Nj08nYonPGQXmw6Ceai/S4QK82IgwWO1EXx1s9namKzVlbVu3Jf81hb+N+8+v21/HQ==", + "dev": true, + "requires": { + "@eslint/eslintrc": "^1.0.2", + "@humanwhocodes/config-array": "^0.6.0", + "ajv": "^6.10.0", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", + "doctrine": "^3.0.0", + "enquirer": "^2.3.5", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^6.0.0", + "eslint-utils": "^3.0.0", + "eslint-visitor-keys": "^3.0.0", + "espree": "^9.0.0", + "esquery": "^1.4.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^6.0.1", + "functional-red-black-tree": "^1.0.1", + "glob-parent": "^6.0.1", + "globals": "^13.6.0", + "ignore": "^4.0.6", + "import-fresh": "^3.0.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "js-yaml": "^4.1.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.0.4", + "natural-compare": "^1.4.0", + "optionator": "^0.9.1", + "progress": "^2.0.0", + "regexpp": "^3.2.0", + "semver": "^7.2.1", + "strip-ansi": "^6.0.0", + "strip-json-comments": "^3.1.0", + "text-table": "^0.2.0", + "v8-compile-cache": "^2.0.3" + }, + "dependencies": { + "debug": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", + "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true + } + } + }, + "eslint-scope": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-6.0.0.tgz", + "integrity": "sha512-uRDL9MWmQCkaFus8RF5K9/L/2fn+80yoW3jkD53l4shjCh26fCtvJGasxjUqP5OT87SYTxCVA3BwTUzuELx9kA==", + "dev": true, + "requires": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + } + }, + "eslint-utils": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", + "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^2.0.0" + }, + "dependencies": { + "eslint-visitor-keys": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", + "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", + "dev": true + } + } + }, + "eslint-visitor-keys": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.0.0.tgz", + "integrity": "sha512-mJOZa35trBTb3IyRmo8xmKBZlxf+N7OnUl4+ZhJHs/r+0770Wh/LEACE2pqMGMe27G/4y8P2bYGk4J70IC5k1Q==", + "dev": true + }, + "espree": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.0.0.tgz", + "integrity": "sha512-r5EQJcYZ2oaGbeR0jR0fFVijGOcwai07/690YRXLINuhmVeRY4UKSAsQPe/0BNuDgwP7Ophoc1PRsr2E3tkbdQ==", + "dev": true, + "requires": { + "acorn": "^8.5.0", + "acorn-jsx": "^5.3.1", + "eslint-visitor-keys": "^3.0.0" + } + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, + "esquery": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", + "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", + "dev": true, + "requires": { + "estraverse": "^5.1.0" + } + }, + "esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "requires": { + "estraverse": "^5.2.0" + } + }, + "estraverse": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", + "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", + "dev": true + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true + }, "exit": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", "dev": true }, + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, + "fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true + }, + "fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "dev": true + }, + "file-entry-cache": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", + "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", + "dev": true, + "requires": { + "flat-cache": "^3.0.4" + } + }, + "flat-cache": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", + "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", + "dev": true, + "requires": { + "flatted": "^3.1.0", + "rimraf": "^3.0.2" + } + }, + "flatted": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.2.tgz", + "integrity": "sha512-JaTY/wtrcSyvXJl4IMFHPKyFur1sE9AUqc0QnhOaJ0CxHtAoIV8pYDzeEfAaNEtGkOfq4gr3LBFmdXW5mOQFnA==", + "dev": true + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, + "functional-red-black-tree": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", + "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", + "dev": true + }, "glob": { "version": "7.1.7", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", @@ -247,6 +672,24 @@ "path-is-absolute": "^1.0.0" } }, + "glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "requires": { + "is-glob": "^4.0.3" + } + }, + "globals": { + "version": "13.11.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.11.0.tgz", + "integrity": "sha512-08/xrJ7wQjK9kkkRoI3OFUBbLx4f+6x3SGwcPvQ0QH6goFDrOU2oyAWrmh3dJezu65buo+HBMzAMQy6rovVC3g==", + "dev": true, + "requires": { + "type-fest": "^0.20.2" + } + }, "growl": { "version": "1.10.5", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", @@ -278,6 +721,28 @@ "readable-stream": "1.1" } }, + "ignore": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", + "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "dev": true + }, + "import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dev": true, + "requires": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + } + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "dev": true + }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -294,17 +759,55 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, "is-generator": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/is-generator/-/is-generator-1.0.3.tgz", "integrity": "sha1-wUwhBX7TbjKNuANHlmxpP4hjifM=" }, + "is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + }, "isarray": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", "dev": true }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "requires": { + "argparse": "^2.0.1" + }, + "dependencies": { + "argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + } + } + }, "jshint": { "version": "2.13.0", "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.13.0.tgz", @@ -329,23 +832,60 @@ } } }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "dev": true + }, "just-extend": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.1.0.tgz", "integrity": "sha512-ApcjaOdVTJ7y4r08xI5wIqpvwS48Q0PBG4DJROcEkH1f8MdAiNFyFxz3xoL0LWAVwjrwPYZdVHHxhRHcx/uGLA==", "dev": true }, + "levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "requires": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + } + }, "lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, + "lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true + }, "lolex": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/lolex/-/lolex-4.2.0.tgz", "integrity": "sha512-gKO5uExCXvSm6zbF562EvM+rd1kQDnB9AZBbiQVzf1ZmdDpxUSvpnAaVOP83N/31mRK8Ml8/VE8DMvsAZQ+7wg==", "dev": true }, + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "requires": { + "yallist": "^4.0.0" + } + }, "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -429,6 +969,12 @@ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, + "natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "dev": true + }, "nise": { "version": "1.5.3", "resolved": "https://registry.npmjs.org/nise/-/nise-1.5.3.tgz", @@ -462,12 +1008,41 @@ "wrappy": "1" } }, + "optionator": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", + "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", + "dev": true, + "requires": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.3" + } + }, + "parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "requires": { + "callsites": "^3.0.0" + } + }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + }, "path-to-regexp": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz", @@ -477,6 +1052,18 @@ "isarray": "0.0.1" } }, + "prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true + }, + "progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", + "dev": true + }, "promisify-any": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/promisify-any/-/promisify-any-2.0.1.tgz", @@ -494,6 +1081,12 @@ } } }, + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true + }, "readable-stream": { "version": "1.1.14", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", @@ -506,11 +1099,56 @@ "string_decoder": "~0.10.x" } }, + "regexpp": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", + "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", + "dev": true + }, + "resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true + }, + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, + "semver": { + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true + }, "shelljs": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.3.0.tgz", @@ -597,6 +1235,12 @@ } } }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, "statuses": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", @@ -608,6 +1252,15 @@ "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", "dev": true }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.1" + } + }, "strip-json-comments": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", @@ -623,12 +1276,33 @@ "has-flag": "^3.0.0" } }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "dev": true + }, + "type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "requires": { + "prelude-ls": "^1.2.1" + } + }, "type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", "dev": true }, + "type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "dev": true + }, "type-is": { "version": "1.6.18", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", @@ -638,11 +1312,47 @@ "mime-types": "~2.1.24" } }, + "uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "requires": { + "punycode": "^2.1.0" + } + }, + "v8-compile-cache": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", + "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", + "dev": true + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "word-wrap": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", + "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "dev": true + }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true } } } diff --git a/package.json b/package.json index 07ddd233b..0e61b468f 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "type-is": "1.6.18" }, "devDependencies": { + "eslint": "^8.0.0", "jshint": "2.13.0", "mocha": "5.2.0", "should": "13.2.3", @@ -36,7 +37,7 @@ "node": ">=4.0" }, "scripts": { - "pretest": "jshint --config ./.jshintrc lib test", + "pretest": "./node_modules/.bin/eslint lib test index.js", "test": "NODE_ENV=test ./node_modules/.bin/mocha 'test/**/*_test.js'", "test-debug": "NODE_ENV=test ./node_modules/.bin/mocha --inspect --debug-brk 'test/**/*_test.js'" }, diff --git a/test/integration/handlers/authorize-handler_test.js b/test/integration/handlers/authorize-handler_test.js index f895f82e3..037e1f403 100644 --- a/test/integration/handlers/authorize-handler_test.js +++ b/test/integration/handlers/authorize-handler_test.js @@ -1124,10 +1124,10 @@ describe('AuthorizeHandler integration', function() { describe('with `response_type` in the request body', function() { it('should return a response type', function() { var model = { - getAccessToken: function() {}, - getClient: function() {}, - saveAuthorizationCode: function() {} - }; + getAccessToken: function() {}, + getClient: function() {}, + saveAuthorizationCode: function() {} + }; var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); var request = new Request({ body: { response_type: 'code' }, headers: {}, method: {}, query: {} }); var ResponseType = handler.getResponseType(request); @@ -1139,10 +1139,10 @@ describe('AuthorizeHandler integration', function() { describe('with `response_type` in the request query', function() { it('should return a response type', function() { var model = { - getAccessToken: function() {}, - getClient: function() {}, - saveAuthorizationCode: function() {} - }; + getAccessToken: function() {}, + getClient: function() {}, + saveAuthorizationCode: function() {} + }; var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); var request = new Request({ body: {}, headers: {}, method: {}, query: { response_type: 'code' } }); var ResponseType = handler.getResponseType(request); diff --git a/test/integration/handlers/token-handler_test.js b/test/integration/handlers/token-handler_test.js index 50277c113..6a5ff5400 100644 --- a/test/integration/handlers/token-handler_test.js +++ b/test/integration/handlers/token-handler_test.js @@ -542,7 +542,7 @@ describe('TokenHandler integration', function() { requireClientAuthentication: { password: false } - }); + }); var request = new Request({ body: { client_id: 'blah', grant_type: 'password'}, headers: {}, method: {}, query: {} }); return handler.getClient(request) @@ -569,13 +569,13 @@ describe('TokenHandler integration', function() { requireClientAuthentication: { password: false } - }); + }); var request = new Request({ - body: { grant_type: 'password'}, - headers: { 'authorization': util.format('Basic %s', new Buffer('blah:').toString('base64')) }, - method: {}, - query: {} - }); + body: { grant_type: 'password'}, + headers: { 'authorization': util.format('Basic %s', new Buffer('blah:').toString('base64')) }, + method: {}, + query: {} + }); return handler.getClient(request) .then(function(data) { diff --git a/test/integration/server_test.js b/test/integration/server_test.js index 2d3aa7845..8042c0eef 100644 --- a/test/integration/server_test.js +++ b/test/integration/server_test.js @@ -225,7 +225,7 @@ describe('Server integration', function() { return { accessToken: 1234, client: {}, user: {} }; }, validateScope: function() { - return 'foo'; + return 'foo'; } }; var server = new Server({ model: model }); diff --git a/test/unit/models/token-model_test.js b/test/unit/models/token-model_test.js index 3d899951c..c968282c1 100644 --- a/test/unit/models/token-model_test.js +++ b/test/unit/models/token-model_test.js @@ -11,10 +11,10 @@ describe('Model', function() { atExpiresAt.setHours(new Date().getHours() + 1); var data = { - accessToken: 'foo', - client: 'bar', - user: 'tar', - accessTokenExpiresAt: atExpiresAt + accessToken: 'foo', + client: 'bar', + user: 'tar', + accessTokenExpiresAt: atExpiresAt }; var model = new TokenModel(data); diff --git a/test/unit/response_test.js b/test/unit/response_test.js index c435e32f7..d226df673 100644 --- a/test/unit/response_test.js +++ b/test/unit/response_test.js @@ -107,14 +107,14 @@ describe('Request', function() { response.headers.newheader.should.eql('newvalue'); }); - it('should process redirect', function() { - var originalResponse = generateBaseResponse(); - - var response = new Response(originalResponse); - response.headers.should.eql(originalResponse.headers); - response.status.should.eql(200); - response.redirect('http://foo.bar'); - response.headers.location.should.eql('http://foo.bar'); - response.status.should.eql(302); - }); + it('should process redirect', function() { + var originalResponse = generateBaseResponse(); + + var response = new Response(originalResponse); + response.headers.should.eql(originalResponse.headers); + response.status.should.eql(200); + response.redirect('http://foo.bar'); + response.headers.location.should.eql('http://foo.bar'); + response.status.should.eql(302); + }); }); From 18d2404ec7233ff0e937fc7426c63a2ba179ff91 Mon Sep 17 00:00:00 2001 From: Jonah Werre Date: Mon, 11 Oct 2021 10:25:19 -0600 Subject: [PATCH 17/99] removed should added chai --- package-lock.json | 101 ++++++++---------- package.json | 2 +- test/assertions.js | 14 +-- .../grant-types/abstract-grant-type_test.js | 2 +- .../authorization-code-grant-type_test.js | 2 +- .../client-credentials-grant-type_test.js | 2 +- .../grant-types/password-grant-type_test.js | 2 +- .../refresh-token-grant-type_test.js | 2 +- .../handlers/authenticate-handler_test.js | 2 +- .../handlers/authorize-handler_test.js | 2 +- .../handlers/token-handler_test.js | 10 +- test/integration/request_test.js | 2 +- .../response-types/code-response-type_test.js | 2 +- test/integration/server_test.js | 2 +- .../token-types/bearer-token-type_test.js | 2 +- test/integration/utils/token-util_test.js | 2 +- test/mocha.opts | 1 - .../grant-types/abstract-grant-type_test.js | 2 +- .../authorization-code-grant-type_test.js | 2 +- .../client-credentials-grant-type_test.js | 2 +- .../grant-types/password-grant-type_test.js | 2 +- .../refresh-token-grant-type_test.js | 2 +- .../handlers/authenticate-handler_test.js | 2 +- test/unit/handlers/authorize-handler_test.js | 2 +- test/unit/handlers/token-handler_test.js | 2 +- test/unit/models/token-model_test.js | 5 +- test/unit/request_test.js | 2 +- test/unit/response_test.js | 2 +- 28 files changed, 86 insertions(+), 91 deletions(-) diff --git a/package-lock.json b/package-lock.json index affd508b1..b749db8b3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -389,6 +389,12 @@ "integrity": "sha1-z+nYwmYoudxa7MYqn12PHzUsEZU=", "dev": true }, + "assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "dev": true + }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", @@ -461,6 +467,20 @@ "integrity": "sha512-YzBnspggWV5hep1m9Z6sZVLOt7vrju8xWooFAgN6BA5qvy98qPAPb7vNUzypFaoh2pb3vlfzbDO8tB57UPGbtw==", "dev": true }, + "chai": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.4.tgz", + "integrity": "sha512-yS5H68VYOCtN1cjfwumDSuzn/9c+yza4f3reKXlE5rUg7SFcCEy90gJvydNgOYtblyf4Zi6jIWRnXOgErta0KA==", + "dev": true, + "requires": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^3.0.1", + "get-func-name": "^2.0.0", + "pathval": "^1.1.1", + "type-detect": "^4.0.5" + } + }, "chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", @@ -472,6 +492,12 @@ "supports-color": "^5.3.0" } }, + "check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "dev": true + }, "clean-stack": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", @@ -609,6 +635,15 @@ "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", "dev": true }, + "deep-eql": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", + "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "dev": true, + "requires": { + "type-detect": "^4.0.0" + } + }, "default-require-extensions": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/default-require-extensions/-/default-require-extensions-3.0.0.tgz", @@ -776,6 +811,12 @@ "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true }, + "get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", + "dev": true + }, "get-package-type": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", @@ -1380,6 +1421,12 @@ "isarray": "0.0.1" } }, + "pathval": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", + "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", + "dev": true + }, "picocolors": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-0.2.1.tgz", @@ -1507,60 +1554,6 @@ "integrity": "sha1-NZbmMHp4FUT1kfN9phg2DzHbV7E=", "dev": true }, - "should": { - "version": "13.2.3", - "resolved": "https://registry.npmjs.org/should/-/should-13.2.3.tgz", - "integrity": "sha512-ggLesLtu2xp+ZxI+ysJTmNjh2U0TsC+rQ/pfED9bUZZ4DKefP27D+7YJVVTvKsmjLpIi9jAa7itwDGkDDmt1GQ==", - "dev": true, - "requires": { - "should-equal": "^2.0.0", - "should-format": "^3.0.3", - "should-type": "^1.4.0", - "should-type-adaptors": "^1.0.1", - "should-util": "^1.0.0" - } - }, - "should-equal": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/should-equal/-/should-equal-2.0.0.tgz", - "integrity": "sha512-ZP36TMrK9euEuWQYBig9W55WPC7uo37qzAEmbjHz4gfyuXrEUgF8cUvQVO+w+d3OMfPvSRQJ22lSm8MQJ43LTA==", - "dev": true, - "requires": { - "should-type": "^1.4.0" - } - }, - "should-format": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/should-format/-/should-format-3.0.3.tgz", - "integrity": "sha1-m/yPdPo5IFxT04w01xcwPidxJPE=", - "dev": true, - "requires": { - "should-type": "^1.3.0", - "should-type-adaptors": "^1.0.1" - } - }, - "should-type": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/should-type/-/should-type-1.4.0.tgz", - "integrity": "sha1-B1bYzoRt/QmEOmlHcZ36DUz/XPM=", - "dev": true - }, - "should-type-adaptors": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/should-type-adaptors/-/should-type-adaptors-1.1.0.tgz", - "integrity": "sha512-JA4hdoLnN+kebEp2Vs8eBe9g7uy0zbRo+RMcU0EsNy+R+k049Ki+N5tT5Jagst2g7EAja+euFuoXFCa8vIklfA==", - "dev": true, - "requires": { - "should-type": "^1.3.0", - "should-util": "^1.0.0" - } - }, - "should-util": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/should-util/-/should-util-1.0.1.tgz", - "integrity": "sha512-oXF8tfxx5cDk8r2kYqlkUJzZpDBqVY/II2WhvU0n9Y3XYvAYRmeaf1PvvIvTgPnv4KJ+ES5M0PyDq5Jp+Ygy2g==", - "dev": true - }, "signal-exit": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.5.tgz", diff --git a/package.json b/package.json index 2e35c20e6..a03c2e55e 100644 --- a/package.json +++ b/package.json @@ -25,10 +25,10 @@ "type-is": "1.6.18" }, "devDependencies": { + "chai": "^4.3.4", "jshint": "2.13.0", "mocha": "5.2.0", "nyc": "^15.1.0", - "should": "13.2.3", "sinon": "7.5.0" }, "license": "MIT", diff --git a/test/assertions.js b/test/assertions.js index 6846e3cdf..8e107859d 100644 --- a/test/assertions.js +++ b/test/assertions.js @@ -4,14 +4,16 @@ * Module dependencies. */ -var should = require('should'); +var chai = require('chai'); /** * SHA-1 assertion. */ +chai.use(function (_chai, utils) { -should.Assertion.add('sha1', function() { - this.params = { operator: 'to be a valid SHA-1 hash' }; - - this.obj.should.match(/^[a-f0-9]{40}$/i); -}, true); + utils.addMethod(chai.Assertion.prototype, 'sha1', function () { + var obj = utils.flag(this, 'object'); + new chai.Assertion(obj).match(/^[a-f0-9]{40}$/i); + }); + +}); diff --git a/test/integration/grant-types/abstract-grant-type_test.js b/test/integration/grant-types/abstract-grant-type_test.js index 6da489cd9..f292af8ea 100644 --- a/test/integration/grant-types/abstract-grant-type_test.js +++ b/test/integration/grant-types/abstract-grant-type_test.js @@ -8,7 +8,7 @@ var AbstractGrantType = require('../../../lib/grant-types/abstract-grant-type'); var InvalidArgumentError = require('../../../lib/errors/invalid-argument-error'); var Promise = require('bluebird'); var Request = require('../../../lib/request'); -var should = require('should'); +var should = require('chai').should(); /** * Test `AbstractGrantType` integration. diff --git a/test/integration/grant-types/authorization-code-grant-type_test.js b/test/integration/grant-types/authorization-code-grant-type_test.js index 7f84e3443..417a23ab6 100644 --- a/test/integration/grant-types/authorization-code-grant-type_test.js +++ b/test/integration/grant-types/authorization-code-grant-type_test.js @@ -11,7 +11,7 @@ var InvalidRequestError = require('../../../lib/errors/invalid-request-error'); var Promise = require('bluebird'); var Request = require('../../../lib/request'); var ServerError = require('../../../lib/errors/server-error'); -var should = require('should'); +var should = require('chai').should(); /** * Test `AuthorizationCodeGrantType` integration. diff --git a/test/integration/grant-types/client-credentials-grant-type_test.js b/test/integration/grant-types/client-credentials-grant-type_test.js index 15ec9cc0e..3bddec8eb 100644 --- a/test/integration/grant-types/client-credentials-grant-type_test.js +++ b/test/integration/grant-types/client-credentials-grant-type_test.js @@ -9,7 +9,7 @@ var InvalidArgumentError = require('../../../lib/errors/invalid-argument-error') var InvalidGrantError = require('../../../lib/errors/invalid-grant-error'); var Promise = require('bluebird'); var Request = require('../../../lib/request'); -var should = require('should'); +var should = require('chai').should(); /** * Test `ClientCredentialsGrantType` integration. diff --git a/test/integration/grant-types/password-grant-type_test.js b/test/integration/grant-types/password-grant-type_test.js index 9cdf50dd5..916355dd4 100644 --- a/test/integration/grant-types/password-grant-type_test.js +++ b/test/integration/grant-types/password-grant-type_test.js @@ -10,7 +10,7 @@ var InvalidRequestError = require('../../../lib/errors/invalid-request-error'); var PasswordGrantType = require('../../../lib/grant-types/password-grant-type'); var Promise = require('bluebird'); var Request = require('../../../lib/request'); -var should = require('should'); +var should = require('chai').should(); /** * Test `PasswordGrantType` integration. diff --git a/test/integration/grant-types/refresh-token-grant-type_test.js b/test/integration/grant-types/refresh-token-grant-type_test.js index 925396afe..cbc294706 100644 --- a/test/integration/grant-types/refresh-token-grant-type_test.js +++ b/test/integration/grant-types/refresh-token-grant-type_test.js @@ -11,7 +11,7 @@ var Promise = require('bluebird'); var RefreshTokenGrantType = require('../../../lib/grant-types/refresh-token-grant-type'); var Request = require('../../../lib/request'); var ServerError = require('../../../lib/errors/server-error'); -var should = require('should'); +var should = require('chai').should(); /** * Test `RefreshTokenGrantType` integration. diff --git a/test/integration/handlers/authenticate-handler_test.js b/test/integration/handlers/authenticate-handler_test.js index 7852ea2eb..1e98a62a4 100644 --- a/test/integration/handlers/authenticate-handler_test.js +++ b/test/integration/handlers/authenticate-handler_test.js @@ -15,7 +15,7 @@ var Request = require('../../../lib/request'); var Response = require('../../../lib/response'); var ServerError = require('../../../lib/errors/server-error'); var UnauthorizedRequestError = require('../../../lib/errors/unauthorized-request-error'); -var should = require('should'); +var should = require('chai').should(); /** * Test `AuthenticateHandler` integration. diff --git a/test/integration/handlers/authorize-handler_test.js b/test/integration/handlers/authorize-handler_test.js index f895f82e3..ae0e41ee2 100644 --- a/test/integration/handlers/authorize-handler_test.js +++ b/test/integration/handlers/authorize-handler_test.js @@ -18,7 +18,7 @@ var Request = require('../../../lib/request'); var Response = require('../../../lib/response'); var ServerError = require('../../../lib/errors/server-error'); var UnauthorizedClientError = require('../../../lib/errors/unauthorized-client-error'); -var should = require('should'); +var should = require('chai').should(); var url = require('url'); /** diff --git a/test/integration/handlers/token-handler_test.js b/test/integration/handlers/token-handler_test.js index 50277c113..26c218664 100644 --- a/test/integration/handlers/token-handler_test.js +++ b/test/integration/handlers/token-handler_test.js @@ -18,7 +18,7 @@ var ServerError = require('../../../lib/errors/server-error'); var TokenHandler = require('../../../lib/handlers/token-handler'); var UnauthorizedClientError = require('../../../lib/errors/unauthorized-client-error'); var UnsupportedGrantTypeError = require('../../../lib/errors/unsupported-grant-type-error'); -var should = require('should'); +var should = require('chai').should(); var util = require('util'); /** @@ -121,8 +121,8 @@ describe('TokenHandler integration', function() { saveToken: function() {} }; var handler = new TokenHandler({ accessTokenLifetime: 120, extendedGrantTypes: extendedGrantTypes, model: model, refreshTokenLifetime: 120 }); - - handler.grantTypes.should.containEql(extendedGrantTypes); + console.log(handler.grantTypes); + handler.grantTypes.should.deep.include(extendedGrantTypes); }); it('should set the `model`', function() { @@ -997,8 +997,8 @@ describe('TokenHandler integration', function() { }; var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); var tokenType = handler.getTokenType({ accessToken: 'foo', refreshToken: 'bar', scope: 'foobar' }); - - tokenType.should.containEql({ accessToken: 'foo', accessTokenLifetime: undefined, refreshToken: 'bar', scope: 'foobar' }); + console.log(tokenType); + tokenType.should.deep.include({ accessToken: 'foo', accessTokenLifetime: undefined, refreshToken: 'bar', scope: 'foobar' }); }); }); diff --git a/test/integration/request_test.js b/test/integration/request_test.js index a43527671..a62309d93 100644 --- a/test/integration/request_test.js +++ b/test/integration/request_test.js @@ -6,7 +6,7 @@ var Request = require('../../lib/request'); var InvalidArgumentError = require('../../lib/errors/invalid-argument-error'); -var should = require('should'); +var should = require('chai').should(); /** * Test `Request` integration. diff --git a/test/integration/response-types/code-response-type_test.js b/test/integration/response-types/code-response-type_test.js index 5461b62c4..e03b4a225 100644 --- a/test/integration/response-types/code-response-type_test.js +++ b/test/integration/response-types/code-response-type_test.js @@ -6,7 +6,7 @@ var CodeResponseType = require('../../../lib/response-types/code-response-type'); var InvalidArgumentError = require('../../../lib/errors/invalid-argument-error'); -var should = require('should'); +var should = require('chai').should(); var url = require('url'); /** diff --git a/test/integration/server_test.js b/test/integration/server_test.js index 2d3aa7845..8baaae032 100644 --- a/test/integration/server_test.js +++ b/test/integration/server_test.js @@ -9,7 +9,7 @@ var Promise = require('bluebird'); var Request = require('../../lib/request'); var Response = require('../../lib/response'); var Server = require('../../lib/server'); -var should = require('should'); +var should = require('chai').should(); /** * Test `Server` integration. diff --git a/test/integration/token-types/bearer-token-type_test.js b/test/integration/token-types/bearer-token-type_test.js index 3c1ef6bdd..c8ad306db 100644 --- a/test/integration/token-types/bearer-token-type_test.js +++ b/test/integration/token-types/bearer-token-type_test.js @@ -6,7 +6,7 @@ var BearerTokenType = require('../../../lib/token-types/bearer-token-type'); var InvalidArgumentError = require('../../../lib/errors/invalid-argument-error'); -var should = require('should'); +var should = require('chai').should(); /** * Test `BearerTokenType` integration. diff --git a/test/integration/utils/token-util_test.js b/test/integration/utils/token-util_test.js index 3fbca3f65..e0608e2f0 100644 --- a/test/integration/utils/token-util_test.js +++ b/test/integration/utils/token-util_test.js @@ -5,7 +5,7 @@ */ var TokenUtil = require('../../../lib/utils/token-util'); -var should = require('should'); +var should = require('chai').should(); /** * Test `TokenUtil` integration. diff --git a/test/mocha.opts b/test/mocha.opts index 00ecb38eb..859c1da79 100644 --- a/test/mocha.opts +++ b/test/mocha.opts @@ -1,4 +1,3 @@ ---require should --require test/assertions --ui bdd --reporter spec diff --git a/test/unit/grant-types/abstract-grant-type_test.js b/test/unit/grant-types/abstract-grant-type_test.js index 528ca4041..d2ccf72ac 100644 --- a/test/unit/grant-types/abstract-grant-type_test.js +++ b/test/unit/grant-types/abstract-grant-type_test.js @@ -6,7 +6,7 @@ var AbstractGrantType = require('../../../lib/grant-types/abstract-grant-type'); var sinon = require('sinon'); -var should = require('should'); +var should = require('chai').should(); /** * Test `AbstractGrantType`. diff --git a/test/unit/grant-types/authorization-code-grant-type_test.js b/test/unit/grant-types/authorization-code-grant-type_test.js index 480416e68..a9220cb3b 100644 --- a/test/unit/grant-types/authorization-code-grant-type_test.js +++ b/test/unit/grant-types/authorization-code-grant-type_test.js @@ -8,7 +8,7 @@ var AuthorizationCodeGrantType = require('../../../lib/grant-types/authorization var Promise = require('bluebird'); var Request = require('../../../lib/request'); var sinon = require('sinon'); -var should = require('should'); +var should = require('chai').should(); /** * Test `AuthorizationCodeGrantType`. diff --git a/test/unit/grant-types/client-credentials-grant-type_test.js b/test/unit/grant-types/client-credentials-grant-type_test.js index fe1fc4840..4b1c8b6b1 100644 --- a/test/unit/grant-types/client-credentials-grant-type_test.js +++ b/test/unit/grant-types/client-credentials-grant-type_test.js @@ -6,7 +6,7 @@ var ClientCredentialsGrantType = require('../../../lib/grant-types/client-credentials-grant-type'); var sinon = require('sinon'); -var should = require('should'); +var should = require('chai').should(); /** * Test `ClientCredentialsGrantType`. diff --git a/test/unit/grant-types/password-grant-type_test.js b/test/unit/grant-types/password-grant-type_test.js index 8e3bfc84e..c99c2ef53 100644 --- a/test/unit/grant-types/password-grant-type_test.js +++ b/test/unit/grant-types/password-grant-type_test.js @@ -7,7 +7,7 @@ var PasswordGrantType = require('../../../lib/grant-types/password-grant-type'); var Request = require('../../../lib/request'); var sinon = require('sinon'); -var should = require('should'); +var should = require('chai').should(); /** * Test `PasswordGrantType`. diff --git a/test/unit/grant-types/refresh-token-grant-type_test.js b/test/unit/grant-types/refresh-token-grant-type_test.js index e5693ba8f..5775f43f1 100644 --- a/test/unit/grant-types/refresh-token-grant-type_test.js +++ b/test/unit/grant-types/refresh-token-grant-type_test.js @@ -7,7 +7,7 @@ var RefreshTokenGrantType = require('../../../lib/grant-types/refresh-token-grant-type'); var Request = require('../../../lib/request'); var sinon = require('sinon'); -var should = require('should'); +var should = require('chai').should(); /** * Test `RefreshTokenGrantType`. diff --git a/test/unit/handlers/authenticate-handler_test.js b/test/unit/handlers/authenticate-handler_test.js index 2adac7884..c2800028b 100644 --- a/test/unit/handlers/authenticate-handler_test.js +++ b/test/unit/handlers/authenticate-handler_test.js @@ -7,7 +7,7 @@ var AuthenticateHandler = require('../../../lib/handlers/authenticate-handler'); var Request = require('../../../lib/request'); var sinon = require('sinon'); -var should = require('should'); +var should = require('chai').should(); var ServerError = require('../../../lib/errors/server-error'); /** diff --git a/test/unit/handlers/authorize-handler_test.js b/test/unit/handlers/authorize-handler_test.js index fe9b6b1d7..35ece25fa 100644 --- a/test/unit/handlers/authorize-handler_test.js +++ b/test/unit/handlers/authorize-handler_test.js @@ -9,7 +9,7 @@ var Request = require('../../../lib/request'); var Response = require('../../../lib/response'); var Promise = require('bluebird'); var sinon = require('sinon'); -var should = require('should'); +var should = require('chai').should(); /** * Test `AuthorizeHandler`. diff --git a/test/unit/handlers/token-handler_test.js b/test/unit/handlers/token-handler_test.js index 2b37cd05a..4dd219970 100644 --- a/test/unit/handlers/token-handler_test.js +++ b/test/unit/handlers/token-handler_test.js @@ -7,7 +7,7 @@ var Request = require('../../../lib/request'); var TokenHandler = require('../../../lib/handlers/token-handler'); var sinon = require('sinon'); -var should = require('should'); +var should = require('chai').should(); /** * Test `TokenHandler`. diff --git a/test/unit/models/token-model_test.js b/test/unit/models/token-model_test.js index 3d899951c..b4664fcd6 100644 --- a/test/unit/models/token-model_test.js +++ b/test/unit/models/token-model_test.js @@ -1,5 +1,5 @@ var TokenModel = require('../../../lib/models/token-model'); - +var should = require('chai').should(); /** * Test `Server`. */ @@ -18,7 +18,8 @@ describe('Model', function() { }; var model = new TokenModel(data); - model.accessTokenLifetime.should.be.Number; + should.exist(model.accessTokenLifetime); + model.accessTokenLifetime.should.a('number'); model.accessTokenLifetime.should.be.approximately(3600, 2); }); }); diff --git a/test/unit/request_test.js b/test/unit/request_test.js index 458cb8f9e..a86005a9c 100644 --- a/test/unit/request_test.js +++ b/test/unit/request_test.js @@ -5,7 +5,7 @@ */ var Request = require('../../lib/request'); -var should = require('should'); +var should = require('chai').should(); /** * Test `Request`. diff --git a/test/unit/response_test.js b/test/unit/response_test.js index c435e32f7..9d6b8a6d2 100644 --- a/test/unit/response_test.js +++ b/test/unit/response_test.js @@ -5,7 +5,7 @@ */ var Response = require('../../lib/response'); -var should = require('should'); +var should = require('chai').should(); /** * Test `Request`. From 05b89447c309e751b464fa00a2c83dfa27547c5c Mon Sep 17 00:00:00 2001 From: Jonah Werre Date: Mon, 11 Oct 2021 10:28:52 -0600 Subject: [PATCH 18/99] removed some log statements --- test/integration/handlers/token-handler_test.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/integration/handlers/token-handler_test.js b/test/integration/handlers/token-handler_test.js index 26c218664..82574c98f 100644 --- a/test/integration/handlers/token-handler_test.js +++ b/test/integration/handlers/token-handler_test.js @@ -121,7 +121,6 @@ describe('TokenHandler integration', function() { saveToken: function() {} }; var handler = new TokenHandler({ accessTokenLifetime: 120, extendedGrantTypes: extendedGrantTypes, model: model, refreshTokenLifetime: 120 }); - console.log(handler.grantTypes); handler.grantTypes.should.deep.include(extendedGrantTypes); }); @@ -997,7 +996,6 @@ describe('TokenHandler integration', function() { }; var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); var tokenType = handler.getTokenType({ accessToken: 'foo', refreshToken: 'bar', scope: 'foobar' }); - console.log(tokenType); tokenType.should.deep.include({ accessToken: 'foo', accessTokenLifetime: undefined, refreshToken: 'bar', scope: 'foobar' }); }); }); From 0cf3b11bebd9f24c89efcd52902e76de7da32196 Mon Sep 17 00:00:00 2001 From: Jonah Werre Date: Mon, 11 Oct 2021 12:51:28 -0600 Subject: [PATCH 19/99] removed 'no-prototype-builtins' from eslint --- .eslintrc | 1 - lib/models/token-model.js | 2 +- lib/token-types/bearer-token-type.js | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.eslintrc b/.eslintrc index a4ac22030..879dff451 100644 --- a/.eslintrc +++ b/.eslintrc @@ -32,7 +32,6 @@ "always" ], "no-control-regex": "off", - "no-prototype-builtins": "off", "no-console": "off", "no-unused-vars": [ "error", diff --git a/lib/models/token-model.js b/lib/models/token-model.js index c6bc3f8d4..37bb133e5 100644 --- a/lib/models/token-model.js +++ b/lib/models/token-model.js @@ -47,7 +47,7 @@ function TokenModel(data, options) { this.customAttributes = {}; for (var key in data) { - if (data.hasOwnProperty(key) && (modelAttributes.indexOf(key) < 0)) { + if ( Object.prototype.hasOwnProperty.call(data, key) && (modelAttributes.indexOf(key) < 0)) { this.customAttributes[key] = data[key]; } } diff --git a/lib/token-types/bearer-token-type.js b/lib/token-types/bearer-token-type.js index 9124cb2e8..944084959 100644 --- a/lib/token-types/bearer-token-type.js +++ b/lib/token-types/bearer-token-type.js @@ -48,7 +48,7 @@ BearerTokenType.prototype.valueOf = function() { } for (var key in this.customAttributes) { - if (this.customAttributes.hasOwnProperty(key)) { + if ( Object.prototype.hasOwnProperty.call(this.customAttributes, key) ) { object[key] = this.customAttributes[key]; } } From ca47721071129fff3e0837665ccd585dca127128 Mon Sep 17 00:00:00 2001 From: Serguei Okladnikov Date: Tue, 12 Oct 2021 10:40:48 +0300 Subject: [PATCH 20/99] docs: add commit message convention and coding rules --- CONTRIBUTING.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6b3471c94..41be0a5c7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -81,6 +81,22 @@ To work on a new feature or a fix please create a new branch: $ git checkout -b feature-xyz # or fix-xyz ``` +### Coding rules + +- Unit-testing: all features or bug fixes must be tested by specs +- Documentation: all public API methods must be documented + +### Commit message convention + +Commit title must meet [angular commit message format](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-commit-message-format) +with ticket number at the end of summary: + +``` +(): # +``` +Summary in present tense. Not capitalized. No period at the end. +The and fields are mandatory, the () and # field is optional. + ### Run the tests before committing Please always make sure your code is passing linter and tests **before From b4e344ddf4122185990376a9dbf19a68c6762287 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Tue, 12 Oct 2021 10:39:46 +0200 Subject: [PATCH 21/99] tests validator is tested for all unicode ranges --- lib/validator/is.js | 17 +++-- test/unit/validator/is_test.js | 125 +++++++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+), 5 deletions(-) create mode 100644 test/unit/validator/is_test.js diff --git a/lib/validator/is.js b/lib/validator/is.js index 07af6cb64..4766be468 100644 --- a/lib/validator/is.js +++ b/lib/validator/is.js @@ -5,10 +5,12 @@ */ var rules = { - NCHAR: /^[\u002D|\u002E|\u005F|\w]+$/, - NQCHAR: /^[\u0021|\u0023-\u005B|\u005D-\u007E]+$/, - NQSCHAR: /^[\u0020-\u0021|\u0023-\u005B|\u005D-\u007E]+$/, - UNICODECHARNOCRLF: /^[\u0009|\u0020-\u007E|\u0080-\uD7FF|\uE000-\uFFFD|\u10000-\u10FFFF]+$/, + NCHAR: /^[\u002D\u002E\u005F\w]+$/, + NQCHAR: /^[\u0021\u0023-\u005B\u005D-\u007E]+$/, + NQSCHAR: /^[\u0020-\u0021\u0023-\u005B\u005D-\u007E]+$/, + // note: \u10000-\u10FFFF is displayed by surrogate pairs + UNICODECHARNOCRLF: /^[\u0009\u0020-\u007E\u0080-\uD7FF\uE000-\uFFFD]+$/, + UNICODECHARNOCRLF_EXTENDED: /[\u{10000}-\u{10FFFF}]/u, URI: /^[a-zA-Z][a-zA-Z0-9+.-]+:/, VSCHAR: /^[\u0020-\u007E]+$/ }; @@ -57,7 +59,12 @@ module.exports = { */ uchar: function(value) { - return rules.UNICODECHARNOCRLF.test(value); + // manually test \u10000-\u10FFFF + if (rules.UNICODECHARNOCRLF.test(value)) { + return true; + } + + return .test(value); }, /** diff --git a/test/unit/validator/is_test.js b/test/unit/validator/is_test.js new file mode 100644 index 000000000..dff6a40fa --- /dev/null +++ b/test/unit/validator/is_test.js @@ -0,0 +1,125 @@ +var is = require('../../../lib/validator/is'); +require('should'); + +function runRanges (ranges, fn, expected) { + ranges.forEach(function (range) { + var lower = range[0]; + var upper = range[1]; + + for (var i = lower; i <= upper; i++) { + var unicodeChar = String.fromCodePoint(i); + var nchar = fn(unicodeChar); + nchar.should.eql(expected, i + ' ' + unicodeChar); + } + }); +} + +describe('Validator', function () { + describe('is', function () { + it('validates if a value matches a unicode character (nchar)', function () { + var validRanges = [ + [45, 46], // \u002D \u002E + [48, 57], // 0-9 + [65, 90], // A-Z + [95, 95], // \u005F + [97, 122] // a-z + ]; + + runRanges(validRanges, is.nchar, true); + + var invalidRanges = [ + [0, 44], + [47, 47], + [58, 64], + [91, 94], + [96, 96], + [123, 1023] + ]; + + runRanges(invalidRanges, is.nchar, false); + }); + it('validates if a value matches a unicode character, including exclamation marks (nqchar)', function () { + var validRanges = [ + [33, 33], // \u0021 + [35, 91], // \u0023-\u005B + [93, 126] // \u005D-\u007E + ]; + + runRanges(validRanges, is.nqchar, true); + + var invalidRanges = [ + [0, 32], + [34, 34], + [92, 92], + [127, 1023] + ]; + + runRanges(invalidRanges, is.nqchar, false); + }); + it('validates if a value matches a unicode character, including exclamation marks and spaces (nqschar)', function () { + var validRanges = [ + [32, 33], // \u0020-\u0021 + [35, 91], // \u0023-\u005B + [93, 126] // \u005D-\u007E + ]; + + runRanges(validRanges, is.nqschar, true); + + var invalidRanges = [ + [0, 31], + [34, 34], + [92, 92], + [127, 1023] + ]; + + runRanges(invalidRanges, is.nqschar, false); + }); + it('validates if a value matches a unicode character excluding the carriage return and linefeed characters (uchar)', function () { + this.timeout(10000); + var validRanges = [ + [9, 9], // \u0009 + [32, 126], // \u0020-\u007E, + [128, 55295], // \u0080-\uD7FF + [57344, 65533], // \uE000-\uFFFD + [65536, 1114111] // \u10000-\u10FFFF + ]; + + runRanges(validRanges, is.uchar, true); + + var invalidRanges = [ + [0, 8], + [10, 31], + [127, 127], + [55296, 57343], + [65534, 65535] + ]; + + runRanges(invalidRanges, is.uchar, false); + }); + it('validates if a value matches generic URIs (uri)', function () { + ['aa:', 'http:', 'https:'].forEach(function (uri) { + is.uri(uri).should.equal(true); + is.uri(uri.toUpperCase()).should.equal(true); + }); + + ['a', 'a:', 'http'].forEach(function (uri) { + is.uri(uri).should.equal(false); + is.uri(uri.toUpperCase()).should.equal(false); + }); + }); + it('validates if a value matches against the printable set of unicode characters (vschar)', function () { + var validRanges = [ + [32, 126] // \u0020-\u007E + ]; + + runRanges(validRanges, is.vschar, true); + + var invalidRanges = [ + [0, 31], + [127, 1023] + ]; + + runRanges(invalidRanges, is.vschar, false); + }); + }); +}); From f57f4c345eefe414592fd180d0162602295ef3e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Tue, 12 Oct 2021 10:42:32 +0200 Subject: [PATCH 22/99] validator is add missing variable in is.uchar --- lib/validator/is.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/validator/is.js b/lib/validator/is.js index 4766be468..a8715c305 100644 --- a/lib/validator/is.js +++ b/lib/validator/is.js @@ -64,7 +64,7 @@ module.exports = { return true; } - return .test(value); + return rules.UNICODECHARNOCRLF_EXTENDED.test(value); }, /** From 615bd75c95b74da2ae2ac499682f7157d1670491 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Tue, 12 Oct 2021 11:25:47 +0200 Subject: [PATCH 23/99] tests validator also test for multiple characters --- test/unit/validator/is_test.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/unit/validator/is_test.js b/test/unit/validator/is_test.js index dff6a40fa..d30adbcb2 100644 --- a/test/unit/validator/is_test.js +++ b/test/unit/validator/is_test.js @@ -8,8 +8,10 @@ function runRanges (ranges, fn, expected) { for (var i = lower; i <= upper; i++) { var unicodeChar = String.fromCodePoint(i); - var nchar = fn(unicodeChar); - nchar.should.eql(expected, i + ' ' + unicodeChar); + // single char + fn(unicodeChar).should.eql(expected, i + ' ' + unicodeChar); + // multiple chars + fn(unicodeChar+unicodeChar).should.eql(expected, i + ' ' + unicodeChar); } }); } @@ -75,7 +77,7 @@ describe('Validator', function () { runRanges(invalidRanges, is.nqschar, false); }); it('validates if a value matches a unicode character excluding the carriage return and linefeed characters (uchar)', function () { - this.timeout(10000); + this.timeout(15000); var validRanges = [ [9, 9], // \u0009 [32, 126], // \u0020-\u007E, From c0e4ef18f34d30a90b02472bcc6f7637d2baffbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Tue, 12 Oct 2021 11:26:19 +0200 Subject: [PATCH 24/99] eslint enable no-control-regex and disable only in validator --- .eslintrc | 1 - lib/validator/is.js | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.eslintrc b/.eslintrc index 879dff451..b0ccd9d23 100644 --- a/.eslintrc +++ b/.eslintrc @@ -31,7 +31,6 @@ "error", "always" ], - "no-control-regex": "off", "no-console": "off", "no-unused-vars": [ "error", diff --git a/lib/validator/is.js b/lib/validator/is.js index a8715c305..a240e936a 100644 --- a/lib/validator/is.js +++ b/lib/validator/is.js @@ -1,4 +1,5 @@ 'use strict'; +/* eslint-disable no-control-regex */ /** * Validation rules. @@ -8,13 +9,14 @@ var rules = { NCHAR: /^[\u002D\u002E\u005F\w]+$/, NQCHAR: /^[\u0021\u0023-\u005B\u005D-\u007E]+$/, NQSCHAR: /^[\u0020-\u0021\u0023-\u005B\u005D-\u007E]+$/, - // note: \u10000-\u10FFFF is displayed by surrogate pairs UNICODECHARNOCRLF: /^[\u0009\u0020-\u007E\u0080-\uD7FF\uE000-\uFFFD]+$/, - UNICODECHARNOCRLF_EXTENDED: /[\u{10000}-\u{10FFFF}]/u, + UNICODECHARNOCRLF_EXTENDED: /^[\u{10000}-\u{10FFFF}]+$/u, URI: /^[a-zA-Z][a-zA-Z0-9+.-]+:/, VSCHAR: /^[\u0020-\u007E]+$/ }; +/* eslint-enable no-control-regex */ + /** * Export validation functions. */ From 9775b39c094e50e7ed750837d9936d80050748ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Tue, 12 Oct 2021 11:29:12 +0200 Subject: [PATCH 25/99] tests validator is increase timeout --- test/unit/validator/is_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/validator/is_test.js b/test/unit/validator/is_test.js index d30adbcb2..347a471a8 100644 --- a/test/unit/validator/is_test.js +++ b/test/unit/validator/is_test.js @@ -77,7 +77,7 @@ describe('Validator', function () { runRanges(invalidRanges, is.nqschar, false); }); it('validates if a value matches a unicode character excluding the carriage return and linefeed characters (uchar)', function () { - this.timeout(15000); + this.timeout(60000); var validRanges = [ [9, 9], // \u0009 [32, 126], // \u0020-\u007E, From 60bad87693b2f53e279f66b97329e8e5494ab4e2 Mon Sep 17 00:00:00 2001 From: Serguei Okladnikov Date: Tue, 12 Oct 2021 13:04:16 +0300 Subject: [PATCH 26/99] docs: lightly softify commit convention requirements --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 41be0a5c7..3106d6040 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -88,7 +88,7 @@ $ git checkout -b feature-xyz # or fix-xyz ### Commit message convention -Commit title must meet [angular commit message format](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-commit-message-format) +We use a commit convention, inspired by [angular commit message format](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-commit-message-format) with ticket number at the end of summary: ``` From 5a98700e73c001cba1643fe3b391854649e72d2e Mon Sep 17 00:00:00 2001 From: HappyZombies Date: Tue, 12 Oct 2021 08:42:51 -0400 Subject: [PATCH 27/99] refactor: update mocha to latest version #17 --- package-lock.json | 527 +++++++++++++++++++++++++++++++++++++++++----- package.json | 2 +- 2 files changed, 476 insertions(+), 53 deletions(-) diff --git a/package-lock.json b/package-lock.json index affd508b1..af69a27b6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -334,6 +334,12 @@ "integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==", "dev": true }, + "@ungap/promise-all-settled": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", + "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==", + "dev": true + }, "aggregate-error": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz", @@ -344,6 +350,12 @@ "indent-string": "^4.0.0" } }, + "ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "dev": true + }, "ansi-regex": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", @@ -359,6 +371,16 @@ "color-convert": "^1.9.0" } }, + "anymatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", + "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", + "dev": true, + "requires": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + } + }, "append-transform": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/append-transform/-/append-transform-2.0.0.tgz", @@ -403,6 +425,12 @@ "safe-buffer": "5.1.2" } }, + "binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "dev": true + }, "bluebird": { "version": "3.7.2", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", @@ -418,6 +446,15 @@ "concat-map": "0.0.1" } }, + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "requires": { + "fill-range": "^7.0.1" + } + }, "browser-stdout": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", @@ -472,6 +509,22 @@ "supports-color": "^5.3.0" } }, + "chokidar": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.2.tgz", + "integrity": "sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==", + "dev": true, + "requires": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "fsevents": "~2.3.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + } + }, "clean-stack": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", @@ -535,12 +588,6 @@ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "dev": true }, - "commander": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", - "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", - "dev": true - }, "commondir": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", @@ -595,12 +642,20 @@ "dev": true }, "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", + "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", "dev": true, "requires": { - "ms": "2.0.0" + "ms": "2.1.2" + }, + "dependencies": { + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } } }, "decamelize": { @@ -721,6 +776,15 @@ "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", "dev": true }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "requires": { + "to-regex-range": "^5.0.1" + } + }, "find-cache-dir": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.2.tgz", @@ -742,6 +806,12 @@ "path-exists": "^4.0.0" } }, + "flat": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", + "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", + "dev": true + }, "foreground-child": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-2.0.0.tgz", @@ -764,6 +834,13 @@ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, + "fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "optional": true + }, "gensync": { "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", @@ -796,6 +873,15 @@ "path-is-absolute": "^1.0.0" } }, + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + }, "globals": { "version": "11.12.0", "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", @@ -831,9 +917,9 @@ } }, "he": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", - "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", "dev": true }, "html-escaper": { @@ -883,6 +969,21 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, + "is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "requires": { + "binary-extensions": "^2.0.0" + } + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, "is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", @@ -894,6 +995,27 @@ "resolved": "https://registry.npmjs.org/is-generator/-/is-generator-1.0.3.tgz", "integrity": "sha1-wUwhBX7TbjKNuANHlmxpP4hjifM=" }, + "is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true + }, + "is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", + "dev": true + }, "is-stream": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", @@ -906,6 +1028,12 @@ "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", "dev": true }, + "is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", + "dev": true + }, "is-windows": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", @@ -1127,6 +1255,67 @@ "integrity": "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=", "dev": true }, + "log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dev": true, + "requires": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, "lolex": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/lolex/-/lolex-4.2.0.tgz", @@ -1169,60 +1358,208 @@ "brace-expansion": "^1.1.7" } }, - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true - }, - "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "dev": true, - "requires": { - "minimist": "0.0.8" - } - }, "mocha": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", - "integrity": "sha1-bYrlCPWRZ/lA8rWzxKYSrlDJCuY=", + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.1.2.tgz", + "integrity": "sha512-ta3LtJ+63RIBP03VBjMGtSqbe6cWXRejF9SyM9Zyli1CKZJZ+vfCTj3oW24V7wAphMJdpOFLoMI3hjJ1LWbs0w==", "dev": true, "requires": { + "@ungap/promise-all-settled": "1.1.2", + "ansi-colors": "4.1.1", "browser-stdout": "1.3.1", - "commander": "2.15.1", - "debug": "3.1.0", - "diff": "3.5.0", - "escape-string-regexp": "1.0.5", - "glob": "7.1.2", + "chokidar": "3.5.2", + "debug": "4.3.2", + "diff": "5.0.0", + "escape-string-regexp": "4.0.0", + "find-up": "5.0.0", + "glob": "7.1.7", "growl": "1.10.5", - "he": "1.1.1", + "he": "1.2.0", + "js-yaml": "4.1.0", + "log-symbols": "4.1.0", "minimatch": "3.0.4", - "mkdirp": "0.5.1", - "supports-color": "5.4.0" + "ms": "2.1.3", + "nanoid": "3.1.25", + "serialize-javascript": "6.0.0", + "strip-json-comments": "3.1.1", + "supports-color": "8.1.1", + "which": "2.0.2", + "workerpool": "6.1.5", + "yargs": "16.2.0", + "yargs-parser": "20.2.4", + "yargs-unparser": "2.0.0" }, "dependencies": { - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, + "cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", "dev": true, "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "diff": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", + "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", + "dev": true + }, + "escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true + }, + "find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "requires": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + } + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "requires": { + "argparse": "^2.0.1" + } + }, + "locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "requires": { + "p-locate": "^5.0.0" + } + }, + "p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "requires": { + "yocto-queue": "^0.1.0" + } + }, + "p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "requires": { + "p-limit": "^3.0.2" + } + }, + "strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true + }, + "supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + }, + "wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + } + }, + "y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true + }, + "yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dev": true, + "requires": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + } + }, + "yargs-parser": { + "version": "20.2.4", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", + "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", + "dev": true } } }, "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, + "nanoid": { + "version": "3.1.25", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.25.tgz", + "integrity": "sha512-rdwtIXaXCLFAQbnfqDRnI6jaRHp9fTcYBjtFKE8eezcZ7LuLjhUaQGNeMXf1HmRoCH32CLz6XwX0TtxEOS/A3Q==", "dev": true }, "nise": { @@ -1264,6 +1601,12 @@ "integrity": "sha512-rB1DUFUNAN4Gn9keO2K1efO35IDK7yKHCdCaIMvFO7yUYmmZYeDjnGKle26G4rwj+LKRQpjyUUvMkPglwGCYNQ==", "dev": true }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true + }, "nyc": { "version": "15.1.0", "resolved": "https://registry.npmjs.org/nyc/-/nyc-15.1.0.tgz", @@ -1386,6 +1729,12 @@ "integrity": "sha512-cMlDqaLEqfSaW8Z7N5Jw+lyIW869EzT73/F5lhtY9cLGoVxSXznfgfXMO0Z5K0o0Q2TkTXq+0KFsdnSe3jDViA==", "dev": true }, + "picomatch": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", + "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==", + "dev": true + }, "pkg-dir": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", @@ -1421,6 +1770,15 @@ } } }, + "randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dev": true, + "requires": { + "safe-buffer": "^5.1.0" + } + }, "readable-stream": { "version": "1.1.14", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", @@ -1433,6 +1791,15 @@ "string_decoder": "~0.10.x" } }, + "readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "requires": { + "picomatch": "^2.2.1" + } + }, "release-zalgo": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/release-zalgo/-/release-zalgo-1.0.0.tgz", @@ -1480,6 +1847,15 @@ "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", "dev": true }, + "serialize-javascript": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", + "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", + "dev": true, + "requires": { + "randombytes": "^2.1.0" + } + }, "set-blocking": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", @@ -1683,6 +2059,15 @@ "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", "dev": true }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "requires": { + "is-number": "^7.0.0" + } + }, "type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", @@ -1734,6 +2119,12 @@ "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", "dev": true }, + "workerpool": { + "version": "6.1.5", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.1.5.tgz", + "integrity": "sha512-XdKkCK0Zqc6w3iTxLckiuJ81tiD/o5rBE/m+nXpRCB+/Sq4DqkfXZ/x0jW02DG1tGsfUGXbTJyZDP+eu67haSw==", + "dev": true + }, "wrap-ansi": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", @@ -1823,6 +2214,38 @@ "camelcase": "^5.0.0", "decamelize": "^1.2.0" } + }, + "yargs-unparser": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", + "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", + "dev": true, + "requires": { + "camelcase": "^6.0.0", + "decamelize": "^4.0.0", + "flat": "^5.0.2", + "is-plain-obj": "^2.1.0" + }, + "dependencies": { + "camelcase": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.2.0.tgz", + "integrity": "sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==", + "dev": true + }, + "decamelize": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", + "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", + "dev": true + } + } + }, + "yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true } } } diff --git a/package.json b/package.json index 2e35c20e6..297da1876 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ }, "devDependencies": { "jshint": "2.13.0", - "mocha": "5.2.0", + "mocha": "^9.1.2", "nyc": "^15.1.0", "should": "13.2.3", "sinon": "7.5.0" From 4003209a07e6a57241693c0764f5c0a348202b36 Mon Sep 17 00:00:00 2001 From: Jonah Werre Date: Tue, 12 Oct 2021 09:10:25 -0600 Subject: [PATCH 28/99] removed tab in token-model_test.js --- test/unit/models/token-model_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/models/token-model_test.js b/test/unit/models/token-model_test.js index b4664fcd6..9f2d41f4d 100644 --- a/test/unit/models/token-model_test.js +++ b/test/unit/models/token-model_test.js @@ -18,7 +18,7 @@ describe('Model', function() { }; var model = new TokenModel(data); - should.exist(model.accessTokenLifetime); + should.exist(model.accessTokenLifetime); model.accessTokenLifetime.should.a('number'); model.accessTokenLifetime.should.be.approximately(3600, 2); }); From 2e4d14f236a7d5bc01fc9d1aad412933f24f37c2 Mon Sep 17 00:00:00 2001 From: Jonah Werre Date: Tue, 12 Oct 2021 11:40:40 -0600 Subject: [PATCH 29/99] removed jshint --- package-lock.json | 159 ---------------------------------------------- package.json | 3 +- 2 files changed, 1 insertion(+), 161 deletions(-) diff --git a/package-lock.json b/package-lock.json index e6bcc7f94..0317e2fa2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -629,16 +629,6 @@ "integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==", "dev": true }, - "cli": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/cli/-/cli-1.0.1.tgz", - "integrity": "sha1-IoF1NPJL+klQw01TLUjsvGIbjBQ=", - "dev": true, - "requires": { - "exit": "0.1.2", - "glob": "^7.1.1" - } - }, "cliui": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", @@ -704,15 +694,6 @@ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, - "console-browserify": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", - "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", - "dev": true, - "requires": { - "date-now": "^0.1.4" - } - }, "convert-source-map": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.8.0.tgz", @@ -722,12 +703,6 @@ "safe-buffer": "~5.1.1" } }, - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, "cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -739,12 +714,6 @@ "which": "^2.0.1" } }, - "date-now": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", - "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=", - "dev": true - }, "debug": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", @@ -799,55 +768,6 @@ "esutils": "^2.0.2" } }, - "dom-serializer": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.2.2.tgz", - "integrity": "sha512-2/xPb3ORsQ42nHYiSunXkDjPLBaEj/xTwUO4B7XCZQTRk7EBtTOPaygh10YAAh2OI1Qrp6NWfpAhzswj0ydt9g==", - "dev": true, - "requires": { - "domelementtype": "^2.0.1", - "entities": "^2.0.0" - }, - "dependencies": { - "domelementtype": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.2.0.tgz", - "integrity": "sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A==", - "dev": true - }, - "entities": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", - "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==", - "dev": true - } - } - }, - "domelementtype": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz", - "integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==", - "dev": true - }, - "domhandler": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.3.0.tgz", - "integrity": "sha1-LeWaCCLVAn+r/28DLCsloqir5zg=", - "dev": true, - "requires": { - "domelementtype": "1" - } - }, - "domutils": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", - "integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=", - "dev": true, - "requires": { - "dom-serializer": "0", - "domelementtype": "1" - } - }, "electron-to-chromium": { "version": "1.3.864", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.864.tgz", @@ -869,12 +789,6 @@ "ansi-colors": "^4.1.1" } }, - "entities": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz", - "integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY=", - "dev": true - }, "es6-error": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz", @@ -1136,12 +1050,6 @@ "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "dev": true }, - "exit": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", - "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", - "dev": true - }, "fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -1327,19 +1235,6 @@ "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", "dev": true }, - "htmlparser2": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz", - "integrity": "sha1-mWwosZFRaovoZQGn15dX5ccMEGg=", - "dev": true, - "requires": { - "domelementtype": "1", - "domhandler": "2.3", - "domutils": "1.5", - "entities": "1.0", - "readable-stream": "1.1" - } - }, "ignore": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", @@ -1584,30 +1479,6 @@ "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", "dev": true }, - "jshint": { - "version": "2.13.0", - "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.13.0.tgz", - "integrity": "sha512-Nd+md9wIeyfDK+RGrbOBzwLONSTdihGMtyGYU/t7zYcN2EgUa4iuY3VK2oxtPYrW5ycTj18iC+UbhNTxe4C66g==", - "dev": true, - "requires": { - "cli": "~1.0.0", - "console-browserify": "1.1.x", - "exit": "0.1.x", - "htmlparser2": "3.8.x", - "lodash": "~4.17.21", - "minimatch": "~3.0.2", - "shelljs": "0.3.x", - "strip-json-comments": "1.0.x" - }, - "dependencies": { - "lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true - } - } - }, "json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", @@ -2035,18 +1906,6 @@ "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", "dev": true }, - "readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, "regexpp": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", @@ -2121,12 +1980,6 @@ "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true }, - "shelljs": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.3.0.tgz", - "integrity": "sha1-NZbmMHp4FUT1kfN9phg2DzHbV7E=", - "dev": true - }, "signal-exit": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.5.tgz", @@ -2196,12 +2049,6 @@ "strip-ansi": "^6.0.1" } }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - }, "strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -2217,12 +2064,6 @@ "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", "dev": true }, - "strip-json-comments": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", - "integrity": "sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E=", - "dev": true - }, "supports-color": { "version": "5.4.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", diff --git a/package.json b/package.json index 9044829b1..b50b3eeed 100644 --- a/package.json +++ b/package.json @@ -25,9 +25,8 @@ "type-is": "1.6.18" }, "devDependencies": { - "eslint": "^8.0.0", "chai": "^4.3.4", - "jshint": "2.13.0", + "eslint": "^8.0.0", "mocha": "5.2.0", "nyc": "^15.1.0", "sinon": "7.5.0" From 7a3a9b0b5c25eae66bb0681b5fc052b627e3a5a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Wed, 13 Oct 2021 09:05:11 +0200 Subject: [PATCH 30/99] ci (dev-infra): removed travis-ci file #34 --- .travis.yml | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 1bb18b78f..000000000 --- a/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: node_js - -node_js: - - 6 - - 8 - - 10 - - 12 - - 13 - - 14 - -sudo: false From 50caf40ae4c25841228d4f083515ddcc45e1949c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Wed, 13 Oct 2021 09:11:25 +0200 Subject: [PATCH 31/99] ci (dev-infra): add matrix strategy to test multiple node versions --- .github/workflows/tests.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2bc278608..26c6ed7e6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -39,26 +39,27 @@ jobs: runs-on: ubuntu-latest # uncomment when a linter is added # needs: [lintjs] + strategy: + matrix: + node: [12, 14, 16] steps: - - name: checkout + - name: Checkout ${{ matrix.node }} uses: actions/checkout@v2 - - name: setup node + - name: Setup node ${{ matrix.node }} uses: actions/setup-node@v1 with: - node-version: '12.x' + node-version: ${{ matrix.node }} - - name: cache dependencies + - name: Cache dependencies ${{ matrix.node }} uses: actions/cache@v1 with: path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + key: ${{ runner.os }}-node-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }} restore-keys: | - ${{ runner.os }}-node- + ${{ runner.os }}-node-${{ matrix.node }} - run: npm ci - - run: npm run test - # uncomment when coverage is added - # - run: npm run test:coverage + - run: npm run test:coverage # ---------------------------------- # uncomment when a linter is added From 66d46be5cdfb4d6640ec4d2e4f66c9b5e6e91fac Mon Sep 17 00:00:00 2001 From: HappyZombies Date: Wed, 13 Oct 2021 09:26:34 -0400 Subject: [PATCH 32/99] Ran npm install, add mocharc.yml file --- .mocharc.yml | 9 + package-lock.json | 611 +++++++++++++++++++++++++--------------------- 2 files changed, 340 insertions(+), 280 deletions(-) create mode 100644 .mocharc.yml diff --git a/.mocharc.yml b/.mocharc.yml new file mode 100644 index 000000000..c119fb401 --- /dev/null +++ b/.mocharc.yml @@ -0,0 +1,9 @@ +recursive: true +reporter: "spec" +retries: 1 +slow: 20 +timeout: 2000 +ui: "bdd" +# some additional files that could be loaded. e.g.: env.js +# file: +# - '/path/to/some/file' diff --git a/package-lock.json b/package-lock.json index b1aa152d8..8e7915edf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -40,14 +40,6 @@ "json5": "^2.1.2", "semver": "^6.3.0", "source-map": "^0.5.0" - }, - "dependencies": { - "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true - } } }, "@babel/generator": { @@ -71,14 +63,6 @@ "@babel/helper-validator-option": "^7.14.5", "browserslist": "^4.16.6", "semver": "^6.3.0" - }, - "dependencies": { - "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true - } } }, "@babel/helper-function-name": { @@ -307,14 +291,6 @@ "@babel/types": "^7.15.4", "debug": "^4.1.0", "globals": "^11.1.0" - }, - "dependencies": { - "globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", - "dev": true - } } }, "@babel/types": { @@ -340,6 +316,31 @@ "resolve-from": "^5.0.0" }, "dependencies": { + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + }, + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, "js-yaml": { "version": "3.14.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", @@ -350,11 +351,32 @@ "esprima": "^4.0.0" } }, - "resolve-from": { + "locate-path": { "version": "5.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", - "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", - "dev": true + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } } } }, @@ -463,13 +485,10 @@ "dev": true }, "argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dev": true, - "requires": { - "sprintf-js": "~1.0.2" - } + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true }, "array-from": { "version": "2.1.1", @@ -559,9 +578,9 @@ } }, "camelcase": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", - "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.2.0.tgz", + "integrity": "sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==", "dev": true }, "caniuse-lite": { @@ -592,6 +611,17 @@ "requires": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" + }, + "dependencies": { + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } } }, "check-error": { @@ -614,17 +644,6 @@ "is-glob": "~4.0.1", "normalize-path": "~3.0.0", "readdirp": "~3.6.0" - }, - "dependencies": { - "glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "requires": { - "is-glob": "^4.0.1" - } - } } }, "clean-stack": { @@ -644,14 +663,14 @@ } }, "cliui": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", - "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", "dev": true, "requires": { "string-width": "^4.2.0", "strip-ansi": "^6.0.0", - "wrap-ansi": "^6.2.0" + "wrap-ansi": "^7.0.0" } }, "co-bluebird": { @@ -750,12 +769,20 @@ "dev": true, "requires": { "ms": "2.1.2" + }, + "dependencies": { + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } } }, "decamelize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", + "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", "dev": true }, "deep-eql": { @@ -777,9 +804,9 @@ } }, "diff": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", + "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", "dev": true }, "dom-serializer": { @@ -900,12 +927,12 @@ } }, "find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", "dev": true, "requires": { - "locate-path": "^5.0.0", + "locate-path": "^6.0.0", "path-exists": "^4.0.0" } }, @@ -982,6 +1009,21 @@ "path-is-absolute": "^1.0.0" } }, + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + }, + "globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true + }, "graceful-fs": { "version": "4.2.8", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz", @@ -1008,14 +1050,6 @@ "requires": { "is-stream": "^2.0.0", "type-fest": "^0.8.0" - }, - "dependencies": { - "type-fest": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", - "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", - "dev": true - } } }, "he": { @@ -1179,14 +1213,6 @@ "@istanbuljs/schema": "^0.1.2", "istanbul-lib-coverage": "^3.0.0", "semver": "^6.3.0" - }, - "dependencies": { - "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true - } } }, "istanbul-lib-processinfo": { @@ -1213,6 +1239,17 @@ "istanbul-lib-coverage": "^3.0.0", "make-dir": "^3.0.0", "supports-color": "^7.1.0" + }, + "dependencies": { + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } } }, "istanbul-lib-source-maps": { @@ -1257,14 +1294,6 @@ "dev": true, "requires": { "argparse": "^2.0.1" - }, - "dependencies": { - "argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true - } } }, "jsesc": { @@ -1287,14 +1316,6 @@ "minimatch": "~3.0.2", "shelljs": "0.3.x", "strip-json-comments": "1.0.x" - }, - "dependencies": { - "strip-json-comments": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", - "integrity": "sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E=", - "dev": true - } } }, "json5": { @@ -1304,14 +1325,6 @@ "dev": true, "requires": { "minimist": "^1.2.5" - }, - "dependencies": { - "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true - } } }, "just-extend": { @@ -1321,12 +1334,12 @@ "dev": true }, "locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", "dev": true, "requires": { - "p-locate": "^4.1.0" + "p-locate": "^5.0.0" } }, "lodash": { @@ -1363,14 +1376,6 @@ "dev": true, "requires": { "semver": "^6.0.0" - }, - "dependencies": { - "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true - } } }, "media-typer": { @@ -1400,6 +1405,12 @@ "brace-expansion": "^1.1.7" } }, + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true + }, "mocha": { "version": "9.1.2", "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.1.2.tgz", @@ -1432,33 +1443,6 @@ "yargs-unparser": "2.0.0" }, "dependencies": { - "cliui": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", - "dev": true, - "requires": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^7.0.0" - } - }, - "diff": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", - "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", - "dev": true - }, - "find-up": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", - "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", - "dev": true, - "requires": { - "locate-path": "^6.0.0", - "path-exists": "^4.0.0" - } - }, "glob": { "version": "7.1.7", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", @@ -1473,92 +1457,18 @@ "path-is-absolute": "^1.0.0" } }, - "locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", - "dev": true, - "requires": { - "p-locate": "^5.0.0" - } - }, - "ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true - }, - "p-limit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", - "dev": true, - "requires": { - "yocto-queue": "^0.1.0" - } - }, - "p-locate": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", - "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", - "dev": true, - "requires": { - "p-limit": "^3.0.2" - } - }, - "supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - }, - "wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "requires": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - } - }, - "y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "dev": true - }, - "yargs": { - "version": "16.2.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", - "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", - "dev": true, - "requires": { - "cliui": "^7.0.2", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.0", - "y18n": "^5.0.5", - "yargs-parser": "^20.2.2" - } - }, - "yargs-parser": { - "version": "20.2.4", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", - "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", + "strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", "dev": true } } }, "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, "nanoid": { @@ -1647,11 +1557,111 @@ "yargs": "^15.0.2" }, "dependencies": { - "resolve-from": { + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + }, + "cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "dev": true, + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + } + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true + }, + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "locate-path": { "version": "5.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", - "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + }, + "wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "dev": true, + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + } + }, + "y18n": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", + "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", "dev": true + }, + "yargs": { + "version": "15.4.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", + "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", + "dev": true, + "requires": { + "cliui": "^6.0.0", + "decamelize": "^1.2.0", + "find-up": "^4.1.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^4.2.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^18.1.2" + } + }, + "yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } } } }, @@ -1665,21 +1675,21 @@ } }, "p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", "dev": true, "requires": { - "p-try": "^2.0.0" + "yocto-queue": "^0.1.0" } }, "p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", "dev": true, "requires": { - "p-limit": "^2.2.0" + "p-limit": "^3.0.2" } }, "p-map": { @@ -1761,6 +1771,45 @@ "dev": true, "requires": { "find-up": "^4.0.0" + }, + "dependencies": { + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + } } }, "process-on-spawn": { @@ -1840,6 +1889,12 @@ "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", "dev": true }, + "resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true + }, "rimraf": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", @@ -1854,6 +1909,12 @@ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + }, "serialize-javascript": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", @@ -1911,6 +1972,12 @@ "supports-color": "^5.5.0" }, "dependencies": { + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true + }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -1987,15 +2054,15 @@ "dev": true }, "strip-json-comments": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", + "integrity": "sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E=", "dev": true }, "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", "dev": true, "requires": { "has-flag": "^4.0.0" @@ -2033,6 +2100,12 @@ "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", "dev": true }, + "type-fest": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", + "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "dev": true + }, "type-is": { "version": "1.6.18", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", @@ -2079,9 +2152,9 @@ "dev": true }, "wrap-ansi": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", - "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", "dev": true, "requires": { "ansi-styles": "^4.0.0", @@ -2108,39 +2181,31 @@ } }, "y18n": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", - "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", "dev": true }, "yargs": { - "version": "15.4.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", - "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", "dev": true, "requires": { - "cliui": "^6.0.0", - "decamelize": "^1.2.0", - "find-up": "^4.1.0", - "get-caller-file": "^2.0.1", + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", "require-directory": "^2.1.1", - "require-main-filename": "^2.0.0", - "set-blocking": "^2.0.0", "string-width": "^4.2.0", - "which-module": "^2.0.0", - "y18n": "^4.0.0", - "yargs-parser": "^18.1.2" + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" } }, "yargs-parser": { - "version": "18.1.3", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", - "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", - "dev": true, - "requires": { - "camelcase": "^5.0.0", - "decamelize": "^1.2.0" - } + "version": "20.2.4", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", + "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", + "dev": true }, "yargs-unparser": { "version": "2.0.0", @@ -2152,20 +2217,6 @@ "decamelize": "^4.0.0", "flat": "^5.0.2", "is-plain-obj": "^2.1.0" - }, - "dependencies": { - "camelcase": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.2.0.tgz", - "integrity": "sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==", - "dev": true - }, - "decamelize": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", - "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", - "dev": true - } } }, "yocto-queue": { From fe789aa6139277f978e4c3eb789ec941b4888f79 Mon Sep 17 00:00:00 2001 From: HappyZombies Date: Wed, 13 Oct 2021 09:56:35 -0400 Subject: [PATCH 33/99] changed config file --- .mocharc.yml | 5 ++--- test/mocha.opts | 3 --- 2 files changed, 2 insertions(+), 6 deletions(-) delete mode 100644 test/mocha.opts diff --git a/.mocharc.yml b/.mocharc.yml index c119fb401..83fda38cf 100644 --- a/.mocharc.yml +++ b/.mocharc.yml @@ -4,6 +4,5 @@ retries: 1 slow: 20 timeout: 2000 ui: "bdd" -# some additional files that could be loaded. e.g.: env.js -# file: -# - '/path/to/some/file' +require: test/assertions +# for more options see here https://github.com/mochajs/mocha/blob/master/example/config/.mocharc.yml diff --git a/test/mocha.opts b/test/mocha.opts deleted file mode 100644 index 859c1da79..000000000 --- a/test/mocha.opts +++ /dev/null @@ -1,3 +0,0 @@ ---require test/assertions ---ui bdd ---reporter spec From 12f0a80d77f576787c0779403efb5205e497428c Mon Sep 17 00:00:00 2001 From: Jonah Werre Date: Wed, 13 Oct 2021 09:00:53 -0600 Subject: [PATCH 34/99] disallow the use of console --- .eslintrc | 54 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/.eslintrc b/.eslintrc index b0ccd9d23..3ef5edabe 100644 --- a/.eslintrc +++ b/.eslintrc @@ -15,31 +15,33 @@ } }, "rules": { - "indent": [ - "error", - 2 - ], - "linebreak-style": [ - "error", - "unix" - ], - "quotes": [ - "error", - "single" - ], - "semi": [ - "error", - "always" - ], - "no-console": "off", - "no-unused-vars": [ - "error", - { - "vars": "all", - "args": "none", - "ignoreRestSiblings": false - } - ] - } + "indent": [ + "error", + 2 + ], + "linebreak-style": [ + "error", + "unix" + ], + "quotes": [ + "error", + "single" + ], + "semi": [ + "error", + "always" + ], + "no-console": [ + "error" + ], + "no-unused-vars": [ + "error", + { + "vars": "all", + "args": "none", + "ignoreRestSiblings": false + } + ] } +} \ No newline at end of file From 4985ca7d38def95d3e58092be87daa84d369a7da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Wed, 13 Oct 2021 17:57:40 +0200 Subject: [PATCH 35/99] docs: correct types and available scripts and add info about removing branch --- CONTRIBUTING.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3106d6040..ebd5f9d66 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -69,9 +69,8 @@ $ npm install From here you can run several scripts for development purposes: ```bash -$ npm run lint # runs the linter -$ npm run tets # runs the tests once -$ npm run tests:coverage # runs the tests including coverage +$ npm run test # runs the tests once +$ npm run test:coverage # runs the tests including coverage $ npm run docs # generates the API docs ``` @@ -162,4 +161,7 @@ Finally your PR needs to pass the review process: the changes - Once all reviewers have approved your PR it will be merged by one of the maintainers :tada: - \ No newline at end of file + +#### After merge + +Please delete your branch after merge. From fcec2769de44ac7f1783cf726811487c76ba8568 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Wed, 13 Oct 2021 17:57:59 +0200 Subject: [PATCH 36/99] docs: add pull request template --- .github/PULL_REQUEST_TEMPLATE.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 987e9093f..7c49376b7 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -7,8 +7,8 @@ We highly appreciate your time and effort to this project! ⚠ PLEASE READ THIS FIRST ⚠ -1. If this is a fix for a security vulnerability you discorvered please don't -just open this PR until we have privatey discussed the vulnerability. Disclosing +1. If this is a fix for a security vulnerability you discovered please don't +just open this PR until we have privately discussed the vulnerability. Disclosing it without contacting us can lead to severe implications for many applications that run on this project. From 0d3f621ba049d000e6bfc2dd9cdfb56d3bc91bb2 Mon Sep 17 00:00:00 2001 From: HappyZombies Date: Wed, 13 Oct 2021 12:03:18 -0400 Subject: [PATCH 37/99] test: Update sinon to latest version #17 --- package-lock.json | 105 ++++++++++++++++------------------------------ package.json | 2 +- 2 files changed, 38 insertions(+), 69 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6be0b6efe..4d9e7c544 100644 --- a/package-lock.json +++ b/package-lock.json @@ -503,25 +503,24 @@ "type-detect": "4.0.8" } }, - "@sinonjs/formatio": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/@sinonjs/formatio/-/formatio-3.2.2.tgz", - "integrity": "sha512-B8SEsgd8gArBLMD6zpRw3juQ2FVSsmdd7qlevyDqzS9WTCtvF55/gAL+h6gue8ZvPYcdiPdvueM/qm//9XzyTQ==", + "@sinonjs/fake-timers": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-7.1.2.tgz", + "integrity": "sha512-iQADsW4LBMISqZ6Ci1dupJL9pprqwcVFTcOsEmQOEhW+KLCVn/Y4Jrvg2k19fIHCp+iFprriYPTdRcQR8NbUPg==", "dev": true, "requires": { - "@sinonjs/commons": "^1", - "@sinonjs/samsam": "^3.1.0" + "@sinonjs/commons": "^1.7.0" } }, "@sinonjs/samsam": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-3.3.3.tgz", - "integrity": "sha512-bKCMKZvWIjYD0BLGnNrxVuw4dkWCYsLqFOUWw8VgKF/+5Y+mE7LfHWPIYoDXowH+3a9LsWDMo0uAP8YDosPvHQ==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-6.0.2.tgz", + "integrity": "sha512-jxPRPp9n93ci7b8hMfJOFDPRLFYadN6FSpeROFTR4UNF4i5b+EK6m4QXPO46BDhFgRy1JuS87zAnFOzCUwMJcQ==", "dev": true, "requires": { - "@sinonjs/commons": "^1.3.0", - "array-from": "^2.1.1", - "lodash": "^4.17.15" + "@sinonjs/commons": "^1.6.0", + "lodash.get": "^4.4.2", + "type-detect": "^4.0.8" } }, "@sinonjs/text-encoding": { @@ -622,12 +621,6 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, - "array-from": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/array-from/-/array-from-2.1.1.tgz", - "integrity": "sha1-z+nYwmYoudxa7MYqn12PHzUsEZU=", - "dev": true - }, "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", @@ -1737,6 +1730,12 @@ "integrity": "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=", "dev": true }, + "lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", + "dev": true + }, "lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", @@ -1753,12 +1752,6 @@ "is-unicode-supported": "^0.1.0" } }, - "lolex": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/lolex/-/lolex-4.2.0.tgz", - "integrity": "sha512-gKO5uExCXvSm6zbF562EvM+rd1kQDnB9AZBbiQVzf1ZmdDpxUSvpnAaVOP83N/31mRK8Ml8/VE8DMvsAZQ+7wg==", - "dev": true - }, "lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -1877,27 +1870,16 @@ "dev": true }, "nise": { - "version": "1.5.3", - "resolved": "https://registry.npmjs.org/nise/-/nise-1.5.3.tgz", - "integrity": "sha512-Ymbac/94xeIrMf59REBPOv0thr+CJVFMhrlAkW/gjCIE58BGQdCj0x7KRCb3yz+Ga2Rz3E9XXSvUyyxqqhjQAQ==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/nise/-/nise-5.1.0.tgz", + "integrity": "sha512-W5WlHu+wvo3PaKLsJJkgPup2LrsXCcm7AWwyNZkUnn5rwPkuPBi3Iwk5SQtN0mv+K65k7nKKjwNQ30wg3wLAQQ==", "dev": true, "requires": { - "@sinonjs/formatio": "^3.2.1", + "@sinonjs/commons": "^1.7.0", + "@sinonjs/fake-timers": "^7.0.4", "@sinonjs/text-encoding": "^0.7.1", "just-extend": "^4.0.2", - "lolex": "^5.0.1", "path-to-regexp": "^1.7.0" - }, - "dependencies": { - "lolex": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/lolex/-/lolex-5.1.2.tgz", - "integrity": "sha512-h4hmjAvHTmd+25JSwrtTIuwbKdwg5NzZVRMLn9saij4SZaepCrTCxPr35H/3bjwfMJtN+t3CX8672UIkglz28A==", - "dev": true, - "requires": { - "@sinonjs/commons": "^1.7.0" - } - } } }, "node-preload": { @@ -2386,39 +2368,26 @@ "dev": true }, "sinon": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-7.5.0.tgz", - "integrity": "sha1-6UiOpGYHDqkI/USj1keP1JI8Z+w=", - "dev": true, - "requires": { - "@sinonjs/commons": "^1.4.0", - "@sinonjs/formatio": "^3.2.1", - "@sinonjs/samsam": "^3.3.3", - "diff": "^3.5.0", - "lolex": "^4.2.0", - "nise": "^1.5.2", - "supports-color": "^5.5.0" + "version": "11.1.2", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-11.1.2.tgz", + "integrity": "sha512-59237HChms4kg7/sXhiRcUzdSkKuydDeTiamT/jesUVHshBgL8XAmhgFo0GfK6RruMDM/iRSij1EybmMog9cJw==", + "dev": true, + "requires": { + "@sinonjs/commons": "^1.8.3", + "@sinonjs/fake-timers": "^7.1.2", + "@sinonjs/samsam": "^6.0.2", + "diff": "^5.0.0", + "nise": "^5.1.0", + "supports-color": "^7.2.0" }, "dependencies": { - "diff": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", - "dev": true - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha1-4uaaRKyHcveKHsCzW2id9lMO/I8=", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, "requires": { - "has-flag": "^3.0.0" + "has-flag": "^4.0.0" } } } diff --git a/package.json b/package.json index 7d0f09ffc..d9bd222b0 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "eslint": "^8.0.0", "mocha": "^9.1.2", "nyc": "^15.1.0", - "sinon": "7.5.0" + "sinon": "^11.1.2" }, "license": "MIT", "engines": { From f8c398fe0a0233ab8dd295927c0efdd494039365 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 14 Oct 2021 09:24:40 +0200 Subject: [PATCH 38/99] build(packaging): update minimal supported node version to 12 #34 --- README.md | 9 +++++++++ package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1dd27cd0c..47cf627a3 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,15 @@ This module has been rewritten using a promise-based approach, introducing chang Please refer to our [3.0 migration guide](https://oauth2-server.readthedocs.io/en/latest/misc/migrating-v2-to-v3.html) for more information. +## Supported NodeJs versions + +This project supports the node versions along the +[NodeJS LTS releases](https://nodejs.org/en/about/releases/), focusing on + +- Maintenance LTS +- Active LTS +- Current + ## Contributing to this project Please read our [contribution guide](./CONTRIBUTING.md) before taking actions. diff --git a/package.json b/package.json index d9bd222b0..c280b4d3b 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ }, "license": "MIT", "engines": { - "node": ">=4.0" + "node": ">=12.0.0" }, "scripts": { "pretest": "./node_modules/.bin/eslint lib test index.js", From 769878d336697c2d2f212b1783e95b8711ba9857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 14 Oct 2021 09:58:32 +0200 Subject: [PATCH 39/99] fix(security): use sha256 for token generation #38 --- lib/utils/token-util.js | 2 +- test/assertions.js | 9 ++++----- test/integration/grant-types/abstract-grant-type_test.js | 4 ++-- test/integration/handlers/authorize-handler_test.js | 2 +- test/integration/handlers/token-handler_test.js | 6 +++--- test/integration/utils/token-util_test.js | 4 ++-- 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/lib/utils/token-util.js b/lib/utils/token-util.js index 0f73746bb..96d05c0de 100644 --- a/lib/utils/token-util.js +++ b/lib/utils/token-util.js @@ -20,7 +20,7 @@ module.exports = { generateRandomToken: function() { return randomBytes(256).then(function(buffer) { return crypto - .createHash('sha1') + .createHash('sha256') .update(buffer) .digest('hex'); }); diff --git a/test/assertions.js b/test/assertions.js index 8e107859d..7ebf85ffd 100644 --- a/test/assertions.js +++ b/test/assertions.js @@ -7,13 +7,12 @@ var chai = require('chai'); /** - * SHA-1 assertion. + * SHA-256 assertion. */ -chai.use(function (_chai, utils) { - utils.addMethod(chai.Assertion.prototype, 'sha1', function () { +chai.use(function (_chai, utils) { + chai.Assertion.addMethod('sha256', function (...args) { var obj = utils.flag(this, 'object'); - new chai.Assertion(obj).match(/^[a-f0-9]{40}$/i); + new chai.Assertion(obj).match(/^[a-f0-9]{64}$/i); }); - }); diff --git a/test/integration/grant-types/abstract-grant-type_test.js b/test/integration/grant-types/abstract-grant-type_test.js index f292af8ea..160ba21e9 100644 --- a/test/integration/grant-types/abstract-grant-type_test.js +++ b/test/integration/grant-types/abstract-grant-type_test.js @@ -64,7 +64,7 @@ describe('AbstractGrantType integration', function() { return handler.generateAccessToken() .then(function(data) { - data.should.be.a.sha1; + data.should.be.a.sha256(); }) .catch(should.fail); }); @@ -98,7 +98,7 @@ describe('AbstractGrantType integration', function() { return handler.generateRefreshToken() .then(function(data) { - data.should.be.a.sha1; + data.should.be.a.sha256(); }) .catch(should.fail); }); diff --git a/test/integration/handlers/authorize-handler_test.js b/test/integration/handlers/authorize-handler_test.js index 8b1aad95b..afe737e1e 100644 --- a/test/integration/handlers/authorize-handler_test.js +++ b/test/integration/handlers/authorize-handler_test.js @@ -587,7 +587,7 @@ describe('AuthorizeHandler integration', function() { return handler.generateAuthorizationCode() .then(function(data) { - data.should.be.a.sha1; + data.should.be.a.sha256(); }) .catch(should.fail); }); diff --git a/test/integration/handlers/token-handler_test.js b/test/integration/handlers/token-handler_test.js index 97212a64a..19b69b598 100644 --- a/test/integration/handlers/token-handler_test.js +++ b/test/integration/handlers/token-handler_test.js @@ -492,7 +492,7 @@ describe('TokenHandler integration', function() { var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); var request = new Request({ body: {}, - headers: { 'authorization': util.format('Basic %s', new Buffer('foo:bar').toString('base64')) }, + headers: { 'authorization': util.format('Basic %s', Buffer.from('foo:bar').toString('base64')) }, method: {}, query: {} }); @@ -571,7 +571,7 @@ describe('TokenHandler integration', function() { }); var request = new Request({ body: { grant_type: 'password'}, - headers: { 'authorization': util.format('Basic %s', new Buffer('blah:').toString('base64')) }, + headers: { 'authorization': util.format('Basic %s', Buffer.from('blah:').toString('base64')) }, method: {}, query: {} }); @@ -679,7 +679,7 @@ describe('TokenHandler integration', function() { var request = new Request({ body: {}, headers: { - 'authorization': util.format('Basic %s', new Buffer('foo:bar').toString('base64')) + 'authorization': util.format('Basic %s', Buffer.from('foo:bar').toString('base64')) }, method: {}, query: {} diff --git a/test/integration/utils/token-util_test.js b/test/integration/utils/token-util_test.js index e0608e2f0..b6aa650f2 100644 --- a/test/integration/utils/token-util_test.js +++ b/test/integration/utils/token-util_test.js @@ -13,10 +13,10 @@ var should = require('chai').should(); describe('TokenUtil integration', function() { describe('generateRandomToken()', function() { - it('should return a sha-1 token', function() { + it('should return a sha-256 token', function() { return TokenUtil.generateRandomToken() .then(function(token) { - token.should.be.a.sha1; + token.should.be.a.sha256(); }) .catch(should.fail); }); From 8e05cb59e6a937743231affa00c287773a14c64e Mon Sep 17 00:00:00 2001 From: Joren Vandeweyer Date: Fri, 15 Oct 2021 01:55:57 +0200 Subject: [PATCH 40/99] Remove lodash dependency (#37) refactor: remove lodash dependency #23 --- .github/dependabot.yml | 33 +++++++++---------- lib/errors/access-denied-error.js | 3 +- lib/errors/insufficient-scope-error.js | 3 +- lib/errors/invalid-argument-error.js | 3 +- lib/errors/invalid-client-error.js | 3 +- lib/errors/invalid-grant-error.js | 3 +- lib/errors/invalid-request-error.js | 3 +- lib/errors/invalid-scope-error.js | 3 +- lib/errors/invalid-token-error.js | 3 +- lib/errors/oauth-error.js | 8 ++--- lib/errors/server-error.js | 3 +- lib/errors/unauthorized-client-error.js | 3 +- lib/errors/unauthorized-request-error.js | 3 +- lib/errors/unsupported-grant-type-error.js | 3 +- lib/errors/unsupported-response-type-error.js | 3 +- lib/handlers/authorize-handler.js | 7 ++-- lib/handlers/token-handler.js | 7 ++-- lib/server.js | 7 ++-- package-lock.json | 3 +- package.json | 1 - 20 files changed, 42 insertions(+), 63 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 473c411e8..b3e36ad14 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,20 +1,17 @@ version: 2 updates: -- package-ecosystem: npm - directory: "/" - schedule: - interval: daily - open-pull-requests-limit: 10 - ignore: - - dependency-name: sinon - versions: - - 10.0.0 - - 9.2.4 - - dependency-name: mocha - versions: - - 8.2.1 - - 8.3.0 - - 8.3.1 - - dependency-name: lodash - versions: - - 4.17.20 + - package-ecosystem: npm + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 + ignore: + - dependency-name: sinon + versions: + - 10.0.0 + - 9.2.4 + - dependency-name: mocha + versions: + - 8.2.1 + - 8.3.0 + - 8.3.1 diff --git a/lib/errors/access-denied-error.js b/lib/errors/access-denied-error.js index d3ffc704a..0f3dc2f19 100644 --- a/lib/errors/access-denied-error.js +++ b/lib/errors/access-denied-error.js @@ -4,7 +4,6 @@ * Module dependencies. */ -var _ = require('lodash'); var OAuthError = require('./oauth-error'); var util = require('util'); @@ -17,7 +16,7 @@ var util = require('util'); */ function AccessDeniedError(message, properties) { - properties = _.assign({ + properties = Object.assign({ code: 400, name: 'access_denied' }, properties); diff --git a/lib/errors/insufficient-scope-error.js b/lib/errors/insufficient-scope-error.js index c6442eac6..c522df747 100644 --- a/lib/errors/insufficient-scope-error.js +++ b/lib/errors/insufficient-scope-error.js @@ -4,7 +4,6 @@ * Module dependencies. */ -var _ = require('lodash'); var OAuthError = require('./oauth-error'); var util = require('util'); @@ -17,7 +16,7 @@ var util = require('util'); */ function InsufficientScopeError(message, properties) { - properties = _.assign({ + properties = Object.assign({ code: 403, name: 'insufficient_scope' }, properties); diff --git a/lib/errors/invalid-argument-error.js b/lib/errors/invalid-argument-error.js index cb56d5a8b..b667468f7 100644 --- a/lib/errors/invalid-argument-error.js +++ b/lib/errors/invalid-argument-error.js @@ -4,7 +4,6 @@ * Module dependencies. */ -var _ = require('lodash'); var OAuthError = require('./oauth-error'); var util = require('util'); @@ -13,7 +12,7 @@ var util = require('util'); */ function InvalidArgumentError(message, properties) { - properties = _.assign({ + properties = Object.assign({ code: 500, name: 'invalid_argument' }, properties); diff --git a/lib/errors/invalid-client-error.js b/lib/errors/invalid-client-error.js index d95358c7c..31aea2df3 100644 --- a/lib/errors/invalid-client-error.js +++ b/lib/errors/invalid-client-error.js @@ -4,7 +4,6 @@ * Module dependencies. */ -var _ = require('lodash'); var OAuthError = require('./oauth-error'); var util = require('util'); @@ -18,7 +17,7 @@ var util = require('util'); */ function InvalidClientError(message, properties) { - properties = _.assign({ + properties = Object.assign({ code: 400, name: 'invalid_client' }, properties); diff --git a/lib/errors/invalid-grant-error.js b/lib/errors/invalid-grant-error.js index 58d032e11..810242d07 100644 --- a/lib/errors/invalid-grant-error.js +++ b/lib/errors/invalid-grant-error.js @@ -4,7 +4,6 @@ * Module dependencies. */ -var _ = require('lodash'); var OAuthError = require('./oauth-error'); var util = require('util'); @@ -19,7 +18,7 @@ var util = require('util'); */ function InvalidGrantError(message, properties) { - properties = _.assign({ + properties = Object.assign({ code: 400, name: 'invalid_grant' }, properties); diff --git a/lib/errors/invalid-request-error.js b/lib/errors/invalid-request-error.js index 4cf0a73b1..bfb178a96 100644 --- a/lib/errors/invalid-request-error.js +++ b/lib/errors/invalid-request-error.js @@ -4,7 +4,6 @@ * Module dependencies. */ -var _ = require('lodash'); var OAuthError = require('./oauth-error'); var util = require('util'); @@ -18,7 +17,7 @@ var util = require('util'); */ function InvalidRequest(message, properties) { - properties = _.assign({ + properties = Object.assign({ code: 400, name: 'invalid_request' }, properties); diff --git a/lib/errors/invalid-scope-error.js b/lib/errors/invalid-scope-error.js index c3b287fc5..bcded24bd 100644 --- a/lib/errors/invalid-scope-error.js +++ b/lib/errors/invalid-scope-error.js @@ -4,7 +4,6 @@ * Module dependencies. */ -var _ = require('lodash'); var OAuthError = require('./oauth-error'); var util = require('util'); @@ -17,7 +16,7 @@ var util = require('util'); */ function InvalidScopeError(message, properties) { - properties = _.assign({ + properties = Object.assign({ code: 400, name: 'invalid_scope' }, properties); diff --git a/lib/errors/invalid-token-error.js b/lib/errors/invalid-token-error.js index d7e7a8bfe..cb12c3e2e 100644 --- a/lib/errors/invalid-token-error.js +++ b/lib/errors/invalid-token-error.js @@ -4,7 +4,6 @@ * Module dependencies. */ -var _ = require('lodash'); var OAuthError = require('./oauth-error'); var util = require('util'); @@ -17,7 +16,7 @@ var util = require('util'); */ function InvalidTokenError(message, properties) { - properties = _.assign({ + properties = Object.assign({ code: 401, name: 'invalid_token' }, properties); diff --git a/lib/errors/oauth-error.js b/lib/errors/oauth-error.js index a388cd358..fc66f75fc 100644 --- a/lib/errors/oauth-error.js +++ b/lib/errors/oauth-error.js @@ -3,7 +3,6 @@ /** * Module dependencies. */ -var _ = require('lodash'); var util = require('util'); var http = require('http'); /** @@ -13,17 +12,16 @@ var http = require('http'); function OAuthError(messageOrError, properties) { var message = messageOrError instanceof Error ? messageOrError.message : messageOrError; var error = messageOrError instanceof Error ? messageOrError : null; - if (_.isEmpty(properties)) - { + if (properties == null || !Object.entries(properties).length ) { properties = {}; } - _.defaults(properties, { code: 500 }); + properties = Object.assign({ code: 500 }, properties); if (error) { properties.inner = error; } - if (_.isEmpty(message)) { + if (!message || message.length === 0) { message = http.STATUS_CODES[properties.code]; } this.code = this.status = this.statusCode = properties.code; diff --git a/lib/errors/server-error.js b/lib/errors/server-error.js index d193af39c..a1bdcf9de 100644 --- a/lib/errors/server-error.js +++ b/lib/errors/server-error.js @@ -4,7 +4,6 @@ * Module dependencies. */ -var _ = require('lodash'); var OAuthError = require('./oauth-error'); var util = require('util'); @@ -17,7 +16,7 @@ var util = require('util'); */ function ServerError(message, properties) { - properties = _.assign({ + properties = Object.assign({ code: 503, name: 'server_error' }, properties); diff --git a/lib/errors/unauthorized-client-error.js b/lib/errors/unauthorized-client-error.js index c05075d3d..eca0d68fc 100644 --- a/lib/errors/unauthorized-client-error.js +++ b/lib/errors/unauthorized-client-error.js @@ -4,7 +4,6 @@ * Module dependencies. */ -var _ = require('lodash'); var OAuthError = require('./oauth-error'); var util = require('util'); @@ -17,7 +16,7 @@ var util = require('util'); */ function UnauthorizedClientError(message, properties) { - properties = _.assign({ + properties = Object.assign({ code: 400, name: 'unauthorized_client' }, properties); diff --git a/lib/errors/unauthorized-request-error.js b/lib/errors/unauthorized-request-error.js index ae7500d9c..afb11b8f5 100644 --- a/lib/errors/unauthorized-request-error.js +++ b/lib/errors/unauthorized-request-error.js @@ -4,7 +4,6 @@ * Module dependencies. */ -var _ = require('lodash'); var OAuthError = require('./oauth-error'); var util = require('util'); @@ -20,7 +19,7 @@ var util = require('util'); */ function UnauthorizedRequestError(message, properties) { - properties = _.assign({ + properties = Object.assign({ code: 401, name: 'unauthorized_request' }, properties); diff --git a/lib/errors/unsupported-grant-type-error.js b/lib/errors/unsupported-grant-type-error.js index 28ca0ec04..63345cea5 100644 --- a/lib/errors/unsupported-grant-type-error.js +++ b/lib/errors/unsupported-grant-type-error.js @@ -4,7 +4,6 @@ * Module dependencies. */ -var _ = require('lodash'); var OAuthError = require('./oauth-error'); var util = require('util'); @@ -17,7 +16,7 @@ var util = require('util'); */ function UnsupportedGrantTypeError(message, properties) { - properties = _.assign({ + properties = Object.assign({ code: 400, name: 'unsupported_grant_type' }, properties); diff --git a/lib/errors/unsupported-response-type-error.js b/lib/errors/unsupported-response-type-error.js index 523cc449b..861ac3492 100644 --- a/lib/errors/unsupported-response-type-error.js +++ b/lib/errors/unsupported-response-type-error.js @@ -4,7 +4,6 @@ * Module dependencies. */ -var _ = require('lodash'); var OAuthError = require('./oauth-error'); var util = require('util'); @@ -18,7 +17,7 @@ var util = require('util'); */ function UnsupportedResponseTypeError(message, properties) { - properties = _.assign({ + properties = Object.assign({ code: 400, name: 'unsupported_response_type' }, properties); diff --git a/lib/handlers/authorize-handler.js b/lib/handlers/authorize-handler.js index 845e25b55..7cd89a154 100644 --- a/lib/handlers/authorize-handler.js +++ b/lib/handlers/authorize-handler.js @@ -4,7 +4,6 @@ * Module dependencies. */ -var _ = require('lodash'); var AccessDeniedError = require('../errors/access-denied-error'); var AuthenticateHandler = require('../handlers/authenticate-handler'); var InvalidArgumentError = require('../errors/invalid-argument-error'); @@ -186,7 +185,7 @@ AuthorizeHandler.prototype.getClient = function(request) { throw new InvalidClientError('Invalid client: missing client `grants`'); } - if (!_.includes(client.grants, 'authorization_code')) { + if (!Array.isArray(client.grants) || !client.grants.includes('authorization_code')) { throw new UnauthorizedClientError('Unauthorized client: `grant_type` is invalid'); } @@ -194,7 +193,7 @@ AuthorizeHandler.prototype.getClient = function(request) { throw new InvalidClientError('Invalid client: missing client `redirectUri`'); } - if (redirectUri && !_.includes(client.redirectUris, redirectUri)) { + if (redirectUri && !client.redirectUris.includes(redirectUri)) { throw new InvalidClientError('Invalid client: `redirect_uri` does not match client value'); } return client; @@ -301,7 +300,7 @@ AuthorizeHandler.prototype.getResponseType = function(request) { throw new InvalidRequestError('Missing parameter: `response_type`'); } - if (!_.has(responseTypes, responseType)) { + if (!Object.prototype.hasOwnProperty.call(responseTypes, responseType)) { throw new UnsupportedResponseTypeError('Unsupported response type: `response_type` is not supported'); } diff --git a/lib/handlers/token-handler.js b/lib/handlers/token-handler.js index feaad3f54..895ce2e5a 100644 --- a/lib/handlers/token-handler.js +++ b/lib/handlers/token-handler.js @@ -4,7 +4,6 @@ * Module dependencies. */ -var _ = require('lodash'); var BearerTokenType = require('../token-types/bearer-token-type'); var InvalidArgumentError = require('../errors/invalid-argument-error'); var InvalidClientError = require('../errors/invalid-client-error'); @@ -56,7 +55,7 @@ function TokenHandler(options) { } this.accessTokenLifetime = options.accessTokenLifetime; - this.grantTypes = _.assign({}, grantTypes, options.extendedGrantTypes); + this.grantTypes = Object.assign({}, grantTypes, options.extendedGrantTypes); this.model = options.model; this.refreshTokenLifetime = options.refreshTokenLifetime; this.allowExtendedTokenAttributes = options.allowExtendedTokenAttributes; @@ -208,11 +207,11 @@ TokenHandler.prototype.handleGrantType = function(request, client) { throw new InvalidRequestError('Invalid parameter: `grant_type`'); } - if (!_.has(this.grantTypes, grantType)) { + if (!Object.prototype.hasOwnProperty.call(this.grantTypes, grantType)) { throw new UnsupportedGrantTypeError('Unsupported grant type: `grant_type` is invalid'); } - if (!_.includes(client.grants, grantType)) { + if (!Array.isArray(client.grants) || !client.grants.includes(grantType)) { throw new UnauthorizedClientError('Unauthorized client: `grant_type` is invalid'); } diff --git a/lib/server.js b/lib/server.js index fba9ccf81..a588f8090 100644 --- a/lib/server.js +++ b/lib/server.js @@ -4,7 +4,6 @@ * Module dependencies. */ -var _ = require('lodash'); var AuthenticateHandler = require('./handlers/authenticate-handler'); var AuthorizeHandler = require('./handlers/authorize-handler'); var InvalidArgumentError = require('./errors/invalid-argument-error'); @@ -33,7 +32,7 @@ OAuth2Server.prototype.authenticate = function(request, response, options, callb options = {scope: options}; } - options = _.assign({ + options = Object.assign({ addAcceptedScopesHeader: true, addAuthorizedScopesHeader: true, allowBearerTokensInQueryString: false @@ -49,7 +48,7 @@ OAuth2Server.prototype.authenticate = function(request, response, options, callb */ OAuth2Server.prototype.authorize = function(request, response, options, callback) { - options = _.assign({ + options = Object.assign({ allowEmptyState: false, authorizationCodeLifetime: 5 * 60 // 5 minutes. }, this.options, options); @@ -64,7 +63,7 @@ OAuth2Server.prototype.authorize = function(request, response, options, callback */ OAuth2Server.prototype.token = function(request, response, options, callback) { - options = _.assign({ + options = Object.assign({ accessTokenLifetime: 60 * 60, // 1 hour. refreshTokenLifetime: 60 * 60 * 24 * 14, // 2 weeks. allowExtendedTokenAttributes: false, diff --git a/package-lock.json b/package-lock.json index 4d9e7c544..fdb1e2d3d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1722,7 +1722,8 @@ "lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true }, "lodash.flattendeep": { "version": "4.4.0", diff --git a/package.json b/package.json index c280b4d3b..081dcbb30 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,6 @@ "dependencies": { "basic-auth": "2.0.1", "bluebird": "3.7.2", - "lodash": "4.17.21", "promisify-any": "2.0.1", "type-is": "1.6.18" }, From 156b34f4abce8fa1c65fff66183a0044c7137d58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Fri, 15 Oct 2021 09:52:29 +0200 Subject: [PATCH 41/99] ci(dev-infra): add codeql semantic analysis #16 #36 --- .github/workflows/codeql-analysis.yml | 69 +++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 000000000..5ffc66f47 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,69 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL Semantic Analysis" + +on: + push: + branches: [ master, development ] + pull_request: # all PR + schedule: + - cron: '0 2 * * *' # every night at 2am + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: true + matrix: + language: [ 'javascript' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] + # Learn more: + # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + # - name: Autobuild + # uses: github/codeql-action/autobuild@v1 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 From be8121b22706d3c634bae594d18b2fc0b4c38907 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Fri, 15 Oct 2021 10:07:06 +0200 Subject: [PATCH 42/99] ci(dev-infra): make codeql scane on push and pr equal #16 #36 --- .github/workflows/codeql-analysis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 5ffc66f47..33f382633 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -12,8 +12,7 @@ name: "CodeQL Semantic Analysis" on: - push: - branches: [ master, development ] + push: # all pushes pull_request: # all PR schedule: - cron: '0 2 * * *' # every night at 2am From 100e8aef30c3459e887da2b9c3ca19a4c362b629 Mon Sep 17 00:00:00 2001 From: HappyZombies Date: Fri, 15 Oct 2021 09:19:19 -0400 Subject: [PATCH 43/99] refactor:Fix typos and clean up package.json and package-lock.json --- .github/FUNDING.yml | 2 -- CONTRIBUTING.md | 4 ++-- README.md | 5 ++--- SECURITY.md | 11 ++++++----- package-lock.json | 6 ------ package.json | 3 +-- 6 files changed, 11 insertions(+), 20 deletions(-) delete mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 973a5aa76..000000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,2 +0,0 @@ -github: thomseddon - diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ebd5f9d66..9c823f752 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -62,7 +62,7 @@ First, clone and install this project from source via ```bash $ git clone git@github.com:node-oauth/node-oauth2-server.git $ cd node-oauth2-server -$ git checkout developmemt # important! do not work on master! +$ git checkout development # important! do not work on master! $ npm install ``` @@ -91,7 +91,7 @@ We use a commit convention, inspired by [angular commit message format](https:// with ticket number at the end of summary: ``` -(): # +(): # ``` Summary in present tense. Not capitalized. No period at the end. The and fields are mandatory, the () and # field is optional. diff --git a/README.md b/README.md index 47cf627a3..95a480556 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Complete, compliant and well tested module for implementing an OAuth2 server in [Node.js](https://nodejs.org). -NOTE: This project has been forked from [oauthjs/node-oauth2-server](https://github.com/oauthjs/node-oauth2-server) and is a continuition due to the project appearing to be abandoned. Please see [this issue](https://github.com/node-oauth/node-oauth2-server/issues/2) to talk about next steps and the future of this project. +NOTE: This project has been forked from [oauthjs/node-oauth2-server](https://github.com/oauthjs/node-oauth2-server) and is a continuation due to the project appearing to be abandoned. Please see [our issue board](https://github.com/node-oauth/node-oauth2-server/issues) to talk about next steps and the future of this project. ## Installation @@ -52,5 +52,4 @@ This project supports the node versions along the ## Contributing to this project Please read our [contribution guide](./CONTRIBUTING.md) before taking actions. -In any case, please open an issue before opening a pull request to find out, -whether your intend to contribute will actually have a chance to be merged. +In any case, please open an issue before opening a pull request to find out whether your intended contribution will actually have a chance to be merged. diff --git a/SECURITY.md b/SECURITY.md index 697becd48..f0cc8ef82 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -13,12 +13,13 @@ currently being supported with security updates. ## Reporting a Vulnerability -Report security vulnerabilities to info[at]jankuester[dot]com +Report security vulnerabilities to info@jankuester.com -Please specify exactly how the vulnerability is to be exploited so we can estime how severe the consequences can be (unless you also can specifiy them, too). -Note, that we need to reproduce the vulnerability (as like with bugs) in order to safely fix it. +Please specify exactly how the vulnerability is to be exploited so we can estimate how severe the consequences can be (unless you also can specify them, too). + +Please note that we need to reproduce the vulnerability (as like with bugs) in order to safely fix it. A fix will be implemented in private until we can ensure the vulnerability is closed. A new release will immediately be published. -If you want to provide a fix please let us know in the Email so we can setup a completely private repository to work on it together. +If you want to provide a fix please let us know in the e-mail so we can setup a completely private repository to work on it together. -Note, that security fixes will also require to pass all tests and audits. +Finally, all security fixes will also require to pass all tests and audits. diff --git a/package-lock.json b/package-lock.json index fdb1e2d3d..c04ae94c3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1719,12 +1719,6 @@ "p-locate": "^5.0.0" } }, - "lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true - }, "lodash.flattendeep": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", diff --git a/package.json b/package.json index 081dcbb30..04999c545 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,5 @@ "doc": "docs", "lib": "lib", "test": "test" - }, - "author": "" + } } From d3b335f18b96aea03b8212efc69432bd6cd175a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Mon, 18 Oct 2021 13:38:21 +0200 Subject: [PATCH 44/99] ci: ignore test.yml workflow on release-* branches PRs #36 --- .github/workflows/tests.yml | 60 +++++++++++-------------------------- 1 file changed, 17 insertions(+), 43 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 26c6ed7e6..a74688fef 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,44 +1,21 @@ -name: Test suite +name: Tests + +# This workflow runs standard unit tests to ensure basic integrity and avoid +# regressions on pull-requests (and pushes) on: push: branches: - - master # allthough master is push protected we still keep it + - master # allthough master is push protected we still keep it - development - pull_request: # runs on all PR + pull_request: # runs on all PR + branches-ignore: + - release-* # on release we run an extended workflow so no need for this jobs: - # ---------------------------------- - # uncomment when a linter is added - # ---------------------------------- - - # lintjs: - # name: Javascript lint - # runs-on: ubuntu-latest - # steps: - # - name: checkout - # uses: actions/checkout@v2 - # - # - name: setup node - # uses: actions/setup-node@v1 - # with: - # node-version: '12.x' - # - # - name: cache dependencies - # uses: actions/cache@v1 - # with: - # path: ~/.npm - # key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} - # restore-keys: | - # ${{ runner.os }}-node- - # - run: npm ci - # - run: npm run lint - unittest: name: unit tests runs-on: ubuntu-latest - # uncomment when a linter is added - # needs: [lintjs] strategy: matrix: node: [12, 14, 16] @@ -61,15 +38,12 @@ jobs: - run: npm ci - run: npm run test:coverage - # ---------------------------------- - # uncomment when a linter is added - # ---------------------------------- - - # - name: check coverage - # uses: devmasx/coverage-check-action@v1.2.0 - # with: - # type: lcov - # result_path: coverage/lcov.info - # min_coverage: 90 - # token: ${{github.token}} - + # with the following action we enforce PRs to have a high coverage + # and ensure, changes are tested well enough so that coverage won't fail + - name: check coverage + uses: devmasx/coverage-check-action@v1.2.0 + with: + type: lcov + result_path: coverage/lcov.info + min_coverage: 95 + token: ${{github.token}} From 8c080ff9842f271c3b7854dfb2571a90ed6861d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Mon, 18 Oct 2021 13:39:01 +0200 Subject: [PATCH 45/99] ci: add tests-release.yml workflow to test release-integrity --- .github/workflows/tests-release.yml | 153 ++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 .github/workflows/tests-release.yml diff --git a/.github/workflows/tests-release.yml b/.github/workflows/tests-release.yml new file mode 100644 index 000000000..75c9236ea --- /dev/null +++ b/.github/workflows/tests-release.yml @@ -0,0 +1,153 @@ +name: Tests for Release + +on: + push: + branches: + - release-* # all release- branches + pull_request: + branches: + - release-* # all release- branches + +jobs: + # STEP 1 - NPM Audit + + # Before we even test a thing we want to have a clean audit! Since this is + # sufficient to be done using the lowest node version, we can easily use + # a fixed one: + + audit: + name: NPM Audit + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup node 12 + uses: actions/setup-node@v1 + with: + node-version: 12 + - run: npm audit + + # STEP 2 - basic unit tests + + # This is the standard unit tests as we do in the basic tests for every PR + unittest: + name: Basic unit tests + runs-on: ubuntu-latest + needs: [audit] + strategy: + matrix: + node: [12, 14, 16] + steps: + - name: Checkout ${{ matrix.node }} + uses: actions/checkout@v2 + + - name: Setup node ${{ matrix.node }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node }} + + - name: Cache dependencies ${{ matrix.node }} + uses: actions/cache@v1 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node-${{ matrix.node }} + + # for this workflow we also require npm audit to pass + - run: npm ci + - run: npm run test:coverage + + # with the following action we enforce PRs to have a high coverage + # and ensure, changes are tested well enough so that coverage won't fail + - name: check coverage + uses: devmasx/coverage-check-action@v1.2.0 + with: + type: lcov + result_path: coverage/lcov.info + min_coverage: 95 + token: ${{github.token}} + + # STEP 3 - Integration tests + + # Since our release may affect several packages that depend on it we need to + # cover the closest ones, like adapters and examples. + + integrationtests: + name: Extended integration tests + runs-on: ubuntu-latest + needs: [unittest] + strategy: + matrix: + node: [12, 14, 16] + steps: + # checkout this repo + - name: Checkout ${{ matrix.node }} + uses: actions/checkout@v2 + + # checkout express-adapter repo + - name: Checkout express-adapter ${{ matrix.node }} + uses: actions/checkout@v2 + with: + repository: node-oauth/express-adapter + path: github/testing + + # place checkout for other adapters here + - name: Setup node ${{ matrix.node }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node }} + + - name: Cache dependencies ${{ matrix.node }} + uses: actions/cache@v1 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node-${{ matrix.node }} + + # in order to test the adapter we need to use the current state + # we just cloned and install it as local dependency + - run: cd github/testing/express-adapter && npm ci + - run: cd github/testing/express-adapter && npm install ./ + - run: cd github/testing/express-adapter && npm run tests + + # todo repeat with other adapters + + npmpubdry: + name: NPM Publish Dry-run + runs-on: ubuntu-latest + needs: [integrationtests] + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup node 12 + uses: actions/setup-node@v1 + with: + node-version: '12.x' + registry-url: 'https://registry.npmjs.org' + - run: npm install + - run: npm publish --dry-run + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + ghpubdry: + needs: [integrationtests] + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + # we always publish targeting the lowest supported node version + node-version: 12 + registry-url: $registry-url(npm) + - run: npm ci + - run: npm publish --dry-run + env: + NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} \ No newline at end of file From c6459b87fe88fbbd6c7e4ff07f8dce93e28b0d90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Mon, 18 Oct 2021 13:39:16 +0200 Subject: [PATCH 46/99] ci: add release.yml to release a new version to registries --- .github/workflows/release.yml | 52 +++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..152375959 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,52 @@ +# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created +# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages + +name: Release + +on: + release: + types: [created] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 12 + - run: npm ci + - run: npm test + + publish-npm: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + # we always publish targeting the lowest supported node version + node-version: 12 + registry-url: 'https://registry.npmjs.org/' + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} + + publish-gpr: + needs: build + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + # we always publish targeting the lowest supported node version + node-version: 12 + registry-url: $registry-url(npm) + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} \ No newline at end of file From f4fc33bb6843cb6bbd30cafdccd9da1e955223e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Tue, 26 Oct 2021 06:42:42 +0200 Subject: [PATCH 47/99] ci(tests): make coverage generate lcov.info file --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 04999c545..1e8be1e4d 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "pretest": "./node_modules/.bin/eslint lib test index.js", "test": "NODE_ENV=test ./node_modules/.bin/mocha 'test/**/*_test.js'", "test-debug": "NODE_ENV=test ./node_modules/.bin/mocha --inspect --debug-brk 'test/**/*_test.js'", - "test:coverage": "NODE_ENV=test nyc --reporter=html --reporter=text ./node_modules/.bin/mocha 'test/**/*_test.js'" + "test:coverage": "NODE_ENV=test nyc --report=lcovonly --reporter=text ./node_modules/.bin/mocha 'test/**/*_test.js'" }, "repository": { "type": "git", From 02e0a4d9cb42d007b2550c4921bafe2c957e340d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Tue, 26 Oct 2021 06:46:34 +0200 Subject: [PATCH 48/99] ci(tests): make coverage generate lcov.info file as well as html #36 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1e8be1e4d..1084a28c6 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "pretest": "./node_modules/.bin/eslint lib test index.js", "test": "NODE_ENV=test ./node_modules/.bin/mocha 'test/**/*_test.js'", "test-debug": "NODE_ENV=test ./node_modules/.bin/mocha --inspect --debug-brk 'test/**/*_test.js'", - "test:coverage": "NODE_ENV=test nyc --report=lcovonly --reporter=text ./node_modules/.bin/mocha 'test/**/*_test.js'" + "test:coverage": "NODE_ENV=test nyc --report=lcov --reporter=text ./node_modules/.bin/mocha 'test/**/*_test.js'" }, "repository": { "type": "git", From ac7bb86a5403fa3ae9598006369a5b5cc4438cb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Tue, 26 Oct 2021 06:47:44 +0200 Subject: [PATCH 49/99] ci(tests): fix spelling in coverage test script #36 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1084a28c6..90e4dabb6 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "pretest": "./node_modules/.bin/eslint lib test index.js", "test": "NODE_ENV=test ./node_modules/.bin/mocha 'test/**/*_test.js'", "test-debug": "NODE_ENV=test ./node_modules/.bin/mocha --inspect --debug-brk 'test/**/*_test.js'", - "test:coverage": "NODE_ENV=test nyc --report=lcov --reporter=text ./node_modules/.bin/mocha 'test/**/*_test.js'" + "test:coverage": "NODE_ENV=test nyc --reporter=lcov --reporter=text ./node_modules/.bin/mocha 'test/**/*_test.js'" }, "repository": { "type": "git", From 002e38045c932dd02f6f3f8d184d70b2131a808b Mon Sep 17 00:00:00 2001 From: HappyZombies Date: Thu, 4 Nov 2021 08:52:44 -0400 Subject: [PATCH 50/99] release: up semver and update changelog --- CHANGELOG.md | 13 +++++++++++++ package-lock.json | 2 +- package.json | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d2be06839..668c19c8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ ## Changelog +## 4.1.0 +### Changed +* Bump dev dependencies to resolve vulnerabilities +* Replaced jshint with eslint along with should and chai +* Use sha256 when generating tokens + +### Added +* Added markdown files to discuss coding rules, commit conventions, contributing guidelines, etc. + +### Removed +* Removed lodash dependency +* Removed statuses package and use built in http.STATUS_CODES instead. + ### 4.0.0 * Bump jshint from 2.12.0 to 2.13.0 * Bump jshint from 2.12.0 to 2.13.0 diff --git a/package-lock.json b/package-lock.json index c04ae94c3..3f800f9d6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@node-oauth/oauth2-server", - "version": "4.0.0", + "version": "4.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 04999c545..ad8cdce9b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@node-oauth/oauth2-server", "description": "Complete, framework-agnostic, compliant and well tested module for implementing an OAuth2 Server in node.js", - "version": "4.0.0", + "version": "4.1.0", "keywords": [ "oauth", "oauth2" From 0e8f864f5f32f8f52f0220f56272f5651728c66f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Nov 2021 15:52:49 +0000 Subject: [PATCH 51/99] Bump eslint from 8.0.0 to 8.2.0 Bumps [eslint](https://github.com/eslint/eslint) from 8.0.0 to 8.2.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v8.0.0...v8.2.0) --- updated-dependencies: - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 202 +++++++--------------------------------------- 1 file changed, 27 insertions(+), 175 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3f800f9d6..6462cd063 100644 --- a/package-lock.json +++ b/package-lock.json @@ -304,9 +304,9 @@ } }, "@eslint/eslintrc": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.0.2.tgz", - "integrity": "sha512-x1ZXdEFsvTcnbTZgqcWUL9w2ybgZCw/qbKTPQnab+XnYA2bMQpJCh+/bBzCRfDJaJdlrrQlOk49jNtru9gL/6Q==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.0.4.tgz", + "integrity": "sha512-h8Vx6MdxwWI2WM8/zREHMoqdgLNXEL4QX3MWSVMdyNJGvXVOs+6lp+m2hc3FnuMHDc4poxFNI20vCk0OmI4G0Q==", "dev": true, "requires": { "ajv": "^6.12.4", @@ -315,60 +315,20 @@ "globals": "^13.9.0", "ignore": "^4.0.6", "import-fresh": "^3.2.1", - "js-yaml": "^3.13.1", + "js-yaml": "^4.1.0", "minimatch": "^3.0.4", "strip-json-comments": "^3.1.1" }, "dependencies": { - "argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dev": true, - "requires": { - "sprintf-js": "~1.0.2" - } - }, - "debug": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", - "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", - "dev": true, - "requires": { - "ms": "2.1.2" - } - }, "globals": { - "version": "13.11.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.11.0.tgz", - "integrity": "sha512-08/xrJ7wQjK9kkkRoI3OFUBbLx4f+6x3SGwcPvQ0QH6goFDrOU2oyAWrmh3dJezu65buo+HBMzAMQy6rovVC3g==", + "version": "13.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.12.0.tgz", + "integrity": "sha512-uS8X6lSKN2JumVoXrbUz+uG4BYG+eiawqm3qFcT7ammfbUHeCBoJMlHcec/S3krSk73/AE/f0szYFmgAA3kYZg==", "dev": true, "requires": { "type-fest": "^0.20.2" } }, - "js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", - "dev": true, - "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - } - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, - "strip-json-comments": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", - "dev": true - }, "type-fest": { "version": "0.20.2", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", @@ -386,29 +346,12 @@ "@humanwhocodes/object-schema": "^1.2.0", "debug": "^4.1.1", "minimatch": "^3.0.4" - }, - "dependencies": { - "debug": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", - "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", - "dev": true, - "requires": { - "ms": "2.1.2" - } - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - } } }, "@humanwhocodes/object-schema": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.0.tgz", - "integrity": "sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", + "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", "dev": true }, "@istanbuljs/load-nyc-config": { @@ -975,12 +918,12 @@ "dev": true }, "eslint": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.0.0.tgz", - "integrity": "sha512-03spzPzMAO4pElm44m60Nj08nYonPGQXmw6Ceai/S4QK82IgwWO1EXx1s9namKzVlbVu3Jf81hb+N+8+v21/HQ==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.2.0.tgz", + "integrity": "sha512-erw7XmM+CLxTOickrimJ1SiF55jiNlVSp2qqm0NuBWPtHYQCegD5ZMaW0c3i5ytPqL+SSLaCxdvQXFPLJn+ABw==", "dev": true, "requires": { - "@eslint/eslintrc": "^1.0.2", + "@eslint/eslintrc": "^1.0.4", "@humanwhocodes/config-array": "^0.6.0", "ajv": "^6.10.0", "chalk": "^4.0.0", @@ -1014,97 +957,21 @@ "progress": "^2.0.0", "regexpp": "^3.2.0", "semver": "^7.2.1", - "strip-ansi": "^6.0.0", + "strip-ansi": "^6.0.1", "strip-json-comments": "^3.1.0", "text-table": "^0.2.0", "v8-compile-cache": "^2.0.3" }, "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "debug": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", - "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", - "dev": true, - "requires": { - "ms": "2.1.2" - } - }, - "escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "dev": true - }, "globals": { - "version": "13.11.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.11.0.tgz", - "integrity": "sha512-08/xrJ7wQjK9kkkRoI3OFUBbLx4f+6x3SGwcPvQ0QH6goFDrOU2oyAWrmh3dJezu65buo+HBMzAMQy6rovVC3g==", + "version": "13.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.12.0.tgz", + "integrity": "sha512-uS8X6lSKN2JumVoXrbUz+uG4BYG+eiawqm3qFcT7ammfbUHeCBoJMlHcec/S3krSk73/AE/f0szYFmgAA3kYZg==", "dev": true, "requires": { "type-fest": "^0.20.2" } }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dev": true, - "requires": { - "argparse": "^2.0.1" - } - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, "semver": { "version": "7.3.5", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", @@ -1114,21 +981,6 @@ "lru-cache": "^6.0.0" } }, - "strip-json-comments": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - }, "type-fest": { "version": "0.20.2", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", @@ -1165,9 +1017,9 @@ } }, "eslint-visitor-keys": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.0.0.tgz", - "integrity": "sha512-mJOZa35trBTb3IyRmo8xmKBZlxf+N7OnUl4+ZhJHs/r+0770Wh/LEACE2pqMGMe27G/4y8P2bYGk4J70IC5k1Q==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.1.0.tgz", + "integrity": "sha512-yWJFpu4DtjsWKkt5GeNBBuZMlNcYVs6vRCLoCVEJrTjaSB6LC98gFipNK/erM2Heg/E8mIK+hXG/pJMLK+eRZA==", "dev": true }, "espree": { @@ -1206,9 +1058,9 @@ } }, "estraverse": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", - "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", "dev": true }, "esutils": { @@ -1291,9 +1143,9 @@ } }, "flatted": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.2.tgz", - "integrity": "sha512-JaTY/wtrcSyvXJl4IMFHPKyFur1sE9AUqc0QnhOaJ0CxHtAoIV8pYDzeEfAaNEtGkOfq4gr3LBFmdXW5mOQFnA==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.4.tgz", + "integrity": "sha512-8/sOawo8tJ4QOBX8YlQBMxL8+RLZfxMQOif9o0KUKTNTjMYElWPE0r/m5VNFxTRd0NSw8qSy8dajrwX4RYI1Hw==", "dev": true }, "foreground-child": { From 55775b9b18c39705dd3f16ae2429f4ecd5a99e55 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Nov 2021 15:53:05 +0000 Subject: [PATCH 52/99] Bump sinon from 7.5.0 to 12.0.1 Bumps [sinon](https://github.com/sinonjs/sinon) from 7.5.0 to 12.0.1. - [Release notes](https://github.com/sinonjs/sinon/releases) - [Changelog](https://github.com/sinonjs/sinon/blob/master/docs/changelog.md) - [Commits](https://github.com/sinonjs/sinon/compare/v7.5.0...v12.0.1) --- updated-dependencies: - dependency-name: sinon dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- package-lock.json | 25 ++++++++++++++++++------- package.json | 2 +- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3f800f9d6..a5e3b831c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -504,9 +504,9 @@ } }, "@sinonjs/fake-timers": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-7.1.2.tgz", - "integrity": "sha512-iQADsW4LBMISqZ6Ci1dupJL9pprqwcVFTcOsEmQOEhW+KLCVn/Y4Jrvg2k19fIHCp+iFprriYPTdRcQR8NbUPg==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-8.1.0.tgz", + "integrity": "sha512-OAPJUAtgeINhh/TAlUID4QTs53Njm7xzddaVlEs/SXwgtiD1tW22zAB/W1wdqfrpmikgaWQ9Fw6Ws+hsiRm5Vg==", "dev": true, "requires": { "@sinonjs/commons": "^1.7.0" @@ -1875,6 +1875,17 @@ "@sinonjs/text-encoding": "^0.7.1", "just-extend": "^4.0.2", "path-to-regexp": "^1.7.0" + }, + "dependencies": { + "@sinonjs/fake-timers": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-7.1.2.tgz", + "integrity": "sha512-iQADsW4LBMISqZ6Ci1dupJL9pprqwcVFTcOsEmQOEhW+KLCVn/Y4Jrvg2k19fIHCp+iFprriYPTdRcQR8NbUPg==", + "dev": true, + "requires": { + "@sinonjs/commons": "^1.7.0" + } + } } }, "node-preload": { @@ -2363,13 +2374,13 @@ "dev": true }, "sinon": { - "version": "11.1.2", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-11.1.2.tgz", - "integrity": "sha512-59237HChms4kg7/sXhiRcUzdSkKuydDeTiamT/jesUVHshBgL8XAmhgFo0GfK6RruMDM/iRSij1EybmMog9cJw==", + "version": "12.0.1", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-12.0.1.tgz", + "integrity": "sha512-iGu29Xhym33ydkAT+aNQFBINakjq69kKO6ByPvTsm3yyIACfyQttRTP03aBP/I8GfhFmLzrnKwNNkr0ORb1udg==", "dev": true, "requires": { "@sinonjs/commons": "^1.8.3", - "@sinonjs/fake-timers": "^7.1.2", + "@sinonjs/fake-timers": "^8.1.0", "@sinonjs/samsam": "^6.0.2", "diff": "^5.0.0", "nise": "^5.1.0", diff --git a/package.json b/package.json index ad8cdce9b..69da5fbe9 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "eslint": "^8.0.0", "mocha": "^9.1.2", "nyc": "^15.1.0", - "sinon": "^11.1.2" + "sinon": "^12.0.1" }, "license": "MIT", "engines": { From 969ce6a6c3408be69dec5045e7bf8a21bcca38b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 11 Nov 2021 09:56:03 +0100 Subject: [PATCH 53/99] build(lint): update eslint rules to automatically fix es5 code #54 --- .eslintrc | 7 +++++++ package.json | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.eslintrc b/.eslintrc index 3ef5edabe..8e36b31a7 100644 --- a/.eslintrc +++ b/.eslintrc @@ -34,6 +34,13 @@ "no-console": [ "error" ], + "no-var": [ + "error" + ], + "prefer-const": ["error", { + "destructuring": "any", + "ignoreReadBeforeAssign": false + }], "no-unused-vars": [ "error", { diff --git a/package.json b/package.json index ad8cdce9b..92fecb330 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,9 @@ "pretest": "./node_modules/.bin/eslint lib test index.js", "test": "NODE_ENV=test ./node_modules/.bin/mocha 'test/**/*_test.js'", "test-debug": "NODE_ENV=test ./node_modules/.bin/mocha --inspect --debug-brk 'test/**/*_test.js'", - "test:coverage": "NODE_ENV=test nyc --reporter=html --reporter=text ./node_modules/.bin/mocha 'test/**/*_test.js'" + "test:coverage": "NODE_ENV=test nyc --reporter=html --reporter=text ./node_modules/.bin/mocha 'test/**/*_test.js'", + "lint": "npx eslint .", + "lint:fix": "npx eslint . --fix" }, "repository": { "type": "git", From b67db9c8c5799b90f80ce10bacb8832428241c26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 11 Nov 2021 09:59:45 +0100 Subject: [PATCH 54/99] build(lint): auto-fix var to const/let via eslint #54 --- lib/errors/access-denied-error.js | 4 +- lib/errors/insufficient-scope-error.js | 4 +- lib/errors/invalid-argument-error.js | 4 +- lib/errors/invalid-client-error.js | 4 +- lib/errors/invalid-grant-error.js | 4 +- lib/errors/invalid-request-error.js | 4 +- lib/errors/invalid-scope-error.js | 4 +- lib/errors/invalid-token-error.js | 4 +- lib/errors/oauth-error.js | 10 +- lib/errors/server-error.js | 4 +- lib/errors/unauthorized-client-error.js | 4 +- lib/errors/unauthorized-request-error.js | 4 +- lib/errors/unsupported-grant-type-error.js | 4 +- lib/errors/unsupported-response-type-error.js | 4 +- lib/grant-types/abstract-grant-type.js | 12 +- .../authorization-code-grant-type.js | 24 +- .../client-credentials-grant-type.js | 18 +- lib/grant-types/password-grant-type.js | 22 +- lib/grant-types/refresh-token-grant-type.js | 22 +- lib/handlers/authenticate-handler.js | 32 +- lib/handlers/authorize-handler.js | 70 +-- lib/handlers/token-handler.js | 54 +-- lib/models/token-model.js | 6 +- lib/request.js | 8 +- lib/response-types/code-response-type.js | 6 +- lib/response-types/token-response-type.js | 2 +- lib/response.js | 4 +- lib/server.js | 8 +- lib/token-types/bearer-token-type.js | 6 +- lib/token-types/mac-token-type.js | 2 +- lib/utils/token-util.js | 4 +- lib/validator/is.js | 2 +- test/assertions.js | 4 +- .../grant-types/abstract-grant-type_test.js | 54 +-- .../authorization-code-grant-type_test.js | 258 +++++------ .../client-credentials-grant-type_test.js | 110 ++--- .../grant-types/password-grant-type_test.js | 150 +++---- .../refresh-token-grant-type_test.js | 230 +++++----- .../handlers/authenticate-handler_test.js | 176 ++++---- .../handlers/authorize-handler_test.js | 382 ++++++++-------- .../handlers/token-handler_test.js | 420 +++++++++--------- test/integration/request_test.js | 28 +- .../response-types/code-response-type_test.js | 20 +- test/integration/response_test.js | 18 +- test/integration/server_test.js | 94 ++-- .../token-types/bearer-token-type_test.js | 28 +- test/integration/utils/token-util_test.js | 4 +- .../grant-types/abstract-grant-type_test.js | 14 +- .../authorization-code-grant-type_test.js | 32 +- .../client-credentials-grant-type_test.js | 20 +- .../grant-types/password-grant-type_test.js | 22 +- .../refresh-token-grant-type_test.js | 68 +-- .../handlers/authenticate-handler_test.js | 40 +- test/unit/handlers/authorize-handler_test.js | 36 +- test/unit/handlers/token-handler_test.js | 14 +- test/unit/models/token-model_test.js | 10 +- test/unit/request_test.js | 50 +-- test/unit/response_test.js | 40 +- test/unit/server_test.js | 28 +- test/unit/validator/is_test.js | 30 +- 60 files changed, 1372 insertions(+), 1372 deletions(-) diff --git a/lib/errors/access-denied-error.js b/lib/errors/access-denied-error.js index 0f3dc2f19..ce5c0af43 100644 --- a/lib/errors/access-denied-error.js +++ b/lib/errors/access-denied-error.js @@ -4,8 +4,8 @@ * Module dependencies. */ -var OAuthError = require('./oauth-error'); -var util = require('util'); +const OAuthError = require('./oauth-error'); +const util = require('util'); /** * Constructor. diff --git a/lib/errors/insufficient-scope-error.js b/lib/errors/insufficient-scope-error.js index c522df747..a27ad6814 100644 --- a/lib/errors/insufficient-scope-error.js +++ b/lib/errors/insufficient-scope-error.js @@ -4,8 +4,8 @@ * Module dependencies. */ -var OAuthError = require('./oauth-error'); -var util = require('util'); +const OAuthError = require('./oauth-error'); +const util = require('util'); /** * Constructor. diff --git a/lib/errors/invalid-argument-error.js b/lib/errors/invalid-argument-error.js index b667468f7..1958caa74 100644 --- a/lib/errors/invalid-argument-error.js +++ b/lib/errors/invalid-argument-error.js @@ -4,8 +4,8 @@ * Module dependencies. */ -var OAuthError = require('./oauth-error'); -var util = require('util'); +const OAuthError = require('./oauth-error'); +const util = require('util'); /** * Constructor. diff --git a/lib/errors/invalid-client-error.js b/lib/errors/invalid-client-error.js index 31aea2df3..1513d5722 100644 --- a/lib/errors/invalid-client-error.js +++ b/lib/errors/invalid-client-error.js @@ -4,8 +4,8 @@ * Module dependencies. */ -var OAuthError = require('./oauth-error'); -var util = require('util'); +const OAuthError = require('./oauth-error'); +const util = require('util'); /** * Constructor. diff --git a/lib/errors/invalid-grant-error.js b/lib/errors/invalid-grant-error.js index 810242d07..2c6a568a1 100644 --- a/lib/errors/invalid-grant-error.js +++ b/lib/errors/invalid-grant-error.js @@ -4,8 +4,8 @@ * Module dependencies. */ -var OAuthError = require('./oauth-error'); -var util = require('util'); +const OAuthError = require('./oauth-error'); +const util = require('util'); /** * Constructor. diff --git a/lib/errors/invalid-request-error.js b/lib/errors/invalid-request-error.js index bfb178a96..56e997ec9 100644 --- a/lib/errors/invalid-request-error.js +++ b/lib/errors/invalid-request-error.js @@ -4,8 +4,8 @@ * Module dependencies. */ -var OAuthError = require('./oauth-error'); -var util = require('util'); +const OAuthError = require('./oauth-error'); +const util = require('util'); /** * Constructor. diff --git a/lib/errors/invalid-scope-error.js b/lib/errors/invalid-scope-error.js index bcded24bd..2f5746d17 100644 --- a/lib/errors/invalid-scope-error.js +++ b/lib/errors/invalid-scope-error.js @@ -4,8 +4,8 @@ * Module dependencies. */ -var OAuthError = require('./oauth-error'); -var util = require('util'); +const OAuthError = require('./oauth-error'); +const util = require('util'); /** * Constructor. diff --git a/lib/errors/invalid-token-error.js b/lib/errors/invalid-token-error.js index cb12c3e2e..e79d9261a 100644 --- a/lib/errors/invalid-token-error.js +++ b/lib/errors/invalid-token-error.js @@ -4,8 +4,8 @@ * Module dependencies. */ -var OAuthError = require('./oauth-error'); -var util = require('util'); +const OAuthError = require('./oauth-error'); +const util = require('util'); /** * Constructor. diff --git a/lib/errors/oauth-error.js b/lib/errors/oauth-error.js index fc66f75fc..a96a41fee 100644 --- a/lib/errors/oauth-error.js +++ b/lib/errors/oauth-error.js @@ -3,15 +3,15 @@ /** * Module dependencies. */ -var util = require('util'); -var http = require('http'); +const util = require('util'); +const http = require('http'); /** * Constructor. */ function OAuthError(messageOrError, properties) { - var message = messageOrError instanceof Error ? messageOrError.message : messageOrError; - var error = messageOrError instanceof Error ? messageOrError : null; + let message = messageOrError instanceof Error ? messageOrError.message : messageOrError; + const error = messageOrError instanceof Error ? messageOrError : null; if (properties == null || !Object.entries(properties).length ) { properties = {}; } @@ -26,7 +26,7 @@ function OAuthError(messageOrError, properties) { } this.code = this.status = this.statusCode = properties.code; this.message = message; - for (var key in properties) { + for (const key in properties) { if (key !== 'code') { this[key] = properties[key]; } diff --git a/lib/errors/server-error.js b/lib/errors/server-error.js index a1bdcf9de..aee958b71 100644 --- a/lib/errors/server-error.js +++ b/lib/errors/server-error.js @@ -4,8 +4,8 @@ * Module dependencies. */ -var OAuthError = require('./oauth-error'); -var util = require('util'); +const OAuthError = require('./oauth-error'); +const util = require('util'); /** * Constructor. diff --git a/lib/errors/unauthorized-client-error.js b/lib/errors/unauthorized-client-error.js index eca0d68fc..fde3cb5c5 100644 --- a/lib/errors/unauthorized-client-error.js +++ b/lib/errors/unauthorized-client-error.js @@ -4,8 +4,8 @@ * Module dependencies. */ -var OAuthError = require('./oauth-error'); -var util = require('util'); +const OAuthError = require('./oauth-error'); +const util = require('util'); /** * Constructor. diff --git a/lib/errors/unauthorized-request-error.js b/lib/errors/unauthorized-request-error.js index afb11b8f5..e96048962 100644 --- a/lib/errors/unauthorized-request-error.js +++ b/lib/errors/unauthorized-request-error.js @@ -4,8 +4,8 @@ * Module dependencies. */ -var OAuthError = require('./oauth-error'); -var util = require('util'); +const OAuthError = require('./oauth-error'); +const util = require('util'); /** * Constructor. diff --git a/lib/errors/unsupported-grant-type-error.js b/lib/errors/unsupported-grant-type-error.js index 63345cea5..586a743bd 100644 --- a/lib/errors/unsupported-grant-type-error.js +++ b/lib/errors/unsupported-grant-type-error.js @@ -4,8 +4,8 @@ * Module dependencies. */ -var OAuthError = require('./oauth-error'); -var util = require('util'); +const OAuthError = require('./oauth-error'); +const util = require('util'); /** * Constructor. diff --git a/lib/errors/unsupported-response-type-error.js b/lib/errors/unsupported-response-type-error.js index 861ac3492..539551ecd 100644 --- a/lib/errors/unsupported-response-type-error.js +++ b/lib/errors/unsupported-response-type-error.js @@ -4,8 +4,8 @@ * Module dependencies. */ -var OAuthError = require('./oauth-error'); -var util = require('util'); +const OAuthError = require('./oauth-error'); +const util = require('util'); /** * Constructor. diff --git a/lib/grant-types/abstract-grant-type.js b/lib/grant-types/abstract-grant-type.js index 224a473e3..4f73e5592 100644 --- a/lib/grant-types/abstract-grant-type.js +++ b/lib/grant-types/abstract-grant-type.js @@ -4,12 +4,12 @@ * Module dependencies. */ -var InvalidArgumentError = require('../errors/invalid-argument-error'); -var InvalidScopeError = require('../errors/invalid-scope-error'); -var Promise = require('bluebird'); -var promisify = require('promisify-any').use(Promise); -var is = require('../validator/is'); -var tokenUtil = require('../utils/token-util'); +const InvalidArgumentError = require('../errors/invalid-argument-error'); +const InvalidScopeError = require('../errors/invalid-scope-error'); +const Promise = require('bluebird'); +const promisify = require('promisify-any').use(Promise); +const is = require('../validator/is'); +const tokenUtil = require('../utils/token-util'); /** * Constructor. diff --git a/lib/grant-types/authorization-code-grant-type.js b/lib/grant-types/authorization-code-grant-type.js index 97c126793..8f21aeffc 100644 --- a/lib/grant-types/authorization-code-grant-type.js +++ b/lib/grant-types/authorization-code-grant-type.js @@ -4,15 +4,15 @@ * Module dependencies. */ -var AbstractGrantType = require('./abstract-grant-type'); -var InvalidArgumentError = require('../errors/invalid-argument-error'); -var InvalidGrantError = require('../errors/invalid-grant-error'); -var InvalidRequestError = require('../errors/invalid-request-error'); -var Promise = require('bluebird'); -var promisify = require('promisify-any').use(Promise); -var ServerError = require('../errors/server-error'); -var is = require('../validator/is'); -var util = require('util'); +const AbstractGrantType = require('./abstract-grant-type'); +const InvalidArgumentError = require('../errors/invalid-argument-error'); +const InvalidGrantError = require('../errors/invalid-grant-error'); +const InvalidRequestError = require('../errors/invalid-request-error'); +const Promise = require('bluebird'); +const promisify = require('promisify-any').use(Promise); +const ServerError = require('../errors/server-error'); +const is = require('../validator/is'); +const util = require('util'); /** * Constructor. @@ -138,7 +138,7 @@ AuthorizationCodeGrantType.prototype.validateRedirectUri = function(request, cod return; } - var redirectUri = request.body.redirect_uri || request.query.redirect_uri; + const redirectUri = request.body.redirect_uri || request.query.redirect_uri; if (!is.uri(redirectUri)) { throw new InvalidRequestError('Invalid request: `redirect_uri` is not a valid URI'); @@ -175,7 +175,7 @@ AuthorizationCodeGrantType.prototype.revokeAuthorizationCode = function(code) { */ AuthorizationCodeGrantType.prototype.saveToken = function(user, client, authorizationCode, scope) { - var fns = [ + const fns = [ this.validateScope(user, client, scope), this.generateAccessToken(client, user, scope), this.generateRefreshToken(client, user, scope), @@ -186,7 +186,7 @@ AuthorizationCodeGrantType.prototype.saveToken = function(user, client, authoriz return Promise.all(fns) .bind(this) .spread(function(scope, accessToken, refreshToken, accessTokenExpiresAt, refreshTokenExpiresAt) { - var token = { + const token = { accessToken: accessToken, authorizationCode: authorizationCode, accessTokenExpiresAt: accessTokenExpiresAt, diff --git a/lib/grant-types/client-credentials-grant-type.js b/lib/grant-types/client-credentials-grant-type.js index 138333e50..d0af0fe51 100644 --- a/lib/grant-types/client-credentials-grant-type.js +++ b/lib/grant-types/client-credentials-grant-type.js @@ -4,12 +4,12 @@ * Module dependencies. */ -var AbstractGrantType = require('./abstract-grant-type'); -var InvalidArgumentError = require('../errors/invalid-argument-error'); -var InvalidGrantError = require('../errors/invalid-grant-error'); -var Promise = require('bluebird'); -var promisify = require('promisify-any').use(Promise); -var util = require('util'); +const AbstractGrantType = require('./abstract-grant-type'); +const InvalidArgumentError = require('../errors/invalid-argument-error'); +const InvalidGrantError = require('../errors/invalid-grant-error'); +const Promise = require('bluebird'); +const promisify = require('promisify-any').use(Promise); +const util = require('util'); /** * Constructor. @@ -54,7 +54,7 @@ ClientCredentialsGrantType.prototype.handle = function(request, client) { throw new InvalidArgumentError('Missing parameter: `client`'); } - var scope = this.getScope(request); + const scope = this.getScope(request); return Promise.bind(this) .then(function() { @@ -85,7 +85,7 @@ ClientCredentialsGrantType.prototype.getUserFromClient = function(client) { */ ClientCredentialsGrantType.prototype.saveToken = function(user, client, scope) { - var fns = [ + const fns = [ this.validateScope(user, client, scope), this.generateAccessToken(client, user, scope), this.getAccessTokenExpiresAt(client, user, scope) @@ -94,7 +94,7 @@ ClientCredentialsGrantType.prototype.saveToken = function(user, client, scope) { return Promise.all(fns) .bind(this) .spread(function(scope, accessToken, accessTokenExpiresAt) { - var token = { + const token = { accessToken: accessToken, accessTokenExpiresAt: accessTokenExpiresAt, scope: scope diff --git a/lib/grant-types/password-grant-type.js b/lib/grant-types/password-grant-type.js index b7f17935b..70a7c1b43 100644 --- a/lib/grant-types/password-grant-type.js +++ b/lib/grant-types/password-grant-type.js @@ -4,14 +4,14 @@ * Module dependencies. */ -var AbstractGrantType = require('./abstract-grant-type'); -var InvalidArgumentError = require('../errors/invalid-argument-error'); -var InvalidGrantError = require('../errors/invalid-grant-error'); -var InvalidRequestError = require('../errors/invalid-request-error'); -var Promise = require('bluebird'); -var promisify = require('promisify-any').use(Promise); -var is = require('../validator/is'); -var util = require('util'); +const AbstractGrantType = require('./abstract-grant-type'); +const InvalidArgumentError = require('../errors/invalid-argument-error'); +const InvalidGrantError = require('../errors/invalid-grant-error'); +const InvalidRequestError = require('../errors/invalid-request-error'); +const Promise = require('bluebird'); +const promisify = require('promisify-any').use(Promise); +const is = require('../validator/is'); +const util = require('util'); /** * Constructor. @@ -56,7 +56,7 @@ PasswordGrantType.prototype.handle = function(request, client) { throw new InvalidArgumentError('Missing parameter: `client`'); } - var scope = this.getScope(request); + const scope = this.getScope(request); return Promise.bind(this) .then(function() { @@ -103,7 +103,7 @@ PasswordGrantType.prototype.getUser = function(request) { */ PasswordGrantType.prototype.saveToken = function(user, client, scope) { - var fns = [ + const fns = [ this.validateScope(user, client, scope), this.generateAccessToken(client, user, scope), this.generateRefreshToken(client, user, scope), @@ -114,7 +114,7 @@ PasswordGrantType.prototype.saveToken = function(user, client, scope) { return Promise.all(fns) .bind(this) .spread(function(scope, accessToken, refreshToken, accessTokenExpiresAt, refreshTokenExpiresAt) { - var token = { + const token = { accessToken: accessToken, accessTokenExpiresAt: accessTokenExpiresAt, refreshToken: refreshToken, diff --git a/lib/grant-types/refresh-token-grant-type.js b/lib/grant-types/refresh-token-grant-type.js index 19f9010c2..3eac92b7e 100644 --- a/lib/grant-types/refresh-token-grant-type.js +++ b/lib/grant-types/refresh-token-grant-type.js @@ -4,15 +4,15 @@ * Module dependencies. */ -var AbstractGrantType = require('./abstract-grant-type'); -var InvalidArgumentError = require('../errors/invalid-argument-error'); -var InvalidGrantError = require('../errors/invalid-grant-error'); -var InvalidRequestError = require('../errors/invalid-request-error'); -var Promise = require('bluebird'); -var promisify = require('promisify-any').use(Promise); -var ServerError = require('../errors/server-error'); -var is = require('../validator/is'); -var util = require('util'); +const AbstractGrantType = require('./abstract-grant-type'); +const InvalidArgumentError = require('../errors/invalid-argument-error'); +const InvalidGrantError = require('../errors/invalid-grant-error'); +const InvalidRequestError = require('../errors/invalid-request-error'); +const Promise = require('bluebird'); +const promisify = require('promisify-any').use(Promise); +const ServerError = require('../errors/server-error'); +const is = require('../validator/is'); +const util = require('util'); /** * Constructor. @@ -142,7 +142,7 @@ RefreshTokenGrantType.prototype.revokeToken = function(token) { */ RefreshTokenGrantType.prototype.saveToken = function(user, client, scope) { - var fns = [ + const fns = [ this.generateAccessToken(client, user, scope), this.generateRefreshToken(client, user, scope), this.getAccessTokenExpiresAt(), @@ -152,7 +152,7 @@ RefreshTokenGrantType.prototype.saveToken = function(user, client, scope) { return Promise.all(fns) .bind(this) .spread(function(accessToken, refreshToken, accessTokenExpiresAt, refreshTokenExpiresAt) { - var token = { + const token = { accessToken: accessToken, accessTokenExpiresAt: accessTokenExpiresAt, scope: scope diff --git a/lib/handlers/authenticate-handler.js b/lib/handlers/authenticate-handler.js index dc9117b27..b02b12319 100644 --- a/lib/handlers/authenticate-handler.js +++ b/lib/handlers/authenticate-handler.js @@ -4,17 +4,17 @@ * Module dependencies. */ -var InvalidArgumentError = require('../errors/invalid-argument-error'); -var InvalidRequestError = require('../errors/invalid-request-error'); -var InsufficientScopeError = require('../errors/insufficient-scope-error'); -var InvalidTokenError = require('../errors/invalid-token-error'); -var OAuthError = require('../errors/oauth-error'); -var Promise = require('bluebird'); -var promisify = require('promisify-any').use(Promise); -var Request = require('../request'); -var Response = require('../response'); -var ServerError = require('../errors/server-error'); -var UnauthorizedRequestError = require('../errors/unauthorized-request-error'); +const InvalidArgumentError = require('../errors/invalid-argument-error'); +const InvalidRequestError = require('../errors/invalid-request-error'); +const InsufficientScopeError = require('../errors/insufficient-scope-error'); +const InvalidTokenError = require('../errors/invalid-token-error'); +const OAuthError = require('../errors/oauth-error'); +const Promise = require('bluebird'); +const promisify = require('promisify-any').use(Promise); +const Request = require('../request'); +const Response = require('../response'); +const ServerError = require('../errors/server-error'); +const UnauthorizedRequestError = require('../errors/unauthorized-request-error'); /** * Constructor. @@ -109,9 +109,9 @@ AuthenticateHandler.prototype.handle = function(request, response) { */ AuthenticateHandler.prototype.getTokenFromRequest = function(request) { - var headerToken = request.get('Authorization'); - var queryToken = request.query.access_token; - var bodyToken = request.body.access_token; + const headerToken = request.get('Authorization'); + const queryToken = request.query.access_token; + const bodyToken = request.body.access_token; if (!!headerToken + !!queryToken + !!bodyToken > 1) { throw new InvalidRequestError('Invalid request: only one authentication method is allowed'); @@ -139,8 +139,8 @@ AuthenticateHandler.prototype.getTokenFromRequest = function(request) { */ AuthenticateHandler.prototype.getTokenFromRequestHeader = function(request) { - var token = request.get('Authorization'); - var matches = token.match(/Bearer\s(\S+)/); + const token = request.get('Authorization'); + const matches = token.match(/Bearer\s(\S+)/); if (!matches) { throw new InvalidRequestError('Invalid request: malformed authorization header'); diff --git a/lib/handlers/authorize-handler.js b/lib/handlers/authorize-handler.js index 7cd89a154..e82501264 100644 --- a/lib/handlers/authorize-handler.js +++ b/lib/handlers/authorize-handler.js @@ -4,29 +4,29 @@ * Module dependencies. */ -var AccessDeniedError = require('../errors/access-denied-error'); -var AuthenticateHandler = require('../handlers/authenticate-handler'); -var InvalidArgumentError = require('../errors/invalid-argument-error'); -var InvalidClientError = require('../errors/invalid-client-error'); -var InvalidRequestError = require('../errors/invalid-request-error'); -var InvalidScopeError = require('../errors/invalid-scope-error'); -var UnsupportedResponseTypeError = require('../errors/unsupported-response-type-error'); -var OAuthError = require('../errors/oauth-error'); -var Promise = require('bluebird'); -var promisify = require('promisify-any').use(Promise); -var Request = require('../request'); -var Response = require('../response'); -var ServerError = require('../errors/server-error'); -var UnauthorizedClientError = require('../errors/unauthorized-client-error'); -var is = require('../validator/is'); -var tokenUtil = require('../utils/token-util'); -var url = require('url'); +const AccessDeniedError = require('../errors/access-denied-error'); +const AuthenticateHandler = require('../handlers/authenticate-handler'); +const InvalidArgumentError = require('../errors/invalid-argument-error'); +const InvalidClientError = require('../errors/invalid-client-error'); +const InvalidRequestError = require('../errors/invalid-request-error'); +const InvalidScopeError = require('../errors/invalid-scope-error'); +const UnsupportedResponseTypeError = require('../errors/unsupported-response-type-error'); +const OAuthError = require('../errors/oauth-error'); +const Promise = require('bluebird'); +const promisify = require('promisify-any').use(Promise); +const Request = require('../request'); +const Response = require('../response'); +const ServerError = require('../errors/server-error'); +const UnauthorizedClientError = require('../errors/unauthorized-client-error'); +const is = require('../validator/is'); +const tokenUtil = require('../utils/token-util'); +const url = require('url'); /** * Response types. */ -var responseTypes = { +const responseTypes = { code: require('../response-types/code-response-type'), //token: require('../response-types/token-response-type') }; @@ -81,7 +81,7 @@ AuthorizeHandler.prototype.handle = function(request, response) { return Promise.reject(new AccessDeniedError('Access denied: user denied access to application')); } - var fns = [ + const fns = [ this.getAuthorizationCodeLifetime(), this.getClient(request), this.getUser(request, response) @@ -90,14 +90,14 @@ AuthorizeHandler.prototype.handle = function(request, response) { return Promise.all(fns) .bind(this) .spread(function(expiresAt, client, user) { - var uri = this.getRedirectUri(request, client); - var scope; - var state; - var ResponseType; + const uri = this.getRedirectUri(request, client); + let scope; + let state; + let ResponseType; return Promise.bind(this) .then(function() { - var requestedScope = this.getScope(request); + const requestedScope = this.getScope(request); return this.validateScope(user, client, requestedScope); }) @@ -113,8 +113,8 @@ AuthorizeHandler.prototype.handle = function(request, response) { return this.saveAuthorizationCode(authorizationCode, expiresAt, scope, client, uri, user); }) .then(function(code) { - var responseType = new ResponseType(code.authorizationCode); - var redirectUri = this.buildSuccessRedirectUri(uri, responseType); + const responseType = new ResponseType(code.authorizationCode); + const redirectUri = this.buildSuccessRedirectUri(uri, responseType); this.updateResponse(response, redirectUri, state); @@ -124,7 +124,7 @@ AuthorizeHandler.prototype.handle = function(request, response) { if (!(e instanceof OAuthError)) { e = new ServerError(e); } - var redirectUri = this.buildErrorRedirectUri(uri, e); + const redirectUri = this.buildErrorRedirectUri(uri, e); this.updateResponse(response, redirectUri, state); @@ -149,7 +149,7 @@ AuthorizeHandler.prototype.generateAuthorizationCode = function(client, user, sc */ AuthorizeHandler.prototype.getAuthorizationCodeLifetime = function() { - var expires = new Date(); + const expires = new Date(); expires.setSeconds(expires.getSeconds() + this.authorizationCodeLifetime); return expires; @@ -160,7 +160,7 @@ AuthorizeHandler.prototype.getAuthorizationCodeLifetime = function() { */ AuthorizeHandler.prototype.getClient = function(request) { - var clientId = request.body.client_id || request.query.client_id; + const clientId = request.body.client_id || request.query.client_id; if (!clientId) { throw new InvalidRequestError('Missing parameter: `client_id`'); @@ -170,7 +170,7 @@ AuthorizeHandler.prototype.getClient = function(request) { throw new InvalidRequestError('Invalid parameter: `client_id`'); } - var redirectUri = request.body.redirect_uri || request.query.redirect_uri; + const redirectUri = request.body.redirect_uri || request.query.redirect_uri; if (redirectUri && !is.uri(redirectUri)) { throw new InvalidRequestError('Invalid request: `redirect_uri` is not a valid URI'); @@ -223,7 +223,7 @@ AuthorizeHandler.prototype.validateScope = function(user, client, scope) { */ AuthorizeHandler.prototype.getScope = function(request) { - var scope = request.body.scope || request.query.scope; + const scope = request.body.scope || request.query.scope; if (!is.nqschar(scope)) { throw new InvalidScopeError('Invalid parameter: `scope`'); @@ -237,7 +237,7 @@ AuthorizeHandler.prototype.getScope = function(request) { */ AuthorizeHandler.prototype.getState = function(request) { - var state = request.body.state || request.query.state; + const state = request.body.state || request.query.state; if (!this.allowEmptyState && !state) { throw new InvalidRequestError('Missing parameter: `state`'); @@ -280,7 +280,7 @@ AuthorizeHandler.prototype.getRedirectUri = function(request, client) { */ AuthorizeHandler.prototype.saveAuthorizationCode = function(authorizationCode, expiresAt, scope, client, redirectUri, user) { - var code = { + const code = { authorizationCode: authorizationCode, expiresAt: expiresAt, redirectUri: redirectUri, @@ -294,7 +294,7 @@ AuthorizeHandler.prototype.saveAuthorizationCode = function(authorizationCode, e */ AuthorizeHandler.prototype.getResponseType = function(request) { - var responseType = request.body.response_type || request.query.response_type; + const responseType = request.body.response_type || request.query.response_type; if (!responseType) { throw new InvalidRequestError('Missing parameter: `response_type`'); @@ -320,7 +320,7 @@ AuthorizeHandler.prototype.buildSuccessRedirectUri = function(redirectUri, respo */ AuthorizeHandler.prototype.buildErrorRedirectUri = function(redirectUri, error) { - var uri = url.parse(redirectUri); + const uri = url.parse(redirectUri); uri.query = { error: error.name diff --git a/lib/handlers/token-handler.js b/lib/handlers/token-handler.js index 895ce2e5a..81959699d 100644 --- a/lib/handlers/token-handler.js +++ b/lib/handlers/token-handler.js @@ -4,27 +4,27 @@ * Module dependencies. */ -var BearerTokenType = require('../token-types/bearer-token-type'); -var InvalidArgumentError = require('../errors/invalid-argument-error'); -var InvalidClientError = require('../errors/invalid-client-error'); -var InvalidRequestError = require('../errors/invalid-request-error'); -var OAuthError = require('../errors/oauth-error'); -var Promise = require('bluebird'); -var promisify = require('promisify-any').use(Promise); -var Request = require('../request'); -var Response = require('../response'); -var ServerError = require('../errors/server-error'); -var TokenModel = require('../models/token-model'); -var UnauthorizedClientError = require('../errors/unauthorized-client-error'); -var UnsupportedGrantTypeError = require('../errors/unsupported-grant-type-error'); -var auth = require('basic-auth'); -var is = require('../validator/is'); +const BearerTokenType = require('../token-types/bearer-token-type'); +const InvalidArgumentError = require('../errors/invalid-argument-error'); +const InvalidClientError = require('../errors/invalid-client-error'); +const InvalidRequestError = require('../errors/invalid-request-error'); +const OAuthError = require('../errors/oauth-error'); +const Promise = require('bluebird'); +const promisify = require('promisify-any').use(Promise); +const Request = require('../request'); +const Response = require('../response'); +const ServerError = require('../errors/server-error'); +const TokenModel = require('../models/token-model'); +const UnauthorizedClientError = require('../errors/unauthorized-client-error'); +const UnsupportedGrantTypeError = require('../errors/unsupported-grant-type-error'); +const auth = require('basic-auth'); +const is = require('../validator/is'); /** * Grant types. */ -var grantTypes = { +const grantTypes = { authorization_code: require('../grant-types/authorization-code-grant-type'), client_credentials: require('../grant-types/client-credentials-grant-type'), password: require('../grant-types/password-grant-type'), @@ -92,8 +92,8 @@ TokenHandler.prototype.handle = function(request, response) { return this.handleGrantType(request, client); }) .tap(function(data) { - var model = new TokenModel(data, {allowExtendedTokenAttributes: this.allowExtendedTokenAttributes}); - var tokenType = this.getTokenType(model); + const model = new TokenModel(data, {allowExtendedTokenAttributes: this.allowExtendedTokenAttributes}); + const tokenType = this.getTokenType(model); this.updateSuccessResponse(response, tokenType); }).catch(function(e) { @@ -112,8 +112,8 @@ TokenHandler.prototype.handle = function(request, response) { */ TokenHandler.prototype.getClient = function(request, response) { - var credentials = this.getClientCredentials(request); - var grantType = request.body.grant_type; + const credentials = this.getClientCredentials(request); + const grantType = request.body.grant_type; if (!credentials.clientId) { throw new InvalidRequestError('Missing parameter: `client_id`'); @@ -172,8 +172,8 @@ TokenHandler.prototype.getClient = function(request, response) { */ TokenHandler.prototype.getClientCredentials = function(request) { - var credentials = auth(request); - var grantType = request.body.grant_type; + const credentials = auth(request); + const grantType = request.body.grant_type; if (credentials) { return { clientId: credentials.name, clientSecret: credentials.pass }; @@ -197,7 +197,7 @@ TokenHandler.prototype.getClientCredentials = function(request) { */ TokenHandler.prototype.handleGrantType = function(request, client) { - var grantType = request.body.grant_type; + const grantType = request.body.grant_type; if (!grantType) { throw new InvalidRequestError('Missing parameter: `grant_type`'); @@ -215,11 +215,11 @@ TokenHandler.prototype.handleGrantType = function(request, client) { throw new UnauthorizedClientError('Unauthorized client: `grant_type` is invalid'); } - var accessTokenLifetime = this.getAccessTokenLifetime(client); - var refreshTokenLifetime = this.getRefreshTokenLifetime(client); - var Type = this.grantTypes[grantType]; + const accessTokenLifetime = this.getAccessTokenLifetime(client); + const refreshTokenLifetime = this.getRefreshTokenLifetime(client); + const Type = this.grantTypes[grantType]; - var options = { + const options = { accessTokenLifetime: accessTokenLifetime, model: this.model, refreshTokenLifetime: refreshTokenLifetime, diff --git a/lib/models/token-model.js b/lib/models/token-model.js index 37bb133e5..473c7ace8 100644 --- a/lib/models/token-model.js +++ b/lib/models/token-model.js @@ -4,13 +4,13 @@ * Module dependencies. */ -var InvalidArgumentError = require('../errors/invalid-argument-error'); +const InvalidArgumentError = require('../errors/invalid-argument-error'); /** * Constructor. */ -var modelAttributes = ['accessToken', 'accessTokenExpiresAt', 'refreshToken', 'refreshTokenExpiresAt', 'scope', 'client', 'user']; +const modelAttributes = ['accessToken', 'accessTokenExpiresAt', 'refreshToken', 'refreshTokenExpiresAt', 'scope', 'client', 'user']; function TokenModel(data, options) { data = data || {}; @@ -46,7 +46,7 @@ function TokenModel(data, options) { if (options && options.allowExtendedTokenAttributes) { this.customAttributes = {}; - for (var key in data) { + for (const key in data) { if ( Object.prototype.hasOwnProperty.call(data, key) && (modelAttributes.indexOf(key) < 0)) { this.customAttributes[key] = data[key]; } diff --git a/lib/request.js b/lib/request.js index 00b879586..560b29bce 100644 --- a/lib/request.js +++ b/lib/request.js @@ -4,8 +4,8 @@ * Module dependencies. */ -var InvalidArgumentError = require('./errors/invalid-argument-error'); -var typeis = require('type-is'); +const InvalidArgumentError = require('./errors/invalid-argument-error'); +const typeis = require('type-is'); /** * Constructor. @@ -32,14 +32,14 @@ function Request(options) { this.query = options.query; // Store the headers in lower case. - for (var field in options.headers) { + for (const field in options.headers) { if (Object.prototype.hasOwnProperty.call(options.headers, field)) { this.headers[field.toLowerCase()] = options.headers[field]; } } // Store additional properties of the request object passed in - for (var property in options) { + for (const property in options) { if (Object.prototype.hasOwnProperty.call(options, property) && !this[property]) { this[property] = options[property]; } diff --git a/lib/response-types/code-response-type.js b/lib/response-types/code-response-type.js index 6eaf23a89..8252248fb 100644 --- a/lib/response-types/code-response-type.js +++ b/lib/response-types/code-response-type.js @@ -4,8 +4,8 @@ * Module dependencies. */ -var InvalidArgumentError = require('../errors/invalid-argument-error'); -var url = require('url'); +const InvalidArgumentError = require('../errors/invalid-argument-error'); +const url = require('url'); /** * Constructor. @@ -28,7 +28,7 @@ CodeResponseType.prototype.buildRedirectUri = function(redirectUri) { throw new InvalidArgumentError('Missing parameter: `redirectUri`'); } - var uri = url.parse(redirectUri, true); + const uri = url.parse(redirectUri, true); uri.query.code = this.code; uri.search = null; diff --git a/lib/response-types/token-response-type.js b/lib/response-types/token-response-type.js index 2637f64cd..29c32e709 100644 --- a/lib/response-types/token-response-type.js +++ b/lib/response-types/token-response-type.js @@ -4,7 +4,7 @@ * Module dependencies. */ -var ServerError = require('../errors/server-error'); +const ServerError = require('../errors/server-error'); /** * Constructor. diff --git a/lib/response.js b/lib/response.js index 76fe854ab..29a2c5170 100644 --- a/lib/response.js +++ b/lib/response.js @@ -12,14 +12,14 @@ function Response(options) { this.status = 200; // Store the headers in lower case. - for (var field in options.headers) { + for (const field in options.headers) { if (Object.prototype.hasOwnProperty.call(options.headers, field)) { this.headers[field.toLowerCase()] = options.headers[field]; } } // Store additional properties of the response object passed in - for (var property in options) { + for (const property in options) { if (Object.prototype.hasOwnProperty.call(options, property) && !this[property]) { this[property] = options[property]; } diff --git a/lib/server.js b/lib/server.js index a588f8090..53bbd2aaf 100644 --- a/lib/server.js +++ b/lib/server.js @@ -4,10 +4,10 @@ * Module dependencies. */ -var AuthenticateHandler = require('./handlers/authenticate-handler'); -var AuthorizeHandler = require('./handlers/authorize-handler'); -var InvalidArgumentError = require('./errors/invalid-argument-error'); -var TokenHandler = require('./handlers/token-handler'); +const AuthenticateHandler = require('./handlers/authenticate-handler'); +const AuthorizeHandler = require('./handlers/authorize-handler'); +const InvalidArgumentError = require('./errors/invalid-argument-error'); +const TokenHandler = require('./handlers/token-handler'); /** * Constructor. diff --git a/lib/token-types/bearer-token-type.js b/lib/token-types/bearer-token-type.js index 944084959..0bf526d0e 100644 --- a/lib/token-types/bearer-token-type.js +++ b/lib/token-types/bearer-token-type.js @@ -4,7 +4,7 @@ * Module dependencies. */ -var InvalidArgumentError = require('../errors/invalid-argument-error'); +const InvalidArgumentError = require('../errors/invalid-argument-error'); /** * Constructor. @@ -30,7 +30,7 @@ function BearerTokenType(accessToken, accessTokenLifetime, refreshToken, scope, */ BearerTokenType.prototype.valueOf = function() { - var object = { + const object = { access_token: this.accessToken, token_type: 'Bearer' }; @@ -47,7 +47,7 @@ BearerTokenType.prototype.valueOf = function() { object.scope = this.scope; } - for (var key in this.customAttributes) { + for (const key in this.customAttributes) { if ( Object.prototype.hasOwnProperty.call(this.customAttributes, key) ) { object[key] = this.customAttributes[key]; } diff --git a/lib/token-types/mac-token-type.js b/lib/token-types/mac-token-type.js index 9fdc600c6..a5dd240a7 100644 --- a/lib/token-types/mac-token-type.js +++ b/lib/token-types/mac-token-type.js @@ -4,7 +4,7 @@ * Module dependencies. */ -var ServerError = require('../errors/server-error'); +const ServerError = require('../errors/server-error'); /** * Constructor. diff --git a/lib/utils/token-util.js b/lib/utils/token-util.js index 96d05c0de..a66e25237 100644 --- a/lib/utils/token-util.js +++ b/lib/utils/token-util.js @@ -4,8 +4,8 @@ * Module dependencies. */ -var crypto = require('crypto'); -var randomBytes = require('bluebird').promisify(require('crypto').randomBytes); +const crypto = require('crypto'); +const randomBytes = require('bluebird').promisify(require('crypto').randomBytes); /** * Export `TokenUtil`. diff --git a/lib/validator/is.js b/lib/validator/is.js index a240e936a..4bb58c55a 100644 --- a/lib/validator/is.js +++ b/lib/validator/is.js @@ -5,7 +5,7 @@ * Validation rules. */ -var rules = { +const rules = { NCHAR: /^[\u002D\u002E\u005F\w]+$/, NQCHAR: /^[\u0021\u0023-\u005B\u005D-\u007E]+$/, NQSCHAR: /^[\u0020-\u0021\u0023-\u005B\u005D-\u007E]+$/, diff --git a/test/assertions.js b/test/assertions.js index 7ebf85ffd..7a95c809d 100644 --- a/test/assertions.js +++ b/test/assertions.js @@ -4,7 +4,7 @@ * Module dependencies. */ -var chai = require('chai'); +const chai = require('chai'); /** * SHA-256 assertion. @@ -12,7 +12,7 @@ var chai = require('chai'); chai.use(function (_chai, utils) { chai.Assertion.addMethod('sha256', function (...args) { - var obj = utils.flag(this, 'object'); + const obj = utils.flag(this, 'object'); new chai.Assertion(obj).match(/^[a-f0-9]{64}$/i); }); }); diff --git a/test/integration/grant-types/abstract-grant-type_test.js b/test/integration/grant-types/abstract-grant-type_test.js index 160ba21e9..a6c4d2be9 100644 --- a/test/integration/grant-types/abstract-grant-type_test.js +++ b/test/integration/grant-types/abstract-grant-type_test.js @@ -4,11 +4,11 @@ * Module dependencies. */ -var AbstractGrantType = require('../../../lib/grant-types/abstract-grant-type'); -var InvalidArgumentError = require('../../../lib/errors/invalid-argument-error'); -var Promise = require('bluebird'); -var Request = require('../../../lib/request'); -var should = require('chai').should(); +const AbstractGrantType = require('../../../lib/grant-types/abstract-grant-type'); +const InvalidArgumentError = require('../../../lib/errors/invalid-argument-error'); +const Promise = require('bluebird'); +const Request = require('../../../lib/request'); +const should = require('chai').should(); /** * Test `AbstractGrantType` integration. @@ -39,20 +39,20 @@ describe('AbstractGrantType integration', function() { }); it('should set the `accessTokenLifetime`', function() { - var grantType = new AbstractGrantType({ accessTokenLifetime: 123, model: {} }); + const grantType = new AbstractGrantType({ accessTokenLifetime: 123, model: {} }); grantType.accessTokenLifetime.should.equal(123); }); it('should set the `model`', function() { - var model = {}; - var grantType = new AbstractGrantType({ accessTokenLifetime: 123, model: model }); + const model = {}; + const grantType = new AbstractGrantType({ accessTokenLifetime: 123, model: model }); grantType.model.should.equal(model); }); it('should set the `refreshTokenLifetime`', function() { - var grantType = new AbstractGrantType({ accessTokenLifetime: 123, model: {}, refreshTokenLifetime: 456 }); + const grantType = new AbstractGrantType({ accessTokenLifetime: 123, model: {}, refreshTokenLifetime: 456 }); grantType.refreshTokenLifetime.should.equal(456); }); @@ -60,7 +60,7 @@ describe('AbstractGrantType integration', function() { describe('generateAccessToken()', function() { it('should return an access token', function() { - var handler = new AbstractGrantType({ accessTokenLifetime: 123, model: {}, refreshTokenLifetime: 456 }); + const handler = new AbstractGrantType({ accessTokenLifetime: 123, model: {}, refreshTokenLifetime: 456 }); return handler.generateAccessToken() .then(function(data) { @@ -70,23 +70,23 @@ describe('AbstractGrantType integration', function() { }); it('should support promises', function() { - var model = { + const model = { generateAccessToken: function() { return Promise.resolve({}); } }; - var handler = new AbstractGrantType({ accessTokenLifetime: 123, model: model, refreshTokenLifetime: 456 }); + const handler = new AbstractGrantType({ accessTokenLifetime: 123, model: model, refreshTokenLifetime: 456 }); handler.generateAccessToken().should.be.an.instanceOf(Promise); }); it('should support non-promises', function() { - var model = { + const model = { generateAccessToken: function() { return {}; } }; - var handler = new AbstractGrantType({ accessTokenLifetime: 123, model: model, refreshTokenLifetime: 456 }); + const handler = new AbstractGrantType({ accessTokenLifetime: 123, model: model, refreshTokenLifetime: 456 }); handler.generateAccessToken().should.be.an.instanceOf(Promise); }); @@ -94,7 +94,7 @@ describe('AbstractGrantType integration', function() { describe('generateRefreshToken()', function() { it('should return a refresh token', function() { - var handler = new AbstractGrantType({ accessTokenLifetime: 123, model: {}, refreshTokenLifetime: 456 }); + const handler = new AbstractGrantType({ accessTokenLifetime: 123, model: {}, refreshTokenLifetime: 456 }); return handler.generateRefreshToken() .then(function(data) { @@ -104,23 +104,23 @@ describe('AbstractGrantType integration', function() { }); it('should support promises', function() { - var model = { + const model = { generateRefreshToken: function() { return Promise.resolve({}); } }; - var handler = new AbstractGrantType({ accessTokenLifetime: 123, model: model, refreshTokenLifetime: 456 }); + const handler = new AbstractGrantType({ accessTokenLifetime: 123, model: model, refreshTokenLifetime: 456 }); handler.generateRefreshToken().should.be.an.instanceOf(Promise); }); it('should support non-promises', function() { - var model = { + const model = { generateRefreshToken: function() { return {}; } }; - var handler = new AbstractGrantType({ accessTokenLifetime: 123, model: model, refreshTokenLifetime: 456 }); + const handler = new AbstractGrantType({ accessTokenLifetime: 123, model: model, refreshTokenLifetime: 456 }); handler.generateRefreshToken().should.be.an.instanceOf(Promise); }); @@ -128,7 +128,7 @@ describe('AbstractGrantType integration', function() { describe('getAccessTokenExpiresAt()', function() { it('should return a date', function() { - var handler = new AbstractGrantType({ accessTokenLifetime: 123, model: {}, refreshTokenLifetime: 456 }); + const handler = new AbstractGrantType({ accessTokenLifetime: 123, model: {}, refreshTokenLifetime: 456 }); handler.getAccessTokenExpiresAt().should.be.an.instanceOf(Date); }); @@ -136,7 +136,7 @@ describe('AbstractGrantType integration', function() { describe('getRefreshTokenExpiresAt()', function() { it('should return a refresh token', function() { - var handler = new AbstractGrantType({ accessTokenLifetime: 123, model: {}, refreshTokenLifetime: 456 }); + const handler = new AbstractGrantType({ accessTokenLifetime: 123, model: {}, refreshTokenLifetime: 456 }); handler.getRefreshTokenExpiresAt().should.be.an.instanceOf(Date); }); @@ -144,8 +144,8 @@ describe('AbstractGrantType integration', function() { describe('getScope()', function() { it('should throw an error if `scope` is invalid', function() { - var handler = new AbstractGrantType({ accessTokenLifetime: 123, model: {}, refreshTokenLifetime: 456 }); - var request = new Request({ body: { scope: 'ø倣‰' }, headers: {}, method: {}, query: {} }); + const handler = new AbstractGrantType({ accessTokenLifetime: 123, model: {}, refreshTokenLifetime: 456 }); + const request = new Request({ body: { scope: 'ø倣‰' }, headers: {}, method: {}, query: {} }); try { handler.getScope(request); @@ -158,15 +158,15 @@ describe('AbstractGrantType integration', function() { }); it('should allow the `scope` to be `undefined`', function() { - var handler = new AbstractGrantType({ accessTokenLifetime: 123, model: {}, refreshTokenLifetime: 456 }); - var request = new Request({ body: {}, headers: {}, method: {}, query: {} }); + const handler = new AbstractGrantType({ accessTokenLifetime: 123, model: {}, refreshTokenLifetime: 456 }); + const request = new Request({ body: {}, headers: {}, method: {}, query: {} }); should.not.exist(handler.getScope(request)); }); it('should return the scope', function() { - var handler = new AbstractGrantType({ accessTokenLifetime: 123, model: {}, refreshTokenLifetime: 456 }); - var request = new Request({ body: { scope: 'foo' }, headers: {}, method: {}, query: {} }); + const handler = new AbstractGrantType({ accessTokenLifetime: 123, model: {}, refreshTokenLifetime: 456 }); + const request = new Request({ body: { scope: 'foo' }, headers: {}, method: {}, query: {} }); handler.getScope(request).should.equal('foo'); }); diff --git a/test/integration/grant-types/authorization-code-grant-type_test.js b/test/integration/grant-types/authorization-code-grant-type_test.js index 417a23ab6..6cddd53fc 100644 --- a/test/integration/grant-types/authorization-code-grant-type_test.js +++ b/test/integration/grant-types/authorization-code-grant-type_test.js @@ -4,14 +4,14 @@ * Module dependencies. */ -var AuthorizationCodeGrantType = require('../../../lib/grant-types/authorization-code-grant-type'); -var InvalidArgumentError = require('../../../lib/errors/invalid-argument-error'); -var InvalidGrantError = require('../../../lib/errors/invalid-grant-error'); -var InvalidRequestError = require('../../../lib/errors/invalid-request-error'); -var Promise = require('bluebird'); -var Request = require('../../../lib/request'); -var ServerError = require('../../../lib/errors/server-error'); -var should = require('chai').should(); +const AuthorizationCodeGrantType = require('../../../lib/grant-types/authorization-code-grant-type'); +const InvalidArgumentError = require('../../../lib/errors/invalid-argument-error'); +const InvalidGrantError = require('../../../lib/errors/invalid-grant-error'); +const InvalidRequestError = require('../../../lib/errors/invalid-request-error'); +const Promise = require('bluebird'); +const Request = require('../../../lib/request'); +const ServerError = require('../../../lib/errors/server-error'); +const should = require('chai').should(); /** * Test `AuthorizationCodeGrantType` integration. @@ -43,7 +43,7 @@ describe('AuthorizationCodeGrantType integration', function() { it('should throw an error if the model does not implement `revokeAuthorizationCode()`', function() { try { - var model = { + const model = { getAuthorizationCode: function() {} }; @@ -58,7 +58,7 @@ describe('AuthorizationCodeGrantType integration', function() { it('should throw an error if the model does not implement `saveToken()`', function() { try { - var model = { + const model = { getAuthorizationCode: function() {}, revokeAuthorizationCode: function() {} }; @@ -75,12 +75,12 @@ describe('AuthorizationCodeGrantType integration', function() { describe('handle()', function() { it('should throw an error if `request` is missing', function() { - var model = { + const model = { getAuthorizationCode: function() {}, revokeAuthorizationCode: function() {}, saveToken: function() {} }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); try { grantType.handle(); @@ -93,14 +93,14 @@ describe('AuthorizationCodeGrantType integration', function() { }); it('should throw an error if `client` is invalid', function() { - var client = {}; - var model = { + const client = {}; + const model = { getAuthorizationCode: function() { return { authorizationCode: 12345, expiresAt: new Date(new Date() * 2), user: {} }; }, revokeAuthorizationCode: function() {}, saveToken: function() {} }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); return grantType.handle(request, client) .then(should.fail) @@ -112,13 +112,13 @@ describe('AuthorizationCodeGrantType integration', function() { it('should throw an error if `client` is missing', function() { - var model = { + const model = { getAuthorizationCode: function() { return { authorizationCode: 12345, expiresAt: new Date(new Date() * 2), user: {} }; }, revokeAuthorizationCode: function() {}, saveToken: function() {} }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); try { grantType.handle(request, null); @@ -130,16 +130,16 @@ describe('AuthorizationCodeGrantType integration', function() { }); it('should return a token', function() { - var client = { id: 'foobar' }; - var token = {}; - var model = { + const client = { id: 'foobar' }; + const token = {}; + const model = { getAuthorizationCode: function() { return { authorizationCode: 12345, client: { id: 'foobar' }, expiresAt: new Date(new Date() * 2), user: {} }; }, revokeAuthorizationCode: function() { return true; }, saveToken: function() { return token; }, validateScope: function() { return 'foo'; } }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); return grantType.handle(request, client) .then(function(data) { @@ -149,40 +149,40 @@ describe('AuthorizationCodeGrantType integration', function() { }); it('should support promises', function() { - var client = { id: 'foobar' }; - var model = { + const client = { id: 'foobar' }; + const model = { getAuthorizationCode: function() { return Promise.resolve({ authorizationCode: 12345, client: { id: 'foobar' }, expiresAt: new Date(new Date() * 2), user: {} }); }, revokeAuthorizationCode: function() { return true; }, saveToken: function() {} }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); grantType.handle(request, client).should.be.an.instanceOf(Promise); }); it('should support non-promises', function() { - var client = { id: 'foobar' }; - var model = { + const client = { id: 'foobar' }; + const model = { getAuthorizationCode: function() { return { authorizationCode: 12345, client: { id: 'foobar' }, expiresAt: new Date(new Date() * 2), user: {} }; }, revokeAuthorizationCode: function() { return true; }, saveToken: function() {} }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); grantType.handle(request, client).should.be.an.instanceOf(Promise); }); it('should support callbacks', function() { - var client = { id: 'foobar' }; - var model = { + const client = { id: 'foobar' }; + const model = { getAuthorizationCode: function(code, callback) { callback(null, { authorizationCode: 12345, client: { id: 'foobar' }, expiresAt: new Date(new Date() * 2), user: {} }); }, revokeAuthorizationCode: function(code, callback) { callback(null, { authorizationCode: 12345, client: { id: 'foobar' }, expiresAt: new Date(new Date() / 2), user: {} }); }, saveToken: function(tokenToSave, client, user, callback) { callback(null, tokenToSave); } }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); grantType.handle(request, client).should.be.an.instanceOf(Promise); }); @@ -190,14 +190,14 @@ describe('AuthorizationCodeGrantType integration', function() { describe('getAuthorizationCode()', function() { it('should throw an error if the request body does not contain `code`', function() { - var client = {}; - var model = { + const client = {}; + const model = { getAuthorizationCode: function() {}, revokeAuthorizationCode: function() {}, saveToken: function() {} }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: {}, headers: {}, method: {}, query: {} }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: {}, headers: {}, method: {}, query: {} }); try { grantType.getAuthorizationCode(request, client); @@ -210,14 +210,14 @@ describe('AuthorizationCodeGrantType integration', function() { }); it('should throw an error if `code` is invalid', function() { - var client = {}; - var model = { + const client = {}; + const model = { getAuthorizationCode: function() {}, revokeAuthorizationCode: function() {}, saveToken: function() {} }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { code: 'ø倣‰' }, headers: {}, method: {}, query: {} }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { code: 'ø倣‰' }, headers: {}, method: {}, query: {} }); try { grantType.getAuthorizationCode(request, client); @@ -230,14 +230,14 @@ describe('AuthorizationCodeGrantType integration', function() { }); it('should throw an error if `authorizationCode` is missing', function() { - var client = {}; - var model = { + const client = {}; + const model = { getAuthorizationCode: function() {}, revokeAuthorizationCode: function() {}, saveToken: function() {} }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); return grantType.getAuthorizationCode(request, client) .then(should.fail) @@ -248,14 +248,14 @@ describe('AuthorizationCodeGrantType integration', function() { }); it('should throw an error if `authorizationCode.client` is missing', function() { - var client = {}; - var model = { + const client = {}; + const model = { getAuthorizationCode: function() { return { authorizationCode: 12345 }; }, revokeAuthorizationCode: function() {}, saveToken: function() {} }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); return grantType.getAuthorizationCode(request, client) .then(should.fail) @@ -266,14 +266,14 @@ describe('AuthorizationCodeGrantType integration', function() { }); it('should throw an error if `authorizationCode.expiresAt` is missing', function() { - var client = {}; - var model = { + const client = {}; + const model = { getAuthorizationCode: function() { return { authorizationCode: 12345, client: {}, user: {} }; }, revokeAuthorizationCode: function() {}, saveToken: function() {} }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); return grantType.getAuthorizationCode(request, client) .then(should.fail) @@ -284,14 +284,14 @@ describe('AuthorizationCodeGrantType integration', function() { }); it('should throw an error if `authorizationCode.user` is missing', function() { - var client = {}; - var model = { + const client = {}; + const model = { getAuthorizationCode: function() { return { authorizationCode: 12345, client: {}, expiresAt: new Date() }; }, revokeAuthorizationCode: function() {}, saveToken: function() {} }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); return grantType.getAuthorizationCode(request, client) .then(should.fail) @@ -302,16 +302,16 @@ describe('AuthorizationCodeGrantType integration', function() { }); it('should throw an error if the client id does not match', function() { - var client = { id: 123 }; - var model = { + const client = { id: 123 }; + const model = { getAuthorizationCode: function() { return { authorizationCode: 12345, expiresAt: new Date(), client: { id: 456 }, user: {} }; }, revokeAuthorizationCode: function() {}, saveToken: function() {} }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); return grantType.getAuthorizationCode(request, client) .then(should.fail) @@ -322,17 +322,17 @@ describe('AuthorizationCodeGrantType integration', function() { }); it('should throw an error if the auth code is expired', function() { - var client = { id: 123 }; - var date = new Date(new Date() / 2); - var model = { + const client = { id: 123 }; + const date = new Date(new Date() / 2); + const model = { getAuthorizationCode: function() { return { authorizationCode: 12345, client: { id: 123 }, expiresAt: date, user: {} }; }, revokeAuthorizationCode: function() {}, saveToken: function() {} }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); return grantType.getAuthorizationCode(request, client) .then(should.fail) @@ -343,15 +343,15 @@ describe('AuthorizationCodeGrantType integration', function() { }); it('should throw an error if the `redirectUri` is invalid', function() { - var authorizationCode = { authorizationCode: 12345, client: { id: 'foobar' }, expiresAt: new Date(new Date() * 2), redirectUri: 'foobar', user: {} }; - var client = { id: 'foobar' }; - var model = { + const authorizationCode = { authorizationCode: 12345, client: { id: 'foobar' }, expiresAt: new Date(new Date() * 2), redirectUri: 'foobar', user: {} }; + const client = { id: 'foobar' }; + const model = { getAuthorizationCode: function() { return authorizationCode; }, revokeAuthorizationCode: function() {}, saveToken: function() {} }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); return grantType.getAuthorizationCode(request, client) .then(should.fail) @@ -362,15 +362,15 @@ describe('AuthorizationCodeGrantType integration', function() { }); it('should return an auth code', function() { - var authorizationCode = { authorizationCode: 12345, client: { id: 'foobar' }, expiresAt: new Date(new Date() * 2), user: {} }; - var client = { id: 'foobar' }; - var model = { + const authorizationCode = { authorizationCode: 12345, client: { id: 'foobar' }, expiresAt: new Date(new Date() * 2), user: {} }; + const client = { id: 'foobar' }; + const model = { getAuthorizationCode: function() { return authorizationCode; }, revokeAuthorizationCode: function() {}, saveToken: function() {} }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); return grantType.getAuthorizationCode(request, client) .then(function(data) { @@ -380,43 +380,43 @@ describe('AuthorizationCodeGrantType integration', function() { }); it('should support promises', function() { - var authorizationCode = { authorizationCode: 12345, client: { id: 'foobar' }, expiresAt: new Date(new Date() * 2), user: {} }; - var client = { id: 'foobar' }; - var model = { + const authorizationCode = { authorizationCode: 12345, client: { id: 'foobar' }, expiresAt: new Date(new Date() * 2), user: {} }; + const client = { id: 'foobar' }; + const model = { getAuthorizationCode: function() { return Promise.resolve(authorizationCode); }, revokeAuthorizationCode: function() {}, saveToken: function() {} }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); grantType.getAuthorizationCode(request, client).should.be.an.instanceOf(Promise); }); it('should support non-promises', function() { - var authorizationCode = { authorizationCode: 12345, client: { id: 'foobar' }, expiresAt: new Date(new Date() * 2), user: {} }; - var client = { id: 'foobar' }; - var model = { + const authorizationCode = { authorizationCode: 12345, client: { id: 'foobar' }, expiresAt: new Date(new Date() * 2), user: {} }; + const client = { id: 'foobar' }; + const model = { getAuthorizationCode: function() { return authorizationCode; }, revokeAuthorizationCode: function() {}, saveToken: function() {} }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); grantType.getAuthorizationCode(request, client).should.be.an.instanceOf(Promise); }); it('should support callbacks', function() { - var authorizationCode = { authorizationCode: 12345, client: { id: 'foobar' }, expiresAt: new Date(new Date() * 2), user: {} }; - var client = { id: 'foobar' }; - var model = { + const authorizationCode = { authorizationCode: 12345, client: { id: 'foobar' }, expiresAt: new Date(new Date() * 2), user: {} }; + const client = { id: 'foobar' }; + const model = { getAuthorizationCode: function(code, callback) { callback(null, authorizationCode); }, revokeAuthorizationCode: function() {}, saveToken: function() {} }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); grantType.getAuthorizationCode(request, client).should.be.an.instanceOf(Promise); }); @@ -424,14 +424,14 @@ describe('AuthorizationCodeGrantType integration', function() { describe('validateRedirectUri()', function() { it('should throw an error if `redirectUri` is missing', function() { - var authorizationCode = { authorizationCode: 12345, client: {}, expiresAt: new Date(new Date() / 2), redirectUri: 'http://foo.bar', user: {} }; - var model = { + const authorizationCode = { authorizationCode: 12345, client: {}, expiresAt: new Date(new Date() / 2), redirectUri: 'http://foo.bar', user: {} }; + const model = { getAuthorizationCode: function() {}, revokeAuthorizationCode: function() { return authorizationCode; }, saveToken: function() {} }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); try { grantType.validateRedirectUri(request, authorizationCode); @@ -444,14 +444,14 @@ describe('AuthorizationCodeGrantType integration', function() { }); it('should throw an error if `redirectUri` is invalid', function() { - var authorizationCode = { authorizationCode: 12345, client: {}, expiresAt: new Date(new Date() / 2), redirectUri: 'http://foo.bar', user: {} }; - var model = { + const authorizationCode = { authorizationCode: 12345, client: {}, expiresAt: new Date(new Date() / 2), redirectUri: 'http://foo.bar', user: {} }; + const model = { getAuthorizationCode: function() {}, revokeAuthorizationCode: function() { return true; }, saveToken: function() {} }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { code: 12345, redirect_uri: 'http://bar.foo' }, headers: {}, method: {}, query: {} }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { code: 12345, redirect_uri: 'http://bar.foo' }, headers: {}, method: {}, query: {} }); try { grantType.validateRedirectUri(request, authorizationCode); @@ -466,13 +466,13 @@ describe('AuthorizationCodeGrantType integration', function() { describe('revokeAuthorizationCode()', function() { it('should revoke the auth code', function() { - var authorizationCode = { authorizationCode: 12345, client: {}, expiresAt: new Date(new Date() / 2), user: {} }; - var model = { + const authorizationCode = { authorizationCode: 12345, client: {}, expiresAt: new Date(new Date() / 2), user: {} }; + const model = { getAuthorizationCode: function() {}, revokeAuthorizationCode: function() { return true; }, saveToken: function() {} }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); return grantType.revokeAuthorizationCode(authorizationCode) .then(function(data) { @@ -482,13 +482,13 @@ describe('AuthorizationCodeGrantType integration', function() { }); it('should throw an error when the auth code is invalid', function() { - var authorizationCode = { authorizationCode: 12345, client: {}, expiresAt: new Date(new Date() / 2), user: {} }; - var model = { + const authorizationCode = { authorizationCode: 12345, client: {}, expiresAt: new Date(new Date() / 2), user: {} }; + const model = { getAuthorizationCode: function() {}, revokeAuthorizationCode: function() { return false; }, saveToken: function() {} }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); return grantType.revokeAuthorizationCode(authorizationCode) .then(function(data) { @@ -501,37 +501,37 @@ describe('AuthorizationCodeGrantType integration', function() { }); it('should support promises', function() { - var authorizationCode = { authorizationCode: 12345, client: {}, expiresAt: new Date(new Date() / 2), user: {} }; - var model = { + const authorizationCode = { authorizationCode: 12345, client: {}, expiresAt: new Date(new Date() / 2), user: {} }; + const model = { getAuthorizationCode: function() {}, revokeAuthorizationCode: function() { return Promise.resolve(true); }, saveToken: function() {} }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); grantType.revokeAuthorizationCode(authorizationCode).should.be.an.instanceOf(Promise); }); it('should support non-promises', function() { - var authorizationCode = { authorizationCode: 12345, client: {}, expiresAt: new Date(new Date() / 2), user: {} }; - var model = { + const authorizationCode = { authorizationCode: 12345, client: {}, expiresAt: new Date(new Date() / 2), user: {} }; + const model = { getAuthorizationCode: function() {}, revokeAuthorizationCode: function() { return authorizationCode; }, saveToken: function() {} }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); grantType.revokeAuthorizationCode(authorizationCode).should.be.an.instanceOf(Promise); }); it('should support callbacks', function() { - var authorizationCode = { authorizationCode: 12345, client: {}, expiresAt: new Date(new Date() / 2), user: {} }; - var model = { + const authorizationCode = { authorizationCode: 12345, client: {}, expiresAt: new Date(new Date() / 2), user: {} }; + const model = { getAuthorizationCode: function() {}, revokeAuthorizationCode: function(code, callback) { callback(null, authorizationCode); }, saveToken: function() {} }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); grantType.revokeAuthorizationCode(authorizationCode).should.be.an.instanceOf(Promise); }); @@ -539,14 +539,14 @@ describe('AuthorizationCodeGrantType integration', function() { describe('saveToken()', function() { it('should save the token', function() { - var token = {}; - var model = { + const token = {}; + const model = { getAuthorizationCode: function() {}, revokeAuthorizationCode: function() {}, saveToken: function() { return token; }, validateScope: function() { return 'foo'; } }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); return grantType.saveToken(token) .then(function(data) { @@ -556,37 +556,37 @@ describe('AuthorizationCodeGrantType integration', function() { }); it('should support promises', function() { - var token = {}; - var model = { + const token = {}; + const model = { getAuthorizationCode: function() {}, revokeAuthorizationCode: function() {}, saveToken: function() { return Promise.resolve(token); } }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); grantType.saveToken(token).should.be.an.instanceOf(Promise); }); it('should support non-promises', function() { - var token = {}; - var model = { + const token = {}; + const model = { getAuthorizationCode: function() {}, revokeAuthorizationCode: function() {}, saveToken: function() { return token; } }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); grantType.saveToken(token).should.be.an.instanceOf(Promise); }); it('should support callbacks', function() { - var token = {}; - var model = { + const token = {}; + const model = { getAuthorizationCode: function() {}, revokeAuthorizationCode: function() {}, saveToken: function(tokenToSave, client, user, callback) { callback(null, token); } }; - var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); + const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model }); grantType.saveToken(token).should.be.an.instanceOf(Promise); }); diff --git a/test/integration/grant-types/client-credentials-grant-type_test.js b/test/integration/grant-types/client-credentials-grant-type_test.js index 3bddec8eb..b13df0862 100644 --- a/test/integration/grant-types/client-credentials-grant-type_test.js +++ b/test/integration/grant-types/client-credentials-grant-type_test.js @@ -4,12 +4,12 @@ * Module dependencies. */ -var ClientCredentialsGrantType = require('../../../lib/grant-types/client-credentials-grant-type'); -var InvalidArgumentError = require('../../../lib/errors/invalid-argument-error'); -var InvalidGrantError = require('../../../lib/errors/invalid-grant-error'); -var Promise = require('bluebird'); -var Request = require('../../../lib/request'); -var should = require('chai').should(); +const ClientCredentialsGrantType = require('../../../lib/grant-types/client-credentials-grant-type'); +const InvalidArgumentError = require('../../../lib/errors/invalid-argument-error'); +const InvalidGrantError = require('../../../lib/errors/invalid-grant-error'); +const Promise = require('bluebird'); +const Request = require('../../../lib/request'); +const should = require('chai').should(); /** * Test `ClientCredentialsGrantType` integration. @@ -41,7 +41,7 @@ describe('ClientCredentialsGrantType integration', function() { it('should throw an error if the model does not implement `saveToken()`', function() { try { - var model = { + const model = { getUserFromClient: function() {} }; @@ -57,11 +57,11 @@ describe('ClientCredentialsGrantType integration', function() { describe('handle()', function() { it('should throw an error if `request` is missing', function() { - var model = { + const model = { getUserFromClient: function() {}, saveToken: function() {} }; - var grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 120, model: model }); + const grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 120, model: model }); try { grantType.handle(); @@ -74,12 +74,12 @@ describe('ClientCredentialsGrantType integration', function() { }); it('should throw an error if `client` is missing', function() { - var model = { + const model = { getUserFromClient: function() {}, saveToken: function() {} }; - var grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 120, model: model }); - var request = new Request({ body: {}, headers: {}, method: {}, query: {} }); + const grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 120, model: model }); + const request = new Request({ body: {}, headers: {}, method: {}, query: {} }); try { grantType.handle(request); @@ -92,14 +92,14 @@ describe('ClientCredentialsGrantType integration', function() { }); it('should return a token', function() { - var token = {}; - var model = { + const token = {}; + const model = { getUserFromClient: function() { return {}; }, saveToken: function() { return token; }, validateScope: function() { return 'foo'; } }; - var grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 120, model: model }); - var request = new Request({ body: {}, headers: {}, method: {}, query: {} }); + const grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 120, model: model }); + const request = new Request({ body: {}, headers: {}, method: {}, query: {} }); return grantType.handle(request, {}) .then(function(data) { @@ -109,25 +109,25 @@ describe('ClientCredentialsGrantType integration', function() { }); it('should support promises', function() { - var token = {}; - var model = { + const token = {}; + const model = { getUserFromClient: function() { return {}; }, saveToken: function() { return token; } }; - var grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 120, model: model }); - var request = new Request({ body: {}, headers: {}, method: {}, query: {} }); + const grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 120, model: model }); + const request = new Request({ body: {}, headers: {}, method: {}, query: {} }); grantType.handle(request, {}).should.be.an.instanceOf(Promise); }); it('should support non-promises', function() { - var token = {}; - var model = { + const token = {}; + const model = { getUserFromClient: function() { return {}; }, saveToken: function() { return token; } }; - var grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 120, model: model }); - var request = new Request({ body: {}, headers: {}, method: {}, query: {} }); + const grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 120, model: model }); + const request = new Request({ body: {}, headers: {}, method: {}, query: {} }); grantType.handle(request, {}).should.be.an.instanceOf(Promise); }); @@ -135,12 +135,12 @@ describe('ClientCredentialsGrantType integration', function() { describe('getUserFromClient()', function() { it('should throw an error if `user` is missing', function() { - var model = { + const model = { getUserFromClient: function() {}, saveToken: function() {} }; - var grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 120, model: model }); - var request = new Request({ body: {}, headers: {}, method: {}, query: {} }); + const grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 120, model: model }); + const request = new Request({ body: {}, headers: {}, method: {}, query: {} }); return grantType.getUserFromClient(request, {}) .then(should.fail) @@ -151,13 +151,13 @@ describe('ClientCredentialsGrantType integration', function() { }); it('should return a user', function() { - var user = { email: 'foo@bar.com' }; - var model = { + const user = { email: 'foo@bar.com' }; + const model = { getUserFromClient: function() { return user; }, saveToken: function() {} }; - var grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 120, model: model }); - var request = new Request({ body: {}, headers: {}, method: {}, query: {} }); + const grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 120, model: model }); + const request = new Request({ body: {}, headers: {}, method: {}, query: {} }); return grantType.getUserFromClient(request, {}) .then(function(data) { @@ -167,37 +167,37 @@ describe('ClientCredentialsGrantType integration', function() { }); it('should support promises', function() { - var user = { email: 'foo@bar.com' }; - var model = { + const user = { email: 'foo@bar.com' }; + const model = { getUserFromClient: function() { return Promise.resolve(user); }, saveToken: function() {} }; - var grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 120, model: model }); - var request = new Request({ body: {}, headers: {}, method: {}, query: {} }); + const grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 120, model: model }); + const request = new Request({ body: {}, headers: {}, method: {}, query: {} }); grantType.getUserFromClient(request, {}).should.be.an.instanceOf(Promise); }); it('should support non-promises', function() { - var user = { email: 'foo@bar.com' }; - var model = { + const user = { email: 'foo@bar.com' }; + const model = { getUserFromClient: function() {return user; }, saveToken: function() {} }; - var grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 120, model: model }); - var request = new Request({ body: {}, headers: {}, method: {}, query: {} }); + const grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 120, model: model }); + const request = new Request({ body: {}, headers: {}, method: {}, query: {} }); grantType.getUserFromClient(request, {}).should.be.an.instanceOf(Promise); }); it('should support callbacks', function() { - var user = { email: 'foo@bar.com' }; - var model = { + const user = { email: 'foo@bar.com' }; + const model = { getUserFromClient: function(userId, callback) { callback(null, user); }, saveToken: function() {} }; - var grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 120, model: model }); - var request = new Request({ body: {}, headers: {}, method: {}, query: {} }); + const grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 120, model: model }); + const request = new Request({ body: {}, headers: {}, method: {}, query: {} }); grantType.getUserFromClient(request, {}).should.be.an.instanceOf(Promise); }); @@ -205,13 +205,13 @@ describe('ClientCredentialsGrantType integration', function() { describe('saveToken()', function() { it('should save the token', function() { - var token = {}; - var model = { + const token = {}; + const model = { getUserFromClient: function() {}, saveToken: function() { return token; }, validateScope: function() { return 'foo'; } }; - var grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 123, model: model }); + const grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 123, model: model }); return grantType.saveToken(token) .then(function(data) { @@ -221,34 +221,34 @@ describe('ClientCredentialsGrantType integration', function() { }); it('should support promises', function() { - var token = {}; - var model = { + const token = {}; + const model = { getUserFromClient: function() {}, saveToken: function() { return Promise.resolve(token); } }; - var grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 123, model: model }); + const grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 123, model: model }); grantType.saveToken(token).should.be.an.instanceOf(Promise); }); it('should support non-promises', function() { - var token = {}; - var model = { + const token = {}; + const model = { getUserFromClient: function() {}, saveToken: function() { return token; } }; - var grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 123, model: model }); + const grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 123, model: model }); grantType.saveToken(token).should.be.an.instanceOf(Promise); }); it('should support callbacks', function() { - var token = {}; - var model = { + const token = {}; + const model = { getUserFromClient: function() {}, saveToken: function(tokenToSave, client, user, callback) { callback(null, token); } }; - var grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 123, model: model }); + const grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 123, model: model }); grantType.saveToken(token).should.be.an.instanceOf(Promise); }); diff --git a/test/integration/grant-types/password-grant-type_test.js b/test/integration/grant-types/password-grant-type_test.js index 916355dd4..a8c4cdaa4 100644 --- a/test/integration/grant-types/password-grant-type_test.js +++ b/test/integration/grant-types/password-grant-type_test.js @@ -4,13 +4,13 @@ * Module dependencies. */ -var InvalidArgumentError = require('../../../lib/errors/invalid-argument-error'); -var InvalidGrantError = require('../../../lib/errors/invalid-grant-error'); -var InvalidRequestError = require('../../../lib/errors/invalid-request-error'); -var PasswordGrantType = require('../../../lib/grant-types/password-grant-type'); -var Promise = require('bluebird'); -var Request = require('../../../lib/request'); -var should = require('chai').should(); +const InvalidArgumentError = require('../../../lib/errors/invalid-argument-error'); +const InvalidGrantError = require('../../../lib/errors/invalid-grant-error'); +const InvalidRequestError = require('../../../lib/errors/invalid-request-error'); +const PasswordGrantType = require('../../../lib/grant-types/password-grant-type'); +const Promise = require('bluebird'); +const Request = require('../../../lib/request'); +const should = require('chai').should(); /** * Test `PasswordGrantType` integration. @@ -42,7 +42,7 @@ describe('PasswordGrantType integration', function() { it('should throw an error if the model does not implement `saveToken()`', function() { try { - var model = { + const model = { getUser: function() {} }; @@ -58,11 +58,11 @@ describe('PasswordGrantType integration', function() { describe('handle()', function() { it('should throw an error if `request` is missing', function() { - var model = { + const model = { getUser: function() {}, saveToken: function() {} }; - var grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); + const grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); try { grantType.handle(); @@ -75,11 +75,11 @@ describe('PasswordGrantType integration', function() { }); it('should throw an error if `client` is missing', function() { - var model = { + const model = { getUser: function() {}, saveToken: function() {} }; - var grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); + const grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); try { grantType.handle({}); @@ -92,15 +92,15 @@ describe('PasswordGrantType integration', function() { }); it('should return a token', function() { - var client = { id: 'foobar' }; - var token = {}; - var model = { + const client = { id: 'foobar' }; + const token = {}; + const model = { getUser: function() { return {}; }, saveToken: function() { return token; }, validateScope: function() { return 'baz'; } }; - var grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { username: 'foo', password: 'bar', scope: 'baz' }, headers: {}, method: {}, query: {} }); + const grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { username: 'foo', password: 'bar', scope: 'baz' }, headers: {}, method: {}, query: {} }); return grantType.handle(request, client) .then(function(data) { @@ -110,40 +110,40 @@ describe('PasswordGrantType integration', function() { }); it('should support promises', function() { - var client = { id: 'foobar' }; - var token = {}; - var model = { + const client = { id: 'foobar' }; + const token = {}; + const model = { getUser: function() { return {}; }, saveToken: function() { return Promise.resolve(token); } }; - var grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { username: 'foo', password: 'bar' }, headers: {}, method: {}, query: {} }); + const grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { username: 'foo', password: 'bar' }, headers: {}, method: {}, query: {} }); grantType.handle(request, client).should.be.an.instanceOf(Promise); }); it('should support non-promises', function() { - var client = { id: 'foobar' }; - var token = {}; - var model = { + const client = { id: 'foobar' }; + const token = {}; + const model = { getUser: function() { return {}; }, saveToken: function() { return token; } }; - var grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { username: 'foo', password: 'bar' }, headers: {}, method: {}, query: {} }); + const grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { username: 'foo', password: 'bar' }, headers: {}, method: {}, query: {} }); grantType.handle(request, client).should.be.an.instanceOf(Promise); }); it('should support callbacks', function() { - var client = { id: 'foobar' }; - var token = {}; - var model = { + const client = { id: 'foobar' }; + const token = {}; + const model = { getUser: function(username, password, callback) { callback(null, {}); }, saveToken: function(tokenToSave, client, user, callback) { callback(null, token); } }; - var grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { username: 'foo', password: 'bar' }, headers: {}, method: {}, query: {} }); + const grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { username: 'foo', password: 'bar' }, headers: {}, method: {}, query: {} }); grantType.handle(request, client).should.be.an.instanceOf(Promise); }); @@ -151,12 +151,12 @@ describe('PasswordGrantType integration', function() { describe('getUser()', function() { it('should throw an error if the request body does not contain `username`', function() { - var model = { + const model = { getUser: function() {}, saveToken: function() {} }; - var grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: {}, headers: {}, method: {}, query: {} }); + const grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: {}, headers: {}, method: {}, query: {} }); try { grantType.getUser(request); @@ -169,12 +169,12 @@ describe('PasswordGrantType integration', function() { }); it('should throw an error if the request body does not contain `password`', function() { - var model = { + const model = { getUser: function() {}, saveToken: function() {} }; - var grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { username: 'foo' }, headers: {}, method: {}, query: {} }); + const grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { username: 'foo' }, headers: {}, method: {}, query: {} }); try { grantType.getUser(request); @@ -187,12 +187,12 @@ describe('PasswordGrantType integration', function() { }); it('should throw an error if `username` is invalid', function() { - var model = { + const model = { getUser: function() {}, saveToken: function() {} }; - var grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { username: '\r\n', password: 'foobar' }, headers: {}, method: {}, query: {} }); + const grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { username: '\r\n', password: 'foobar' }, headers: {}, method: {}, query: {} }); try { grantType.getUser(request); @@ -205,12 +205,12 @@ describe('PasswordGrantType integration', function() { }); it('should throw an error if `password` is invalid', function() { - var model = { + const model = { getUser: function() {}, saveToken: function() {} }; - var grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { username: 'foobar', password: '\r\n' }, headers: {}, method: {}, query: {} }); + const grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { username: 'foobar', password: '\r\n' }, headers: {}, method: {}, query: {} }); try { grantType.getUser(request); @@ -223,12 +223,12 @@ describe('PasswordGrantType integration', function() { }); it('should throw an error if `user` is missing', function() { - var model = { + const model = { getUser: function() {}, saveToken: function() {} }; - var grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { username: 'foo', password: 'bar' }, headers: {}, method: {}, query: {} }); + const grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { username: 'foo', password: 'bar' }, headers: {}, method: {}, query: {} }); return grantType.getUser(request) .then(should.fail) @@ -239,13 +239,13 @@ describe('PasswordGrantType integration', function() { }); it('should return a user', function() { - var user = { email: 'foo@bar.com' }; - var model = { + const user = { email: 'foo@bar.com' }; + const model = { getUser: function() { return user; }, saveToken: function() {} }; - var grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { username: 'foo', password: 'bar' }, headers: {}, method: {}, query: {} }); + const grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { username: 'foo', password: 'bar' }, headers: {}, method: {}, query: {} }); return grantType.getUser(request) .then(function(data) { @@ -255,37 +255,37 @@ describe('PasswordGrantType integration', function() { }); it('should support promises', function() { - var user = { email: 'foo@bar.com' }; - var model = { + const user = { email: 'foo@bar.com' }; + const model = { getUser: function() { return Promise.resolve(user); }, saveToken: function() {} }; - var grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { username: 'foo', password: 'bar' }, headers: {}, method: {}, query: {} }); + const grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { username: 'foo', password: 'bar' }, headers: {}, method: {}, query: {} }); grantType.getUser(request).should.be.an.instanceOf(Promise); }); it('should support non-promises', function() { - var user = { email: 'foo@bar.com' }; - var model = { + const user = { email: 'foo@bar.com' }; + const model = { getUser: function() { return user; }, saveToken: function() {} }; - var grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { username: 'foo', password: 'bar' }, headers: {}, method: {}, query: {} }); + const grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { username: 'foo', password: 'bar' }, headers: {}, method: {}, query: {} }); grantType.getUser(request).should.be.an.instanceOf(Promise); }); it('should support callbacks', function() { - var user = { email: 'foo@bar.com' }; - var model = { + const user = { email: 'foo@bar.com' }; + const model = { getUser: function(username, password, callback) { callback(null, user); }, saveToken: function() {} }; - var grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { username: 'foo', password: 'bar' }, headers: {}, method: {}, query: {} }); + const grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { username: 'foo', password: 'bar' }, headers: {}, method: {}, query: {} }); grantType.getUser(request).should.be.an.instanceOf(Promise); }); @@ -293,13 +293,13 @@ describe('PasswordGrantType integration', function() { describe('saveToken()', function() { it('should save the token', function() { - var token = {}; - var model = { + const token = {}; + const model = { getUser: function() {}, saveToken: function() { return token; }, validateScope: function() { return 'foo'; } }; - var grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); + const grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); return grantType.saveToken(token) .then(function(data) { @@ -309,34 +309,34 @@ describe('PasswordGrantType integration', function() { }); it('should support promises', function() { - var token = {}; - var model = { + const token = {}; + const model = { getUser: function() {}, saveToken: function() { return Promise.resolve(token); } }; - var grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); + const grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); grantType.saveToken(token).should.be.an.instanceOf(Promise); }); it('should support non-promises', function() { - var token = {}; - var model = { + const token = {}; + const model = { getUser: function() {}, saveToken: function() { return token; } }; - var grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); + const grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); grantType.saveToken(token).should.be.an.instanceOf(Promise); }); it('should support callbacks', function() { - var token = {}; - var model = { + const token = {}; + const model = { getUser: function() {}, saveToken: function(tokenToSave, client, user, callback) { callback(null, token); } }; - var grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); + const grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model }); grantType.saveToken(token).should.be.an.instanceOf(Promise); }); diff --git a/test/integration/grant-types/refresh-token-grant-type_test.js b/test/integration/grant-types/refresh-token-grant-type_test.js index cbc294706..945d51c4f 100644 --- a/test/integration/grant-types/refresh-token-grant-type_test.js +++ b/test/integration/grant-types/refresh-token-grant-type_test.js @@ -4,14 +4,14 @@ * Module dependencies. */ -var InvalidArgumentError = require('../../../lib/errors/invalid-argument-error'); -var InvalidGrantError = require('../../../lib/errors/invalid-grant-error'); -var InvalidRequestError = require('../../../lib/errors/invalid-request-error'); -var Promise = require('bluebird'); -var RefreshTokenGrantType = require('../../../lib/grant-types/refresh-token-grant-type'); -var Request = require('../../../lib/request'); -var ServerError = require('../../../lib/errors/server-error'); -var should = require('chai').should(); +const InvalidArgumentError = require('../../../lib/errors/invalid-argument-error'); +const InvalidGrantError = require('../../../lib/errors/invalid-grant-error'); +const InvalidRequestError = require('../../../lib/errors/invalid-request-error'); +const Promise = require('bluebird'); +const RefreshTokenGrantType = require('../../../lib/grant-types/refresh-token-grant-type'); +const Request = require('../../../lib/request'); +const ServerError = require('../../../lib/errors/server-error'); +const should = require('chai').should(); /** * Test `RefreshTokenGrantType` integration. @@ -43,7 +43,7 @@ describe('RefreshTokenGrantType integration', function() { it('should throw an error if the model does not implement `revokeToken()`', function() { try { - var model = { + const model = { getRefreshToken: function() {} }; @@ -58,7 +58,7 @@ describe('RefreshTokenGrantType integration', function() { it('should throw an error if the model does not implement `saveToken()`', function() { try { - var model = { + const model = { getRefreshToken: function() {}, revokeToken: function() {} }; @@ -75,12 +75,12 @@ describe('RefreshTokenGrantType integration', function() { describe('handle()', function() { it('should throw an error if `request` is missing', function() { - var model = { + const model = { getRefreshToken: function() {}, revokeToken: function() {}, saveToken: function() {} }; - var grantType = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); + const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); try { grantType.handle(); @@ -93,13 +93,13 @@ describe('RefreshTokenGrantType integration', function() { }); it('should throw an error if `client` is missing', function() { - var model = { + const model = { getRefreshToken: function() {}, revokeToken: function() {}, saveToken: function() {} }; - var grantType = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); - var request = new Request({ body: {}, headers: {}, method: {}, query: {} }); + const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); + const request = new Request({ body: {}, headers: {}, method: {}, query: {} }); try { grantType.handle(request); @@ -112,15 +112,15 @@ describe('RefreshTokenGrantType integration', function() { }); it('should return a token', function() { - var client = { id: 123 }; - var token = { accessToken: 'foo', client: { id: 123 }, user: {} }; - var model = { + const client = { id: 123 }; + const token = { accessToken: 'foo', client: { id: 123 }, user: {} }; + const model = { getRefreshToken: function() { return token; }, revokeToken: function() { return { accessToken: 'foo', client: { id: 123 }, refreshTokenExpiresAt: new Date(new Date() / 2), user: {} }; }, saveToken: function() { return token; } }; - var grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { refresh_token: 'foobar' }, headers: {}, method: {}, query: {} }); + const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { refresh_token: 'foobar' }, headers: {}, method: {}, query: {} }); return grantType.handle(request, client) .then(function(data) { @@ -130,40 +130,40 @@ describe('RefreshTokenGrantType integration', function() { }); it('should support promises', function() { - var client = { id: 123 }; - var model = { + const client = { id: 123 }; + const model = { getRefreshToken: function() { return Promise.resolve({ accessToken: 'foo', client: { id: 123 }, user: {} }); }, revokeToken: function() { return Promise.resolve({ accessToken: 'foo', client: {}, refreshTokenExpiresAt: new Date(new Date() / 2), user: {} }); }, saveToken: function() { return Promise.resolve({ accessToken: 'foo', client: {}, user: {} }); } }; - var grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { refresh_token: 'foobar' }, headers: {}, method: {}, query: {} }); + const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { refresh_token: 'foobar' }, headers: {}, method: {}, query: {} }); grantType.handle(request, client).should.be.an.instanceOf(Promise); }); it('should support non-promises', function() { - var client = { id: 123 }; - var model = { + const client = { id: 123 }; + const model = { getRefreshToken: function() { return { accessToken: 'foo', client: { id: 123 }, user: {} }; }, revokeToken: function() { return { accessToken: 'foo', client: {}, refreshTokenExpiresAt: new Date(new Date() / 2), user: {} }; }, saveToken: function() { return { accessToken: 'foo', client: {}, user: {} }; } }; - var grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { refresh_token: 'foobar' }, headers: {}, method: {}, query: {} }); + const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { refresh_token: 'foobar' }, headers: {}, method: {}, query: {} }); grantType.handle(request, client).should.be.an.instanceOf(Promise); }); it('should support callbacks', function() { - var client = { id: 123 }; - var model = { + const client = { id: 123 }; + const model = { getRefreshToken: function(refreshToken, callback) { callback(null, { accessToken: 'foo', client: { id: 123 }, user: {} }); }, revokeToken: function(refreshToken, callback) { callback(null, { accessToken: 'foo', client: {}, refreshTokenExpiresAt: new Date(new Date() / 2), user: {} }); }, saveToken: function(tokenToSave, client, user, callback) { callback(null,{ accessToken: 'foo', client: {}, user: {} }); } }; - var grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { refresh_token: 'foobar' }, headers: {}, method: {}, query: {} }); + const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { refresh_token: 'foobar' }, headers: {}, method: {}, query: {} }); grantType.handle(request, client).should.be.an.instanceOf(Promise); }); @@ -171,14 +171,14 @@ describe('RefreshTokenGrantType integration', function() { describe('getRefreshToken()', function() { it('should throw an error if the `refreshToken` parameter is missing from the request body', function() { - var client = {}; - var model = { + const client = {}; + const model = { getRefreshToken: function() {}, revokeToken: function() {}, saveToken: function() {} }; - var grantType = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); - var request = new Request({ body: {}, headers: {}, method: {}, query: {} }); + const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); + const request = new Request({ body: {}, headers: {}, method: {}, query: {} }); try { grantType.getRefreshToken(request, client); @@ -191,14 +191,14 @@ describe('RefreshTokenGrantType integration', function() { }); it('should throw an error if `refreshToken` is not found', function() { - var client = { id: 123 }; - var model = { + const client = { id: 123 }; + const model = { getRefreshToken: function() { return; }, revokeToken: function() {}, saveToken: function() {} }; - var grantType = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); - var request = new Request({ body: { refresh_token: '12345' }, headers: {}, method: {}, query: {} }); + const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); + const request = new Request({ body: { refresh_token: '12345' }, headers: {}, method: {}, query: {} }); return grantType.getRefreshToken(request, client) .then(should.fail) @@ -209,14 +209,14 @@ describe('RefreshTokenGrantType integration', function() { }); it('should throw an error if `refreshToken.client` is missing', function() { - var client = {}; - var model = { + const client = {}; + const model = { getRefreshToken: function() { return {}; }, revokeToken: function() {}, saveToken: function() {} }; - var grantType = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); - var request = new Request({ body: { refresh_token: 12345 }, headers: {}, method: {}, query: {} }); + const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); + const request = new Request({ body: { refresh_token: 12345 }, headers: {}, method: {}, query: {} }); return grantType.getRefreshToken(request, client) .then(should.fail) @@ -227,16 +227,16 @@ describe('RefreshTokenGrantType integration', function() { }); it('should throw an error if `refreshToken.user` is missing', function() { - var client = {}; - var model = { + const client = {}; + const model = { getRefreshToken: function() { return { accessToken: 'foo', client: {} }; }, revokeToken: function() {}, saveToken: function() {} }; - var grantType = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); - var request = new Request({ body: { refresh_token: 12345 }, headers: {}, method: {}, query: {} }); + const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); + const request = new Request({ body: { refresh_token: 12345 }, headers: {}, method: {}, query: {} }); return grantType.getRefreshToken(request, client) .then(should.fail) @@ -247,16 +247,16 @@ describe('RefreshTokenGrantType integration', function() { }); it('should throw an error if the client id does not match', function() { - var client = { id: 123 }; - var model = { + const client = { id: 123 }; + const model = { getRefreshToken: function() { return { accessToken: 'foo', client: { id: 456 }, user: {} }; }, revokeToken: function() {}, saveToken: function() {} }; - var grantType = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); - var request = new Request({ body: { refresh_token: 12345 }, headers: {}, method: {}, query: {} }); + const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); + const request = new Request({ body: { refresh_token: 12345 }, headers: {}, method: {}, query: {} }); return grantType.getRefreshToken(request, client) .then(should.fail) @@ -267,16 +267,16 @@ describe('RefreshTokenGrantType integration', function() { }); it('should throw an error if `refresh_token` contains invalid characters', function() { - var client = {}; - var model = { + const client = {}; + const model = { getRefreshToken: function() { return { client: { id: 456 }, user: {} }; }, revokeToken: function() {}, saveToken: function() {} }; - var grantType = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); - var request = new Request({ body: { refresh_token: 'ø倣‰' }, headers: {}, method: {}, query: {} }); + const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); + const request = new Request({ body: { refresh_token: 'ø倣‰' }, headers: {}, method: {}, query: {} }); try { grantType.getRefreshToken(request, client); @@ -289,16 +289,16 @@ describe('RefreshTokenGrantType integration', function() { }); it('should throw an error if `refresh_token` is missing', function() { - var client = {}; - var model = { + const client = {}; + const model = { getRefreshToken: function() { return { accessToken: 'foo', client: { id: 456 }, user: {} }; }, revokeToken: function() {}, saveToken: function() {} }; - var grantType = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); - var request = new Request({ body: { refresh_token: 12345 }, headers: {}, method: {}, query: {} }); + const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); + const request = new Request({ body: { refresh_token: 12345 }, headers: {}, method: {}, query: {} }); return grantType.getRefreshToken(request, client) .then(should.fail) @@ -309,17 +309,17 @@ describe('RefreshTokenGrantType integration', function() { }); it('should throw an error if `refresh_token` is expired', function() { - var client = { id: 123 }; - var date = new Date(new Date() / 2); - var model = { + const client = { id: 123 }; + const date = new Date(new Date() / 2); + const model = { getRefreshToken: function() { return { accessToken: 'foo', client: { id: 123 }, refreshTokenExpiresAt: date, user: {} }; }, revokeToken: function() {}, saveToken: function() {} }; - var grantType = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); - var request = new Request({ body: { refresh_token: 12345 }, headers: {}, method: {}, query: {} }); + const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); + const request = new Request({ body: { refresh_token: 12345 }, headers: {}, method: {}, query: {} }); return grantType.getRefreshToken(request, client) .then(should.fail) @@ -330,16 +330,16 @@ describe('RefreshTokenGrantType integration', function() { }); it('should throw an error if `refreshTokenExpiresAt` is not a date value', function() { - var client = { id: 123 }; - var model = { + const client = { id: 123 }; + const model = { getRefreshToken: function() { return { accessToken: 'foo', client: { id: 123 }, refreshTokenExpiresAt: 'stringvalue', user: {} }; }, revokeToken: function() {}, saveToken: function() {} }; - var grantType = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); - var request = new Request({ body: { refresh_token: 12345 }, headers: {}, method: {}, query: {} }); + const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); + const request = new Request({ body: { refresh_token: 12345 }, headers: {}, method: {}, query: {} }); return grantType.getRefreshToken(request, client) .then(should.fail) @@ -350,15 +350,15 @@ describe('RefreshTokenGrantType integration', function() { }); it('should return a token', function() { - var client = { id: 123 }; - var token = { accessToken: 'foo', client: { id: 123 }, user: {} }; - var model = { + const client = { id: 123 }; + const token = { accessToken: 'foo', client: { id: 123 }, user: {} }; + const model = { getRefreshToken: function() { return token; }, revokeToken: function() {}, saveToken: function() {} }; - var grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { refresh_token: 'foobar' }, headers: {}, method: {}, query: {} }); + const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { refresh_token: 'foobar' }, headers: {}, method: {}, query: {} }); return grantType.getRefreshToken(request, client) .then(function(data) { @@ -368,43 +368,43 @@ describe('RefreshTokenGrantType integration', function() { }); it('should support promises', function() { - var client = { id: 123 }; - var token = { accessToken: 'foo', client: { id: 123 }, user: {} }; - var model = { + const client = { id: 123 }; + const token = { accessToken: 'foo', client: { id: 123 }, user: {} }; + const model = { getRefreshToken: function() { return Promise.resolve(token); }, revokeToken: function() {}, saveToken: function() {} }; - var grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { refresh_token: 'foobar' }, headers: {}, method: {}, query: {} }); + const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { refresh_token: 'foobar' }, headers: {}, method: {}, query: {} }); grantType.getRefreshToken(request, client).should.be.an.instanceOf(Promise); }); it('should support non-promises', function() { - var client = { id: 123 }; - var token = { accessToken: 'foo', client: { id: 123 }, user: {} }; - var model = { + const client = { id: 123 }; + const token = { accessToken: 'foo', client: { id: 123 }, user: {} }; + const model = { getRefreshToken: function() { return token; }, revokeToken: function() {}, saveToken: function() {} }; - var grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { refresh_token: 'foobar' }, headers: {}, method: {}, query: {} }); + const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { refresh_token: 'foobar' }, headers: {}, method: {}, query: {} }); grantType.getRefreshToken(request, client).should.be.an.instanceOf(Promise); }); it('should support callbacks', function() { - var client = { id: 123 }; - var token = { accessToken: 'foo', client: { id: 123 }, user: {} }; - var model = { + const client = { id: 123 }; + const token = { accessToken: 'foo', client: { id: 123 }, user: {} }; + const model = { getRefreshToken: function(refreshToken, callback) { callback(null, token); }, revokeToken: function() {}, saveToken: function() {} }; - var grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); - var request = new Request({ body: { refresh_token: 'foobar' }, headers: {}, method: {}, query: {} }); + const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); + const request = new Request({ body: { refresh_token: 'foobar' }, headers: {}, method: {}, query: {} }); grantType.getRefreshToken(request, client).should.be.an.instanceOf(Promise); }); @@ -412,12 +412,12 @@ describe('RefreshTokenGrantType integration', function() { describe('revokeToken()', function() { it('should throw an error if the `token` is invalid', function() { - var model = { + const model = { getRefreshToken: function() {}, revokeToken: function() {}, saveToken: function() {} }; - var grantType = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); + const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); grantType.revokeToken({}) .then(should.fail) @@ -428,13 +428,13 @@ describe('RefreshTokenGrantType integration', function() { }); it('should revoke the token', function() { - var token = { accessToken: 'foo', client: {}, refreshTokenExpiresAt: new Date(new Date() / 2), user: {} }; - var model = { + const token = { accessToken: 'foo', client: {}, refreshTokenExpiresAt: new Date(new Date() / 2), user: {} }; + const model = { getRefreshToken: function() {}, revokeToken: function() { return token; }, saveToken: function() {} }; - var grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); + const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); return grantType.revokeToken(token) .then(function(data) { @@ -444,37 +444,37 @@ describe('RefreshTokenGrantType integration', function() { }); it('should support promises', function() { - var token = { accessToken: 'foo', client: {}, refreshTokenExpiresAt: new Date(new Date() / 2), user: {} }; - var model = { + const token = { accessToken: 'foo', client: {}, refreshTokenExpiresAt: new Date(new Date() / 2), user: {} }; + const model = { getRefreshToken: function() {}, revokeToken: function() { return Promise.resolve(token); }, saveToken: function() {} }; - var grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); + const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); grantType.revokeToken(token).should.be.an.instanceOf(Promise); }); it('should support non-promises', function() { - var token = { accessToken: 'foo', client: {}, refreshTokenExpiresAt: new Date(new Date() / 2), user: {} }; - var model = { + const token = { accessToken: 'foo', client: {}, refreshTokenExpiresAt: new Date(new Date() / 2), user: {} }; + const model = { getRefreshToken: function() {}, revokeToken: function() { return token; }, saveToken: function() {} }; - var grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); + const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); grantType.revokeToken(token).should.be.an.instanceOf(Promise); }); it('should support callbacks', function() { - var token = { accessToken: 'foo', client: {}, refreshTokenExpiresAt: new Date(new Date() / 2), user: {} }; - var model = { + const token = { accessToken: 'foo', client: {}, refreshTokenExpiresAt: new Date(new Date() / 2), user: {} }; + const model = { getRefreshToken: function() {}, revokeToken: function(refreshToken, callback) { callback(null, token); }, saveToken: function() {} }; - var grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); + const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); grantType.revokeToken(token).should.be.an.instanceOf(Promise); }); @@ -482,13 +482,13 @@ describe('RefreshTokenGrantType integration', function() { describe('saveToken()', function() { it('should save the token', function() { - var token = {}; - var model = { + const token = {}; + const model = { getRefreshToken: function() {}, revokeToken: function() {}, saveToken: function() { return token; } }; - var grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); + const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); return grantType.saveToken(token) .then(function(data) { @@ -498,37 +498,37 @@ describe('RefreshTokenGrantType integration', function() { }); it('should support promises', function() { - var token = {}; - var model = { + const token = {}; + const model = { getRefreshToken: function() {}, revokeToken: function() {}, saveToken: function() { return Promise.resolve(token); } }; - var grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); + const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); grantType.saveToken(token).should.be.an.instanceOf(Promise); }); it('should support non-promises', function() { - var token = {}; - var model = { + const token = {}; + const model = { getRefreshToken: function() {}, revokeToken: function() {}, saveToken: function() { return token; } }; - var grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); + const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); grantType.saveToken(token).should.be.an.instanceOf(Promise); }); it('should support callbacks', function() { - var token = {}; - var model = { + const token = {}; + const model = { getRefreshToken: function() {}, revokeToken: function() {}, saveToken: function(tokenToSave, client, user, callback) { callback(null, token); } }; - var grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); + const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model }); grantType.saveToken(token).should.be.an.instanceOf(Promise); }); diff --git a/test/integration/handlers/authenticate-handler_test.js b/test/integration/handlers/authenticate-handler_test.js index 1e98a62a4..3e0eefd5f 100644 --- a/test/integration/handlers/authenticate-handler_test.js +++ b/test/integration/handlers/authenticate-handler_test.js @@ -4,18 +4,18 @@ * Module dependencies. */ -var AccessDeniedError = require('../../../lib/errors/access-denied-error'); -var AuthenticateHandler = require('../../../lib/handlers/authenticate-handler'); -var InvalidArgumentError = require('../../../lib/errors/invalid-argument-error'); -var InvalidRequestError = require('../../../lib/errors/invalid-request-error'); -var InsufficientScopeError = require('../../../lib/errors/insufficient-scope-error'); -var InvalidTokenError = require('../../../lib/errors/invalid-token-error'); -var Promise = require('bluebird'); -var Request = require('../../../lib/request'); -var Response = require('../../../lib/response'); -var ServerError = require('../../../lib/errors/server-error'); -var UnauthorizedRequestError = require('../../../lib/errors/unauthorized-request-error'); -var should = require('chai').should(); +const AccessDeniedError = require('../../../lib/errors/access-denied-error'); +const AuthenticateHandler = require('../../../lib/handlers/authenticate-handler'); +const InvalidArgumentError = require('../../../lib/errors/invalid-argument-error'); +const InvalidRequestError = require('../../../lib/errors/invalid-request-error'); +const InsufficientScopeError = require('../../../lib/errors/insufficient-scope-error'); +const InvalidTokenError = require('../../../lib/errors/invalid-token-error'); +const Promise = require('bluebird'); +const Request = require('../../../lib/request'); +const Response = require('../../../lib/response'); +const ServerError = require('../../../lib/errors/server-error'); +const UnauthorizedRequestError = require('../../../lib/errors/unauthorized-request-error'); +const should = require('chai').should(); /** * Test `AuthenticateHandler` integration. @@ -79,18 +79,18 @@ describe('AuthenticateHandler integration', function() { }); it('should set the `model`', function() { - var model = { getAccessToken: function() {} }; - var grantType = new AuthenticateHandler({ model: model }); + const model = { getAccessToken: function() {} }; + const grantType = new AuthenticateHandler({ model: model }); grantType.model.should.equal(model); }); it('should set the `scope`', function() { - var model = { + const model = { getAccessToken: function() {}, verifyScope: function() {} }; - var grantType = new AuthenticateHandler({ + const grantType = new AuthenticateHandler({ addAcceptedScopesHeader: true, addAuthorizedScopesHeader: true, model: model, @@ -103,7 +103,7 @@ describe('AuthenticateHandler integration', function() { describe('handle()', function() { it('should throw an error if `request` is missing', function() { - var handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); + const handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); try { handler.handle(); @@ -116,14 +116,14 @@ describe('AuthenticateHandler integration', function() { }); it('should set the `WWW-Authenticate` header if an unauthorized request error is thrown', function() { - var model = { + const model = { getAccessToken: function() { throw new UnauthorizedRequestError(); } }; - var handler = new AuthenticateHandler({ model: model }); - var request = new Request({ body: {}, headers: { 'Authorization': 'Bearer foo' }, method: {}, query: {} }); - var response = new Response({ body: {}, headers: {} }); + const handler = new AuthenticateHandler({ model: model }); + const request = new Request({ body: {}, headers: { 'Authorization': 'Bearer foo' }, method: {}, query: {} }); + const response = new Response({ body: {}, headers: {} }); return handler.handle(request, response) .then(should.fail) @@ -133,14 +133,14 @@ describe('AuthenticateHandler integration', function() { }); it('should throw the error if an oauth error is thrown', function() { - var model = { + const model = { getAccessToken: function() { throw new AccessDeniedError('Cannot request this access token'); } }; - var handler = new AuthenticateHandler({ model: model }); - var request = new Request({ body: {}, headers: { 'Authorization': 'Bearer foo' }, method: {}, query: {} }); - var response = new Response({ body: {}, headers: {} }); + const handler = new AuthenticateHandler({ model: model }); + const request = new Request({ body: {}, headers: { 'Authorization': 'Bearer foo' }, method: {}, query: {} }); + const response = new Response({ body: {}, headers: {} }); return handler.handle(request, response) .then(should.fail) @@ -151,14 +151,14 @@ describe('AuthenticateHandler integration', function() { }); it('should throw a server error if a non-oauth error is thrown', function() { - var model = { + const model = { getAccessToken: function() { throw new Error('Unhandled exception'); } }; - var handler = new AuthenticateHandler({ model: model }); - var request = new Request({ body: {}, headers: { 'Authorization': 'Bearer foo' }, method: {}, query: {} }); - var response = new Response({ body: {}, headers: {} }); + const handler = new AuthenticateHandler({ model: model }); + const request = new Request({ body: {}, headers: { 'Authorization': 'Bearer foo' }, method: {}, query: {} }); + const response = new Response({ body: {}, headers: {} }); return handler.handle(request, response) .then(should.fail) @@ -169,11 +169,11 @@ describe('AuthenticateHandler integration', function() { }); it('should return an access token', function() { - var accessToken = { + const accessToken = { user: {}, accessTokenExpiresAt: new Date(new Date().getTime() + 10000) }; - var model = { + const model = { getAccessToken: function() { return accessToken; }, @@ -181,14 +181,14 @@ describe('AuthenticateHandler integration', function() { return true; } }; - var handler = new AuthenticateHandler({ addAcceptedScopesHeader: true, addAuthorizedScopesHeader: true, model: model, scope: 'foo' }); - var request = new Request({ + const handler = new AuthenticateHandler({ addAcceptedScopesHeader: true, addAuthorizedScopesHeader: true, model: model, scope: 'foo' }); + const request = new Request({ body: {}, headers: { 'Authorization': 'Bearer foo' }, method: {}, query: {} }); - var response = new Response({ body: {}, headers: {} }); + const response = new Response({ body: {}, headers: {} }); return handler.handle(request, response) .then(function(data) { @@ -200,8 +200,8 @@ describe('AuthenticateHandler integration', function() { describe('getTokenFromRequest()', function() { it('should throw an error if more than one authentication method is used', function() { - var handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); - var request = new Request({ + const handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); + const request = new Request({ body: {}, headers: { 'Authorization': 'Bearer foo' }, method: {}, @@ -219,8 +219,8 @@ describe('AuthenticateHandler integration', function() { }); it('should throw an error if `accessToken` is missing', function() { - var handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); - var request = new Request({ body: {}, headers: {}, method: {}, query: {} }); + const handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); + const request = new Request({ body: {}, headers: {}, method: {}, query: {} }); try { handler.getTokenFromRequest(request); @@ -235,8 +235,8 @@ describe('AuthenticateHandler integration', function() { describe('getTokenFromRequestHeader()', function() { it('should throw an error if the token is malformed', function() { - var handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); - var request = new Request({ + const handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); + const request = new Request({ body: {}, headers: { 'Authorization': 'foobar' @@ -256,8 +256,8 @@ describe('AuthenticateHandler integration', function() { }); it('should return the bearer token', function() { - var handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); - var request = new Request({ + const handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); + const request = new Request({ body: {}, headers: { 'Authorization': 'Bearer foo' @@ -266,7 +266,7 @@ describe('AuthenticateHandler integration', function() { query: {} }); - var bearerToken = handler.getTokenFromRequestHeader(request); + const bearerToken = handler.getTokenFromRequestHeader(request); bearerToken.should.equal('foo'); }); @@ -274,7 +274,7 @@ describe('AuthenticateHandler integration', function() { describe('getTokenFromRequestQuery()', function() { it('should throw an error if the query contains a token', function() { - var handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); + const handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); try { handler.getTokenFromRequestQuery(); @@ -287,7 +287,7 @@ describe('AuthenticateHandler integration', function() { }); it('should return the bearer token if `allowBearerTokensInQueryString` is true', function() { - var handler = new AuthenticateHandler({ allowBearerTokensInQueryString: true, model: { getAccessToken: function() {} } }); + const handler = new AuthenticateHandler({ allowBearerTokensInQueryString: true, model: { getAccessToken: function() {} } }); handler.getTokenFromRequestQuery({ query: { access_token: 'foo' } }).should.equal('foo'); }); @@ -295,8 +295,8 @@ describe('AuthenticateHandler integration', function() { describe('getTokenFromRequestBody()', function() { it('should throw an error if the method is `GET`', function() { - var handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); - var request = new Request({ + const handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); + const request = new Request({ body: { access_token: 'foo' }, headers: {}, method: 'GET', @@ -314,8 +314,8 @@ describe('AuthenticateHandler integration', function() { }); it('should throw an error if the media type is not `application/x-www-form-urlencoded`', function() { - var handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); - var request = new Request({ + const handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); + const request = new Request({ body: { access_token: 'foo' }, headers: {}, method: {}, @@ -333,8 +333,8 @@ describe('AuthenticateHandler integration', function() { }); it('should return the bearer token', function() { - var handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); - var request = new Request({ + const handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); + const request = new Request({ body: { access_token: 'foo' }, headers: { 'content-type': 'application/x-www-form-urlencoded', 'transfer-encoding': 'chunked' }, method: {}, @@ -347,10 +347,10 @@ describe('AuthenticateHandler integration', function() { describe('getAccessToken()', function() { it('should throw an error if `accessToken` is missing', function() { - var model = { + const model = { getAccessToken: function() {} }; - var handler = new AuthenticateHandler({ model: model }); + const handler = new AuthenticateHandler({ model: model }); return handler.getAccessToken('foo') .then(should.fail) @@ -361,12 +361,12 @@ describe('AuthenticateHandler integration', function() { }); it('should throw an error if `accessToken.user` is missing', function() { - var model = { + const model = { getAccessToken: function() { return {}; } }; - var handler = new AuthenticateHandler({ model: model }); + const handler = new AuthenticateHandler({ model: model }); return handler.getAccessToken('foo') .then(should.fail) @@ -377,13 +377,13 @@ describe('AuthenticateHandler integration', function() { }); it('should return an access token', function() { - var accessToken = { user: {} }; - var model = { + const accessToken = { user: {} }; + const model = { getAccessToken: function() { return accessToken; } }; - var handler = new AuthenticateHandler({ model: model }); + const handler = new AuthenticateHandler({ model: model }); return handler.getAccessToken('foo') .then(function(data) { @@ -393,34 +393,34 @@ describe('AuthenticateHandler integration', function() { }); it('should support promises', function() { - var model = { + const model = { getAccessToken: function() { return Promise.resolve({ user: {} }); } }; - var handler = new AuthenticateHandler({ model: model }); + const handler = new AuthenticateHandler({ model: model }); handler.getAccessToken('foo').should.be.an.instanceOf(Promise); }); it('should support non-promises', function() { - var model = { + const model = { getAccessToken: function() { return { user: {} }; } }; - var handler = new AuthenticateHandler({ model: model }); + const handler = new AuthenticateHandler({ model: model }); handler.getAccessToken('foo').should.be.an.instanceOf(Promise); }); it('should support callbacks', function() { - var model = { + const model = { getAccessToken: function(token, callback) { callback(null, { user: {} }); } }; - var handler = new AuthenticateHandler({ model: model }); + const handler = new AuthenticateHandler({ model: model }); handler.getAccessToken('foo').should.be.an.instanceOf(Promise); }); @@ -428,8 +428,8 @@ describe('AuthenticateHandler integration', function() { describe('validateAccessToken()', function() { it('should throw an error if `accessToken` is expired', function() { - var accessToken = { accessTokenExpiresAt: new Date(new Date() / 2) }; - var handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); + const accessToken = { accessTokenExpiresAt: new Date(new Date() / 2) }; + const handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); try { handler.validateAccessToken(accessToken); @@ -442,11 +442,11 @@ describe('AuthenticateHandler integration', function() { }); it('should return an access token', function() { - var accessToken = { + const accessToken = { user: {}, accessTokenExpiresAt: new Date(new Date().getTime() + 10000) }; - var handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); + const handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); handler.validateAccessToken(accessToken).should.equal(accessToken); }); @@ -454,13 +454,13 @@ describe('AuthenticateHandler integration', function() { describe('verifyScope()', function() { it('should throw an error if `scope` is insufficient', function() { - var model = { + const model = { getAccessToken: function() {}, verifyScope: function() { return false; } }; - var handler = new AuthenticateHandler({ addAcceptedScopesHeader: true, addAuthorizedScopesHeader: true, model: model, scope: 'foo' }); + const handler = new AuthenticateHandler({ addAcceptedScopesHeader: true, addAuthorizedScopesHeader: true, model: model, scope: 'foo' }); return handler.verifyScope('foo') .then(should.fail) @@ -471,37 +471,37 @@ describe('AuthenticateHandler integration', function() { }); it('should support promises', function() { - var model = { + const model = { getAccessToken: function() {}, verifyScope: function() { return true; } }; - var handler = new AuthenticateHandler({ addAcceptedScopesHeader: true, addAuthorizedScopesHeader: true, model: model, scope: 'foo' }); + const handler = new AuthenticateHandler({ addAcceptedScopesHeader: true, addAuthorizedScopesHeader: true, model: model, scope: 'foo' }); handler.verifyScope('foo').should.be.an.instanceOf(Promise); }); it('should support non-promises', function() { - var model = { + const model = { getAccessToken: function() {}, verifyScope: function() { return true; } }; - var handler = new AuthenticateHandler({ addAcceptedScopesHeader: true, addAuthorizedScopesHeader: true, model: model, scope: 'foo' }); + const handler = new AuthenticateHandler({ addAcceptedScopesHeader: true, addAuthorizedScopesHeader: true, model: model, scope: 'foo' }); handler.verifyScope('foo').should.be.an.instanceOf(Promise); }); it('should support callbacks', function() { - var model = { + const model = { getAccessToken: function() {}, verifyScope: function(token, scope, callback) { callback(null, true); } }; - var handler = new AuthenticateHandler({ addAcceptedScopesHeader: true, addAuthorizedScopesHeader: true, model: model, scope: 'foo' }); + const handler = new AuthenticateHandler({ addAcceptedScopesHeader: true, addAuthorizedScopesHeader: true, model: model, scope: 'foo' }); handler.verifyScope('foo').should.be.an.instanceOf(Promise); }); @@ -509,12 +509,12 @@ describe('AuthenticateHandler integration', function() { describe('updateResponse()', function() { it('should not set the `X-Accepted-OAuth-Scopes` header if `scope` is not specified', function() { - var model = { + const model = { getAccessToken: function() {}, verifyScope: function() {} }; - var handler = new AuthenticateHandler({ addAcceptedScopesHeader: true, addAuthorizedScopesHeader: false, model: model }); - var response = new Response({ body: {}, headers: {} }); + const handler = new AuthenticateHandler({ addAcceptedScopesHeader: true, addAuthorizedScopesHeader: false, model: model }); + const response = new Response({ body: {}, headers: {} }); handler.updateResponse(response, { scope: 'foo biz' }); @@ -522,12 +522,12 @@ describe('AuthenticateHandler integration', function() { }); it('should set the `X-Accepted-OAuth-Scopes` header if `scope` is specified', function() { - var model = { + const model = { getAccessToken: function() {}, verifyScope: function() {} }; - var handler = new AuthenticateHandler({ addAcceptedScopesHeader: true, addAuthorizedScopesHeader: false, model: model, scope: 'foo bar' }); - var response = new Response({ body: {}, headers: {} }); + const handler = new AuthenticateHandler({ addAcceptedScopesHeader: true, addAuthorizedScopesHeader: false, model: model, scope: 'foo bar' }); + const response = new Response({ body: {}, headers: {} }); handler.updateResponse(response, { scope: 'foo biz' }); @@ -535,12 +535,12 @@ describe('AuthenticateHandler integration', function() { }); it('should not set the `X-Authorized-OAuth-Scopes` header if `scope` is not specified', function() { - var model = { + const model = { getAccessToken: function() {}, verifyScope: function() {} }; - var handler = new AuthenticateHandler({ addAcceptedScopesHeader: false, addAuthorizedScopesHeader: true, model: model }); - var response = new Response({ body: {}, headers: {} }); + const handler = new AuthenticateHandler({ addAcceptedScopesHeader: false, addAuthorizedScopesHeader: true, model: model }); + const response = new Response({ body: {}, headers: {} }); handler.updateResponse(response, { scope: 'foo biz' }); @@ -548,12 +548,12 @@ describe('AuthenticateHandler integration', function() { }); it('should set the `X-Authorized-OAuth-Scopes` header', function() { - var model = { + const model = { getAccessToken: function() {}, verifyScope: function() {} }; - var handler = new AuthenticateHandler({ addAcceptedScopesHeader: false, addAuthorizedScopesHeader: true, model: model, scope: 'foo bar' }); - var response = new Response({ body: {}, headers: {} }); + const handler = new AuthenticateHandler({ addAcceptedScopesHeader: false, addAuthorizedScopesHeader: true, model: model, scope: 'foo bar' }); + const response = new Response({ body: {}, headers: {} }); handler.updateResponse(response, { scope: 'foo biz' }); diff --git a/test/integration/handlers/authorize-handler_test.js b/test/integration/handlers/authorize-handler_test.js index afe737e1e..49d2c0d6a 100644 --- a/test/integration/handlers/authorize-handler_test.js +++ b/test/integration/handlers/authorize-handler_test.js @@ -4,22 +4,22 @@ * Module dependencies. */ -var AccessDeniedError = require('../../../lib/errors/access-denied-error'); -var AuthenticateHandler = require('../../../lib/handlers/authenticate-handler'); -var AuthorizeHandler = require('../../../lib/handlers/authorize-handler'); -var CodeResponseType = require('../../../lib/response-types/code-response-type'); -var InvalidArgumentError = require('../../../lib/errors/invalid-argument-error'); -var InvalidClientError = require('../../../lib/errors/invalid-client-error'); -var InvalidRequestError = require('../../../lib/errors/invalid-request-error'); -var InvalidScopeError = require('../../../lib/errors/invalid-scope-error'); -var UnsupportedResponseTypeError = require('../../../lib/errors/unsupported-response-type-error'); -var Promise = require('bluebird'); -var Request = require('../../../lib/request'); -var Response = require('../../../lib/response'); -var ServerError = require('../../../lib/errors/server-error'); -var UnauthorizedClientError = require('../../../lib/errors/unauthorized-client-error'); -var should = require('chai').should(); -var url = require('url'); +const AccessDeniedError = require('../../../lib/errors/access-denied-error'); +const AuthenticateHandler = require('../../../lib/handlers/authenticate-handler'); +const AuthorizeHandler = require('../../../lib/handlers/authorize-handler'); +const CodeResponseType = require('../../../lib/response-types/code-response-type'); +const InvalidArgumentError = require('../../../lib/errors/invalid-argument-error'); +const InvalidClientError = require('../../../lib/errors/invalid-client-error'); +const InvalidRequestError = require('../../../lib/errors/invalid-request-error'); +const InvalidScopeError = require('../../../lib/errors/invalid-scope-error'); +const UnsupportedResponseTypeError = require('../../../lib/errors/unsupported-response-type-error'); +const Promise = require('bluebird'); +const Request = require('../../../lib/request'); +const Response = require('../../../lib/response'); +const ServerError = require('../../../lib/errors/server-error'); +const UnauthorizedClientError = require('../../../lib/errors/unauthorized-client-error'); +const should = require('chai').should(); +const url = require('url'); /** * Test `AuthorizeHandler` integration. @@ -72,7 +72,7 @@ describe('AuthorizeHandler integration', function() { }); it('should throw an error if the model does not implement `getAccessToken()`', function() { - var model = { + const model = { getClient: function() {}, saveAuthorizationCode: function() {} }; @@ -88,34 +88,34 @@ describe('AuthorizeHandler integration', function() { }); it('should set the `authorizationCodeLifetime`', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); handler.authorizationCodeLifetime.should.equal(120); }); it('should set the `authenticateHandler`', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); handler.authenticateHandler.should.be.an.instanceOf(AuthenticateHandler); }); it('should set the `model`', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); handler.model.should.equal(model); }); @@ -123,12 +123,12 @@ describe('AuthorizeHandler integration', function() { describe('handle()', function() { it('should throw an error if `request` is missing', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); try { handler.handle(); @@ -141,13 +141,13 @@ describe('AuthorizeHandler integration', function() { }); it('should throw an error if `response` is missing', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ body: {}, headers: {}, method: {}, query: {} }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: {}, headers: {}, method: {}, query: {} }); try { handler.handle(request); @@ -160,14 +160,14 @@ describe('AuthorizeHandler integration', function() { }); it('should throw an error if `allowed` is `false`', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ body: {}, headers: {}, method: {}, query: { allowed: 'false' } }); - var response = new Response({ body: {}, headers: {} }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: {}, headers: {}, method: {}, query: { allowed: 'false' } }); + const response = new Response({ body: {}, headers: {} }); return handler.handle(request, response) .then(should.fail) @@ -178,7 +178,7 @@ describe('AuthorizeHandler integration', function() { }); it('should redirect to an error response if a non-oauth error is thrown', function() { - var model = { + const model = { getAccessToken: function() { return { user: {}, @@ -192,8 +192,8 @@ describe('AuthorizeHandler integration', function() { throw new Error('Unhandled exception'); } }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { client_id: 12345, response_type: 'code' @@ -206,7 +206,7 @@ describe('AuthorizeHandler integration', function() { state: 'foobar' } }); - var response = new Response({ body: {}, headers: {} }); + const response = new Response({ body: {}, headers: {} }); return handler.handle(request, response) .then(should.fail) @@ -216,7 +216,7 @@ describe('AuthorizeHandler integration', function() { }); it('should redirect to an error response if an oauth error is thrown', function() { - var model = { + const model = { getAccessToken: function() { return { user: {}, @@ -230,8 +230,8 @@ describe('AuthorizeHandler integration', function() { throw new AccessDeniedError('Cannot request this auth code'); } }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { client_id: 12345, response_type: 'code' @@ -244,7 +244,7 @@ describe('AuthorizeHandler integration', function() { state: 'foobar' } }); - var response = new Response({ body: {}, headers: {} }); + const response = new Response({ body: {}, headers: {} }); return handler.handle(request, response) .then(should.fail) @@ -254,8 +254,8 @@ describe('AuthorizeHandler integration', function() { }); it('should redirect to a successful response with `code` and `state` if successful', function() { - var client = { grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] }; - var model = { + const client = { grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] }; + const model = { getAccessToken: function() { return { client: client, @@ -270,8 +270,8 @@ describe('AuthorizeHandler integration', function() { return { authorizationCode: 12345, client: client }; } }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { client_id: 12345, response_type: 'code' @@ -284,7 +284,7 @@ describe('AuthorizeHandler integration', function() { state: 'foobar' } }); - var response = new Response({ body: {}, headers: {} }); + const response = new Response({ body: {}, headers: {} }); return handler.handle(request, response) .then(function() { @@ -294,7 +294,7 @@ describe('AuthorizeHandler integration', function() { }); it('should redirect to an error response if `scope` is invalid', function() { - var model = { + const model = { getAccessToken: function() { return { user: {}, @@ -308,8 +308,8 @@ describe('AuthorizeHandler integration', function() { return {}; } }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { client_id: 12345, response_type: 'code' @@ -323,7 +323,7 @@ describe('AuthorizeHandler integration', function() { state: 'foobar' } }); - var response = new Response({ body: {}, headers: {} }); + const response = new Response({ body: {}, headers: {} }); return handler.handle(request, response) .then(should.fail) @@ -333,8 +333,8 @@ describe('AuthorizeHandler integration', function() { }); it('should redirect to a successful response if `model.validateScope` is not defined', function() { - var client = { grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] }; - var model = { + const client = { grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] }; + const model = { getAccessToken: function() { return { client: client, @@ -349,8 +349,8 @@ describe('AuthorizeHandler integration', function() { return { authorizationCode: 12345, client: client }; } }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { client_id: 12345, response_type: 'code' @@ -364,7 +364,7 @@ describe('AuthorizeHandler integration', function() { state: 'foobar' } }); - var response = new Response({ body: {}, headers: {} }); + const response = new Response({ body: {}, headers: {} }); return handler.handle(request, response) .then(function(data) { @@ -377,8 +377,8 @@ describe('AuthorizeHandler integration', function() { }); it('should redirect to an error response if `scope` is insufficient', function() { - var client = { grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] }; - var model = { + const client = { grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] }; + const model = { getAccessToken: function() { return { client: client, @@ -396,8 +396,8 @@ describe('AuthorizeHandler integration', function() { return false; } }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { client_id: 12345, response_type: 'code' @@ -411,7 +411,7 @@ describe('AuthorizeHandler integration', function() { state: 'foobar' } }); - var response = new Response({ body: {}, headers: {} }); + const response = new Response({ body: {}, headers: {} }); return handler.handle(request, response) .then(should.fail) @@ -421,7 +421,7 @@ describe('AuthorizeHandler integration', function() { }); it('should redirect to an error response if `state` is missing', function() { - var model = { + const model = { getAccessToken: function() { return { user: {}, @@ -435,8 +435,8 @@ describe('AuthorizeHandler integration', function() { throw new AccessDeniedError('Cannot request this auth code'); } }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { client_id: 12345, response_type: 'code' @@ -447,7 +447,7 @@ describe('AuthorizeHandler integration', function() { method: {}, query: {} }); - var response = new Response({ body: {}, headers: {} }); + const response = new Response({ body: {}, headers: {} }); return handler.handle(request, response) .then(should.fail) @@ -457,7 +457,7 @@ describe('AuthorizeHandler integration', function() { }); it('should redirect to an error response if `response_type` is invalid', function() { - var model = { + const model = { getAccessToken: function() { return { user: {}, @@ -471,8 +471,8 @@ describe('AuthorizeHandler integration', function() { return { authorizationCode: 12345, client: {} }; } }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { client_id: 12345, response_type: 'test' @@ -485,7 +485,7 @@ describe('AuthorizeHandler integration', function() { state: 'foobar' } }); - var response = new Response({ body: {}, headers: {} }); + const response = new Response({ body: {}, headers: {} }); return handler.handle(request, response) .then(should.fail) @@ -495,7 +495,7 @@ describe('AuthorizeHandler integration', function() { }); it('should fail on invalid `response_type` before calling model.saveAuthorizationCode()', function() { - var model = { + const model = { getAccessToken: function() { return { user: {}, @@ -509,8 +509,8 @@ describe('AuthorizeHandler integration', function() { throw new Error('must not be reached'); } }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { client_id: 12345, response_type: 'test' @@ -523,7 +523,7 @@ describe('AuthorizeHandler integration', function() { state: 'foobar' } }); - var response = new Response({ body: {}, headers: {} }); + const response = new Response({ body: {}, headers: {} }); return handler.handle(request, response) .then(should.fail) @@ -533,8 +533,8 @@ describe('AuthorizeHandler integration', function() { }); it('should return the `code` if successful', function() { - var client = { grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] }; - var model = { + const client = { grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] }; + const model = { getAccessToken: function() { return { client: client, @@ -549,8 +549,8 @@ describe('AuthorizeHandler integration', function() { return { authorizationCode: 12345, client: client }; } }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { client_id: 12345, response_type: 'code' @@ -563,7 +563,7 @@ describe('AuthorizeHandler integration', function() { state: 'foobar' } }); - var response = new Response({ body: {}, headers: {} }); + const response = new Response({ body: {}, headers: {} }); return handler.handle(request, response) .then(function(data) { @@ -578,12 +578,12 @@ describe('AuthorizeHandler integration', function() { describe('generateAuthorizationCode()', function() { it('should return an auth code', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); return handler.generateAuthorizationCode() .then(function(data) { @@ -593,7 +593,7 @@ describe('AuthorizeHandler integration', function() { }); it('should support promises', function() { - var model = { + const model = { generateAuthorizationCode: function() { return Promise.resolve({}); }, @@ -601,13 +601,13 @@ describe('AuthorizeHandler integration', function() { getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); handler.generateAuthorizationCode().should.be.an.instanceOf(Promise); }); it('should support non-promises', function() { - var model = { + const model = { generateAuthorizationCode: function() { return {}; }, @@ -615,7 +615,7 @@ describe('AuthorizeHandler integration', function() { getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); handler.generateAuthorizationCode().should.be.an.instanceOf(Promise); }); @@ -623,12 +623,12 @@ describe('AuthorizeHandler integration', function() { describe('getAuthorizationCodeLifetime()', function() { it('should return a date', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); handler.getAuthorizationCodeLifetime().should.be.an.instanceOf(Date); }); @@ -636,13 +636,13 @@ describe('AuthorizeHandler integration', function() { describe('getClient()', function() { it('should throw an error if `client_id` is missing', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ body: { response_type: 'code' }, headers: {}, method: {}, query: {} }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { response_type: 'code' }, headers: {}, method: {}, query: {} }); try { handler.getClient(request); @@ -655,13 +655,13 @@ describe('AuthorizeHandler integration', function() { }); it('should throw an error if `client_id` is invalid', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ body: { client_id: 'ø倣‰', response_type: 'code' }, headers: {}, method: {}, query: {} }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { client_id: 'ø倣‰', response_type: 'code' }, headers: {}, method: {}, query: {} }); try { handler.getClient(request); @@ -674,13 +674,13 @@ describe('AuthorizeHandler integration', function() { }); it('should throw an error if `client.redirectUri` is invalid', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ body: { client_id: 12345, response_type: 'code', redirect_uri: 'foobar' }, headers: {}, method: {}, query: {} }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { client_id: 12345, response_type: 'code', redirect_uri: 'foobar' }, headers: {}, method: {}, query: {} }); try { handler.getClient(request); @@ -693,13 +693,13 @@ describe('AuthorizeHandler integration', function() { }); it('should throw an error if `client` is missing', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ body: { client_id: 12345, response_type: 'code' }, headers: {}, method: {}, query: {} }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { client_id: 12345, response_type: 'code' }, headers: {}, method: {}, query: {} }); return handler.getClient(request) .then(should.fail) @@ -710,15 +710,15 @@ describe('AuthorizeHandler integration', function() { }); it('should throw an error if `client.grants` is missing', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() { return {}; }, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ body: { client_id: 12345, response_type: 'code' }, headers: {}, method: {}, query: {} }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { client_id: 12345, response_type: 'code' }, headers: {}, method: {}, query: {} }); return handler.getClient(request) .then(should.fail) @@ -729,15 +729,15 @@ describe('AuthorizeHandler integration', function() { }); it('should throw an error if `client` is unauthorized', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() { return { grants: [] }; }, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ body: { client_id: 12345, response_type: 'code' }, headers: {}, method: {}, query: {} }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { client_id: 12345, response_type: 'code' }, headers: {}, method: {}, query: {} }); return handler.getClient(request) .then(should.fail) @@ -748,13 +748,13 @@ describe('AuthorizeHandler integration', function() { }); it('should throw an error if `client.redirectUri` is missing', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() { return { grants: ['authorization_code'] }; }, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ body: { client_id: 12345, response_type: 'code' }, headers: {}, method: {}, query: {} }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { client_id: 12345, response_type: 'code' }, headers: {}, method: {}, query: {} }); return handler.getClient(request) .then(should.fail) @@ -765,15 +765,15 @@ describe('AuthorizeHandler integration', function() { }); it('should throw an error if `client.redirectUri` is not equal to `redirectUri`', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() { return { grants: ['authorization_code'], redirectUris: ['https://example.com'] }; }, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ body: { client_id: 12345, response_type: 'code', redirect_uri: 'https://foobar.com' }, headers: {}, method: {}, query: {} }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { client_id: 12345, response_type: 'code', redirect_uri: 'https://foobar.com' }, headers: {}, method: {}, query: {} }); return handler.getClient(request) .then(should.fail) @@ -784,15 +784,15 @@ describe('AuthorizeHandler integration', function() { }); it('should support promises', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() { return Promise.resolve({ grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] }); }, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { client_id: 12345 }, headers: {}, method: {}, @@ -803,15 +803,15 @@ describe('AuthorizeHandler integration', function() { }); it('should support non-promises', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() { return { grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] }; }, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { client_id: 12345 }, headers: {}, method: {}, @@ -822,7 +822,7 @@ describe('AuthorizeHandler integration', function() { }); it('should support callbacks', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function(clientId, clientSecret, callback) { should.equal(clientSecret, null); @@ -830,8 +830,8 @@ describe('AuthorizeHandler integration', function() { }, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { client_id: 12345 }, headers: {}, method: {}, @@ -843,16 +843,16 @@ describe('AuthorizeHandler integration', function() { describe('with `client_id` in the request query', function() { it('should return a client', function() { - var client = { grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] }; - var model = { + const client = { grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] }; + const model = { getAccessToken: function() {}, getClient: function() { return client; }, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ body: { response_type: 'code' }, headers: {}, method: {}, query: { client_id: 12345 } }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { response_type: 'code' }, headers: {}, method: {}, query: { client_id: 12345 } }); return handler.getClient(request) .then(function(data) { @@ -865,13 +865,13 @@ describe('AuthorizeHandler integration', function() { describe('getScope()', function() { it('should throw an error if `scope` is invalid', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ body: { scope: 'ø倣‰' }, headers: {}, method: {}, query: {} }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { scope: 'ø倣‰' }, headers: {}, method: {}, query: {} }); try { handler.getScope(request); @@ -885,13 +885,13 @@ describe('AuthorizeHandler integration', function() { describe('with `scope` in the request body', function() { it('should return the scope', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ body: { scope: 'foo' }, headers: {}, method: {}, query: {} }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { scope: 'foo' }, headers: {}, method: {}, query: {} }); handler.getScope(request).should.equal('foo'); }); @@ -899,13 +899,13 @@ describe('AuthorizeHandler integration', function() { describe('with `scope` in the request query', function() { it('should return the scope', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ body: {}, headers: {}, method: {}, query: { scope: 'foo' } }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: {}, headers: {}, method: {}, query: { scope: 'foo' } }); handler.getScope(request).should.equal('foo'); }); @@ -914,13 +914,13 @@ describe('AuthorizeHandler integration', function() { describe('getState()', function() { it('should throw an error if `allowEmptyState` is false and `state` is missing', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ allowEmptyState: false, authorizationCodeLifetime: 120, model: model }); - var request = new Request({ body: {}, headers: {}, method: {}, query: {} }); + const handler = new AuthorizeHandler({ allowEmptyState: false, authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: {}, headers: {}, method: {}, query: {} }); try { handler.getState(request); @@ -933,13 +933,13 @@ describe('AuthorizeHandler integration', function() { }); it('should throw an error if `state` is invalid', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ body: {}, headers: {}, method: {}, query: { state: 'ø倣‰' } }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: {}, headers: {}, method: {}, query: { state: 'ø倣‰' } }); try { handler.getState(request); @@ -953,13 +953,13 @@ describe('AuthorizeHandler integration', function() { describe('with `state` in the request body', function() { it('should return the state', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ body: { state: 'foobar' }, headers: {}, method: {}, query: {} }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { state: 'foobar' }, headers: {}, method: {}, query: {} }); handler.getState(request).should.equal('foobar'); }); @@ -967,13 +967,13 @@ describe('AuthorizeHandler integration', function() { describe('with `state` in the request query', function() { it('should return the state', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ body: {}, headers: {}, method: {}, query: { state: 'foobar' } }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: {}, headers: {}, method: {}, query: { state: 'foobar' } }); handler.getState(request).should.equal('foobar'); }); @@ -982,14 +982,14 @@ describe('AuthorizeHandler integration', function() { describe('getUser()', function() { it('should throw an error if `user` is missing', function() { - var authenticateHandler = { handle: function() {} }; - var model = { + const authenticateHandler = { handle: function() {} }; + const model = { getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authenticateHandler: authenticateHandler, authorizationCodeLifetime: 120, model: model }); - var request = new Request({ body: {}, headers: {}, method: {}, query: {} }); - var response = new Response(); + const handler = new AuthorizeHandler({ authenticateHandler: authenticateHandler, authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: {}, headers: {}, method: {}, query: {} }); + const response = new Response(); return handler.getUser(request, response) .then(should.fail) @@ -1000,8 +1000,8 @@ describe('AuthorizeHandler integration', function() { }); it('should return a user', function() { - var user = {}; - var model = { + const user = {}; + const model = { getAccessToken: function() { return { user: user, @@ -1011,9 +1011,9 @@ describe('AuthorizeHandler integration', function() { getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ body: {}, headers: { 'Authorization': 'Bearer foo' }, method: {}, query: {} }); - var response = new Response({ body: {}, headers: {} }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: {}, headers: { 'Authorization': 'Bearer foo' }, method: {}, query: {} }); + const response = new Response({ body: {}, headers: {} }); return handler.getUser(request, response) .then(function(data) { @@ -1025,15 +1025,15 @@ describe('AuthorizeHandler integration', function() { describe('saveAuthorizationCode()', function() { it('should return an auth code', function() { - var authorizationCode = {}; - var model = { + const authorizationCode = {}; + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() { return authorizationCode; } }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); return handler.saveAuthorizationCode('foo', 'bar', 'biz', 'baz') .then(function(data) { @@ -1043,40 +1043,40 @@ describe('AuthorizeHandler integration', function() { }); it('should support promises when calling `model.saveAuthorizationCode()`', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() { return Promise.resolve({}); } }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); handler.saveAuthorizationCode('foo', 'bar', 'biz', 'baz').should.be.an.instanceOf(Promise); }); it('should support non-promises when calling `model.saveAuthorizationCode()`', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() { return {}; } }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); handler.saveAuthorizationCode('foo', 'bar', 'biz', 'baz').should.be.an.instanceOf(Promise); }); it('should support callbacks when calling `model.saveAuthorizationCode()`', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function(code, client, user, callback) { return callback(null, true); } }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); handler.saveAuthorizationCode('foo', 'bar', 'biz', 'baz').should.be.an.instanceOf(Promise); }); @@ -1084,13 +1084,13 @@ describe('AuthorizeHandler integration', function() { describe('getResponseType()', function() { it('should throw an error if `response_type` is missing', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ body: {}, headers: {}, method: {}, query: {} }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: {}, headers: {}, method: {}, query: {} }); try { handler.getResponseType(request); @@ -1103,13 +1103,13 @@ describe('AuthorizeHandler integration', function() { }); it('should throw an error if `response_type` is not `code`', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ body: { response_type: 'foobar' }, headers: {}, method: {}, query: {} }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { response_type: 'foobar' }, headers: {}, method: {}, query: {} }); try { handler.getResponseType(request); @@ -1123,14 +1123,14 @@ describe('AuthorizeHandler integration', function() { describe('with `response_type` in the request body', function() { it('should return a response type', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ body: { response_type: 'code' }, headers: {}, method: {}, query: {} }); - var ResponseType = handler.getResponseType(request); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { response_type: 'code' }, headers: {}, method: {}, query: {} }); + const ResponseType = handler.getResponseType(request); ResponseType.should.equal(CodeResponseType); }); @@ -1138,14 +1138,14 @@ describe('AuthorizeHandler integration', function() { describe('with `response_type` in the request query', function() { it('should return a response type', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ body: {}, headers: {}, method: {}, query: { response_type: 'code' } }); - var ResponseType = handler.getResponseType(request); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: {}, headers: {}, method: {}, query: { response_type: 'code' } }); + const ResponseType = handler.getResponseType(request); ResponseType.should.equal(CodeResponseType); }); @@ -1154,14 +1154,14 @@ describe('AuthorizeHandler integration', function() { describe('buildSuccessRedirectUri()', function() { it('should return a redirect uri', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var responseType = new CodeResponseType(12345); - var redirectUri = handler.buildSuccessRedirectUri('http://example.com/cb', responseType); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const responseType = new CodeResponseType(12345); + const redirectUri = handler.buildSuccessRedirectUri('http://example.com/cb', responseType); url.format(redirectUri).should.equal('http://example.com/cb?code=12345'); }); @@ -1169,27 +1169,27 @@ describe('AuthorizeHandler integration', function() { describe('buildErrorRedirectUri()', function() { it('should set `error_description` if available', function() { - var error = new InvalidClientError('foo bar'); - var model = { + const error = new InvalidClientError('foo bar'); + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var redirectUri = handler.buildErrorRedirectUri('http://example.com/cb', error); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const redirectUri = handler.buildErrorRedirectUri('http://example.com/cb', error); url.format(redirectUri).should.equal('http://example.com/cb?error=invalid_client&error_description=foo%20bar'); }); it('should return a redirect uri', function() { - var error = new InvalidClientError(); - var model = { + const error = new InvalidClientError(); + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var redirectUri = handler.buildErrorRedirectUri('http://example.com/cb', error); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const redirectUri = handler.buildErrorRedirectUri('http://example.com/cb', error); url.format(redirectUri).should.equal('http://example.com/cb?error=invalid_client&error_description=Bad%20Request'); }); @@ -1197,14 +1197,14 @@ describe('AuthorizeHandler integration', function() { describe('updateResponse()', function() { it('should set the `location` header', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var response = new Response({ body: {}, headers: {} }); - var uri = url.parse('http://example.com/cb'); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const response = new Response({ body: {}, headers: {} }); + const uri = url.parse('http://example.com/cb'); handler.updateResponse(response, uri, 'foobar'); diff --git a/test/integration/handlers/token-handler_test.js b/test/integration/handlers/token-handler_test.js index 19b69b598..41ec5248b 100644 --- a/test/integration/handlers/token-handler_test.js +++ b/test/integration/handlers/token-handler_test.js @@ -4,22 +4,22 @@ * Module dependencies. */ -var AccessDeniedError = require('../../../lib/errors/access-denied-error'); -var BearerTokenType = require('../../../lib/token-types/bearer-token-type'); -var InvalidArgumentError = require('../../../lib/errors/invalid-argument-error'); -var InvalidClientError = require('../../../lib/errors/invalid-client-error'); -var InvalidGrantError = require('../../../lib/errors/invalid-grant-error'); -var InvalidRequestError = require('../../../lib/errors/invalid-request-error'); -var PasswordGrantType = require('../../../lib/grant-types/password-grant-type'); -var Promise = require('bluebird'); -var Request = require('../../../lib/request'); -var Response = require('../../../lib/response'); -var ServerError = require('../../../lib/errors/server-error'); -var TokenHandler = require('../../../lib/handlers/token-handler'); -var UnauthorizedClientError = require('../../../lib/errors/unauthorized-client-error'); -var UnsupportedGrantTypeError = require('../../../lib/errors/unsupported-grant-type-error'); -var should = require('chai').should(); -var util = require('util'); +const AccessDeniedError = require('../../../lib/errors/access-denied-error'); +const BearerTokenType = require('../../../lib/token-types/bearer-token-type'); +const InvalidArgumentError = require('../../../lib/errors/invalid-argument-error'); +const InvalidClientError = require('../../../lib/errors/invalid-client-error'); +const InvalidGrantError = require('../../../lib/errors/invalid-grant-error'); +const InvalidRequestError = require('../../../lib/errors/invalid-request-error'); +const PasswordGrantType = require('../../../lib/grant-types/password-grant-type'); +const Promise = require('bluebird'); +const Request = require('../../../lib/request'); +const Response = require('../../../lib/response'); +const ServerError = require('../../../lib/errors/server-error'); +const TokenHandler = require('../../../lib/handlers/token-handler'); +const UnauthorizedClientError = require('../../../lib/errors/unauthorized-client-error'); +const UnsupportedGrantTypeError = require('../../../lib/errors/unsupported-grant-type-error'); +const should = require('chai').should(); +const util = require('util'); /** * Test `TokenHandler` integration. @@ -72,75 +72,75 @@ describe('TokenHandler integration', function() { }); it('should set the `accessTokenLifetime`', function() { - var accessTokenLifetime = {}; - var model = { + const accessTokenLifetime = {}; + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: accessTokenLifetime, model: model, refreshTokenLifetime: 120 }); + const handler = new TokenHandler({ accessTokenLifetime: accessTokenLifetime, model: model, refreshTokenLifetime: 120 }); handler.accessTokenLifetime.should.equal(accessTokenLifetime); }); it('should set the `alwaysIssueNewRefreshToken`', function() { - var alwaysIssueNewRefreshToken = true; - var model = { + const alwaysIssueNewRefreshToken = true; + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 123, model: model, refreshTokenLifetime: 120, alwaysIssueNewRefreshToken: alwaysIssueNewRefreshToken }); + const handler = new TokenHandler({ accessTokenLifetime: 123, model: model, refreshTokenLifetime: 120, alwaysIssueNewRefreshToken: alwaysIssueNewRefreshToken }); handler.alwaysIssueNewRefreshToken.should.equal(alwaysIssueNewRefreshToken); }); it('should set the `alwaysIssueNewRefreshToken` to false', function() { - var alwaysIssueNewRefreshToken = false; - var model = { + const alwaysIssueNewRefreshToken = false; + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 123, model: model, refreshTokenLifetime: 120, alwaysIssueNewRefreshToken: alwaysIssueNewRefreshToken }); + const handler = new TokenHandler({ accessTokenLifetime: 123, model: model, refreshTokenLifetime: 120, alwaysIssueNewRefreshToken: alwaysIssueNewRefreshToken }); handler.alwaysIssueNewRefreshToken.should.equal(alwaysIssueNewRefreshToken); }); it('should return the default `alwaysIssueNewRefreshToken` value', function() { - var model = { + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 123, model: model, refreshTokenLifetime: 120 }); + const handler = new TokenHandler({ accessTokenLifetime: 123, model: model, refreshTokenLifetime: 120 }); handler.alwaysIssueNewRefreshToken.should.equal(true); }); it('should set the `extendedGrantTypes`', function() { - var extendedGrantTypes = { foo: 'bar' }; - var model = { + const extendedGrantTypes = { foo: 'bar' }; + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, extendedGrantTypes: extendedGrantTypes, model: model, refreshTokenLifetime: 120 }); + const handler = new TokenHandler({ accessTokenLifetime: 120, extendedGrantTypes: extendedGrantTypes, model: model, refreshTokenLifetime: 120 }); handler.grantTypes.should.deep.include(extendedGrantTypes); }); it('should set the `model`', function() { - var model = { + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); handler.model.should.equal(model); }); it('should set the `refreshTokenLifetime`', function() { - var refreshTokenLifetime = {}; - var model = { + const refreshTokenLifetime = {}; + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: refreshTokenLifetime }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: refreshTokenLifetime }); handler.refreshTokenLifetime.should.equal(refreshTokenLifetime); }); @@ -148,11 +148,11 @@ describe('TokenHandler integration', function() { describe('handle()', function() { it('should throw an error if `request` is missing', function() { - var model = { + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); try { handler.handle(); @@ -165,12 +165,12 @@ describe('TokenHandler integration', function() { }); it('should throw an error if `response` is missing', function() { - var model = { + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ body: {}, headers: {}, method: {}, query: {} }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: {}, headers: {}, method: {}, query: {} }); try { handler.handle(request); @@ -183,13 +183,13 @@ describe('TokenHandler integration', function() { }); it('should throw an error if the method is not `POST`', function() { - var model = { + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ body: {}, headers: {}, method: 'GET', query: {} }); - var response = new Response({ body: {}, headers: {} }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: {}, headers: {}, method: 'GET', query: {} }); + const response = new Response({ body: {}, headers: {} }); return handler.handle(request, response) .then(should.fail) @@ -200,13 +200,13 @@ describe('TokenHandler integration', function() { }); it('should throw an error if the media type is not `application/x-www-form-urlencoded`', function() { - var model = { + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ body: {}, headers: {}, method: 'POST', query: {} }); - var response = new Response({ body: {}, headers: {} }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: {}, headers: {}, method: 'POST', query: {} }); + const response = new Response({ body: {}, headers: {} }); return handler.handle(request, response) .then(should.fail) @@ -217,13 +217,13 @@ describe('TokenHandler integration', function() { }); it('should throw the error if an oauth error is thrown', function() { - var model = { + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ body: {}, headers: { 'content-type': 'application/x-www-form-urlencoded', 'transfer-encoding': 'chunked' }, method: 'POST', query: {} }); - var response = new Response({ body: {}, headers: {} }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: {}, headers: { 'content-type': 'application/x-www-form-urlencoded', 'transfer-encoding': 'chunked' }, method: 'POST', query: {} }); + const response = new Response({ body: {}, headers: {} }); return handler.handle(request, response) .then(should.fail) @@ -234,15 +234,15 @@ describe('TokenHandler integration', function() { }); it('should throw a server error if a non-oauth error is thrown', function() { - var model = { + const model = { getClient: function() { throw new Error('Unhandled exception'); }, getUser: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: { client_id: 12345, client_secret: 'secret', @@ -254,7 +254,7 @@ describe('TokenHandler integration', function() { method: 'POST', query: {} }); - var response = new Response({ body: {}, headers: {} }); + const response = new Response({ body: {}, headers: {} }); return handler.handle(request, response) .then(should.fail) @@ -266,15 +266,15 @@ describe('TokenHandler integration', function() { }); it('should update the response if an error is thrown', function() { - var model = { + const model = { getClient: function() { throw new Error('Unhandled exception'); }, getUser: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: { client_id: 12345, client_secret: 'secret', @@ -286,7 +286,7 @@ describe('TokenHandler integration', function() { method: 'POST', query: {} }); - var response = new Response({ body: {}, headers: {} }); + const response = new Response({ body: {}, headers: {} }); return handler.handle(request, response) .then(should.fail) @@ -297,15 +297,15 @@ describe('TokenHandler integration', function() { }); it('should return a bearer token if successful', function() { - var token = { accessToken: 'foo', client: {}, refreshToken: 'bar', scope: 'foobar', user: {} }; - var model = { + const token = { accessToken: 'foo', client: {}, refreshToken: 'bar', scope: 'foobar', user: {} }; + const model = { getClient: function() { return { grants: ['password'] }; }, getUser: function() { return {}; }, saveToken: function() { return token; }, validateScope: function() { return 'baz'; } }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: { client_id: 12345, client_secret: 'secret', @@ -318,7 +318,7 @@ describe('TokenHandler integration', function() { method: 'POST', query: {} }); - var response = new Response({ body: {}, headers: {} }); + const response = new Response({ body: {}, headers: {} }); return handler.handle(request, response) .then(function(data) { @@ -328,15 +328,15 @@ describe('TokenHandler integration', function() { }); it('should not return custom attributes in a bearer token if the allowExtendedTokenAttributes is not set', function() { - var token = { accessToken: 'foo', client: {}, refreshToken: 'bar', scope: 'foobar', user: {}, foo: 'bar' }; - var model = { + const token = { accessToken: 'foo', client: {}, refreshToken: 'bar', scope: 'foobar', user: {}, foo: 'bar' }; + const model = { getClient: function() { return { grants: ['password'] }; }, getUser: function() { return {}; }, saveToken: function() { return token; }, validateScope: function() { return 'baz'; } }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: { client_id: 12345, client_secret: 'secret', @@ -349,7 +349,7 @@ describe('TokenHandler integration', function() { method: 'POST', query: {} }); - var response = new Response({ body: {}, headers: {} }); + const response = new Response({ body: {}, headers: {} }); return handler.handle(request, response) .then(function() { @@ -363,15 +363,15 @@ describe('TokenHandler integration', function() { }); it('should return custom attributes in a bearer token if the allowExtendedTokenAttributes is set', function() { - var token = { accessToken: 'foo', client: {}, refreshToken: 'bar', scope: 'foobar', user: {}, foo: 'bar' }; - var model = { + const token = { accessToken: 'foo', client: {}, refreshToken: 'bar', scope: 'foobar', user: {}, foo: 'bar' }; + const model = { getClient: function() { return { grants: ['password'] }; }, getUser: function() { return {}; }, saveToken: function() { return token; }, validateScope: function() { return 'baz'; } }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120, allowExtendedTokenAttributes: true }); - var request = new Request({ + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120, allowExtendedTokenAttributes: true }); + const request = new Request({ body: { client_id: 12345, client_secret: 'secret', @@ -384,7 +384,7 @@ describe('TokenHandler integration', function() { method: 'POST', query: {} }); - var response = new Response({ body: {}, headers: {} }); + const response = new Response({ body: {}, headers: {} }); return handler.handle(request, response) .then(function() { @@ -401,12 +401,12 @@ describe('TokenHandler integration', function() { describe('getClient()', function() { it('should throw an error if `clientId` is invalid', function() { - var model = { + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ body: { client_id: 'ø倣‰', client_secret: 'foo' }, headers: {}, method: {}, query: {} }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: { client_id: 'ø倣‰', client_secret: 'foo' }, headers: {}, method: {}, query: {} }); try { handler.getClient(request); @@ -419,12 +419,12 @@ describe('TokenHandler integration', function() { }); it('should throw an error if `clientSecret` is invalid', function() { - var model = { + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ body: { client_id: 'foo', client_secret: 'ø倣‰' }, headers: {}, method: {}, query: {} }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: { client_id: 'foo', client_secret: 'ø倣‰' }, headers: {}, method: {}, query: {} }); try { handler.getClient(request); @@ -437,12 +437,12 @@ describe('TokenHandler integration', function() { }); it('should throw an error if `client` is missing', function() { - var model = { + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ body: { client_id: 12345, client_secret: 'secret' }, headers: {}, method: {}, query: {} }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: { client_id: 12345, client_secret: 'secret' }, headers: {}, method: {}, query: {} }); return handler.getClient(request) .then(should.fail) @@ -453,12 +453,12 @@ describe('TokenHandler integration', function() { }); it('should throw an error if `client.grants` is missing', function() { - var model = { + const model = { getClient: function() { return {}; }, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ body: { client_id: 12345, client_secret: 'secret' }, headers: {}, method: {}, query: {} }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: { client_id: 12345, client_secret: 'secret' }, headers: {}, method: {}, query: {} }); return handler.getClient(request) .then(should.fail) @@ -469,12 +469,12 @@ describe('TokenHandler integration', function() { }); it('should throw an error if `client.grants` is invalid', function() { - var model = { + const model = { getClient: function() { return { grants: 'foobar' }; }, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ body: { client_id: 12345, client_secret: 'secret' }, headers: {}, method: {}, query: {} }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: { client_id: 12345, client_secret: 'secret' }, headers: {}, method: {}, query: {} }); return handler.getClient(request) .then(should.fail) @@ -485,18 +485,18 @@ describe('TokenHandler integration', function() { }); it('should throw a 401 error if the client is invalid and the request contains an authorization header', function() { - var model = { + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: {}, headers: { 'authorization': util.format('Basic %s', Buffer.from('foo:bar').toString('base64')) }, method: {}, query: {} }); - var response = new Response({ body: {}, headers: {} }); + const response = new Response({ body: {}, headers: {} }); return handler.getClient(request, response) .then(should.fail) @@ -510,13 +510,13 @@ describe('TokenHandler integration', function() { }); it('should return a client', function() { - var client = { id: 12345, grants: [] }; - var model = { + const client = { id: 12345, grants: [] }; + const model = { getClient: function() { return client; }, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ body: { client_id: 12345, client_secret: 'secret' }, headers: {}, method: {}, query: {} }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: { client_id: 12345, client_secret: 'secret' }, headers: {}, method: {}, query: {} }); return handler.getClient(request) .then(function(data) { @@ -528,13 +528,13 @@ describe('TokenHandler integration', function() { describe('with `password` grant type and `requireClientAuthentication` is false', function() { it('should return a client ', function() { - var client = { id: 12345, grants: [] }; - var model = { + const client = { id: 12345, grants: [] }; + const model = { getClient: function() { return client; }, saveToken: function() {} }; - var handler = new TokenHandler({ + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120, @@ -542,7 +542,7 @@ describe('TokenHandler integration', function() { password: false } }); - var request = new Request({ body: { client_id: 'blah', grant_type: 'password'}, headers: {}, method: {}, query: {} }); + const request = new Request({ body: { client_id: 'blah', grant_type: 'password'}, headers: {}, method: {}, query: {} }); return handler.getClient(request) .then(function(data) { @@ -555,13 +555,13 @@ describe('TokenHandler integration', function() { describe('with `password` grant type and `requireClientAuthentication` is false and Authorization header', function() { it('should return a client ', function() { - var client = { id: 12345, grants: [] }; - var model = { + const client = { id: 12345, grants: [] }; + const model = { getClient: function() { return client; }, saveToken: function() {} }; - var handler = new TokenHandler({ + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120, @@ -569,7 +569,7 @@ describe('TokenHandler integration', function() { password: false } }); - var request = new Request({ + const request = new Request({ body: { grant_type: 'password'}, headers: { 'authorization': util.format('Basic %s', Buffer.from('blah:').toString('base64')) }, method: {}, @@ -585,34 +585,34 @@ describe('TokenHandler integration', function() { }); it('should support promises', function() { - var model = { + const model = { getClient: function() { return Promise.resolve({ grants: [] }); }, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ body: { client_id: 12345, client_secret: 'secret' }, headers: {}, method: {}, query: {} }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: { client_id: 12345, client_secret: 'secret' }, headers: {}, method: {}, query: {} }); handler.getClient(request).should.be.an.instanceOf(Promise); }); it('should support non-promises', function() { - var model = { + const model = { getClient: function() { return { grants: [] }; }, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ body: { client_id: 12345, client_secret: 'secret' }, headers: {}, method: {}, query: {} }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: { client_id: 12345, client_secret: 'secret' }, headers: {}, method: {}, query: {} }); handler.getClient(request).should.be.an.instanceOf(Promise); }); it('should support callbacks', function() { - var model = { + const model = { getClient: function(clientId, clientSecret, callback) { callback(null, { grants: [] }); }, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ body: { client_id: 12345, client_secret: 'secret' }, headers: {}, method: {}, query: {} }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: { client_id: 12345, client_secret: 'secret' }, headers: {}, method: {}, query: {} }); handler.getClient(request).should.be.an.instanceOf(Promise); }); @@ -620,12 +620,12 @@ describe('TokenHandler integration', function() { describe('getClientCredentials()', function() { it('should throw an error if `client_id` is missing', function() { - var model = { + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ body: { client_secret: 'foo' }, headers: {}, method: {}, query: {} }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: { client_secret: 'foo' }, headers: {}, method: {}, query: {} }); try { handler.getClientCredentials(request); @@ -638,12 +638,12 @@ describe('TokenHandler integration', function() { }); it('should throw an error if `client_secret` is missing', function() { - var model = { + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ body: { client_id: 'foo' }, headers: {}, method: {}, query: {} }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: { client_id: 'foo' }, headers: {}, method: {}, query: {} }); try { handler.getClientCredentials(request); @@ -657,13 +657,13 @@ describe('TokenHandler integration', function() { describe('with `client_id` and grant type is `password` and `requireClientAuthentication` is false', function() { it('should return a client', function() { - var model = { + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120, requireClientAuthentication: { password: false} }); - var request = new Request({ body: { client_id: 'foo', grant_type: 'password' }, headers: {}, method: {}, query: {} }); - var credentials = handler.getClientCredentials(request); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120, requireClientAuthentication: { password: false} }); + const request = new Request({ body: { client_id: 'foo', grant_type: 'password' }, headers: {}, method: {}, query: {} }); + const credentials = handler.getClientCredentials(request); credentials.should.eql({ clientId: 'foo' }); }); @@ -671,12 +671,12 @@ describe('TokenHandler integration', function() { describe('with `client_id` and `client_secret` in the request header as basic auth', function() { it('should return a client', function() { - var model = { + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: {}, headers: { 'authorization': util.format('Basic %s', Buffer.from('foo:bar').toString('base64')) @@ -684,7 +684,7 @@ describe('TokenHandler integration', function() { method: {}, query: {} }); - var credentials = handler.getClientCredentials(request); + const credentials = handler.getClientCredentials(request); credentials.should.eql({ clientId: 'foo', clientSecret: 'bar' }); }); @@ -692,13 +692,13 @@ describe('TokenHandler integration', function() { describe('with `client_id` and `client_secret` in the request body', function() { it('should return a client', function() { - var model = { + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ body: { client_id: 'foo', client_secret: 'bar' }, headers: {}, method: {}, query: {} }); - var credentials = handler.getClientCredentials(request); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: { client_id: 'foo', client_secret: 'bar' }, headers: {}, method: {}, query: {} }); + const credentials = handler.getClientCredentials(request); credentials.should.eql({ clientId: 'foo', clientSecret: 'bar' }); }); @@ -707,12 +707,12 @@ describe('TokenHandler integration', function() { describe('handleGrantType()', function() { it('should throw an error if `grant_type` is missing', function() { - var model = { + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ body: {}, headers: {}, method: {}, query: {} }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: {}, headers: {}, method: {}, query: {} }); try { handler.handleGrantType(request); @@ -725,12 +725,12 @@ describe('TokenHandler integration', function() { }); it('should throw an error if `grant_type` is invalid', function() { - var model = { + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ body: { grant_type: '~foo~' }, headers: {}, method: {}, query: {} }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: { grant_type: '~foo~' }, headers: {}, method: {}, query: {} }); try { handler.handleGrantType(request); @@ -743,12 +743,12 @@ describe('TokenHandler integration', function() { }); it('should throw an error if `grant_type` is unsupported', function() { - var model = { + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ body: { grant_type: 'foobar' }, headers: {}, method: {}, query: {} }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: { grant_type: 'foobar' }, headers: {}, method: {}, query: {} }); try { handler.handleGrantType(request); @@ -761,13 +761,13 @@ describe('TokenHandler integration', function() { }); it('should throw an error if `grant_type` is unauthorized', function() { - var client = { grants: ['client_credentials'] }; - var model = { + const client = { grants: ['client_credentials'] }; + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ body: { grant_type: 'password' }, headers: {}, method: {}, query: {} }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: { grant_type: 'password' }, headers: {}, method: {}, query: {} }); try { handler.handleGrantType(request, client); @@ -780,14 +780,14 @@ describe('TokenHandler integration', function() { }); it('should throw an invalid grant error if a non-oauth error is thrown', function() { - var client = { grants: ['password'] }; - var model = { + const client = { grants: ['password'] }; + const model = { getClient: function(clientId, password, callback) { callback(null, client); }, getUser: function(uid, pwd, callback) { callback(); }, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ body: { grant_type: 'password', username: 'foo', password: 'bar' }, headers: {}, method: {}, query: {} }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: { grant_type: 'password', username: 'foo', password: 'bar' }, headers: {}, method: {}, query: {} }); return handler.handleGrantType(request, client) .then(should.fail) @@ -799,17 +799,17 @@ describe('TokenHandler integration', function() { describe('with grant_type `authorization_code`', function() { it('should return a token', function() { - var client = { id: 'foobar', grants: ['authorization_code'] }; - var token = {}; - var model = { + const client = { id: 'foobar', grants: ['authorization_code'] }; + const token = {}; + const model = { getAuthorizationCode: function() { return { authorizationCode: 12345, client: { id: 'foobar' }, expiresAt: new Date(new Date() * 2), user: {} }; }, getClient: function() {}, saveToken: function() { return token; }, validateScope: function() { return 'foo'; }, revokeAuthorizationCode: function() { return { authorizationCode: 12345, client: { id: 'foobar' }, expiresAt: new Date(new Date() / 2), user: {} }; } }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: { code: 12345, grant_type: 'authorization_code' @@ -829,16 +829,16 @@ describe('TokenHandler integration', function() { describe('with grant_type `client_credentials`', function() { it('should return a token', function() { - var client = { grants: ['client_credentials'] }; - var token = {}; - var model = { + const client = { grants: ['client_credentials'] }; + const token = {}; + const model = { getClient: function() {}, getUserFromClient: function() { return {}; }, saveToken: function() { return token; }, validateScope: function() { return 'foo'; } }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: { grant_type: 'client_credentials', scope: 'foo' @@ -858,16 +858,16 @@ describe('TokenHandler integration', function() { describe('with grant_type `password`', function() { it('should return a token', function() { - var client = { grants: ['password'] }; - var token = {}; - var model = { + const client = { grants: ['password'] }; + const token = {}; + const model = { getClient: function() {}, getUser: function() { return {}; }, saveToken: function() { return token; }, validateScope: function() { return 'baz'; } }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: { client_id: 12345, client_secret: 'secret', @@ -891,16 +891,16 @@ describe('TokenHandler integration', function() { describe('with grant_type `refresh_token`', function() { it('should return a token', function() { - var client = { grants: ['refresh_token'] }; - var token = { accessToken: 'foo', client: {}, user: {} }; - var model = { + const client = { grants: ['refresh_token'] }; + const token = { accessToken: 'foo', client: {}, user: {} }; + const model = { getClient: function() {}, getRefreshToken: function() { return { accessToken: 'foo', client: {}, refreshTokenExpiresAt: new Date(new Date() * 2), user: {} }; }, saveToken: function() { return token; }, revokeToken: function() { return { accessToken: 'foo', client: {}, refreshTokenExpiresAt: new Date(new Date() / 2), user: {} }; } }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: { grant_type: 'refresh_token', refresh_token: 12345 @@ -920,16 +920,16 @@ describe('TokenHandler integration', function() { describe('with custom grant_type', function() { it('should return a token', function() { - var client = { grants: ['urn:ietf:params:oauth:grant-type:saml2-bearer'] }; - var token = {}; - var model = { + const client = { grants: ['urn:ietf:params:oauth:grant-type:saml2-bearer'] }; + const token = {}; + const model = { getClient: function() {}, getUser: function() { return {}; }, saveToken: function() { return token; }, validateScope: function() { return 'foo'; } }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120, extendedGrantTypes: { 'urn:ietf:params:oauth:grant-type:saml2-bearer': PasswordGrantType } }); - var request = new Request({ body: { grant_type: 'urn:ietf:params:oauth:grant-type:saml2-bearer', username: 'foo', password: 'bar' }, headers: {}, method: {}, query: {} }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120, extendedGrantTypes: { 'urn:ietf:params:oauth:grant-type:saml2-bearer': PasswordGrantType } }); + const request = new Request({ body: { grant_type: 'urn:ietf:params:oauth:grant-type:saml2-bearer', username: 'foo', password: 'bar' }, headers: {}, method: {}, query: {} }); return handler.handleGrantType(request, client) .then(function(data) { @@ -942,23 +942,23 @@ describe('TokenHandler integration', function() { describe('getAccessTokenLifetime()', function() { it('should return the client access token lifetime', function() { - var client = { accessTokenLifetime: 60 }; - var model = { + const client = { accessTokenLifetime: 60 }; + const model = { getClient: function() { return client; }, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); handler.getAccessTokenLifetime(client).should.equal(60); }); it('should return the default access token lifetime', function() { - var client = {}; - var model = { + const client = {}; + const model = { getClient: function() { return client; }, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); handler.getAccessTokenLifetime(client).should.equal(120); }); @@ -966,23 +966,23 @@ describe('TokenHandler integration', function() { describe('getRefreshTokenLifetime()', function() { it('should return the client access token lifetime', function() { - var client = { refreshTokenLifetime: 60 }; - var model = { + const client = { refreshTokenLifetime: 60 }; + const model = { getClient: function() { return client; }, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); handler.getRefreshTokenLifetime(client).should.equal(60); }); it('should return the default access token lifetime', function() { - var client = {}; - var model = { + const client = {}; + const model = { getClient: function() { return client; }, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); handler.getRefreshTokenLifetime(client).should.equal(120); }); @@ -990,25 +990,25 @@ describe('TokenHandler integration', function() { describe('getTokenType()', function() { it('should return a token type', function() { - var model = { + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var tokenType = handler.getTokenType({ accessToken: 'foo', refreshToken: 'bar', scope: 'foobar' }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const tokenType = handler.getTokenType({ accessToken: 'foo', refreshToken: 'bar', scope: 'foobar' }); tokenType.should.deep.include({ accessToken: 'foo', accessTokenLifetime: undefined, refreshToken: 'bar', scope: 'foobar' }); }); }); describe('updateSuccessResponse()', function() { it('should set the `body`', function() { - var model = { + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var tokenType = new BearerTokenType('foo', 'bar', 'biz'); - var response = new Response({ body: {}, headers: {} }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const tokenType = new BearerTokenType('foo', 'bar', 'biz'); + const response = new Response({ body: {}, headers: {} }); handler.updateSuccessResponse(response, tokenType); @@ -1016,13 +1016,13 @@ describe('TokenHandler integration', function() { }); it('should set the `Cache-Control` header', function() { - var model = { + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var tokenType = new BearerTokenType('foo', 'bar', 'biz'); - var response = new Response({ body: {}, headers: {} }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const tokenType = new BearerTokenType('foo', 'bar', 'biz'); + const response = new Response({ body: {}, headers: {} }); handler.updateSuccessResponse(response, tokenType); @@ -1030,13 +1030,13 @@ describe('TokenHandler integration', function() { }); it('should set the `Pragma` header', function() { - var model = { + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var tokenType = new BearerTokenType('foo', 'bar', 'biz'); - var response = new Response({ body: {}, headers: {} }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const tokenType = new BearerTokenType('foo', 'bar', 'biz'); + const response = new Response({ body: {}, headers: {} }); handler.updateSuccessResponse(response, tokenType); @@ -1046,13 +1046,13 @@ describe('TokenHandler integration', function() { describe('updateErrorResponse()', function() { it('should set the `body`', function() { - var error = new AccessDeniedError('Cannot request a token'); - var model = { + const error = new AccessDeniedError('Cannot request a token'); + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var response = new Response({ body: {}, headers: {} }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const response = new Response({ body: {}, headers: {} }); handler.updateErrorResponse(response, error); @@ -1061,13 +1061,13 @@ describe('TokenHandler integration', function() { }); it('should set the `status`', function() { - var error = new AccessDeniedError('Cannot request a token'); - var model = { + const error = new AccessDeniedError('Cannot request a token'); + const model = { getClient: function() {}, saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var response = new Response({ body: {}, headers: {} }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const response = new Response({ body: {}, headers: {} }); handler.updateErrorResponse(response, error); diff --git a/test/integration/request_test.js b/test/integration/request_test.js index a62309d93..e0c98f131 100644 --- a/test/integration/request_test.js +++ b/test/integration/request_test.js @@ -4,9 +4,9 @@ * Module dependencies. */ -var Request = require('../../lib/request'); -var InvalidArgumentError = require('../../lib/errors/invalid-argument-error'); -var should = require('chai').should(); +const Request = require('../../lib/request'); +const InvalidArgumentError = require('../../lib/errors/invalid-argument-error'); +const should = require('chai').should(); /** * Test `Request` integration. @@ -48,25 +48,25 @@ describe('Request integration', function() { }); it('should set the `body`', function() { - var request = new Request({ body: 'foo', headers: {}, method: {}, query: {} }); + const request = new Request({ body: 'foo', headers: {}, method: {}, query: {} }); request.body.should.equal('foo'); }); it('should set the `headers`', function() { - var request = new Request({ body: {}, headers: { foo: 'bar', QuX: 'biz' }, method: {}, query: {} }); + const request = new Request({ body: {}, headers: { foo: 'bar', QuX: 'biz' }, method: {}, query: {} }); request.headers.should.eql({ foo: 'bar', qux: 'biz' }); }); it('should set the `method`', function() { - var request = new Request({ body: {}, headers: {}, method: 'biz', query: {} }); + const request = new Request({ body: {}, headers: {}, method: 'biz', query: {} }); request.method.should.equal('biz'); }); it('should set the `query`', function() { - var request = new Request({ body: {}, headers: {}, method: {}, query: 'baz' }); + const request = new Request({ body: {}, headers: {}, method: {}, query: 'baz' }); request.query.should.equal('baz'); }); @@ -74,13 +74,13 @@ describe('Request integration', function() { describe('get()', function() { it('should return `undefined` if the field does not exist', function() { - var request = new Request({ body: {}, headers: {}, method: {}, query: {} }); + const request = new Request({ body: {}, headers: {}, method: {}, query: {} }); (undefined === request.get('content-type')).should.be.true; }); it('should return the value if the field exists', function() { - var request = new Request({ + const request = new Request({ body: {}, headers: { 'content-type': 'text/html; charset=utf-8' @@ -95,7 +95,7 @@ describe('Request integration', function() { describe('is()', function() { it('should accept an array of `types`', function() { - var request = new Request({ + const request = new Request({ body: {}, headers: { 'content-type': 'application/json', @@ -109,7 +109,7 @@ describe('Request integration', function() { }); it('should accept multiple `types` as arguments', function() { - var request = new Request({ + const request = new Request({ body: {}, headers: { 'content-type': 'application/json', @@ -123,7 +123,7 @@ describe('Request integration', function() { }); it('should return the first matching type', function() { - var request = new Request({ + const request = new Request({ body: {}, headers: { 'content-type': 'text/html; charset=utf-8', @@ -137,7 +137,7 @@ describe('Request integration', function() { }); it('should return `false` if none of the `types` match', function() { - var request = new Request({ + const request = new Request({ body: {}, headers: { 'content-type': 'text/html; charset=utf-8', @@ -151,7 +151,7 @@ describe('Request integration', function() { }); it('should return `false` if the request has no body', function() { - var request = new Request({ body: {}, headers: {}, method: {}, query: {} }); + const request = new Request({ body: {}, headers: {}, method: {}, query: {} }); request.is('text/html').should.be.false; }); diff --git a/test/integration/response-types/code-response-type_test.js b/test/integration/response-types/code-response-type_test.js index e03b4a225..44bd53b0f 100644 --- a/test/integration/response-types/code-response-type_test.js +++ b/test/integration/response-types/code-response-type_test.js @@ -4,10 +4,10 @@ * Module dependencies. */ -var CodeResponseType = require('../../../lib/response-types/code-response-type'); -var InvalidArgumentError = require('../../../lib/errors/invalid-argument-error'); -var should = require('chai').should(); -var url = require('url'); +const CodeResponseType = require('../../../lib/response-types/code-response-type'); +const InvalidArgumentError = require('../../../lib/errors/invalid-argument-error'); +const should = require('chai').should(); +const url = require('url'); /** * Test `CodeResponseType` integration. @@ -27,7 +27,7 @@ describe('CodeResponseType integration', function() { }); it('should set the `code`', function() { - var responseType = new CodeResponseType('foo'); + const responseType = new CodeResponseType('foo'); responseType.code.should.equal('foo'); }); @@ -35,7 +35,7 @@ describe('CodeResponseType integration', function() { describe('buildRedirectUri()', function() { it('should throw an error if the `redirectUri` is missing', function() { - var responseType = new CodeResponseType('foo'); + const responseType = new CodeResponseType('foo'); try { responseType.buildRedirectUri(); @@ -48,15 +48,15 @@ describe('CodeResponseType integration', function() { }); it('should return the new redirect uri and set the `code` and `state` in the query', function() { - var responseType = new CodeResponseType('foo'); - var redirectUri = responseType.buildRedirectUri('http://example.com/cb'); + const responseType = new CodeResponseType('foo'); + const redirectUri = responseType.buildRedirectUri('http://example.com/cb'); url.format(redirectUri).should.equal('http://example.com/cb?code=foo'); }); it('should return the new redirect uri and append the `code` and `state` in the query', function() { - var responseType = new CodeResponseType('foo'); - var redirectUri = responseType.buildRedirectUri('http://example.com/cb?foo=bar'); + const responseType = new CodeResponseType('foo'); + const redirectUri = responseType.buildRedirectUri('http://example.com/cb?foo=bar'); url.format(redirectUri).should.equal('http://example.com/cb?foo=bar&code=foo'); }); diff --git a/test/integration/response_test.js b/test/integration/response_test.js index 1e1e0206a..d6c37e43c 100644 --- a/test/integration/response_test.js +++ b/test/integration/response_test.js @@ -4,7 +4,7 @@ * Module dependencies. */ -var Response = require('../../lib/response'); +const Response = require('../../lib/response'); /** * Test `Response` integration. @@ -13,19 +13,19 @@ var Response = require('../../lib/response'); describe('Response integration', function() { describe('constructor()', function() { it('should set the `body`', function() { - var response = new Response({ body: 'foo', headers: {} }); + const response = new Response({ body: 'foo', headers: {} }); response.body.should.equal('foo'); }); it('should set the `headers`', function() { - var response = new Response({ body: {}, headers: { foo: 'bar', QuX: 'biz' } }); + const response = new Response({ body: {}, headers: { foo: 'bar', QuX: 'biz' } }); response.headers.should.eql({ foo: 'bar', qux: 'biz' }); }); it('should set the `status` to 200', function() { - var response = new Response({ body: {}, headers: {} }); + const response = new Response({ body: {}, headers: {} }); response.status.should.equal(200); }); @@ -33,13 +33,13 @@ describe('Response integration', function() { describe('get()', function() { it('should return `undefined` if the field does not exist', function() { - var response = new Response({ body: {}, headers: {} }); + const response = new Response({ body: {}, headers: {} }); (undefined === response.get('content-type')).should.be.true; }); it('should return the value if the field exists', function() { - var response = new Response({ body: {}, headers: { 'content-type': 'text/html; charset=utf-8' } }); + const response = new Response({ body: {}, headers: { 'content-type': 'text/html; charset=utf-8' } }); response.get('Content-Type').should.equal('text/html; charset=utf-8'); }); @@ -47,7 +47,7 @@ describe('Response integration', function() { describe('redirect()', function() { it('should set the location header to `url`', function() { - var response = new Response({ body: {}, headers: {} }); + const response = new Response({ body: {}, headers: {} }); response.redirect('http://example.com'); @@ -55,7 +55,7 @@ describe('Response integration', function() { }); it('should set the `status` to 302', function() { - var response = new Response({ body: {}, headers: {} }); + const response = new Response({ body: {}, headers: {} }); response.redirect('http://example.com'); @@ -65,7 +65,7 @@ describe('Response integration', function() { describe('set()', function() { it('should set the `field`', function() { - var response = new Response({ body: {}, headers: {} }); + const response = new Response({ body: {}, headers: {} }); response.set('foo', 'bar'); diff --git a/test/integration/server_test.js b/test/integration/server_test.js index 1851e21e3..db1054441 100644 --- a/test/integration/server_test.js +++ b/test/integration/server_test.js @@ -4,12 +4,12 @@ * Module dependencies. */ -var InvalidArgumentError = require('../../lib/errors/invalid-argument-error'); -var Promise = require('bluebird'); -var Request = require('../../lib/request'); -var Response = require('../../lib/response'); -var Server = require('../../lib/server'); -var should = require('chai').should(); +const InvalidArgumentError = require('../../lib/errors/invalid-argument-error'); +const Promise = require('bluebird'); +const Request = require('../../lib/request'); +const Response = require('../../lib/response'); +const Server = require('../../lib/server'); +const should = require('chai').should(); /** * Test `Server` integration. @@ -29,8 +29,8 @@ describe('Server integration', function() { }); it('should set the `model`', function() { - var model = {}; - var server = new Server({ model: model }); + const model = {}; + const server = new Server({ model: model }); server.options.model.should.equal(model); }); @@ -38,7 +38,7 @@ describe('Server integration', function() { describe('authenticate()', function() { it('should set the default `options`', function() { - var model = { + const model = { getAccessToken: function() { return { user: {}, @@ -46,9 +46,9 @@ describe('Server integration', function() { }; } }; - var server = new Server({ model: model }); - var request = new Request({ body: {}, headers: { 'Authorization': 'Bearer foo' }, method: {}, query: {} }); - var response = new Response({ body: {}, headers: {} }); + const server = new Server({ model: model }); + const request = new Request({ body: {}, headers: { 'Authorization': 'Bearer foo' }, method: {}, query: {} }); + const response = new Response({ body: {}, headers: {} }); return server.authenticate(request, response) .then(function() { @@ -60,7 +60,7 @@ describe('Server integration', function() { }); it('should return a promise', function() { - var model = { + const model = { getAccessToken: function(token, callback) { callback(null, { user: {}, @@ -68,16 +68,16 @@ describe('Server integration', function() { }); } }; - var server = new Server({ model: model }); - var request = new Request({ body: {}, headers: { 'Authorization': 'Bearer foo' }, method: {}, query: {} }); - var response = new Response({ body: {}, headers: {} }); - var handler = server.authenticate(request, response); + const server = new Server({ model: model }); + const request = new Request({ body: {}, headers: { 'Authorization': 'Bearer foo' }, method: {}, query: {} }); + const response = new Response({ body: {}, headers: {} }); + const handler = server.authenticate(request, response); handler.should.be.an.instanceOf(Promise); }); it('should support callbacks', function(next) { - var model = { + const model = { getAccessToken: function() { return { user: {}, @@ -85,9 +85,9 @@ describe('Server integration', function() { }; } }; - var server = new Server({ model: model }); - var request = new Request({ body: {}, headers: { 'Authorization': 'Bearer foo' }, method: {}, query: {} }); - var response = new Response({ body: {}, headers: {} }); + const server = new Server({ model: model }); + const request = new Request({ body: {}, headers: { 'Authorization': 'Bearer foo' }, method: {}, query: {} }); + const response = new Response({ body: {}, headers: {} }); server.authenticate(request, response, null, next); }); @@ -95,7 +95,7 @@ describe('Server integration', function() { describe('authorize()', function() { it('should set the default `options`', function() { - var model = { + const model = { getAccessToken: function() { return { user: {}, @@ -109,9 +109,9 @@ describe('Server integration', function() { return { authorizationCode: 123 }; } }; - var server = new Server({ model: model }); - var request = new Request({ body: { client_id: 1234, client_secret: 'secret', response_type: 'code' }, headers: { 'Authorization': 'Bearer foo' }, method: {}, query: { state: 'foobar' } }); - var response = new Response({ body: {}, headers: {} }); + const server = new Server({ model: model }); + const request = new Request({ body: { client_id: 1234, client_secret: 'secret', response_type: 'code' }, headers: { 'Authorization': 'Bearer foo' }, method: {}, query: { state: 'foobar' } }); + const response = new Response({ body: {}, headers: {} }); return server.authorize(request, response) .then(function() { @@ -122,7 +122,7 @@ describe('Server integration', function() { }); it('should return a promise', function() { - var model = { + const model = { getAccessToken: function() { return { user: {}, @@ -136,16 +136,16 @@ describe('Server integration', function() { return { authorizationCode: 123 }; } }; - var server = new Server({ model: model }); - var request = new Request({ body: { client_id: 1234, client_secret: 'secret', response_type: 'code' }, headers: { 'Authorization': 'Bearer foo' }, method: {}, query: { state: 'foobar' } }); - var response = new Response({ body: {}, headers: {} }); - var handler = server.authorize(request, response); + const server = new Server({ model: model }); + const request = new Request({ body: { client_id: 1234, client_secret: 'secret', response_type: 'code' }, headers: { 'Authorization': 'Bearer foo' }, method: {}, query: { state: 'foobar' } }); + const response = new Response({ body: {}, headers: {} }); + const handler = server.authorize(request, response); handler.should.be.an.instanceOf(Promise); }); it('should support callbacks', function(next) { - var model = { + const model = { getAccessToken: function() { return { user: {}, @@ -159,9 +159,9 @@ describe('Server integration', function() { return { authorizationCode: 123 }; } }; - var server = new Server({ model: model }); - var request = new Request({ body: { client_id: 1234, client_secret: 'secret', response_type: 'code' }, headers: { 'Authorization': 'Bearer foo' }, method: {}, query: { state: 'foobar' } }); - var response = new Response({ body: {}, headers: {} }); + const server = new Server({ model: model }); + const request = new Request({ body: { client_id: 1234, client_secret: 'secret', response_type: 'code' }, headers: { 'Authorization': 'Bearer foo' }, method: {}, query: { state: 'foobar' } }); + const response = new Response({ body: {}, headers: {} }); server.authorize(request, response, null, next); }); @@ -169,7 +169,7 @@ describe('Server integration', function() { describe('token()', function() { it('should set the default `options`', function() { - var model = { + const model = { getClient: function() { return { grants: ['password'] }; }, @@ -181,9 +181,9 @@ describe('Server integration', function() { }, validateScope: function() { return 'foo'; } }; - var server = new Server({ model: model }); - var request = new Request({ body: { client_id: 1234, client_secret: 'secret', grant_type: 'password', username: 'foo', password: 'pass', scope: 'foo' }, headers: { 'content-type': 'application/x-www-form-urlencoded', 'transfer-encoding': 'chunked' }, method: 'POST', query: {} }); - var response = new Response({ body: {}, headers: {} }); + const server = new Server({ model: model }); + const request = new Request({ body: { client_id: 1234, client_secret: 'secret', grant_type: 'password', username: 'foo', password: 'pass', scope: 'foo' }, headers: { 'content-type': 'application/x-www-form-urlencoded', 'transfer-encoding': 'chunked' }, method: 'POST', query: {} }); + const response = new Response({ body: {}, headers: {} }); return server.token(request, response) .then(function() { @@ -194,7 +194,7 @@ describe('Server integration', function() { }); it('should return a promise', function() { - var model = { + const model = { getClient: function() { return { grants: ['password'] }; }, @@ -205,16 +205,16 @@ describe('Server integration', function() { return { accessToken: 1234, client: {}, user: {} }; } }; - var server = new Server({ model: model }); - var request = new Request({ body: { client_id: 1234, client_secret: 'secret', grant_type: 'password', username: 'foo', password: 'pass' }, headers: { 'content-type': 'application/x-www-form-urlencoded', 'transfer-encoding': 'chunked' }, method: 'POST', query: {} }); - var response = new Response({ body: {}, headers: {} }); - var handler = server.token(request, response); + const server = new Server({ model: model }); + const request = new Request({ body: { client_id: 1234, client_secret: 'secret', grant_type: 'password', username: 'foo', password: 'pass' }, headers: { 'content-type': 'application/x-www-form-urlencoded', 'transfer-encoding': 'chunked' }, method: 'POST', query: {} }); + const response = new Response({ body: {}, headers: {} }); + const handler = server.token(request, response); handler.should.be.an.instanceOf(Promise); }); it('should support callbacks', function(next) { - var model = { + const model = { getClient: function() { return { grants: ['password'] }; }, @@ -228,9 +228,9 @@ describe('Server integration', function() { return 'foo'; } }; - var server = new Server({ model: model }); - var request = new Request({ body: { client_id: 1234, client_secret: 'secret', grant_type: 'password', username: 'foo', password: 'pass', scope: 'foo' }, headers: { 'content-type': 'application/x-www-form-urlencoded', 'transfer-encoding': 'chunked' }, method: 'POST', query: {} }); - var response = new Response({ body: {}, headers: {} }); + const server = new Server({ model: model }); + const request = new Request({ body: { client_id: 1234, client_secret: 'secret', grant_type: 'password', username: 'foo', password: 'pass', scope: 'foo' }, headers: { 'content-type': 'application/x-www-form-urlencoded', 'transfer-encoding': 'chunked' }, method: 'POST', query: {} }); + const response = new Response({ body: {}, headers: {} }); server.token(request, response, null, next); }); diff --git a/test/integration/token-types/bearer-token-type_test.js b/test/integration/token-types/bearer-token-type_test.js index c8ad306db..47b1daa6b 100644 --- a/test/integration/token-types/bearer-token-type_test.js +++ b/test/integration/token-types/bearer-token-type_test.js @@ -4,9 +4,9 @@ * Module dependencies. */ -var BearerTokenType = require('../../../lib/token-types/bearer-token-type'); -var InvalidArgumentError = require('../../../lib/errors/invalid-argument-error'); -var should = require('chai').should(); +const BearerTokenType = require('../../../lib/token-types/bearer-token-type'); +const InvalidArgumentError = require('../../../lib/errors/invalid-argument-error'); +const should = require('chai').should(); /** * Test `BearerTokenType` integration. @@ -26,19 +26,19 @@ describe('BearerTokenType integration', function() { }); it('should set the `accessToken`', function() { - var responseType = new BearerTokenType('foo', 'bar'); + const responseType = new BearerTokenType('foo', 'bar'); responseType.accessToken.should.equal('foo'); }); it('should set the `accessTokenLifetime`', function() { - var responseType = new BearerTokenType('foo', 'bar'); + const responseType = new BearerTokenType('foo', 'bar'); responseType.accessTokenLifetime.should.equal('bar'); }); it('should set the `refreshToken`', function() { - var responseType = new BearerTokenType('foo', 'bar', 'biz'); + const responseType = new BearerTokenType('foo', 'bar', 'biz'); responseType.refreshToken.should.equal('biz'); }); @@ -46,8 +46,8 @@ describe('BearerTokenType integration', function() { describe('valueOf()', function() { it('should return the value representation', function() { - var responseType = new BearerTokenType('foo', 'bar'); - var value = responseType.valueOf(); + const responseType = new BearerTokenType('foo', 'bar'); + const value = responseType.valueOf(); value.should.eql({ access_token: 'foo', @@ -57,8 +57,8 @@ describe('BearerTokenType integration', function() { }); it('should not include the `expires_in` if not given', function() { - var responseType = new BearerTokenType('foo'); - var value = responseType.valueOf(); + const responseType = new BearerTokenType('foo'); + const value = responseType.valueOf(); value.should.eql({ access_token: 'foo', @@ -67,8 +67,8 @@ describe('BearerTokenType integration', function() { }); it('should set `refresh_token` if `refreshToken` is defined', function() { - var responseType = new BearerTokenType('foo', 'bar', 'biz'); - var value = responseType.valueOf(); + const responseType = new BearerTokenType('foo', 'bar', 'biz'); + const value = responseType.valueOf(); value.should.eql({ access_token: 'foo', @@ -79,8 +79,8 @@ describe('BearerTokenType integration', function() { }); it('should set `expires_in` if `accessTokenLifetime` is defined', function() { - var responseType = new BearerTokenType('foo', 'bar', 'biz'); - var value = responseType.valueOf(); + const responseType = new BearerTokenType('foo', 'bar', 'biz'); + const value = responseType.valueOf(); value.should.eql({ access_token: 'foo', diff --git a/test/integration/utils/token-util_test.js b/test/integration/utils/token-util_test.js index b6aa650f2..d4f368eaa 100644 --- a/test/integration/utils/token-util_test.js +++ b/test/integration/utils/token-util_test.js @@ -4,8 +4,8 @@ * Module dependencies. */ -var TokenUtil = require('../../../lib/utils/token-util'); -var should = require('chai').should(); +const TokenUtil = require('../../../lib/utils/token-util'); +const should = require('chai').should(); /** * Test `TokenUtil` integration. diff --git a/test/unit/grant-types/abstract-grant-type_test.js b/test/unit/grant-types/abstract-grant-type_test.js index d2ccf72ac..f6cb13a43 100644 --- a/test/unit/grant-types/abstract-grant-type_test.js +++ b/test/unit/grant-types/abstract-grant-type_test.js @@ -4,9 +4,9 @@ * Module dependencies. */ -var AbstractGrantType = require('../../../lib/grant-types/abstract-grant-type'); -var sinon = require('sinon'); -var should = require('chai').should(); +const AbstractGrantType = require('../../../lib/grant-types/abstract-grant-type'); +const sinon = require('sinon'); +const should = require('chai').should(); /** * Test `AbstractGrantType`. @@ -15,10 +15,10 @@ var should = require('chai').should(); describe('AbstractGrantType', function() { describe('generateAccessToken()', function() { it('should call `model.generateAccessToken()`', function() { - var model = { + const model = { generateAccessToken: sinon.stub().returns({ client: {}, expiresAt: new Date(), user: {} }) }; - var handler = new AbstractGrantType({ accessTokenLifetime: 120, model: model }); + const handler = new AbstractGrantType({ accessTokenLifetime: 120, model: model }); return handler.generateAccessToken() .then(function() { @@ -31,10 +31,10 @@ describe('AbstractGrantType', function() { describe('generateRefreshToken()', function() { it('should call `model.generateRefreshToken()`', function() { - var model = { + const model = { generateRefreshToken: sinon.stub().returns({ client: {}, expiresAt: new Date(new Date() / 2), user: {} }) }; - var handler = new AbstractGrantType({ accessTokenLifetime: 120, model: model }); + const handler = new AbstractGrantType({ accessTokenLifetime: 120, model: model }); return handler.generateRefreshToken() .then(function() { diff --git a/test/unit/grant-types/authorization-code-grant-type_test.js b/test/unit/grant-types/authorization-code-grant-type_test.js index a9220cb3b..83cc85437 100644 --- a/test/unit/grant-types/authorization-code-grant-type_test.js +++ b/test/unit/grant-types/authorization-code-grant-type_test.js @@ -4,11 +4,11 @@ * Module dependencies. */ -var AuthorizationCodeGrantType = require('../../../lib/grant-types/authorization-code-grant-type'); -var Promise = require('bluebird'); -var Request = require('../../../lib/request'); -var sinon = require('sinon'); -var should = require('chai').should(); +const AuthorizationCodeGrantType = require('../../../lib/grant-types/authorization-code-grant-type'); +const Promise = require('bluebird'); +const Request = require('../../../lib/request'); +const sinon = require('sinon'); +const should = require('chai').should(); /** * Test `AuthorizationCodeGrantType`. @@ -17,14 +17,14 @@ var should = require('chai').should(); describe('AuthorizationCodeGrantType', function() { describe('getAuthorizationCode()', function() { it('should call `model.getAuthorizationCode()`', function() { - var model = { + const model = { getAuthorizationCode: sinon.stub().returns({ authorizationCode: 12345, client: {}, expiresAt: new Date(new Date() * 2), user: {} }), revokeAuthorizationCode: function() {}, saveToken: function() {} }; - var handler = new AuthorizationCodeGrantType({ accessTokenLifetime: 120, model: model }); - var request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); - var client = {}; + const handler = new AuthorizationCodeGrantType({ accessTokenLifetime: 120, model: model }); + const request = new Request({ body: { code: 12345 }, headers: {}, method: {}, query: {} }); + const client = {}; return handler.getAuthorizationCode(request, client) .then(function() { @@ -39,13 +39,13 @@ describe('AuthorizationCodeGrantType', function() { describe('revokeAuthorizationCode()', function() { it('should call `model.revokeAuthorizationCode()`', function() { - var model = { + const model = { getAuthorizationCode: function() {}, revokeAuthorizationCode: sinon.stub().returns(true), saveToken: function() {} }; - var handler = new AuthorizationCodeGrantType({ accessTokenLifetime: 120, model: model }); - var authorizationCode = {}; + const handler = new AuthorizationCodeGrantType({ accessTokenLifetime: 120, model: model }); + const authorizationCode = {}; return handler.revokeAuthorizationCode(authorizationCode) .then(function() { @@ -60,14 +60,14 @@ describe('AuthorizationCodeGrantType', function() { describe('saveToken()', function() { it('should call `model.saveToken()`', function() { - var client = {}; - var user = {}; - var model = { + const client = {}; + const user = {}; + const model = { getAuthorizationCode: function() {}, revokeAuthorizationCode: function() {}, saveToken: sinon.stub().returns(true) }; - var handler = new AuthorizationCodeGrantType({ accessTokenLifetime: 120, model: model }); + const handler = new AuthorizationCodeGrantType({ accessTokenLifetime: 120, model: model }); sinon.stub(handler, 'validateScope').returns('foobiz'); sinon.stub(handler, 'generateAccessToken').returns(Promise.resolve('foo')); diff --git a/test/unit/grant-types/client-credentials-grant-type_test.js b/test/unit/grant-types/client-credentials-grant-type_test.js index 4b1c8b6b1..3997823b0 100644 --- a/test/unit/grant-types/client-credentials-grant-type_test.js +++ b/test/unit/grant-types/client-credentials-grant-type_test.js @@ -4,9 +4,9 @@ * Module dependencies. */ -var ClientCredentialsGrantType = require('../../../lib/grant-types/client-credentials-grant-type'); -var sinon = require('sinon'); -var should = require('chai').should(); +const ClientCredentialsGrantType = require('../../../lib/grant-types/client-credentials-grant-type'); +const sinon = require('sinon'); +const should = require('chai').should(); /** * Test `ClientCredentialsGrantType`. @@ -15,12 +15,12 @@ var should = require('chai').should(); describe('ClientCredentialsGrantType', function() { describe('getUserFromClient()', function() { it('should call `model.getUserFromClient()`', function() { - var model = { + const model = { getUserFromClient: sinon.stub().returns(true), saveToken: function() {} }; - var handler = new ClientCredentialsGrantType({ accessTokenLifetime: 120, model: model }); - var client = {}; + const handler = new ClientCredentialsGrantType({ accessTokenLifetime: 120, model: model }); + const client = {}; return handler.getUserFromClient(client) .then(function() { @@ -35,13 +35,13 @@ describe('ClientCredentialsGrantType', function() { describe('saveToken()', function() { it('should call `model.saveToken()`', function() { - var client = {}; - var user = {}; - var model = { + const client = {}; + const user = {}; + const model = { getUserFromClient: function() {}, saveToken: sinon.stub().returns(true) }; - var handler = new ClientCredentialsGrantType({ accessTokenLifetime: 120, model: model }); + const handler = new ClientCredentialsGrantType({ accessTokenLifetime: 120, model: model }); sinon.stub(handler, 'validateScope').returns('foobar'); sinon.stub(handler, 'generateAccessToken').returns('foo'); diff --git a/test/unit/grant-types/password-grant-type_test.js b/test/unit/grant-types/password-grant-type_test.js index c99c2ef53..ceb2ad9d1 100644 --- a/test/unit/grant-types/password-grant-type_test.js +++ b/test/unit/grant-types/password-grant-type_test.js @@ -4,10 +4,10 @@ * Module dependencies. */ -var PasswordGrantType = require('../../../lib/grant-types/password-grant-type'); -var Request = require('../../../lib/request'); -var sinon = require('sinon'); -var should = require('chai').should(); +const PasswordGrantType = require('../../../lib/grant-types/password-grant-type'); +const Request = require('../../../lib/request'); +const sinon = require('sinon'); +const should = require('chai').should(); /** * Test `PasswordGrantType`. @@ -16,12 +16,12 @@ var should = require('chai').should(); describe('PasswordGrantType', function() { describe('getUser()', function() { it('should call `model.getUser()`', function() { - var model = { + const model = { getUser: sinon.stub().returns(true), saveToken: function() {} }; - var handler = new PasswordGrantType({ accessTokenLifetime: 120, model: model }); - var request = new Request({ body: { username: 'foo', password: 'bar' }, headers: {}, method: {}, query: {} }); + const handler = new PasswordGrantType({ accessTokenLifetime: 120, model: model }); + const request = new Request({ body: { username: 'foo', password: 'bar' }, headers: {}, method: {}, query: {} }); return handler.getUser(request) .then(function() { @@ -37,13 +37,13 @@ describe('PasswordGrantType', function() { describe('saveToken()', function() { it('should call `model.saveToken()`', function() { - var client = {}; - var user = {}; - var model = { + const client = {}; + const user = {}; + const model = { getUser: function() {}, saveToken: sinon.stub().returns(true) }; - var handler = new PasswordGrantType({ accessTokenLifetime: 120, model: model }); + const handler = new PasswordGrantType({ accessTokenLifetime: 120, model: model }); sinon.stub(handler, 'validateScope').returns('foobar'); sinon.stub(handler, 'generateAccessToken').returns('foo'); diff --git a/test/unit/grant-types/refresh-token-grant-type_test.js b/test/unit/grant-types/refresh-token-grant-type_test.js index 5775f43f1..c91a37ed2 100644 --- a/test/unit/grant-types/refresh-token-grant-type_test.js +++ b/test/unit/grant-types/refresh-token-grant-type_test.js @@ -4,10 +4,10 @@ * Module dependencies. */ -var RefreshTokenGrantType = require('../../../lib/grant-types/refresh-token-grant-type'); -var Request = require('../../../lib/request'); -var sinon = require('sinon'); -var should = require('chai').should(); +const RefreshTokenGrantType = require('../../../lib/grant-types/refresh-token-grant-type'); +const Request = require('../../../lib/request'); +const sinon = require('sinon'); +const should = require('chai').should(); /** * Test `RefreshTokenGrantType`. @@ -16,15 +16,15 @@ var should = require('chai').should(); describe('RefreshTokenGrantType', function() { describe('handle()', function() { it('should revoke the previous token', function() { - var token = { accessToken: 'foo', client: {}, user: {} }; - var model = { + const token = { accessToken: 'foo', client: {}, user: {} }; + const model = { getRefreshToken: function() { return token; }, saveToken: function() { return { accessToken: 'bar', client: {}, user: {} }; }, revokeToken: sinon.stub().returns({ accessToken: 'foo', client: {}, refreshTokenExpiresAt: new Date(new Date() / 2), user: {} }) }; - var handler = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); - var request = new Request({ body: { refresh_token: 'bar' }, headers: {}, method: {}, query: {} }); - var client = {}; + const handler = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); + const request = new Request({ body: { refresh_token: 'bar' }, headers: {}, method: {}, query: {} }); + const client = {}; return handler.handle(request, client) .then(function() { @@ -39,14 +39,14 @@ describe('RefreshTokenGrantType', function() { describe('getRefreshToken()', function() { it('should call `model.getRefreshToken()`', function() { - var model = { + const model = { getRefreshToken: sinon.stub().returns({ accessToken: 'foo', client: {}, user: {} }), saveToken: function() {}, revokeToken: function() {} }; - var handler = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); - var request = new Request({ body: { refresh_token: 'bar' }, headers: {}, method: {}, query: {} }); - var client = {}; + const handler = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); + const request = new Request({ body: { refresh_token: 'bar' }, headers: {}, method: {}, query: {} }); + const client = {}; return handler.getRefreshToken(request, client) .then(function() { @@ -61,13 +61,13 @@ describe('RefreshTokenGrantType', function() { describe('revokeToken()', function() { it('should call `model.revokeToken()`', function() { - var model = { + const model = { getRefreshToken: function() {}, revokeToken: sinon.stub().returns({ accessToken: 'foo', client: {}, refreshTokenExpiresAt: new Date(new Date() / 2), user: {} }), saveToken: function() {} }; - var handler = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); - var token = {}; + const handler = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); + const token = {}; return handler.revokeToken(token) .then(function() { @@ -80,13 +80,13 @@ describe('RefreshTokenGrantType', function() { }); it('should not call `model.revokeToken()`', function() { - var model = { + const model = { getRefreshToken: function() {}, revokeToken: sinon.stub().returns({ accessToken: 'foo', client: {}, refreshTokenExpiresAt: new Date(new Date() / 2), user: {} }), saveToken: function() {} }; - var handler = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model, alwaysIssueNewRefreshToken: false }); - var token = {}; + const handler = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model, alwaysIssueNewRefreshToken: false }); + const token = {}; return handler.revokeToken(token) .then(function() { @@ -96,13 +96,13 @@ describe('RefreshTokenGrantType', function() { }); it('should not call `model.revokeToken()`', function() { - var model = { + const model = { getRefreshToken: function() {}, revokeToken: sinon.stub().returns({ accessToken: 'foo', client: {}, refreshTokenExpiresAt: new Date(new Date() / 2), user: {} }), saveToken: function() {} }; - var handler = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model, alwaysIssueNewRefreshToken: true }); - var token = {}; + const handler = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model, alwaysIssueNewRefreshToken: true }); + const token = {}; return handler.revokeToken(token) .then(function() { @@ -117,14 +117,14 @@ describe('RefreshTokenGrantType', function() { describe('saveToken()', function() { it('should call `model.saveToken()`', function() { - var client = {}; - var user = {}; - var model = { + const client = {}; + const user = {}; + const model = { getRefreshToken: function() {}, revokeToken: function() {}, saveToken: sinon.stub().returns(true) }; - var handler = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); + const handler = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model }); sinon.stub(handler, 'generateAccessToken').returns('foo'); sinon.stub(handler, 'generateRefreshToken').returns('bar'); @@ -144,14 +144,14 @@ describe('RefreshTokenGrantType', function() { }); it('should call `model.saveToken()` without refresh token', function() { - var client = {}; - var user = {}; - var model = { + const client = {}; + const user = {}; + const model = { getRefreshToken: function() {}, revokeToken: function() {}, saveToken: sinon.stub().returns(true) }; - var handler = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model, alwaysIssueNewRefreshToken: false }); + const handler = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model, alwaysIssueNewRefreshToken: false }); sinon.stub(handler, 'generateAccessToken').returns('foo'); sinon.stub(handler, 'generateRefreshToken').returns('bar'); @@ -171,14 +171,14 @@ describe('RefreshTokenGrantType', function() { }); it('should call `model.saveToken()` with refresh token', function() { - var client = {}; - var user = {}; - var model = { + const client = {}; + const user = {}; + const model = { getRefreshToken: function() {}, revokeToken: function() {}, saveToken: sinon.stub().returns(true) }; - var handler = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model, alwaysIssueNewRefreshToken: true}); + const handler = new RefreshTokenGrantType({ accessTokenLifetime: 120, model: model, alwaysIssueNewRefreshToken: true}); sinon.stub(handler, 'generateAccessToken').returns('foo'); sinon.stub(handler, 'generateRefreshToken').returns('bar'); diff --git a/test/unit/handlers/authenticate-handler_test.js b/test/unit/handlers/authenticate-handler_test.js index c2800028b..4d634288d 100644 --- a/test/unit/handlers/authenticate-handler_test.js +++ b/test/unit/handlers/authenticate-handler_test.js @@ -4,11 +4,11 @@ * Module dependencies. */ -var AuthenticateHandler = require('../../../lib/handlers/authenticate-handler'); -var Request = require('../../../lib/request'); -var sinon = require('sinon'); -var should = require('chai').should(); -var ServerError = require('../../../lib/errors/server-error'); +const AuthenticateHandler = require('../../../lib/handlers/authenticate-handler'); +const Request = require('../../../lib/request'); +const sinon = require('sinon'); +const should = require('chai').should(); +const ServerError = require('../../../lib/errors/server-error'); /** * Test `AuthenticateHandler`. @@ -18,8 +18,8 @@ describe('AuthenticateHandler', function() { describe('getTokenFromRequest()', function() { describe('with bearer token in the request authorization header', function() { it('should call `getTokenFromRequestHeader()`', function() { - var handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); - var request = new Request({ + const handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); + const request = new Request({ body: {}, headers: { 'Authorization': 'Bearer foo' }, method: {}, @@ -38,8 +38,8 @@ describe('AuthenticateHandler', function() { describe('with bearer token in the request query', function() { it('should call `getTokenFromRequestQuery()`', function() { - var handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); - var request = new Request({ + const handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); + const request = new Request({ body: {}, headers: {}, method: {}, @@ -58,8 +58,8 @@ describe('AuthenticateHandler', function() { describe('with bearer token in the request body', function() { it('should call `getTokenFromRequestBody()`', function() { - var handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); - var request = new Request({ + const handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); + const request = new Request({ body: { access_token: 'foo' }, headers: {}, method: {}, @@ -79,10 +79,10 @@ describe('AuthenticateHandler', function() { describe('getAccessToken()', function() { it('should call `model.getAccessToken()`', function() { - var model = { + const model = { getAccessToken: sinon.stub().returns({ user: {} }) }; - var handler = new AuthenticateHandler({ model: model }); + const handler = new AuthenticateHandler({ model: model }); return handler.getAccessToken('foo') .then(function() { @@ -97,12 +97,12 @@ describe('AuthenticateHandler', function() { describe('validateAccessToken()', function() { it('should fail if token has no valid `accessTokenExpiresAt` date', function() { - var model = { + const model = { getAccessToken: function() {} }; - var handler = new AuthenticateHandler({ model: model }); + const handler = new AuthenticateHandler({ model: model }); - var failed = false; + let failed = false; try { handler.validateAccessToken({ user: {} @@ -116,10 +116,10 @@ describe('AuthenticateHandler', function() { }); it('should succeed if token has valid `accessTokenExpiresAt` date', function() { - var model = { + const model = { getAccessToken: function() {} }; - var handler = new AuthenticateHandler({ model: model }); + const handler = new AuthenticateHandler({ model: model }); try { handler.validateAccessToken({ user: {}, @@ -134,11 +134,11 @@ describe('AuthenticateHandler', function() { describe('verifyScope()', function() { it('should call `model.getAccessToken()` if scope is defined', function() { - var model = { + const model = { getAccessToken: function() {}, verifyScope: sinon.stub().returns(true) }; - var handler = new AuthenticateHandler({ addAcceptedScopesHeader: true, addAuthorizedScopesHeader: true, model: model, scope: 'bar' }); + const handler = new AuthenticateHandler({ addAcceptedScopesHeader: true, addAuthorizedScopesHeader: true, model: model, scope: 'bar' }); return handler.verifyScope('foo') .then(function() { diff --git a/test/unit/handlers/authorize-handler_test.js b/test/unit/handlers/authorize-handler_test.js index 35ece25fa..86ce336a7 100644 --- a/test/unit/handlers/authorize-handler_test.js +++ b/test/unit/handlers/authorize-handler_test.js @@ -4,12 +4,12 @@ * Module dependencies. */ -var AuthorizeHandler = require('../../../lib/handlers/authorize-handler'); -var Request = require('../../../lib/request'); -var Response = require('../../../lib/response'); -var Promise = require('bluebird'); -var sinon = require('sinon'); -var should = require('chai').should(); +const AuthorizeHandler = require('../../../lib/handlers/authorize-handler'); +const Request = require('../../../lib/request'); +const Response = require('../../../lib/response'); +const Promise = require('bluebird'); +const sinon = require('sinon'); +const should = require('chai').should(); /** * Test `AuthorizeHandler`. @@ -18,13 +18,13 @@ var should = require('chai').should(); describe('AuthorizeHandler', function() { describe('generateAuthorizationCode()', function() { it('should call `model.generateAuthorizationCode()`', function() { - var model = { + const model = { generateAuthorizationCode: sinon.stub().returns({}), getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); return handler.generateAuthorizationCode() .then(function() { @@ -37,13 +37,13 @@ describe('AuthorizeHandler', function() { describe('getClient()', function() { it('should call `model.getClient()`', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: sinon.stub().returns({ grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] }), saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - var request = new Request({ body: { client_id: 12345, client_secret: 'secret' }, headers: {}, method: {}, query: {} }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { client_id: 12345, client_secret: 'secret' }, headers: {}, method: {}, query: {} }); return handler.getClient(request) .then(function() { @@ -58,14 +58,14 @@ describe('AuthorizeHandler', function() { describe('getUser()', function() { it('should call `authenticateHandler.getUser()`', function() { - var authenticateHandler = { handle: sinon.stub().returns(Promise.resolve({})) }; - var model = { + const authenticateHandler = { handle: sinon.stub().returns(Promise.resolve({})) }; + const model = { getClient: function() {}, saveAuthorizationCode: function() {} }; - var handler = new AuthorizeHandler({ authenticateHandler: authenticateHandler, authorizationCodeLifetime: 120, model: model }); - var request = new Request({ body: {}, headers: {}, method: {}, query: {} }); - var response = new Response(); + const handler = new AuthorizeHandler({ authenticateHandler: authenticateHandler, authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: {}, headers: {}, method: {}, query: {} }); + const response = new Response(); return handler.getUser(request, response) .then(function() { @@ -80,12 +80,12 @@ describe('AuthorizeHandler', function() { describe('saveAuthorizationCode()', function() { it('should call `model.saveAuthorizationCode()`', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: sinon.stub().returns({}) }; - var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); return handler.saveAuthorizationCode('foo', 'bar', 'qux', 'biz', 'baz', 'boz') .then(function() { diff --git a/test/unit/handlers/token-handler_test.js b/test/unit/handlers/token-handler_test.js index 4dd219970..8fe258b9d 100644 --- a/test/unit/handlers/token-handler_test.js +++ b/test/unit/handlers/token-handler_test.js @@ -4,10 +4,10 @@ * Module dependencies. */ -var Request = require('../../../lib/request'); -var TokenHandler = require('../../../lib/handlers/token-handler'); -var sinon = require('sinon'); -var should = require('chai').should(); +const Request = require('../../../lib/request'); +const TokenHandler = require('../../../lib/handlers/token-handler'); +const sinon = require('sinon'); +const should = require('chai').should(); /** * Test `TokenHandler`. @@ -16,12 +16,12 @@ var should = require('chai').should(); describe('TokenHandler', function() { describe('getClient()', function() { it('should call `model.getClient()`', function() { - var model = { + const model = { getClient: sinon.stub().returns({ grants: ['password'] }), saveToken: function() {} }; - var handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); - var request = new Request({ body: { client_id: 12345, client_secret: 'secret' }, headers: {}, method: {}, query: {} }); + const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 }); + const request = new Request({ body: { client_id: 12345, client_secret: 'secret' }, headers: {}, method: {}, query: {} }); return handler.getClient(request) .then(function() { diff --git a/test/unit/models/token-model_test.js b/test/unit/models/token-model_test.js index 6fa011090..7dcac615b 100644 --- a/test/unit/models/token-model_test.js +++ b/test/unit/models/token-model_test.js @@ -1,5 +1,5 @@ -var TokenModel = require('../../../lib/models/token-model'); -var should = require('chai').should(); +const TokenModel = require('../../../lib/models/token-model'); +const should = require('chai').should(); /** * Test `Server`. */ @@ -7,17 +7,17 @@ var should = require('chai').should(); describe('Model', function() { describe('constructor()', function() { it('should calculate `accessTokenLifetime` if `accessTokenExpiresAt` is set', function() { - var atExpiresAt = new Date(); + const atExpiresAt = new Date(); atExpiresAt.setHours(new Date().getHours() + 1); - var data = { + const data = { accessToken: 'foo', client: 'bar', user: 'tar', accessTokenExpiresAt: atExpiresAt }; - var model = new TokenModel(data); + const model = new TokenModel(data); should.exist(model.accessTokenLifetime); model.accessTokenLifetime.should.a('number'); model.accessTokenLifetime.should.be.approximately(3600, 2); diff --git a/test/unit/request_test.js b/test/unit/request_test.js index a86005a9c..f292e2b4a 100644 --- a/test/unit/request_test.js +++ b/test/unit/request_test.js @@ -4,8 +4,8 @@ * Module dependencies. */ -var Request = require('../../lib/request'); -var should = require('chai').should(); +const Request = require('../../lib/request'); +const should = require('chai').should(); /** * Test `Request`. @@ -28,9 +28,9 @@ function generateBaseRequest() { describe('Request', function() { it('should instantiate with a basic request', function() { - var originalRequest = generateBaseRequest(); + const originalRequest = generateBaseRequest(); - var request = new Request(originalRequest); + const request = new Request(originalRequest); request.headers.should.eql(originalRequest.headers); request.method.should.eql(originalRequest.method); request.query.should.eql(originalRequest.query); @@ -38,10 +38,10 @@ describe('Request', function() { }); it('should allow a request to be passed without a body', function() { - var originalRequest = generateBaseRequest(); + const originalRequest = generateBaseRequest(); delete originalRequest.body; - var request = new Request(originalRequest); + const request = new Request(originalRequest); request.headers.should.eql(originalRequest.headers); request.method.should.eql(originalRequest.method); request.query.should.eql(originalRequest.query); @@ -49,7 +49,7 @@ describe('Request', function() { }); it('should throw if headers are not passed to the constructor', function() { - var originalRequest = generateBaseRequest(); + const originalRequest = generateBaseRequest(); delete originalRequest.headers; (function() { @@ -58,7 +58,7 @@ describe('Request', function() { }); it('should throw if query string isn\'t passed to the constructor', function() { - var originalRequest = generateBaseRequest(); + const originalRequest = generateBaseRequest(); delete originalRequest.query; (function() { @@ -67,7 +67,7 @@ describe('Request', function() { }); it('should throw if method isn\'t passed to the constructor', function() { - var originalRequest = generateBaseRequest(); + const originalRequest = generateBaseRequest(); delete originalRequest.method; (function() { @@ -76,13 +76,13 @@ describe('Request', function() { }); it('should convert all header keys to lowercase', function() { - var originalRequest = generateBaseRequest(); + const originalRequest = generateBaseRequest(); originalRequest.headers = { Foo: 'bar', BAR: 'foo' }; - var request = new Request(originalRequest); + const request = new Request(originalRequest); request.headers.foo.should.eql('bar'); request.headers.bar.should.eql('foo'); should.not.exist(request.headers.Foo); @@ -90,7 +90,7 @@ describe('Request', function() { }); it('should include additional properties passed in the request', function() { - var originalRequest = generateBaseRequest(); + const originalRequest = generateBaseRequest(); originalRequest.custom = { newFoo: 'newBar' }; @@ -99,7 +99,7 @@ describe('Request', function() { newBar: 'newFoo' }; - var request = new Request(originalRequest); + const request = new Request(originalRequest); request.headers.should.eql(originalRequest.headers); request.method.should.eql(originalRequest.method); request.query.should.eql(originalRequest.query); @@ -109,7 +109,7 @@ describe('Request', function() { }); it('should include additional properties passed in the request', function() { - var originalRequest = generateBaseRequest(); + const originalRequest = generateBaseRequest(); originalRequest.custom = { newFoo: 'newBar' }; @@ -118,7 +118,7 @@ describe('Request', function() { newBar: 'newFoo' }; - var request = new Request(originalRequest); + const request = new Request(originalRequest); request.headers.should.eql(originalRequest.headers); request.method.should.eql(originalRequest.method); request.query.should.eql(originalRequest.query); @@ -128,41 +128,41 @@ describe('Request', function() { }); it('should allow getting of headers using `request.get`', function() { - var originalRequest = generateBaseRequest(); + const originalRequest = generateBaseRequest(); - var request = new Request(originalRequest); + const request = new Request(originalRequest); request.get('bar').should.eql(originalRequest.headers.bar); }); it('should allow getting of headers using `request.get`', function() { - var originalRequest = generateBaseRequest(); + const originalRequest = generateBaseRequest(); - var request = new Request(originalRequest); + const request = new Request(originalRequest); request.get('bar').should.eql(originalRequest.headers.bar); }); it('should allow getting of headers using `request.get`', function() { - var originalRequest = generateBaseRequest(); + const originalRequest = generateBaseRequest(); - var request = new Request(originalRequest); + const request = new Request(originalRequest); request.get('bar').should.eql(originalRequest.headers.bar); }); it('should validate the content-type', function() { - var originalRequest = generateBaseRequest(); + const originalRequest = generateBaseRequest(); originalRequest.headers['content-type'] = 'application/x-www-form-urlencoded'; originalRequest.headers['content-length'] = JSON.stringify(originalRequest.body).length; - var request = new Request(originalRequest); + const request = new Request(originalRequest); request.is('application/x-www-form-urlencoded').should.eql('application/x-www-form-urlencoded'); }); it('should return false if the content-type is invalid', function() { - var originalRequest = generateBaseRequest(); + const originalRequest = generateBaseRequest(); originalRequest.headers['content-type'] = 'application/x-www-form-urlencoded'; originalRequest.headers['content-length'] = JSON.stringify(originalRequest.body).length; - var request = new Request(originalRequest); + const request = new Request(originalRequest); request.is('application/json').should.eql(false); }); }); diff --git a/test/unit/response_test.js b/test/unit/response_test.js index 0ef54a87d..8d4897c93 100644 --- a/test/unit/response_test.js +++ b/test/unit/response_test.js @@ -4,8 +4,8 @@ * Module dependencies. */ -var Response = require('../../lib/response'); -var should = require('chai').should(); +const Response = require('../../lib/response'); +const should = require('chai').should(); /** * Test `Request`. @@ -24,42 +24,42 @@ function generateBaseResponse() { describe('Request', function() { it('should instantiate with a basic request', function() { - var originalResponse = generateBaseResponse(); + const originalResponse = generateBaseResponse(); - var response = new Response(originalResponse); + const response = new Response(originalResponse); response.headers.should.eql(originalResponse.headers); response.body.should.eql(originalResponse.body); response.status.should.eql(200); }); it('should allow a response to be passed without a body', function() { - var originalResponse = generateBaseResponse(); + const originalResponse = generateBaseResponse(); delete originalResponse.body; - var response = new Response(originalResponse); + const response = new Response(originalResponse); response.headers.should.eql(originalResponse.headers); response.body.should.eql({}); response.status.should.eql(200); }); it('should allow a response to be passed without headers', function() { - var originalResponse = generateBaseResponse(); + const originalResponse = generateBaseResponse(); delete originalResponse.headers; - var response = new Response(originalResponse); + const response = new Response(originalResponse); response.headers.should.eql({}); response.body.should.eql(originalResponse.body); response.status.should.eql(200); }); it('should convert all header keys to lowercase', function() { - var originalResponse = generateBaseResponse(); + const originalResponse = generateBaseResponse(); originalResponse.headers = { Foo: 'bar', BAR: 'foo' }; - var response = new Response(originalResponse); + const response = new Response(originalResponse); response.headers.foo.should.eql('bar'); response.headers.bar.should.eql('foo'); should.not.exist(response.headers.Foo); @@ -67,7 +67,7 @@ describe('Request', function() { }); it('should include additional properties passed in the response', function() { - var originalResponse = generateBaseResponse(); + const originalResponse = generateBaseResponse(); originalResponse.custom = { newFoo: 'newBar' }; @@ -76,7 +76,7 @@ describe('Request', function() { newBar: 'newFoo' }; - var response = new Response(originalResponse); + const response = new Response(originalResponse); response.headers.should.eql(originalResponse.headers); response.body.should.eql(originalResponse.body); response.custom.should.eql(originalResponse.custom); @@ -84,23 +84,23 @@ describe('Request', function() { }); it('should allow getting of headers using `response.get`', function() { - var originalResponse = generateBaseResponse(); + const originalResponse = generateBaseResponse(); - var response = new Response(originalResponse); + const response = new Response(originalResponse); response.get('bar').should.eql(originalResponse.headers.bar); }); it('should allow getting of headers using `response.get`', function() { - var originalResponse = generateBaseResponse(); + const originalResponse = generateBaseResponse(); - var response = new Response(originalResponse); + const response = new Response(originalResponse); response.get('bar').should.eql(originalResponse.headers.bar); }); it('should allow setting of headers using `response.set`', function() { - var originalResponse = generateBaseResponse(); + const originalResponse = generateBaseResponse(); - var response = new Response(originalResponse); + const response = new Response(originalResponse); response.headers.should.eql(originalResponse.headers); response.set('newheader', 'newvalue'); response.headers.bar.should.eql('foo'); @@ -108,9 +108,9 @@ describe('Request', function() { }); it('should process redirect', function() { - var originalResponse = generateBaseResponse(); + const originalResponse = generateBaseResponse(); - var response = new Response(originalResponse); + const response = new Response(originalResponse); response.headers.should.eql(originalResponse.headers); response.status.should.eql(200); response.redirect('http://foo.bar'); diff --git a/test/unit/server_test.js b/test/unit/server_test.js index e7c343f0c..3987df77a 100644 --- a/test/unit/server_test.js +++ b/test/unit/server_test.js @@ -4,12 +4,12 @@ * Module dependencies. */ -var AuthenticateHandler = require('../../lib/handlers/authenticate-handler'); -var AuthorizeHandler = require('../../lib/handlers/authorize-handler'); -var Promise = require('bluebird'); -var Server = require('../../lib/server'); -var TokenHandler = require('../../lib/handlers/token-handler'); -var sinon = require('sinon'); +const AuthenticateHandler = require('../../lib/handlers/authenticate-handler'); +const AuthorizeHandler = require('../../lib/handlers/authorize-handler'); +const Promise = require('bluebird'); +const Server = require('../../lib/server'); +const TokenHandler = require('../../lib/handlers/token-handler'); +const sinon = require('sinon'); /** * Test `Server`. @@ -18,10 +18,10 @@ var sinon = require('sinon'); describe('Server', function() { describe('authenticate()', function() { it('should call `handle`', function() { - var model = { + const model = { getAccessToken: function() {} }; - var server = new Server({ model: model }); + const server = new Server({ model: model }); sinon.stub(AuthenticateHandler.prototype, 'handle').returns(Promise.resolve()); @@ -33,11 +33,11 @@ describe('Server', function() { }); it('should map string passed as `options` to `options.scope`', function() { - var model = { + const model = { getAccessToken: function() {}, verifyScope: function() {} }; - var server = new Server({ model: model }); + const server = new Server({ model: model }); sinon.stub(AuthenticateHandler.prototype, 'handle').returns(Promise.resolve()); @@ -53,12 +53,12 @@ describe('Server', function() { describe('authorize()', function() { it('should call `handle`', function() { - var model = { + const model = { getAccessToken: function() {}, getClient: function() {}, saveAuthorizationCode: function() {} }; - var server = new Server({ model: model }); + const server = new Server({ model: model }); sinon.stub(AuthorizeHandler.prototype, 'handle').returns(Promise.resolve()); @@ -72,11 +72,11 @@ describe('Server', function() { describe('token()', function() { it('should call `handle`', function() { - var model = { + const model = { getClient: function() {}, saveToken: function() {} }; - var server = new Server({ model: model }); + const server = new Server({ model: model }); sinon.stub(TokenHandler.prototype, 'handle').returns(Promise.resolve()); diff --git a/test/unit/validator/is_test.js b/test/unit/validator/is_test.js index c6827d8e0..016371a38 100644 --- a/test/unit/validator/is_test.js +++ b/test/unit/validator/is_test.js @@ -1,13 +1,13 @@ -var is = require('../../../lib/validator/is'); +const is = require('../../../lib/validator/is'); require('chai').should(); function runRanges (ranges, fn, expected) { ranges.forEach(function (range) { - var lower = range[0]; - var upper = range[1]; + const lower = range[0]; + const upper = range[1]; - for (var i = lower; i <= upper; i++) { - var unicodeChar = String.fromCodePoint(i); + for (let i = lower; i <= upper; i++) { + const unicodeChar = String.fromCodePoint(i); // single char fn(unicodeChar).should.eql(expected, i + ' ' + unicodeChar); // multiple chars @@ -19,7 +19,7 @@ function runRanges (ranges, fn, expected) { describe('Validator', function () { describe('is', function () { it('validates if a value matches a unicode character (nchar)', function () { - var validRanges = [ + const validRanges = [ [45, 46], // \u002D \u002E [48, 57], // 0-9 [65, 90], // A-Z @@ -29,7 +29,7 @@ describe('Validator', function () { runRanges(validRanges, is.nchar, true); - var invalidRanges = [ + const invalidRanges = [ [0, 44], [47, 47], [58, 64], @@ -41,7 +41,7 @@ describe('Validator', function () { runRanges(invalidRanges, is.nchar, false); }); it('validates if a value matches a unicode character, including exclamation marks (nqchar)', function () { - var validRanges = [ + const validRanges = [ [33, 33], // \u0021 [35, 91], // \u0023-\u005B [93, 126] // \u005D-\u007E @@ -49,7 +49,7 @@ describe('Validator', function () { runRanges(validRanges, is.nqchar, true); - var invalidRanges = [ + const invalidRanges = [ [0, 32], [34, 34], [92, 92], @@ -59,7 +59,7 @@ describe('Validator', function () { runRanges(invalidRanges, is.nqchar, false); }); it('validates if a value matches a unicode character, including exclamation marks and spaces (nqschar)', function () { - var validRanges = [ + const validRanges = [ [32, 33], // \u0020-\u0021 [35, 91], // \u0023-\u005B [93, 126] // \u005D-\u007E @@ -67,7 +67,7 @@ describe('Validator', function () { runRanges(validRanges, is.nqschar, true); - var invalidRanges = [ + const invalidRanges = [ [0, 31], [34, 34], [92, 92], @@ -78,7 +78,7 @@ describe('Validator', function () { }); it('validates if a value matches a unicode character excluding the carriage return and linefeed characters (uchar)', function () { this.timeout(60000); - var validRanges = [ + const validRanges = [ [9, 9], // \u0009 [32, 126], // \u0020-\u007E, [128, 55295], // \u0080-\uD7FF @@ -88,7 +88,7 @@ describe('Validator', function () { runRanges(validRanges, is.uchar, true); - var invalidRanges = [ + const invalidRanges = [ [0, 8], [10, 31], [127, 127], @@ -110,13 +110,13 @@ describe('Validator', function () { }); }); it('validates if a value matches against the printable set of unicode characters (vschar)', function () { - var validRanges = [ + const validRanges = [ [32, 126] // \u0020-\u007E ]; runRanges(validRanges, is.vschar, true); - var invalidRanges = [ + const invalidRanges = [ [0, 31], [127, 1023] ]; From e3aeff133092c804f07b03d3c9667a141f2a0957 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Sun, 10 Oct 2021 08:22:39 +0300 Subject: [PATCH 55/99] Add TS types Copied from DefinitelyTyped. --- index.d.ts | 476 +++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 477 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 000000000..260e34aeb --- /dev/null +++ b/index.d.ts @@ -0,0 +1,476 @@ +// Type definitions for Node OAuth2 Server 4.0 +// Definitions by: Robbie Van Gorkom , +// Charles Irick , +// Daniel Fischer , +// Vitor Santos + +import * as http from 'http'; + +/** + * Represents an OAuth2 server instance. + */ +declare class OAuth2Server { + static OAuth2Server: typeof OAuth2Server; + + /** + * Instantiates OAuth2Server using the supplied model + */ + constructor(options: OAuth2Server.ServerOptions); + + /** + * Authenticates a request. + */ + authenticate( + request: OAuth2Server.Request, + response: OAuth2Server.Response, + options?: OAuth2Server.AuthenticateOptions, + callback?: OAuth2Server.Callback + ): Promise; + + /** + * Authorizes a token request. + */ + authorize( + request: OAuth2Server.Request, + response: OAuth2Server.Response, + options?: OAuth2Server.AuthorizeOptions, + callback?: OAuth2Server.Callback + ): Promise; + + /** + * Retrieves a new token for an authorized token request. + */ + token( + request: OAuth2Server.Request, + response: OAuth2Server.Response, + options?: OAuth2Server.TokenOptions, + callback?: OAuth2Server.Callback + ): Promise; +} + +declare namespace OAuth2Server { + /** + * Represents an incoming HTTP request. + */ + class Request { + body?: any; + headers?: { [key: string]: string; } | undefined; + method?: string | undefined; + query?: { [key: string]: string; } | undefined; + + /** + * Instantiates Request using the supplied options. + * + */ + constructor(options?: { [key: string]: any } | http.IncomingMessage); + + /** + * Returns the specified HTTP header field. The match is case-insensitive. + * + */ + get(field: string): any | undefined; + + /** + * Checks if the request’s Content-Type HTTP header matches any of the given MIME types. + * + */ + is(types: string[]): string | false; + } + + /** + * Represents an outgoing HTTP response. + */ + class Response { + body?: any; + headers?: { [key: string]: string; } | undefined; + status?: number | undefined; + + /** + * Instantiates Response using the supplied options. + * + */ + constructor(options?: { [key: string]: any; } | http.ServerResponse); + + /** + * Returns the specified HTTP header field. The match is case-insensitive. + * + */ + get(field: string): any | undefined; + + /** + * Sets the specified HTTP header field. The match is case-insensitive. + * + */ + set(field: string, value: string): void; + + /** + * Redirects to the specified URL using 302 Found. + * + */ + redirect(url: string): void; + } + + abstract class AbstractGrantType { + /** + * Instantiates AbstractGrantType using the supplied options. + * + */ + constructor(options: TokenOptions) + + /** + * Generate access token. Calls Model#generateAccessToken() if implemented. + * + */ + generateAccessToken(client: Client, user: User, scope: string | string[]): Promise; + + /** + * Generate refresh token. Calls Model#generateRefreshToken() if implemented. + * + */ + generateRefreshToken(client: Client, user: User, scope: string | string[]): Promise; + + /** + * Get access token expiration date. + * + */ + getAccessTokenExpiresAt(): Date; + + /** + * Get refresh token expiration date. + * + */ + getRefreshTokenExpiresAt(): Date; + + /** + * Get scope from the request body. + * + */ + getScope(request: Request): string; + + /** + * Validate requested scope. Calls Model#validateScope() if implemented. + * + */ + validateScope(user: User, client: Client, scope: string | string[]): Promise; + + /** + * Retrieve info from the request and client and return token + * + */ + abstract handle(request: Request, client: Client): Promise; + } + + interface ServerOptions extends AuthenticateOptions, AuthorizeOptions, TokenOptions { + /** + * Model object + */ + model: AuthorizationCodeModel | ClientCredentialsModel | RefreshTokenModel | PasswordModel | ExtensionModel; + } + + interface AuthenticateOptions { + /** + * The scope(s) to authenticate. + */ + scope?: string | string[] | undefined; + + /** + * Set the X-Accepted-OAuth-Scopes HTTP header on response objects. + */ + addAcceptedScopesHeader?: boolean | undefined; + + /** + * Set the X-OAuth-Scopes HTTP header on response objects. + */ + addAuthorizedScopesHeader?: boolean | undefined; + + /** + * Allow clients to pass bearer tokens in the query string of a request. + */ + allowBearerTokensInQueryString?: boolean | undefined; + } + + interface AuthorizeOptions { + /** + * The authenticate handler + */ + authenticateHandler?: {} | undefined; + + /** + * Allow clients to specify an empty state + */ + allowEmptyState?: boolean | undefined; + + /** + * Lifetime of generated authorization codes in seconds (default = 5 minutes). + */ + authorizationCodeLifetime?: number | undefined; + } + + interface TokenOptions { + /** + * Lifetime of generated access tokens in seconds (default = 1 hour) + */ + accessTokenLifetime?: number | undefined; + + /** + * Lifetime of generated refresh tokens in seconds (default = 2 weeks) + */ + refreshTokenLifetime?: number | undefined; + + /** + * Allow extended attributes to be set on the returned token + */ + allowExtendedTokenAttributes?: boolean | undefined; + + /** + * Require a client secret. Defaults to true for all grant types. + */ + requireClientAuthentication?: {} | undefined; + + /** + * Always revoke the used refresh token and issue a new one for the refresh_token grant. + */ + alwaysIssueNewRefreshToken?: boolean | undefined; + + /** + * Additional supported grant types. + */ + extendedGrantTypes?: { [key: string]: typeof AbstractGrantType } | undefined; + } + + /** + * Represents a generic callback structure for model callbacks + */ + type Callback = (err?: any, result?: T) => void; + + /** + * For returning falsey parameters in cases of failure + */ + type Falsey = '' | 0 | false | null | undefined; + + interface BaseModel { + /** + * Invoked to generate a new access token. + * + */ + generateAccessToken?(client: Client, user: User, scope: string | string[], callback?: Callback): Promise; + + /** + * Invoked to retrieve a client using a client id or a client id/client secret combination, depending on the grant type. + * + */ + getClient(clientId: string, clientSecret: string, callback?: Callback): Promise; + + /** + * Invoked to save an access token and optionally a refresh token, depending on the grant type. + * + */ + saveToken(token: Token, client: Client, user: User, callback?: Callback): Promise; + } + + interface RequestAuthenticationModel { + /** + * Invoked to retrieve an existing access token previously saved through Model#saveToken(). + * + */ + getAccessToken(accessToken: string, callback?: Callback): Promise; + + /** + * Invoked during request authentication to check if the provided access token was authorized the requested scopes. + * + */ + verifyScope(token: Token, scope: string | string[], callback?: Callback): Promise; + } + + interface AuthorizationCodeModel extends BaseModel, RequestAuthenticationModel { + /** + * Invoked to generate a new refresh token. + * + */ + generateRefreshToken?(client: Client, user: User, scope: string | string[], callback?: Callback): Promise; + + /** + * Invoked to generate a new authorization code. + * + */ + generateAuthorizationCode?(client: Client, user: User, scope: string | string[], callback?: Callback): Promise; + + /** + * Invoked to retrieve an existing authorization code previously saved through Model#saveAuthorizationCode(). + * + */ + getAuthorizationCode(authorizationCode: string, callback?: Callback): Promise; + + /** + * Invoked to save an authorization code. + * + */ + saveAuthorizationCode( + code: Pick, + client: Client, + user: User, + callback?: Callback): Promise; + + /** + * Invoked to revoke an authorization code. + * + */ + revokeAuthorizationCode(code: AuthorizationCode, callback?: Callback): Promise; + + /** + * Invoked to check if the requested scope is valid for a particular client/user combination. + * + */ + validateScope?(user: User, client: Client, scope: string | string[], callback?: Callback): Promise; + } + + interface PasswordModel extends BaseModel, RequestAuthenticationModel { + /** + * Invoked to generate a new refresh token. + * + */ + generateRefreshToken?(client: Client, user: User, scope: string | string[], callback?: Callback): Promise; + + /** + * Invoked to retrieve a user using a username/password combination. + * + */ + getUser(username: string, password: string, callback?: Callback): Promise; + + /** + * Invoked to check if the requested scope is valid for a particular client/user combination. + * + */ + validateScope?(user: User, client: Client, scope: string | string[], callback?: Callback): Promise; + } + + interface RefreshTokenModel extends BaseModel, RequestAuthenticationModel { + /** + * Invoked to generate a new refresh token. + * + */ + generateRefreshToken?(client: Client, user: User, scope: string | string[], callback?: Callback): Promise; + + /** + * Invoked to retrieve an existing refresh token previously saved through Model#saveToken(). + * + */ + getRefreshToken(refreshToken: string, callback?: Callback): Promise; + + /** + * Invoked to revoke a refresh token. + * + */ + revokeToken(token: RefreshToken | Token, callback?: Callback): Promise; + } + + interface ClientCredentialsModel extends BaseModel, RequestAuthenticationModel { + /** + * Invoked to retrieve the user associated with the specified client. + * + */ + getUserFromClient(client: Client, callback?: Callback): Promise; + + /** + * Invoked to check if the requested scope is valid for a particular client/user combination. + * + */ + validateScope?(user: User, client: Client, scope: string | string[], callback?: Callback): Promise; + } + + interface ExtensionModel extends BaseModel, RequestAuthenticationModel {} + + /** + * An interface representing the user. + * A user object is completely transparent to oauth2-server and is simply used as input to model functions. + */ + interface User { + [key: string]: any; + } + + /** + * An interface representing the client and associated data + */ + interface Client { + id: string; + redirectUris?: string | string[] | undefined; + grants: string | string[]; + accessTokenLifetime?: number | undefined; + refreshTokenLifetime?: number | undefined; + [key: string]: any; + } + + /** + * An interface representing the authorization code and associated data. + */ + interface AuthorizationCode { + authorizationCode: string; + expiresAt: Date; + redirectUri: string; + scope?: string | string[] | undefined; + client: Client; + user: User; + [key: string]: any; + } + + /** + * An interface representing the token(s) and associated data. + */ + interface Token { + accessToken: string; + accessTokenExpiresAt?: Date | undefined; + refreshToken?: string | undefined; + refreshTokenExpiresAt?: Date | undefined; + scope?: string | string[] | undefined; + client: Client; + user: User; + [key: string]: any; + } + + /** + * An interface representing the refresh token and associated data. + */ + interface RefreshToken { + refreshToken: string; + refreshTokenExpiresAt?: Date | undefined; + scope?: string | string[] | undefined; + client: Client; + user: User; + [key: string]: any; + } + + class OAuthError extends Error { + constructor(messageOrError: string | Error, properties?: object); + + /** + * The HTTP error code. + */ + code: number; + + /** + * The OAuth error code. + */ + name: string; + + /** + * A human-readable error message. + */ + message: string; + } + + class AccessDeniedError extends OAuthError {} + class InsufficientScopeError extends OAuthError {} + class InvalidArgumentError extends OAuthError {} + class InvalidClientError extends OAuthError {} + class InvalidGrantError extends OAuthError {} + class InvalidRequestError extends OAuthError {} + class InvalidScopeError extends OAuthError {} + class InvalidTokenError extends OAuthError {} + class ServerError extends OAuthError {} + class UnauthorizedClientError extends OAuthError {} + class UnauthorizedRequestError extends OAuthError {} + class UnsupportedGrantTypeError extends OAuthError {} + class UnsupportedResponseTypeError extends OAuthError {} +} + +export = OAuth2Server; diff --git a/package.json b/package.json index beaeb89da..7cede2a22 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "Daniel Reguero" ], "main": "index.js", + "types": "index.d.ts", "dependencies": { "basic-auth": "2.0.1", "bluebird": "3.7.2", From d991b14858a0a0dc090a1ed8d5eb0dc18a0aefe2 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Sun, 10 Oct 2021 08:27:37 +0300 Subject: [PATCH 56/99] Remove superfluous files from published package --- package.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/package.json b/package.json index 7cede2a22..ae20a4bea 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,11 @@ ], "main": "index.js", "types": "index.d.ts", + "files": [ + "index.js", + "index.d.ts", + "lib" + ], "dependencies": { "basic-auth": "2.0.1", "bluebird": "3.7.2", From eaa9d03a61f5fad7dad2f244c2fbca7c9ce6cbd2 Mon Sep 17 00:00:00 2001 From: HappyZombies Date: Sat, 27 Nov 2021 11:46:00 -0500 Subject: [PATCH 57/99] release: up semver and update changelog --- CHANGELOG.md | 7 +++++++ package-lock.json | 2 +- package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 668c19c8a..9083b9b8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ ## Changelog +## 4.1.1 + +### Added +- Added TypeScript types +### Changed +- Removed extra files when someone npm installs. + ## 4.1.0 ### Changed * Bump dev dependencies to resolve vulnerabilities diff --git a/package-lock.json b/package-lock.json index a2a526ebd..d9ecbcab1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@node-oauth/oauth2-server", - "version": "4.1.0", + "version": "4.1.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index ae20a4bea..c04355437 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@node-oauth/oauth2-server", "description": "Complete, framework-agnostic, compliant and well tested module for implementing an OAuth2 Server in node.js", - "version": "4.1.0", + "version": "4.1.1", "keywords": [ "oauth", "oauth2" From 2fa8a7fbe732f521f122be23b434bbf4664a17f0 Mon Sep 17 00:00:00 2001 From: HappyZombies Date: Sat, 27 Nov 2021 11:49:36 -0500 Subject: [PATCH 58/99] release: add missing changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9083b9b8e..e258b2a60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Added TypeScript types ### Changed - Removed extra files when someone npm installs. +- Upgrades all code from ES5 to ES6, where possible. ## 4.1.0 ### Changed From 4ca8032456eabdaa5ed1fe38927af06bb6acfdaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Mon, 29 Nov 2021 09:23:14 +0100 Subject: [PATCH 59/99] fix(handlers): skip varcheck for state when allowEmptyState --- lib/handlers/authorize-handler.js | 15 ++++++++------- .../handlers/authorize-handler_test.js | 12 ++++++++++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/lib/handlers/authorize-handler.js b/lib/handlers/authorize-handler.js index e82501264..8e7be7da7 100644 --- a/lib/handlers/authorize-handler.js +++ b/lib/handlers/authorize-handler.js @@ -238,13 +238,14 @@ AuthorizeHandler.prototype.getScope = function(request) { AuthorizeHandler.prototype.getState = function(request) { const state = request.body.state || request.query.state; - - if (!this.allowEmptyState && !state) { - throw new InvalidRequestError('Missing parameter: `state`'); - } - - if (!is.vschar(state)) { - throw new InvalidRequestError('Invalid parameter: `state`'); + const stateExists = state && state.length > 0; + const stateIsValid = stateExists + ? is.vschar(state) + : this.allowEmptyState; + + if (!stateIsValid) { + const message = (!stateExists) ? 'Missing' : 'Invalid'; + throw new InvalidRequestError(`${message} parameter: \`state\``); } return state; diff --git a/test/integration/handlers/authorize-handler_test.js b/test/integration/handlers/authorize-handler_test.js index 49d2c0d6a..71535f008 100644 --- a/test/integration/handlers/authorize-handler_test.js +++ b/test/integration/handlers/authorize-handler_test.js @@ -932,6 +932,18 @@ describe('AuthorizeHandler integration', function() { } }); + it('should allow missing `state` if `allowEmptyState` is valid', function () { + const model = { + getAccessToken: function() {}, + getClient: function() {}, + saveAuthorizationCode: function() {} + }; + const handler = new AuthorizeHandler({ allowEmptyState: true, authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: {}, headers: {}, method: {}, query: {} }); + const state = handler.getState(request); + should.equal(state, undefined); + }); + it('should throw an error if `state` is invalid', function() { const model = { getAccessToken: function() {}, From b56afcdb5258f4bc83fbdd2c5c842fa07bb0e578 Mon Sep 17 00:00:00 2001 From: Francesco Stefanni Date: Sun, 5 Dec 2021 11:54:34 +0100 Subject: [PATCH 60/99] fixes issue 89, point 18, original pr 646 --- lib/handlers/authenticate-handler.js | 6 +++ .../handlers/authenticate-handler_test.js | 51 +++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/lib/handlers/authenticate-handler.js b/lib/handlers/authenticate-handler.js index b02b12319..3521a7aa9 100644 --- a/lib/handlers/authenticate-handler.js +++ b/lib/handlers/authenticate-handler.js @@ -90,6 +90,12 @@ AuthenticateHandler.prototype.handle = function(request, response) { // @see https://tools.ietf.org/html/rfc6750#section-3.1 if (e instanceof UnauthorizedRequestError) { response.set('WWW-Authenticate', 'Bearer realm="Service"'); + } else if (e instanceof InvalidRequestError) { + response.set('WWW-Authenticate', 'Bearer realm="Service",error="invalid_request"'); + } else if (e instanceof InvalidTokenError) { + response.set('WWW-Authenticate', 'Bearer realm="Service",error="invalid_token"'); + } else if (e instanceof InsufficientScopeError) { + response.set('WWW-Authenticate', 'Bearer realm="Service",error="insufficient_scope"'); } if (!(e instanceof OAuthError)) { diff --git a/test/integration/handlers/authenticate-handler_test.js b/test/integration/handlers/authenticate-handler_test.js index 3e0eefd5f..151ada325 100644 --- a/test/integration/handlers/authenticate-handler_test.js +++ b/test/integration/handlers/authenticate-handler_test.js @@ -132,6 +132,57 @@ describe('AuthenticateHandler integration', function() { }); }); + it('should set the `WWW-Authenticate` header if an InvalidRequestError is thrown', function() { + const model = { + getAccessToken: function() { + throw new InvalidRequestError(); + } + }; + const handler = new AuthenticateHandler({ model: model }); + const request = new Request({ body: {}, headers: { 'Authorization': 'Bearer foo' }, method: {}, query: {} }); + const response = new Response({ body: {}, headers: {} }); + + return handler.handle(request, response) + .then(should.fail) + .catch(function() { + response.get('WWW-Authenticate').should.equal('Bearer realm="Service",error="invalid_request"'); + }); + }); + + it('should set the `WWW-Authenticate` header if an InvalidTokenError is thrown', function() { + const model = { + getAccessToken: function() { + throw new InvalidTokenError(); + } + }; + const handler = new AuthenticateHandler({ model: model }); + const request = new Request({ body: {}, headers: { 'Authorization': 'Bearer foo' }, method: {}, query: {} }); + const response = new Response({ body: {}, headers: {} }); + + return handler.handle(request, response) + .then(should.fail) + .catch(function() { + response.get('WWW-Authenticate').should.equal('Bearer realm="Service",error="invalid_token"'); + }); + }); + + it('should set the `WWW-Authenticate` header if an InsufficientScopeError is thrown', function() { + const model = { + getAccessToken: function() { + throw new InsufficientScopeError(); + } + }; + const handler = new AuthenticateHandler({ model: model }); + const request = new Request({ body: {}, headers: { 'Authorization': 'Bearer foo' }, method: {}, query: {} }); + const response = new Response({ body: {}, headers: {} }); + + return handler.handle(request, response) + .then(should.fail) + .catch(function() { + response.get('WWW-Authenticate').should.equal('Bearer realm="Service",error="insufficient_scope"'); + }); + }); + it('should throw the error if an oauth error is thrown', function() { const model = { getAccessToken: function() { From 3df52fdf2c324933cfa8b6c00782d3de8d70c31b Mon Sep 17 00:00:00 2001 From: Francesco Stefanni Date: Sun, 5 Dec 2021 14:11:34 +0100 Subject: [PATCH 61/99] supported custom validateRedirectUri --- lib/handlers/authorize-handler.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/handlers/authorize-handler.js b/lib/handlers/authorize-handler.js index e82501264..491949002 100644 --- a/lib/handlers/authorize-handler.js +++ b/lib/handlers/authorize-handler.js @@ -160,6 +160,7 @@ AuthorizeHandler.prototype.getAuthorizationCodeLifetime = function() { */ AuthorizeHandler.prototype.getClient = function(request) { + const self = this; const clientId = request.body.client_id || request.query.client_id; if (!clientId) { @@ -193,7 +194,11 @@ AuthorizeHandler.prototype.getClient = function(request) { throw new InvalidClientError('Invalid client: missing client `redirectUri`'); } - if (redirectUri && !client.redirectUris.includes(redirectUri)) { + if (redirectUri && typeof self.model.validateRedirectUri === 'function') { + if (self.model.validateRedirectUri(redirectUri, client.redirectUris)) { + throw new InvalidClientError('Invalid client: `redirect_uri` does not match client value'); + } + } else if (redirectUri && !client.redirectUris.includes(redirectUri)) { throw new InvalidClientError('Invalid client: `redirect_uri` does not match client value'); } return client; From 91f27f8e362cef33642158736357afd618365d56 Mon Sep 17 00:00:00 2001 From: Francesco Stefanni Date: Sun, 5 Dec 2021 15:30:56 +0100 Subject: [PATCH 62/99] Supported state in case of denial --- lib/handlers/authorize-handler.js | 7 +++- .../handlers/authorize-handler_test.js | 33 +++++++++++++++---- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/lib/handlers/authorize-handler.js b/lib/handlers/authorize-handler.js index e82501264..371eadd1f 100644 --- a/lib/handlers/authorize-handler.js +++ b/lib/handlers/authorize-handler.js @@ -96,6 +96,12 @@ AuthorizeHandler.prototype.handle = function(request, response) { let ResponseType; return Promise.bind(this) + .then(function() { + state = this.getState(request); + if(request.query.allowed === 'false') { + throw new AccessDeniedError('Access denied: user denied access to application'); + } + }) .then(function() { const requestedScope = this.getScope(request); @@ -107,7 +113,6 @@ AuthorizeHandler.prototype.handle = function(request, response) { return this.generateAuthorizationCode(client, user, scope); }) .then(function(authorizationCode) { - state = this.getState(request); ResponseType = this.getResponseType(request); return this.saveAuthorizationCode(authorizationCode, expiresAt, scope, client, uri, user); diff --git a/test/integration/handlers/authorize-handler_test.js b/test/integration/handlers/authorize-handler_test.js index 49d2c0d6a..6641b4cb1 100644 --- a/test/integration/handlers/authorize-handler_test.js +++ b/test/integration/handlers/authorize-handler_test.js @@ -161,12 +161,33 @@ describe('AuthorizeHandler integration', function() { it('should throw an error if `allowed` is `false`', function() { const model = { - getAccessToken: function() {}, - getClient: function() {}, - saveAuthorizationCode: function() {} + getAccessToken: function() { + return { + user: {}, + accessTokenExpiresAt: new Date(new Date().getTime() + 10000) + }; + }, + getClient: function() { + return { grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] }; + }, + saveAuthorizationCode: function() { + throw new Error('Unhandled exception'); + } }; const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); - const request = new Request({ body: {}, headers: {}, method: {}, query: { allowed: 'false' } }); + const request = new Request({ + body: { + client_id: 'test' + }, + headers: { + 'Authorization': 'Bearer foo' + }, + method: {}, + query: { + allowed: 'false', + state: 'foobar' + } + }); const response = new Response({ body: {}, headers: {} }); return handler.handle(request, response) @@ -328,7 +349,7 @@ describe('AuthorizeHandler integration', function() { return handler.handle(request, response) .then(should.fail) .catch(function() { - response.get('location').should.equal('http://example.com/cb?error=invalid_scope&error_description=Invalid%20parameter%3A%20%60scope%60'); + response.get('location').should.equal('http://example.com/cb?error=invalid_scope&error_description=Invalid%20parameter%3A%20%60scope%60&state=foobar'); }); }); @@ -416,7 +437,7 @@ describe('AuthorizeHandler integration', function() { return handler.handle(request, response) .then(should.fail) .catch(function() { - response.get('location').should.equal('http://example.com/cb?error=invalid_scope&error_description=Invalid%20scope%3A%20Requested%20scope%20is%20invalid'); + response.get('location').should.equal('http://example.com/cb?error=invalid_scope&error_description=Invalid%20scope%3A%20Requested%20scope%20is%20invalid&state=foobar'); }); }); From 88ef515d932b05d477f95c27387c4fe895a5d361 Mon Sep 17 00:00:00 2001 From: Joren Vandeweyer Date: Sat, 11 Dec 2021 14:47:07 +0100 Subject: [PATCH 63/99] added test for `validateRedirectUri` --- lib/handlers/authorize-handler.js | 2 +- test/unit/handlers/authorize-handler_test.js | 30 ++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/lib/handlers/authorize-handler.js b/lib/handlers/authorize-handler.js index 491949002..c88c5a8eb 100644 --- a/lib/handlers/authorize-handler.js +++ b/lib/handlers/authorize-handler.js @@ -195,7 +195,7 @@ AuthorizeHandler.prototype.getClient = function(request) { } if (redirectUri && typeof self.model.validateRedirectUri === 'function') { - if (self.model.validateRedirectUri(redirectUri, client.redirectUris)) { + if (!self.model.validateRedirectUri(redirectUri, client.redirectUris)) { throw new InvalidClientError('Invalid client: `redirect_uri` does not match client value'); } } else if (redirectUri && !client.redirectUris.includes(redirectUri)) { diff --git a/test/unit/handlers/authorize-handler_test.js b/test/unit/handlers/authorize-handler_test.js index 86ce336a7..c27a9ee22 100644 --- a/test/unit/handlers/authorize-handler_test.js +++ b/test/unit/handlers/authorize-handler_test.js @@ -99,4 +99,34 @@ describe('AuthorizeHandler', function() { .catch(should.fail); }); }); + + describe('validateRedirectUri()', function() { + it('should call `model.validateRedirectUri()`', function() { + const client = { grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] }; + const redirect_uri = 'http://example.com/cb/2'; + const model = { + getAccessToken: function() {}, + getClient: sinon.stub().returns(client), + saveAuthorizationCode: function() {}, + validateRedirectUri: sinon.stub().returns(true) + }; + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { client_id: 12345, client_secret: 'secret', redirect_uri }, headers: {}, method: {}, query: {} }); + + return handler.getClient(request) + .then(function() { + model.getClient.callCount.should.equal(1); + model.getClient.firstCall.args.should.have.length(2); + model.getClient.firstCall.args[0].should.equal(12345); + model.getClient.firstCall.thisValue.should.equal(model); + + model.validateRedirectUri.callCount.should.equal(1); + model.validateRedirectUri.firstCall.args.should.have.length(2); + model.validateRedirectUri.firstCall.args[0].should.equal(redirect_uri); + model.validateRedirectUri.firstCall.args[1].should.equal(client.redirectUris); + model.validateRedirectUri.firstCall.thisValue.should.equal(model); + }) + .catch(should.fail); + }); + }); }); From 0a86e694ac77a1ee272aac9c54f544a838c18b56 Mon Sep 17 00:00:00 2001 From: Joren Vandeweyer Date: Sat, 11 Dec 2021 15:19:42 +0100 Subject: [PATCH 64/99] updated documentation --- docs/model/overview.rst | 1 + docs/model/spec.rst | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/docs/model/overview.rst b/docs/model/overview.rst index 5e345abd0..62c9ffa99 100644 --- a/docs/model/overview.rst +++ b/docs/model/overview.rst @@ -37,6 +37,7 @@ Model functions used by the authorization code grant: - :ref:`Model#saveAuthorizationCode` - :ref:`Model#revokeAuthorizationCode` - :ref:`Model#validateScope` +- :ref:`Model#validateRedirectUri` -------- diff --git a/docs/model/spec.rst b/docs/model/spec.rst index 4cdd1fd11..b13f43854 100644 --- a/docs/model/spec.rst +++ b/docs/model/spec.rst @@ -985,3 +985,40 @@ Returns ``true`` if the access token passes, ``false`` otherwise. return requestedScopes.every(s => authorizedScopes.indexOf(s) >= 0); } +-------- + +.. _Model#validateRedirectUri: + +``validateRedirectUri(redirect_uri, redirect_uris, [callback])`` +================================================================ + +Invoked to check if the provided ``redirect_uri`` is valid for a particular ``client``. + +This model function is **optional**. If not implemented, the redirect_uri should be included in the provided redirect_uris of the client. + +**Invoked during:** + +- ``authorization_code`` grant + +**Arguments:** + ++-----------------+----------+---------------------------------------------------------------------+ +| Name | Type | Description | ++=================+==========+=====================================================================+ +| redirect_uri | String | The redirect URI to validate. | ++-----------------+----------+---------------------------------------------------------------------+ +| redirect_uris | Array | The list of redirect URIs configured for the client. | ++-----------------+----------+---------------------------------------------------------------------+ + +**Return value:** + +Returns ``true`` if the ``redirect_uri`` is valid, ``false`` otherwise. + +**Remarks:** + +:: + + function validateRedirectUri(redirect_uri, redirect_uris) { + return redirect_uris.includes(redirect_uri); + } + From 98a9d197ef7c0d3f20cca65ffec59973f2089d66 Mon Sep 17 00:00:00 2001 From: Joren Vandeweyer Date: Sat, 11 Dec 2021 15:59:08 +0100 Subject: [PATCH 65/99] better implementation of validateRedirectUri --- docs/model/spec.rst | 14 ++--- lib/handlers/authorize-handler.js | 25 +++++--- .../handlers/authorize-handler_test.js | 59 +++++++++++++++++++ test/unit/handlers/authorize-handler_test.js | 2 +- 4 files changed, 85 insertions(+), 15 deletions(-) diff --git a/docs/model/spec.rst b/docs/model/spec.rst index b13f43854..46b649493 100644 --- a/docs/model/spec.rst +++ b/docs/model/spec.rst @@ -989,12 +989,12 @@ Returns ``true`` if the access token passes, ``false`` otherwise. .. _Model#validateRedirectUri: -``validateRedirectUri(redirect_uri, redirect_uris, [callback])`` +``validateRedirectUri(redirectUri, client, [callback])`` ================================================================ -Invoked to check if the provided ``redirect_uri`` is valid for a particular ``client``. +Invoked to check if the provided ``redirectUri`` is valid for a particular ``client``. -This model function is **optional**. If not implemented, the redirect_uri should be included in the provided redirect_uris of the client. +This model function is **optional**. If not implemented, the ``redirectUri`` should be included in the provided ``redirectUris`` of the client. **Invoked during:** @@ -1007,18 +1007,18 @@ This model function is **optional**. If not implemented, the redirect_uri should +=================+==========+=====================================================================+ | redirect_uri | String | The redirect URI to validate. | +-----------------+----------+---------------------------------------------------------------------+ -| redirect_uris | Array | The list of redirect URIs configured for the client. | +| client | Object | The associated client. | +-----------------+----------+---------------------------------------------------------------------+ **Return value:** -Returns ``true`` if the ``redirect_uri`` is valid, ``false`` otherwise. +Returns ``true`` if the ``redirectUri`` is valid, ``false`` otherwise. **Remarks:** :: - function validateRedirectUri(redirect_uri, redirect_uris) { - return redirect_uris.includes(redirect_uri); + function validateRedirectUri(redirectUri, client) { + return client.redirectUris.includes(redirectUri); } diff --git a/lib/handlers/authorize-handler.js b/lib/handlers/authorize-handler.js index c88c5a8eb..96a47e36c 100644 --- a/lib/handlers/authorize-handler.js +++ b/lib/handlers/authorize-handler.js @@ -194,14 +194,17 @@ AuthorizeHandler.prototype.getClient = function(request) { throw new InvalidClientError('Invalid client: missing client `redirectUri`'); } - if (redirectUri && typeof self.model.validateRedirectUri === 'function') { - if (!self.model.validateRedirectUri(redirectUri, client.redirectUris)) { - throw new InvalidClientError('Invalid client: `redirect_uri` does not match client value'); - } - } else if (redirectUri && !client.redirectUris.includes(redirectUri)) { - throw new InvalidClientError('Invalid client: `redirect_uri` does not match client value'); + if (redirectUri) { + return self.validateRedirectUri(redirectUri, client) + .then(function(valid) { + if (!valid) { + throw new InvalidClientError('Invalid client: `redirect_uri` does not match client value'); + } + return client; + }); + } else { + return client; } - return client; }); }; @@ -294,6 +297,14 @@ AuthorizeHandler.prototype.saveAuthorizationCode = function(authorizationCode, e return promisify(this.model.saveAuthorizationCode, 3).call(this.model, code, client, user); }; + +AuthorizeHandler.prototype.validateRedirectUri = function(redirectUri, client) { + if (this.model.validateRedirectUri) { + return promisify(this.model.validateRedirectUri, 2).call(this.model, redirectUri, client); + } + + return Promise.resolve(client.redirectUris.includes(redirectUri)); +}; /** * Get response type. */ diff --git a/test/integration/handlers/authorize-handler_test.js b/test/integration/handlers/authorize-handler_test.js index 49d2c0d6a..6ff8621a3 100644 --- a/test/integration/handlers/authorize-handler_test.js +++ b/test/integration/handlers/authorize-handler_test.js @@ -634,6 +634,65 @@ describe('AuthorizeHandler integration', function() { }); }); + describe('validateRedirectUri()', function() { + it('should support empty model', function() { + const model = { + getAccessToken: function() {}, + getClient: function() {}, + saveAuthorizationCode: function() {} + }; + + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + + handler.validateRedirectUri('http://example.com/a', { redirectUris: ['http://example.com/a'] }).should.be.an.instanceOf(Promise); + }); + + it('should support promises', function() { + const model = { + getAccessToken: function() {}, + getClient: function() {}, + saveAuthorizationCode: function() {}, + validateRedirectUri: function() { + return Promise.resolve(true); + } + }; + + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + + handler.validateRedirectUri('http://example.com/a', { }).should.be.an.instanceOf(Promise); + }); + + it('should support non-promises', function() { + const model = { + getAccessToken: function() {}, + getClient: function() {}, + saveAuthorizationCode: function() {}, + validateRedirectUri: function() { + return true; + } + }; + + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + + handler.validateRedirectUri('http://example.com/a', { }).should.be.an.instanceOf(Promise); + }); + + it('should support callbacks', function() { + const model = { + getAccessToken: function() {}, + getClient: function() {}, + saveAuthorizationCode: function() {}, + validateRedirectUri: function(redirectUri, client, callback) { + callback(null, false); + } + }; + + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + + handler.validateRedirectUri('http://example.com/a', { }).should.be.an.instanceOf(Promise); + }); + }); + describe('getClient()', function() { it('should throw an error if `client_id` is missing', function() { const model = { diff --git a/test/unit/handlers/authorize-handler_test.js b/test/unit/handlers/authorize-handler_test.js index c27a9ee22..2a44bc64d 100644 --- a/test/unit/handlers/authorize-handler_test.js +++ b/test/unit/handlers/authorize-handler_test.js @@ -123,7 +123,7 @@ describe('AuthorizeHandler', function() { model.validateRedirectUri.callCount.should.equal(1); model.validateRedirectUri.firstCall.args.should.have.length(2); model.validateRedirectUri.firstCall.args[0].should.equal(redirect_uri); - model.validateRedirectUri.firstCall.args[1].should.equal(client.redirectUris); + model.validateRedirectUri.firstCall.args[1].should.equal(client); model.validateRedirectUri.firstCall.thisValue.should.equal(model); }) .catch(should.fail); From 8719d839958cbd92a3439f739af9fd19f0c47eed Mon Sep 17 00:00:00 2001 From: Francesco Stefanni Date: Sun, 12 Dec 2021 12:10:11 +0100 Subject: [PATCH 66/99] Bearer regular expression matching in authenticate handler --- lib/handlers/authenticate-handler.js | 2 +- .../handlers/authenticate-handler_test.js | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/handlers/authenticate-handler.js b/lib/handlers/authenticate-handler.js index b02b12319..78fb6111d 100644 --- a/lib/handlers/authenticate-handler.js +++ b/lib/handlers/authenticate-handler.js @@ -140,7 +140,7 @@ AuthenticateHandler.prototype.getTokenFromRequest = function(request) { AuthenticateHandler.prototype.getTokenFromRequestHeader = function(request) { const token = request.get('Authorization'); - const matches = token.match(/Bearer\s(\S+)/); + const matches = token.match(/^Bearer\s(\S+)/); if (!matches) { throw new InvalidRequestError('Invalid request: malformed authorization header'); diff --git a/test/unit/handlers/authenticate-handler_test.js b/test/unit/handlers/authenticate-handler_test.js index 4d634288d..ff0a924dd 100644 --- a/test/unit/handlers/authenticate-handler_test.js +++ b/test/unit/handlers/authenticate-handler_test.js @@ -5,6 +5,7 @@ */ const AuthenticateHandler = require('../../../lib/handlers/authenticate-handler'); +const InvalidRequestError = require('../../../lib/errors/invalid-request-error'); const Request = require('../../../lib/request'); const sinon = require('sinon'); const should = require('chai').should(); @@ -16,6 +17,33 @@ const ServerError = require('../../../lib/errors/server-error'); describe('AuthenticateHandler', function() { describe('getTokenFromRequest()', function() { + describe('with bearer token in the request authorization header', function() { + it('should throw an error if the token is malformed', () => { + const handler = new AuthenticateHandler({ + model: { getAccessToken() {} }, + }); + const request = new Request({ + body: {}, + headers: { + Authorization: 'foo Bearer bar', + }, + method: 'ANY', + query: {}, + }); + + try { + handler.getTokenFromRequestHeader(request); + + should.fail('should.fail', ''); + } catch (e) { + e.should.be.an.instanceOf(InvalidRequestError); + e.message.should.equal( + 'Invalid request: malformed authorization header', + ); + } + }); + }); + describe('with bearer token in the request authorization header', function() { it('should call `getTokenFromRequestHeader()`', function() { const handler = new AuthenticateHandler({ model: { getAccessToken: function() {} } }); From ff9a5d2b72608b1984e5513d0ba3bef917c73bc6 Mon Sep 17 00:00:00 2001 From: Francesco Stefanni <33950786+FStefanni@users.noreply.github.com> Date: Mon, 13 Dec 2021 12:35:17 +0100 Subject: [PATCH 67/99] fixed misssing return statement in doc (#98) Co-authored-by: Daniel Reguero Co-authored-by: Francesco Stefanni --- docs/model/spec.rst | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/model/spec.rst b/docs/model/spec.rst index 4cdd1fd11..33d8b8989 100644 --- a/docs/model/spec.rst +++ b/docs/model/spec.rst @@ -214,7 +214,7 @@ An ``Object`` representing the access token and associated data. function getAccessToken(accessToken) { // imaginary DB queries - db.queryAccessToken({access_token: accessToken}) + return db.queryAccessToken({access_token: accessToken}) .then(function(token) { return Promise.all([ token, @@ -288,7 +288,7 @@ An ``Object`` representing the refresh token and associated data. function getRefreshToken(refreshToken) { // imaginary DB queries - db.queryRefreshToken({refresh_token: refreshToken}) + return db.queryRefreshToken({refresh_token: refreshToken}) .then(function(token) { return Promise.all([ token, @@ -364,7 +364,7 @@ An ``Object`` representing the authorization code and associated data. function getAuthorizationCode(authorizationCode) { // imaginary DB queries - db.queryAuthorizationCode({authorization_code: authorizationCode}) + return db.queryAuthorizationCode({authorization_code: authorizationCode}) .then(function(code) { return Promise.all([ code, @@ -446,7 +446,7 @@ The return value (``client``) can carry additional properties that will be ignor if (clientSecret) { params.client_secret = clientSecret; } - db.queryClient(params) + return db.queryClient(params) .then(function(client) { return { id: client.id, @@ -984,4 +984,3 @@ Returns ``true`` if the access token passes, ``false`` otherwise. let authorizedScopes = token.scope.split(' '); return requestedScopes.every(s => authorizedScopes.indexOf(s) >= 0); } - From 292774eb1c8658f46b1b7a212a0665e3ebe5a643 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Dec 2021 12:38:45 +0100 Subject: [PATCH 68/99] build(deps-dev): bump eslint from 8.2.0 to 8.4.1 (#102) Bumps [eslint](https://github.com/eslint/eslint) from 8.2.0 to 8.4.1. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v8.2.0...v8.4.1) --- updated-dependencies: - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: Daniel Reguero Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 54 +++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/package-lock.json b/package-lock.json index d9ecbcab1..2a5c7cb97 100644 --- a/package-lock.json +++ b/package-lock.json @@ -304,14 +304,14 @@ } }, "@eslint/eslintrc": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.0.4.tgz", - "integrity": "sha512-h8Vx6MdxwWI2WM8/zREHMoqdgLNXEL4QX3MWSVMdyNJGvXVOs+6lp+m2hc3FnuMHDc4poxFNI20vCk0OmI4G0Q==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.0.5.tgz", + "integrity": "sha512-BLxsnmK3KyPunz5wmCCpqy0YelEoxxGmH73Is+Z74oOTMtExcjkr3dDR6quwrjh1YspA8DH9gnX1o069KiS9AQ==", "dev": true, "requires": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.0.0", + "espree": "^9.2.0", "globals": "^13.9.0", "ignore": "^4.0.6", "import-fresh": "^3.2.1", @@ -338,12 +338,12 @@ } }, "@humanwhocodes/config-array": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.6.0.tgz", - "integrity": "sha512-JQlEKbcgEUjBFhLIF4iqM7u/9lwgHRBcpHrmUNCALK0Q3amXN6lxdoXLnF0sm11E9VqTmBALR87IlUg1bZ8A9A==", + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.2.tgz", + "integrity": "sha512-UXOuFCGcwciWckOpmfKDq/GyhlTf9pN/BzG//x8p8zTOFEcGuA68ANXheFS0AGvy3qgZqLBUkMs7hqzqCKOVwA==", "dev": true, "requires": { - "@humanwhocodes/object-schema": "^1.2.0", + "@humanwhocodes/object-schema": "^1.2.1", "debug": "^4.1.1", "minimatch": "^3.0.4" } @@ -479,9 +479,9 @@ "dev": true }, "acorn": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.5.0.tgz", - "integrity": "sha512-yXbYeFy+jUuYd3/CDcg2NkIYE991XYX/bje7LmjJigUciaeO1JR4XxXgCIV1/Zc/dRuFEyw1L0pbA+qynJkW5Q==", + "version": "8.6.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.6.0.tgz", + "integrity": "sha512-U1riIR+lBSNi3IbxtaHOIKdH8sLFv3NYfNv8sg7ZsNhcfl4HF2++BfqqrNAxoCLQW1iiylOj76ecnaUxz+z9yw==", "dev": true }, "acorn-jsx": { @@ -918,13 +918,13 @@ "dev": true }, "eslint": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.2.0.tgz", - "integrity": "sha512-erw7XmM+CLxTOickrimJ1SiF55jiNlVSp2qqm0NuBWPtHYQCegD5ZMaW0c3i5ytPqL+SSLaCxdvQXFPLJn+ABw==", + "version": "8.4.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.4.1.tgz", + "integrity": "sha512-TxU/p7LB1KxQ6+7aztTnO7K0i+h0tDi81YRY9VzB6Id71kNz+fFYnf5HD5UOQmxkzcoa0TlVZf9dpMtUv0GpWg==", "dev": true, "requires": { - "@eslint/eslintrc": "^1.0.4", - "@humanwhocodes/config-array": "^0.6.0", + "@eslint/eslintrc": "^1.0.5", + "@humanwhocodes/config-array": "^0.9.2", "ajv": "^6.10.0", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", @@ -932,10 +932,10 @@ "doctrine": "^3.0.0", "enquirer": "^2.3.5", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^6.0.0", + "eslint-scope": "^7.1.0", "eslint-utils": "^3.0.0", - "eslint-visitor-keys": "^3.0.0", - "espree": "^9.0.0", + "eslint-visitor-keys": "^3.1.0", + "espree": "^9.2.0", "esquery": "^1.4.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", @@ -990,9 +990,9 @@ } }, "eslint-scope": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-6.0.0.tgz", - "integrity": "sha512-uRDL9MWmQCkaFus8RF5K9/L/2fn+80yoW3jkD53l4shjCh26fCtvJGasxjUqP5OT87SYTxCVA3BwTUzuELx9kA==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.0.tgz", + "integrity": "sha512-aWwkhnS0qAXqNOgKOK0dJ2nvzEbhEvpy8OlJ9kZ0FeZnA6zpjv1/Vei+puGFFX7zkPCkHHXb7IDX3A+7yPrRWg==", "dev": true, "requires": { "esrecurse": "^4.3.0", @@ -1023,14 +1023,14 @@ "dev": true }, "espree": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.0.0.tgz", - "integrity": "sha512-r5EQJcYZ2oaGbeR0jR0fFVijGOcwai07/690YRXLINuhmVeRY4UKSAsQPe/0BNuDgwP7Ophoc1PRsr2E3tkbdQ==", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.2.0.tgz", + "integrity": "sha512-oP3utRkynpZWF/F2x/HZJ+AGtnIclaR7z1pYPxy7NYM2fSO6LgK/Rkny8anRSPK/VwEA1eqm2squui0T7ZMOBg==", "dev": true, "requires": { - "acorn": "^8.5.0", + "acorn": "^8.6.0", "acorn-jsx": "^5.3.1", - "eslint-visitor-keys": "^3.0.0" + "eslint-visitor-keys": "^3.1.0" } }, "esprima": { From 4ff1f0744a27d9d64d6bc03a621fd7ba4098a9ed Mon Sep 17 00:00:00 2001 From: Jonah Werre Date: Mon, 13 Dec 2021 14:19:03 -0700 Subject: [PATCH 69/99] added @node-oauth/formats module, removed is.js tests --- lib/grant-types/abstract-grant-type.js | 4 +- .../authorization-code-grant-type.js | 8 +- lib/grant-types/password-grant-type.js | 6 +- lib/grant-types/refresh-token-grant-type.js | 4 +- lib/handlers/authorize-handler.js | 10 +- lib/handlers/token-handler.js | 8 +- package-lock.json | 5 + package.json | 2 + test/unit/validator/is_test.js | 127 ------------------ 9 files changed, 27 insertions(+), 147 deletions(-) delete mode 100644 test/unit/validator/is_test.js diff --git a/lib/grant-types/abstract-grant-type.js b/lib/grant-types/abstract-grant-type.js index 4f73e5592..d9894b6aa 100644 --- a/lib/grant-types/abstract-grant-type.js +++ b/lib/grant-types/abstract-grant-type.js @@ -8,7 +8,7 @@ const InvalidArgumentError = require('../errors/invalid-argument-error'); const InvalidScopeError = require('../errors/invalid-scope-error'); const Promise = require('bluebird'); const promisify = require('promisify-any').use(Promise); -const is = require('../validator/is'); +const isFormat = require('@node-oauth/formats'); const tokenUtil = require('../utils/token-util'); /** @@ -83,7 +83,7 @@ AbstractGrantType.prototype.getRefreshTokenExpiresAt = function() { */ AbstractGrantType.prototype.getScope = function(request) { - if (!is.nqschar(request.body.scope)) { + if (!isFormat.nqschar(request.body.scope)) { throw new InvalidArgumentError('Invalid parameter: `scope`'); } diff --git a/lib/grant-types/authorization-code-grant-type.js b/lib/grant-types/authorization-code-grant-type.js index 8f21aeffc..ed66eeab6 100644 --- a/lib/grant-types/authorization-code-grant-type.js +++ b/lib/grant-types/authorization-code-grant-type.js @@ -11,7 +11,7 @@ const InvalidRequestError = require('../errors/invalid-request-error'); const Promise = require('bluebird'); const promisify = require('promisify-any').use(Promise); const ServerError = require('../errors/server-error'); -const is = require('../validator/is'); +const isFormat = require('@node-oauth/formats'); const util = require('util'); /** @@ -85,7 +85,7 @@ AuthorizationCodeGrantType.prototype.getAuthorizationCode = function(request, cl throw new InvalidRequestError('Missing parameter: `code`'); } - if (!is.vschar(request.body.code)) { + if (!isFormat.vschar(request.body.code)) { throw new InvalidRequestError('Invalid parameter: `code`'); } return promisify(this.model.getAuthorizationCode, 1).call(this.model, request.body.code) @@ -114,7 +114,7 @@ AuthorizationCodeGrantType.prototype.getAuthorizationCode = function(request, cl throw new InvalidGrantError('Invalid grant: authorization code has expired'); } - if (code.redirectUri && !is.uri(code.redirectUri)) { + if (code.redirectUri && !isFormat.uri(code.redirectUri)) { throw new InvalidGrantError('Invalid grant: `redirect_uri` is not a valid URI'); } @@ -140,7 +140,7 @@ AuthorizationCodeGrantType.prototype.validateRedirectUri = function(request, cod const redirectUri = request.body.redirect_uri || request.query.redirect_uri; - if (!is.uri(redirectUri)) { + if (!isFormat.uri(redirectUri)) { throw new InvalidRequestError('Invalid request: `redirect_uri` is not a valid URI'); } diff --git a/lib/grant-types/password-grant-type.js b/lib/grant-types/password-grant-type.js index 70a7c1b43..b65f9e1f6 100644 --- a/lib/grant-types/password-grant-type.js +++ b/lib/grant-types/password-grant-type.js @@ -10,7 +10,7 @@ const InvalidGrantError = require('../errors/invalid-grant-error'); const InvalidRequestError = require('../errors/invalid-request-error'); const Promise = require('bluebird'); const promisify = require('promisify-any').use(Promise); -const is = require('../validator/is'); +const isFormat = require('@node-oauth/formats'); const util = require('util'); /** @@ -80,11 +80,11 @@ PasswordGrantType.prototype.getUser = function(request) { throw new InvalidRequestError('Missing parameter: `password`'); } - if (!is.uchar(request.body.username)) { + if (!isFormat.uchar(request.body.username)) { throw new InvalidRequestError('Invalid parameter: `username`'); } - if (!is.uchar(request.body.password)) { + if (!isFormat.uchar(request.body.password)) { throw new InvalidRequestError('Invalid parameter: `password`'); } diff --git a/lib/grant-types/refresh-token-grant-type.js b/lib/grant-types/refresh-token-grant-type.js index 3eac92b7e..c9a25df32 100644 --- a/lib/grant-types/refresh-token-grant-type.js +++ b/lib/grant-types/refresh-token-grant-type.js @@ -11,7 +11,7 @@ const InvalidRequestError = require('../errors/invalid-request-error'); const Promise = require('bluebird'); const promisify = require('promisify-any').use(Promise); const ServerError = require('../errors/server-error'); -const is = require('../validator/is'); +const isFormat = require('@node-oauth/formats'); const util = require('util'); /** @@ -82,7 +82,7 @@ RefreshTokenGrantType.prototype.getRefreshToken = function(request, client) { throw new InvalidRequestError('Missing parameter: `refresh_token`'); } - if (!is.vschar(request.body.refresh_token)) { + if (!isFormat.vschar(request.body.refresh_token)) { throw new InvalidRequestError('Invalid parameter: `refresh_token`'); } diff --git a/lib/handlers/authorize-handler.js b/lib/handlers/authorize-handler.js index 5e06deda1..6b42fa015 100644 --- a/lib/handlers/authorize-handler.js +++ b/lib/handlers/authorize-handler.js @@ -18,7 +18,7 @@ const Request = require('../request'); const Response = require('../response'); const ServerError = require('../errors/server-error'); const UnauthorizedClientError = require('../errors/unauthorized-client-error'); -const is = require('../validator/is'); +const isFormat = require('@node-oauth/formats'); const tokenUtil = require('../utils/token-util'); const url = require('url'); @@ -171,13 +171,13 @@ AuthorizeHandler.prototype.getClient = function(request) { throw new InvalidRequestError('Missing parameter: `client_id`'); } - if (!is.vschar(clientId)) { + if (!isFormat.vschar(clientId)) { throw new InvalidRequestError('Invalid parameter: `client_id`'); } const redirectUri = request.body.redirect_uri || request.query.redirect_uri; - if (redirectUri && !is.uri(redirectUri)) { + if (redirectUri && !isFormat.uri(redirectUri)) { throw new InvalidRequestError('Invalid request: `redirect_uri` is not a valid URI'); } return promisify(this.model.getClient, 2).call(this.model, clientId, null) @@ -230,7 +230,7 @@ AuthorizeHandler.prototype.validateScope = function(user, client, scope) { AuthorizeHandler.prototype.getScope = function(request) { const scope = request.body.scope || request.query.scope; - if (!is.nqschar(scope)) { + if (!isFormat.nqschar(scope)) { throw new InvalidScopeError('Invalid parameter: `scope`'); } @@ -245,7 +245,7 @@ AuthorizeHandler.prototype.getState = function(request) { const state = request.body.state || request.query.state; const stateExists = state && state.length > 0; const stateIsValid = stateExists - ? is.vschar(state) + ? isFormat.vschar(state) : this.allowEmptyState; if (!stateIsValid) { diff --git a/lib/handlers/token-handler.js b/lib/handlers/token-handler.js index 81959699d..285843e85 100644 --- a/lib/handlers/token-handler.js +++ b/lib/handlers/token-handler.js @@ -18,7 +18,7 @@ const TokenModel = require('../models/token-model'); const UnauthorizedClientError = require('../errors/unauthorized-client-error'); const UnsupportedGrantTypeError = require('../errors/unsupported-grant-type-error'); const auth = require('basic-auth'); -const is = require('../validator/is'); +const isFormat = require('@node-oauth/formats'); /** * Grant types. @@ -123,11 +123,11 @@ TokenHandler.prototype.getClient = function(request, response) { throw new InvalidRequestError('Missing parameter: `client_secret`'); } - if (!is.vschar(credentials.clientId)) { + if (!isFormat.vschar(credentials.clientId)) { throw new InvalidRequestError('Invalid parameter: `client_id`'); } - if (credentials.clientSecret && !is.vschar(credentials.clientSecret)) { + if (credentials.clientSecret && !isFormat.vschar(credentials.clientSecret)) { throw new InvalidRequestError('Invalid parameter: `client_secret`'); } @@ -203,7 +203,7 @@ TokenHandler.prototype.handleGrantType = function(request, client) { throw new InvalidRequestError('Missing parameter: `grant_type`'); } - if (!is.nchar(grantType) && !is.uri(grantType)) { + if (!isFormat.nchar(grantType) && !isFormat.uri(grantType)) { throw new InvalidRequestError('Invalid parameter: `grant_type`'); } diff --git a/package-lock.json b/package-lock.json index 2a5c7cb97..19a704e23 100644 --- a/package-lock.json +++ b/package-lock.json @@ -437,6 +437,11 @@ "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", "dev": true }, + "@node-oauth/formats": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@node-oauth/formats/-/formats-1.0.0.tgz", + "integrity": "sha512-DwSbLtdC8zC5B5gTJkFzJj5s9vr9SGzOgQvV9nH7tUVuMSScg0EswAczhjIapOmH3Y8AyP7C4Jv7b8+QJObWZA==" + }, "@sinonjs/commons": { "version": "1.8.3", "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.3.tgz", diff --git a/package.json b/package.json index c04355437..c0deb377e 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "lib" ], "dependencies": { + "@node-oauth/formats": "^1.0.0", "basic-auth": "2.0.1", "bluebird": "3.7.2", "promisify-any": "2.0.1", @@ -44,6 +45,7 @@ "pretest": "./node_modules/.bin/eslint lib test index.js", "test": "NODE_ENV=test ./node_modules/.bin/mocha 'test/**/*_test.js'", "test-debug": "NODE_ENV=test ./node_modules/.bin/mocha --inspect --debug-brk 'test/**/*_test.js'", + "test:watch": "NODE_ENV=test ./node_modules/.bin/mocha --watch 'test/**/*_test.js'", "test:coverage": "NODE_ENV=test nyc --reporter=html --reporter=text ./node_modules/.bin/mocha 'test/**/*_test.js'", "lint": "npx eslint .", "lint:fix": "npx eslint . --fix" diff --git a/test/unit/validator/is_test.js b/test/unit/validator/is_test.js deleted file mode 100644 index 016371a38..000000000 --- a/test/unit/validator/is_test.js +++ /dev/null @@ -1,127 +0,0 @@ -const is = require('../../../lib/validator/is'); -require('chai').should(); - -function runRanges (ranges, fn, expected) { - ranges.forEach(function (range) { - const lower = range[0]; - const upper = range[1]; - - for (let i = lower; i <= upper; i++) { - const unicodeChar = String.fromCodePoint(i); - // single char - fn(unicodeChar).should.eql(expected, i + ' ' + unicodeChar); - // multiple chars - fn(unicodeChar+unicodeChar).should.eql(expected, i + ' ' + unicodeChar); - } - }); -} - -describe('Validator', function () { - describe('is', function () { - it('validates if a value matches a unicode character (nchar)', function () { - const validRanges = [ - [45, 46], // \u002D \u002E - [48, 57], // 0-9 - [65, 90], // A-Z - [95, 95], // \u005F - [97, 122] // a-z - ]; - - runRanges(validRanges, is.nchar, true); - - const invalidRanges = [ - [0, 44], - [47, 47], - [58, 64], - [91, 94], - [96, 96], - [123, 1023] - ]; - - runRanges(invalidRanges, is.nchar, false); - }); - it('validates if a value matches a unicode character, including exclamation marks (nqchar)', function () { - const validRanges = [ - [33, 33], // \u0021 - [35, 91], // \u0023-\u005B - [93, 126] // \u005D-\u007E - ]; - - runRanges(validRanges, is.nqchar, true); - - const invalidRanges = [ - [0, 32], - [34, 34], - [92, 92], - [127, 1023] - ]; - - runRanges(invalidRanges, is.nqchar, false); - }); - it('validates if a value matches a unicode character, including exclamation marks and spaces (nqschar)', function () { - const validRanges = [ - [32, 33], // \u0020-\u0021 - [35, 91], // \u0023-\u005B - [93, 126] // \u005D-\u007E - ]; - - runRanges(validRanges, is.nqschar, true); - - const invalidRanges = [ - [0, 31], - [34, 34], - [92, 92], - [127, 1023] - ]; - - runRanges(invalidRanges, is.nqschar, false); - }); - it('validates if a value matches a unicode character excluding the carriage return and linefeed characters (uchar)', function () { - this.timeout(60000); - const validRanges = [ - [9, 9], // \u0009 - [32, 126], // \u0020-\u007E, - [128, 55295], // \u0080-\uD7FF - [57344, 65533], // \uE000-\uFFFD - [65536, 1114111] // \u10000-\u10FFFF - ]; - - runRanges(validRanges, is.uchar, true); - - const invalidRanges = [ - [0, 8], - [10, 31], - [127, 127], - [55296, 57343], - [65534, 65535] - ]; - - runRanges(invalidRanges, is.uchar, false); - }); - it('validates if a value matches generic URIs (uri)', function () { - ['aa:', 'http:', 'https:'].forEach(function (uri) { - is.uri(uri).should.equal(true); - is.uri(uri.toUpperCase()).should.equal(true); - }); - - ['a', 'a:', 'http'].forEach(function (uri) { - is.uri(uri).should.equal(false); - is.uri(uri.toUpperCase()).should.equal(false); - }); - }); - it('validates if a value matches against the printable set of unicode characters (vschar)', function () { - const validRanges = [ - [32, 126] // \u0020-\u007E - ]; - - runRanges(validRanges, is.vschar, true); - - const invalidRanges = [ - [0, 31], - [127, 1023] - ]; - - runRanges(invalidRanges, is.vschar, false); - }); - }); -}); From 10bca6867ed561fd74541882c3b93d636483ff40 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 19 Dec 2021 00:19:43 +0100 Subject: [PATCH 70/99] Bump sinon from 11.1.2 to 12.0.1 (#74) Bumps [sinon](https://github.com/sinonjs/sinon) from 11.1.2 to 12.0.1. - [Release notes](https://github.com/sinonjs/sinon/releases) - [Changelog](https://github.com/sinonjs/sinon/blob/master/docs/changelog.md) - [Commits](https://github.com/sinonjs/sinon/compare/v11.1.2...v12.0.1) --- updated-dependencies: - dependency-name: sinon dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> From 643e09173e2ee79986a7b2e470b156ea6b14dcdf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 19 Dec 2021 00:20:05 +0100 Subject: [PATCH 71/99] build(deps-dev): bump eslint from 8.2.0 to 8.4.1 (#106) Bumps [eslint](https://github.com/eslint/eslint) from 8.2.0 to 8.4.1. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v8.2.0...v8.4.1) --- updated-dependencies: - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> From 92bea82b6636d7c83f9966f4a707153e97ef33b1 Mon Sep 17 00:00:00 2001 From: Joren Vandeweyer Date: Sun, 19 Dec 2021 11:44:56 +0100 Subject: [PATCH 72/99] Integration test password grant (#100) * test example * created db & model factories * added refresh_token grant type test * removed failing test, not implemented feature * add reference to issue * client authentication test * random client credentials in test * replace math.random by crypto.randomBytes --- test/compliance/client-authentication_test.js | 128 ++++++++++ test/compliance/password-grant-type_test.js | 236 ++++++++++++++++++ .../refresh-token-grant-type_test.js | 173 +++++++++++++ test/helpers/db.js | 70 ++++++ test/helpers/model.js | 92 +++++++ test/helpers/request.js | 17 ++ 6 files changed, 716 insertions(+) create mode 100644 test/compliance/client-authentication_test.js create mode 100644 test/compliance/password-grant-type_test.js create mode 100644 test/compliance/refresh-token-grant-type_test.js create mode 100644 test/helpers/db.js create mode 100644 test/helpers/model.js create mode 100644 test/helpers/request.js diff --git a/test/compliance/client-authentication_test.js b/test/compliance/client-authentication_test.js new file mode 100644 index 000000000..72624ec5b --- /dev/null +++ b/test/compliance/client-authentication_test.js @@ -0,0 +1,128 @@ +/** + * @see https://datatracker.ietf.org/doc/html/rfc6749#section-2.3.1 + * + * For example (with extra line breaks for display purposes only): + * + * Authorization: Basic czZCaGRSa3F0Mzo3RmpmcDBaQnIxS3REUmJuZlZkbUl3 + * + * Alternatively, the authorization server MAY support including the + * client credentials in the request-body using the following + * parameters: + * + * client_id + * REQUIRED. The client identifier issued to the client during + * the registration process described by Section 2.2. + * + * client_secret + * REQUIRED. The client secret. The client MAY omit the + * parameter if the client secret is an empty string. + */ + +const OAuth2Server = require('../..'); +const DB = require('../helpers/db'); +const createModel = require('../helpers/model'); +const createRequest = require('../helpers/request'); +const Response = require('../../lib/response'); + +require('chai').should(); + +const db = new DB(); + +const auth = new OAuth2Server({ + model: createModel(db) +}); + +const user = db.saveUser({ id: 1, username: 'test', password: 'test'}); +const client = db.saveClient({ id: 'a', secret: 'b', grants: ['password'] }); +const scope = 'read write'; + +function createDefaultRequest () { + return createRequest({ + body: { + grant_type: 'password', + username: user.username, + password: user.password, + scope + }, + headers: { + 'authorization': 'Basic ' + Buffer.from(client.id + ':' + client.secret).toString('base64'), + 'content-type': 'application/x-www-form-urlencoded' + }, + method: 'POST', + }); +} + +describe('Client Authentication Compliance', function () { + describe('No authentication', function () { + it('should be an unsuccesfull authentication', async function () { + const request = createDefaultRequest(); + const response = new Response({}); + + delete request.headers.authorization; + + await auth.token(request, response, {}) + .then((token) => { + throw new Error('Should not be here'); + }). + catch(err => { + err.name.should.equal('invalid_client'); + }); + }); + }); + + describe('Basic Authentication', function () { + it('should be a succesfull authentication', async function () { + const request = createDefaultRequest(); + const response = new Response({}); + + await auth.token(request, response, {}); + }); + + it('should be an unsuccesfull authentication', async function () { + const request = createDefaultRequest(); + const response = new Response({}); + + request.headers.authorization = 'Basic ' + Buffer.from('a:c').toString('base64'); + + await auth.token(request, response, {}) + .then((token) => { + throw new Error('Should not be here'); + }). + catch(err => { + err.name.should.equal('invalid_client'); + }); + }); + }); + + describe('Request body authentication', function () { + it('should be a succesfull authentication', async function () { + const request = createDefaultRequest(); + const response = new Response({}); + + delete request.headers.authorization; + + request.body.client_id = client.id; + request.body.client_secret = client.secret; + + await auth.token(request, response, {}); + }); + + it('should be an unsuccesfull authentication', async function () { + const request = createDefaultRequest(); + const response = new Response({}); + + delete request.headers.authorization; + + request.body.client_id = 'a'; + request.body.client_secret = 'c'; + + await auth.token(request, response, {}) + .then((token) => { + throw new Error('Should not be here'); + }) + .catch(err => { + err.name.should.equal('invalid_client'); + }); + }); + }); +}); diff --git a/test/compliance/password-grant-type_test.js b/test/compliance/password-grant-type_test.js new file mode 100644 index 000000000..7941d54fe --- /dev/null +++ b/test/compliance/password-grant-type_test.js @@ -0,0 +1,236 @@ +/** + * Request + * @see https://datatracker.ietf.org/doc/html/rfc6749#section-4.3.2 + * + * grant_type + * REQUIRED. Value MUST be set to "password". + * username + * REQUIRED. The resource owner username. + * password + * REQUIRED. The resource owner password. + * scope + * OPTIONAL. The scope of the access request as described by Section 3.3. + */ + +/** + * Response + * @see https://datatracker.ietf.org/doc/html/rfc6749#section-5.1 + * + * access_token + * REQUIRED. The access token issued by the authorization server. + * token_type + * REQUIRED. The type of the token issued as described in + * Section 7.1. Value is case insensitive. + * expires_in + * RECOMMENDED. The lifetime in seconds of the access token. For + * example, the value "3600" denotes that the access token will + * expire in one hour from the time the response was generated. + * If omitted, the authorization server SHOULD provide the + * expiration time via other means or document the default value. + * refresh_token + * OPTIONAL. The refresh token, which can be used to obtain new + * access tokens using the same authorization grant as described + * in Section 6. + * scope + * OPTIONAL, if identical to the scope requested by the client; + * otherwise, REQUIRED. The scope of the access token as + * described by Section 3.3. + */ + +/** + * Response (error) + * @see https://datatracker.ietf.org/doc/html/rfc6749#section-5.2 + * + * error + * REQUIRED. A single ASCII [USASCII] error code from the following: + * invalid_request, invalid_client, invalid_grant + * unauthorized_client, unsupported_grant_type, invalid_scope + * error_description + * OPTIONAL. Human-readable ASCII [USASCII] text providing + * additional information, used to assist the client developer in + * understanding the error that occurred. + * error_uri + * OPTIONAL. A URI identifying a human-readable web page with + * information about the error, used to provide the client + * developer with additional information about the error. + */ + +const OAuth2Server = require('../..'); +const DB = require('../helpers/db'); +const createModel = require('../helpers/model'); +const createRequest = require('../helpers/request'); +const Response = require('../../lib/response'); +const crypto = require('crypto'); + +require('chai').should(); + +const db = new DB(); + +const auth = new OAuth2Server({ + model: createModel(db) +}); + +const user = db.saveUser({ id: 1, username: 'test', password: 'test'}); +const client = db.saveClient({ id: 'a', secret: 'b', grants: ['password'] }); +const scope = 'read write'; + +function createDefaultRequest () { + return createRequest({ + body: { + grant_type: 'password', + username: user.username, + password: user.password, + scope + }, + headers: { + 'authorization': 'Basic ' + Buffer.from(client.id + ':' + client.secret).toString('base64'), + 'content-type': 'application/x-www-form-urlencoded' + }, + method: 'POST', + }); +} + +describe('PasswordGrantType Compliance', function () { + describe('Authenticate', function () { + it ('Succesfull authorization', async function () { + const request = createDefaultRequest(); + const response = new Response({}); + + const token = await auth.token(request, response, {}); + response.body.token_type.should.equal('Bearer'); + response.body.access_token.should.equal(token.accessToken); + response.body.refresh_token.should.equal(token.refreshToken); + response.body.expires_in.should.be.a('number'); + response.body.scope.should.equal(scope); + + token.accessToken.should.be.a('string'); + token.refreshToken.should.be.a('string'); + token.accessTokenExpiresAt.should.be.a('date'); + token.refreshTokenExpiresAt.should.be.a('date'); + token.scope.should.equal(scope); + + db.accessTokens.has(token.accessToken).should.equal(true); + db.refreshTokens.has(token.refreshToken).should.equal(true); + }); + + it ('Succesfull authorization and authentication', async function () { + const tokenRequest = createDefaultRequest(); + const tokenResponse = new Response({}); + + const token = await auth.token(tokenRequest, tokenResponse, {}); + + const authenticationRequest = createRequest({ + body: {}, + headers: { + 'Authorization': `Bearer ${token.accessToken}` + }, + method: 'GET', + query: {} + }); + const authenticationResponse = new Response({}); + + const authenticated = await auth.authenticate( + authenticationRequest, + authenticationResponse, + {}); + + authenticated.scope.should.equal(scope); + authenticated.user.should.be.an('object'); + authenticated.client.should.be.an('object'); + }); + + it ('Username missing', async function () { + const request = createDefaultRequest(); + const response = new Response({}); + + delete request.body.username; + + await auth.token(request, response, {}) + .catch(err => { + err.name.should.equal('invalid_request'); + }); + }); + + it ('Password missing', async function () { + const request = createDefaultRequest(); + const response = new Response({}); + + delete request.body.password; + + await auth.token(request, response, {}) + .catch(err => { + err.name.should.equal('invalid_request'); + }); + }); + + it ('Wrong username', async function () { + const request = createDefaultRequest(); + const response = new Response({}); + + request.body.username = 'wrong'; + + await auth.token(request, response, {}) + .catch(err => { + err.name.should.equal('invalid_grant'); + }); + }); + + it ('Wrong password', async function () { + const request = createDefaultRequest(); + const response = new Response({}); + + request.body.password = 'wrong'; + + await auth.token(request, response, {}) + .catch(err => { + err.name.should.equal('invalid_grant'); + }); + }); + + it ('Client not found', async function () { + const request = createDefaultRequest(); + const response = new Response({}); + + const clientId = crypto.randomBytes(4).toString('hex'); + const clientSecret = crypto.randomBytes(4).toString('hex'); + + request.headers.authorization = 'Basic ' + Buffer.from(`${clientId}:${clientSecret}`).toString('base64'); + + await auth.token(request, response, {}) + .catch(err => { + err.name.should.equal('invalid_client'); + }); + }); + + it ('Client secret not required', async function () { + const request = createDefaultRequest(); + const response = new Response({}); + + delete request.body.client_secret; + + const token = await auth.token(request, response, { + requireClientAuthentication: { + password: false + } + }); + + token.accessToken.should.be.a('string'); + }); + + it ('Client secret required', async function () { + const request = createDefaultRequest(); + const response = new Response({}); + + delete request.body.client_secret; + + await auth.token(request, response, { + requireClientAuthentication: { + password: false + } + }) + .catch(err => { + err.name.should.equal('invalid_client'); + }); + }); + }); +}); diff --git a/test/compliance/refresh-token-grant-type_test.js b/test/compliance/refresh-token-grant-type_test.js new file mode 100644 index 000000000..b01fef3db --- /dev/null +++ b/test/compliance/refresh-token-grant-type_test.js @@ -0,0 +1,173 @@ +/** + * Request an access token using the refresh token grant type. + * @see https://datatracker.ietf.org/doc/html/rfc6749#section-6 + * + * grant_type + * REQUIRED. Value MUST be set to "refresh_token". + * refresh_token + * REQUIRED. The refresh token issued to the client. + * scope + * OPTIONAL. The scope of the access request as described by + * Section 3.3. The requested scope MUST NOT include any scope + * not originally granted by the resource owner, and if omitted is + * treated as equal to the scope originally granted by the + * resource owner. + */ + + +/** + * Response + * @see https://datatracker.ietf.org/doc/html/rfc6749#section-5.1 + * + * access_token + * REQUIRED. The access token issued by the authorization server. + * token_type + * REQUIRED. The type of the token issued as described in + * Section 7.1. Value is case insensitive. + * expires_in + * RECOMMENDED. The lifetime in seconds of the access token. For + * example, the value "3600" denotes that the access token will + * expire in one hour from the time the response was generated. + * If omitted, the authorization server SHOULD provide the + * expiration time via other means or document the default value. + * refresh_token + * OPTIONAL. The refresh token, which can be used to obtain new + * access tokens using the same authorization grant as described + * in Section 6. + * scope + * OPTIONAL, if identical to the scope requested by the client; + * otherwise, REQUIRED. The scope of the access token as + * described by Section 3.3. + */ + +/** + * Response (error) + * @see https://datatracker.ietf.org/doc/html/rfc6749#section-5.2 + * + * error + * REQUIRED. A single ASCII [USASCII] error code from the following: + * invalid_request, invalid_client, invalid_grant + * unauthorized_client, unsupported_grant_type, invalid_scope + * error_description + * OPTIONAL. Human-readable ASCII [USASCII] text providing + * additional information, used to assist the client developer in + * understanding the error that occurred. + * error_uri + * OPTIONAL. A URI identifying a human-readable web page with + * information about the error, used to provide the client + * developer with additional information about the error. + */ +const OAuth2Server = require('../..'); +const DB = require('../helpers/db'); +const createModel = require('../helpers/model'); +const createRequest = require('../helpers/request'); +const Response = require('../../lib/response'); + +require('chai').should(); + +const db = new DB(); + +const auth = new OAuth2Server({ + model: createModel(db) +}); + +const user = db.saveUser({ id: 1, username: 'test', password: 'test'}); +const client = db.saveClient({ id: 'a', secret: 'b', grants: ['password', 'refresh_token'] }); +const scope = 'read write'; + +function createLoginRequest () { + return createRequest({ + body: { + grant_type: 'password', + username: user.username, + password: user.password, + scope + }, + headers: { + 'authorization': 'Basic ' + Buffer.from(client.id + ':' + client.secret).toString('base64'), + 'content-type': 'application/x-www-form-urlencoded' + }, + method: 'POST', + }); +} + +function createRefreshRequest (refresh_token) { + return createRequest({ + method: 'POST', + body: { + grant_type: 'refresh_token', + refresh_token, + scope + }, + headers: { + 'authorization': 'Basic ' + Buffer.from(client.id + ':' + client.secret).toString('base64'), + 'content-type': 'application/x-www-form-urlencoded' + } + }); +} + +describe('RefreshTokenGrantType Compliance', function () { + describe('With scope', function () { + it('Should generate token response', async function () { + const request = createLoginRequest(); + const response = new Response({}); + + const credentials = await auth.token(request, response, {}); + + const refreshRequest = createRefreshRequest(credentials.refreshToken); + const refreshResponse = new Response({}); + + const token = await auth.token(refreshRequest, refreshResponse, {}); + + refreshResponse.body.token_type.should.equal('Bearer'); + refreshResponse.body.access_token.should.equal(token.accessToken); + refreshResponse.body.refresh_token.should.equal(token.refreshToken); + refreshResponse.body.expires_in.should.be.a('number'); + refreshResponse.body.scope.should.equal(scope); + + token.accessToken.should.be.a('string'); + token.refreshToken.should.be.a('string'); + token.accessTokenExpiresAt.should.be.a('date'); + token.refreshTokenExpiresAt.should.be.a('date'); + token.scope.should.equal(scope); + + db.accessTokens.has(token.accessToken).should.equal(true); + db.refreshTokens.has(token.refreshToken).should.equal(true); + }); + + it('Should throw invalid_grant error', async function () { + const request = createRefreshRequest('invalid'); + const response = new Response({}); + + await auth.token(request, response, {}) + .then(() => { + throw Error('Should not reach this'); + }).catch(err => { + err.name.should.equal('invalid_grant'); + }); + }); + + // TODO: test refresh token with different scopes + // https://github.com/node-oauth/node-oauth2-server/issues/104 + + // it('Should throw invalid_scope error', async function () { + // const request = createLoginRequest(); + // const response = new Response({}); + + // const credentials = await auth.token(request, response, {}); + + // const refreshRequest = createRefreshRequest(credentials.refreshToken); + // const refreshResponse = new Response({}); + + // refreshRequest.scope = 'invalid'; + + // await auth.token(refreshRequest, refreshResponse, {}) + // .then(() => { + // throw Error('Should not reach this'); + // }) + // .catch(err => { + // err.name.should.equal('invalid_scope'); + // }); + // }); + }); +}); diff --git a/test/helpers/db.js b/test/helpers/db.js new file mode 100644 index 000000000..147d17410 --- /dev/null +++ b/test/helpers/db.js @@ -0,0 +1,70 @@ +class DB { + constructor () { + this.users = new Map(); + this.clients = []; + this.accessTokens = new Map(); + this.refreshTokens= new Map(); + } + + saveUser (user) { + this.users.set(user.id, user); + + return user; + } + + findUser (username, password) { + return Array.from(this.users.values()).find(user => { + return user.username === username && user.password === password; + }); + } + + findUserById (id) { + return this.users.get(id); + } + + saveClient (client) { + this.clients.push(client); + + return client; + } + + findClient (clientId, clientSecret) { + return this.clients.find(client => { + if (clientSecret) { + return client.id === clientId && client.secret === clientSecret; + } else { + return client.id === clientId; + } + }); + } + + findClientById (id) { + return this.clients.find(client => client.id === id); + } + + saveAccessToken (accessToken, meta) { + this.accessTokens.set(accessToken, meta); + } + + findAccessToken (accessToken) { + return this.accessTokens.get(accessToken); + } + + deleteAccessToken (accessToken) { + this.accessTokens.delete(accessToken); + } + + saveRefreshToken (refreshToken, meta) { + this.refreshTokens.set(refreshToken, meta); + } + + findRefreshToken (refreshToken) { + return this.refreshTokens.get(refreshToken); + } + + deleteRefreshToken (refreshToken) { + this.refreshTokens.delete(refreshToken); + } +} + +module.exports = DB; diff --git a/test/helpers/model.js b/test/helpers/model.js new file mode 100644 index 000000000..7a1893b1d --- /dev/null +++ b/test/helpers/model.js @@ -0,0 +1,92 @@ +const scopes = ['read', 'write']; + +function createModel (db) { + async function getUser (username, password) { + return db.findUser(username, password); + } + + async function getClient (clientId, clientSecret) { + return db.findClient(clientId, clientSecret); + } + + async function saveToken (token, client, user) { + const meta = { + clientId: client.id, + userId: user.id, + scope: token.scope, + accessTokenExpiresAt: token.accessTokenExpiresAt, + refreshTokenExpiresAt: token.refreshTokenExpiresAt + }; + + token.client = client; + token.user = user; + + if (token.accessToken) { + db.saveAccessToken(token.accessToken, meta); + } + + if (token.refreshToken) { + db.saveRefreshToken(token.refreshToken, meta); + } + + return token; + } + + async function getAccessToken (accessToken) { + const meta = db.findAccessToken(accessToken); + + if (!meta) { + return false; + } + + return { + accessToken, + accessTokenExpiresAt: meta.accessTokenExpiresAt, + user: db.findUserById(meta.userId), + client: db.findClientById(meta.clientId), + scope: meta.scope + }; + } + + async function getRefreshToken (refreshToken) { + const meta = db.findRefreshToken(refreshToken); + + if (!meta) { + return false; + } + + return { + refreshToken, + refreshTokenExpiresAt: meta.refreshTokenExpiresAt, + user: db.findUserById(meta.userId), + client: db.findClientById(meta.clientId), + scope: meta.scope + }; + } + + async function revokeToken (token) { + db.deleteRefreshToken(token.refreshToken); + + return true; + } + + async function verifyScope (token, scope) { + if (typeof scope === 'string') { + return scopes.includes(scope); + } else { + return scope.every(s => scopes.includes(s)); + } + } + + return { + getUser, + getClient, + saveToken, + getAccessToken, + getRefreshToken, + revokeToken, + verifyScope + }; +} + +module.exports = createModel; diff --git a/test/helpers/request.js b/test/helpers/request.js new file mode 100644 index 000000000..be556a8d5 --- /dev/null +++ b/test/helpers/request.js @@ -0,0 +1,17 @@ +const Request = require('../../lib/request'); + +module.exports = (request) => { + const req = new Request({ + query: {}, + body: {}, + headers: {}, + method: 'GET', + ...request + }); + + req.is = function (header) { + return this.headers['content-type'] === header; + }; + + return req; +}; From 3a1e4330a174ede3eae9f8bd79e7a2c6dd073ac6 Mon Sep 17 00:00:00 2001 From: Joren Vandeweyer Date: Sun, 19 Dec 2021 14:31:31 +0100 Subject: [PATCH 73/99] added warning in docs, added extra tests that actually use parameters --- docs/model/spec.rst | 5 ++ .../handlers/authorize-handler_test.js | 2 +- test/unit/handlers/authorize-handler_test.js | 46 +++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/docs/model/spec.rst b/docs/model/spec.rst index 46b649493..301ab954a 100644 --- a/docs/model/spec.rst +++ b/docs/model/spec.rst @@ -1015,6 +1015,11 @@ This model function is **optional**. If not implemented, the ``redirectUri`` sho Returns ``true`` if the ``redirectUri`` is valid, ``false`` otherwise. **Remarks:** +When implementing this method you should take care of possible security risks related to ``redirectUri``. +.. _rfc6819: https://datatracker.ietf.org/doc/html/rfc6819 + +Section-5.2.3.5 is implemented by default. +.. _Section-5.2.3.5: https://datatracker.ietf.org/doc/html/rfc6819#section-5.2.3.5 :: diff --git a/test/integration/handlers/authorize-handler_test.js b/test/integration/handlers/authorize-handler_test.js index 6ff8621a3..1ff772182 100644 --- a/test/integration/handlers/authorize-handler_test.js +++ b/test/integration/handlers/authorize-handler_test.js @@ -635,7 +635,7 @@ describe('AuthorizeHandler integration', function() { }); describe('validateRedirectUri()', function() { - it('should support empty model', function() { + it('should support empty method', function() { const model = { getAccessToken: function() {}, getClient: function() {}, diff --git a/test/unit/handlers/authorize-handler_test.js b/test/unit/handlers/authorize-handler_test.js index 2a44bc64d..376bc1e4a 100644 --- a/test/unit/handlers/authorize-handler_test.js +++ b/test/unit/handlers/authorize-handler_test.js @@ -128,5 +128,51 @@ describe('AuthorizeHandler', function() { }) .catch(should.fail); }); + + it('should be successful validation', function () { + const client = { grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] }; + const redirect_uri = 'http://example.com/cb'; + const model = { + getAccessToken: function() {}, + getClient: sinon.stub().returns(client), + saveAuthorizationCode: function() {}, + validateRedirectUri: function (redirectUri, client) { + return client.redirectUris.includes(redirectUri); + } + }; + + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { client_id: 12345, client_secret: 'secret', redirect_uri }, headers: {}, method: {}, query: {} }); + + return handler.getClient(request) + .then((client) => { + client.should.equal(client); + }); + }); + + it('should be unsuccessful validation', function () { + const client = { grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] }; + const redirect_uri = 'http://example.com/callback'; + const model = { + getAccessToken: function() {}, + getClient: sinon.stub().returns(client), + saveAuthorizationCode: function() {}, + validateRedirectUri: function (redirectUri, client) { + return client.redirectUris.includes(redirectUri); + } + }; + + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { client_id: 12345, client_secret: 'secret', redirect_uri }, headers: {}, method: {}, query: {} }); + + return handler.getClient(request) + .then(() => { + throw Error('should not resolve'); + }) + .catch((err) => { + err.name.should.equal('invalid_client'); + err.message.should.equal('Invalid client: `redirect_uri` does not match client value'); + }); + }); }); }); From 4921a1cd4b04d0398faf5d80c0f22434b2e24575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Mon, 20 Dec 2021 08:58:02 +0100 Subject: [PATCH 74/99] fix(handler): deny access when body.allowed is 'false' (#94) * fix(handler): deny access when body.allowed is 'false' * fix(authorization): use simplified if-branch to check for body allow value --- lib/handlers/authorize-handler.js | 2 +- .../handlers/authorize-handler_test.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/handlers/authorize-handler.js b/lib/handlers/authorize-handler.js index b3f1d5e5a..830bfa76d 100644 --- a/lib/handlers/authorize-handler.js +++ b/lib/handlers/authorize-handler.js @@ -77,7 +77,7 @@ AuthorizeHandler.prototype.handle = function(request, response) { throw new InvalidArgumentError('Invalid argument: `response` must be an instance of Response'); } - if ('false' === request.query.allowed) { + if (request.query.allowed === 'false' || request.body.allowed === 'false') { return Promise.reject(new AccessDeniedError('Access denied: user denied access to application')); } diff --git a/test/integration/handlers/authorize-handler_test.js b/test/integration/handlers/authorize-handler_test.js index efcdf7658..054e2cc4f 100644 --- a/test/integration/handlers/authorize-handler_test.js +++ b/test/integration/handlers/authorize-handler_test.js @@ -198,6 +198,24 @@ describe('AuthorizeHandler integration', function() { }); }); + it('should throw an error if `allowed` is `false` body', function() { + const model = { + getAccessToken: function() {}, + getClient: function() {}, + saveAuthorizationCode: function() {} + }; + const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model }); + const request = new Request({ body: { allowed: 'false' }, headers: {}, method: {}, query: {} }); + const response = new Response({ body: {}, headers: {} }); + + return handler.handle(request, response) + .then(should.fail) + .catch(function(e) { + e.should.be.an.instanceOf(AccessDeniedError); + e.message.should.equal('Access denied: user denied access to application'); + }); + }); + it('should redirect to an error response if a non-oauth error is thrown', function() { const model = { getAccessToken: function() { From 13aacce984255758a1b5f6b27b399d4488c5670e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 13 Jan 2022 09:15:21 +0100 Subject: [PATCH 75/99] feature(ci): release workflow only runs on non-draft pull requests --- .github/workflows/tests-release.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests-release.yml b/.github/workflows/tests-release.yml index 75c9236ea..7a6dce70e 100644 --- a/.github/workflows/tests-release.yml +++ b/.github/workflows/tests-release.yml @@ -5,9 +5,11 @@ on: branches: - release-* # all release- branches pull_request: + types: [review_requested, ready_for_review] # only non-draft PR branches: - release-* # all release- branches + jobs: # STEP 1 - NPM Audit @@ -27,7 +29,7 @@ jobs: uses: actions/setup-node@v1 with: node-version: 12 - - run: npm audit + - run: npm audit --production # no audit for dev dependencies # STEP 2 - basic unit tests From edd8160d753f926bcc6e4d539028711e30b5729e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 13 Jan 2022 09:20:14 +0100 Subject: [PATCH 76/99] fix(ci): use actions v2 for setting up node --- .github/workflows/tests-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests-release.yml b/.github/workflows/tests-release.yml index 7a6dce70e..b15bf6fa0 100644 --- a/.github/workflows/tests-release.yml +++ b/.github/workflows/tests-release.yml @@ -26,7 +26,7 @@ jobs: uses: actions/checkout@v2 - name: Setup node 12 - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: 12 - run: npm audit --production # no audit for dev dependencies @@ -46,7 +46,7 @@ jobs: uses: actions/checkout@v2 - name: Setup node ${{ matrix.node }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: ${{ matrix.node }} From 69a30439834e631ac70d6d61322442178f786b8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 13 Jan 2022 09:23:38 +0100 Subject: [PATCH 77/99] fix(ci): use code-ql only on non-draft releases --- .github/workflows/codeql-analysis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 33f382633..7cadbb5f9 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -14,6 +14,7 @@ name: "CodeQL Semantic Analysis" on: push: # all pushes pull_request: # all PR + types: [review_requested, ready_for_review] # only non-draft PR schedule: - cron: '0 2 * * *' # every night at 2am From 36e13ebaebcddd97f60834d9d10afd93ffc95141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 13 Jan 2022 09:26:48 +0100 Subject: [PATCH 78/99] fix(ci): fix audit job syntax error --- .github/workflows/tests-release.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests-release.yml b/.github/workflows/tests-release.yml index b15bf6fa0..422817a20 100644 --- a/.github/workflows/tests-release.yml +++ b/.github/workflows/tests-release.yml @@ -22,13 +22,10 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup node 12 - uses: actions/setup-node@v2 + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 with: - node-version: 12 + node-version: '12' - run: npm audit --production # no audit for dev dependencies # STEP 2 - basic unit tests From 4188547a590d8696e9a78e531f8369d2114768dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 13 Jan 2022 09:29:39 +0100 Subject: [PATCH 79/99] fix(ci): fix publish jobs syntax error --- .github/workflows/tests-release.yml | 38 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/.github/workflows/tests-release.yml b/.github/workflows/tests-release.yml index 422817a20..63418c5fa 100644 --- a/.github/workflows/tests-release.yml +++ b/.github/workflows/tests-release.yml @@ -120,19 +120,17 @@ jobs: runs-on: ubuntu-latest needs: [integrationtests] steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup node 12 - uses: actions/setup-node@v1 - with: - node-version: '12.x' - registry-url: 'https://registry.npmjs.org' - - run: npm install - - run: npm publish --dry-run + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: '12' + registry-url: 'https://registry.npmjs.org' + - run: npm install --production + - run: npm publish --dry-run env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + ghpubdry: needs: [integrationtests] runs-on: ubuntu-latest @@ -140,13 +138,13 @@ jobs: contents: read packages: write steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - # we always publish targeting the lowest supported node version - node-version: 12 - registry-url: $registry-url(npm) - - run: npm ci - - run: npm publish --dry-run - env: - NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} \ No newline at end of file + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + # we always publish targeting the lowest supported node version + node-version: 12 + registry-url: $registry-url(npm) + - run: npm install --prudction + - run: npm publish --dry-run + env: + NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} \ No newline at end of file From ecb072efccde7db4bd74df14db64742563c52d06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 13 Jan 2022 09:32:13 +0100 Subject: [PATCH 80/99] fix(ci): fix publish jobs syntax error --- .github/workflows/tests-release.yml | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/.github/workflows/tests-release.yml b/.github/workflows/tests-release.yml index 63418c5fa..9764e7f69 100644 --- a/.github/workflows/tests-release.yml +++ b/.github/workflows/tests-release.yml @@ -115,23 +115,21 @@ jobs: # todo repeat with other adapters - npmpubdry: - name: NPM Publish Dry-run + publish-npm-dry: runs-on: ubuntu-latest needs: [integrationtests] steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: '12' - registry-url: 'https://registry.npmjs.org' - - run: npm install --production - - run: npm publish --dry-run + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 12 + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm publish --dry-run env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - + NODE_AUTH_TOKEN: ${{secrets.npm_token}} - ghpubdry: + publish-github-dry: needs: [integrationtests] runs-on: ubuntu-latest permissions: @@ -144,7 +142,7 @@ jobs: # we always publish targeting the lowest supported node version node-version: 12 registry-url: $registry-url(npm) - - run: npm install --prudction + - run: npm ci - run: npm publish --dry-run env: NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} \ No newline at end of file From 510546b4678ac4888d20d138b393460be51a3968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 13 Jan 2022 09:46:12 +0100 Subject: [PATCH 81/99] fix(ci): fix check coverage --- .github/workflows/tests-release.yml | 6 ++---- .github/workflows/tests.yml | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tests-release.yml b/.github/workflows/tests-release.yml index 9764e7f69..20246a097 100644 --- a/.github/workflows/tests-release.yml +++ b/.github/workflows/tests-release.yml @@ -62,12 +62,10 @@ jobs: # with the following action we enforce PRs to have a high coverage # and ensure, changes are tested well enough so that coverage won't fail - name: check coverage - uses: devmasx/coverage-check-action@v1.2.0 + uses: VeryGoodOpenSource/very_good_coverage@v1.2.0 with: - type: lcov - result_path: coverage/lcov.info + path: './coverage/lcov.info' min_coverage: 95 - token: ${{github.token}} # STEP 3 - Integration tests diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a74688fef..e8b05a706 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -41,9 +41,7 @@ jobs: # with the following action we enforce PRs to have a high coverage # and ensure, changes are tested well enough so that coverage won't fail - name: check coverage - uses: devmasx/coverage-check-action@v1.2.0 + uses: VeryGoodOpenSource/very_good_coverage@v1.2.0 with: - type: lcov - result_path: coverage/lcov.info + path: './coverage/lcov.info' min_coverage: 95 - token: ${{github.token}} From 88a7bfed070ffaf22e20eab82b286c5ea8e2cbae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 13 Jan 2022 09:50:46 +0100 Subject: [PATCH 82/99] fix(ci): run workflows also only on push for non-draft PR --- .github/workflows/tests-release.yml | 1 + .github/workflows/tests.yml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.github/workflows/tests-release.yml b/.github/workflows/tests-release.yml index 20246a097..47b8f8468 100644 --- a/.github/workflows/tests-release.yml +++ b/.github/workflows/tests-release.yml @@ -2,6 +2,7 @@ name: Tests for Release on: push: + types: [review_requested, ready_for_review] # only non-draft PR branches: - release-* # all release- branches pull_request: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e8b05a706..1c6aec016 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,6 +8,8 @@ on: branches: - master # allthough master is push protected we still keep it - development + branches-ignore: + - release-* # on release we run an extended workflow so no need for this pull_request: # runs on all PR branches-ignore: - release-* # on release we run an extended workflow so no need for this From d6ec7d8ac426d0118cacc4b404f18f77322cb744 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 13 Jan 2022 09:52:14 +0100 Subject: [PATCH 83/99] fix(ci): fix tets.yml semantic error --- .github/workflows/tests.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1c6aec016..e8b05a706 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,8 +8,6 @@ on: branches: - master # allthough master is push protected we still keep it - development - branches-ignore: - - release-* # on release we run an extended workflow so no need for this pull_request: # runs on all PR branches-ignore: - release-* # on release we run an extended workflow so no need for this From e556def39e533ecffb25387f9ab591d7207fe091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 13 Jan 2022 09:54:54 +0100 Subject: [PATCH 84/99] fix(ci): release-workflow trigger on push to PR --- .github/workflows/tests-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests-release.yml b/.github/workflows/tests-release.yml index 47b8f8468..699fece81 100644 --- a/.github/workflows/tests-release.yml +++ b/.github/workflows/tests-release.yml @@ -2,11 +2,11 @@ name: Tests for Release on: push: - types: [review_requested, ready_for_review] # only non-draft PR branches: - release-* # all release- branches pull_request: - types: [review_requested, ready_for_review] # only non-draft PR + # only non-draft PR and when there are "pushes" to the open PR + types: [review_requested, ready_for_review, synchronize] branches: - release-* # all release- branches From 465b786a71efd2f5251bcdc60af3c77096138bd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 13 Jan 2022 09:58:14 +0100 Subject: [PATCH 85/99] fix(ci): add lcov reporter to test:coverage --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c0deb377e..7e6000c63 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "test": "NODE_ENV=test ./node_modules/.bin/mocha 'test/**/*_test.js'", "test-debug": "NODE_ENV=test ./node_modules/.bin/mocha --inspect --debug-brk 'test/**/*_test.js'", "test:watch": "NODE_ENV=test ./node_modules/.bin/mocha --watch 'test/**/*_test.js'", - "test:coverage": "NODE_ENV=test nyc --reporter=html --reporter=text ./node_modules/.bin/mocha 'test/**/*_test.js'", + "test:coverage": "NODE_ENV=test nyc --reporter=html --reporter=lcov --reporter=text ./node_modules/.bin/mocha 'test/**/*_test.js'", "lint": "npx eslint .", "lint:fix": "npx eslint . --fix" }, From b7867e70378f3410ed02e8b99a6fd5f1bf7d9a99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 13 Jan 2022 10:06:25 +0100 Subject: [PATCH 86/99] fix(ci): use oauthjs/express-oauth-server for integration testing --- .github/workflows/tests-release.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests-release.yml b/.github/workflows/tests-release.yml index 699fece81..f2e24154a 100644 --- a/.github/workflows/tests-release.yml +++ b/.github/workflows/tests-release.yml @@ -89,7 +89,7 @@ jobs: - name: Checkout express-adapter ${{ matrix.node }} uses: actions/checkout@v2 with: - repository: node-oauth/express-adapter + repository: oauthjs/express-oauth-server path: github/testing # place checkout for other adapters here @@ -108,9 +108,12 @@ jobs: # in order to test the adapter we need to use the current state # we just cloned and install it as local dependency - - run: cd github/testing/express-adapter && npm ci - - run: cd github/testing/express-adapter && npm install ./ - - run: cd github/testing/express-adapter && npm run tests + - run: | + PROJECT_PATH=$(pwd) + cd github/testing/express-adapter + npm ci + npm install $PROJECT_PATH + npm run test # todo repeat with other adapters From 3167a8e3d05761988c3883d448ac821d686a68de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 13 Jan 2022 10:12:38 +0100 Subject: [PATCH 87/99] fix(ci): fix path for integration test --- .github/workflows/tests-release.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/tests-release.yml b/.github/workflows/tests-release.yml index f2e24154a..930dfad03 100644 --- a/.github/workflows/tests-release.yml +++ b/.github/workflows/tests-release.yml @@ -109,10 +109,9 @@ jobs: # in order to test the adapter we need to use the current state # we just cloned and install it as local dependency - run: | - PROJECT_PATH=$(pwd) cd github/testing/express-adapter npm ci - npm install $PROJECT_PATH + npm install ../../../ npm run test # todo repeat with other adapters From c99001c9b2fe22ddf379aeba5d6b4e60ad5e28b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 13 Jan 2022 10:16:39 +0100 Subject: [PATCH 88/99] fix(ci): fix path for integration test --- .github/workflows/tests-release.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests-release.yml b/.github/workflows/tests-release.yml index 930dfad03..d74162a05 100644 --- a/.github/workflows/tests-release.yml +++ b/.github/workflows/tests-release.yml @@ -92,9 +92,8 @@ jobs: repository: oauthjs/express-oauth-server path: github/testing - # place checkout for other adapters here - name: Setup node ${{ matrix.node }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: ${{ matrix.node }} @@ -102,9 +101,9 @@ jobs: uses: actions/cache@v1 with: path: ~/.npm - key: ${{ runner.os }}-node-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }} + key: ${{ runner.os }}-node-${{ matrix.node }}-oauthjs/express-oauth-server-${{ hashFiles('github/testing/**/package-lock.json') }} restore-keys: | - ${{ runner.os }}-node-${{ matrix.node }} + ${{ runner.os }}-node-${{ matrix.node }}-oauthjs/express-oauth-server # in order to test the adapter we need to use the current state # we just cloned and install it as local dependency From fd9ead86b60d1f75a1aa74850fa31da87bab5979 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 13 Jan 2022 10:37:59 +0100 Subject: [PATCH 89/99] fix(ci): fix path for integration test --- .github/workflows/tests-release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests-release.yml b/.github/workflows/tests-release.yml index d74162a05..8f42fdbc6 100644 --- a/.github/workflows/tests-release.yml +++ b/.github/workflows/tests-release.yml @@ -90,7 +90,7 @@ jobs: uses: actions/checkout@v2 with: repository: oauthjs/express-oauth-server - path: github/testing + path: github/testing/express - name: Setup node ${{ matrix.node }} uses: actions/setup-node@v2 @@ -101,14 +101,14 @@ jobs: uses: actions/cache@v1 with: path: ~/.npm - key: ${{ runner.os }}-node-${{ matrix.node }}-oauthjs/express-oauth-server-${{ hashFiles('github/testing/**/package-lock.json') }} + key: ${{ runner.os }}-node-${{ matrix.node }}-oauthjs/express-oauth-server-${{ hashFiles('github/testing/express/**/package-lock.json') }} restore-keys: | ${{ runner.os }}-node-${{ matrix.node }}-oauthjs/express-oauth-server # in order to test the adapter we need to use the current state # we just cloned and install it as local dependency - run: | - cd github/testing/express-adapter + cd github/testing/express npm ci npm install ../../../ npm run test From aee6d92af84495977195b74cb4e9734ca0067440 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 13 Jan 2022 10:47:11 +0100 Subject: [PATCH 90/99] fix(ci): fix path for integration test --- .github/workflows/tests-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests-release.yml b/.github/workflows/tests-release.yml index 8f42fdbc6..ee434a8cd 100644 --- a/.github/workflows/tests-release.yml +++ b/.github/workflows/tests-release.yml @@ -109,6 +109,7 @@ jobs: # we just cloned and install it as local dependency - run: | cd github/testing/express + ls -la npm ci npm install ../../../ npm run test From 916c6134b487237a9e5882b422fefe715605ae29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 13 Jan 2022 10:52:56 +0100 Subject: [PATCH 91/99] fix(ci): fix path for integration test --- .github/workflows/tests-release.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/tests-release.yml b/.github/workflows/tests-release.yml index ee434a8cd..b2dab9684 100644 --- a/.github/workflows/tests-release.yml +++ b/.github/workflows/tests-release.yml @@ -109,8 +109,6 @@ jobs: # we just cloned and install it as local dependency - run: | cd github/testing/express - ls -la - npm ci npm install ../../../ npm run test From a47e867fd8d2c79c8b17e8ece05db6fe58e1c26e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 13 Jan 2022 11:05:51 +0100 Subject: [PATCH 92/99] fix(ci): use node-oauth/express-oauth-server for integration test --- .github/workflows/tests-release.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests-release.yml b/.github/workflows/tests-release.yml index b2dab9684..ff0493c3e 100644 --- a/.github/workflows/tests-release.yml +++ b/.github/workflows/tests-release.yml @@ -89,7 +89,7 @@ jobs: - name: Checkout express-adapter ${{ matrix.node }} uses: actions/checkout@v2 with: - repository: oauthjs/express-oauth-server + repository: node-oauth/express-oauth-server path: github/testing/express - name: Setup node ${{ matrix.node }} @@ -101,15 +101,16 @@ jobs: uses: actions/cache@v1 with: path: ~/.npm - key: ${{ runner.os }}-node-${{ matrix.node }}-oauthjs/express-oauth-server-${{ hashFiles('github/testing/express/**/package-lock.json') }} + key: ${{ runner.os }}-node-${{ matrix.node }}-node-oauth/express-oauth-server-${{ hashFiles('github/testing/express/**/package-lock.json') }} restore-keys: | - ${{ runner.os }}-node-${{ matrix.node }}-oauthjs/express-oauth-server + ${{ runner.os }}-node-${{ matrix.node }}-node-oauth/express-oauth-server # in order to test the adapter we need to use the current state # we just cloned and install it as local dependency - run: | cd github/testing/express npm install ../../../ + cd ../../../ npm run test # todo repeat with other adapters From 8073105a724e22fdb61fe8d790b63c04ba0105f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 13 Jan 2022 11:08:11 +0100 Subject: [PATCH 93/99] fix(ci): fix path for integration test --- .github/workflows/tests-release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/tests-release.yml b/.github/workflows/tests-release.yml index ff0493c3e..071993972 100644 --- a/.github/workflows/tests-release.yml +++ b/.github/workflows/tests-release.yml @@ -110,7 +110,6 @@ jobs: - run: | cd github/testing/express npm install ../../../ - cd ../../../ npm run test # todo repeat with other adapters From 06e6b4c9f92c6b4e2077cf131c9fbbb363004125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 13 Jan 2022 11:10:30 +0100 Subject: [PATCH 94/99] fix(ci): fix path for integration test --- .github/workflows/tests-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests-release.yml b/.github/workflows/tests-release.yml index 071993972..9949fb355 100644 --- a/.github/workflows/tests-release.yml +++ b/.github/workflows/tests-release.yml @@ -110,6 +110,7 @@ jobs: - run: | cd github/testing/express npm install ../../../ + npm install npm run test # todo repeat with other adapters From 099d063e23c96e40136313c0d5364095325956cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 13 Jan 2022 11:16:12 +0100 Subject: [PATCH 95/99] fix(ci): fix path for integration test --- .github/workflows/tests-release.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests-release.yml b/.github/workflows/tests-release.yml index 9949fb355..63be8c765 100644 --- a/.github/workflows/tests-release.yml +++ b/.github/workflows/tests-release.yml @@ -105,12 +105,13 @@ jobs: restore-keys: | ${{ runner.os }}-node-${{ matrix.node }}-node-oauth/express-oauth-server - # in order to test the adapter we need to use the current state + # in order to test the adapter we need to use the current checkout + # and install it as local dependency # we just cloned and install it as local dependency - run: | cd github/testing/express + npm ci npm install ../../../ - npm install npm run test # todo repeat with other adapters From f4bfae830123d66d830bb8327abe8ba5268ff738 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Thu, 13 Jan 2022 11:26:04 +0100 Subject: [PATCH 96/99] fix(ci): exclude node 16 to get running --- .github/workflows/tests-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests-release.yml b/.github/workflows/tests-release.yml index 63be8c765..6eba05e70 100644 --- a/.github/workflows/tests-release.yml +++ b/.github/workflows/tests-release.yml @@ -79,7 +79,7 @@ jobs: needs: [unittest] strategy: matrix: - node: [12, 14, 16] + node: [12, 14] # TODO get running for node 16 steps: # checkout this repo - name: Checkout ${{ matrix.node }} From 9c702365863fc585657538da6c930c43d22c00e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Tue, 18 Jan 2022 20:51:02 +0100 Subject: [PATCH 97/99] build(ci): add --access-public flag to npm publish --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 152375959..5acd3e1d2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,7 +29,7 @@ jobs: node-version: 12 registry-url: 'https://registry.npmjs.org/' - run: npm ci - - run: npm publish + - run: npm publish --access public env: NODE_AUTH_TOKEN: ${{secrets.npm_token}} @@ -47,6 +47,6 @@ jobs: node-version: 12 registry-url: $registry-url(npm) - run: npm ci - - run: npm publish + - run: npm publish --access public env: NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} \ No newline at end of file From c97d0e31fc1f7b81941a3942366c0f27b8c2557b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Tue, 1 Feb 2022 18:26:36 +0100 Subject: [PATCH 98/99] ci: disable release workflow until decision is made pro automated releases --- .github/workflows/release.yml | 100 +++++++++++++++++----------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5acd3e1d2..630487ec1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,52 +1,52 @@ # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created # For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages - -name: Release - -on: - release: - types: [created] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: 12 - - run: npm ci - - run: npm test - - publish-npm: - needs: build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - # we always publish targeting the lowest supported node version - node-version: 12 - registry-url: 'https://registry.npmjs.org/' - - run: npm ci - - run: npm publish --access public - env: - NODE_AUTH_TOKEN: ${{secrets.npm_token}} - - publish-gpr: - needs: build - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - # we always publish targeting the lowest supported node version - node-version: 12 - registry-url: $registry-url(npm) - - run: npm ci - - run: npm publish --access public - env: - NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} \ No newline at end of file +# +#name: Release +# +#on: +# release: +# types: [created] +# +#jobs: +# build: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v2 +# - uses: actions/setup-node@v2 +# with: +# node-version: 12 +# - run: npm ci +# - run: npm test +# +# publish-npm: +# needs: build +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v2 +# - uses: actions/setup-node@v2 +# with: +# # we always publish targeting the lowest supported node version +# node-version: 12 +# registry-url: 'https://registry.npmjs.org/' +# - run: npm ci +# - run: npm publish --access public +# env: +# NODE_AUTH_TOKEN: ${{secrets.npm_token}} +# +# publish-gpr: +# needs: build +# runs-on: ubuntu-latest +# permissions: +# contents: read +# packages: write +# steps: +# - uses: actions/checkout@v2 +# - uses: actions/setup-node@v2 +# with: +# # we always publish targeting the lowest supported node version +# node-version: 12 +# registry-url: $registry-url(npm) +# - run: npm ci +# - run: npm publish --access public +# env: +# NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} \ No newline at end of file From 08d4cd32007887cacfcdc56df7c693b1a20ead52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=BCster?= Date: Fri, 18 Mar 2022 12:05:46 +0100 Subject: [PATCH 99/99] refactor(ci): remove unused ci workflow --- .github/workflows/release.yml | 52 ----------------------------------- 1 file changed, 52 deletions(-) delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 630487ec1..000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,52 +0,0 @@ -# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created -# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages -# -#name: Release -# -#on: -# release: -# types: [created] -# -#jobs: -# build: -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v2 -# - uses: actions/setup-node@v2 -# with: -# node-version: 12 -# - run: npm ci -# - run: npm test -# -# publish-npm: -# needs: build -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v2 -# - uses: actions/setup-node@v2 -# with: -# # we always publish targeting the lowest supported node version -# node-version: 12 -# registry-url: 'https://registry.npmjs.org/' -# - run: npm ci -# - run: npm publish --access public -# env: -# NODE_AUTH_TOKEN: ${{secrets.npm_token}} -# -# publish-gpr: -# needs: build -# runs-on: ubuntu-latest -# permissions: -# contents: read -# packages: write -# steps: -# - uses: actions/checkout@v2 -# - uses: actions/setup-node@v2 -# with: -# # we always publish targeting the lowest supported node version -# node-version: 12 -# registry-url: $registry-url(npm) -# - run: npm ci -# - run: npm publish --access public -# env: -# NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} \ No newline at end of file