@commercetools-frontend/application-shell-connectors 21.16.0 → 21.18.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.18.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,
@@ -262,8 +262,29 @@ var mapUserToApplicationContextUser = function mapUserToApplicationContextUser(u
262
262
  // a locale (language + country).
263
263
  locale: user.language,
264
264
  timeZone: user.timeZone || defaultTimeZone,
265
- projects: user.projects
266
- };
265
+ projects: user.projects,
266
+ verificationStatus: user.verificationStatus
267
+ }; // This property will only be populated when user has logged in using SSO
268
+
269
+ if (user.idTokenUserInfo) {
270
+ var additionalClaims = {};
271
+
272
+ try {
273
+ additionalClaims = JSON.parse(user.idTokenUserInfo.additionalClaims || '{}');
274
+ } catch (error) {
275
+ sentry.reportErrorToSentry(new Error('@commercetools-frontend/application-shell-connectors: Could not parse received user sso token additional claims from server.'), {
276
+ extra: {
277
+ receivedAdditionalClaims: user.idTokenUserInfo.additionalClaims
278
+ }
279
+ });
280
+ }
281
+
282
+ applicationContextUser.idTokenUserInfo = _objectSpread$1(_objectSpread$1({}, user.idTokenUserInfo), {}, {
283
+ additionalClaims: additionalClaims
284
+ });
285
+ }
286
+
287
+ return applicationContextUser;
267
288
  }; // Adjust certain fields which depend e.g. on the origin
268
289
 
269
290
  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.18.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,
@@ -260,8 +260,29 @@ var mapUserToApplicationContextUser = function mapUserToApplicationContextUser(u
260
260
  // a locale (language + country).
261
261
  locale: user.language,
262
262
  timeZone: user.timeZone || defaultTimeZone,
263
- projects: user.projects
264
- };
263
+ projects: user.projects,
264
+ verificationStatus: user.verificationStatus
265
+ }; // This property will only be populated when user has logged in using SSO
266
+
267
+ if (user.idTokenUserInfo) {
268
+ var additionalClaims = {};
269
+
270
+ try {
271
+ additionalClaims = JSON.parse(user.idTokenUserInfo.additionalClaims || '{}');
272
+ } catch (error) {
273
+ sentry.reportErrorToSentry(new Error('@commercetools-frontend/application-shell-connectors: Could not parse received user sso token additional claims from server.'), {
274
+ extra: {
275
+ receivedAdditionalClaims: user.idTokenUserInfo.additionalClaims
276
+ }
277
+ });
278
+ }
279
+
280
+ applicationContextUser.idTokenUserInfo = _objectSpread$1(_objectSpread$1({}, user.idTokenUserInfo), {}, {
281
+ additionalClaims: additionalClaims
282
+ });
283
+ }
284
+
285
+ return applicationContextUser;
265
286
  }; // Adjust certain fields which depend e.g. on the origin
266
287
 
267
288
  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.18.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,
@@ -239,8 +239,29 @@ var mapUserToApplicationContextUser = function mapUserToApplicationContextUser(u
239
239
  // a locale (language + country).
240
240
  locale: user.language,
241
241
  timeZone: user.timeZone || defaultTimeZone,
242
- projects: user.projects
243
- };
242
+ projects: user.projects,
243
+ verificationStatus: user.verificationStatus
244
+ }; // This property will only be populated when user has logged in using SSO
245
+
246
+ if (user.idTokenUserInfo) {
247
+ var additionalClaims = {};
248
+
249
+ try {
250
+ additionalClaims = JSON.parse(user.idTokenUserInfo.additionalClaims || '{}');
251
+ } catch (error) {
252
+ reportErrorToSentry(new Error('@commercetools-frontend/application-shell-connectors: Could not parse received user sso token additional claims from server.'), {
253
+ extra: {
254
+ receivedAdditionalClaims: user.idTokenUserInfo.additionalClaims
255
+ }
256
+ });
257
+ }
258
+
259
+ applicationContextUser.idTokenUserInfo = _objectSpread$1(_objectSpread$1({}, user.idTokenUserInfo), {}, {
260
+ additionalClaims: additionalClaims
261
+ });
262
+ }
263
+
264
+ return applicationContextUser;
244
265
  }; // Adjust certain fields which depend e.g. on the origin
245
266
 
246
267
  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' | 'verificationStatus'> & {
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'];
@@ -562,6 +574,7 @@ export declare type TUser = TMetaData & {
562
574
  numberFormat: Scalars['String'];
563
575
  projects: TProjectQueryResult;
564
576
  timeZone?: Maybe<Scalars['String']>;
577
+ verificationStatus: TVerificationStatus;
565
578
  version?: Maybe<Scalars['Int']>;
566
579
  };
567
580
  export declare type TUserDraft = {
@@ -578,6 +591,10 @@ export declare type TUserUpdateAction = {
578
591
  changePassword?: InputMaybe<TChangeUserPassword>;
579
592
  setTimeZone?: InputMaybe<TSetUserTimeZone>;
580
593
  };
594
+ export declare enum TVerificationStatus {
595
+ Unverified = "Unverified",
596
+ Verified = "Verified"
597
+ }
581
598
  export declare type TAmILoggedInQueryVariables = Exact<{
582
599
  [key: string]: never;
583
600
  }>;
@@ -682,6 +699,7 @@ export declare type TFetchLoggedInUserQuery = {
682
699
  launchdarklyTrackingTenant: string;
683
700
  defaultProjectKey?: string | null;
684
701
  businessRole?: string | null;
702
+ verificationStatus: TVerificationStatus;
685
703
  projects: {
686
704
  __typename?: 'ProjectQueryResult';
687
705
  total: number;
@@ -699,6 +717,17 @@ export declare type TFetchLoggedInUserQuery = {
699
717
  };
700
718
  }>;
701
719
  };
720
+ idTokenUserInfo?: {
721
+ __typename?: 'IdTokenUserInfo';
722
+ iss: string;
723
+ sub: string;
724
+ aud: string;
725
+ exp: number;
726
+ iat: number;
727
+ email?: string | null;
728
+ name?: string | null;
729
+ additionalClaims?: string | null;
730
+ } | null;
702
731
  } | null;
703
732
  };
704
733
  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.18.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.18.0",
27
+ "@commercetools-frontend/sentry": "21.18.0",
28
28
  "@emotion/react": "11.10.4",
29
29
  "@types/lodash": "^4.14.185",
30
30
  "@types/prop-types": "^15.7.5",
@@ -36,7 +36,7 @@
36
36
  "tiny-warning": "1.0.3"
37
37
  },
38
38
  "devDependencies": {
39
- "@apollo/client": "3.6.9",
39
+ "@apollo/client": "3.7.0",
40
40
  "@testing-library/react": "12.1.5",
41
41
  "react": "17.0.2"
42
42
  },