client-oauth2
Advanced tools
Comparing version 4.2.5 to 4.3.0
{ | ||
"name": "client-oauth2", | ||
"version": "4.2.5", | ||
"version": "4.3.0", | ||
"description": "Straight-forward execution of OAuth 2.0 flows and authenticated API requests", | ||
@@ -44,29 +44,27 @@ "main": "src/client-oauth2.js", | ||
"devDependencies": { | ||
"body-parser": "^1.15.2", | ||
"browserify": "^16.1.1", | ||
"body-parser": "^1.19.0", | ||
"browserify": "^16.5.0", | ||
"chai": "^4.1.2", | ||
"cors": "^2.8.1", | ||
"envify": "^4.0.0", | ||
"es6-promise": "^4.2.4", | ||
"express": "^4.14.0", | ||
"es6-promise": "^4.2.8", | ||
"express": "^4.17.1", | ||
"is-travis": "^2.0.0", | ||
"karma": "^4.1.0", | ||
"karma-browserify": "^6.0.0", | ||
"karma": "^5.0.3", | ||
"karma-browserify": "^7.0.0", | ||
"karma-chai": "^0.1.0", | ||
"karma-chrome-launcher": "^2.0.0", | ||
"karma-chrome-launcher": "^3.1.0", | ||
"karma-cli": "^2.0.0", | ||
"karma-coverage": "^1.1.2", | ||
"karma-firefox-launcher": "^1.0.0", | ||
"karma-mocha": "^1.1.1", | ||
"karma-phantomjs-launcher": "^1.0.0", | ||
"mocha": "^6.1.4", | ||
"karma-coverage": "^2.0.1", | ||
"karma-firefox-launcher": "^1.3.0", | ||
"karma-mocha": "^2.0.1", | ||
"mocha": "^7.1.0", | ||
"object-assign": "^4.1.1", | ||
"phantomjs-prebuilt": "^2.1.4", | ||
"standard": "^12.0.0", | ||
"watchify": "^3.7.0" | ||
"standard": "^14.3.3", | ||
"watchify": "^3.11.1" | ||
}, | ||
"dependencies": { | ||
"popsicle": "12.0.4", | ||
"safe-buffer": "^5.1.1" | ||
"popsicle": "^12.0.5", | ||
"safe-buffer": "^5.2.0" | ||
} | ||
} |
var Buffer = require('safe-buffer').Buffer | ||
var Querystring = require('querystring') | ||
var Url = require('url') | ||
var defaultRequest = require('./request') | ||
const DEFAULT_URL_BASE = 'https://example.org/' | ||
var btoa | ||
@@ -22,3 +23,3 @@ if (typeof Buffer === 'function') { | ||
var DEFAULT_HEADERS = { | ||
'Accept': 'application/json, application/x-www-form-urlencoded', | ||
Accept: 'application/json, application/x-www-form-urlencoded', | ||
'Content-Type': 'application/x-www-form-urlencoded' | ||
@@ -33,3 +34,3 @@ } | ||
var ERROR_RESPONSES = { | ||
'invalid_request': [ | ||
invalid_request: [ | ||
'The request is missing a required parameter, includes an', | ||
@@ -39,3 +40,3 @@ 'invalid parameter value, includes a parameter more than', | ||
].join(' '), | ||
'invalid_client': [ | ||
invalid_client: [ | ||
'Client authentication failed (e.g., unknown client, no', | ||
@@ -45,3 +46,3 @@ 'client authentication included, or unsupported', | ||
].join(' '), | ||
'invalid_grant': [ | ||
invalid_grant: [ | ||
'The provided authorization grant (e.g., authorization', | ||
@@ -53,21 +54,21 @@ 'code, resource owner credentials) or refresh token is', | ||
].join(' '), | ||
'unauthorized_client': [ | ||
unauthorized_client: [ | ||
'The client is not authorized to request an authorization', | ||
'code using this method.' | ||
].join(' '), | ||
'unsupported_grant_type': [ | ||
unsupported_grant_type: [ | ||
'The authorization grant type is not supported by the', | ||
'authorization server.' | ||
].join(' '), | ||
'access_denied': [ | ||
access_denied: [ | ||
'The resource owner or authorization server denied the request.' | ||
].join(' '), | ||
'unsupported_response_type': [ | ||
unsupported_response_type: [ | ||
'The authorization server does not support obtaining', | ||
'an authorization code using this method.' | ||
].join(' '), | ||
'invalid_scope': [ | ||
invalid_scope: [ | ||
'The requested scope is invalid, unknown, or malformed.' | ||
].join(' '), | ||
'server_error': [ | ||
server_error: [ | ||
'The authorization server encountered an unexpected', | ||
@@ -79,3 +80,3 @@ 'condition that prevented it from fulfilling the request.', | ||
].join(' '), | ||
'temporarily_unavailable': [ | ||
temporarily_unavailable: [ | ||
'The authorization server is currently unable to handle', | ||
@@ -473,4 +474,4 @@ 'the request due to a temporary overloading or maintenance', | ||
var options = Object.assign({}, this.client.options, opts) | ||
var url = typeof uri === 'object' ? uri : Url.parse(uri, true) | ||
var expectedUrl = Url.parse(options.redirectUri) | ||
var url = typeof uri === 'object' ? uri : new URL(uri, DEFAULT_URL_BASE) | ||
var expectedUrl = new URL(options.redirectUri, DEFAULT_URL_BASE) | ||
@@ -494,3 +495,3 @@ if (typeof url.pathname === 'string' && url.pathname !== expectedUrl.pathname) { | ||
{}, | ||
typeof url.query === 'string' ? Querystring.parse(url.query) : (url.query || {}), | ||
typeof url.search === 'string' ? Querystring.parse(url.search.substr(1)) : (url.search || {}), | ||
typeof url.hash === 'string' ? Querystring.parse(url.hash.substr(1)) : (url.hash || {}) | ||
@@ -591,3 +592,3 @@ ) | ||
var url = typeof uri === 'object' ? uri : Url.parse(uri, true) | ||
var url = typeof uri === 'object' ? uri : new URL(uri, DEFAULT_URL_BASE) | ||
@@ -597,3 +598,3 @@ if ( | ||
typeof url.pathname === 'string' && | ||
url.pathname !== Url.parse(options.redirectUri).pathname | ||
url.pathname !== (new URL(options.redirectUri, DEFAULT_URL_BASE)).pathname | ||
) { | ||
@@ -605,7 +606,9 @@ return Promise.reject( | ||
if (!url.query) { | ||
if (!url.search || !url.search.substr(1)) { | ||
return Promise.reject(new TypeError('Unable to process uri: ' + uri)) | ||
} | ||
var data = typeof url.query === 'string' ? Querystring.parse(url.query) : (url.query || {}) | ||
var data = typeof url.search === 'string' | ||
? Querystring.parse(url.search.substr(1)) | ||
: (url.search || {}) | ||
var err = getAuthError(data) | ||
@@ -677,3 +680,3 @@ | ||
if (options.clientId) { | ||
headers['Authorization'] = auth(options.clientId, options.clientSecret) | ||
headers.Authorization = auth(options.clientId, options.clientSecret) | ||
} | ||
@@ -680,0 +683,0 @@ |
33604
20
99940
746
+ Addedpopsicle@12.1.2(transitive)
+ Addedpopsicle-transport-xhr@2.0.0(transitive)
- Removedip-regex@2.1.0(transitive)
- Removedpopsicle@12.0.4(transitive)
- Removedpopsicle-transport-xhr@1.0.2(transitive)
- Removedtough-cookie@3.0.1(transitive)
Updatedpopsicle@^12.0.5
Updatedsafe-buffer@^5.2.0