Skip to content

Commit 0d8aa97

Browse files
dependabot-preview[bot]thomheymannThomas Heymann
authored
Bump simple-oauth2 from 1.6.0 to 3.4.0 (#49)
* Bump simple-oauth2 from 1.6.0 to 3.4.0 Bumps [simple-oauth2](https://github.com/lelylan/simple-oauth2) from 1.6.0 to 3.4.0. - [Release notes](https://github.com/lelylan/simple-oauth2/releases) - [Changelog](https://github.com/lelylan/simple-oauth2/blob/master/CHANGELOG.md) - [Commits](lelylan/simple-oauth2@1.6.0...3.4.0) Signed-off-by: dependabot-preview[bot] <[email protected]> * Upgrade dependencies (#51) Co-authored-by: Thomas Heymann <[email protected]> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Thomas Heymann <[email protected]> Co-authored-by: Thomas Heymann <[email protected]>
1 parent 2bef690 commit 0d8aa97

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const fp = require('fastify-plugin')
66
const oauth2Module = require('simple-oauth2')
77

88
const promisify = require('util').promisify || require('es6-promisify').promisify
9+
const callbackify = require('util').callbackify
910

1011
function defaultGenerateStateFunction () {
1112
return defaultState
@@ -73,10 +74,10 @@ const oauthPlugin = fp(function (fastify, options, next) {
7374
}
7475

7576
const cbk = function (o, code, callback) {
76-
return o.oauth2.authorizationCode.getToken({
77+
return callbackify(o.oauth2.authorizationCode.getToken.bind(o.oauth2.authorizationCode, {
7778
code: code,
7879
redirect_uri: callbackUri
79-
}, callback)
80+
}))(callback)
8081
}
8182

8283
function getAccessTokenFromAuthorizationCodeFlowCallbacked (request, callback) {
@@ -102,7 +103,7 @@ const oauthPlugin = fp(function (fastify, options, next) {
102103

103104
function getNewAccessTokenUsingRefreshTokenCallbacked (refreshToken, params, callback) {
104105
const accessToken = fastify[name].oauth2.accessToken.create({ refresh_token: refreshToken })
105-
accessToken.refresh(params, callback)
106+
callbackify(accessToken.refresh.bind(accessToken, params))(callback)
106107
}
107108
const getNewAccessTokenUsingRefreshTokenPromisified = promisify(getNewAccessTokenUsingRefreshTokenCallbacked)
108109

@@ -112,7 +113,6 @@ const oauthPlugin = fp(function (fastify, options, next) {
112113
}
113114
getNewAccessTokenUsingRefreshTokenCallbacked(refreshToken, params, callback)
114115
}
115-
116116
const oauth2 = oauth2Module.create(credentials)
117117

118118
if (startRedirectPath) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@
3737
"dependencies": {
3838
"es6-promisify": "^6.0.0",
3939
"fastify-plugin": "^2.0.0",
40-
"simple-oauth2": "^1.6.0"
40+
"simple-oauth2": "^3.4.0"
4141
}
4242
}

test.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,17 @@ function makeRequests (t, fastify) {
3939
}
4040

4141
const githubScope = nock('https://github.com')
42-
.post('/login/oauth/access_token', 'code=my-code&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fcallback&grant_type=authorization_code&client_id=my-client-id&client_secret=my-secret')
42+
.post('/login/oauth/access_token', 'grant_type=authorization_code&code=my-code&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fcallback', {
43+
reqheaders: {
44+
authorization: 'Basic bXktY2xpZW50LWlkOm15LXNlY3JldA=='
45+
}
46+
})
4347
.reply(200, RESPONSE_BODY)
44-
.post('/login/oauth/access_token', 'grant_type=refresh_token&refresh_token=my-refresh-token&client_id=my-client-id&client_secret=my-secret')
48+
.post('/login/oauth/access_token', 'grant_type=refresh_token&refresh_token=my-refresh-token', {
49+
reqheaders: {
50+
authorization: 'Basic bXktY2xpZW50LWlkOm15LXNlY3JldA=='
51+
}
52+
})
4553
.reply(200, RESPONSE_BODY_REFRESHED)
4654

4755
fastify.inject({

0 commit comments

Comments
 (0)