New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

refresh-token

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

refresh-token - npm Package Compare versions

Comparing version

to
0.0.2

8

lib/refresh.js
var request = require('request');
var EventEmitter = require('events').EventEmitter;

@@ -20,2 +21,4 @@ /**

function TokenProvider (url, options) {
EventEmitter.call(this);
if(!(this instanceof TokenProvider)){

@@ -52,2 +55,4 @@ //when calling as a function, force new.

TokenProvider.prototype = Object.create(EventEmitter.prototype);
/**

@@ -75,3 +80,2 @@ * Return a valid access token.

}, function (err, response, body) {
if(err) return done(err);

@@ -84,2 +88,4 @@

this.emit('new token', this.currentToken);
return done(null, this.currentToken.access_token);

@@ -86,0 +92,0 @@

9

package.json
{
"name": "refresh-token",
"version": "0.0.1",
"version": "0.0.2",
"description": "Returns a new oauth2 access token when expired.",
"main": "lib/refresh.js",
"keywords": ["oauth2", "oauth", "refresh", "token"],
"keywords": [
"oauth2",
"oauth",
"refresh",
"token"
],
"scripts": {

@@ -8,0 +13,0 @@ "test": "mocha --require should"

@@ -1,2 +0,2 @@

Helper to get a valid oauth 2 token given a refresh token.
Helper function to get always an oauth 2 valid token given a refresh token.

@@ -37,3 +37,3 @@ [The mechanism is explained here](http://tools.ietf.org/html/draft-ietf-oauth-v2-10#section-4.2).

var tokenProvider = new TokenProvider({
var tokenProvider = new GoogleTokenProvider({
refresh_token: 'refresh token',

@@ -40,0 +40,0 @@ client_id: 'client id',

@@ -18,3 +18,3 @@ var TokenProvider = require('../lib/refresh'),

it('should provide a new token', function (done) {
it('should provide a new token when it doesnt have access_token', function (done) {
var tokenProvider = new TokenProvider(

@@ -33,2 +33,20 @@ 'https://accounts.google.com/o/oauth2/token', {

it('should emit new token when generating a token', function (done) {
var tokenProvider = new TokenProvider(
'https://accounts.google.com/o/oauth2/token', {
refresh_token: testingKeys.refresh_token,
client_id: testingKeys.client_id,
client_secret: testingKeys.client_secret
});
tokenProvider.on('new token', function (tokenProps) {
tokenProps.access_token.should.not.eql(testingKeys.access_token);
done();
});
tokenProvider.getToken(function(err, token){
//no op;
});
});
it('should return the same token when calling two times in series', function (done) {

@@ -35,0 +53,0 @@ var tokenProvider = new TokenProvider(

Sorry, the diff of this file is not supported yet