Innovenergy_trunk/frontend/node_modules/testcafe/lib/dashboard/get-default-project-link.js

23 lines
2.8 KiB
JavaScript
Raw Normal View History

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const get_dashboard_url_1 = __importDefault(require("./get-dashboard-url"));
function decodeAuthenticationToken(token) {
let tokenData;
try {
tokenData = JSON.parse(Buffer.from(token, 'base64').toString());
}
catch (e) { } // eslint-disable-line no-empty
if (tokenData && tokenData.projectId && tokenData.tokenSecret)
return tokenData;
return void 0;
}
function getDefaultProjectLink(token) {
const tokenData = decodeAuthenticationToken(token);
return new URL(`/runs/${tokenData.projectId}`, (0, get_dashboard_url_1.default)()).toString();
}
exports.default = getDefaultProjectLink;
module.exports = exports.default;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2V0LWRlZmF1bHQtcHJvamVjdC1saW5rLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2Rhc2hib2FyZC9nZXQtZGVmYXVsdC1wcm9qZWN0LWxpbmsudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFDQSw0RUFBa0Q7QUFFbEQsU0FBUyx5QkFBeUIsQ0FBRSxLQUFhO0lBQzdDLElBQUksU0FBUyxDQUFDO0lBRWQsSUFBSTtRQUNBLFNBQVMsR0FBRyxJQUFJLENBQUMsS0FBSyxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsS0FBSyxFQUFFLFFBQVEsQ0FBQyxDQUFDLFFBQVEsRUFBRSxDQUFDLENBQUM7S0FDbkU7SUFDRCxPQUFPLENBQUMsRUFBRSxHQUFFLENBQUMsK0JBQStCO0lBRTVDLElBQUksU0FBUyxJQUFJLFNBQVMsQ0FBQyxTQUFTLElBQUksU0FBUyxDQUFDLFdBQVc7UUFDekQsT0FBTyxTQUFTLENBQUM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