@commercetools-frontend/application-shell-connectors 21.16.0 → 21.17.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.
@@ -16,6 +16,7 @@ var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
16
16
  var _pt = require('prop-types');
17
17
  var react = require('react');
18
18
  var moment = require('moment-timezone');
19
+ var sentry = require('@commercetools-frontend/sentry');
19
20
  var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
20
21
  var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
21
22
  var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
@@ -25,7 +26,6 @@ var jsxRuntime = require('@emotion/react/jsx-runtime');
25
26
  var warning = require('tiny-warning');
26
27
  var react$1 = require('@apollo/client/react');
27
28
  var constants = require('@commercetools-frontend/constants');
28
- var sentry = require('@commercetools-frontend/sentry');
29
29
 
30
30
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
31
31
 
@@ -47,7 +47,7 @@ var _valuesInstanceProperty__default = /*#__PURE__*/_interopDefault(_valuesInsta
47
47
  var warning__default = /*#__PURE__*/_interopDefault(warning);
48
48
 
49
49
  // NOTE: This string will be replaced on build time with the package version.
50
- var version = "21.16.0";
50
+ var version = "21.17.0";
51
51
 
52
52
  var mcHostnameRegex = /^mc(-(\d){4,})?\.(.*)$/;
53
53
  var mcPreviewHostnameRegex = /^.*\.mc-preview\.(.*)$/;
@@ -252,7 +252,7 @@ var defaultTimeZone = moment__default["default"].tz.guess() || 'Etc/UTC'; // Exp
252
252
 
253
253
  var mapUserToApplicationContextUser = function mapUserToApplicationContextUser(user) {
254
254
  if (!user) return null;
255
- return {
255
+ var applicationContextUser = {
256
256
  id: user.id,
257
257
  email: user.email,
258
258
  firstName: user.firstName,
@@ -263,7 +263,27 @@ var mapUserToApplicationContextUser = function mapUserToApplicationContextUser(u
263
263
  locale: user.language,
264
264
  timeZone: user.timeZone || defaultTimeZone,
265
265
  projects: user.projects
266
- };
266
+ }; // This property will only be populated when user has logged in using SSO
267
+
268
+ if (user.idTokenUserInfo) {
269
+ var additionalClaims = {};
270
+
271
+ try {
272
+ additionalClaims = JSON.parse(user.idTokenUserInfo.additionalClaims || '');
273
+ } catch (error) {
274
+ sentry.reportErrorToSentry(new Error('@commercetools-frontend/application-shell-connectors: Could not parse received user sso token additional claims from server.'), {
275
+ extra: {
276
+ receivedAdditionalClaims: user.idTokenUserInfo.additionalClaims
277
+ }
278
+ });
279
+ }
280
+
281
+ applicationContextUser.idTokenUserInfo = _objectSpread$1(_objectSpread$1({}, user.idTokenUserInfo), {}, {
282
+ additionalClaims: additionalClaims
283
+ });
284
+ }
285
+
286
+ return applicationContextUser;
267
287
  }; // Adjust certain fields which depend e.g. on the origin
268
288
 
269
289
  var mapEnvironmentToApplicationContextEnvironment = function mapEnvironmentToApplicationContextEnvironment(environment, origin) {
@@ -16,6 +16,7 @@ var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
16
16
  require('prop-types');
17
17
  var react = require('react');
18
18
  var moment = require('moment-timezone');
19
+ var sentry = require('@commercetools-frontend/sentry');
19
20
  var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
20
21
  var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
21
22
  var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
@@ -25,7 +26,6 @@ var jsxRuntime = require('@emotion/react/jsx-runtime');
25
26
  require('tiny-warning');
26
27
  var react$1 = require('@apollo/client/react');
27
28
  var constants = require('@commercetools-frontend/constants');
28
- var sentry = require('@commercetools-frontend/sentry');
29
29
 
30
30
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
31
31
 
@@ -45,7 +45,7 @@ var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
45
45
  var _valuesInstanceProperty__default = /*#__PURE__*/_interopDefault(_valuesInstanceProperty);
46
46
 
47
47
  // NOTE: This string will be replaced on build time with the package version.
48
- var version = "21.16.0";
48
+ var version = "21.17.0";
49
49
 
50
50
  var mcHostnameRegex = /^mc(-(\d){4,})?\.(.*)$/;
51
51
  var mcPreviewHostnameRegex = /^.*\.mc-preview\.(.*)$/;
@@ -250,7 +250,7 @@ var defaultTimeZone = moment__default["default"].tz.guess() || 'Etc/UTC'; // Exp
250
250
 
251
251
  var mapUserToApplicationContextUser = function mapUserToApplicationContextUser(user) {
252
252
  if (!user) return null;
253
- return {
253
+ var applicationContextUser = {
254
254
  id: user.id,
255
255
  email: user.email,
256
256
  firstName: user.firstName,
@@ -261,7 +261,27 @@ var mapUserToApplicationContextUser = function mapUserToApplicationContextUser(u
261
261
  locale: user.language,
262
262
  timeZone: user.timeZone || defaultTimeZone,
263
263
  projects: user.projects
264
- };
264
+ }; // This property will only be populated when user has logged in using SSO
265
+
266
+ if (user.idTokenUserInfo) {
267
+ var additionalClaims = {};
268
+
269
+ try {
270
+ additionalClaims = JSON.parse(user.idTokenUserInfo.additionalClaims || '');
271
+ } catch (error) {
272
+ sentry.reportErrorToSentry(new Error('@commercetools-frontend/application-shell-connectors: Could not parse received user sso token additional claims from server.'), {
273
+ extra: {
274
+ receivedAdditionalClaims: user.idTokenUserInfo.additionalClaims
275
+ }
276
+ });
277
+ }
278
+
279
+ applicationContextUser.idTokenUserInfo = _objectSpread$1(_objectSpread$1({}, user.idTokenUserInfo), {}, {
280
+ additionalClaims: additionalClaims
281
+ });
282
+ }
283
+
284
+ return applicationContextUser;
265
285
  }; // Adjust certain fields which depend e.g. on the origin
266
286
 
267
287
  var mapEnvironmentToApplicationContextEnvironment = function mapEnvironmentToApplicationContextEnvironment(environment, origin) {
@@ -12,6 +12,7 @@ import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
12
12
  import _pt from 'prop-types';
13
13
  import { createContext, useContext, useEffect } from 'react';
14
14
  import moment from 'moment-timezone';
15
+ import { reportErrorToSentry } from '@commercetools-frontend/sentry';
15
16
  import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
16
17
  import _toConsumableArray from '@babel/runtime-corejs3/helpers/esm/toConsumableArray';
17
18
  import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
@@ -21,10 +22,9 @@ import { jsx } from '@emotion/react/jsx-runtime';
21
22
  import warning from 'tiny-warning';
22
23
  import { useQuery } from '@apollo/client/react';
23
24
  import { GRAPHQL_TARGETS } from '@commercetools-frontend/constants';
24
- import { reportErrorToSentry } from '@commercetools-frontend/sentry';
25
25
 
26
26
  // NOTE: This string will be replaced on build time with the package version.
27
- var version = "21.16.0";
27
+ var version = "21.17.0";
28
28
 
29
29
  var mcHostnameRegex = /^mc(-(\d){4,})?\.(.*)$/;
30
30
  var mcPreviewHostnameRegex = /^.*\.mc-preview\.(.*)$/;
@@ -229,7 +229,7 @@ var defaultTimeZone = moment.tz.guess() || 'Etc/UTC'; // Expose only certain fie
229
229
 
230
230
  var mapUserToApplicationContextUser = function mapUserToApplicationContextUser(user) {
231
231
  if (!user) return null;
232
- return {
232
+ var applicationContextUser = {
233
233
  id: user.id,
234
234
  email: user.email,
235
235
  firstName: user.firstName,
@@ -240,7 +240,27 @@ var mapUserToApplicationContextUser = function mapUserToApplicationContextUser(u
240
240
  locale: user.language,
241
241
  timeZone: user.timeZone || defaultTimeZone,
242
242
  projects: user.projects
243
- };
243
+ }; // This property will only be populated when user has logged in using SSO
244
+
245
+ if (user.idTokenUserInfo) {
246
+ var additionalClaims = {};
247
+
248
+ try {
249
+ additionalClaims = JSON.parse(user.idTokenUserInfo.additionalClaims || '');
250
+ } catch (error) {
251
+ reportErrorToSentry(new Error('@commercetools-frontend/application-shell-connectors: Could not parse received user sso token additional claims from server.'), {
252
+ extra: {
253
+ receivedAdditionalClaims: user.idTokenUserInfo.additionalClaims
254
+ }
255
+ });
256
+ }
257
+
258
+ applicationContextUser.idTokenUserInfo = _objectSpread$1(_objectSpread$1({}, user.idTokenUserInfo), {}, {
259
+ additionalClaims: additionalClaims
260
+ });
261
+ }
262
+
263
+ return applicationContextUser;
244
264
  }; // Adjust certain fields which depend e.g. on the origin
245
265
 
246
266
  var mapEnvironmentToApplicationContextEnvironment = function mapEnvironmentToApplicationContextEnvironment(environment, origin) {
@@ -1,5 +1,5 @@
1
1
  import type { ApplicationWindow } from '@commercetools-frontend/constants';
2
- import type { TFetchLoggedInUserQuery, TFetchProjectQuery } from '../../types/generated/mc';
2
+ import type { TFetchLoggedInUserQuery, TFetchProjectQuery, TIdTokenUserInfo } from '../../types/generated/mc';
3
3
  import { ComponentType, ReactNode } from 'react';
4
4
  declare type TFetchedUser = TFetchLoggedInUserQuery['user'];
5
5
  declare type TFetchedProject = TFetchProjectQuery['project'];
@@ -23,33 +23,15 @@ declare type TApplicationContextGroupedByResourceType = {
23
23
  declare type TApplicationContextDataFenceType = 'store';
24
24
  declare type TApplicationContextDataFences = Partial<Record<TApplicationContextDataFenceType, TApplicationContextGroupedByResourceType>>;
25
25
  declare type TApplicationContextEnvironment = ApplicationWindow['app'];
26
- declare const Context: import("react").Context<{}>;
27
- export declare const mapUserToApplicationContextUser: (user?: TFetchedUser) => {
28
- id: string;
29
- email: string;
30
- firstName: string;
31
- lastName: string;
32
- businessRole: string | null | undefined;
26
+ declare type TApplicationContextUser = Pick<NonNullable<TFetchedUser>, 'id' | 'email' | 'firstName' | 'lastName' | 'businessRole' | 'projects'> & {
33
27
  locale: string;
34
28
  timeZone: string;
35
- projects: {
36
- __typename?: "ProjectQueryResult" | undefined;
37
- total: number;
38
- results: {
39
- __typename?: "Project" | undefined;
40
- name: string;
41
- key: string;
42
- suspension: {
43
- __typename?: "ProjectSuspension" | undefined;
44
- isActive: boolean;
45
- };
46
- expiry: {
47
- __typename?: "ProjectExpiry" | undefined;
48
- isActive: boolean;
49
- };
50
- }[];
29
+ idTokenUserInfo?: Omit<TIdTokenUserInfo, 'additionalClaims'> & {
30
+ additionalClaims: Record<string, unknown>;
51
31
  };
52
- } | null;
32
+ };
33
+ declare const Context: import("react").Context<{}>;
34
+ export declare const mapUserToApplicationContextUser: (user?: TFetchedUser) => TApplicationContextUser | null;
53
35
  export declare const mapEnvironmentToApplicationContextEnvironment: <AdditionalEnvironmentProperties extends {}>(environment: AdditionalEnvironmentProperties & {
54
36
  applicationId: string;
55
37
  applicationName: string;
@@ -84,6 +84,17 @@ export declare type TFeature = {
84
84
  reason?: Maybe<Scalars['String']>;
85
85
  value: Scalars['Boolean'];
86
86
  };
87
+ export declare type TIdTokenUserInfo = {
88
+ __typename?: 'IdTokenUserInfo';
89
+ additionalClaims?: Maybe<Scalars['String']>;
90
+ aud: Scalars['String'];
91
+ email?: Maybe<Scalars['String']>;
92
+ exp: Scalars['Float'];
93
+ iat: Scalars['Float'];
94
+ iss: Scalars['String'];
95
+ name?: Maybe<Scalars['String']>;
96
+ sub: Scalars['String'];
97
+ };
87
98
  export declare type TInvitationInput = {
88
99
  emails: Array<Scalars['String']>;
89
100
  organization: TInvitationOrganizationInput;
@@ -551,6 +562,7 @@ export declare type TUser = TMetaData & {
551
562
  firstName: Scalars['String'];
552
563
  gravatarHash: Scalars['String'];
553
564
  id: Scalars['ID'];
565
+ idTokenUserInfo?: Maybe<TIdTokenUserInfo>;
554
566
  language: Scalars['String'];
555
567
  lastModifiedAt: Scalars['String'];
556
568
  lastName: Scalars['String'];
@@ -699,6 +711,17 @@ export declare type TFetchLoggedInUserQuery = {
699
711
  };
700
712
  }>;
701
713
  };
714
+ idTokenUserInfo?: {
715
+ __typename?: 'IdTokenUserInfo';
716
+ iss: string;
717
+ sub: string;
718
+ aud: string;
719
+ exp: number;
720
+ iat: number;
721
+ email?: string | null;
722
+ name?: string | null;
723
+ additionalClaims?: string | null;
724
+ } | null;
702
725
  } | null;
703
726
  };
704
727
  export declare type TFetchUserProjectsQueryVariables = Exact<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-frontend/application-shell-connectors",
3
- "version": "21.16.0",
3
+ "version": "21.17.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": {
@@ -23,8 +23,8 @@
23
23
  "dependencies": {
24
24
  "@babel/runtime": "^7.19.0",
25
25
  "@babel/runtime-corejs3": "^7.19.0",
26
- "@commercetools-frontend/constants": "21.16.0",
27
- "@commercetools-frontend/sentry": "21.16.0",
26
+ "@commercetools-frontend/constants": "21.17.0",
27
+ "@commercetools-frontend/sentry": "21.17.0",
28
28
  "@emotion/react": "11.10.4",
29
29
  "@types/lodash": "^4.14.185",
30
30
  "@types/prop-types": "^15.7.5",