Skip to content

Commit

Permalink
v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fiznool committed Mar 25, 2020
1 parent 844eefd commit 517c3e6
Show file tree
Hide file tree
Showing 11 changed files with 2,157 additions and 77 deletions.
21 changes: 21 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"env": {
"commonjs": true,
"es6": true,
"node": true,
"mocha": true
},
"extends": "eslint:recommended",
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
"eqeqeq": ["error", "smart"],
"no-var": ["error"],
"prefer-const": ["error"]
}
}
110 changes: 108 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,110 @@
node_modules
# Created by https://www.gitignore.io/api/node
# Edit at https://www.gitignore.io/?templates=node

### Node ###
# Logs
logs
*.log
package-lock.json
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# rollup.js default build output
dist/

# Uncomment the public line if your project uses Gatsby
# https://nextjs.org/blog/next-9-1#public-directory-support
# https://create-react-app.dev/docs/using-the-public-folder/#docsNav
# public

# Storybook build outputs
.out
.storybook-out

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# Temporary folders
tmp/
temp/

# End of https://www.gitignore.io/api/node
27 changes: 0 additions & 27 deletions .jshintrc

This file was deleted.

1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
language: node_js
node_js:
- '8'
- '10'
- '12'
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [2.0.0] - 2020-03-25
### Breaking
- Drop support for node < 10.

## [1.1.0] - 2018-06-06
### Added
- Support using a strategy which overrides the `getOAuthAccessToken` function, for example the Reddit or Spotify strategy. #10
Expand Down Expand Up @@ -51,6 +55,7 @@ The move from 0.4 to 1.0 is non-breaking, _unless_ you are using a version of no
### Added
- Initial release.

[2.0.0]: https://github.com/fiznool/passport-oauth2-refresh/compare/v1.1.0...v2.0.0
[1.1.0]: https://github.com/fiznool/passport-oauth2-refresh/compare/v1.0.0...v1.1.0
[1.0.0]: https://github.com/fiznool/passport-oauth2-refresh/compare/v0.4.0...v1.0.0
[0.4.0]: https://github.com/fiznool/passport-oauth2-refresh/compare/v0.3.1...v0.4.0
Expand Down
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014 Tom Spencer
Copyright (c) 2014 - 2020 Tom Spencer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ An add-on to the [Passport](http://passportjs.org) authentication library to pro
## Installation

```
npm install passport-oauth2-refresh --save
npm install passport-oauth2-refresh
```

## Usage
Expand All @@ -20,11 +20,11 @@ When setting up your passport strategies, add a call to `refresh.use()` after `p
An example, using the Facebook strategy:

``` js
var passport = require('passport'),
, refresh = require('passport-oauth2-refresh')
, FacebookStrategy = require('passport-facebook').Strategy;
const passport = require('passport');
const refresh = require('passport-oauth2-refresh');
const FacebookStrategy = require('passport-facebook').Strategy;

var strategy = new FacebookStrategy({
const strategy = new FacebookStrategy({
clientID: FACEBOOK_APP_ID,
clientSecret: FACEBOOK_APP_SECRET,
callbackURL: "http://www.example.com/auth/facebook/callback"
Expand All @@ -44,7 +44,7 @@ refresh.use(strategy);
When you need to refresh the access token, call `requestNewAccessToken()`:

``` js
var refresh = require('passport-oauth2-refresh');
const refresh = require('passport-oauth2-refresh');
refresh.requestNewAccessToken('facebook', 'some_refresh_token', function(err, accessToken, refreshToken) {
// You have a new access token, store it in the user object,
// or use it to make a new request.
Expand Down Expand Up @@ -75,7 +75,7 @@ This can be useful if you'd like to reuse strategy objects but under a different
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:

``` js
var extraParams = { some: 'extra_param' };
const extraParams = { some: 'extra_param' };
refresh.requestNewAccessToken('gmail', 'some_refresh_token', extraParams, done);
```

Expand Down
10 changes: 4 additions & 6 deletions lib/refresh.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var AuthTokenRefresh = {};
const AuthTokenRefresh = {};

AuthTokenRefresh._strategies = {};

Expand All @@ -23,11 +23,9 @@ AuthTokenRefresh.use = function(name, strategy) {
name = strategy && strategy.name;
}

/* jshint eqnull: true */
if(strategy == null) {
throw new Error('Cannot register: strategy is null');
}
/* jshint eqnull: false */

if(!name) {
throw new Error('Cannot register: name must be specified, or strategy must include name');
Expand All @@ -39,7 +37,7 @@ AuthTokenRefresh.use = function(name, strategy) {

// Use the strategy's OAuth2 object, since it might have been overwritten.
// https://github.com/fiznool/passport-oauth2-refresh/issues/3
var OAuth2 = strategy._oauth2.constructor;
const OAuth2 = strategy._oauth2.constructor;

// Generate our own oauth2 object for use later.
// Use the strategy's _refreshURL, if defined,
Expand All @@ -54,7 +52,7 @@ AuthTokenRefresh.use = function(name, strategy) {
strategy._refreshURL || strategy._oauth2._accessTokenUrl,
strategy._oauth2._customHeaders)
};

// Some strategies overwrite the getOAuthAccessToken function to set headers
// https://github.com/fiznool/passport-oauth2-refresh/issues/10
AuthTokenRefresh._strategies[name].refreshOAuth2.getOAuthAccessToken = strategy._oauth2.getOAuthAccessToken;
Expand Down Expand Up @@ -88,7 +86,7 @@ AuthTokenRefresh.requestNewAccessToken = function(name, refreshToken, params, do

// Send a request to refresh an access token, and call the passed
// callback with the result.
var strategy = AuthTokenRefresh._strategies[name];
const strategy = AuthTokenRefresh._strategies[name];
if(!strategy) {
return done(new Error('Strategy was not registered to refresh a token'));
}
Expand Down
Loading

0 comments on commit 517c3e6

Please sign in to comment.