Skip to content

Commit 81eca78

Browse files
committed
Prettier, bump deps
1 parent d699328 commit 81eca78

File tree

8 files changed

+2651
-590
lines changed

8 files changed

+2651
-590
lines changed

.github/workflows/nodejs.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,25 @@ name: Node.js CI
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master]
66
pull_request:
7-
branches: [ master ]
7+
branches: [master]
88

99
jobs:
1010
build:
11-
1211
runs-on: ubuntu-latest
1312

1413
strategy:
1514
matrix:
1615
node-version: [10.x, 12.x, 14.x]
1716

1817
steps:
19-
- uses: actions/checkout@v2
20-
- name: Use Node.js ${{ matrix.node-version }}
21-
uses: actions/setup-node@v1
22-
with:
23-
node-version: ${{ matrix.node-version }}
24-
- run: npm ci
25-
- run: npm test
26-
env:
27-
CI: true
18+
- uses: actions/checkout@v2
19+
- name: Use Node.js ${{ matrix.node-version }}
20+
uses: actions/setup-node@v1
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
- run: npm ci
24+
- run: npm test
25+
env:
26+
CI: true

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"bracketSpacing": true,
3+
"singleQuote": true,
4+
"trailingComma": "all"
5+
}

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
11
# Change Log
2+
23
All notable changes to this project will be documented in this file.
34
This project adheres to [Semantic Versioning](http://semver.org/).
45

56
## [2.0.1] - 2020-12-02
7+
68
### Updated
9+
710
- Update dependencies and test against node 14.
811

912
## [2.0.0] - 2020-03-25
13+
1014
### Breaking
15+
1116
- Drop support for node < 10.
1217

1318
## [1.1.0] - 2018-06-06
19+
1420
### Added
21+
1522
- Support using a strategy which overrides the `getOAuthAccessToken` function, for example the Reddit or Spotify strategy. #10
1623

1724
## [1.0.0] - 2015-12-17
25+
1826
### Added
27+
1928
- Allow extra params to be sent when requesting access token.
2029
- Use embedded `_oauth2` constructor to create new OAuth2 instance, to support instances where the `_oauth2` object is using a custom implementation.
2130

2231
### Removed
32+
2333
- Dropped peerDependency on `oauth2` library, in favour of using the `_oauth2` object exposed by passport.
2434
- Dropped support for node.js 0.6 and 0.8, lowest supported version is now 0.10. _If you still need support for 0.6 or 0.8, please continue to use v0.4.0 of this module._
2535

@@ -28,35 +38,51 @@ This project adheres to [Semantic Versioning](http://semver.org/).
2838
The move from 0.4 to 1.0 is non-breaking, _unless_ you are using a version of node.js lower than 0.10. In this case, you should stick to using 0.4. Otherwise, you can safely upgrade with no code changes required.
2939

3040
## [0.4.0] - 2015-04-01
41+
3142
### Added
43+
3244
- Allow strategy to be added with an explicit name: `refresh.use(name, strategy)`.
3345

3446
## [0.3.1] - 2015-03-06
47+
3548
### Changed
49+
3650
- Removed peer dependency on passport-oauth2, to fix npm 3 warning.
3751

3852
## [0.3.0] - 2015-01-27
53+
3954
### Added
55+
4056
- Support strategies which use separate URLs for generating and refreshing tokens (e.g. `passport-echosign`).
4157

4258
## [0.2.1] - 2014-11-16
59+
4360
### Fixed
61+
4462
- Fixed passport-oauth2 peer dependency link.
4563

4664
## [0.2.0] - 2014-11-16
65+
4766
### Changed
67+
4868
- Added passport-oauth2 as a peer dependency.
4969

5070
## [0.1.2] - 2014-11-16
71+
5172
### Changed
73+
5274
- Fixed git url.
5375

5476
## [0.1.1] - 2014-11-16
77+
5578
### Changed
79+
5680
- Fixed README typo.
5781

5882
## 0.1.0 - 2014-11-16
83+
5984
### Added
85+
6086
- Initial release.
6187

6288
[2.0.1]: https://github.com/fiznool/passport-oauth2-refresh/compare/v2.0.0...v2.0.1

README.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ When setting up your passport strategies, add a call to `refresh.use()` after `p
2424

2525
An example, using the Facebook strategy:
2626

27-
``` js
27+
```js
2828
const passport = require('passport');
2929
const refresh = require('passport-oauth2-refresh');
3030
const FacebookStrategy = require('passport-facebook').Strategy;
@@ -48,24 +48,26 @@ refresh.use(strategy);
4848

4949
When you need to refresh the access token, call `requestNewAccessToken()`:
5050

51-
``` js
51+
```js
5252
const refresh = require('passport-oauth2-refresh');
53-
refresh.requestNewAccessToken('facebook', 'some_refresh_token', function(err, accessToken, refreshToken) {
54-
// You have a new access token, store it in the user object,
55-
// or use it to make a new request.
56-
// `refreshToken` may or may not exist, depending on the strategy you are using.
57-
// You probably don't need it anyway, as according to the OAuth 2.0 spec,
58-
// it should be the same as the initial refresh token.
59-
60-
});
61-
53+
refresh.requestNewAccessToken(
54+
'facebook',
55+
'some_refresh_token',
56+
function (err, accessToken, refreshToken) {
57+
// You have a new access token, store it in the user object,
58+
// or use it to make a new request.
59+
// `refreshToken` may or may not exist, depending on the strategy you are using.
60+
// You probably don't need it anyway, as according to the OAuth 2.0 spec,
61+
// it should be the same as the initial refresh token.
62+
},
63+
);
6264
```
6365

6466
### Specific name
6567

6668
Instead of using the default `strategy.name`, you can setup `passport-oauth2-refresh` to use an specific name instead.
6769

68-
``` js
70+
```js
6971
// Setup
7072
passport.use('gmail', googleStrategy);
7173

@@ -79,7 +81,7 @@ This can be useful if you'd like to reuse strategy objects but under a different
7981

8082
Some endpoints require additional parameters to be sent when requesting a new access token. To send these parameters, specify the parameters when calling `requestNewAccessToken` as follows:
8183

82-
``` js
84+
```js
8385
const extraParams = { some: 'extra_param' };
8486
refresh.requestNewAccessToken('gmail', 'some_refresh_token', extraParams, done);
8587
```

lib/refresh.js

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,24 @@ AuthTokenRefresh._strategies = {};
1616
* @param {String|Strategy} name
1717
* @param {Strategy} passport strategy
1818
*/
19-
AuthTokenRefresh.use = function(name, strategy) {
20-
if(arguments.length === 1) {
19+
AuthTokenRefresh.use = function (name, strategy) {
20+
if (arguments.length === 1) {
2121
// Infer name from strategy
2222
strategy = name;
2323
name = strategy && strategy.name;
2424
}
2525

26-
if(strategy == null) {
26+
if (strategy == null) {
2727
throw new Error('Cannot register: strategy is null');
2828
}
2929

30-
if(!name) {
31-
throw new Error('Cannot register: name must be specified, or strategy must include name');
30+
if (!name) {
31+
throw new Error(
32+
'Cannot register: name must be specified, or strategy must include name',
33+
);
3234
}
3335

34-
if(!strategy._oauth2) {
36+
if (!strategy._oauth2) {
3537
throw new Error('Cannot register: not an OAuth2 strategy');
3638
}
3739

@@ -50,20 +52,22 @@ AuthTokenRefresh.use = function(name, strategy) {
5052
strategy._oauth2._baseSite,
5153
strategy._oauth2._authorizeUrl,
5254
strategy._refreshURL || strategy._oauth2._accessTokenUrl,
53-
strategy._oauth2._customHeaders)
55+
strategy._oauth2._customHeaders,
56+
),
5457
};
5558

5659
// Some strategies overwrite the getOAuthAccessToken function to set headers
5760
// https://github.com/fiznool/passport-oauth2-refresh/issues/10
58-
AuthTokenRefresh._strategies[name].refreshOAuth2.getOAuthAccessToken = strategy._oauth2.getOAuthAccessToken;
61+
AuthTokenRefresh._strategies[name].refreshOAuth2.getOAuthAccessToken =
62+
strategy._oauth2.getOAuthAccessToken;
5963
};
6064

6165
/**
6266
* Check if a strategy is registered for refreshing.
6367
* @param {String} name Strategy name
6468
* @return {Boolean}
6569
*/
66-
AuthTokenRefresh.has = function(name) {
70+
AuthTokenRefresh.has = function (name) {
6771
return !!AuthTokenRefresh._strategies[name];
6872
};
6973

@@ -78,16 +82,21 @@ AuthTokenRefresh.has = function(name) {
7882
* params to use when requesting the token.
7983
* @param {Function} done Callback when all is done.
8084
*/
81-
AuthTokenRefresh.requestNewAccessToken = function(name, refreshToken, params, done) {
82-
if(arguments.length === 3) {
85+
AuthTokenRefresh.requestNewAccessToken = function (
86+
name,
87+
refreshToken,
88+
params,
89+
done,
90+
) {
91+
if (arguments.length === 3) {
8392
done = params;
8493
params = {};
8594
}
8695

8796
// Send a request to refresh an access token, and call the passed
8897
// callback with the result.
8998
const strategy = AuthTokenRefresh._strategies[name];
90-
if(!strategy) {
99+
if (!strategy) {
91100
return done(new Error('Strategy was not registered to refresh a token'));
92101
}
93102

0 commit comments

Comments
 (0)