askui
Version:
Reliable, automated end-to-end-testing that depends on what is shown on your screen instead of the technology you are running on
24 lines (23 loc) • 1.66 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.readCredentials = readCredentials;
const lib_1 = require("../lib");
const read_environment_credentials_1 = require("./read-environment-credentials");
function readCredentials(clientArgs) {
const environmentCredentials = (0, read_environment_credentials_1.envCredentials)();
const inCodeCredentials = clientArgs.credentials;
const credentials = inCodeCredentials !== null && inCodeCredentials !== void 0 ? inCodeCredentials : environmentCredentials;
if (!credentials) {
throw new Error('No credentials are defined! Please define a token and a Workspace ID in the environment variables ASKUI_TOKEN and ASKUI_WORKSPACE_ID or define them in the UiControlClient.build.');
}
if (!(credentials === null || credentials === void 0 ? void 0 : credentials.token)) {
throw new Error('No Token is defined! Please define a token in the environment variable ASKUI_TOKEN or define a token in the UiControlClient.');
}
if (!(credentials === null || credentials === void 0 ? void 0 : credentials.workspaceId)) {
throw new Error('No Workspace ID is defined! Please define a workspace ID in the environment variable ASKUI_WORKSPACE_ID or define a workspace ID in the UiControlClient.');
}
if (environmentCredentials && inCodeCredentials) {
lib_1.logger.warn('In-code credentials in UiControlClient.build and ENV variables(ASKUI_WORKSPACE_ID und ASKUI_TOKEN) are defined! We recommend to remove the in-code credentials for security reason! In-code credentials will be used for this execution.');
}
return credentials;
}