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

client-oauth2

Package Overview
Dependencies
Maintainers
2
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

client-oauth2 - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

3

package.json
{
"name": "client-oauth2",
"version": "3.0.0",
"version": "3.0.1",
"description": "Straight-forward execution of OAuth 2.0 flows and authenticated API requests",

@@ -62,4 +62,5 @@ "main": "src/client-oauth2.js",

"dependencies": {
"popsicle": "^8.2.0",
"xtend": "^4.0.1"
}
}

@@ -33,3 +33,3 @@ # Client OAuth 2.0

**P.S.** The second argument to the constructor can inject a custom request function, and the third argument can inject a custom `Promise` implementation.
**P.S.** The second argument to the constructor can inject a custom request function.

@@ -89,3 +89,3 @@ ### Options (global and method-based)

app.get('/auth/github/callback', function (req, res) {
githubAuth.code.getToken(req.url)
githubAuth.code.getToken(req.originalUrl)
.then(function (user) {

@@ -92,0 +92,0 @@ console.log(user) //=> { accessToken: '...', tokenType: 'bearer', ... }

@@ -211,5 +211,4 @@ var extend = require('xtend')

*/
function ClientOAuth2 (options, request, Promise) {
function ClientOAuth2 (options, request) {
this.options = options
this.Promise = Promise || global.Promise
this.request = request || defaultRequest

@@ -222,6 +221,2 @@

this.jwt = new JwtBearerFlow(this)
if (typeof this.Promise !== 'function') {
throw new TypeError('A `Promise` implementation is required for `ClientOAuth2` to work')
}
}

@@ -272,3 +267,3 @@

return this.request(options.method, url, body, options.headers, this.Promise)
return this.request(options.method, url, body, options.headers)
.then(function (res) {

@@ -275,0 +270,0 @@ if (res.status < 200 || res.status >= 399) {

@@ -8,6 +8,5 @@ /**

* @param {Object} headers
* @param {Promise} Promise
* @returns {Promise}
*/
module.exports = function request (method, url, body, headers, Promise) {
module.exports = function request (method, url, body, headers) {
return new Promise(function (resolve, reject) {

@@ -14,0 +13,0 @@ var xhr = new window.XMLHttpRequest()

@@ -1,8 +0,5 @@

var http = require('http')
var https = require('https')
var Url = require('url')
var createUnzip = require('zlib').createUnzip
var popsicle = require('popsicle')
/**
* Make a request using node HTTP(s).
* Make a request using node.
*

@@ -13,45 +10,16 @@ * @param {String} method

* @param {Object} headers
* @param {Promise} Promise
* @returns {Promise}
*/
module.exports = function request (method, url, body, headers, Promise) {
return new Promise(function (resolve, reject) {
var requestOptions = Url.parse(url)
var lib = requestOptions.protocol === 'https:' ? https : http
requestOptions.method = method
requestOptions.headers = headers
// Send the http request and listen for the response to finish.
var request = lib.request(requestOptions, function (res) {
var data = ''
var stream = res
var encoding = res.headers['content-encoding']
if (encoding === 'deflate' || encoding === 'gzip') {
var unzip = createUnzip()
unzip.on('error', reject)
stream.pipe(unzip)
stream = unzip
}
stream.on('error', reject)
stream.on('data', function (chunk) {
data += chunk
})
stream.on('end', function () {
return resolve({
status: res.statusCode,
body: data
})
})
})
request.on('error', reject)
request.write(body)
request.end()
module.exports = function request (method, url, body, headers) {
return popsicle.get({
url: url,
body: body,
method: method,
headers: headers
}).then(function (res) {
return {
status: res.status,
body: res.body
}
})
}
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