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 1.0.3 to 1.1.0

3

CHANGELOG.md
# Changelog
## v1.1.0
* Add support to body encoding format in library requests
## v1.0.3

@@ -4,0 +7,0 @@ * Add missing documentation for module options

@@ -31,2 +31,3 @@ 'use strict';

options: joi.object().keys({
bodyFormat: joi.any().valid('form', 'json').default('form'),
useBasicAuthorizationHeader: joi.boolean().default(true),

@@ -33,0 +34,0 @@ useBodyAuth: joi.boolean().default(true),

@@ -56,10 +56,36 @@ 'use strict';

if (Object.keys(params).length === 0) params = null;
if (method !== 'GET') options.form = params;
if (method !== 'GET') {
if (config.options.bodyFormat === 'form') {
options.form = params;
} else if (config.options.bodyFormat === 'json') {
options.json = true;
options.body = params;
} else {
// joi should prevent us from getting here, but throw to be safe.
throw new Error(
`Unknown bodyFormat value: ${config.options.bodyFormat}`
);
}
}
if (method === 'GET') options.qs = params;
// Enable the system to send authorization params in the body
// For example github does not require to be in the header
if (config.options.useBodyAuth && options.form) {
options.form[config.client.idParamName] = config.client.id;
options.form[config.client.secretParamName] = config.client.secret;
// Enable the system to send authorization params in the body.
if (config.options.useBodyAuth) {
if (options.form) {
// An example using `form` authorization params in the body is the
// GitHub API.
options.form[config.client.idParamName] = config.client.id;
options.form[config.client.secretParamName] = config.client.secret;
} else if (options.json) {
// An example using `json` authorization params in the body is the
// Amazon Developer Publishing API.
options.body[config.client.idParamName] = config.client.id;
options.body[config.client.secretParamName] = config.client.secret;
} else {
// joi should prevent us from getting here, but throw to be safe.
throw new Error(
`Unable to write bodyAuth for bodyFormat: ${config.options.bodyFormat}`
);
}
}

@@ -66,0 +92,0 @@

2

package.json
{
"name": "simple-oauth2",
"version": "1.0.3",
"version": "1.1.0",
"description": "Node.js client for OAuth2",

@@ -5,0 +5,0 @@ "author": "Andrea Reginato <andrea.reginato@gmail.com>",

@@ -86,2 +86,3 @@ [![NPM Package Version](https://img.shields.io/npm/v/simple-oauth2.svg?style=flat-square)](https://www.npmjs.com/package/simple-oauth2)

* `options` optional object to setup the module.
- `bodyFormat` - Format of data sent in the request body. Valid values are `form` or `json`. Defaults to **form**.
- `useBodyAuth` - Whether or not the client.id/client.secret params are sent in the request body. Defaults to **true**.

@@ -88,0 +89,0 @@ - `useBasicAuthorizationHeader` - Whether or not the Basic Authorization header should be sent at the token request.

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