Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Replace code.code with code.authorizationCode #220

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
3a7e198
refactor: Remove util.inherits #70
Dec 18, 2021
9460888
refactor: Remove util.inherits #70
Dec 18, 2021
60afc18
refactor: Remove util.inherits #70
Dec 19, 2021
c73b5b2
change Object.assign to spread operator
Dec 19, 2021
1d7b401
captureStackTrace removed from OAuthError constructor
Dec 19, 2021
186d85f
fix super constructor call OAuthError
Dec 21, 2021
ab48e15
OAuthError unit test
Dec 21, 2021
c2e6409
revert package.json
Feb 1, 2022
6536fe2
Merge branch 'development-upstream' into development
Jul 22, 2022
bb96022
Merge branch 'development' into development
jankapunkt Mar 21, 2023
f2f6c21
Merge branch 'master' into development
jankapunkt Jun 6, 2023
e00a630
Update authorization-code-grant-type.js
jankapunkt Jun 8, 2023
9fd04f6
refactor(deps): remove util.inherits #70
jankapunkt Jun 8, 2023
126ceff
breaking(deps): remove bluebird and promisify-any
jankapunkt Jun 9, 2023
5454497
docs: add 5.0.0 to changelog
jankapunkt Jun 9, 2023
085b13d
docs: add 5.x note to readme
jankapunkt Jun 9, 2023
2627848
docs: add 5.x to security policy
jankapunkt Jun 9, 2023
cf2adba
build(core): bump node 14 to 16
jankapunkt Jun 9, 2023
2563e7b
fix: replace Promise. calls in async functions with native behaviour
jankapunkt Jun 13, 2023
e1fdc23
fix(tests): replace Promise. calls with native async behaviour where …
jankapunkt Jun 13, 2023
18c6663
build(deps-dev): bump sinon from 15.1.0 to 15.2.0
dependabot[bot] Jun 20, 2023
0448856
Merge branch 'development' into dependabot/npm_and_yarn/sinon-15.2.0
jankapunkt Jun 22, 2023
3d766a7
refactor: use native promises and async/await, drop bluebird and prom…
jankapunkt Jun 22, 2023
1e8a156
build(deps-dev): bump eslint from 8.42.0 to 8.44.0
dependabot[bot] Jul 3, 2023
64da4eb
Merge branch 'development' into dependabot/npm_and_yarn/sinon-15.2.0
jankapunkt Jul 13, 2023
ececdd1
Merge branch 'development' into dependabot/npm_and_yarn/eslint-8.44.0
jankapunkt Jul 13, 2023
7b940ec
Merge pull request #195 from node-oauth/dependabot/npm_and_yarn/eslin…
jankapunkt Jul 15, 2023
7ca480e
build(deps-dev): bump eslint from 8.42.0 to 8.46.0
dependabot[bot] Jul 28, 2023
dd2f9b8
Merge branch 'development' into dependabot/npm_and_yarn/eslint-8.46.0
jankapunkt Aug 2, 2023
18caaba
Merge branch 'development' into dependabot/npm_and_yarn/sinon-15.2.0
jankapunkt Aug 2, 2023
35e056d
Merge pull request #201 from node-oauth/dependabot/npm_and_yarn/eslin…
jankapunkt Aug 2, 2023
4b0459e
Merge pull request #193 from node-oauth/dependabot/npm_and_yarn/sinon…
jankapunkt Aug 2, 2023
bf2dae9
build(deps-dev): bump sinon from 15.1.0 to 15.2.0
dependabot[bot] Aug 2, 2023
68d01ad
Marked verifyScope function as optional in model types.
shrihari-prakash Aug 4, 2023
6c4f73a
Fix PR comments.
shrihari-prakash Aug 4, 2023
1718df3
Merge branch 'development' into verify-scope-fix
jankapunkt Aug 4, 2023
e29410b
types: marked verifyScope function as optional #209 fix #202
jankapunkt Aug 4, 2023
320f947
Merge pull request #206 from node-oauth/dependabot/npm_and_yarn/sinon…
jankapunkt Aug 7, 2023
176e49c
Docs: Replace `code.code` with `code.authorizationCode`
menewman Aug 15, 2023
b6ea526
Also update sample implementation of getAuthorizationCode
menewman Aug 15, 2023
ad76316
Merge branch 'master' into fix-replace-code-with-authorization-code-i…
jankapunkt Aug 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .mocharc.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
recursive: true
reporter: "spec"
retries: 1
retries: 0
slow: 20
timeout: 2000
ui: "bdd"
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
## Changelog

## 5.0.0

- removed `bluebird` and `promisify-any`
- uses native Promises and `async/await` everywhere
- drop support for Node 14 (EOL), setting Node 16 as `engine` in `package.json`
- this is a breaking change, because **it removes callback support** for
`OAuthServer` and your model implementation.

## 4.2.0
### Fixed
- fix(core): Bearer regular expression matching in authenticate handler #105
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ Most users should refer to our [Express (active)](https://github.com/node-oauth/

More examples can be found here: https://github.com/14gasher/oauth-example

## Version 5 notes

Beginning with version `5.x` we removed dual support for callbacks and promises.
With this version there is only support for Promises / async/await.

With this version we also bumped the `engine` to Node 16 as 14 is now deprecated.

## Migrating from OAuthJs and 3.x

Version 4.x should not be hard-breaking, however, there were many improvements and fixes that may
Expand Down
11 changes: 6 additions & 5 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
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: |
| Version | Supported |
|---------|--------------------------------------------------|
| 5.x.x | :white_check_mark: |
| 4.x.x | :white_check_mark: but only high severity issues |
| 3.x.x | :x: |
| < 3 | :x: |

## Reporting a Vulnerability

Expand Down
80 changes: 41 additions & 39 deletions docs/model/spec.rst
Original file line number Diff line number Diff line change
Expand Up @@ -326,25 +326,25 @@ This model function is **required** if the ``authorization_code`` grant is used.

An ``Object`` representing the authorization code and associated data.

+--------------------+--------+--------------------------------------------------------------+
| Name | Type | Description |
+====================+========+==============================================================+
| code | Object | The return value. |
+--------------------+--------+--------------------------------------------------------------+
| code.code | String | The authorization code passed to ``getAuthorizationCode()``. |
+--------------------+--------+--------------------------------------------------------------+
| code.expiresAt | Date | The expiry time of the authorization code. |
+--------------------+--------+--------------------------------------------------------------+
| [code.redirectUri] | String | The redirect URI of the authorization code. |
+--------------------+--------+--------------------------------------------------------------+
| [code.scope] | String | The authorized scope of the authorization code. |
+--------------------+--------+--------------------------------------------------------------+
| code.client | Object | The client associated with the authorization code. |
+--------------------+--------+--------------------------------------------------------------+
| code.client.id | String | A unique string identifying the client. |
+--------------------+--------+--------------------------------------------------------------+
| code.user | Object | The user associated with the authorization code. |
+--------------------+--------+--------------------------------------------------------------+
+--------------------+--------+------------------------------------------------------------------+
| Name | Type | Description |
+====================+========+==================================================================+
| code | Object | The return value. |
+--------------------+--------+------------------------------------------------------------------+
| code.authorizationCode | String | The authorization code passed to ``getAuthorizationCode()``. |
+--------------------+--------+------------------------------------------------------------------+
| code.expiresAt | Date | The expiry time of the authorization code. |
+--------------------+--------+------------------------------------------------------------------+
| [code.redirectUri] | String | The redirect URI of the authorization code. |
+--------------------+--------+------------------------------------------------------------------+
| [code.scope] | String | The authorized scope of the authorization code. |
+--------------------+--------+------------------------------------------------------------------+
| code.client | Object | The client associated with the authorization code. |
+--------------------+--------+------------------------------------------------------------------+
| code.client.id | String | A unique string identifying the client. |
+--------------------+--------+------------------------------------------------------------------+
| code.user | Object | The user associated with the authorization code. |
+--------------------+--------+------------------------------------------------------------------+

``code.client`` and ``code.user`` can carry additional properties that will be ignored by *oauth2-server*.

Expand All @@ -364,7 +364,7 @@ An ``Object`` representing the authorization code and associated data.
})
.spread(function(code, client, user) {
return {
code: code.authorization_code,
authorizationCode: code.authorization_code,
expiresAt: code.expires_at,
redirectUri: code.redirect_uri,
scope: code.scope,
Expand Down Expand Up @@ -792,25 +792,27 @@ This model function is **required** if the ``authorization_code`` grant is used.

**Arguments:**

+--------------------+----------+---------------------------------------------------------------------+
| Name | Type | Description |
+====================+==========+=====================================================================+
| code | Object | The return value. |
+--------------------+----------+---------------------------------------------------------------------+
| code.code | String | The authorization code. |
+--------------------+----------+---------------------------------------------------------------------+
| code.expiresAt | Date | The expiry time of the authorization code. |
+--------------------+----------+---------------------------------------------------------------------+
| [code.redirectUri] | String | The redirect URI of the authorization code. |
+--------------------+----------+---------------------------------------------------------------------+
| [code.scope] | String | The authorized scope of the authorization code. |
+--------------------+----------+---------------------------------------------------------------------+
| code.client | Object | The client associated with the authorization code. |
+--------------------+----------+---------------------------------------------------------------------+
| code.client.id | String | A unique string identifying the client. |
+--------------------+----------+---------------------------------------------------------------------+
| code.user | Object | The user associated with the authorization code. |
+--------------------+----------+---------------------------------------------------------------------+
+--------------------+----------+-------------------------------------------------------------------------+
| Name | Type | Description |
+====================+==========+=========================================================================+
| code | Object | The code to be revoked. |
+--------------------+----------+-------------------------------------------------------------------------+
| code.authorizationCode | String | The authorization code. |
+--------------------+----------+-------------------------------------------------------------------------+
| code.expiresAt | Date | The expiry time of the authorization code. |
+--------------------+----------+-------------------------------------------------------------------------+
| [code.redirectUri] | String | The redirect URI of the authorization code. |
+--------------------+----------+-------------------------------------------------------------------------+
| [code.scope] | String | The authorized scope of the authorization code. |
+--------------------+----------+-------------------------------------------------------------------------+
| code.client | Object | The client associated with the authorization code. |
+--------------------+----------+-------------------------------------------------------------------------+
| code.client.id | String | A unique string identifying the client. |
+--------------------+----------+-------------------------------------------------------------------------+
| code.user | Object | The user associated with the authorization code. |
+--------------------+----------+-------------------------------------------------------------------------+
| [callback] | Function | Node-style callback to be used instead of the returned ``Promise``. |
+--------------------+----------+-------------------------------------------------------------------------+

**Return value:**

Expand Down
3 changes: 2 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,10 @@ declare namespace OAuth2Server {

/**
* Invoked during request authentication to check if the provided access token was authorized the requested scopes.
* Optional, if a custom authenticateHandler is used or if there is no scope part of the request.
*
*/
verifyScope(token: Token, scope: string | string[], callback?: Callback<boolean>): Promise<boolean>;
verifyScope?(token: Token, scope: string | string[], callback?: Callback<boolean>): Promise<boolean>;
}

interface AuthorizationCodeModel extends BaseModel, RequestAuthenticationModel {
Expand Down
22 changes: 9 additions & 13 deletions lib/errors/access-denied-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

const OAuthError = require('./oauth-error');
const util = require('util');

/**
* Constructor.
Expand All @@ -15,21 +14,18 @@ const util = require('util');
* @see https://tools.ietf.org/html/rfc6749#section-4.1.2.1
*/

function AccessDeniedError(message, properties) {
properties = Object.assign({
code: 400,
name: 'access_denied'
}, properties);
class AccessDeniedError extends OAuthError {
constructor(message, properties) {
properties = {
code: 400,
name: 'access_denied',
...properties
};

OAuthError.call(this, message, properties);
super(message, properties);
}
}

/**
* Inherit prototype.
*/

util.inherits(AccessDeniedError, OAuthError);

/**
* Export constructor.
*/
Expand Down
22 changes: 9 additions & 13 deletions lib/errors/insufficient-scope-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

const OAuthError = require('./oauth-error');
const util = require('util');

/**
* Constructor.
Expand All @@ -15,21 +14,18 @@ const util = require('util');
* @see https://tools.ietf.org/html/rfc6750.html#section-3.1
*/

function InsufficientScopeError(message, properties) {
properties = Object.assign({
code: 403,
name: 'insufficient_scope'
}, properties);
class InsufficientScopeError extends OAuthError {
constructor(message, properties) {
properties = {
code: 403,
name: 'insufficient_scope',
...properties
};

OAuthError.call(this, message, properties);
super(message, properties);
}
}

/**
* Inherit prototype.
*/

util.inherits(InsufficientScopeError, OAuthError);

/**
* Export constructor.
*/
Expand Down
22 changes: 9 additions & 13 deletions lib/errors/invalid-argument-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,23 @@
*/

const OAuthError = require('./oauth-error');
const util = require('util');

/**
* Constructor.
*/

function InvalidArgumentError(message, properties) {
properties = Object.assign({
code: 500,
name: 'invalid_argument'
}, properties);
class InvalidArgumentError extends OAuthError {
constructor(message, properties) {
properties = {
code: 500,
name: 'invalid_argument',
...properties
};

OAuthError.call(this, message, properties);
super(message, properties);
}
}

/**
* Inherit prototype.
*/

util.inherits(InvalidArgumentError, OAuthError);

/**
* Export constructor.
*/
Expand Down
22 changes: 9 additions & 13 deletions lib/errors/invalid-client-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

const OAuthError = require('./oauth-error');
const util = require('util');

/**
* Constructor.
Expand All @@ -16,21 +15,18 @@ const util = require('util');
* @see https://tools.ietf.org/html/rfc6749#section-5.2
*/

function InvalidClientError(message, properties) {
properties = Object.assign({
code: 400,
name: 'invalid_client'
}, properties);
class InvalidClientError extends OAuthError {
constructor(message, properties) {
properties = {
code: 400,
name: 'invalid_client',
...properties
};

OAuthError.call(this, message, properties);
super(message, properties);
}
}

/**
* Inherit prototype.
*/

util.inherits(InvalidClientError, OAuthError);

/**
* Export constructor.
*/
Expand Down
22 changes: 9 additions & 13 deletions lib/errors/invalid-grant-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

const OAuthError = require('./oauth-error');
const util = require('util');

/**
* Constructor.
Expand All @@ -17,21 +16,18 @@ const util = require('util');
* @see https://tools.ietf.org/html/rfc6749#section-5.2
*/

function InvalidGrantError(message, properties) {
properties = Object.assign({
code: 400,
name: 'invalid_grant'
}, properties);
class InvalidGrantError extends OAuthError {
constructor(message, properties) {
properties = {
code: 400,
name: 'invalid_grant',
...properties
};

OAuthError.call(this, message, properties);
super(message, properties);
}
}

/**
* Inherit prototype.
*/

util.inherits(InvalidGrantError, OAuthError);

/**
* Export constructor.
*/
Expand Down
22 changes: 9 additions & 13 deletions lib/errors/invalid-request-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

const OAuthError = require('./oauth-error');
const util = require('util');

/**
* Constructor.
Expand All @@ -16,21 +15,18 @@ const util = require('util');
* @see https://tools.ietf.org/html/rfc6749#section-4.2.2.1
*/

function InvalidRequest(message, properties) {
properties = Object.assign({
code: 400,
name: 'invalid_request'
}, properties);
class InvalidRequest extends OAuthError {
constructor(message, properties) {
properties = {
code: 400,
name: 'invalid_request',
...properties
};

OAuthError.call(this, message, properties);
super(message, properties);
}
}

/**
* Inherit prototype.
*/

util.inherits(InvalidRequest, OAuthError);

/**
* Export constructor.
*/
Expand Down
Loading
Loading