Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

simple-oauth2

Package Overview
Dependencies
Maintainers
2
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-oauth2 - npm Package Compare versions

Comparing version 3.3.0 to 3.4.0

lib/access-token/index.js

16

CHANGELOG.md
# 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc