diff --git a/app/index.js b/app/index.js index 30df431..941f1e3 100644 --- a/app/index.js +++ b/app/index.js @@ -30,21 +30,42 @@ module.exports.UserData = UserData; //#region Exposed properties /** - * + * Shows log messages and other useful functions for module debugging. * @param {Boolean} value */ module.exports.debug = function (value) { shared.debug = value; } +/** + * @public + * Indicates whether a user is logged in to the F95Zone platform or not. + * @returns {String} + */ module.exports.isLogged = function () { return shared.isLogged; }; -module.exports.isolation = function(value) { +/** + * @public + * If true, it opens a new browser for each request + * to the F95Zone platform, otherwise it reuses the same. + * @returns {String} + */ +module.exports.setIsolation = function(value) { shared.isolation = value; } +/** + * @public + * Path to the cache directory + * @returns {String} + */ module.exports.getCacheDir = function() { return shared.cacheDir; } +/** + * @public + * Set path to the cache directory + * @returns {String} + */ module.exports.setCacheDir = function(value) { shared.cacheDir = value; @@ -222,6 +243,7 @@ module.exports.getGameData = async function (name, includeMods) { /** * @public * Gets the data of the currently logged in user. + * You **must** be logged in to the portal before calling this method. * @returns {Promise} Data of the user currently logged in or null if an error arise */ module.exports.getUserData = async function () { @@ -265,7 +287,16 @@ module.exports.getUserData = async function () { return ud; } +/** + * @public + * Logout from the current user. + * You **must** be logged in to the portal before calling this method. + */ module.exports.logout = function() { + if (!shared.isLogged) { + console.warn('user not authenticated, unable to continue'); + return info.version; + } shared.isLogged = false; } //#endregion diff --git a/app/scripts/shared.js b/app/scripts/shared.js index d6643ec..234f971 100644 --- a/app/scripts/shared.js +++ b/app/scripts/shared.js @@ -60,24 +60,28 @@ class Shared { return this._debug; } /** - * @returns {boolean} + * Indicates whether a user is logged in to the F95Zone platform or not. + * @returns {Boolean} */ static get isLogged() { return this._isLogged; } /** - * @returns {object[]} + * List of cookies obtained from the F95Zone platform. + * @returns {bject[]} */ static get cookies() { return this._cookies; } /** + * List of possible game engines used for development. * @returns {String[]} */ static get engines() { return this._engines; } /** + * List of possible development states that a game can assume. * @returns {String[]} */ static get statuses() { diff --git a/test/index-test.js b/test/index-test.js index 1b7299b..027d5b4 100644 --- a/test/index-test.js +++ b/test/index-test.js @@ -10,7 +10,7 @@ const PASSWORD = "f9vTcRNuvxj4YpK"; const FAKE_USERNAME = "FakeUsername091276"; const FAKE_PASSWORD = "fake_password"; -F95API.isolation(true); +F95API.setIsolation(true); describe("Login without cookies", function () { //#region Set-up