New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.2.20 to 0.2.21

55

lib/oauth2/index.js

@@ -17,2 +17,3 @@ const jsonfile = require('jsonfile');

var authorizationCompleted = false;
var server = null;

@@ -28,3 +29,4 @@ app.get('/', function (req, res) {

return res
.sendFile(path.join(__dirname + '/authOk.html'));
.status(200)
.json("Login complete! You can now close this window and the settings!");
}

@@ -39,12 +41,22 @@

if (!code) {
return res
.status(200)
.json("Authorization code missing!");
}
authorizationCompleted = true;
oauth2.authorizationCode.getToken(options, function (error, result) {
if (error) {
console.log(error);
return res.json('Authentication failed');
/*if (tokenCallback)
tokenCallback(error, null);*/
if (tokenCallback)
tokenCallback(error, null);
setTimeout(function () {
server.close();
}, 5000);
return res.json(error);
}
authorizationCompleted = true;
const token = oauth2.accessToken.create(result);

@@ -62,3 +74,4 @@

return res
.sendFile(path.join(__dirname + '/authOk.html'));
.status(200)
.json("Login complete! You can now close this window and the settings!");
});

@@ -68,3 +81,3 @@ });

try {
var server = app.listen(port);
server = app.listen(port);
} catch (e) {

@@ -119,8 +132,8 @@ return e;

if (result.token.access_token && result.token.refresh_token)
jsonfile.writeFile(currentAuthFile, result.token);
if (callback)
callback(error, {
needsAuthorization: false,
token: result.token
jsonfile.writeFile(currentAuthFile, result.token, function () {
if (callback)
callback(error, {
needsAuthorization: false,
token: result.token
});
});

@@ -153,9 +166,9 @@ } else if (callback)

if (result && result.token) {
jsonfile.writeFile(currentAuthFile, result.token);
if (callback)
callback(error, {
needsAuthorization: false,
token: result.token
});
jsonfile.writeFile(currentAuthFile, result.token, function () {
if (callback)
callback(error, {
needsAuthorization: false,
token: result.token
});
});
} else if (callback)

@@ -162,0 +175,0 @@ callback(error, {

@@ -58,11 +58,29 @@ const rp = require("request-promise");

that.emit("needsAuthorization", auth);
that.emit("needsAuthorization", auth, error);
} else {
$doRequest(resolve, function (e) {
if (e && e.error && e.error.errorcode) {
if (e.statusCode === 403) {
that._oAuth2.refreshToken(function (error, refreshStatus) {
if (error) {
var auth = that._oAuth2.startAuthorization(3000, function (err, token) {
if (err)
reject(err, token);
else
$doRequest(resolve, reject, token, options);
});
that.emit("needsAuthorization", auth, error);
}
else
$doRequest(resolve, reject, refreshStatus.token, options);
});
} else if (e && e.error && e.error.errorcode) {
// Token expired ...
if (e.error.errorcode === 2007) {
that._oAuth2.refreshToken(function () {
$doRequest(resolve, reject, status.token, options);
})
that._oAuth2.refreshToken(function (error, refreshStatus) {
if (error)
reject(error, refreshStatus);
else
$doRequest(resolve, reject, refreshStatus.token, options);
});
} else {

@@ -69,0 +87,0 @@ reject(e);

@@ -40,5 +40,5 @@ const inherits = require('util').inherits;

this._requestor.on("needsAuthorization", function (auth) {
this._requestor.on("needsAuthorization", function (auth, error) {
that._authRunning = true;
that.emit("needsAuthorization", auth);
that.emit("needsAuthorization", auth, error);
});

@@ -308,3 +308,2 @@

// Uninitialize fix hack ...
return new Promise(function (resolve, reject) {

@@ -311,0 +310,0 @@ that._requestor.call("initialize").catch(function (e) {

{
"name": "innogy-smarthome-lib",
"version": "0.2.20",
"version": "0.2.21",
"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