zcatalyst-cli 1.18.0-beta.3 → 1.18.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -54,6 +54,7 @@ exports.default = new command_1.default('event:generate <source> <action>')
54
54
  .needs('auth')
55
55
  .action(function generate(source, action) {
56
56
  return __awaiter(this, void 0, void 0, function* () {
57
+ var _a;
57
58
  const unknownArgs = (0, option_1.getUnknownOpts)([]);
58
59
  if (unknownArgs.length % 2 !== 0) {
59
60
  throw new error_1.default('Unknown options are not provided as key value pairs', {
@@ -175,7 +176,7 @@ exports.default = new command_1.default('event:generate <source> <action>')
175
176
  break;
176
177
  }
177
178
  });
178
- const sourceModule = (yield Promise.resolve().then(() => __importStar(require('../../../event_generate/' + source)))).default;
179
+ const sourceModule = (yield (_a = '../../../event_generate/' + source, Promise.resolve().then(() => __importStar(require(_a))))).default;
179
180
  eventJsonContent = yield sourceModule(eventJsonContent, optionMap, action);
180
181
  const jsonContent = JSON.parse(eventJsonContent);
181
182
  Object.keys(jsonContent).forEach((key) => {
@@ -46,6 +46,7 @@ exports.default = new command_1.default('event:generate:integ <service>')
46
46
  .needs('rc')
47
47
  .needs('auth')
48
48
  .action((service) => __awaiter(void 0, void 0, void 0, function* () {
49
+ var _a;
49
50
  const availableServices = Object.keys(constants_1.INTEG.service_map);
50
51
  if (!availableServices.includes(service)) {
51
52
  throw new error_1.default('Unknown service requested', {
@@ -56,7 +57,7 @@ exports.default = new command_1.default('event:generate:integ <service>')
56
57
  }
57
58
  const inputs = (0, option_1.getOptionValue)('inputs', '');
58
59
  const serviceValue = constants_1.INTEG.service_map[service];
59
- const serviceModule = (yield Promise.resolve().then(() => __importStar(require(`../../../event_generate/integration/${serviceValue}`))))
60
+ const serviceModule = (yield (_a = `../../../event_generate/integration/${serviceValue}`, Promise.resolve().then(() => __importStar(require(_a)))))
60
61
  .default;
61
62
  const payload = yield serviceModule(inputs);
62
63
  process.stdout.write(payload + '\n');
@@ -36,7 +36,8 @@ exports.default = (client) => {
36
36
  function loadCommand(name) {
37
37
  return __awaiter(this, void 0, void 0, function* () {
38
38
  return new Promise((resolve, reject) => setTimeout(() => __awaiter(this, void 0, void 0, function* () {
39
- const cmd = (yield Promise.resolve().then(() => __importStar(require('./' + name.split(':').join('/'))))).default;
39
+ var _a;
40
+ const cmd = (yield (_a = './' + name.split(':').join('/'), Promise.resolve().then(() => __importStar(require(_a))))).default;
40
41
  try {
41
42
  cmd.register(client);
42
43
  resolve();
@@ -38,6 +38,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
38
38
  const index_js_1 = __importDefault(require("../../../prompt/index.js"));
39
39
  const index_js_2 = require("../../../util_modules/constants/index.js");
40
40
  exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
41
+ var _a;
41
42
  const clientInitAnswer = yield index_js_1.default.ask(index_js_1.default.question('clientFlavour', 'Choose the type of client to initialise: ', {
42
43
  type: 'list',
43
44
  choices: index_js_2.PLUGIN.client.map((plugin) => {
@@ -47,5 +48,5 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
47
48
  });
48
49
  })
49
50
  }));
50
- return (yield Promise.resolve().then(() => __importStar(require('./initializers/' + clientInitAnswer.clientFlavour)))).default();
51
+ return (yield (_a = './initializers/' + clientInitAnswer.clientFlavour, Promise.resolve().then(() => __importStar(require(_a))))).default();
51
52
  });
@@ -229,7 +229,8 @@ class Command {
229
229
  (0, logger_1.debug)(e);
230
230
  }
231
231
  yield Promise.all(js_1.JS.map(this.beforeRunners, (before) => __awaiter(this, void 0, void 0, function* () {
232
- const beforeModule = (yield Promise.resolve().then(() => __importStar(require('../command_needs/' + before.fn)))).default;
232
+ var _a;
233
+ const beforeModule = (yield (_a = '../command_needs/' + before.fn, Promise.resolve().then(() => __importStar(require(_a))))).default;
233
234
  return beforeModule.call(this, before.args);
234
235
  })));
235
236
  return this.cmdAction.call(this, ...args);
@@ -44,6 +44,7 @@ const rc_1 = __importDefault(require("../internal/rc"));
44
44
  const fs_1 = require("../util_modules/fs");
45
45
  const logger_1 = require("../util_modules/logger");
46
46
  const runMigration = (rc, migFiles, idx = 0) => __awaiter(void 0, void 0, void 0, function* () {
47
+ var _a;
47
48
  if (migFiles.length <= idx) {
48
49
  return Promise.resolve();
49
50
  }
@@ -54,7 +55,7 @@ const runMigration = (rc, migFiles, idx = 0) => __awaiter(void 0, void 0, void 0
54
55
  return runMigration(rc, migFiles, ++idx);
55
56
  }
56
57
  try {
57
- const migModule = yield Promise.resolve().then(() => __importStar(require(migFile)));
58
+ const migModule = yield (_a = migFile, Promise.resolve().then(() => __importStar(require(_a))));
58
59
  if (migModule.isRequire()) {
59
60
  (0, logger_1.debug)('migration started for v' + currentMigFileVersion);
60
61
  migModule.migrate();
@@ -83,6 +84,7 @@ const runMigration = (rc, migFiles, idx = 0) => __awaiter(void 0, void 0, void 0
83
84
  return runMigration(rc, migFiles, ++idx);
84
85
  });
85
86
  const runGlobalMigration = (migFiles) => __awaiter(void 0, void 0, void 0, function* () {
87
+ var _b;
86
88
  if (migFiles.length === 0) {
87
89
  return;
88
90
  }
@@ -96,7 +98,7 @@ const runGlobalMigration = (migFiles) => __awaiter(void 0, void 0, void 0, funct
96
98
  return runGlobalMigration(migFiles);
97
99
  }
98
100
  try {
99
- const migModule = yield Promise.resolve().then(() => __importStar(require(migFile)));
101
+ const migModule = yield (_b = migFile, Promise.resolve().then(() => __importStar(require(_b))));
100
102
  if (migModule.isRequire()) {
101
103
  (0, logger_1.debug)('migration started for v' + currentMigFileVersion);
102
104
  migModule.migrate();
@@ -42,6 +42,7 @@ const async_js_1 = require("./util_modules/fs/lib/async.js");
42
42
  const error_js_1 = __importDefault(require("./error.js"));
43
43
  const ansi_colors_1 = require("ansi-colors");
44
44
  exports.default = (name, source) => __awaiter(void 0, void 0, void 0, function* () {
45
+ var _a, _b;
45
46
  if (name === (0, path_1.basename)(name)) {
46
47
  const projectModulePath = (0, project_js_1.resolveProjectPath)((0, path_1.join)(source, 'node_modules', name));
47
48
  const projectModulePathExists = yield (0, async_js_1.dirExists)(projectModulePath);
@@ -53,7 +54,7 @@ exports.default = (name, source) => __awaiter(void 0, void 0, void 0, function*
53
54
  });
54
55
  }
55
56
  app_module_path_1.default.addPath(projectModulePath);
56
- return Promise.resolve().then(() => __importStar(require(projectModulePath)));
57
+ return _a = projectModulePath, Promise.resolve().then(() => __importStar(require(_a)));
57
58
  }
58
59
  const projectModulePath = (0, project_js_1.resolveProjectPath)(name);
59
60
  const projectModulePathExists = yield (0, async_js_1.dirExists)(projectModulePath);
@@ -65,5 +66,5 @@ exports.default = (name, source) => __awaiter(void 0, void 0, void 0, function*
65
66
  });
66
67
  }
67
68
  app_module_path_1.default.addPath(projectModulePath);
68
- return Promise.resolve().then(() => __importStar(require(projectModulePath)));
69
+ return _b = projectModulePath, Promise.resolve().then(() => __importStar(require(_b)));
69
70
  });
@@ -26,6 +26,9 @@ var ETreeState;
26
26
  ETreeState[ETreeState["EXPANDED"] = 3] = "EXPANDED";
27
27
  })(ETreeState || (ETreeState = {}));
28
28
  class TreeNode {
29
+ get indent() {
30
+ return this.level * 2;
31
+ }
29
32
  constructor(root) {
30
33
  _TreeNode_instances.add(this);
31
34
  this.open = false;
@@ -36,9 +39,6 @@ class TreeNode {
36
39
  this.level = 1;
37
40
  this.root = root;
38
41
  }
39
- get indent() {
40
- return this.level * 2;
41
- }
42
42
  addNode(node) {
43
43
  if (node instanceof TreeNode) {
44
44
  this.leaves.push(node);
@@ -23,12 +23,12 @@ function addAppSailRoutes(app, details, proxy, unknownProxy) {
23
23
  req.url = req.originalUrl;
24
24
  unknownProxy(req, res);
25
25
  }));
26
- app.use('/baas/logout', (req, res) => {
26
+ app.use('/__catalyst', (req, res) => __awaiter(this, void 0, void 0, function* () {
27
27
  req.url = req.originalUrl;
28
28
  unknownProxy(req, res);
29
- });
29
+ }));
30
30
  ((_b = (_a = details.target) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.catalyst_auth) === true &&
31
- app.use(['/__catalyst', '/accounts', '/oauthorize'], (req, res) => {
31
+ app.use(['/accounts', '/oauthorize'], (req, res) => {
32
32
  if (req.url.includes('/appsail/logout_redirect')) {
33
33
  res.redirect(typeof req.query.service_url === 'string' ? req.query.service_url : '/');
34
34
  return;
@@ -20,6 +20,17 @@ const error_1 = __importDefault(require("../../../../error"));
20
20
  const project_1 = require("../../../../util_modules/project");
21
21
  const http_proxy_1 = require("http-proxy");
22
22
  const logger_1 = require("../../../../util_modules/logger");
23
+ const iam_cookies = [
24
+ 'ZD_CSRF_TOKEN',
25
+ '_iamadt_client',
26
+ '_iambdt_client',
27
+ '_zcsr_tmp',
28
+ 'iamcsr',
29
+ 'zalb',
30
+ 'stk',
31
+ 'JSESSIONID'
32
+ ];
33
+ const isIamCookie = (cookieStr) => iam_cookies.some((val) => cookieStr.startsWith(val));
23
34
  const removeSecure = (str) => str.replace(/;\s?Secure/i, '').replace(/;\s?SameSite=None/i, '');
24
35
  exports.removeSecure = removeSecure;
25
36
  const redirectByAuth = (req, res, redirectUrl) => {
@@ -68,17 +79,16 @@ const createProxyServer = (port) => {
68
79
  };
69
80
  exports.createProxyServer = createProxyServer;
70
81
  const proxyResponseHandler = ({ systemRoutes, signInRedirect = '/app/local-redirect' }) => (proxyRes, req, res) => {
82
+ var _a, _b;
71
83
  if (!req.url) {
72
84
  return;
73
85
  }
74
- if (req.url.startsWith('/oauthorize')) {
75
- const set = proxyRes.headers['set-cookie'];
76
- if (set) {
77
- const result = Array.isArray(set) ? set.map(exports.removeSecure) : (0, exports.removeSecure)(set);
78
- proxyRes.headers['set-cookie'] = result;
79
- }
80
- }
81
- else if (req.url.startsWith('/baas') || req.url.startsWith('/__catalyst')) {
86
+ proxyRes.headers['set-cookie'] = (_a = proxyRes.headers['set-cookie']) === null || _a === void 0 ? void 0 : _a.map((cookie) => {
87
+ if (isIamCookie(cookie))
88
+ return (0, exports.removeSecure)(cookie);
89
+ return cookie;
90
+ });
91
+ if (req.url.startsWith('/baas') || req.url.startsWith('/__catalyst')) {
82
92
  if (req.url.includes('/signin-redirect')) {
83
93
  if (systemRoutes === undefined) {
84
94
  (0, exports.redirectByAuth)(req, res, signInRedirect);
@@ -107,12 +117,8 @@ const proxyResponseHandler = ({ systemRoutes, signInRedirect = '/app/local-redir
107
117
  }
108
118
  }
109
119
  }
110
- else if (req.url.startsWith('/accounts')) {
111
- const set = proxyRes.headers['set-cookie'] || [];
112
- if (req.url.includes('/signin')) {
113
- set.push('IAM_TEST_COOKIE=IAM_TEST_COOKIE; Domain=localhost; Path=/');
114
- }
115
- proxyRes.headers['set-cookie'] = set.map(exports.removeSecure);
120
+ else if (req.url.startsWith('/accounts') && req.url.includes('/signin')) {
121
+ (_b = proxyRes.headers['set-cookie']) === null || _b === void 0 ? void 0 : _b.push('IAM_TEST_COOKIE=IAM_TEST_COOKIE; Domain=localhost; Path=/');
116
122
  }
117
123
  };
118
124
  exports.proxyResponseHandler = proxyResponseHandler;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zcatalyst-cli",
3
- "version": "1.18.0-beta.3",
3
+ "version": "1.18.0-beta.4",
4
4
  "description": "Command Line Tool for CATALYST",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {
@@ -94,6 +94,7 @@
94
94
  "build:watch": "gulp watch",
95
95
  "clean": "gulp cleanup",
96
96
  "test:unit": "jest --config jest.config.js",
97
+ "lint:nofix": "eslint --ext .ts src/ --color",
97
98
  "lint:src": "eslint --ext .ts src/ --fix --color",
98
99
  "lint:unit": "eslint --ext .js,.ts test/ --fix --color",
99
100
  "lint": "run-p lint:src lint:unit",