diff --git a/AABrowserAPI/API.js b/AABrowserAPI/BotCode.js
similarity index 99%
rename from AABrowserAPI/API.js
rename to AABrowserAPI/BotCode.js
index 9bead5e6c..9a5474840 100644
--- a/AABrowserAPI/API.js
+++ b/AABrowserAPI/BotCode.js
@@ -1,4 +1,4 @@
-exports.newAPI = function newAPI() {
+exports.newBotCode = function newBotCode() {
let thisObject = {
saveBotCode: saveBotCode,
diff --git a/AABrowserAPI/UserAuthentication.js b/AABrowserAPI/UserAuthentication.js
new file mode 100644
index 000000000..7d48837f7
--- /dev/null
+++ b/AABrowserAPI/UserAuthentication.js
@@ -0,0 +1,23 @@
+exports.newUserAuthentication = function newUserAuthentication() {
+
+ let thisObject = {
+ authenticateUser: authenticateUser,
+ initialize: initialize
+ }
+
+ let serverConfig;
+
+ return thisObject;
+
+ function initialize(pServerConfig) {
+
+ serverConfig = pServerConfig;
+
+ }
+
+ function authenticateUser(callBackFunction) {
+
+ callBackFunction(global.DEFAULT_OK_RESPONSE);
+
+ }
+}
\ No newline at end of file
diff --git a/CloudVM/CloudSupport.js b/CloudVM/CloudSupport.js
index e3cc40c56..9431f17cf 100644
--- a/CloudVM/CloudSupport.js
+++ b/CloudVM/CloudSupport.js
@@ -141,28 +141,3 @@ function downloadModule(pPath, callBackFunction) {
}
}
-function callServer(pContentToSend, pPath, callBackFunction) {
-
- let xhttp = new XMLHttpRequest();
- xhttp.onreadystatechange = function () {
- if (this.readyState === 4 && this.status === 200) {
-
- callBackFunction(xhttp.responseText);
-
- }
- };
-
- if (pContentToSend === undefined) {
-
- xhttp.open("GET", pPath, true);
- xhttp.send();
-
- } else {
-
- let blob = new Blob([pContentToSend], { type: 'text/plain' });
-
- xhttp.open("POST", pPath, true);
- xhttp.send(blob);
-
- }
-}
diff --git a/Dashboard.js b/Dashboard.js
index 5d378d686..8f638b8c1 100644
--- a/Dashboard.js
+++ b/Dashboard.js
@@ -40,34 +40,6 @@ UI_PANEL = {
}
};
-/* Callbacks default responses. */
-
-let GLOBAL = {};
-
-GLOBAL.DEFAULT_OK_RESPONSE = {
- result: "Ok",
- message: "Operation Succeeded"
-};
-
-GLOBAL.DEFAULT_FAIL_RESPONSE = {
- result: "Fail",
- message: "Operation Failed"
-};
-
-GLOBAL.DEFAULT_RETRY_RESPONSE = {
- result: "Retry",
- message: "Retry Later"
-};
-
-GLOBAL.CUSTOM_OK_RESPONSE = {
- result: "Ok, but check Message",
- message: "Custom Message"
-};
-
-GLOBAL.CUSTOM_FAIL_RESPONSE = {
- result: "Fail Because",
- message: "Custom Message"
-};
/* The Dashboard is the root object that contains all the other stuff in it. Some of that stuff is visible, some other is invisible. */
diff --git a/Project.njsproj b/Project.njsproj
index 7b7e5e06b..e2fd0014f 100644
--- a/Project.njsproj
+++ b/Project.njsproj
@@ -29,7 +29,10 @@
true
-
+
+ Code
+
+
Code
diff --git a/Scripts/AppPreLoader.js b/Scripts/AppPreLoader.js
index 9ff7d98a4..318ee5384 100644
--- a/Scripts/AppPreLoader.js
+++ b/Scripts/AppPreLoader.js
@@ -1,6 +1,37 @@
+/* Callbacks default responses. */
+
+let GLOBAL = {};
+
+GLOBAL.DEFAULT_OK_RESPONSE = {
+ result: "Ok",
+ message: "Operation Succeeded"
+};
+
+GLOBAL.DEFAULT_FAIL_RESPONSE = {
+ result: "Fail",
+ message: "Operation Failed"
+};
+
+GLOBAL.DEFAULT_RETRY_RESPONSE = {
+ result: "Retry",
+ message: "Retry Later"
+};
+
+GLOBAL.CUSTOM_OK_RESPONSE = {
+ result: "Ok, but check Message",
+ message: "Custom Message"
+};
+
+GLOBAL.CUSTOM_FAIL_RESPONSE = {
+ result: "Fail Because",
+ message: "Custom Message"
+};
+
function loadAdvancedAlgosPlatform() {
+ /* The first thing to do here is to add the canvas where all the action is going to happen. */
+
let canvas = document.createElement('canvas');
canvas.id = "canvas";
@@ -12,17 +43,70 @@ function loadAdvancedAlgosPlatform() {
let body = document.getElementsByTagName("body")[0];
body.appendChild(canvas);
- let path = "Scripts/AppLoader.js";
+ /* The second thing to do is to send the tokenSession to the server, so that it can prepare the server side data structures needed. */
- REQUIREJS([path], onRequired);
+ let sessionToken = window.sessionToken;
+ if (sessionToken === undefined) { sessionToken = ""}
- function onRequired(pModule) {
+ let path = "AABrowserAPI/authenticateUser/" + sessionToken;
- console.log(path + " downloaded.");
+ callServer(undefined, path, onServerReponded);
- let APP_LOADER_MODULE = newAppLoader();
- APP_LOADER_MODULE.loadModules();
+ function onServerReponded(pResponse) {
+ err = JSON.parse(pResponse);
+
+ if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
+
+ console.log("Authentication Error. " + err.message);
+ return;
+
+ }
+
+ loadModules();
+ }
+
+ /* And Finally, we start loading all the scripts we will inmediatelly need. */
+
+ function loadModules() {
+
+ let path = "Scripts/AppLoader.js";
+
+ REQUIREJS([path], onRequired);
+
+ function onRequired(pModule) {
+
+ console.log(path + " downloaded.");
+
+ let APP_LOADER_MODULE = newAppLoader();
+ APP_LOADER_MODULE.loadModules();
+
+ }
}
}
+function callServer(pContentToSend, pPath, callBackFunction) {
+
+ let xhttp = new XMLHttpRequest();
+ xhttp.onreadystatechange = function () {
+ if (this.readyState === 4 && this.status === 200) {
+
+ callBackFunction(xhttp.responseText);
+
+ }
+ };
+
+ if (pContentToSend === undefined) {
+
+ xhttp.open("GET", pPath, true);
+ xhttp.send();
+
+ } else {
+
+ let blob = new Blob([pContentToSend], { type: 'text/plain' });
+
+ xhttp.open("POST", pPath, true);
+ xhttp.send(blob);
+
+ }
+}
diff --git a/Server/ConfigReader.js b/Server/ConfigReader.js
index dd9d9dec9..0a0f84767 100644
--- a/Server/ConfigReader.js
+++ b/Server/ConfigReader.js
@@ -18,9 +18,8 @@
return thisObject;
- function initialize(pEcosystem, pEcosystemObject, pServerConfig, pStorageData, callBackFunction) {
+ function initialize(pEcosystem, pEcosystemObject, pStorageData, callBackFunction) {
- serverConfig = pServerConfig;
storageData = pStorageData;
ecosystem = pEcosystem;
ecosystemObject = pEcosystemObject;
diff --git a/index.html b/index.html
index 9b91a18a8..c733eb598 100644
--- a/index.html
+++ b/index.html
@@ -4,6 +4,8 @@
Advanced Algos
+
+
diff --git a/server.js b/server.js
index 272e7aba3..5d08efd7b 100644
--- a/server.js
+++ b/server.js
@@ -49,7 +49,8 @@ let isHttpServerStarted = false;
const STORAGE = require('./Server/Storage');
let storage = STORAGE.newStorage();
-let sessionManager; // This module have all authenticated active sessions.
+let sessionManager; // This module have all authenticated active sessions.
+let storageAccessManager; // This module manages the SAS for user to access the cloud storage from the browser.
initialize();
@@ -64,7 +65,7 @@ function initialize() {
const CONFIG_READER = require('./Server/ConfigReader');
let configReader = CONFIG_READER.newConfigReader();
- configReader.initialize(ecosystem, ecosystemObject, serverConfig, storageData, onInitialized);
+ configReader.initialize(ecosystem, ecosystemObject, storageData, onInitialized);
function onInitialized(pServerConfig) {
@@ -424,21 +425,21 @@ function onBrowserRequest(request, response) {
case "AABrowserAPI": // This means the Scripts folder.
{
- const AABROSER_API_MODULE = require('./AABrowserAPI/' + 'API');
- let api = AABROSER_API_MODULE.newAPI();
+ switch (requestParameters[2]) {
- api.initialize(serverConfig);
+ case "saveBotCode": {
- processPost(request, response, onPostReceived)
+ const AABROSER_API_BOT_CODE = require('./AABrowserAPI/' + 'BotCode');
+ let botCode = AABROSER_API_BOT_CODE.newBotCode();
- function onPostReceived(pData) {
+ botCode.initialize(serverConfig);
- switch (requestParameters[2]) {
+ processPost(request, response, onPostReceived)
- case "saveBotCode": {
+ function onPostReceived(pData) {
let devTeam = requestParameters[3];
- let source = requestParameters[4] + "/" + requestParameters[5];
+ let source = requestParameters[4] + "/" + requestParameters[5];
let repo = requestParameters[6];
let path;
@@ -447,15 +448,31 @@ function onBrowserRequest(request, response) {
} else {
path = requestParameters[7];
}
- api.saveBotCode(devTeam, source, repo, path, pData, onResponse);
- break;
+ botCode.saveBotCode(devTeam, source, repo, path, pData, onResponse);
+
+ function onResponse(err, pResponse) {
+
+ respondWithContent(JSON.stringify(pResponse), response);
+ }
}
+ break;
}
- function onResponse(err, pResponse) {
+ case "authenticateUser": {
- respondWithContent(JSON.stringify(pResponse), response);
+ const AABROSER_API_USER_AUTHENTICATION = require('./AABrowserAPI/' + 'UserAuthentication');
+ let userAuthentication = AABROSER_API_USER_AUTHENTICATION.newUserAuthentication();
+
+ userAuthentication.initialize();
+ userAuthentication.authenticateUser(onFinish);
+
+ function onFinish(err) {
+
+ respondWithContent(JSON.stringify(err), response);
+ }
+
+ break;
}
}
}
@@ -814,6 +831,14 @@ function onBrowserRequest(request, response) {
let fileContent = file.toString();
+ /* The second request parameters is the sessionToken, if it exists. */
+
+ if (requestParameters[2] !== "" && requestParameters[2] !== undefined) {
+
+ fileContent.replace("", "")
+
+ }
+
addImages();
function addImages() {