simple-oauth2
Advanced tools
Comparing version 3.3.0 to 3.4.0
# Changelog | ||
## Next | ||
### 3.3.0 | ||
## 3.4.0 | ||
### Improvements | ||
* [#301](https://github.com/lelylan/simple-oauth2/pull/301) Refactor module schema to reuse constants across the codebase | ||
* [#302](https://github.com/lelylan/simple-oauth2/pull/302) Extract access token parsing functionality from token class | ||
* [#310](https://github.com/lelylan/simple-oauth2/pull/310) [#312](https://github.com/lelylan/simple-oauth2/pull/312) Change how date-fns is imported do make it compatible with webpack | ||
### Maintainance | ||
* [#303](https://github.com/lelylan/simple-oauth2/pull/303) [#304](https://github.com/lelylan/simple-oauth2/pull/304) Add more references to API documentation on library README | ||
* [#306](https://github.com/lelylan/simple-oauth2/pull/306) Add documentation for URL resolution on host/paths configurations | ||
* [#307](https://github.com/lelylan/simple-oauth2/pull/307) Replace travis CI with github actions | ||
## 3.3.0 | ||
* [#299](https://github.com/lelylan/simple-oauth2/pull/299) Add support to verify for token expiration with a custom expiration window | ||
@@ -36,3 +48,3 @@ * [#300](https://github.com/lelylan/simple-oauth2/pull/300) Add support to set the header credentials' encoding mode with `options.credentialsEncodingMode`. | ||
* [#260](https://github.com/lelylan/simple-oauth2/pull/260) Use new Node.js WHATWG URL api instead of the legacy url module. This change affects how `auth.authorizeHost` and `auth.authorizePath` are resolved when using the `authorizationCode.authorizeURL` method. | ||
* [#260](https://github.com/lelylan/simple-oauth2/pull/260) Use new [Node.js WHATWG URL](https://nodejs.org/dist/latest-v12.x/docs/api/url.html#url_constructor_new_url_input_base) api instead of the legacy url module. This change affects how `auth.authorizeHost` and `auth.authorizePath` are resolved when using the `authorizationCode.authorizeURL` method. | ||
@@ -39,0 +51,0 @@ * [#256](https://github.com/lelylan/simple-oauth2/pull/256) Users can override the `grant_type` parameter when performing a token exchange throught the `.getToken` method. Useful in cases where the auth server uses a value different from the standard. |
64
index.js
@@ -9,2 +9,3 @@ 'use strict'; | ||
const AccessToken = require('./lib/access-token'); | ||
const { authorizationMethodEnum, bodyFormatEnum, encodingModeEnum } = require('./lib/request-options'); | ||
@@ -14,27 +15,40 @@ // https://tools.ietf.org/html/draft-ietf-oauth-v2-31#appendix-A.1 | ||
const optionsSchema = Joi | ||
.object() | ||
.keys({ | ||
client: Joi.object().keys({ | ||
id: Joi.string().pattern(vsCharRegEx).allow(''), | ||
secret: Joi.string().pattern(vsCharRegEx).allow(''), | ||
secretParamName: Joi.string().default('client_secret'), | ||
idParamName: Joi.string().default('client_id'), | ||
}).required(), | ||
auth: Joi.object().keys({ | ||
tokenHost: Joi.string().required().uri({ scheme: ['http', 'https'] }), | ||
tokenPath: Joi.string().default('/oauth/token'), | ||
revokePath: Joi.string().default('/oauth/revoke'), | ||
authorizeHost: Joi.string().uri({ scheme: ['http', 'https'] }).default(Joi.ref('tokenHost')), | ||
authorizePath: Joi.string().default('/oauth/authorize'), | ||
}).required(), | ||
http: Joi.object().unknown(true), | ||
options: Joi.object().keys({ | ||
scopeSeparator: Joi.string().default(' '), | ||
credentialsEncodingMode: Joi.string().valid('strict', 'loose').default('strict'), | ||
bodyFormat: Joi.string().valid('form', 'json').default('form'), | ||
authorizationMethod: Joi.any().valid('header', 'body').default('header'), | ||
}).default(), | ||
}); | ||
const clientSchema = Joi.object().keys({ | ||
id: Joi.string().pattern(vsCharRegEx).allow(''), | ||
secret: Joi.string().pattern(vsCharRegEx).allow(''), | ||
secretParamName: Joi.string().default('client_secret'), | ||
idParamName: Joi.string().default('client_id'), | ||
}).required(); | ||
const authSchema = Joi.object().keys({ | ||
tokenHost: Joi.string().required().uri({ scheme: ['http', 'https'] }), | ||
tokenPath: Joi.string().default('/oauth/token'), | ||
revokePath: Joi.string().default('/oauth/revoke'), | ||
authorizeHost: Joi.string().uri({ scheme: ['http', 'https'] }).default(Joi.ref('tokenHost')), | ||
authorizePath: Joi.string().default('/oauth/authorize'), | ||
}).required(); | ||
const optionsSchema = Joi.object().keys({ | ||
scopeSeparator: Joi.string().default(' '), | ||
credentialsEncodingMode: Joi | ||
.string() | ||
.valid(...Object.values(encodingModeEnum)) | ||
.default(encodingModeEnum.STRICT), | ||
bodyFormat: Joi | ||
.string() | ||
.valid(...Object.values(bodyFormatEnum)) | ||
.default(bodyFormatEnum.FORM), | ||
authorizationMethod: Joi | ||
.string() | ||
.valid(...Object.values(authorizationMethodEnum)) | ||
.default(authorizationMethodEnum.HEADER), | ||
}).default(); | ||
const moduleOptionsSchema = Joi.object().keys({ | ||
client: clientSchema, | ||
auth: authSchema, | ||
http: Joi.object().unknown(true), | ||
options: optionsSchema, | ||
}); | ||
module.exports = { | ||
@@ -48,3 +62,3 @@ | ||
create(opts = {}) { | ||
const options = Joi.attempt(opts, optionsSchema, 'Invalid options provided to simple-oauth2'); | ||
const options = Joi.attempt(opts, moduleOptionsSchema, 'Invalid options provided to simple-oauth2'); | ||
const client = new Client(options); | ||
@@ -51,0 +65,0 @@ |
@@ -6,3 +6,3 @@ 'use strict'; | ||
const debug = require('debug')('simple-oauth2:client'); | ||
const RequestOptions = require('./request-options'); | ||
const { RequestOptions } = require('./request-options'); | ||
@@ -9,0 +9,0 @@ const defaultHttpHeaders = { |
{ | ||
"name": "simple-oauth2", | ||
"version": "3.3.0", | ||
"version": "3.4.0", | ||
"description": "Node.js client for OAuth2", | ||
@@ -5,0 +5,0 @@ "author": "Andrea Reginato <andrea.reginato@gmail.com>", |
@@ -5,2 +5,3 @@ # Simple OAuth2 | ||
[![Build Status](https://img.shields.io/travis/lelylan/simple-oauth2.svg?style=flat-square)](https://travis-ci.org/lelylan/simple-oauth2) | ||
[![Build Status](https://github.com/lelylan/simple-oauth2/workflows/Node.js%20CI/badge.svg)](https://github.com/lelylan/simple-oauth2/actions) | ||
[![Dependency Status](https://img.shields.io/david/lelylan/simple-oauth2.svg?style=flat-square)](https://david-dm.org/lelylan/simple-oauth2) | ||
@@ -65,2 +66,3 @@ | ||
``` | ||
For more detailed configuration information see [API Documentation](./API.md) | ||
@@ -67,0 +69,0 @@ ### OAuth2 Supported grants |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37145
13
421
301
205866
1