@commercetools-frontend/application-config 27.9.1 → 27.9.3
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.
- package/dist/commercetools-frontend-application-config.cjs.dev.js +60 -68
- package/dist/commercetools-frontend-application-config.cjs.prod.js +60 -68
- package/dist/commercetools-frontend-application-config.esm.js +58 -67
- package/dist/{formatters-3e1c755e.cjs.dev.js → formatters-4515015b.cjs.prod.js} +10 -13
- package/dist/{formatters-e218c305.esm.js → formatters-5629a23b.esm.js} +10 -12
- package/dist/{formatters-89609c66.cjs.prod.js → formatters-5a68b5ac.cjs.dev.js} +10 -13
- package/package.json +3 -3
- package/ssr/dist/commercetools-frontend-application-config-ssr.cjs.dev.js +1 -2
- package/ssr/dist/commercetools-frontend-application-config-ssr.cjs.prod.js +1 -2
- package/ssr/dist/commercetools-frontend-application-config-ssr.esm.js +1 -2
|
@@ -8,8 +8,8 @@ import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/obje
|
|
|
8
8
|
import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
|
|
9
9
|
import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
|
|
10
10
|
import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
|
|
11
|
-
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
12
11
|
import _URL from '@babel/runtime-corejs3/core-js-stable/url';
|
|
12
|
+
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
13
13
|
import fs$1 from 'node:fs';
|
|
14
14
|
import path, { parse } from 'node:path';
|
|
15
15
|
import omitEmpty from 'omit-empty-es';
|
|
@@ -33,7 +33,8 @@ import _trimInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instanc
|
|
|
33
33
|
import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
|
|
34
34
|
import path$1 from 'path';
|
|
35
35
|
import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
|
|
36
|
-
import
|
|
36
|
+
import _bindInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/bind';
|
|
37
|
+
import { f as formatEntryPointUriPathToResourceAccessKey, e as entryPointUriPathToResourceAccesses } from './formatters-5629a23b.esm.js';
|
|
37
38
|
import _Set from '@babel/runtime-corejs3/core-js-stable/set';
|
|
38
39
|
import _Array$isArray from '@babel/runtime-corejs3/core-js-stable/array/is-array';
|
|
39
40
|
import Ajv from 'ajv';
|
|
@@ -113,11 +114,10 @@ const isDynamicAwaitSupported = () => {
|
|
|
113
114
|
const isEsmModule = async cwd => {
|
|
114
115
|
const packagePath = path.join(cwd, 'package.json');
|
|
115
116
|
try {
|
|
116
|
-
var _JSON$parse;
|
|
117
117
|
const packageJSON = await fs.readFile(packagePath, {
|
|
118
118
|
encoding: 'utf-8'
|
|
119
119
|
});
|
|
120
|
-
return
|
|
120
|
+
return JSON.parse(packageJSON)?.type === 'module';
|
|
121
121
|
} catch (error) {
|
|
122
122
|
return false;
|
|
123
123
|
}
|
|
@@ -137,7 +137,7 @@ const createExplorerFor = async configFileName => {
|
|
|
137
137
|
const loaders = isDynamicAwaitSupported() || (await isEsmModule(process.cwd())) ? defaultLoaders : defaultLoadersSync;
|
|
138
138
|
return cosmiconfig(configFileName, {
|
|
139
139
|
searchStrategy: 'project',
|
|
140
|
-
searchPlaces: [
|
|
140
|
+
searchPlaces: [`${configFileName}.js`, `${configFileName}.cjs`, `${configFileName}.mjs`, `${configFileName}.ts`],
|
|
141
141
|
loaders: {
|
|
142
142
|
'.js': loaders['.js'],
|
|
143
143
|
'.cjs': loaders['.cjs'],
|
|
@@ -152,9 +152,9 @@ const getConfigPath = async () => {
|
|
|
152
152
|
const customApplicationConfigFile = await customApplicationExplorer.search();
|
|
153
153
|
const customViewConfigFile = await customViewExplorer.search();
|
|
154
154
|
if (!customApplicationConfigFile && !customViewConfigFile) {
|
|
155
|
-
throw new Error(
|
|
155
|
+
throw new Error(`Missing or invalid configuration file.`);
|
|
156
156
|
}
|
|
157
|
-
return
|
|
157
|
+
return customApplicationConfigFile?.filepath || customViewConfigFile?.filepath;
|
|
158
158
|
};
|
|
159
159
|
const loadConfig = async applicationPath => {
|
|
160
160
|
const customApplicationExplorer = await createExplorerFor('custom-application-config');
|
|
@@ -162,10 +162,10 @@ const loadConfig = async applicationPath => {
|
|
|
162
162
|
const customApplicationConfigFile = await customApplicationExplorer.search(applicationPath);
|
|
163
163
|
const customViewConfigFile = await customViewExplorer.search(applicationPath);
|
|
164
164
|
if ((!customApplicationConfigFile || !customApplicationConfigFile.config) && (!customViewConfigFile || !customViewConfigFile.config)) {
|
|
165
|
-
throw new MissingOrInvalidConfigError(
|
|
165
|
+
throw new MissingOrInvalidConfigError(`Missing or invalid configuration file.`);
|
|
166
166
|
}
|
|
167
167
|
if (customApplicationConfigFile && customViewConfigFile) {
|
|
168
|
-
throw new MissingOrInvalidConfigError(
|
|
168
|
+
throw new MissingOrInvalidConfigError(`Found configuration files for both Custom Application and Custom View. Please remove one of them.`);
|
|
169
169
|
}
|
|
170
170
|
return customViewConfigFile || customApplicationConfigFile;
|
|
171
171
|
};
|
|
@@ -199,15 +199,14 @@ Boolean(valueOfEnvConfig.match(variableSyntax));
|
|
|
199
199
|
const isEnvVariablePlaceholder = valueOfPlaceholder => Boolean(valueOfPlaceholder.match(envRefSyntax));
|
|
200
200
|
const isIntlVariablePlaceholder = valueOfPlaceholder => Boolean(valueOfPlaceholder.match(intlRefSyntax));
|
|
201
201
|
const isFilePathVariablePlaceholder = valueOfPlaceholder => Boolean(valueOfPlaceholder.match(filePathRefSyntax));
|
|
202
|
-
const isStructuredJson = message =>
|
|
202
|
+
const isStructuredJson = message => message?.string !== undefined;
|
|
203
203
|
const substituteEnvVariablePlaceholder = (valueOfPlaceholder, matchedString, valueOfEnvConfig, loadingOptions) => {
|
|
204
204
|
const _valueOfPlaceholder$s = valueOfPlaceholder.split(':'),
|
|
205
205
|
_valueOfPlaceholder$s2 = _slicedToArray(_valueOfPlaceholder$s, 2),
|
|
206
206
|
requestedEnvVar = _valueOfPlaceholder$s2[1];
|
|
207
207
|
const hasEnvField = loadingOptions.processEnv.hasOwnProperty(requestedEnvVar);
|
|
208
208
|
if (!hasEnvField) {
|
|
209
|
-
|
|
210
|
-
throw new Error(_concatInstanceProperty(_context = "Missing environment variable '".concat(requestedEnvVar, "' specified in config as 'env:")).call(_context, requestedEnvVar, "'."));
|
|
209
|
+
throw new Error(`Missing environment variable '${requestedEnvVar}' specified in config as 'env:${requestedEnvVar}'.`);
|
|
211
210
|
}
|
|
212
211
|
return valueOfEnvConfig.replace(new RegExp(escapeRegExp(matchedString), 'g'), loadingOptions.processEnv[requestedEnvVar]);
|
|
213
212
|
};
|
|
@@ -216,14 +215,13 @@ const substituteIntlVariablePlaceholder = (valueOfPlaceholder, matchedString, va
|
|
|
216
215
|
_valueOfPlaceholder$s4 = _slicedToArray(_valueOfPlaceholder$s3, 3),
|
|
217
216
|
locale = _valueOfPlaceholder$s4[1],
|
|
218
217
|
requestedIntlMessageId = _valueOfPlaceholder$s4[2];
|
|
219
|
-
const translationsFilePath = require.resolve(
|
|
220
|
-
paths: [
|
|
218
|
+
const translationsFilePath = require.resolve(`./i18n/data/${locale}.json`, {
|
|
219
|
+
paths: [`${loadingOptions.applicationPath}/src`, loadingOptions.applicationPath]
|
|
221
220
|
});
|
|
222
221
|
const translations = require(translationsFilePath);
|
|
223
222
|
const hasIntlMessage = translations.hasOwnProperty(requestedIntlMessageId);
|
|
224
223
|
if (!hasIntlMessage) {
|
|
225
|
-
|
|
226
|
-
throw new Error(_concatInstanceProperty(_context2 = _concatInstanceProperty(_context3 = "Missing message key '".concat(requestedIntlMessageId, "' specified in config as 'intl:")).call(_context3, locale, ":")).call(_context2, requestedIntlMessageId, "'."));
|
|
224
|
+
throw new Error(`Missing message key '${requestedIntlMessageId}' specified in config as 'intl:${locale}:${requestedIntlMessageId}'.`);
|
|
227
225
|
}
|
|
228
226
|
const translation = translations[requestedIntlMessageId];
|
|
229
227
|
const translationValue = isStructuredJson(translation) ? translation.string : translation;
|
|
@@ -249,7 +247,7 @@ const substituteFilePathVariablePlaceholder = (valueOfPlaceholder, matchedString
|
|
|
249
247
|
// to /etc/passwd).
|
|
250
248
|
const normalizedSpecifier = path$1.posix.normalize(filePathOrModule);
|
|
251
249
|
if (_startsWithInstanceProperty(normalizedSpecifier).call(normalizedSpecifier, '..')) {
|
|
252
|
-
throw new Error(
|
|
250
|
+
throw new Error(`Path traversal in module specifiers is not allowed: ${filePathOrModule}`);
|
|
253
251
|
}
|
|
254
252
|
}
|
|
255
253
|
const resolvedPath = require.resolve(filePathOrModule, {
|
|
@@ -284,7 +282,7 @@ const substituteFilePathVariablePlaceholder = (valueOfPlaceholder, matchedString
|
|
|
284
282
|
// Use path.relative() to avoid string prefix vulnerabilities (e.g., "/app" vs "/app-evil")
|
|
285
283
|
const isSafePath = !_startsWithInstanceProperty(relativePath).call(relativePath, '..') && !path$1.isAbsolute(relativePath);
|
|
286
284
|
if (!isSafePath) {
|
|
287
|
-
throw new Error(
|
|
285
|
+
throw new Error(`Access to files outside workspace directory is not allowed: ${filePathOrModule}`);
|
|
288
286
|
}
|
|
289
287
|
}
|
|
290
288
|
const content = fs$1.readFileSync(normalizedPath, {
|
|
@@ -986,13 +984,12 @@ const printErrors = errors => {
|
|
|
986
984
|
return 'No errors';
|
|
987
985
|
}
|
|
988
986
|
return _mapInstanceProperty(errors).call(errors, error => {
|
|
989
|
-
|
|
990
|
-
const baseMessage = _concatInstanceProperty(_context = "".concat(error.instancePath, " ")).call(_context, error.message);
|
|
987
|
+
const baseMessage = `${error.instancePath} ${error.message}`;
|
|
991
988
|
switch (error.keyword) {
|
|
992
989
|
case 'additionalProperties':
|
|
993
|
-
return
|
|
990
|
+
return `${baseMessage}: ${error.params.additionalProperty}`;
|
|
994
991
|
case 'enum':
|
|
995
|
-
return
|
|
992
|
+
return `${baseMessage}: ${error.params.allowedValues.toString()}`;
|
|
996
993
|
default:
|
|
997
994
|
return baseMessage;
|
|
998
995
|
}
|
|
@@ -1005,8 +1002,7 @@ const validateConfig = (configType, config) => {
|
|
|
1005
1002
|
} else if (configType === LOADED_CONFIG_TYPES.CUSTOM_VIEW) {
|
|
1006
1003
|
validation = validateCustomViewConfig;
|
|
1007
1004
|
} else {
|
|
1008
|
-
|
|
1009
|
-
throw new Error(_concatInstanceProperty(_context4 = "Invalid config type \"".concat(configType, "\", expected ")).call(_context4, _Object$keys(LOADED_CONFIG_TYPES).toString()));
|
|
1005
|
+
throw new Error(`Invalid config type "${configType}", expected ${_Object$keys(LOADED_CONFIG_TYPES).toString()}`);
|
|
1010
1006
|
}
|
|
1011
1007
|
const isValid = validation(config);
|
|
1012
1008
|
if (!isValid) {
|
|
@@ -1019,9 +1015,9 @@ const validateEntryPointUriPath = config => {
|
|
|
1019
1015
|
}
|
|
1020
1016
|
};
|
|
1021
1017
|
const validateSubmenuLinks = config => {
|
|
1022
|
-
var
|
|
1018
|
+
var _context;
|
|
1023
1019
|
const uriPathSet = new _Set();
|
|
1024
|
-
_forEachInstanceProperty(
|
|
1020
|
+
_forEachInstanceProperty(_context = config.submenuLinks).call(_context, _ref => {
|
|
1025
1021
|
let uriPath = _ref.uriPath;
|
|
1026
1022
|
if (uriPathSet.has(uriPath)) {
|
|
1027
1023
|
throw new Error('Duplicate URI path. Every submenu link must have a unique URI path value');
|
|
@@ -1030,64 +1026,63 @@ const validateSubmenuLinks = config => {
|
|
|
1030
1026
|
});
|
|
1031
1027
|
};
|
|
1032
1028
|
const validateAdditionalOAuthScopes = config => {
|
|
1033
|
-
var
|
|
1029
|
+
var _context2, _context3;
|
|
1034
1030
|
const additionalPermissionNames = new _Set();
|
|
1035
|
-
(
|
|
1031
|
+
((_context2 = config.additionalOAuthScopes) == null ? void 0 : _bindInstanceProperty(_context3 = Function.call).call(_context3, _forEachInstanceProperty(_context2), _context2))?.(_ref2 => {
|
|
1036
1032
|
let name = _ref2.name,
|
|
1037
1033
|
view = _ref2.view,
|
|
1038
1034
|
manage = _ref2.manage;
|
|
1039
1035
|
if ((_Array$isArray(view) && view.length === 0 || !view) && (_Array$isArray(manage) && manage.length === 0 || !manage)) {
|
|
1040
|
-
throw new Error(
|
|
1036
|
+
throw new Error(`At least one OAuth Scope for permission group name "${name}" is required`);
|
|
1041
1037
|
} else if (additionalPermissionNames.has(name)) {
|
|
1042
|
-
throw new Error(
|
|
1038
|
+
throw new Error(`Duplicate additional permission group name "${name}". Every additional permission must have a unique name`);
|
|
1043
1039
|
}
|
|
1044
1040
|
if (!name.match(PERMISSION_GROUP_NAME_REGEX)) {
|
|
1045
|
-
throw new Error(
|
|
1041
|
+
throw new Error(`Additional permission group name "${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`);
|
|
1046
1042
|
}
|
|
1047
1043
|
additionalPermissionNames.add(name);
|
|
1048
1044
|
});
|
|
1049
1045
|
};
|
|
1050
1046
|
|
|
1051
1047
|
function ownKeys$1(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1052
|
-
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
1048
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context6 = ownKeys$1(Object(t), !0)).call(_context6, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context7 = ownKeys$1(Object(t))).call(_context7, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1053
1049
|
|
|
1054
1050
|
// The `uriPath` of each submenu link is supposed to be defined relative
|
|
1055
1051
|
// to the `entryPointUriPath`. Computing the full path is done internally to keep
|
|
1056
1052
|
// the configuration simple.
|
|
1057
1053
|
const computeUriPath = (uriPath, entryPointUriPath) => {
|
|
1058
|
-
var _context;
|
|
1059
1054
|
// In case the `uriPath` is only `/`, it means that the link is supposed to be
|
|
1060
1055
|
// treated the same as the main application path. In this case, the return value
|
|
1061
1056
|
// should not contain any unnecessary trailing slash and therefore we use the `entryPointUriPath`.
|
|
1062
1057
|
if (uriPath === '/') return entryPointUriPath;
|
|
1063
1058
|
// In case the `uriPath` is already configured including the `entryPointUriPath`,
|
|
1064
1059
|
// we return the `uriPath` as-is.
|
|
1065
|
-
if (_startsWithInstanceProperty(uriPath).call(uriPath,
|
|
1060
|
+
if (_startsWithInstanceProperty(uriPath).call(uriPath, `${entryPointUriPath}/`)) return uriPath;
|
|
1066
1061
|
// Return the full path including the `entryPointUriPath` as a prefix.
|
|
1067
|
-
return
|
|
1062
|
+
return `${entryPointUriPath}/${uriPath}`;
|
|
1068
1063
|
};
|
|
1069
1064
|
const getPermissions = appConfig => {
|
|
1070
|
-
var _context2,
|
|
1071
|
-
const additionalResourceAccessKeyToOauthScopeMap = _reduceInstanceProperty(
|
|
1065
|
+
var _context, _context2, _context3, _context4;
|
|
1066
|
+
const additionalResourceAccessKeyToOauthScopeMap = _reduceInstanceProperty(_context = appConfig.additionalOAuthScopes || []).call(_context, (previousOauthScope, _ref) => {
|
|
1072
1067
|
let name = _ref.name,
|
|
1073
1068
|
view = _ref.view,
|
|
1074
1069
|
manage = _ref.manage;
|
|
1075
1070
|
const formattedResourceKey = formatEntryPointUriPathToResourceAccessKey(name);
|
|
1076
1071
|
return _objectSpread$1(_objectSpread$1({}, previousOauthScope), {}, {
|
|
1077
|
-
[
|
|
1078
|
-
[
|
|
1072
|
+
[`view${formattedResourceKey}`]: view,
|
|
1073
|
+
[`manage${formattedResourceKey}`]: manage
|
|
1079
1074
|
});
|
|
1080
1075
|
}, {});
|
|
1081
|
-
const additionalPermissionNames = ((
|
|
1076
|
+
const additionalPermissionNames = ((_context2 = appConfig.additionalOAuthScopes) == null ? void 0 : _bindInstanceProperty(_context3 = Function.call).call(_context3, _mapInstanceProperty(_context2), _context2))?.(_ref2 => {
|
|
1082
1077
|
let name = _ref2.name;
|
|
1083
1078
|
return name;
|
|
1084
|
-
})
|
|
1079
|
+
}) || [];
|
|
1085
1080
|
const permissionKeys = entryPointUriPathToResourceAccesses(appConfig.entryPointUriPath ||
|
|
1086
1081
|
// In case the `entryPointUriPath` is not defined it is because the
|
|
1087
1082
|
// configuration is for a custom view. In this case we use the
|
|
1088
1083
|
// default entry point uri path.
|
|
1089
1084
|
CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH, additionalPermissionNames);
|
|
1090
|
-
const additionalPermissions = _mapInstanceProperty(
|
|
1085
|
+
const additionalPermissions = _mapInstanceProperty(_context4 = _Object$keys(additionalResourceAccessKeyToOauthScopeMap)).call(_context4, additionalResourceAccessKey => ({
|
|
1091
1086
|
name: permissionKeys[additionalResourceAccessKey],
|
|
1092
1087
|
oAuthScopes: additionalResourceAccessKeyToOauthScopeMap[additionalResourceAccessKey]
|
|
1093
1088
|
}));
|
|
@@ -1100,7 +1095,7 @@ const getPermissions = appConfig => {
|
|
|
1100
1095
|
}, ...additionalPermissions];
|
|
1101
1096
|
};
|
|
1102
1097
|
function transformCustomApplicationConfigToData(appConfig) {
|
|
1103
|
-
var
|
|
1098
|
+
var _context5;
|
|
1104
1099
|
validateEntryPointUriPath(appConfig);
|
|
1105
1100
|
validateSubmenuLinks(appConfig);
|
|
1106
1101
|
validateAdditionalOAuthScopes(appConfig);
|
|
@@ -1113,7 +1108,7 @@ function transformCustomApplicationConfigToData(appConfig) {
|
|
|
1113
1108
|
permissions: getPermissions(appConfig),
|
|
1114
1109
|
icon: appConfig.icon,
|
|
1115
1110
|
mainMenuLink: appConfig.mainMenuLink,
|
|
1116
|
-
submenuLinks: _mapInstanceProperty(
|
|
1111
|
+
submenuLinks: _mapInstanceProperty(_context5 = appConfig.submenuLinks).call(_context5, submenuLink => _objectSpread$1(_objectSpread$1({}, submenuLink), {}, {
|
|
1117
1112
|
uriPath: computeUriPath(submenuLink.uriPath, appConfig.entryPointUriPath)
|
|
1118
1113
|
}))
|
|
1119
1114
|
};
|
|
@@ -1138,12 +1133,11 @@ function transformConfigurationToData(configType, configuration) {
|
|
|
1138
1133
|
} else if (configType === LOADED_CONFIG_TYPES.CUSTOM_VIEW) {
|
|
1139
1134
|
return transformCustomViewConfigToData(configuration);
|
|
1140
1135
|
} else {
|
|
1141
|
-
throw new Error(
|
|
1136
|
+
throw new Error(`Invalid config type: ${configType}`);
|
|
1142
1137
|
}
|
|
1143
1138
|
}
|
|
1144
1139
|
|
|
1145
1140
|
const mapCloudIdentifierToApiUrl = key => {
|
|
1146
|
-
var _context;
|
|
1147
1141
|
switch (key) {
|
|
1148
1142
|
case CLOUD_IDENTIFIERS.GCP_AU:
|
|
1149
1143
|
return MC_API_URLS[CLOUD_IDENTIFIERS.GCP_AU];
|
|
@@ -1160,7 +1154,7 @@ const mapCloudIdentifierToApiUrl = key => {
|
|
|
1160
1154
|
default:
|
|
1161
1155
|
// We would probably never get to this point, as the JSON schema validation
|
|
1162
1156
|
// kicks in before.
|
|
1163
|
-
throw new Error(
|
|
1157
|
+
throw new Error(`Unknown cloud identifier "${key}". Supported values: ${_Object$values(CLOUD_IDENTIFIERS).toString()}`);
|
|
1164
1158
|
}
|
|
1165
1159
|
};
|
|
1166
1160
|
const getUniqueValues = function () {
|
|
@@ -1184,10 +1178,10 @@ const getOrThrow = (fn, errorMessage) => {
|
|
|
1184
1178
|
};
|
|
1185
1179
|
|
|
1186
1180
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1187
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
1181
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1188
1182
|
// TODO: make it configurable.
|
|
1189
1183
|
const developmentPort = 3001;
|
|
1190
|
-
const developmentAppUrl =
|
|
1184
|
+
const developmentAppUrl = `http://localhost:${developmentPort}`;
|
|
1191
1185
|
const getLoadedConfigurationType = configFileName => {
|
|
1192
1186
|
if (_includesInstanceProperty(configFileName).call(configFileName, 'custom-view-config')) {
|
|
1193
1187
|
return LOADED_CONFIG_TYPES.CUSTOM_VIEW;
|
|
@@ -1203,7 +1197,6 @@ const omitDevConfigIfEmpty = devConfig => {
|
|
|
1203
1197
|
};
|
|
1204
1198
|
const isCustomViewData = data => data.entryPointUriPath === undefined;
|
|
1205
1199
|
const getRuntimeEnvironmentConfigForDevelopment = _ref => {
|
|
1206
|
-
var _appConfig$env$develo;
|
|
1207
1200
|
let isProd = _ref.isProd,
|
|
1208
1201
|
configurationData = _ref.configurationData,
|
|
1209
1202
|
mcApiUrl = _ref.mcApiUrl,
|
|
@@ -1220,7 +1213,7 @@ const getRuntimeEnvironmentConfigForDevelopment = _ref => {
|
|
|
1220
1213
|
initialProjectKey:
|
|
1221
1214
|
// For the `account` application, we should unset the projectKey.
|
|
1222
1215
|
entryPointUriPath === 'account' ? undefined : appConfig.env.development.initialProjectKey
|
|
1223
|
-
},
|
|
1216
|
+
}, appConfig.env.development?.teamId && _objectSpread({
|
|
1224
1217
|
teamId: appConfig.env.development.teamId
|
|
1225
1218
|
}, isCustomViewData(configurationData) ? {
|
|
1226
1219
|
customViewId: configurationData.id
|
|
@@ -1228,12 +1221,11 @@ const getRuntimeEnvironmentConfigForDevelopment = _ref => {
|
|
|
1228
1221
|
applicationId: configurationData.id
|
|
1229
1222
|
})), {}, {
|
|
1230
1223
|
oAuthScopes: appConfig.oAuthScopes,
|
|
1231
|
-
additionalOAuthScopes: appConfig
|
|
1224
|
+
additionalOAuthScopes: appConfig?.additionalOAuthScopes
|
|
1232
1225
|
}));
|
|
1233
1226
|
if (isCustomViewData(configurationData)) {
|
|
1234
|
-
var _context;
|
|
1235
1227
|
const hostUriPath = appConfig.env.development.hostUriPath;
|
|
1236
|
-
const defaultHostUriPath = oidcConfig.initialProjectKey ?
|
|
1228
|
+
const defaultHostUriPath = oidcConfig.initialProjectKey ? `/${oidcConfig.initialProjectKey}/${entryPointUriPath}` : `/${entryPointUriPath}`;
|
|
1237
1229
|
const hostUrl = new _URL(hostUriPath || defaultHostUriPath, developmentAppUrl);
|
|
1238
1230
|
return omitDevConfigIfEmpty({
|
|
1239
1231
|
oidc: oidcConfig,
|
|
@@ -1255,7 +1247,6 @@ const getRuntimeEnvironmentConfigForDevelopment = _ref => {
|
|
|
1255
1247
|
});
|
|
1256
1248
|
};
|
|
1257
1249
|
const getRuntimeEnvironmentConfig = _ref2 => {
|
|
1258
|
-
var _context2;
|
|
1259
1250
|
let isProd = _ref2.isProd,
|
|
1260
1251
|
configurationData = _ref2.configurationData,
|
|
1261
1252
|
additionalAppEnv = _ref2.additionalAppEnv,
|
|
@@ -1274,7 +1265,7 @@ const getRuntimeEnvironmentConfig = _ref2 => {
|
|
|
1274
1265
|
// In development, we prefix the entry point with the "__local" prefix.
|
|
1275
1266
|
// This is important to determine to which URL the MC should redirect to
|
|
1276
1267
|
// after successful login.
|
|
1277
|
-
const applicationIdentifier = isProd ?
|
|
1268
|
+
const applicationIdentifier = isProd ? `${configurationData.id}:${entryPointUriPath}` : `__local:${entryPointUriPath}`;
|
|
1278
1269
|
const developmentConfig = getRuntimeEnvironmentConfigForDevelopment({
|
|
1279
1270
|
isProd,
|
|
1280
1271
|
configurationData,
|
|
@@ -1306,7 +1297,7 @@ const getRuntimeEnvironmentConfig = _ref2 => {
|
|
|
1306
1297
|
// again will result in returning the cached value.
|
|
1307
1298
|
let cachedConfig;
|
|
1308
1299
|
const processConfig = async function () {
|
|
1309
|
-
var
|
|
1300
|
+
var _context;
|
|
1310
1301
|
let _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1311
1302
|
_ref3$disableCache = _ref3.disableCache,
|
|
1312
1303
|
disableCache = _ref3$disableCache === void 0 ? false : _ref3$disableCache,
|
|
@@ -1325,22 +1316,22 @@ const processConfig = async function () {
|
|
|
1325
1316
|
processEnv
|
|
1326
1317
|
});
|
|
1327
1318
|
const configurationData = transformConfigurationToData(configType, appConfig);
|
|
1328
|
-
const appEnvKey =
|
|
1319
|
+
const appEnvKey = processEnv.MC_APP_ENV ?? processEnv.NODE_ENV ?? 'development';
|
|
1329
1320
|
const isProd = getIsProd(processEnv);
|
|
1330
|
-
const additionalAppEnv =
|
|
1331
|
-
const revision =
|
|
1321
|
+
const additionalAppEnv = appConfig.additionalEnv ?? {};
|
|
1322
|
+
const revision = additionalAppEnv.revision ?? '';
|
|
1332
1323
|
|
|
1333
1324
|
// Parse all the supported URLs, which gets implicitly validated
|
|
1334
1325
|
|
|
1335
1326
|
const envAppUrl = isProd ? configurationData.url : developmentAppUrl;
|
|
1336
|
-
const appUrl = getOrThrow(() => new _URL(envAppUrl),
|
|
1327
|
+
const appUrl = getOrThrow(() => new _URL(envAppUrl), `Invalid application URL: "${envAppUrl}"`);
|
|
1337
1328
|
|
|
1338
1329
|
// Use `||` instead of `??` to include empty string values.
|
|
1339
1330
|
const envCdnUrl = isProd ? appConfig.env.production.cdnUrl || appUrl.href : developmentAppUrl;
|
|
1340
|
-
const cdnUrl = getOrThrow(() => new _URL(envCdnUrl),
|
|
1331
|
+
const cdnUrl = getOrThrow(() => new _URL(envCdnUrl), `Invalid application CDN URL: "${envCdnUrl}"`);
|
|
1341
1332
|
const mcApiUrl = getOrThrow(() => new _URL(
|
|
1342
1333
|
// Use `||` instead of `??` to include empty string values.
|
|
1343
|
-
appConfig.mcApiUrl || mapCloudIdentifierToApiUrl(appConfig.cloudIdentifier)),
|
|
1334
|
+
appConfig.mcApiUrl || mapCloudIdentifierToApiUrl(appConfig.cloudIdentifier)), `Invalid MC API URL: "${appConfig.mcApiUrl}"`);
|
|
1344
1335
|
cachedConfig = {
|
|
1345
1336
|
data: configurationData,
|
|
1346
1337
|
env: getRuntimeEnvironmentConfig({
|
|
@@ -1355,16 +1346,16 @@ const processConfig = async function () {
|
|
|
1355
1346
|
revision
|
|
1356
1347
|
}),
|
|
1357
1348
|
headers: _objectSpread(_objectSpread({}, appConfig.headers), {}, {
|
|
1358
|
-
csp: _objectSpread(_objectSpread({},
|
|
1349
|
+
csp: _objectSpread(_objectSpread({}, appConfig.headers?.csp), {}, {
|
|
1359
1350
|
// We need to make sure the URL we use in these CSP headers have a slash in the end,
|
|
1360
1351
|
// otherwise it might create an invalid value when application/CDN URL points to a
|
|
1361
1352
|
// non-root directory (ex: https://www.my-domain.com/app). This is a valid URL but from
|
|
1362
1353
|
// the CSP point of view, it will say only the file `app` can be used as a source, so
|
|
1363
1354
|
// any other file from that domain will be forbidden. Using the slash (ex: https://www.my-domain.com/app/)
|
|
1364
1355
|
// at the end it's like using a wildcard so anything 'below' `app` will be allowed.
|
|
1365
|
-
'connect-src': getUniqueValues(
|
|
1366
|
-
'script-src': getUniqueValues(
|
|
1367
|
-
'style-src': getUniqueValues(
|
|
1356
|
+
'connect-src': getUniqueValues(appConfig.headers?.csp?.['connect-src'], _concatInstanceProperty(_context = [mcApiUrl.origin]).call(_context, isProd ? [`${trimTrailingSlash(appUrl.href)}/`, `${trimTrailingSlash(cdnUrl.href)}/`] : [])),
|
|
1357
|
+
'script-src': getUniqueValues(appConfig.headers?.csp?.['script-src'], isProd ? [`${trimTrailingSlash(appUrl.href)}/`, `${trimTrailingSlash(cdnUrl.href)}/`] : []),
|
|
1358
|
+
'style-src': getUniqueValues(appConfig.headers?.csp?.['style-src'], isProd ? [`${trimTrailingSlash(appUrl.href)}/`, `${trimTrailingSlash(cdnUrl.href)}/`] : [])
|
|
1368
1359
|
})
|
|
1369
1360
|
})
|
|
1370
1361
|
};
|
|
@@ -12,7 +12,6 @@ var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
|
12
12
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
13
13
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
14
14
|
var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
15
|
-
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
16
15
|
var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entries');
|
|
17
16
|
var upperFirst = require('lodash/upperFirst');
|
|
18
17
|
var constants = require('@commercetools-frontend/constants');
|
|
@@ -29,12 +28,11 @@ var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$def
|
|
|
29
28
|
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
30
29
|
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
31
30
|
var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
|
|
32
|
-
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
33
31
|
var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
|
|
34
32
|
var upperFirst__default = /*#__PURE__*/_interopDefault(upperFirst);
|
|
35
33
|
|
|
36
34
|
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
37
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
35
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context6 = ownKeys(Object(t), !0)).call(_context6, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context7 = ownKeys(Object(t))).call(_context7, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
38
36
|
/**
|
|
39
37
|
* The function formats the `entryPointUriPath` to a resource access key.
|
|
40
38
|
* It makes the first character of the string and the next character after a special character an uppercase.
|
|
@@ -62,7 +60,7 @@ const formatEntryPointUriPathToResourceAccessKey = entryPointUriPath => {
|
|
|
62
60
|
// If the word after the hyphen is numeric, replace the hyphen with a forward slash.
|
|
63
61
|
// If not, omit the hyphen and uppercase the first character
|
|
64
62
|
if (i > 0 && /^\d+$/.test(word[0])) {
|
|
65
|
-
return
|
|
63
|
+
return `/${word}`;
|
|
66
64
|
}
|
|
67
65
|
return upperFirst__default["default"](word);
|
|
68
66
|
}).join('');
|
|
@@ -86,15 +84,14 @@ function entryPointUriPathToResourceAccesses(entryPointUriPath, permissionGroupN
|
|
|
86
84
|
var _context4;
|
|
87
85
|
const resourceAccessKey = constants.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH === entryPointUriPath ? '' : formatEntryPointUriPathToResourceAccessKey(entryPointUriPath);
|
|
88
86
|
const defaultResourceAccesses = {
|
|
89
|
-
view:
|
|
90
|
-
manage:
|
|
87
|
+
view: `view${resourceAccessKey}`,
|
|
88
|
+
manage: `manage${resourceAccessKey}`
|
|
91
89
|
};
|
|
92
|
-
const additionalResourceAccesses = _reduceInstanceProperty__default["default"](_context4 = permissionGroupNames
|
|
93
|
-
var _context5, _context6;
|
|
90
|
+
const additionalResourceAccesses = _reduceInstanceProperty__default["default"](_context4 = permissionGroupNames ?? []).call(_context4, (resourceAccesses, permissionGroupName) => {
|
|
94
91
|
const additionalResourceAccessKey = formatPermissionGroupNameToResourceAccessKey(permissionGroupName);
|
|
95
92
|
return _objectSpread(_objectSpread({}, resourceAccesses), {}, {
|
|
96
|
-
[
|
|
97
|
-
[
|
|
93
|
+
[`view${additionalResourceAccessKey}`]: `${defaultResourceAccesses.view}${additionalResourceAccessKey}`,
|
|
94
|
+
[`manage${additionalResourceAccessKey}`]: `${defaultResourceAccesses.manage}${additionalResourceAccessKey}`
|
|
98
95
|
});
|
|
99
96
|
}, {});
|
|
100
97
|
return _objectSpread(_objectSpread({}, defaultResourceAccesses), additionalResourceAccesses);
|
|
@@ -106,9 +103,9 @@ function computeCustomViewPermissionsKeys(permissionGroupNames) {
|
|
|
106
103
|
return entryPointUriPathToPermissionKeys(constants.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH, permissionGroupNames || []);
|
|
107
104
|
}
|
|
108
105
|
function entryPointUriPathToPermissionKeys(entryPointUriPath, permissionGroupNames) {
|
|
109
|
-
var
|
|
110
|
-
const resourceAccesses = entryPointUriPathToResourceAccesses(entryPointUriPath, permissionGroupNames
|
|
111
|
-
return _reduceInstanceProperty__default["default"](
|
|
106
|
+
var _context5;
|
|
107
|
+
const resourceAccesses = entryPointUriPathToResourceAccesses(entryPointUriPath, permissionGroupNames ?? []);
|
|
108
|
+
return _reduceInstanceProperty__default["default"](_context5 = _Object$entries__default["default"](resourceAccesses)).call(_context5, (permissionKeys, _ref) => {
|
|
112
109
|
let _ref2 = _slicedToArray(_ref, 2),
|
|
113
110
|
resourceAccessKey = _ref2[0],
|
|
114
111
|
resourceAccessValue = _ref2[1];
|
|
@@ -10,13 +10,12 @@ import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
|
|
|
10
10
|
import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
|
|
11
11
|
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
12
12
|
import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
|
|
13
|
-
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
14
13
|
import _Object$entries from '@babel/runtime-corejs3/core-js-stable/object/entries';
|
|
15
14
|
import upperFirst from 'lodash/upperFirst';
|
|
16
15
|
import { CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH } from '@commercetools-frontend/constants';
|
|
17
16
|
|
|
18
17
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
19
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
18
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context6 = ownKeys(Object(t), !0)).call(_context6, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context7 = ownKeys(Object(t))).call(_context7, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
20
19
|
/**
|
|
21
20
|
* The function formats the `entryPointUriPath` to a resource access key.
|
|
22
21
|
* It makes the first character of the string and the next character after a special character an uppercase.
|
|
@@ -44,7 +43,7 @@ const formatEntryPointUriPathToResourceAccessKey = entryPointUriPath => {
|
|
|
44
43
|
// If the word after the hyphen is numeric, replace the hyphen with a forward slash.
|
|
45
44
|
// If not, omit the hyphen and uppercase the first character
|
|
46
45
|
if (i > 0 && /^\d+$/.test(word[0])) {
|
|
47
|
-
return
|
|
46
|
+
return `/${word}`;
|
|
48
47
|
}
|
|
49
48
|
return upperFirst(word);
|
|
50
49
|
}).join('');
|
|
@@ -68,15 +67,14 @@ function entryPointUriPathToResourceAccesses(entryPointUriPath, permissionGroupN
|
|
|
68
67
|
var _context4;
|
|
69
68
|
const resourceAccessKey = CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH === entryPointUriPath ? '' : formatEntryPointUriPathToResourceAccessKey(entryPointUriPath);
|
|
70
69
|
const defaultResourceAccesses = {
|
|
71
|
-
view:
|
|
72
|
-
manage:
|
|
70
|
+
view: `view${resourceAccessKey}`,
|
|
71
|
+
manage: `manage${resourceAccessKey}`
|
|
73
72
|
};
|
|
74
|
-
const additionalResourceAccesses = _reduceInstanceProperty(_context4 = permissionGroupNames
|
|
75
|
-
var _context5, _context6;
|
|
73
|
+
const additionalResourceAccesses = _reduceInstanceProperty(_context4 = permissionGroupNames ?? []).call(_context4, (resourceAccesses, permissionGroupName) => {
|
|
76
74
|
const additionalResourceAccessKey = formatPermissionGroupNameToResourceAccessKey(permissionGroupName);
|
|
77
75
|
return _objectSpread(_objectSpread({}, resourceAccesses), {}, {
|
|
78
|
-
[
|
|
79
|
-
[
|
|
76
|
+
[`view${additionalResourceAccessKey}`]: `${defaultResourceAccesses.view}${additionalResourceAccessKey}`,
|
|
77
|
+
[`manage${additionalResourceAccessKey}`]: `${defaultResourceAccesses.manage}${additionalResourceAccessKey}`
|
|
80
78
|
});
|
|
81
79
|
}, {});
|
|
82
80
|
return _objectSpread(_objectSpread({}, defaultResourceAccesses), additionalResourceAccesses);
|
|
@@ -88,9 +86,9 @@ function computeCustomViewPermissionsKeys(permissionGroupNames) {
|
|
|
88
86
|
return entryPointUriPathToPermissionKeys(CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH, permissionGroupNames || []);
|
|
89
87
|
}
|
|
90
88
|
function entryPointUriPathToPermissionKeys(entryPointUriPath, permissionGroupNames) {
|
|
91
|
-
var
|
|
92
|
-
const resourceAccesses = entryPointUriPathToResourceAccesses(entryPointUriPath, permissionGroupNames
|
|
93
|
-
return _reduceInstanceProperty(
|
|
89
|
+
var _context5;
|
|
90
|
+
const resourceAccesses = entryPointUriPathToResourceAccesses(entryPointUriPath, permissionGroupNames ?? []);
|
|
91
|
+
return _reduceInstanceProperty(_context5 = _Object$entries(resourceAccesses)).call(_context5, (permissionKeys, _ref) => {
|
|
94
92
|
let _ref2 = _slicedToArray(_ref, 2),
|
|
95
93
|
resourceAccessKey = _ref2[0],
|
|
96
94
|
resourceAccessValue = _ref2[1];
|
|
@@ -12,7 +12,6 @@ var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
|
12
12
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
13
13
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
14
14
|
var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
15
|
-
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
16
15
|
var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entries');
|
|
17
16
|
var upperFirst = require('lodash/upperFirst');
|
|
18
17
|
var constants = require('@commercetools-frontend/constants');
|
|
@@ -29,12 +28,11 @@ var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$def
|
|
|
29
28
|
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
30
29
|
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
31
30
|
var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
|
|
32
|
-
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
33
31
|
var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
|
|
34
32
|
var upperFirst__default = /*#__PURE__*/_interopDefault(upperFirst);
|
|
35
33
|
|
|
36
34
|
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
37
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
35
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context6 = ownKeys(Object(t), !0)).call(_context6, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context7 = ownKeys(Object(t))).call(_context7, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
38
36
|
/**
|
|
39
37
|
* The function formats the `entryPointUriPath` to a resource access key.
|
|
40
38
|
* It makes the first character of the string and the next character after a special character an uppercase.
|
|
@@ -62,7 +60,7 @@ const formatEntryPointUriPathToResourceAccessKey = entryPointUriPath => {
|
|
|
62
60
|
// If the word after the hyphen is numeric, replace the hyphen with a forward slash.
|
|
63
61
|
// If not, omit the hyphen and uppercase the first character
|
|
64
62
|
if (i > 0 && /^\d+$/.test(word[0])) {
|
|
65
|
-
return
|
|
63
|
+
return `/${word}`;
|
|
66
64
|
}
|
|
67
65
|
return upperFirst__default["default"](word);
|
|
68
66
|
}).join('');
|
|
@@ -86,15 +84,14 @@ function entryPointUriPathToResourceAccesses(entryPointUriPath, permissionGroupN
|
|
|
86
84
|
var _context4;
|
|
87
85
|
const resourceAccessKey = constants.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH === entryPointUriPath ? '' : formatEntryPointUriPathToResourceAccessKey(entryPointUriPath);
|
|
88
86
|
const defaultResourceAccesses = {
|
|
89
|
-
view:
|
|
90
|
-
manage:
|
|
87
|
+
view: `view${resourceAccessKey}`,
|
|
88
|
+
manage: `manage${resourceAccessKey}`
|
|
91
89
|
};
|
|
92
|
-
const additionalResourceAccesses = _reduceInstanceProperty__default["default"](_context4 = permissionGroupNames
|
|
93
|
-
var _context5, _context6;
|
|
90
|
+
const additionalResourceAccesses = _reduceInstanceProperty__default["default"](_context4 = permissionGroupNames ?? []).call(_context4, (resourceAccesses, permissionGroupName) => {
|
|
94
91
|
const additionalResourceAccessKey = formatPermissionGroupNameToResourceAccessKey(permissionGroupName);
|
|
95
92
|
return _objectSpread(_objectSpread({}, resourceAccesses), {}, {
|
|
96
|
-
[
|
|
97
|
-
[
|
|
93
|
+
[`view${additionalResourceAccessKey}`]: `${defaultResourceAccesses.view}${additionalResourceAccessKey}`,
|
|
94
|
+
[`manage${additionalResourceAccessKey}`]: `${defaultResourceAccesses.manage}${additionalResourceAccessKey}`
|
|
98
95
|
});
|
|
99
96
|
}, {});
|
|
100
97
|
return _objectSpread(_objectSpread({}, defaultResourceAccesses), additionalResourceAccesses);
|
|
@@ -106,9 +103,9 @@ function computeCustomViewPermissionsKeys(permissionGroupNames) {
|
|
|
106
103
|
return entryPointUriPathToPermissionKeys(constants.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH, permissionGroupNames || []);
|
|
107
104
|
}
|
|
108
105
|
function entryPointUriPathToPermissionKeys(entryPointUriPath, permissionGroupNames) {
|
|
109
|
-
var
|
|
110
|
-
const resourceAccesses = entryPointUriPathToResourceAccesses(entryPointUriPath, permissionGroupNames
|
|
111
|
-
return _reduceInstanceProperty__default["default"](
|
|
106
|
+
var _context5;
|
|
107
|
+
const resourceAccesses = entryPointUriPathToResourceAccesses(entryPointUriPath, permissionGroupNames ?? []);
|
|
108
|
+
return _reduceInstanceProperty__default["default"](_context5 = _Object$entries__default["default"](resourceAccesses)).call(_context5, (permissionKeys, _ref) => {
|
|
112
109
|
let _ref2 = _slicedToArray(_ref, 2),
|
|
113
110
|
resourceAccessKey = _ref2[0],
|
|
114
111
|
resourceAccessValue = _ref2[1];
|