@commercetools-frontend/application-config 21.23.9 → 21.24.0

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.
@@ -15,8 +15,8 @@ var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/ob
15
15
  var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
16
16
  var fs = require('fs');
17
17
  var omitEmpty = require('omit-empty-es');
18
- var path = require('path');
19
18
  var child_process = require('child_process');
19
+ var path = require('path');
20
20
  var cosmiconfig = require('cosmiconfig');
21
21
  var _Reflect$construct = require('@babel/runtime-corejs3/core-js-stable/reflect/construct');
22
22
  var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
@@ -26,20 +26,19 @@ var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
26
26
  var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
27
27
  var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
28
28
  var _wrapNativeSuper = require('@babel/runtime-corejs3/helpers/wrapNativeSuper');
29
+ var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
30
+ var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
31
+ var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
32
+ var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
33
+ var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
29
34
  var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
35
+ var formatters = require('./formatters-a6cf66a7.cjs.dev.js');
30
36
  var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
31
37
  var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
32
38
  var Ajv = require('ajv');
33
- var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
34
- var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
35
- var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
36
- var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
37
39
  var _Object$values = require('@babel/runtime-corejs3/core-js-stable/object/values');
38
40
  var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
39
41
  var uniq = require('lodash/uniq');
40
- var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
41
- var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
42
- var formatters = require('./formatters-d2c7b577.cjs.dev.js');
43
42
  var createDOMPurify = require('dompurify');
44
43
  var jsdom$1 = require('jsdom');
45
44
  require('@babel/runtime-corejs3/core-js-stable/object/entries');
@@ -61,24 +60,24 @@ var fs__default = /*#__PURE__*/_interopDefault(fs);
61
60
  var omitEmpty__default = /*#__PURE__*/_interopDefault(omitEmpty);
62
61
  var path__default = /*#__PURE__*/_interopDefault(path);
63
62
  var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
63
+ var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
64
+ var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
65
+ var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
66
+ var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
64
67
  var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
65
68
  var _Set__default = /*#__PURE__*/_interopDefault(_Set);
66
69
  var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
67
70
  var Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
68
- var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
69
- var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
70
71
  var _Object$values__default = /*#__PURE__*/_interopDefault(_Object$values);
71
72
  var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
72
73
  var uniq__default = /*#__PURE__*/_interopDefault(uniq);
73
- var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
74
- var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
75
74
  var createDOMPurify__default = /*#__PURE__*/_interopDefault(createDOMPurify);
76
75
 
77
76
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
78
77
 
79
78
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct__default["default"]) return false; if (_Reflect$construct__default["default"].sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); return true; } catch (e) { return false; } }
80
79
 
81
- var MissingOrInvalidConfigError = /*#__PURE__*/function (_Error) {
80
+ let MissingOrInvalidConfigError = /*#__PURE__*/function (_Error) {
82
81
  _inherits(MissingOrInvalidConfigError, _Error);
83
82
 
84
83
  var _super = _createSuper(MissingOrInvalidConfigError);
@@ -100,21 +99,21 @@ var MissingOrInvalidConfigError = /*#__PURE__*/function (_Error) {
100
99
  return _createClass(MissingOrInvalidConfigError);
101
100
  }( /*#__PURE__*/_wrapNativeSuper(Error));
102
101
 
102
+ // Helper function to find the package root path from the current location,
103
103
  // for instance in respect to both source files and dist files.
104
-
105
- var findPackageRootPath = function findPackageRootPath(dir) {
106
- var packageJsonPath = path__default["default"].join(dir, 'package.json');
104
+ const findPackageRootPath = dir => {
105
+ const packageJsonPath = path__default["default"].join(dir, 'package.json');
107
106
 
108
107
  if (fs__default["default"].existsSync(packageJsonPath)) {
109
108
  return dir;
110
109
  }
111
110
 
112
- var parentDir = path__default["default"].join(dir, '..');
111
+ const parentDir = path__default["default"].join(dir, '..');
113
112
  return findPackageRootPath(parentDir);
114
113
  };
115
114
 
116
- var loadJsModule = function loadJsModule(filePath) {
117
- var packageRootPath = findPackageRootPath( // Start from the parent folder
115
+ const loadJsModule = filePath => {
116
+ const packageRootPath = findPackageRootPath( // Start from the parent folder
118
117
  path__default["default"].join(__dirname, '..')); // Load the JS module using a child process. This is primarly to avoid
119
118
  // unwanted behaviors using `@babel/register` in the main process.
120
119
  // The loader script does the actual `require` of the given `filePath`
@@ -122,14 +121,14 @@ var loadJsModule = function loadJsModule(filePath) {
122
121
  // The "required module output" is then written into `stdout` and parsed
123
122
  // as JSON.
124
123
 
125
- var output = child_process.execFileSync('node', [path__default["default"].join(packageRootPath, 'scripts/load-js-module.js'), filePath], {
124
+ const output = child_process.execFileSync('node', [path__default["default"].join(packageRootPath, 'scripts/load-js-module.js'), filePath], {
126
125
  encoding: 'utf8'
127
126
  });
128
127
  return JSON.parse(output);
129
128
  };
130
129
 
131
- var moduleName = 'custom-application-config';
132
- var explorer = cosmiconfig.cosmiconfigSync(moduleName, {
130
+ const moduleName = 'custom-application-config';
131
+ const explorer = cosmiconfig.cosmiconfigSync(moduleName, {
133
132
  // Restrict the supported file formats / names
134
133
  searchPlaces: [".".concat(moduleName, "rc"), ".".concat(moduleName, ".json"), ".".concat(moduleName, ".js"), ".".concat(moduleName, ".cjs"), ".".concat(moduleName, ".mjs"), ".".concat(moduleName, ".ts"), "".concat(moduleName, ".json"), "".concat(moduleName, ".js"), "".concat(moduleName, ".cjs"), "".concat(moduleName, ".mjs"), "".concat(moduleName, ".ts")],
135
134
  loaders: {
@@ -140,8 +139,8 @@ var explorer = cosmiconfig.cosmiconfigSync(moduleName, {
140
139
  '.ts': loadJsModule
141
140
  }
142
141
  });
143
- var getConfigPath = function getConfigPath() {
144
- var configFile = explorer.search();
142
+ const getConfigPath = () => {
143
+ const configFile = explorer.search();
145
144
 
146
145
  if (!configFile) {
147
146
  throw new Error("Missing or invalid Custom Application configuration file.");
@@ -150,8 +149,8 @@ var getConfigPath = function getConfigPath() {
150
149
  return configFile.filepath;
151
150
  };
152
151
 
153
- var loadConfig = function loadConfig(applicationPath) {
154
- var configFile = explorer.search(applicationPath);
152
+ const loadConfig = applicationPath => {
153
+ const configFile = explorer.search(applicationPath);
155
154
 
156
155
  if (!configFile || !configFile.config) {
157
156
  throw new MissingOrInvalidConfigError("Missing or invalid Custom Application configuration file.");
@@ -160,6 +159,118 @@ var loadConfig = function loadConfig(applicationPath) {
160
159
  return configFile.config;
161
160
  };
162
161
 
162
+ /**
163
+ * NOTE:
164
+ * Allows variable placeholders. Supported types are:
165
+ * - `env`: For example `${env:MC_API_URL}`.
166
+ * - `intl`: For example `${intl:en:Menu.title}`.
167
+ * - `path`: For example `${path:./app.svg}`, or `${path:@commercetools-frontend/assets/application-icons/rocket.svg}`.
168
+ */
169
+ const variableSyntax = /\${([ ~:\w.'",\-/()@]+?)}/g;
170
+ const envRefSyntax = /^env:/g;
171
+ const intlRefSyntax = /^intl:/g;
172
+ const filePathRefSyntax = /^path:/g;
173
+
174
+ const hasVariablePlaceholder = valueOfEnvConfig => typeof valueOfEnvConfig === 'string' && // Using `{regex}.test()` might cause false positives if called multiple
175
+ // times on a global regular expression:
176
+ // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test
177
+ // As with exec() (or in combination with it), test() called multiple times
178
+ // on the same global regular expression instance will advance past the previous match.
179
+ Boolean(valueOfEnvConfig.match(variableSyntax));
180
+
181
+ const isEnvVariablePlaceholder = valueOfPlaceholder => Boolean(valueOfPlaceholder.match(envRefSyntax));
182
+
183
+ const isIntlVariablePlaceholder = valueOfPlaceholder => Boolean(valueOfPlaceholder.match(intlRefSyntax));
184
+
185
+ const isFilePathVariablePlaceholder = valueOfPlaceholder => Boolean(valueOfPlaceholder.match(filePathRefSyntax));
186
+
187
+ const isStructuredJson = message => (message === null || message === void 0 ? void 0 : message.string) !== undefined;
188
+
189
+ const substituteEnvVariablePlaceholder = (valueOfPlaceholder, matchedString, valueOfEnvConfig, loadingOptions) => {
190
+ const _valueOfPlaceholder$s = valueOfPlaceholder.split(':'),
191
+ _valueOfPlaceholder$s2 = _slicedToArray(_valueOfPlaceholder$s, 2),
192
+ requestedEnvVar = _valueOfPlaceholder$s2[1];
193
+
194
+ const hasEnvField = loadingOptions.processEnv.hasOwnProperty(requestedEnvVar);
195
+
196
+ if (!hasEnvField) {
197
+ var _context;
198
+
199
+ throw new Error(_concatInstanceProperty__default["default"](_context = "Missing environment variable '".concat(requestedEnvVar, "' specified in config as 'env:")).call(_context, requestedEnvVar, "'."));
200
+ }
201
+
202
+ const escapedMatchedString = matchedString.replace(/[${}:]/g, '\\$&');
203
+ return valueOfEnvConfig.replace(new RegExp("(".concat(escapedMatchedString, ")+"), 'g'), loadingOptions.processEnv[requestedEnvVar]);
204
+ };
205
+
206
+ const substituteIntlVariablePlaceholder = (valueOfPlaceholder, matchedString, valueOfEnvConfig, loadingOptions) => {
207
+ const _valueOfPlaceholder$s3 = valueOfPlaceholder.split(':'),
208
+ _valueOfPlaceholder$s4 = _slicedToArray(_valueOfPlaceholder$s3, 3),
209
+ locale = _valueOfPlaceholder$s4[1],
210
+ requestedIntlMessageId = _valueOfPlaceholder$s4[2];
211
+
212
+ const translationsFilePath = require.resolve("./i18n/data/".concat(locale, ".json"), {
213
+ paths: ["".concat(loadingOptions.applicationPath, "/src"), loadingOptions.applicationPath]
214
+ });
215
+
216
+ const translations = require(translationsFilePath);
217
+
218
+ const hasIntlMessage = translations.hasOwnProperty(requestedIntlMessageId);
219
+
220
+ if (!hasIntlMessage) {
221
+ var _context2, _context3;
222
+
223
+ throw new Error(_concatInstanceProperty__default["default"](_context2 = _concatInstanceProperty__default["default"](_context3 = "Missing message key '".concat(requestedIntlMessageId, "' specified in config as 'intl:")).call(_context3, locale, ":")).call(_context2, requestedIntlMessageId, "'."));
224
+ }
225
+
226
+ const translation = translations[requestedIntlMessageId];
227
+ const translationValue = isStructuredJson(translation) ? translation.string : translation;
228
+ const escapedMatchedString = matchedString.replace(/[${}:]/g, '\\$&');
229
+ return valueOfEnvConfig.replace(new RegExp("(".concat(escapedMatchedString, ")+"), 'g'), translationValue);
230
+ };
231
+
232
+ const substituteFilePathVariablePlaceholder = (valueOfPlaceholder, matchedString, valueOfEnvConfig, loadingOptions) => {
233
+ const _valueOfPlaceholder$s5 = valueOfPlaceholder.split(':'),
234
+ _valueOfPlaceholder$s6 = _slicedToArray(_valueOfPlaceholder$s5, 2),
235
+ filePathOrModule = _valueOfPlaceholder$s6[1];
236
+
237
+ const content = fs__default["default"].readFileSync(require.resolve(filePathOrModule, {
238
+ // Relative paths should be resolved from the application folder.
239
+ paths: [loadingOptions.applicationPath]
240
+ }), {
241
+ encoding: 'utf-8'
242
+ });
243
+ const escapedMatchedString = matchedString.replace(/[${}:]/g, '\\$&');
244
+ return valueOfEnvConfig.replace(new RegExp("(".concat(escapedMatchedString, ")+"), 'g'), content);
245
+ };
246
+
247
+ const getValueOfPlaceholder = valueWithPlaceholder => valueWithPlaceholder.replace(variableSyntax, (_match, varName) => _trimInstanceProperty__default["default"](varName).call(varName)).replace(/\s/g, '');
248
+
249
+ const substituteVariablePlaceholders = (config, loadingOptions) => JSON.parse(_JSON$stringify__default["default"](config), (_key, value) => {
250
+ // Only strings are allowed
251
+ let substitutedValue = value;
252
+
253
+ if (hasVariablePlaceholder(substitutedValue)) {
254
+ const matchResult = substitutedValue.match(variableSyntax);
255
+
256
+ if (matchResult) {
257
+ _forEachInstanceProperty__default["default"](matchResult).call(matchResult, matchedString => {
258
+ const valueOfPlaceholder = getValueOfPlaceholder(matchedString);
259
+
260
+ if (isEnvVariablePlaceholder(valueOfPlaceholder)) {
261
+ substitutedValue = substituteEnvVariablePlaceholder(valueOfPlaceholder, matchedString, substitutedValue, loadingOptions);
262
+ } else if (isIntlVariablePlaceholder(valueOfPlaceholder)) {
263
+ substitutedValue = substituteIntlVariablePlaceholder(valueOfPlaceholder, matchedString, substitutedValue, loadingOptions);
264
+ } else if (isFilePathVariablePlaceholder(valueOfPlaceholder)) {
265
+ substitutedValue = substituteFilePathVariablePlaceholder(valueOfPlaceholder, matchedString, substitutedValue, loadingOptions);
266
+ }
267
+ });
268
+ }
269
+ }
270
+
271
+ return substitutedValue;
272
+ });
273
+
163
274
  var schemaJson = {
164
275
  $schema: "http://json-schema.org/draft-07/schema",
165
276
  $id: "https://docs.commercetools.com/custom-applications/schema.json",
@@ -517,20 +628,20 @@ var schemaJson = {
517
628
  * The entryPointUriPath may be between 2 and 64 characters and only contain alphabetic lowercase characters,
518
629
  * non-consecutive underscores and hyphens. Leading and trailing underscore and hyphens are also not allowed.
519
630
  */
520
- var ENTRY_POINT_URI_PATH_REGEX = /^[^-_#]([0-9a-z]|[-_](?![-_])){0,62}[^-_#]$/g;
631
+ const ENTRY_POINT_URI_PATH_REGEX = /^[^-_#]([0-9a-z]|[-_](?![-_])){0,62}[^-_#]$/g;
521
632
  /**
522
633
  * The permission group name may be between 2 and 64 characters and only contain alphanumeric lowercase characters and non-consecutive hyphens. Leading and trailing hyphens are also not allowed.
523
634
  */
524
635
 
525
- var PERMISSION_GROUP_NAME_REGEX = /^[^-#]([a-z]|[-](?![-])){0,62}[^-#]$/g;
526
- var CLOUD_IDENTIFIERS = {
636
+ const PERMISSION_GROUP_NAME_REGEX = /^[^-#]([a-z]|[-](?![-])){0,62}[^-#]$/g;
637
+ const CLOUD_IDENTIFIERS = {
527
638
  GCP_AU: 'gcp-au',
528
639
  GCP_EU: 'gcp-eu',
529
640
  GCP_US: 'gcp-us',
530
641
  AWS_FRA: 'aws-fra',
531
642
  AWS_OHIO: 'aws-ohio'
532
643
  };
533
- var MC_API_URLS = {
644
+ const MC_API_URLS = {
534
645
  GCP_AU: 'https://mc-api.australia-southeast1.gcp.commercetools.com',
535
646
  GCP_EU: 'https://mc-api.europe-west1.gcp.commercetools.com',
536
647
  GCP_US: 'https://mc-api.us-central1.gcp.commercetools.com',
@@ -538,21 +649,21 @@ var MC_API_URLS = {
538
649
  AWS_OHIO: 'https://mc-api.us-east-2.aws.commercetools.com'
539
650
  };
540
651
 
541
- var ajv = new Ajv__default["default"]({
652
+ const ajv = new Ajv__default["default"]({
542
653
  strict: true,
543
654
  useDefaults: true
544
655
  });
545
- var validate = ajv.compile(schemaJson);
656
+ const validate = ajv.compile(schemaJson);
546
657
 
547
- var printErrors = function printErrors(errors) {
658
+ const printErrors = errors => {
548
659
  if (!errors) {
549
660
  return 'No errors';
550
661
  }
551
662
 
552
- return _mapInstanceProperty__default["default"](errors).call(errors, function (error) {
663
+ return _mapInstanceProperty__default["default"](errors).call(errors, error => {
553
664
  var _context, _context2, _context3;
554
665
 
555
- var baseMessage = _concatInstanceProperty__default["default"](_context = "".concat(error.instancePath, " ")).call(_context, error.message);
666
+ const baseMessage = _concatInstanceProperty__default["default"](_context = "".concat(error.instancePath, " ")).call(_context, error.message);
556
667
 
557
668
  switch (error.keyword) {
558
669
  case 'additionalProperties':
@@ -567,25 +678,25 @@ var printErrors = function printErrors(errors) {
567
678
  }).join('\n');
568
679
  };
569
680
 
570
- var validateConfig = function validateConfig(config) {
571
- var valid = validate(config);
681
+ const validateConfig = config => {
682
+ const valid = validate(config);
572
683
 
573
684
  if (!valid) {
574
685
  throw new Error(printErrors(validate.errors));
575
686
  }
576
687
  };
577
- var validateEntryPointUriPath = function validateEntryPointUriPath(config) {
688
+ const validateEntryPointUriPath = config => {
578
689
  if (!config.entryPointUriPath.match(ENTRY_POINT_URI_PATH_REGEX)) {
579
690
  throw new Error('Invalid "entryPointUriPath". The value may be between 2 and 64 characters and only contain alphanumeric lowercase characters, non-consecutive underscores and hyphens. Leading and trailing underscores and hyphens are also not allowed.');
580
691
  }
581
692
  };
582
- var validateSubmenuLinks = function validateSubmenuLinks(config) {
693
+ const validateSubmenuLinks = config => {
583
694
  var _context4;
584
695
 
585
- var uriPathSet = new _Set__default["default"]();
696
+ const uriPathSet = new _Set__default["default"]();
586
697
 
587
- _forEachInstanceProperty__default["default"](_context4 = config.submenuLinks).call(_context4, function (_ref) {
588
- var uriPath = _ref.uriPath;
698
+ _forEachInstanceProperty__default["default"](_context4 = config.submenuLinks).call(_context4, _ref => {
699
+ let uriPath = _ref.uriPath;
589
700
 
590
701
  if (uriPathSet.has(uriPath)) {
591
702
  throw new Error('Duplicate URI path. Every submenu link must have a unique URI path value');
@@ -594,12 +705,12 @@ var validateSubmenuLinks = function validateSubmenuLinks(config) {
594
705
  uriPathSet.add(uriPath);
595
706
  });
596
707
  };
597
- var validateAdditionalOAuthScopes = function validateAdditionalOAuthScopes(config) {
708
+ const validateAdditionalOAuthScopes = config => {
598
709
  var _config$additionalOAu;
599
710
 
600
- var additionalPermissionNames = new _Set__default["default"]();
601
- (_config$additionalOAu = config.additionalOAuthScopes) === null || _config$additionalOAu === void 0 ? void 0 : _forEachInstanceProperty__default["default"](_config$additionalOAu).call(_config$additionalOAu, function (_ref2) {
602
- var name = _ref2.name,
711
+ const additionalPermissionNames = new _Set__default["default"]();
712
+ (_config$additionalOAu = config.additionalOAuthScopes) === null || _config$additionalOAu === void 0 ? void 0 : _forEachInstanceProperty__default["default"](_config$additionalOAu).call(_config$additionalOAu, _ref2 => {
713
+ let name = _ref2.name,
603
714
  view = _ref2.view,
604
715
  manage = _ref2.manage;
605
716
 
@@ -617,188 +728,13 @@ var validateAdditionalOAuthScopes = function validateAdditionalOAuthScopes(confi
617
728
  });
618
729
  };
619
730
 
620
- /**
621
- * NOTE:
622
- * Allows variable placeholders. Supported types are:
623
- * - `env`: For example `${env:MC_API_URL}`.
624
- * - `intl`: For example `${intl:en:Menu.title}`.
625
- * - `path`: For example `${path:./app.svg}`, or `${path:@commercetools-frontend/assets/application-icons/rocket.svg}`.
626
- */
627
- var variableSyntax = /\${([ ~:\w.'",\-/()@]+?)}/g;
628
- var envRefSyntax = /^env:/g;
629
- var intlRefSyntax = /^intl:/g;
630
- var filePathRefSyntax = /^path:/g;
631
-
632
- var hasVariablePlaceholder = function hasVariablePlaceholder(valueOfEnvConfig) {
633
- return typeof valueOfEnvConfig === 'string' && // Using `{regex}.test()` might cause false positives if called multiple
634
- // times on a global regular expression:
635
- // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test
636
- // As with exec() (or in combination with it), test() called multiple times
637
- // on the same global regular expression instance will advance past the previous match.
638
- Boolean(valueOfEnvConfig.match(variableSyntax));
639
- };
640
-
641
- var isEnvVariablePlaceholder = function isEnvVariablePlaceholder(valueOfPlaceholder) {
642
- return Boolean(valueOfPlaceholder.match(envRefSyntax));
643
- };
644
-
645
- var isIntlVariablePlaceholder = function isIntlVariablePlaceholder(valueOfPlaceholder) {
646
- return Boolean(valueOfPlaceholder.match(intlRefSyntax));
647
- };
648
-
649
- var isFilePathVariablePlaceholder = function isFilePathVariablePlaceholder(valueOfPlaceholder) {
650
- return Boolean(valueOfPlaceholder.match(filePathRefSyntax));
651
- };
652
-
653
- var substituteEnvVariablePlaceholder = function substituteEnvVariablePlaceholder(valueOfPlaceholder, matchedString, valueOfEnvConfig, loadingOptions) {
654
- var _valueOfPlaceholder$s = valueOfPlaceholder.split(':'),
655
- _valueOfPlaceholder$s2 = _slicedToArray(_valueOfPlaceholder$s, 2),
656
- requestedEnvVar = _valueOfPlaceholder$s2[1];
657
-
658
- var hasEnvField = loadingOptions.processEnv.hasOwnProperty(requestedEnvVar);
659
-
660
- if (!hasEnvField) {
661
- var _context;
662
-
663
- throw new Error(_concatInstanceProperty__default["default"](_context = "Missing environment variable '".concat(requestedEnvVar, "' specified in config as 'env:")).call(_context, requestedEnvVar, "'."));
664
- }
665
-
666
- var escapedMatchedString = matchedString.replace(/[${}:]/g, '\\$&');
667
- return valueOfEnvConfig.replace(new RegExp("(".concat(escapedMatchedString, ")+"), 'g'), loadingOptions.processEnv[requestedEnvVar]);
668
- };
669
-
670
- var substituteIntlVariablePlaceholder = function substituteIntlVariablePlaceholder(valueOfPlaceholder, matchedString, valueOfEnvConfig, loadingOptions) {
671
- var _valueOfPlaceholder$s3 = valueOfPlaceholder.split(':'),
672
- _valueOfPlaceholder$s4 = _slicedToArray(_valueOfPlaceholder$s3, 3),
673
- locale = _valueOfPlaceholder$s4[1],
674
- requestedIntlMessageId = _valueOfPlaceholder$s4[2];
675
-
676
- var translationsFilePath = require.resolve("./i18n/data/".concat(locale, ".json"), {
677
- paths: ["".concat(loadingOptions.applicationPath, "/src"), loadingOptions.applicationPath]
678
- });
679
-
680
- var translations = require(translationsFilePath);
681
-
682
- var hasIntlMessage = translations.hasOwnProperty(requestedIntlMessageId);
683
-
684
- if (!hasIntlMessage) {
685
- var _context2, _context3;
686
-
687
- throw new Error(_concatInstanceProperty__default["default"](_context2 = _concatInstanceProperty__default["default"](_context3 = "Missing message key '".concat(requestedIntlMessageId, "' specified in config as 'intl:")).call(_context3, locale, ":")).call(_context2, requestedIntlMessageId, "'."));
688
- }
689
-
690
- var escapedMatchedString = matchedString.replace(/[${}:]/g, '\\$&');
691
- return valueOfEnvConfig.replace(new RegExp("(".concat(escapedMatchedString, ")+"), 'g'), translations[requestedIntlMessageId]);
692
- };
693
-
694
- var substituteFilePathVariablePlaceholder = function substituteFilePathVariablePlaceholder(valueOfPlaceholder, matchedString, valueOfEnvConfig, loadingOptions) {
695
- var _valueOfPlaceholder$s5 = valueOfPlaceholder.split(':'),
696
- _valueOfPlaceholder$s6 = _slicedToArray(_valueOfPlaceholder$s5, 2),
697
- filePathOrModule = _valueOfPlaceholder$s6[1];
698
-
699
- var content = fs__default["default"].readFileSync(require.resolve(filePathOrModule, {
700
- // Relative paths should be resolved from the application folder.
701
- paths: [loadingOptions.applicationPath]
702
- }), {
703
- encoding: 'utf-8'
704
- });
705
- var escapedMatchedString = matchedString.replace(/[${}:]/g, '\\$&');
706
- return valueOfEnvConfig.replace(new RegExp("(".concat(escapedMatchedString, ")+"), 'g'), content);
707
- };
708
-
709
- var getValueOfPlaceholder = function getValueOfPlaceholder(valueWithPlaceholder) {
710
- return valueWithPlaceholder.replace(variableSyntax, function (_match, varName) {
711
- return _trimInstanceProperty__default["default"](varName).call(varName);
712
- }).replace(/\s/g, '');
713
- };
714
-
715
- var substituteVariablePlaceholders = function substituteVariablePlaceholders(config, loadingOptions) {
716
- return JSON.parse(_JSON$stringify__default["default"](config), function (_key, value) {
717
- // Only strings are allowed
718
- var substitutedValue = value;
719
-
720
- if (hasVariablePlaceholder(substitutedValue)) {
721
- var matchResult = substitutedValue.match(variableSyntax);
722
-
723
- if (matchResult) {
724
- _forEachInstanceProperty__default["default"](matchResult).call(matchResult, function (matchedString) {
725
- var valueOfPlaceholder = getValueOfPlaceholder(matchedString);
726
-
727
- if (isEnvVariablePlaceholder(valueOfPlaceholder)) {
728
- substitutedValue = substituteEnvVariablePlaceholder(valueOfPlaceholder, matchedString, substitutedValue, loadingOptions);
729
- } else if (isIntlVariablePlaceholder(valueOfPlaceholder)) {
730
- substitutedValue = substituteIntlVariablePlaceholder(valueOfPlaceholder, matchedString, substitutedValue, loadingOptions);
731
- } else if (isFilePathVariablePlaceholder(valueOfPlaceholder)) {
732
- substitutedValue = substituteFilePathVariablePlaceholder(valueOfPlaceholder, matchedString, substitutedValue, loadingOptions);
733
- }
734
- });
735
- }
736
- }
737
-
738
- return substitutedValue;
739
- });
740
- };
741
-
742
- var mapCloudIdentifierToApiUrl = function mapCloudIdentifierToApiUrl(key) {
743
- var _context;
744
-
745
- switch (key) {
746
- case CLOUD_IDENTIFIERS.GCP_AU:
747
- return MC_API_URLS.GCP_AU;
748
-
749
- case CLOUD_IDENTIFIERS.GCP_EU:
750
- return MC_API_URLS.GCP_EU;
751
-
752
- case CLOUD_IDENTIFIERS.GCP_US:
753
- return MC_API_URLS.GCP_US;
754
-
755
- case CLOUD_IDENTIFIERS.AWS_FRA:
756
- return MC_API_URLS.AWS_FRA;
757
-
758
- case CLOUD_IDENTIFIERS.AWS_OHIO:
759
- return MC_API_URLS.AWS_OHIO;
760
-
761
- default:
762
- // We would probably never get to this point, as the JSON schema validation
763
- // kicks in before.
764
- throw new Error(_concatInstanceProperty__default["default"](_context = "Unknown cloud identifier \"".concat(key, "\". Supported values: ")).call(_context, _Object$values__default["default"](CLOUD_IDENTIFIERS).toString()));
765
- }
766
- };
767
-
768
- var getUniqueValues = function getUniqueValues() {
769
- var _context2;
770
-
771
- var initialValues = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
772
- var additionalValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
773
- return uniq__default["default"](_concatInstanceProperty__default["default"](_context2 = []).call(_context2, _toConsumableArray(initialValues), _toConsumableArray(additionalValues)));
774
- };
775
-
776
- var nonProductionEnvironment = ['development', 'test'];
777
-
778
- var getIsProd = function getIsProd(env) {
779
- return (// TL;DR: in case the `MC_APP_ENV` is defined, we consider that it's
780
- // a production environment unless it's one of `development` or `test`.
781
- // This allows to use for example the `staging` value, which from the
782
- // application perspective is still considered a production environment.
783
- env.MC_APP_ENV ? !_includesInstanceProperty__default["default"](nonProductionEnvironment).call(nonProductionEnvironment, env.MC_APP_ENV) : env.NODE_ENV === 'production'
784
- );
785
- };
786
-
787
- var getOrThrow = function getOrThrow(fn, errorMessage) {
788
- try {
789
- return fn();
790
- } catch (error) {
791
- throw new Error(errorMessage);
792
- }
793
- };
794
-
795
731
  function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
796
732
 
797
- function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context6, _context7; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context6 = ownKeys$1(Object(source), !0)).call(_context6, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context7 = ownKeys$1(Object(source))).call(_context7, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
733
+ function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context5, _context6; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context5 = ownKeys$1(Object(source), !0)).call(_context5, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context6 = ownKeys$1(Object(source))).call(_context6, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
798
734
  // to the `entryPointUriPath`. Computing the full path is done internally to keep
799
735
  // the configuration simple.
800
736
 
801
- var computeUriPath = function computeUriPath(uriPath, entryPointUriPath) {
737
+ const computeUriPath = (uriPath, entryPointUriPath) => {
802
738
  var _context;
803
739
 
804
740
  // In case the `uriPath` is only `/`, it means that the link is supposed to be
@@ -812,43 +748,42 @@ var computeUriPath = function computeUriPath(uriPath, entryPointUriPath) {
812
748
  return _concatInstanceProperty__default["default"](_context = "".concat(entryPointUriPath, "/")).call(_context, uriPath);
813
749
  };
814
750
 
815
- var getPermissions = function getPermissions(appConfig) {
816
- var _context2, _appConfig$additional, _context3, _context4;
817
-
818
- var additionalResourceAccessKeyToOauthScopeMap = _reduceInstanceProperty__default["default"](_context2 = appConfig.additionalOAuthScopes || []).call(_context2, function (previousOauthScope, _ref) {
819
- var _objectSpread2;
751
+ const getPermissions = appConfig => {
752
+ var _context2, _appConfig$additional, _context3;
820
753
 
821
- var name = _ref.name,
754
+ const additionalResourceAccessKeyToOauthScopeMap = _reduceInstanceProperty__default["default"](_context2 = appConfig.additionalOAuthScopes || []).call(_context2, (previousOauthScope, _ref) => {
755
+ let name = _ref.name,
822
756
  view = _ref.view,
823
757
  manage = _ref.manage;
824
- var formattedResourceKey = formatters.formatEntryPointUriPathToResourceAccessKey(name);
825
- return _objectSpread$1(_objectSpread$1({}, previousOauthScope), {}, (_objectSpread2 = {}, _defineProperty(_objectSpread2, "view".concat(formattedResourceKey), view), _defineProperty(_objectSpread2, "manage".concat(formattedResourceKey), manage), _objectSpread2));
758
+ const formattedResourceKey = formatters.formatEntryPointUriPathToResourceAccessKey(name);
759
+ return _objectSpread$1(_objectSpread$1({}, previousOauthScope), {}, {
760
+ ["view".concat(formattedResourceKey)]: view,
761
+ ["manage".concat(formattedResourceKey)]: manage
762
+ });
826
763
  }, {});
827
764
 
828
- var additionalPermissionNames = ((_appConfig$additional = appConfig.additionalOAuthScopes) === null || _appConfig$additional === void 0 ? void 0 : _mapInstanceProperty__default["default"](_appConfig$additional).call(_appConfig$additional, function (_ref2) {
829
- var name = _ref2.name;
765
+ const additionalPermissionNames = ((_appConfig$additional = appConfig.additionalOAuthScopes) === null || _appConfig$additional === void 0 ? void 0 : _mapInstanceProperty__default["default"](_appConfig$additional).call(_appConfig$additional, _ref2 => {
766
+ let name = _ref2.name;
830
767
  return name;
831
768
  })) || [];
832
- var permissionKeys = formatters.entryPointUriPathToResourceAccesses(appConfig.entryPointUriPath, additionalPermissionNames);
769
+ const permissionKeys = formatters.entryPointUriPathToResourceAccesses(appConfig.entryPointUriPath, additionalPermissionNames);
833
770
 
834
- var additionalPermissions = _mapInstanceProperty__default["default"](_context3 = _Object$keys__default["default"](additionalResourceAccessKeyToOauthScopeMap)).call(_context3, function (additionalResourceAccessKey) {
835
- return {
836
- name: permissionKeys[additionalResourceAccessKey],
837
- oAuthScopes: additionalResourceAccessKeyToOauthScopeMap[additionalResourceAccessKey]
838
- };
839
- });
771
+ const additionalPermissions = _mapInstanceProperty__default["default"](_context3 = _Object$keys__default["default"](additionalResourceAccessKeyToOauthScopeMap)).call(_context3, additionalResourceAccessKey => ({
772
+ name: permissionKeys[additionalResourceAccessKey],
773
+ oAuthScopes: additionalResourceAccessKeyToOauthScopeMap[additionalResourceAccessKey]
774
+ }));
840
775
 
841
- return _concatInstanceProperty__default["default"](_context4 = [{
776
+ return [{
842
777
  name: permissionKeys.view,
843
778
  oAuthScopes: appConfig.oAuthScopes.view
844
779
  }, {
845
780
  name: permissionKeys.manage,
846
781
  oAuthScopes: appConfig.oAuthScopes.manage
847
- }]).call(_context4, _toConsumableArray(additionalPermissions));
782
+ }, ...additionalPermissions];
848
783
  };
849
784
 
850
785
  function transformCustomApplicationConfigToData(appConfig) {
851
- var _context5;
786
+ var _context4;
852
787
 
853
788
  validateEntryPointUriPath(appConfig);
854
789
  validateSubmenuLinks(appConfig);
@@ -862,26 +797,70 @@ function transformCustomApplicationConfigToData(appConfig) {
862
797
  permissions: getPermissions(appConfig),
863
798
  icon: appConfig.icon,
864
799
  mainMenuLink: appConfig.mainMenuLink,
865
- submenuLinks: _mapInstanceProperty__default["default"](_context5 = appConfig.submenuLinks).call(_context5, function (submenuLink) {
866
- return _objectSpread$1(_objectSpread$1({}, submenuLink), {}, {
867
- uriPath: computeUriPath(submenuLink.uriPath, appConfig.entryPointUriPath)
868
- });
869
- })
800
+ submenuLinks: _mapInstanceProperty__default["default"](_context4 = appConfig.submenuLinks).call(_context4, submenuLink => _objectSpread$1(_objectSpread$1({}, submenuLink), {}, {
801
+ uriPath: computeUriPath(submenuLink.uriPath, appConfig.entryPointUriPath)
802
+ }))
870
803
  };
871
804
  }
872
805
 
806
+ const mapCloudIdentifierToApiUrl = key => {
807
+ var _context;
808
+
809
+ switch (key) {
810
+ case CLOUD_IDENTIFIERS.GCP_AU:
811
+ return MC_API_URLS.GCP_AU;
812
+
813
+ case CLOUD_IDENTIFIERS.GCP_EU:
814
+ return MC_API_URLS.GCP_EU;
815
+
816
+ case CLOUD_IDENTIFIERS.GCP_US:
817
+ return MC_API_URLS.GCP_US;
818
+
819
+ case CLOUD_IDENTIFIERS.AWS_FRA:
820
+ return MC_API_URLS.AWS_FRA;
821
+
822
+ case CLOUD_IDENTIFIERS.AWS_OHIO:
823
+ return MC_API_URLS.AWS_OHIO;
824
+
825
+ default:
826
+ // We would probably never get to this point, as the JSON schema validation
827
+ // kicks in before.
828
+ throw new Error(_concatInstanceProperty__default["default"](_context = "Unknown cloud identifier \"".concat(key, "\". Supported values: ")).call(_context, _Object$values__default["default"](CLOUD_IDENTIFIERS).toString()));
829
+ }
830
+ };
831
+
832
+ const getUniqueValues = function () {
833
+ let initialValues = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
834
+ let additionalValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
835
+ return uniq__default["default"]([...initialValues, ...additionalValues]);
836
+ };
837
+
838
+ const nonProductionEnvironment = ['development', 'test'];
839
+
840
+ const getIsProd = env => // TL;DR: in case the `MC_APP_ENV` is defined, we consider that it's
841
+ // a production environment unless it's one of `development` or `test`.
842
+ // This allows to use for example the `staging` value, which from the
843
+ // application perspective is still considered a production environment.
844
+ env.MC_APP_ENV ? !_includesInstanceProperty__default["default"](nonProductionEnvironment).call(nonProductionEnvironment, env.MC_APP_ENV) : env.NODE_ENV === 'production';
845
+
846
+ const getOrThrow = (fn, errorMessage) => {
847
+ try {
848
+ return fn();
849
+ } catch (error) {
850
+ throw new Error(errorMessage);
851
+ }
852
+ };
853
+
873
854
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
874
855
 
875
856
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
876
857
  // TODO: make it configurable.
877
- var developmentPort = 3001;
878
- var developmentAppUrl = "http://localhost:".concat(developmentPort);
858
+ const developmentPort = 3001;
859
+ const developmentAppUrl = "http://localhost:".concat(developmentPort);
879
860
 
880
- var trimTrailingSlash = function trimTrailingSlash(value) {
881
- return value.replace(/\/$/, '');
882
- };
861
+ const trimTrailingSlash = value => value.replace(/\/$/, '');
883
862
 
884
- var omitDevConfigIfEmpty = function omitDevConfigIfEmpty(devConfig) {
863
+ const omitDevConfigIfEmpty = devConfig => {
885
864
  if ( // @ts-expect-error: the `accountLinks` is not explicitly typed as it's only used by the account app.
886
865
  devConfig !== null && devConfig !== void 0 && devConfig.accountLinks || devConfig !== null && devConfig !== void 0 && devConfig.menuLinks || devConfig !== null && devConfig !== void 0 && devConfig.oidc) return devConfig;
887
866
  return undefined;
@@ -889,12 +868,12 @@ var omitDevConfigIfEmpty = function omitDevConfigIfEmpty(devConfig) {
889
868
  // again will result in returning the cached value.
890
869
 
891
870
 
892
- var cachedConfig;
871
+ let cachedConfig;
893
872
 
894
- var processConfig = function processConfig() {
873
+ const processConfig = function () {
895
874
  var _ref2, _processEnv$MC_APP_EN, _appConfig$additional, _ref3, _context, _appConfig$env$develo, _appConfig$headers, _appConfig$headers2, _appConfig$headers2$c, _context2, _appConfig$headers3, _appConfig$headers3$c, _appConfig$headers4, _appConfig$headers4$c;
896
875
 
897
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
876
+ let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
898
877
  _ref$disableCache = _ref.disableCache,
899
878
  disableCache = _ref$disableCache === void 0 ? false : _ref$disableCache,
900
879
  _ref$processEnv = _ref.processEnv,
@@ -903,37 +882,31 @@ var processConfig = function processConfig() {
903
882
  applicationPath = _ref$applicationPath === void 0 ? fs__default["default"].realpathSync(process.cwd()) : _ref$applicationPath;
904
883
 
905
884
  if (cachedConfig && !disableCache) return cachedConfig;
906
- var rawConfig = loadConfig(applicationPath);
885
+ const rawConfig = loadConfig(applicationPath);
907
886
  validateConfig(rawConfig);
908
- var appConfig = substituteVariablePlaceholders(rawConfig, {
909
- applicationPath: applicationPath,
910
- processEnv: processEnv
887
+ const appConfig = substituteVariablePlaceholders(rawConfig, {
888
+ applicationPath,
889
+ processEnv
911
890
  });
912
- var customApplicationData = transformCustomApplicationConfigToData(appConfig);
913
- var appEnvKey = (_ref2 = (_processEnv$MC_APP_EN = processEnv.MC_APP_ENV) !== null && _processEnv$MC_APP_EN !== void 0 ? _processEnv$MC_APP_EN : processEnv.NODE_ENV) !== null && _ref2 !== void 0 ? _ref2 : 'development';
914
- var isProd = getIsProd(processEnv);
915
- var additionalAppEnv = (_appConfig$additional = appConfig.additionalEnv) !== null && _appConfig$additional !== void 0 ? _appConfig$additional : {};
916
- var revision = (_ref3 = additionalAppEnv.revision) !== null && _ref3 !== void 0 ? _ref3 : ''; // Parse all the supported URLs, which gets implicitly validated
917
-
918
- var envAppUrl = isProd ? customApplicationData.url : developmentAppUrl;
919
- var appUrl = getOrThrow(function () {
920
- return new _URL__default["default"](envAppUrl);
921
- }, "Invalid application URL: \"".concat(envAppUrl, "\"")); // Use `||` instead of `??` to include empty string values.
922
-
923
- var envCdnUrl = isProd ? appConfig.env.production.cdnUrl || appUrl.href : developmentAppUrl;
924
- var cdnUrl = getOrThrow(function () {
925
- return new _URL__default["default"](envCdnUrl);
926
- }, "Invalid application CDN URL: \"".concat(envCdnUrl, "\""));
927
- var mcApiUrl = getOrThrow(function () {
928
- return new _URL__default["default"]( // Use `||` instead of `??` to include empty string values.
929
- appConfig.mcApiUrl || mapCloudIdentifierToApiUrl(appConfig.cloudIdentifier));
930
- }, "Invalid MC API URL: \"".concat(appConfig.mcApiUrl, "\"")); // The real application ID is only used in production.
891
+ const customApplicationData = transformCustomApplicationConfigToData(appConfig);
892
+ const appEnvKey = (_ref2 = (_processEnv$MC_APP_EN = processEnv.MC_APP_ENV) !== null && _processEnv$MC_APP_EN !== void 0 ? _processEnv$MC_APP_EN : processEnv.NODE_ENV) !== null && _ref2 !== void 0 ? _ref2 : 'development';
893
+ const isProd = getIsProd(processEnv);
894
+ const additionalAppEnv = (_appConfig$additional = appConfig.additionalEnv) !== null && _appConfig$additional !== void 0 ? _appConfig$additional : {};
895
+ const revision = (_ref3 = additionalAppEnv.revision) !== null && _ref3 !== void 0 ? _ref3 : ''; // Parse all the supported URLs, which gets implicitly validated
896
+
897
+ const envAppUrl = isProd ? customApplicationData.url : developmentAppUrl;
898
+ const appUrl = getOrThrow(() => new _URL__default["default"](envAppUrl), "Invalid application URL: \"".concat(envAppUrl, "\"")); // Use `||` instead of `??` to include empty string values.
899
+
900
+ const envCdnUrl = isProd ? appConfig.env.production.cdnUrl || appUrl.href : developmentAppUrl;
901
+ const cdnUrl = getOrThrow(() => new _URL__default["default"](envCdnUrl), "Invalid application CDN URL: \"".concat(envCdnUrl, "\""));
902
+ const mcApiUrl = getOrThrow(() => new _URL__default["default"]( // Use `||` instead of `??` to include empty string values.
903
+ appConfig.mcApiUrl || mapCloudIdentifierToApiUrl(appConfig.cloudIdentifier)), "Invalid MC API URL: \"".concat(appConfig.mcApiUrl, "\"")); // The real application ID is only used in production.
931
904
  // In development, we prefix the entry point with the "__local" prefix.
932
905
  // This is important to determine to which URL the MC should redirect to
933
906
  // after successful login.
934
907
 
935
- var applicationId = isProd ? _concatInstanceProperty__default["default"](_context = "".concat(customApplicationData.id, ":")).call(_context, customApplicationData.entryPointUriPath) : "__local:".concat(customApplicationData.entryPointUriPath);
936
- var developmentConfig = isProd ? undefined : omitDevConfigIfEmpty({
908
+ const applicationId = isProd ? _concatInstanceProperty__default["default"](_context = "".concat(customApplicationData.id, ":")).call(_context, customApplicationData.entryPointUriPath) : "__local:".concat(customApplicationData.entryPointUriPath);
909
+ const developmentConfig = isProd ? undefined : omitDevConfigIfEmpty({
937
910
  oidc: omitEmpty__default["default"]({
938
911
  authorizeUrl: [// In case the MC API url points to localhost, we need to point
939
912
  // to a local running dev login page to handle the workflow properly.
@@ -955,7 +928,7 @@ var processConfig = function processConfig() {
955
928
  cachedConfig = {
956
929
  data: customApplicationData,
957
930
  env: _objectSpread(_objectSpread(_objectSpread({}, omitEmpty__default["default"](additionalAppEnv)), {}, {
958
- applicationId: applicationId,
931
+ applicationId,
959
932
  applicationName: customApplicationData.name,
960
933
  entryPointUriPath: customApplicationData.entryPointUriPath
961
934
  }, isProd || !developmentConfig ? {} : {
@@ -966,7 +939,7 @@ var processConfig = function processConfig() {
966
939
  frontendHost: appUrl.host,
967
940
  location: appConfig.cloudIdentifier,
968
941
  mcApiUrl: mcApiUrl.origin,
969
- revision: revision,
942
+ revision,
970
943
  servedByProxy: isProd
971
944
  }),
972
945
  headers: _objectSpread(_objectSpread({}, appConfig.headers), {}, {
@@ -986,9 +959,9 @@ var processConfig = function processConfig() {
986
959
  return cachedConfig;
987
960
  };
988
961
 
989
- var jsdom = new jsdom$1.JSDOM(''); // @ts-expect-error: jsdom returns DOMWindow, which doesn't match Window dompurify expects
962
+ const jsdom = new jsdom$1.JSDOM(''); // @ts-expect-error: jsdom returns DOMWindow, which doesn't match Window dompurify expects
990
963
 
991
- var DOMPurify = createDOMPurify__default["default"](jsdom.window);
964
+ const DOMPurify = createDOMPurify__default["default"](jsdom.window);
992
965
  function sanitizeSvg(data) {
993
966
  return DOMPurify.sanitize(data, {
994
967
  USE_PROFILES: {