@commercetools-frontend/application-shell-connectors 24.11.0 → 24.13.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.
- package/dist/commercetools-frontend-application-shell-connectors.cjs.dev.js +67 -63
- package/dist/commercetools-frontend-application-shell-connectors.cjs.prod.js +63 -60
- package/dist/commercetools-frontend-application-shell-connectors.esm.js +67 -63
- package/dist/declarations/src/components/application-context/index.d.ts +2 -3
- package/dist/declarations/src/components/application-context/normalizers.d.ts +1 -5
- package/dist/declarations/src/export-types.d.ts +1 -2
- package/dist/declarations/src/index.d.ts +1 -1
- package/dist/declarations/src/types/generated/mc.d.ts +9 -8
- package/package.json +5 -5
|
@@ -11,6 +11,7 @@ import { createContext, useContext, useCallback, useEffect, useMemo } from 'reac
|
|
|
11
11
|
import moment from 'moment-timezone';
|
|
12
12
|
import { reportErrorToSentry } from '@commercetools-frontend/sentry';
|
|
13
13
|
import _URL from '@babel/runtime-corejs3/core-js-stable/url';
|
|
14
|
+
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
14
15
|
import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
|
|
15
16
|
import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
|
|
16
17
|
import _Object$entries from '@babel/runtime-corejs3/core-js-stable/object/entries';
|
|
@@ -43,7 +44,7 @@ import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringif
|
|
|
43
44
|
import { RetryLink } from '@apollo/client/link/retry';
|
|
44
45
|
|
|
45
46
|
// NOTE: This string will be replaced on build time with the package version.
|
|
46
|
-
var version = "24.
|
|
47
|
+
var version = "24.13.0";
|
|
47
48
|
|
|
48
49
|
// From https://github.com/acdlite/recompose/blob/master/src/packages/recompose/getDisplayName.js
|
|
49
50
|
const getDisplayName = Component => {
|
|
@@ -65,9 +66,10 @@ const getMcOriginTld = host => {
|
|
|
65
66
|
return host.replace(mcHostnameRegex, '$3');
|
|
66
67
|
};
|
|
67
68
|
const getMcApiUrlFromOrigin = origin => {
|
|
69
|
+
var _context;
|
|
68
70
|
const url = new _URL(origin);
|
|
69
71
|
const originTld = getMcOriginTld(url.host);
|
|
70
|
-
return
|
|
72
|
+
return _concatInstanceProperty(_context = "".concat(url.protocol, "//mc-api.")).call(_context, originTld);
|
|
71
73
|
};
|
|
72
74
|
const parseAsBoolean = value => value === true || value === 'true';
|
|
73
75
|
function getMcApiUrl() {
|
|
@@ -89,8 +91,6 @@ function getMcApiUrl() {
|
|
|
89
91
|
|
|
90
92
|
function ownKeys$7(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; }
|
|
91
93
|
function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys$7(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys$7(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
92
|
-
// Menu visibilities
|
|
93
|
-
|
|
94
94
|
// Permissions
|
|
95
95
|
|
|
96
96
|
// Action rights
|
|
@@ -126,17 +126,6 @@ const normalizeAllAppliedPermissions = allAppliedPermissions => {
|
|
|
126
126
|
});
|
|
127
127
|
}, {});
|
|
128
128
|
};
|
|
129
|
-
const normalizeAllAppliedMenuVisibilities = allAppliedMenuVisibilities => {
|
|
130
|
-
if (!allAppliedMenuVisibilities || allAppliedMenuVisibilities.length === 0) {
|
|
131
|
-
return null;
|
|
132
|
-
}
|
|
133
|
-
return _reduceInstanceProperty(allAppliedMenuVisibilities).call(allAppliedMenuVisibilities, (transformedAllApplied, allApplied) => {
|
|
134
|
-
if (!allApplied) return transformedAllApplied;
|
|
135
|
-
return _objectSpread$7(_objectSpread$7({}, transformedAllApplied), {}, {
|
|
136
|
-
[allApplied.name]: allApplied.value
|
|
137
|
-
});
|
|
138
|
-
}, {});
|
|
139
|
-
};
|
|
140
129
|
const normalizeAllAppliedActionRights = allAppliedActionRights => {
|
|
141
130
|
if (!allAppliedActionRights || allAppliedActionRights.length === 0) {
|
|
142
131
|
return null;
|
|
@@ -299,9 +288,9 @@ const createApplicationContext = (environment, user, project, projectDataLocale)
|
|
|
299
288
|
environment: mapEnvironmentToApplicationContextEnvironment(environment),
|
|
300
289
|
user: mapUserToApplicationContextUser(user),
|
|
301
290
|
project: mapProjectToApplicationContextProject(project),
|
|
302
|
-
permissions: normalizeAllAppliedPermissions(project
|
|
303
|
-
actionRights: normalizeAllAppliedActionRights(project
|
|
304
|
-
dataFences: normalizeAllAppliedDataFences(project
|
|
291
|
+
permissions: normalizeAllAppliedPermissions(project === null || project === void 0 ? void 0 : project.allAppliedPermissions),
|
|
292
|
+
actionRights: normalizeAllAppliedActionRights(project === null || project === void 0 ? void 0 : project.allAppliedActionRights),
|
|
293
|
+
dataFences: normalizeAllAppliedDataFences(project === null || project === void 0 ? void 0 : project.allAppliedDataFences),
|
|
305
294
|
dataLocale: projectDataLocale || null
|
|
306
295
|
});
|
|
307
296
|
const ApplicationContextProvider = props => jsx(Context$2.Provider, {
|
|
@@ -331,7 +320,7 @@ function withApplicationContext(mapApplicationContextToProps) {
|
|
|
331
320
|
return jsx(Component, _objectSpread$6(_objectSpread$6({}, props), mappedProps));
|
|
332
321
|
}
|
|
333
322
|
});
|
|
334
|
-
WrappedComponent.displayName =
|
|
323
|
+
WrappedComponent.displayName = "withApplicationContext(".concat(getDisplayName(Component), ")");
|
|
335
324
|
return WrappedComponent;
|
|
336
325
|
};
|
|
337
326
|
}
|
|
@@ -447,7 +436,7 @@ const ProjectExtensionProviderForImageRegex = props => {
|
|
|
447
436
|
};
|
|
448
437
|
ProjectExtensionProviderForImageRegex.displayName = 'ProjectExtensionProviderForImageRegex';
|
|
449
438
|
const GetProjectExtensionImageRegex = props => {
|
|
450
|
-
useWarning(false,
|
|
439
|
+
useWarning(false, "@commercetools-frontend/application-shell-connectors: It is not recommended to use the 'GetProjectExtensionImageRegex' anymore. Please use the 'useProjectExtensionImageRegex' hook instead.");
|
|
451
440
|
return jsx(Context.Consumer, {
|
|
452
441
|
children: imageRegexContext => props.render(imageRegexContext)
|
|
453
442
|
});
|
|
@@ -457,7 +446,7 @@ function withProjectExtensionImageRegex() {
|
|
|
457
446
|
let propKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'imageRegexData';
|
|
458
447
|
return Component => {
|
|
459
448
|
const WrappedComponent = props => {
|
|
460
|
-
useWarning(false,
|
|
449
|
+
useWarning(false, "@commercetools-frontend/application-shell-connectors: It is not recommended to use the 'withProjectExtensionImageRegex' high order component anymore. Please use the 'useProjectExtensionImageRegex' hook instead.");
|
|
461
450
|
const imageregexContext = useProjectExtensionImageRegex();
|
|
462
451
|
return jsx(GetProjectExtensionImageRegex, {
|
|
463
452
|
render: () =>
|
|
@@ -467,7 +456,7 @@ function withProjectExtensionImageRegex() {
|
|
|
467
456
|
}))
|
|
468
457
|
});
|
|
469
458
|
};
|
|
470
|
-
WrappedComponent.displayName =
|
|
459
|
+
WrappedComponent.displayName = "withProjectExtensionImageRegex(".concat(getDisplayName(Component), ")");
|
|
471
460
|
return WrappedComponent;
|
|
472
461
|
};
|
|
473
462
|
}
|
|
@@ -488,8 +477,8 @@ const forwardTokenRetryHeader = headers => _objectSpread$3(_objectSpread$3({}, h
|
|
|
488
477
|
// so that the MC BE can issue a new token.
|
|
489
478
|
// NOTE: the retry is not meant to work for the MC access token.
|
|
490
479
|
const getDoesGraphQLTargetSupportTokenRetry = context => {
|
|
491
|
-
var _context;
|
|
492
|
-
const graphQLTarget = context.headers
|
|
480
|
+
var _context$headers, _context$headers2, _context;
|
|
481
|
+
const graphQLTarget = ((_context$headers = context.headers) === null || _context$headers === void 0 ? void 0 : _context$headers[SUPPORTED_HEADERS.X_GRAPHQL_TARGET]) || ((_context$headers2 = context.headers) === null || _context$headers2 === void 0 ? void 0 : _context$headers2[SUPPORTED_HEADERS.X_GRAPHQL_TARGET.toLowerCase()]);
|
|
493
482
|
return Boolean(graphQLTarget && _includesInstanceProperty(_context = [GRAPHQL_TARGETS.COMMERCETOOLS_PLATFORM, GRAPHQL_TARGETS.ADMINISTRATION_SERVICE, GRAPHQL_TARGETS.SETTINGS_SERVICE, GRAPHQL_TARGETS.MERCHANT_CENTER_BACKEND]).call(_context, graphQLTarget));
|
|
494
483
|
};
|
|
495
484
|
const isHttpError = error => error.statusCode !== undefined || error.statusCode !== undefined;
|
|
@@ -503,7 +492,7 @@ const errorLink = onError(_ref => {
|
|
|
503
492
|
operation = _ref.operation,
|
|
504
493
|
forward = _ref.forward;
|
|
505
494
|
if (networkError && isHttpError(networkError) && networkError.statusCode === STATUS_CODES.UNAUTHORIZED) {
|
|
506
|
-
history.push(
|
|
495
|
+
history.push("/logout?reason=".concat(LOGOUT_REASONS.UNAUTHORIZED));
|
|
507
496
|
return;
|
|
508
497
|
}
|
|
509
498
|
|
|
@@ -515,7 +504,8 @@ const errorLink = onError(_ref => {
|
|
|
515
504
|
const context = operation.getContext();
|
|
516
505
|
if (graphQLErrors && isGraphQLError(graphQLErrors)) {
|
|
517
506
|
for (const err of graphQLErrors) {
|
|
518
|
-
|
|
507
|
+
var _err$extensions;
|
|
508
|
+
const isNonAuthenticatedViaExtensionCode = (err === null || err === void 0 || (_err$extensions = err.extensions) === null || _err$extensions === void 0 ? void 0 : _err$extensions.code) === 'UNAUTHENTICATED';
|
|
519
509
|
/**
|
|
520
510
|
* NOTE:
|
|
521
511
|
* Not not all GraphQL APIs expose an `extensions` field in
|
|
@@ -523,7 +513,7 @@ const errorLink = onError(_ref => {
|
|
|
523
513
|
* property until they introduced support for the `extensions`
|
|
524
514
|
* field.
|
|
525
515
|
*/
|
|
526
|
-
const isNonAuthenticatedViaCode = err
|
|
516
|
+
const isNonAuthenticatedViaCode = (err === null || err === void 0 ? void 0 : err.message) === 'invalid_token';
|
|
527
517
|
if ((isNonAuthenticatedViaExtensionCode || isNonAuthenticatedViaCode) && getDoesGraphQLTargetSupportTokenRetry(context) && !getSkipTokenRetry(context)) {
|
|
528
518
|
operation.setContext(_ref2 => {
|
|
529
519
|
let headers = _ref2.headers;
|
|
@@ -559,7 +549,8 @@ const errorLink = onError(_ref => {
|
|
|
559
549
|
|
|
560
550
|
// Attempt to load the `teamId` from sessionStorage
|
|
561
551
|
function selectTeamIdFromStorage() {
|
|
562
|
-
|
|
552
|
+
var _window$app$__DEVELOP;
|
|
553
|
+
return window.sessionStorage.getItem(STORAGE_KEYS.ACTIVE_TEAM_ID) || ((_window$app$__DEVELOP = window.app.__DEVELOPMENT__) === null || _window$app$__DEVELOP === void 0 || (_window$app$__DEVELOP = _window$app$__DEVELOP.oidc) === null || _window$app$__DEVELOP === void 0 ? void 0 : _window$app$__DEVELOP.teamId);
|
|
563
554
|
}
|
|
564
555
|
|
|
565
556
|
const staticUrlPathsInPositionOfProjectKey = ['login', 'logout', 'account'];
|
|
@@ -620,7 +611,7 @@ function getCorrelationId() {
|
|
|
620
611
|
|
|
621
612
|
const createApolloContextForProxyForwardTo = proxyForwardTocontext => ({
|
|
622
613
|
// Send the request to the forward-to endpoint.
|
|
623
|
-
uri:
|
|
614
|
+
uri: "".concat(getMcApiUrl(), "/proxy/forward-to"),
|
|
624
615
|
// Custom properties to be used by the "header-link".
|
|
625
616
|
forwardToConfig: proxyForwardTocontext,
|
|
626
617
|
skipGraphQlTargetCheck: true
|
|
@@ -662,7 +653,7 @@ function selectUserLanguageFromStorage() {
|
|
|
662
653
|
const getSessionToken = () => window.sessionStorage.getItem(STORAGE_KEYS.SESSION_TOKEN);
|
|
663
654
|
const setActiveSession = sessionToken => {
|
|
664
655
|
if (!sessionToken) return;
|
|
665
|
-
window.sessionStorage.setItem(STORAGE_KEYS.SESSION_TOKEN, sessionToken
|
|
656
|
+
window.sessionStorage.setItem(STORAGE_KEYS.SESSION_TOKEN, sessionToken !== null && sessionToken !== void 0 ? sessionToken : '');
|
|
666
657
|
window.localStorage.setItem(STORAGE_KEYS.LOGIN_STRATEGY, LOGIN_STRATEGY_OIDC);
|
|
667
658
|
// Remove flag for original workflow
|
|
668
659
|
window.localStorage.removeItem(STORAGE_KEYS.IS_AUTHENTICATED);
|
|
@@ -684,7 +675,8 @@ const setSessionScope = scope => {
|
|
|
684
675
|
window.sessionStorage.setItem(STORAGE_KEYS.SESSION_SCOPE, scope);
|
|
685
676
|
};
|
|
686
677
|
const getSessionState = stateId => {
|
|
687
|
-
|
|
678
|
+
var _context;
|
|
679
|
+
const sessionStateKey = _concatInstanceProperty(_context = "".concat(STORAGE_KEYS.NONCE, "_")).call(_context, stateId);
|
|
688
680
|
const unparsedSessionState = window.sessionStorage.getItem(sessionStateKey);
|
|
689
681
|
if (unparsedSessionState) {
|
|
690
682
|
try {
|
|
@@ -692,19 +684,22 @@ const getSessionState = stateId => {
|
|
|
692
684
|
return parsedSessionState;
|
|
693
685
|
} catch (error) {
|
|
694
686
|
if (process.env.NODE_ENV !== 'production') {
|
|
687
|
+
var _context2;
|
|
695
688
|
// eslint-disable-next-line no-console
|
|
696
|
-
console.warn(
|
|
689
|
+
console.warn(_concatInstanceProperty(_context2 = "Cannot parse session state for \"".concat(sessionStateKey, "\".\n")).call(_context2, unparsedSessionState));
|
|
697
690
|
}
|
|
698
691
|
}
|
|
699
692
|
}
|
|
700
693
|
return null;
|
|
701
694
|
};
|
|
702
695
|
const setSessionState = (stateId, state) => {
|
|
703
|
-
|
|
696
|
+
var _context3;
|
|
697
|
+
const sessionStateKey = _concatInstanceProperty(_context3 = "".concat(STORAGE_KEYS.NONCE, "_")).call(_context3, stateId);
|
|
704
698
|
window.sessionStorage.setItem(sessionStateKey, _JSON$stringify(state));
|
|
705
699
|
};
|
|
706
700
|
const removeSessionState = stateId => {
|
|
707
|
-
|
|
701
|
+
var _context4;
|
|
702
|
+
const sessionStateKey = _concatInstanceProperty(_context4 = "".concat(STORAGE_KEYS.NONCE, "_")).call(_context4, stateId);
|
|
708
703
|
window.sessionStorage.removeItem(sessionStateKey);
|
|
709
704
|
};
|
|
710
705
|
|
|
@@ -726,13 +721,14 @@ var oidcStorage = /*#__PURE__*/Object.freeze({
|
|
|
726
721
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? _Reflect$construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
727
722
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
|
|
728
723
|
function ownKeys$2(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; }
|
|
729
|
-
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
724
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context3 = ownKeys$2(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context4 = ownKeys$2(Object(t))).call(_context4, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
730
725
|
let _userAgent$1;
|
|
731
726
|
const getUserAgent$1 = () => {
|
|
732
727
|
if (!_userAgent$1) {
|
|
728
|
+
var _window$app$applicati, _window$app;
|
|
733
729
|
_userAgent$1 = createHttpUserAgent({
|
|
734
730
|
name: 'unknown-http-client',
|
|
735
|
-
libraryName: typeof window !== 'undefined' ? window.app
|
|
731
|
+
libraryName: typeof window !== 'undefined' ? (_window$app$applicati = (_window$app = window.app) === null || _window$app === void 0 ? void 0 : _window$app.applicationName) !== null && _window$app$applicati !== void 0 ? _window$app$applicati : 'unknown-application-name' : undefined
|
|
736
732
|
});
|
|
737
733
|
}
|
|
738
734
|
return _userAgent$1;
|
|
@@ -740,48 +736,50 @@ const getUserAgent$1 = () => {
|
|
|
740
736
|
const defaultForwardToVersion = 'v2';
|
|
741
737
|
const defaultForwardToAudiencePolicy = 'forward-url-full-path';
|
|
742
738
|
function buildApiUrl(endpoint) {
|
|
739
|
+
var _context;
|
|
743
740
|
const apiUrl = getMcApiUrl().replace(/\/$/, '');
|
|
744
|
-
return
|
|
741
|
+
return _concatInstanceProperty(_context = "".concat(apiUrl)).call(_context, endpoint);
|
|
745
742
|
}
|
|
746
743
|
const getAppliedForwardToHeaders = forwardToConfig => {
|
|
747
|
-
var
|
|
744
|
+
var _context2, _forwardToConfig$head, _forwardToConfig$vers, _forwardToConfig$audi;
|
|
748
745
|
if (!forwardToConfig) {
|
|
749
746
|
return {};
|
|
750
747
|
}
|
|
751
748
|
if (!forwardToConfig.uri) {
|
|
752
|
-
throw new Error(
|
|
749
|
+
throw new Error("Missing required \"uri\" option.");
|
|
753
750
|
}
|
|
754
751
|
const exchangeTokenClaims = [];
|
|
755
752
|
if (forwardToConfig.includeUserPermissions) {
|
|
756
753
|
exchangeTokenClaims.push('permissions');
|
|
757
754
|
}
|
|
758
|
-
return _objectSpread$2(_objectSpread$2({}, _reduceInstanceProperty(
|
|
755
|
+
return _objectSpread$2(_objectSpread$2({}, _reduceInstanceProperty(_context2 = _Object$entries((_forwardToConfig$head = forwardToConfig.headers) !== null && _forwardToConfig$head !== void 0 ? _forwardToConfig$head : {})).call(_context2, (customForwardHeaders, _ref) => {
|
|
759
756
|
let _ref2 = _slicedToArray(_ref, 2),
|
|
760
757
|
headerName = _ref2[0],
|
|
761
758
|
headerValue = _ref2[1];
|
|
762
759
|
return _objectSpread$2(_objectSpread$2({}, customForwardHeaders), {}, {
|
|
763
760
|
// Prefix headers so that the MC API can allow and forward them.
|
|
764
|
-
[
|
|
761
|
+
["x-forward-header-".concat(headerName)]: headerValue
|
|
765
762
|
});
|
|
766
763
|
}, {})), {}, {
|
|
767
|
-
[SUPPORTED_HEADERS.ACCEPT_VERSION]: forwardToConfig.version
|
|
764
|
+
[SUPPORTED_HEADERS.ACCEPT_VERSION]: (_forwardToConfig$vers = forwardToConfig.version) !== null && _forwardToConfig$vers !== void 0 ? _forwardToConfig$vers : defaultForwardToVersion,
|
|
768
765
|
[SUPPORTED_HEADERS.X_FORWARD_TO]: forwardToConfig.uri,
|
|
769
|
-
[SUPPORTED_HEADERS.X_FORWARD_TO_AUDIENCE_POLICY]: forwardToConfig.audiencePolicy
|
|
766
|
+
[SUPPORTED_HEADERS.X_FORWARD_TO_AUDIENCE_POLICY]: (_forwardToConfig$audi = forwardToConfig.audiencePolicy) !== null && _forwardToConfig$audi !== void 0 ? _forwardToConfig$audi : defaultForwardToAudiencePolicy,
|
|
770
767
|
[SUPPORTED_HEADERS.X_FORWARD_TO_CLAIMS]: exchangeTokenClaims.join(' ')
|
|
771
768
|
});
|
|
772
769
|
};
|
|
773
770
|
function createHttpClientOptions() {
|
|
771
|
+
var _config$projectKey, _window$app$__DEVELOP;
|
|
774
772
|
let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
775
773
|
const sessionToken = getSessionToken();
|
|
776
|
-
const projectKey = config.projectKey
|
|
774
|
+
const projectKey = (_config$projectKey = config.projectKey) !== null && _config$projectKey !== void 0 ? _config$projectKey : selectProjectKeyFromUrl();
|
|
777
775
|
const userId = selectUserId();
|
|
778
|
-
const userAgent = config
|
|
776
|
+
const userAgent = (config === null || config === void 0 ? void 0 : config.userAgent) || getUserAgent$1();
|
|
779
777
|
return {
|
|
780
778
|
credentials: 'include',
|
|
781
779
|
headers: omitEmpty(_objectSpread$2(_objectSpread$2({}, config.headers), {}, {
|
|
782
780
|
// Required headers
|
|
783
781
|
[SUPPORTED_HEADERS.ACCEPT]: 'application/json',
|
|
784
|
-
[SUPPORTED_HEADERS.AUTHORIZATION]: sessionToken ?
|
|
782
|
+
[SUPPORTED_HEADERS.AUTHORIZATION]: sessionToken ? "Bearer ".concat(sessionToken) : undefined,
|
|
785
783
|
[SUPPORTED_HEADERS.X_APPLICATION_ID]: window.app.applicationIdentifier,
|
|
786
784
|
[SUPPORTED_HEADERS.X_CUSTOM_VIEW_ID]: window.app.customViewId,
|
|
787
785
|
[SUPPORTED_HEADERS.X_CORRELATION_ID]: getCorrelationId({
|
|
@@ -790,7 +788,7 @@ function createHttpClientOptions() {
|
|
|
790
788
|
[SUPPORTED_HEADERS.X_PROJECT_KEY]: projectKey,
|
|
791
789
|
[SUPPORTED_HEADERS.X_USER_AGENT]: userAgent,
|
|
792
790
|
// MC Identity Login Mode Override header for development
|
|
793
|
-
[SUPPORTED_HEADERS.X_MC_IDENTITY_LOGIN_MODE_OVERRIDE]: window.app.__DEVELOPMENT__
|
|
791
|
+
[SUPPORTED_HEADERS.X_MC_IDENTITY_LOGIN_MODE_OVERRIDE]: (_window$app$__DEVELOP = window.app.__DEVELOPMENT__) === null || _window$app$__DEVELOP === void 0 ? void 0 : _window$app$__DEVELOP.mcIdentityLoginModeOverride
|
|
794
792
|
}, getAppliedForwardToHeaders(config.forwardToConfig)))
|
|
795
793
|
};
|
|
796
794
|
}
|
|
@@ -821,7 +819,7 @@ async function executeHttpClientRequest(fetcher) {
|
|
|
821
819
|
}))
|
|
822
820
|
}));
|
|
823
821
|
if (response.statusCode === STATUS_CODES.UNAUTHORIZED) {
|
|
824
|
-
throw new RenewTokenError(
|
|
822
|
+
throw new RenewTokenError("Unauthorized response, attempting retry.");
|
|
825
823
|
}
|
|
826
824
|
|
|
827
825
|
// In case a new session token is returned from the server, save it.
|
|
@@ -845,15 +843,15 @@ async function executeHttpClientRequest(fetcher) {
|
|
|
845
843
|
}
|
|
846
844
|
|
|
847
845
|
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; }
|
|
848
|
-
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
846
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context5, _context6; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context5 = ownKeys$1(Object(t), !0)).call(_context5, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context6 = ownKeys$1(Object(t))).call(_context6, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
849
847
|
let _userAgent;
|
|
850
848
|
const getUserAgent = () => {
|
|
851
849
|
if (!_userAgent) {
|
|
852
|
-
var _context;
|
|
850
|
+
var _context, _window$app$applicati, _window$app;
|
|
853
851
|
_userAgent = createHttpUserAgent({
|
|
854
852
|
name: 'apollo-client',
|
|
855
853
|
// version: apolloVersion,
|
|
856
|
-
libraryName: _filterInstanceProperty(_context = [typeof window !== 'undefined' ? window.app
|
|
854
|
+
libraryName: _filterInstanceProperty(_context = [typeof window !== 'undefined' ? (_window$app$applicati = (_window$app = window.app) === null || _window$app === void 0 ? void 0 : _window$app.applicationName) !== null && _window$app$applicati !== void 0 ? _window$app$applicati : 'unknown-application-name' : undefined, 'application-shell']).call(_context, Boolean).join('/'),
|
|
857
855
|
libraryVersion: version,
|
|
858
856
|
contactUrl: 'https://git.io/fjuyC',
|
|
859
857
|
// points to the appkit repo issues
|
|
@@ -867,13 +865,18 @@ const isKnownGraphQlTarget = target => {
|
|
|
867
865
|
return target ? _includesInstanceProperty(_context2 = _Object$values(GRAPHQL_TARGETS)).call(_context2, target) : false;
|
|
868
866
|
};
|
|
869
867
|
const extractSessionTokenFromResponse = context => {
|
|
870
|
-
|
|
868
|
+
var _context$response, _context$restResponse;
|
|
869
|
+
const refreshedSessionToken = (_context$response = context.response) === null || _context$response === void 0 || (_context$response = _context$response.headers) === null || _context$response === void 0 ? void 0 : _context$response.get('x-refreshed-session-token');
|
|
871
870
|
if (refreshedSessionToken) {
|
|
872
|
-
return refreshedSessionToken
|
|
871
|
+
return refreshedSessionToken !== null && refreshedSessionToken !== void 0 ? refreshedSessionToken : null;
|
|
873
872
|
}
|
|
874
|
-
const restResponseWithRefreshTokenHeader = context.restResponses
|
|
873
|
+
const restResponseWithRefreshTokenHeader = (_context$restResponse = context.restResponses) === null || _context$restResponse === void 0 ? void 0 : _findInstanceProperty(_context$restResponse).call(_context$restResponse, response => {
|
|
874
|
+
var _response$headers;
|
|
875
|
+
return (_response$headers = response.headers) === null || _response$headers === void 0 ? void 0 : _response$headers.has('x-refreshed-session-token');
|
|
876
|
+
});
|
|
875
877
|
if (restResponseWithRefreshTokenHeader) {
|
|
876
|
-
|
|
878
|
+
var _restResponseWithRefr;
|
|
879
|
+
return (_restResponseWithRefr = restResponseWithRefreshTokenHeader.headers.get('x-refreshed-session-token')) !== null && _restResponseWithRefr !== void 0 ? _restResponseWithRefr : null;
|
|
877
880
|
}
|
|
878
881
|
return null;
|
|
879
882
|
};
|
|
@@ -881,11 +884,11 @@ const extractSessionTokenFromResponse = context => {
|
|
|
881
884
|
/* eslint-disable import/prefer-default-export */
|
|
882
885
|
// Use a middleware to update the request headers with the correct params.
|
|
883
886
|
const headerLink = new ApolloLink((operation, forward) => {
|
|
884
|
-
var _context3;
|
|
887
|
+
var _context3, _context4;
|
|
885
888
|
const apolloContext = operation.getContext();
|
|
886
889
|
const variables = operation.variables;
|
|
887
890
|
const graphQlTarget = apolloContext.target || variables.target;
|
|
888
|
-
if (!apolloContext.skipGraphQlTargetCheck && !isKnownGraphQlTarget(graphQlTarget)) throw new Error(
|
|
891
|
+
if (!apolloContext.skipGraphQlTargetCheck && !isKnownGraphQlTarget(graphQlTarget)) throw new Error(_concatInstanceProperty(_context3 = "GraphQL target \"".concat(graphQlTarget, "\" is missing (or is not supported) in operation \"")).call(_context3, operation.operationName, "\""));
|
|
889
892
|
|
|
890
893
|
/**
|
|
891
894
|
* NOTE:
|
|
@@ -912,7 +915,7 @@ const headerLink = new ApolloLink((operation, forward) => {
|
|
|
912
915
|
forwardToConfig: apolloContext.forwardToConfig,
|
|
913
916
|
projectKey
|
|
914
917
|
}));
|
|
915
|
-
return _mapInstanceProperty(
|
|
918
|
+
return _mapInstanceProperty(_context4 = forward(operation)).call(_context4, response => {
|
|
916
919
|
const context = operation.getContext();
|
|
917
920
|
const refreshedSessionToken = extractSessionTokenFromResponse(context);
|
|
918
921
|
if (refreshedSessionToken) {
|
|
@@ -925,7 +928,7 @@ const headerLink = new ApolloLink((operation, forward) => {
|
|
|
925
928
|
const tokenRetryLink = new RetryLink({
|
|
926
929
|
attempts: (count, operation, error) => {
|
|
927
930
|
const context = operation.getContext();
|
|
928
|
-
if (error
|
|
931
|
+
if ((error === null || error === void 0 ? void 0 : error.statusCode) === STATUS_CODES.UNAUTHORIZED && count === 1 && getDoesGraphQLTargetSupportTokenRetry(context) && !getSkipTokenRetry(context)) {
|
|
929
932
|
operation.setContext(_ref => {
|
|
930
933
|
let headers = _ref.headers;
|
|
931
934
|
return {
|
|
@@ -943,7 +946,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _co
|
|
|
943
946
|
const createApolloLink = function () {
|
|
944
947
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
945
948
|
const httpLink = createHttpLink({
|
|
946
|
-
uri:
|
|
949
|
+
uri: "".concat(getMcApiUrl(), "/graphql"),
|
|
947
950
|
fetch
|
|
948
951
|
});
|
|
949
952
|
|
|
@@ -987,8 +990,9 @@ const mergeArraysObjects = function () {
|
|
|
987
990
|
}, []);
|
|
988
991
|
};
|
|
989
992
|
const createApolloClient = function () {
|
|
993
|
+
var _options$cache, _customCacheConfig$ty;
|
|
990
994
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
991
|
-
const customCacheConfig = options
|
|
995
|
+
const customCacheConfig = (_options$cache = options === null || options === void 0 ? void 0 : options.cache) !== null && _options$cache !== void 0 ? _options$cache : {};
|
|
992
996
|
return new ApolloClient({
|
|
993
997
|
link: createApolloLink(options),
|
|
994
998
|
// https://www.apollographql.com/docs/react/caching/cache-configuration/
|
|
@@ -1027,7 +1031,7 @@ const createApolloClient = function () {
|
|
|
1027
1031
|
}
|
|
1028
1032
|
}
|
|
1029
1033
|
}
|
|
1030
|
-
}, customCacheConfig.typePolicies
|
|
1034
|
+
}, (_customCacheConfig$ty = customCacheConfig.typePolicies) !== null && _customCacheConfig$ty !== void 0 ? _customCacheConfig$ty : {})
|
|
1031
1035
|
}))
|
|
1032
1036
|
});
|
|
1033
1037
|
};
|
|
@@ -1042,4 +1046,4 @@ function useMcMutation(mutation, options) {
|
|
|
1042
1046
|
return useMutation(mutation, options);
|
|
1043
1047
|
}
|
|
1044
1048
|
|
|
1045
|
-
export { ApplicationContext, ApplicationContextProvider, Context$2 as Context, CustomViewContextProvider, GetProjectExtensionImageRegex, ProjectExtensionProviderForImageRegex, buildApiUrl, createApolloClient, createApolloContextForProxyForwardTo, createHttpClientOptions, executeHttpClientRequest, getCachedApolloClient, getCorrelationId, getMcApiUrl, isLoggerEnabled, logger, normalizeAllAppliedActionRights, normalizeAllAppliedDataFences,
|
|
1049
|
+
export { ApplicationContext, ApplicationContextProvider, Context$2 as Context, CustomViewContextProvider, GetProjectExtensionImageRegex, ProjectExtensionProviderForImageRegex, buildApiUrl, createApolloClient, createApolloContextForProxyForwardTo, createHttpClientOptions, executeHttpClientRequest, getCachedApolloClient, getCorrelationId, getMcApiUrl, isLoggerEnabled, logger, normalizeAllAppliedActionRights, normalizeAllAppliedDataFences, normalizeAllAppliedPermissions, oidcStorage, selectProjectKeyFromUrl, selectTeamIdFromStorage, selectUserId, selectUserLanguageFromStorage, setCachedApolloClient, useApplicationContext, useCustomViewContext, useCustomViewParentDataRefresher, useMcLazyQuery, useMcMutation, useMcQuery, useProjectExtensionImageRegex, version, withApplicationContext, withProjectExtensionImageRegex };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { ProviderProps, TApplicationContext as ApplicationContext } from "./application-context.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { TPermissions as NormalizedPermissions, TActionRights as NormalizedActionRights, TDataFences as NormalizedDataFences } from "./normalizers.js";
|
|
3
3
|
export type TProviderProps<AdditionalEnvironmentProperties extends {}> = ProviderProps<AdditionalEnvironmentProperties>;
|
|
4
4
|
export type TApplicationContext<AdditionalEnvironmentProperties extends {}> = ApplicationContext<AdditionalEnvironmentProperties>;
|
|
5
|
-
export type TNormalizedMenuVisibilities = NormalizedMenuVisibilities;
|
|
6
5
|
export type TNormalizedPermissions = NormalizedPermissions;
|
|
7
6
|
export type TNormalizedActionRights = NormalizedActionRights;
|
|
8
7
|
export type TNormalizedDataFences = NormalizedDataFences;
|
|
9
8
|
export { Context, ApplicationContext, ApplicationContextProvider, withApplicationContext, useApplicationContext, } from "./application-context.js";
|
|
10
|
-
export { normalizeAllAppliedActionRights, normalizeAllAppliedDataFences,
|
|
9
|
+
export { normalizeAllAppliedActionRights, normalizeAllAppliedDataFences, normalizeAllAppliedPermissions, } from "./normalizers.js";
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type { TAppliedPermission, TAppliedActionRight,
|
|
2
|
-
export type TMenuVisibilities = {
|
|
3
|
-
[key: string]: boolean;
|
|
4
|
-
};
|
|
1
|
+
import type { TAppliedPermission, TAppliedActionRight, TStoreDataFence } from "../../types/generated/mc.js";
|
|
5
2
|
export type TPermissions = {
|
|
6
3
|
[key: string]: boolean;
|
|
7
4
|
};
|
|
@@ -43,6 +40,5 @@ export type TDataFences = Partial<Record<TDataFenceType, TDataFenceGroupedByReso
|
|
|
43
40
|
* to move this over to `permissions` and export it there.
|
|
44
41
|
*/
|
|
45
42
|
export declare const normalizeAllAppliedPermissions: (allAppliedPermissions?: TAppliedPermission[]) => TPermissions | null;
|
|
46
|
-
export declare const normalizeAllAppliedMenuVisibilities: (allAppliedMenuVisibilities?: TAppliedMenuVisibilities[]) => TMenuVisibilities | null;
|
|
47
43
|
export declare const normalizeAllAppliedActionRights: (allAppliedActionRights?: TAppliedActionRight[]) => TActionRights | null;
|
|
48
44
|
export declare const normalizeAllAppliedDataFences: (allAppliedDataFences?: TStoreDataFence[]) => TDataFences | null;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type { TProviderProps as ProviderProps, TApplicationContext as ApplicationContext,
|
|
1
|
+
import type { TProviderProps as ProviderProps, TApplicationContext as ApplicationContext, TNormalizedPermissions as NormalizedPermissions, TNormalizedActionRights as NormalizedActionRights, TNormalizedDataFences as NormalizedDataFences } from "./components/application-context/index.js";
|
|
2
2
|
import type { TCustomViewContextProviderProps as CustomViewContextProviderProps, TCustomViewContext as CustomViewContext } from "./components/custom-view-context/index.js";
|
|
3
3
|
import type { TImageRegexContext as ImageRegexContext } from "./components/project-extension-image-regex/index.js";
|
|
4
4
|
import type { TApolloContext as ApolloContext } from "./utils/apollo-context.js";
|
|
5
5
|
import type { TFetcher, TFetcherResponse, THeaders, TConfig, TOptions, TForwardToAudiencePolicy as ForwardToAudiencePolicy } from "./utils/http-client.js";
|
|
6
6
|
export type TProviderProps<AdditionalEnvironmentProperties extends {}> = ProviderProps<AdditionalEnvironmentProperties>;
|
|
7
7
|
export type TApplicationContext<AdditionalEnvironmentProperties extends {}> = ApplicationContext<AdditionalEnvironmentProperties>;
|
|
8
|
-
export type TNormalizedMenuVisibilities = NormalizedMenuVisibilities;
|
|
9
8
|
export type TNormalizedPermissions = NormalizedPermissions;
|
|
10
9
|
export type TNormalizedActionRights = NormalizedActionRights;
|
|
11
10
|
export type TNormalizedDataFences = NormalizedDataFences;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { default as version } from "./version.js";
|
|
2
2
|
export * from "./export-types.js";
|
|
3
|
-
export { Context, ApplicationContext, ApplicationContextProvider, withApplicationContext, useApplicationContext, normalizeAllAppliedActionRights, normalizeAllAppliedDataFences,
|
|
3
|
+
export { Context, ApplicationContext, ApplicationContextProvider, withApplicationContext, useApplicationContext, normalizeAllAppliedActionRights, normalizeAllAppliedDataFences, normalizeAllAppliedPermissions, } from "./components/application-context/index.js";
|
|
4
4
|
export { useCustomViewParentDataRefresher } from "./hooks/custom-views/use-custom-view-parent-data-refresher.js";
|
|
5
5
|
export { CustomViewContextProvider, useCustomViewContext, } from "./components/custom-view-context/index.js";
|
|
6
6
|
export { GetProjectExtensionImageRegex, ProjectExtensionProviderForImageRegex, withProjectExtensionImageRegex, useProjectExtensionImageRegex, } from "./components/project-extension-image-regex/index.js";
|
|
@@ -27,7 +27,8 @@ export type TAllPermissionsForAllApplications = {
|
|
|
27
27
|
__typename?: 'AllPermissionsForAllApplications';
|
|
28
28
|
allAppliedActionRights: Array<TAppliedActionRight>;
|
|
29
29
|
allAppliedDataFences: Array<TAppliedDataFence>;
|
|
30
|
-
|
|
30
|
+
/** @deprecated This field is no longer supported */
|
|
31
|
+
allAppliedMenuVisibilities?: Maybe<Array<Maybe<TAppliedMenuVisibilities>>>;
|
|
31
32
|
allAppliedPermissions: Array<TAppliedPermission>;
|
|
32
33
|
};
|
|
33
34
|
export type TAppliedActionRight = {
|
|
@@ -154,6 +155,7 @@ export type TMutation = {
|
|
|
154
155
|
createMyOrganization?: Maybe<TOrganizationCreated>;
|
|
155
156
|
createMyProject?: Maybe<TProjectPendingCreation>;
|
|
156
157
|
createOAuthClient: TOAuthClient;
|
|
158
|
+
createUserFromIdentity: TUser;
|
|
157
159
|
deleteAccount: TDeletedUser;
|
|
158
160
|
deleteOAuthClient: TOAuthClient;
|
|
159
161
|
importSampleData: TImportResponse;
|
|
@@ -176,6 +178,9 @@ export type TMutation_CreateMyProjectArgs = {
|
|
|
176
178
|
export type TMutation_CreateOAuthClientArgs = {
|
|
177
179
|
draft: TOAuthClientCreationInput;
|
|
178
180
|
};
|
|
181
|
+
export type TMutation_CreateUserFromIdentityArgs = {
|
|
182
|
+
token: Scalars['String'];
|
|
183
|
+
};
|
|
179
184
|
export type TMutation_DeleteAccountArgs = {
|
|
180
185
|
jwt: Scalars['String'];
|
|
181
186
|
};
|
|
@@ -269,8 +274,8 @@ export type TProject = TMetaData & {
|
|
|
269
274
|
__typename?: 'Project';
|
|
270
275
|
allAppliedActionRights: Array<TAppliedActionRight>;
|
|
271
276
|
allAppliedDataFences: Array<TAppliedDataFence>;
|
|
272
|
-
/** @deprecated This field
|
|
273
|
-
allAppliedMenuVisibilities
|
|
277
|
+
/** @deprecated This field is no longer supported */
|
|
278
|
+
allAppliedMenuVisibilities?: Maybe<Array<Maybe<TAppliedMenuVisibilities>>>;
|
|
274
279
|
allAppliedPermissions: Array<TAppliedPermission>;
|
|
275
280
|
allPermissionsForAllApplications: TAllPermissionsForAllApplications;
|
|
276
281
|
apiVersion: Scalars['String'];
|
|
@@ -444,6 +449,7 @@ export type TResetUser = {
|
|
|
444
449
|
};
|
|
445
450
|
export declare enum TSampleDatasets {
|
|
446
451
|
B2B = "B2B",
|
|
452
|
+
B2Clifestyle = "B2CLIFESTYLE",
|
|
447
453
|
Goodstore = "GOODSTORE"
|
|
448
454
|
}
|
|
449
455
|
export type TSetUserTimeZone = {
|
|
@@ -626,11 +632,6 @@ export type TFetchProjectQuery = {
|
|
|
626
632
|
name: string;
|
|
627
633
|
value: boolean;
|
|
628
634
|
}>;
|
|
629
|
-
allAppliedMenuVisibilities: Array<{
|
|
630
|
-
__typename?: 'AppliedMenuVisibilities';
|
|
631
|
-
name: string;
|
|
632
|
-
value: boolean;
|
|
633
|
-
}>;
|
|
634
635
|
allAppliedDataFences: Array<{
|
|
635
636
|
__typename: 'StoreDataFence';
|
|
636
637
|
type: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/application-shell-connectors",
|
|
3
|
-
"version": "24.
|
|
3
|
+
"version": "24.13.0",
|
|
4
4
|
"description": "Contains complementary tools for @commercetools-frontend/application-shell",
|
|
5
5
|
"bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
6
6
|
"repository": {
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@babel/runtime": "^7.22.15",
|
|
39
39
|
"@babel/runtime-corejs3": "^7.22.15",
|
|
40
|
-
"@commercetools-frontend/application-config": "24.
|
|
41
|
-
"@commercetools-frontend/browser-history": "24.
|
|
42
|
-
"@commercetools-frontend/constants": "24.
|
|
43
|
-
"@commercetools-frontend/sentry": "24.
|
|
40
|
+
"@commercetools-frontend/application-config": "24.13.0",
|
|
41
|
+
"@commercetools-frontend/browser-history": "24.13.0",
|
|
42
|
+
"@commercetools-frontend/constants": "24.13.0",
|
|
43
|
+
"@commercetools-frontend/sentry": "24.13.0",
|
|
44
44
|
"@commercetools/http-user-agent": "3.0.0",
|
|
45
45
|
"@emotion/react": "^11.14.0",
|
|
46
46
|
"@types/lodash": "^4.14.198",
|