zcatalyst-cli 1.15.0 → 1.15.2

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.
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.missingScopes = void 0;
15
16
  const ansi_colors_1 = require("ansi-colors");
16
17
  const http_1 = require("http");
17
18
  const server_js_1 = require("../util_modules/server.js");
@@ -30,6 +31,10 @@ const fs_1 = require("../util_modules/fs");
30
31
  const js_1 = require("../util_modules/js");
31
32
  const logger_1 = require("../util_modules/logger");
32
33
  const option_1 = require("../util_modules/option");
34
+ exports.missingScopes = {
35
+ [constants_1.DC_TYPE.au.value]: ['zia_hub'],
36
+ [constants_1.DC_TYPE.eu.value]: ['zia_hub']
37
+ };
33
38
  class Login {
34
39
  constructor(localhost = true, user = true) {
35
40
  this.localhost = localhost;
@@ -58,7 +63,7 @@ class Login {
58
63
  '/oauth/v2/auth?' +
59
64
  js_1.JS.map({
60
65
  client_id: constants_1.AUTH.web.id,
61
- scope: js_1.JS.values(constants_1.SCOPE).join(' '),
66
+ scope: js_1.JS.values(this._getScopes()).join(' '),
62
67
  response_type: 'code',
63
68
  access_type: 'offline',
64
69
  prompt: 'consent',
@@ -115,7 +120,7 @@ class Login {
115
120
  qs: {
116
121
  client_id: constants_1.AUTH.mobile.id,
117
122
  client_secret: constants_1.AUTH.mobile.secret,
118
- scope: js_1.JS.values(constants_1.SCOPE).join(' '),
123
+ scope: js_1.JS.values(this._getScopes()).join(' '),
119
124
  grant_type: 'device_token',
120
125
  code
121
126
  },
@@ -215,7 +220,7 @@ class Login {
215
220
  origin: constants_1.ORIGIN.auth,
216
221
  qs: {
217
222
  client_id: constants_1.AUTH.mobile.id,
218
- scope: js_1.JS.values(constants_1.SCOPE).join(' '),
223
+ scope: js_1.JS.values(this._getScopes()).join(' '),
219
224
  grant_type: 'device_request',
220
225
  access_type: 'offline',
221
226
  prompt: 'consent'
@@ -260,7 +265,7 @@ class Login {
260
265
  return {
261
266
  user: userDetails,
262
267
  token: result,
263
- scopes: js_1.JS.values(constants_1.SCOPE),
268
+ scopes: js_1.JS.values(this._getScopes()),
264
269
  dc: (0, dc_1.getActiveDC)()
265
270
  };
266
271
  }
@@ -322,7 +327,7 @@ class Login {
322
327
  resolve({
323
328
  user: userDetails,
324
329
  token: result,
325
- scopes: js_1.JS.values(constants_1.SCOPE),
330
+ scopes: js_1.JS.values(this._getScopes()),
326
331
  dc: (0, dc_1.getActiveDC)()
327
332
  });
328
333
  }
@@ -356,5 +361,17 @@ class Login {
356
361
  });
357
362
  });
358
363
  }
364
+ _getScopes() {
365
+ const dc = (0, dc_1.getActiveDC)();
366
+ if (dc in exports.missingScopes) {
367
+ const devoidScopes = exports.missingScopes[dc];
368
+ const _scopes = Object.assign({}, constants_1.SCOPE);
369
+ devoidScopes.forEach((scope) => {
370
+ delete _scopes[scope];
371
+ });
372
+ return _scopes;
373
+ }
374
+ return constants_1.SCOPE;
375
+ }
359
376
  }
360
377
  exports.default = Login;
@@ -130,7 +130,7 @@ exports.default = new command_1.default('init [feature]')
130
130
  return saveAndComplete(config);
131
131
  }
132
132
  if (typeof feature === 'string') {
133
- featureAns.features = feature;
133
+ featureAns.features = [feature];
134
134
  }
135
135
  runtime_store_1.default.set('context.features', featureAns.features);
136
136
  yield (yield Promise.resolve().then(() => __importStar(require('../init')))).default();
@@ -253,11 +253,13 @@ function refineTargets(rawTargets, mapRemoteFn = true) {
253
253
  }
254
254
  exports.refineTargets = refineTargets;
255
255
  function refineEnvVariables(vars) {
256
- return Object.entries(vars || {}).reduce((envObj, curEntry) => {
257
- envObj[curEntry[0]] =
258
- typeof curEntry[1] === 'object' ? JSON.stringify(curEntry[1]) : curEntry[1];
259
- return envObj;
260
- }, {});
256
+ return !vars
257
+ ? undefined
258
+ : Object.entries(vars).reduce((envObj, curEntry) => {
259
+ envObj[curEntry[0]] =
260
+ typeof curEntry[1] === 'object' ? JSON.stringify(curEntry[1]) : curEntry[1];
261
+ return envObj;
262
+ }, {});
261
263
  }
262
264
  function executeHook({ prefix, command }) {
263
265
  if ((0, option_1.getOptionValue)('ignoreScripts', false)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zcatalyst-cli",
3
- "version": "1.15.0",
3
+ "version": "1.15.2",
4
4
  "description": "Command Line Tool for CATALYST",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {