Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

innogy-smarthome-lib

Package Overview
Dependencies
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

innogy-smarthome-lib - npm Package Compare versions

Comparing version 0.1.17 to 0.1.18

34

lib/oauth2/index.js

@@ -91,2 +91,27 @@ const jsonfile = require('jsonfile');

var refreshToken = function (oAuthConfig, callback) {
const oauth2 = oauthLib.create(oAuthConfig);
var cachedAuthorization = getCachedAuthorization();
if (cachedAuthorization) {
var token = oauth2.accessToken.create(cachedAuthorization);
token.refresh(function (error, result) {
if (result && result.token) {
jsonfile.writeFile(currentAuthFile, result.token);
if (callback)
callback(error, {
needsAuthorization: false,
token: result.token
});
} else if (callback)
callback(error, {
needsAuthorization: true,
token: null
});
});
}
};
var getAuthorizationStatus = function (oAuthConfig, callback) {

@@ -102,7 +127,7 @@ const oauth2 = oauthLib.create(oAuthConfig);

var now = new Date();
var before30Mins = new Date();
before30Mins.setMinutes(now.getMinutes() - 30);
// Refresh token 30 Mins before expiration date
expirationDate.setMinutes(expirationDate.getMinutes() - 30);
if (expirationDate < before30Mins) {
if (expirationDate < now) {
token.refresh(function (error, result) {

@@ -150,4 +175,7 @@ if (result && result.token) {

return getAuthorizationStartUri(config.oAuth2Credentials, config.oAuth2RedirectConfig, port);
},
refreshToken: function (callback) {
return refreshToken(config.oAuth2Credentials, callback);
}
}
};

@@ -60,3 +60,16 @@ const rp = require("request-promise");

} else {
$doRequest(resolve, reject, status.token, options);
$doRequest(resolve, function (e) {
if (e && e.error && e.error.errorcode) {
// Token expired ...
if (e.error.errorcode === 2007) {
that._oAuth2.refreshToken(function () {
$doRequest(resolve, reject, status.token, options);
})
} else {
reject(e);
}
} else {
reject(e);
}
}, status.token, options);
}

@@ -63,0 +76,0 @@ });

2

package.json
{
"name": "innogy-smarthome-lib",
"version": "0.1.17",
"version": "0.1.18",
"description": "JavaScript library for the Innogy SmartHome system",

@@ -5,0 +5,0 @@ "main": "./lib/smarthome",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc