@commercetools-frontend/application-config 22.2.1 → 22.3.1

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.
@@ -32,7 +32,7 @@ var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/string
32
32
  var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
33
33
  var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
34
34
  var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
35
- var formatters = require('./formatters-b42c3866.cjs.prod.js');
35
+ var formatters = require('./formatters-4f8eba33.cjs.prod.js');
36
36
  var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
37
37
  var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
38
38
  var Ajv = require('ajv');
@@ -74,28 +74,19 @@ var uniq__default = /*#__PURE__*/_interopDefault(uniq);
74
74
  var createDOMPurify__default = /*#__PURE__*/_interopDefault(createDOMPurify);
75
75
 
76
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); }; }
77
-
78
77
  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; } }
79
-
80
78
  let MissingOrInvalidConfigError = /*#__PURE__*/function (_Error) {
81
79
  _inherits(MissingOrInvalidConfigError, _Error);
82
-
83
80
  var _super = _createSuper(MissingOrInvalidConfigError);
84
-
85
81
  function MissingOrInvalidConfigError(message) {
86
82
  var _this;
87
-
88
83
  _classCallCheck(this, MissingOrInvalidConfigError);
89
-
90
84
  _this = _super.call(this, message);
91
-
92
85
  _Object$defineProperty__default["default"](_assertThisInitialized(_this), 'name', {
93
86
  value: 'MissingOrInvalidConfigError'
94
87
  });
95
-
96
88
  return _this;
97
89
  }
98
-
99
90
  return _createClass(MissingOrInvalidConfigError);
100
91
  }( /*#__PURE__*/_wrapNativeSuper(Error));
101
92
 
@@ -103,30 +94,27 @@ let MissingOrInvalidConfigError = /*#__PURE__*/function (_Error) {
103
94
  // for instance in respect to both source files and dist files.
104
95
  const findPackageRootPath = dir => {
105
96
  const packageJsonPath = path__default["default"].join(dir, 'package.json');
106
-
107
97
  if (fs__default["default"].existsSync(packageJsonPath)) {
108
98
  return dir;
109
99
  }
110
-
111
100
  const parentDir = path__default["default"].join(dir, '..');
112
101
  return findPackageRootPath(parentDir);
113
102
  };
114
-
115
103
  const loadJsModule = filePath => {
116
- const packageRootPath = findPackageRootPath( // Start from the parent folder
117
- path__default["default"].join(__dirname, '..')); // Load the JS module using a child process. This is primarly to avoid
104
+ const packageRootPath = findPackageRootPath(
105
+ // Start from the parent folder
106
+ path__default["default"].join(__dirname, '..'));
107
+ // Load the JS module using a child process. This is primarly to avoid
118
108
  // unwanted behaviors using `@babel/register` in the main process.
119
109
  // The loader script does the actual `require` of the given `filePath`
120
110
  // and uses `@babel/register` to correctly parse and execute the file.
121
111
  // The "required module output" is then written into `stdout` and parsed
122
112
  // as JSON.
123
-
124
113
  const output = child_process.execFileSync('node', [path__default["default"].join(packageRootPath, 'scripts/load-js-module.js'), filePath], {
125
114
  encoding: 'utf8'
126
115
  });
127
116
  return JSON.parse(output);
128
117
  };
129
-
130
118
  const moduleName = 'custom-application-config';
131
119
  const explorer = cosmiconfig.cosmiconfigSync(moduleName, {
132
120
  // Restrict the supported file formats / names
@@ -141,24 +129,21 @@ const explorer = cosmiconfig.cosmiconfigSync(moduleName, {
141
129
  });
142
130
  const getConfigPath = () => {
143
131
  const configFile = explorer.search();
144
-
145
132
  if (!configFile) {
146
133
  throw new Error("Missing or invalid Custom Application configuration file.");
147
134
  }
148
-
149
135
  return configFile.filepath;
150
136
  };
151
-
152
137
  const loadConfig = applicationPath => {
153
138
  const configFile = explorer.search(applicationPath);
154
-
155
139
  if (!configFile || !configFile.config) {
156
140
  throw new MissingOrInvalidConfigError("Missing or invalid Custom Application configuration file.");
157
141
  }
158
-
159
142
  return configFile.config;
160
143
  };
161
144
 
145
+ // Transifex's Structured JSON format.
146
+ // https://help.transifex.com/en/articles/6220899-structured-json
162
147
  /**
163
148
  * NOTE:
164
149
  * Allows variable placeholders. Supported types are:
@@ -170,70 +155,52 @@ const variableSyntax = /\${([ ~:\w.'",\-/()@]+?)}/g;
170
155
  const envRefSyntax = /^env:/g;
171
156
  const intlRefSyntax = /^intl:/g;
172
157
  const filePathRefSyntax = /^path:/g;
173
-
174
- const hasVariablePlaceholder = valueOfEnvConfig => typeof valueOfEnvConfig === 'string' && // Using `{regex}.test()` might cause false positives if called multiple
158
+ const hasVariablePlaceholder = valueOfEnvConfig => typeof valueOfEnvConfig === 'string' &&
159
+ // Using `{regex}.test()` might cause false positives if called multiple
175
160
  // times on a global regular expression:
176
161
  // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test
177
162
  // As with exec() (or in combination with it), test() called multiple times
178
163
  // on the same global regular expression instance will advance past the previous match.
179
164
  Boolean(valueOfEnvConfig.match(variableSyntax));
180
-
181
165
  const isEnvVariablePlaceholder = valueOfPlaceholder => Boolean(valueOfPlaceholder.match(envRefSyntax));
182
-
183
166
  const isIntlVariablePlaceholder = valueOfPlaceholder => Boolean(valueOfPlaceholder.match(intlRefSyntax));
184
-
185
167
  const isFilePathVariablePlaceholder = valueOfPlaceholder => Boolean(valueOfPlaceholder.match(filePathRefSyntax));
186
-
187
168
  const isStructuredJson = message => (message === null || message === void 0 ? void 0 : message.string) !== undefined;
188
-
189
169
  const substituteEnvVariablePlaceholder = (valueOfPlaceholder, matchedString, valueOfEnvConfig, loadingOptions) => {
190
170
  const _valueOfPlaceholder$s = valueOfPlaceholder.split(':'),
191
- _valueOfPlaceholder$s2 = _slicedToArray(_valueOfPlaceholder$s, 2),
192
- requestedEnvVar = _valueOfPlaceholder$s2[1];
193
-
171
+ _valueOfPlaceholder$s2 = _slicedToArray(_valueOfPlaceholder$s, 2),
172
+ requestedEnvVar = _valueOfPlaceholder$s2[1];
194
173
  const hasEnvField = loadingOptions.processEnv.hasOwnProperty(requestedEnvVar);
195
-
196
174
  if (!hasEnvField) {
197
175
  var _context;
198
-
199
176
  throw new Error(_concatInstanceProperty__default["default"](_context = "Missing environment variable '".concat(requestedEnvVar, "' specified in config as 'env:")).call(_context, requestedEnvVar, "'."));
200
177
  }
201
-
202
178
  const escapedMatchedString = matchedString.replace(/[${}:]/g, '\\$&');
203
179
  return valueOfEnvConfig.replace(new RegExp("(".concat(escapedMatchedString, ")+"), 'g'), loadingOptions.processEnv[requestedEnvVar]);
204
180
  };
205
-
206
181
  const substituteIntlVariablePlaceholder = (valueOfPlaceholder, matchedString, valueOfEnvConfig, loadingOptions) => {
207
182
  const _valueOfPlaceholder$s3 = valueOfPlaceholder.split(':'),
208
- _valueOfPlaceholder$s4 = _slicedToArray(_valueOfPlaceholder$s3, 3),
209
- locale = _valueOfPlaceholder$s4[1],
210
- requestedIntlMessageId = _valueOfPlaceholder$s4[2];
211
-
183
+ _valueOfPlaceholder$s4 = _slicedToArray(_valueOfPlaceholder$s3, 3),
184
+ locale = _valueOfPlaceholder$s4[1],
185
+ requestedIntlMessageId = _valueOfPlaceholder$s4[2];
212
186
  const translationsFilePath = require.resolve("./i18n/data/".concat(locale, ".json"), {
213
187
  paths: ["".concat(loadingOptions.applicationPath, "/src"), loadingOptions.applicationPath]
214
188
  });
215
-
216
189
  const translations = require(translationsFilePath);
217
-
218
190
  const hasIntlMessage = translations.hasOwnProperty(requestedIntlMessageId);
219
-
220
191
  if (!hasIntlMessage) {
221
192
  var _context2, _context3;
222
-
223
193
  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
194
  }
225
-
226
195
  const translation = translations[requestedIntlMessageId];
227
196
  const translationValue = isStructuredJson(translation) ? translation.string : translation;
228
197
  const escapedMatchedString = matchedString.replace(/[${}:]/g, '\\$&');
229
198
  return valueOfEnvConfig.replace(new RegExp("(".concat(escapedMatchedString, ")+"), 'g'), translationValue);
230
199
  };
231
-
232
200
  const substituteFilePathVariablePlaceholder = (valueOfPlaceholder, matchedString, valueOfEnvConfig, loadingOptions) => {
233
201
  const _valueOfPlaceholder$s5 = valueOfPlaceholder.split(':'),
234
- _valueOfPlaceholder$s6 = _slicedToArray(_valueOfPlaceholder$s5, 2),
235
- filePathOrModule = _valueOfPlaceholder$s6[1];
236
-
202
+ _valueOfPlaceholder$s6 = _slicedToArray(_valueOfPlaceholder$s5, 2),
203
+ filePathOrModule = _valueOfPlaceholder$s6[1];
237
204
  const content = fs__default["default"].readFileSync(require.resolve(filePathOrModule, {
238
205
  // Relative paths should be resolved from the application folder.
239
206
  paths: [loadingOptions.applicationPath]
@@ -243,20 +210,15 @@ const substituteFilePathVariablePlaceholder = (valueOfPlaceholder, matchedString
243
210
  const escapedMatchedString = matchedString.replace(/[${}:]/g, '\\$&');
244
211
  return valueOfEnvConfig.replace(new RegExp("(".concat(escapedMatchedString, ")+"), 'g'), content);
245
212
  };
246
-
247
213
  const getValueOfPlaceholder = valueWithPlaceholder => valueWithPlaceholder.replace(variableSyntax, (_match, varName) => _trimInstanceProperty__default["default"](varName).call(varName)).replace(/\s/g, '');
248
-
249
214
  const substituteVariablePlaceholders = (config, loadingOptions) => JSON.parse(_JSON$stringify__default["default"](config), (_key, value) => {
250
215
  // Only strings are allowed
251
216
  let substitutedValue = value;
252
-
253
217
  if (hasVariablePlaceholder(substitutedValue)) {
254
218
  const matchResult = substitutedValue.match(variableSyntax);
255
-
256
219
  if (matchResult) {
257
220
  _forEachInstanceProperty__default["default"](matchResult).call(matchResult, matchedString => {
258
221
  const valueOfPlaceholder = getValueOfPlaceholder(matchedString);
259
-
260
222
  if (isEnvVariablePlaceholder(valueOfPlaceholder)) {
261
223
  substitutedValue = substituteEnvVariablePlaceholder(valueOfPlaceholder, matchedString, substitutedValue, loadingOptions);
262
224
  } else if (isIntlVariablePlaceholder(valueOfPlaceholder)) {
@@ -267,7 +229,6 @@ const substituteVariablePlaceholders = (config, loadingOptions) => JSON.parse(_J
267
229
  });
268
230
  }
269
231
  }
270
-
271
232
  return substitutedValue;
272
233
  });
273
234
 
@@ -629,24 +590,26 @@ var schemaJson = {
629
590
  * non-consecutive underscores and hyphens. Leading and trailing underscore and hyphens are also not allowed.
630
591
  */
631
592
  const ENTRY_POINT_URI_PATH_REGEX = /^[^-_#]([0-9a-z]|[-_](?![-_])){0,62}[^-_#]$/g;
593
+
632
594
  /**
633
595
  * 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.
634
596
  */
635
-
636
597
  const PERMISSION_GROUP_NAME_REGEX = /^[^-#]([a-z]|[-](?![-])){0,62}[^-#]$/g;
637
598
  const CLOUD_IDENTIFIERS = {
638
599
  GCP_AU: 'gcp-au',
639
600
  GCP_EU: 'gcp-eu',
640
601
  GCP_US: 'gcp-us',
641
602
  AWS_FRA: 'aws-fra',
642
- AWS_OHIO: 'aws-ohio'
603
+ AWS_OHIO: 'aws-ohio',
604
+ AWS_CN: 'aws-cn'
643
605
  };
644
606
  const MC_API_URLS = {
645
607
  GCP_AU: 'https://mc-api.australia-southeast1.gcp.commercetools.com',
646
608
  GCP_EU: 'https://mc-api.europe-west1.gcp.commercetools.com',
647
609
  GCP_US: 'https://mc-api.us-central1.gcp.commercetools.com',
648
610
  AWS_FRA: 'https://mc-api.eu-central-1.aws.commercetools.com',
649
- AWS_OHIO: 'https://mc-api.us-east-2.aws.commercetools.com'
611
+ AWS_OHIO: 'https://mc-api.us-east-2.aws.commercetools.com',
612
+ AWS_CN: 'https://mc-api.cn-northwest-1.aws.commercetools.cn'
650
613
  };
651
614
 
652
615
  const ajv = new Ajv__default["default"]({
@@ -654,33 +617,25 @@ const ajv = new Ajv__default["default"]({
654
617
  useDefaults: true
655
618
  });
656
619
  const validate = ajv.compile(schemaJson);
657
-
658
620
  const printErrors = errors => {
659
621
  if (!errors) {
660
622
  return 'No errors';
661
623
  }
662
-
663
624
  return _mapInstanceProperty__default["default"](errors).call(errors, error => {
664
625
  var _context, _context2, _context3;
665
-
666
626
  const baseMessage = _concatInstanceProperty__default["default"](_context = "".concat(error.instancePath, " ")).call(_context, error.message);
667
-
668
627
  switch (error.keyword) {
669
628
  case 'additionalProperties':
670
629
  return _concatInstanceProperty__default["default"](_context2 = "".concat(baseMessage, ": ")).call(_context2, error.params.additionalProperty);
671
-
672
630
  case 'enum':
673
631
  return _concatInstanceProperty__default["default"](_context3 = "".concat(baseMessage, ": ")).call(_context3, error.params.allowedValues.toString());
674
-
675
632
  default:
676
633
  return baseMessage;
677
634
  }
678
635
  }).join('\n');
679
636
  };
680
-
681
637
  const validateConfig = config => {
682
638
  const valid = validate(config);
683
-
684
639
  if (!valid) {
685
640
  throw new Error(printErrors(validate.errors));
686
641
  }
@@ -692,87 +647,73 @@ const validateEntryPointUriPath = config => {
692
647
  };
693
648
  const validateSubmenuLinks = config => {
694
649
  var _context4;
695
-
696
650
  const uriPathSet = new _Set__default["default"]();
697
-
698
651
  _forEachInstanceProperty__default["default"](_context4 = config.submenuLinks).call(_context4, _ref => {
699
652
  let uriPath = _ref.uriPath;
700
-
701
653
  if (uriPathSet.has(uriPath)) {
702
654
  throw new Error('Duplicate URI path. Every submenu link must have a unique URI path value');
703
655
  }
704
-
705
656
  uriPathSet.add(uriPath);
706
657
  });
707
658
  };
708
659
  const validateAdditionalOAuthScopes = config => {
709
660
  var _config$additionalOAu;
710
-
711
661
  const additionalPermissionNames = new _Set__default["default"]();
712
662
  (_config$additionalOAu = config.additionalOAuthScopes) === null || _config$additionalOAu === void 0 ? void 0 : _forEachInstanceProperty__default["default"](_config$additionalOAu).call(_config$additionalOAu, _ref2 => {
713
663
  let name = _ref2.name,
714
- view = _ref2.view,
715
- manage = _ref2.manage;
716
-
664
+ view = _ref2.view,
665
+ manage = _ref2.manage;
717
666
  if ((_Array$isArray__default["default"](view) && view.length === 0 || !view) && (_Array$isArray__default["default"](manage) && manage.length === 0 || !manage)) {
718
667
  throw new Error("At least one OAuth Scope for permission group name \"".concat(name, "\" is required"));
719
668
  } else if (additionalPermissionNames.has(name)) {
720
669
  throw new Error("Duplicate additional permission group name \"".concat(name, "\". Every additional permission must have a unique name"));
721
670
  }
722
-
723
671
  if (!name.match(PERMISSION_GROUP_NAME_REGEX)) {
724
672
  throw new Error("Additional permission group name \"".concat(name, "\" is invalid. The value may be between 2 and 64 characters and only contain alphabetic lowercase characters and non-consecutive hyphens. Leading and trailing hyphens are also not allowed"));
725
673
  }
726
-
727
674
  additionalPermissionNames.add(name);
728
675
  });
729
676
  };
730
677
 
731
678
  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; }
732
-
733
679
  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; }
680
+
681
+ // The `uriPath` of each submenu link is supposed to be defined relative
734
682
  // to the `entryPointUriPath`. Computing the full path is done internally to keep
735
683
  // the configuration simple.
736
-
737
684
  const computeUriPath = (uriPath, entryPointUriPath) => {
738
685
  var _context;
739
-
740
686
  // In case the `uriPath` is only `/`, it means that the link is supposed to be
741
687
  // treated the same as the main application path. In this case, the return value
742
688
  // should not contain any unnecessary trailing slash and therefore we use the `entryPointUriPath`.
743
- if (uriPath === '/') return entryPointUriPath; // In case the `uriPath` is already configured including the `entryPointUriPath`,
689
+ if (uriPath === '/') return entryPointUriPath;
690
+ // In case the `uriPath` is already configured including the `entryPointUriPath`,
744
691
  // we return the `uriPath` as-is.
745
-
746
- if (_startsWithInstanceProperty__default["default"](uriPath).call(uriPath, "".concat(entryPointUriPath, "/"))) return uriPath; // Return the full path including the `entryPointUriPath` as a prefix.
747
-
692
+ if (_startsWithInstanceProperty__default["default"](uriPath).call(uriPath, "".concat(entryPointUriPath, "/"))) return uriPath;
693
+ // Return the full path including the `entryPointUriPath` as a prefix.
748
694
  return _concatInstanceProperty__default["default"](_context = "".concat(entryPointUriPath, "/")).call(_context, uriPath);
749
695
  };
750
-
751
696
  const getPermissions = appConfig => {
752
697
  var _context2, _appConfig$additional, _context3;
753
-
754
698
  const additionalResourceAccessKeyToOauthScopeMap = _reduceInstanceProperty__default["default"](_context2 = appConfig.additionalOAuthScopes || []).call(_context2, (previousOauthScope, _ref) => {
755
699
  let name = _ref.name,
756
- view = _ref.view,
757
- manage = _ref.manage;
700
+ view = _ref.view,
701
+ manage = _ref.manage;
758
702
  const formattedResourceKey = formatters.formatEntryPointUriPathToResourceAccessKey(name);
759
703
  return _objectSpread$1(_objectSpread$1({}, previousOauthScope), {}, {
760
704
  ["view".concat(formattedResourceKey)]: view,
761
705
  ["manage".concat(formattedResourceKey)]: manage
762
706
  });
763
707
  }, {});
764
-
765
708
  const additionalPermissionNames = ((_appConfig$additional = appConfig.additionalOAuthScopes) === null || _appConfig$additional === void 0 ? void 0 : _mapInstanceProperty__default["default"](_appConfig$additional).call(_appConfig$additional, _ref2 => {
766
709
  let name = _ref2.name;
767
710
  return name;
768
711
  })) || [];
769
712
  const permissionKeys = formatters.entryPointUriPathToResourceAccesses(appConfig.entryPointUriPath, additionalPermissionNames);
770
-
771
713
  const additionalPermissions = _mapInstanceProperty__default["default"](_context3 = _Object$keys__default["default"](additionalResourceAccessKeyToOauthScopeMap)).call(_context3, additionalResourceAccessKey => ({
772
714
  name: permissionKeys[additionalResourceAccessKey],
773
715
  oAuthScopes: additionalResourceAccessKeyToOauthScopeMap[additionalResourceAccessKey]
774
716
  }));
775
-
776
717
  return [{
777
718
  name: permissionKeys.view,
778
719
  oAuthScopes: appConfig.oAuthScopes.view
@@ -781,10 +722,8 @@ const getPermissions = appConfig => {
781
722
  oAuthScopes: appConfig.oAuthScopes.manage
782
723
  }, ...additionalPermissions];
783
724
  };
784
-
785
725
  function transformCustomApplicationConfigToData(appConfig) {
786
726
  var _context4;
787
-
788
727
  validateEntryPointUriPath(appConfig);
789
728
  validateSubmenuLinks(appConfig);
790
729
  validateAdditionalOAuthScopes(appConfig);
@@ -805,44 +744,37 @@ function transformCustomApplicationConfigToData(appConfig) {
805
744
 
806
745
  const mapCloudIdentifierToApiUrl = key => {
807
746
  var _context;
808
-
809
747
  switch (key) {
810
748
  case CLOUD_IDENTIFIERS.GCP_AU:
811
749
  return MC_API_URLS.GCP_AU;
812
-
813
750
  case CLOUD_IDENTIFIERS.GCP_EU:
814
751
  return MC_API_URLS.GCP_EU;
815
-
816
752
  case CLOUD_IDENTIFIERS.GCP_US:
817
753
  return MC_API_URLS.GCP_US;
818
-
819
754
  case CLOUD_IDENTIFIERS.AWS_FRA:
820
755
  return MC_API_URLS.AWS_FRA;
821
-
822
756
  case CLOUD_IDENTIFIERS.AWS_OHIO:
823
757
  return MC_API_URLS.AWS_OHIO;
824
-
758
+ case CLOUD_IDENTIFIERS.AWS_CN:
759
+ return MC_API_URLS.AWS_CN;
825
760
  default:
826
761
  // We would probably never get to this point, as the JSON schema validation
827
762
  // kicks in before.
828
763
  throw new Error(_concatInstanceProperty__default["default"](_context = "Unknown cloud identifier \"".concat(key, "\". Supported values: ")).call(_context, _Object$values__default["default"](CLOUD_IDENTIFIERS).toString()));
829
764
  }
830
765
  };
831
-
832
766
  const getUniqueValues = function () {
833
767
  let initialValues = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
834
768
  let additionalValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
835
769
  return uniq__default["default"]([...initialValues, ...additionalValues]);
836
770
  };
837
-
838
771
  const nonProductionEnvironment = ['development', 'test'];
839
-
840
- const getIsProd = env => // TL;DR: in case the `MC_APP_ENV` is defined, we consider that it's
772
+ const getIsProd = env =>
773
+ // TL;DR: in case the `MC_APP_ENV` is defined, we consider that it's
841
774
  // a production environment unless it's one of `development` or `test`.
842
775
  // This allows to use for example the `staging` value, which from the
843
776
  // application perspective is still considered a production environment.
844
777
  env.MC_APP_ENV ? !_includesInstanceProperty__default["default"](nonProductionEnvironment).call(nonProductionEnvironment, env.MC_APP_ENV) : env.NODE_ENV === 'production';
845
-
846
778
  const getOrThrow = (fn, errorMessage) => {
847
779
  try {
848
780
  return fn();
@@ -852,35 +784,30 @@ const getOrThrow = (fn, errorMessage) => {
852
784
  };
853
785
 
854
786
  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; }
855
-
856
787
  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; }
857
788
  // TODO: make it configurable.
858
789
  const developmentPort = 3001;
859
790
  const developmentAppUrl = "http://localhost:".concat(developmentPort);
860
-
861
791
  const trimTrailingSlash = value => value.replace(/\/$/, '');
862
-
863
792
  const omitDevConfigIfEmpty = devConfig => {
864
- if ( // @ts-expect-error: the `accountLinks` is not explicitly typed as it's only used by the account app.
793
+ if (
794
+ // @ts-expect-error: the `accountLinks` is not explicitly typed as it's only used by the account app.
865
795
  devConfig !== null && devConfig !== void 0 && devConfig.accountLinks || devConfig !== null && devConfig !== void 0 && devConfig.menuLinks || devConfig !== null && devConfig !== void 0 && devConfig.oidc) return devConfig;
866
796
  return undefined;
867
- }; // Keep a reference to the config so that requiring the module
868
- // again will result in returning the cached value.
869
-
797
+ };
870
798
 
799
+ // Keep a reference to the config so that requiring the module
800
+ // again will result in returning the cached value.
871
801
  let cachedConfig;
872
-
873
802
  const processConfig = function () {
874
803
  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;
875
-
876
804
  let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
877
- _ref$disableCache = _ref.disableCache,
878
- disableCache = _ref$disableCache === void 0 ? false : _ref$disableCache,
879
- _ref$processEnv = _ref.processEnv,
880
- processEnv = _ref$processEnv === void 0 ? process.env : _ref$processEnv,
881
- _ref$applicationPath = _ref.applicationPath,
882
- applicationPath = _ref$applicationPath === void 0 ? fs__default["default"].realpathSync(process.cwd()) : _ref$applicationPath;
883
-
805
+ _ref$disableCache = _ref.disableCache,
806
+ disableCache = _ref$disableCache === void 0 ? false : _ref$disableCache,
807
+ _ref$processEnv = _ref.processEnv,
808
+ processEnv = _ref$processEnv === void 0 ? process.env : _ref$processEnv,
809
+ _ref$applicationPath = _ref.applicationPath,
810
+ applicationPath = _ref$applicationPath === void 0 ? fs__default["default"].realpathSync(process.cwd()) : _ref$applicationPath;
884
811
  if (cachedConfig && !disableCache) return cachedConfig;
885
812
  const rawConfig = loadConfig(applicationPath);
886
813
  validateConfig(rawConfig);
@@ -892,26 +819,33 @@ const processConfig = function () {
892
819
  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
820
  const isProd = getIsProd(processEnv);
894
821
  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
822
+ const revision = (_ref3 = additionalAppEnv.revision) !== null && _ref3 !== void 0 ? _ref3 : '';
823
+
824
+ // Parse all the supported URLs, which gets implicitly validated
896
825
 
897
826
  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.
827
+ const appUrl = getOrThrow(() => new _URL__default["default"](envAppUrl), "Invalid application URL: \"".concat(envAppUrl, "\""));
899
828
 
829
+ // Use `||` instead of `??` to include empty string values.
900
830
  const envCdnUrl = isProd ? appConfig.env.production.cdnUrl || appUrl.href : developmentAppUrl;
901
831
  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.
832
+ const mcApiUrl = getOrThrow(() => new _URL__default["default"](
833
+ // Use `||` instead of `??` to include empty string values.
834
+ appConfig.mcApiUrl || mapCloudIdentifierToApiUrl(appConfig.cloudIdentifier)), "Invalid MC API URL: \"".concat(appConfig.mcApiUrl, "\""));
835
+
836
+ // The real application ID is only used in production.
904
837
  // In development, we prefix the entry point with the "__local" prefix.
905
838
  // This is important to determine to which URL the MC should redirect to
906
839
  // after successful login.
907
-
908
840
  const applicationId = isProd ? _concatInstanceProperty__default["default"](_context = "".concat(customApplicationData.id, ":")).call(_context, customApplicationData.entryPointUriPath) : "__local:".concat(customApplicationData.entryPointUriPath);
909
841
  const developmentConfig = isProd ? undefined : omitDevConfigIfEmpty({
910
842
  oidc: omitEmpty__default["default"]({
911
- authorizeUrl: [// In case the MC API url points to localhost, we need to point
843
+ authorizeUrl: [
844
+ // In case the MC API url points to localhost, we need to point
912
845
  // to a local running dev login page to handle the workflow properly.
913
846
  mcApiUrl.hostname === 'localhost' ? mcApiUrl.origin.replace(mcApiUrl.port, String(developmentPort)) : mcApiUrl.origin.replace('mc-api', 'mc'), '/login/authorize'].join(''),
914
- initialProjectKey: // For the `account` application, we should unset the projectKey.
847
+ initialProjectKey:
848
+ // For the `account` application, we should unset the projectKey.
915
849
  customApplicationData.entryPointUriPath === 'account' ? undefined : appConfig.env.development.initialProjectKey,
916
850
  teamId: (_appConfig$env$develo = appConfig.env.development) === null || _appConfig$env$develo === void 0 ? void 0 : _appConfig$env$develo.teamId,
917
851
  oAuthScopes: appConfig.oAuthScopes,
@@ -959,8 +893,8 @@ const processConfig = function () {
959
893
  return cachedConfig;
960
894
  };
961
895
 
962
- const jsdom = new jsdom$1.JSDOM(''); // @ts-expect-error: jsdom returns DOMWindow, which doesn't match Window dompurify expects
963
-
896
+ const jsdom = new jsdom$1.JSDOM('');
897
+ // @ts-expect-error: jsdom returns DOMWindow, which doesn't match Window dompurify expects
964
898
  const DOMPurify = createDOMPurify__default["default"](jsdom.window);
965
899
  function sanitizeSvg(data) {
966
900
  return DOMPurify.sanitize(data, {
@@ -968,7 +902,8 @@ function sanitizeSvg(data) {
968
902
  svg: true
969
903
  },
970
904
  RETURN_DOM: true,
971
- FORBID_ATTR: [// To avoid injection by using `style="filter:url(\"data:image/svg+xml,<svg`
905
+ FORBID_ATTR: [
906
+ // To avoid injection by using `style="filter:url(\"data:image/svg+xml,<svg`
972
907
  'style']
973
908
  }).innerHTML;
974
909
  }