axios-oauth-client
Advanced tools
Comparing version 2.0.0 to 2.0.1
import qs from 'qs'; | ||
function oauth(axios, { url, ...credentials }) { | ||
return (moreCredentials = {}) => axios({ | ||
url, | ||
method: "post", | ||
data: qs.stringify({ | ||
return (moreCredentials = {}) => { | ||
const body = { | ||
...credentials, | ||
...moreCredentials | ||
}) | ||
}).then((res) => res.data); | ||
}; | ||
if ("scope" in body && !body.scope) { | ||
delete body.scope; | ||
} | ||
return axios({ | ||
url, | ||
method: "post", | ||
data: qs.stringify(body) | ||
}).then((res) => res.data); | ||
}; | ||
} | ||
oauth.authorizationCode = function(axios, url, client_id, client_secret, redirect_uri, code = null, scope = null) { | ||
return oauth(axios, { | ||
function authorizationCode(axios, url, client_id, client_secret, redirect_uri, code = null, scope = null) { | ||
const grant = oauth(axios, { | ||
url, | ||
@@ -23,25 +30,31 @@ grant_type: "authorization_code", | ||
}); | ||
}; | ||
oauth.ownerCredentials = function(axios, url, client_id, client_secret, username = null, password = null, scope = null) { | ||
return oauth(axios, { | ||
return (code2 = null, scope2 = null) => grant({ code: code2, scope: scope2 }); | ||
} | ||
function clientCredentials(axios, url, client_id, client_secret, scope = null) { | ||
const grant = oauth(axios, { | ||
url, | ||
grant_type: "password", | ||
grant_type: "client_credentials", | ||
client_id, | ||
client_secret, | ||
username, | ||
password, | ||
scope | ||
}); | ||
}; | ||
oauth.clientCredentials = function(axios, url, client_id, client_secret, scope = null) { | ||
return oauth(axios, { | ||
return (scope2) => grant(scope2 ? { scope: scope2 } : null); | ||
} | ||
function ownerCredentials(axios, url, client_id, client_secret, username = null, password = null, scope = null) { | ||
const grant = oauth(axios, { | ||
url, | ||
grant_type: "client_credentials", | ||
grant_type: "password", | ||
client_id, | ||
client_secret, | ||
username, | ||
password, | ||
scope | ||
}); | ||
}; | ||
oauth.refreshToken = function(axios, url, client_id, client_secret, refresh_token = null, scope = null) { | ||
return oauth(axios, { | ||
return (username2 = null, password2 = null, scope2 = null) => grant({ username: username2, password: password2, scope: scope2 }); | ||
} | ||
function refreshToken(axios, url, client_id, client_secret, refresh_token = null, scope = null) { | ||
const grant = oauth(axios, { | ||
url, | ||
@@ -54,4 +67,12 @@ grant_type: "refresh_token", | ||
}); | ||
return (refresh_token2 = null, scope2 = null) => grant({ refresh_token: refresh_token2, scope: scope2 }); | ||
} | ||
var index = { | ||
authorizationCode, | ||
clientCredentials, | ||
ownerCredentials, | ||
refreshToken | ||
}; | ||
export { oauth as default }; | ||
export { index as default }; |
{ | ||
"name": "axios-oauth-client", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "OAuth 2.0 client utils for axios", | ||
@@ -52,4 +52,4 @@ "author": "Jonathon Hill <jhill9693@gmail.com>", | ||
"peerDependencies": { | ||
"axios": "^1.0.0" | ||
"axios": "^1.2.1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
9880
208
0