cloudrail-si
Advanced tools
Comparing version 2.6.2 to 2.7.0
# CloudRail SI Node.JS SDK changelog | ||
* **2.7.0** | ||
* BREAKING: The RedirectReceiver's callback function has a Node-style signature now | ||
* Added standard implementation for a RedirectReceiver with "electron" framework | ||
* Minor bugfixes | ||
* **2.6.2** | ||
@@ -4,0 +9,0 @@ * Added standard implementation for local RedirectReceiver |
@@ -10,5 +10,4 @@ "use strict"; | ||
function InternalError(message) { | ||
var newMessage = "An internal error has occured which you probably cannot fix. " + | ||
"We'd very much appreciate it if you would report it to the CloudRail team. The error message is:\n" + message; | ||
_super.call(this, newMessage); | ||
_super.call(this, "An internal error has occured which you probably cannot fix. " + "We'd very much appreciate it if you would report it to the CloudRail team. The error message is:\n" + message); | ||
this.message = message; | ||
} | ||
@@ -15,0 +14,0 @@ return InternalError; |
@@ -10,4 +10,4 @@ "use strict"; | ||
function UserError(message) { | ||
var newMessage = "An error occured that you should be able to fix. The error message is:\n" + message; | ||
_super.call(this, newMessage); | ||
_super.call(this, "An error occured that you should be able to fix. The error message is:\n" + message); | ||
this.message = message; | ||
} | ||
@@ -14,0 +14,0 @@ return UserError; |
@@ -0,4 +1,9 @@ | ||
-- | ||
Preamble | ||
Please visit https://cloudrail.com/cloudrail-pricing/ for enterprise licensing options. | ||
-- | ||
Software License | ||
I. Licobo GmbH ("CloudRail") holds the copyright in the downloadable standalone | ||
I. Licobo GmbH ("CloudRail") holds the copyright in the downloadable standalone | ||
software library CloudRail-SI ("Library"). | ||
@@ -5,0 +10,0 @@ |
@@ -37,3 +37,3 @@ { | ||
"engineStrict": true, | ||
"version": "2.6.2", | ||
"version": "2.7.0", | ||
"main": "index.js", | ||
@@ -40,0 +40,0 @@ "typings": "index.d.ts", |
@@ -11,19 +11,47 @@ "use strict"; | ||
return function (url, state, callback) { | ||
var sockets = {}; | ||
var nextSocketId = 0; | ||
var server = http.createServer(function (req, res) { | ||
res.statusCode = 200; | ||
res.setHeader("Content-Type", "text/html"); | ||
res.end(respHtml); | ||
server.close(function () { return callback(req.url); }); | ||
for (var socketId in sockets) | ||
sockets[socketId].destroy(); | ||
try { | ||
var sockets_1 = {}; | ||
var nextSocketId_1 = 0; | ||
var server_1 = http.createServer(function (req, res) { | ||
res.statusCode = 200; | ||
res.setHeader("Content-Type", "text/html"); | ||
res.end(respHtml); | ||
server_1.close(function () { return callback(undefined, req.url); }); | ||
for (var socketId in sockets_1) | ||
sockets_1[socketId].destroy(); | ||
}); | ||
server_1.on("connection", function (socket) { | ||
var socketId = nextSocketId_1++; | ||
sockets_1[socketId] = socket; | ||
socket.on("close", function () { return delete sockets_1[socketId]; }); | ||
}); | ||
server_1.listen(port); | ||
opn(url); | ||
} | ||
catch (err) { | ||
callback(err); | ||
} | ||
}; | ||
}; | ||
RedirectReceivers.getElectronAuthenticator = function (BrowserWindow, redirectUrl) { | ||
return function (url, currentState, callback) { | ||
var authWindow = new BrowserWindow({ | ||
webPreferences: { | ||
nodeIntegration: false, | ||
partition: Math.random().toString() | ||
} | ||
}); | ||
server.on("connection", function (socket) { | ||
var socketId = nextSocketId++; | ||
sockets[socketId] = socket; | ||
socket.on("close", function () { return delete sockets[socketId]; }); | ||
}); | ||
server.listen(port); | ||
opn(url); | ||
authWindow.loadURL(url); | ||
function incomingRedirect(url) { | ||
if (url.indexOf(redirectUrl) === 0) { | ||
authWindow.destroy(); | ||
callback(undefined, url); | ||
} | ||
} | ||
authWindow.webContents.on("will-navigate", function (event, url) { return incomingRedirect(url); }); | ||
authWindow.webContents.on("did-get-redirect-request", function (event, oldUrl, newUrl) { return incomingRedirect(newUrl); }); | ||
authWindow.on("close", function () { | ||
authWindow = null; | ||
callback(new Error("Authentication window was closed")); | ||
}, false); | ||
}; | ||
@@ -30,0 +58,0 @@ }; |
@@ -27,4 +27,9 @@ "use strict"; | ||
throw new UserError_1.UserError("This service needs the RedirectReceiver to be implemented as a function. Have a look at our examples and documentation if you are unsure how to do that."); | ||
return new Promise(function (resolve) { | ||
redirectReceiver(urlStr, environment.saveStateToString(), resolve); | ||
return new Promise(function (resolve, reject) { | ||
redirectReceiver(urlStr, environment.saveStateToString(), function (error, redirectedUrl) { | ||
if (error) | ||
reject(error); | ||
else | ||
resolve(redirectedUrl); | ||
}); | ||
}).then(function (redirectUrl) { | ||
@@ -31,0 +36,0 @@ var queryMap = url.parse(redirectUrl, true).query; |
@@ -106,3 +106,3 @@ "use strict"; | ||
return Promise.resolve().then(function () { return loop(condition, body); }).catch(function (e) { | ||
if (e instanceof UserError_1.UserError) | ||
if (!(e instanceof InternalError_1.InternalError)) | ||
throw e; | ||
@@ -109,0 +109,0 @@ var errorMessage = "Service code error in function " + _this.sandbox.currentFunctionName() + " at line " + _this.sandbox.currentServiceCodeLine() + " with message: " + e.message; |
Sorry, the diff of this file is too big to display
920094
18742