@imposium-hub/components 2.5.18 → 2.6.0-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.
Files changed (77) hide show
  1. package/dist/cjs/Util.js +1 -2
  2. package/dist/cjs/Util.js.map +1 -1
  3. package/dist/cjs/components/app-wrapper/AppWrapper.d.ts +14 -22
  4. package/dist/cjs/components/app-wrapper/AppWrapper.js +170 -216
  5. package/dist/cjs/components/app-wrapper/AppWrapper.js.map +1 -1
  6. package/dist/cjs/components/app-wrapper/AppWrapperV2.d.ts +3 -9
  7. package/dist/cjs/components/app-wrapper/AppWrapperV2.js +119 -45
  8. package/dist/cjs/components/app-wrapper/AppWrapperV2.js.map +1 -1
  9. package/dist/cjs/components/app-wrapper/AppWrapperV3.d.ts +1 -1
  10. package/dist/cjs/components/app-wrapper/AppWrapperV3.js +7 -44
  11. package/dist/cjs/components/app-wrapper/AppWrapperV3.js.map +1 -1
  12. package/dist/cjs/components/compositions/TextLayer.js +0 -1
  13. package/dist/cjs/components/compositions/TextLayer.js.map +1 -1
  14. package/dist/cjs/components/header/Header.d.ts +6 -5
  15. package/dist/cjs/components/header/Header.js +46 -62
  16. package/dist/cjs/components/header/Header.js.map +1 -1
  17. package/dist/cjs/components/modal/Modal.d.ts +1 -1
  18. package/dist/cjs/components/modal/Modal.js +2 -3
  19. package/dist/cjs/components/modal/Modal.js.map +1 -1
  20. package/dist/cjs/index.d.ts +2 -7
  21. package/dist/cjs/index.js +5 -17
  22. package/dist/cjs/index.js.map +1 -1
  23. package/dist/cjs/redux/actions/asset-uploads.js +0 -1
  24. package/dist/cjs/redux/actions/asset-uploads.js.map +1 -1
  25. package/dist/cjs/services/API.d.ts +6 -2
  26. package/dist/cjs/services/API.js +38 -15
  27. package/dist/cjs/services/API.js.map +1 -1
  28. package/dist/cjs/services/Session.d.ts +0 -11
  29. package/dist/cjs/services/Session.js +3 -126
  30. package/dist/cjs/services/Session.js.map +1 -1
  31. package/dist/esm/Util.js +1 -2
  32. package/dist/esm/Util.js.map +1 -1
  33. package/dist/esm/components/app-wrapper/AppWrapper.d.ts +14 -22
  34. package/dist/esm/components/app-wrapper/AppWrapper.js +75 -182
  35. package/dist/esm/components/app-wrapper/AppWrapper.js.map +1 -1
  36. package/dist/esm/components/app-wrapper/AppWrapperV2.d.ts +3 -9
  37. package/dist/esm/components/app-wrapper/AppWrapperV2.js +30 -33
  38. package/dist/esm/components/app-wrapper/AppWrapperV2.js.map +1 -1
  39. package/dist/esm/components/app-wrapper/AppWrapperV3.d.ts +1 -1
  40. package/dist/esm/components/app-wrapper/AppWrapperV3.js +5 -42
  41. package/dist/esm/components/app-wrapper/AppWrapperV3.js.map +1 -1
  42. package/dist/esm/components/compositions/TextLayer.js +0 -1
  43. package/dist/esm/components/compositions/TextLayer.js.map +1 -1
  44. package/dist/esm/components/header/Header.d.ts +6 -5
  45. package/dist/esm/components/header/Header.js +46 -60
  46. package/dist/esm/components/header/Header.js.map +1 -1
  47. package/dist/esm/components/modal/Modal.d.ts +1 -1
  48. package/dist/esm/components/modal/Modal.js +2 -3
  49. package/dist/esm/components/modal/Modal.js.map +1 -1
  50. package/dist/esm/index.d.ts +2 -7
  51. package/dist/esm/index.js +2 -7
  52. package/dist/esm/index.js.map +1 -1
  53. package/dist/esm/redux/actions/asset-uploads.js +0 -1
  54. package/dist/esm/redux/actions/asset-uploads.js.map +1 -1
  55. package/dist/esm/services/API.d.ts +6 -2
  56. package/dist/esm/services/API.js +37 -15
  57. package/dist/esm/services/API.js.map +1 -1
  58. package/dist/esm/services/Session.d.ts +0 -11
  59. package/dist/esm/services/Session.js +3 -84
  60. package/dist/esm/services/Session.js.map +1 -1
  61. package/dist/styles.css +0 -5
  62. package/dist/styles.less +0 -1
  63. package/less/components/button.less +0 -1
  64. package/package.json +3 -2
  65. package/src/Util.ts +1 -2
  66. package/src/components/app-wrapper/AppWrapper.tsx +131 -272
  67. package/src/components/compositions/TextLayer.tsx +0 -1
  68. package/src/components/header/Header.tsx +55 -80
  69. package/src/components/modal/Modal.tsx +7 -10
  70. package/src/index.ts +1 -14
  71. package/src/redux/actions/asset-uploads.ts +0 -1
  72. package/src/services/API.ts +48 -17
  73. package/src/components/auth-gate/AuthGate.tsx +0 -84
  74. package/src/redux/actions/auth.ts +0 -30
  75. package/src/redux/reducers/auth.ts +0 -33
  76. package/src/services/Auth0.ts +0 -82
  77. package/src/services/Session.ts +0 -153
@@ -1,82 +0,0 @@
1
- import * as auth0 from 'auth0-js';
2
-
3
- export interface IIdentity {
4
- accessToken: string;
5
- expiry: number;
6
- expiresIn: number;
7
- idToken: string;
8
- tokenType: string;
9
- idTokenPayload: any;
10
- }
11
-
12
- export default class AuthService {
13
- private static readonly IMPOSIUM_APP_DEFAULTS: any = {
14
- scope: 'openid',
15
- audience: 'https://api.4cinsights.io/',
16
- responseType: 'token id_token',
17
- redirectUri: `${window.location.origin}/auth`
18
- };
19
-
20
- // Auth0 JS client
21
- private static auth0Client: auth0.WebAuth;
22
-
23
- /*
24
- Initialize the auth0 web client with client ID for a given app-wrapper
25
- */
26
- public static bindToClient = (clientID: string, domain: string): void => {
27
- AuthService.auth0Client = new auth0.WebAuth({
28
- clientID,
29
- domain,
30
- ...AuthService.IMPOSIUM_APP_DEFAULTS
31
- });
32
- };
33
-
34
- /*
35
- redirect to auth0 for login
36
- */
37
- public static login = (): void => {
38
- AuthService.auth0Client.authorize();
39
- };
40
-
41
- /*
42
- Re-direct to auth0 to cancel session & instruct auth0 to redirect back to login
43
- */
44
- public static logout = (): void => {
45
- AuthService.auth0Client.logout({ returnTo: `${window.location.origin}/auth` });
46
- };
47
-
48
- /*
49
- Validate auth0 expiry timestamp
50
- */
51
- public static checkExpiry = (expiry: number): boolean => expiry > Date.now().valueOf() / 1000;
52
-
53
- /*
54
- Parse out identity from hash
55
- */
56
- public static parseIdFromHash = (hash: string): Promise<IIdentity> => {
57
- return new Promise((resolve, reject) => {
58
- AuthService.auth0Client.parseHash({ options: hash }, (e: Error, id: IIdentity) => {
59
- if (!e) {
60
- resolve(id);
61
- } else {
62
- reject(e);
63
- }
64
- });
65
- });
66
- };
67
-
68
- /*
69
- Defer to auth0 web servers to check if users session is valid
70
- */
71
- public static checkSession = (): Promise<IIdentity | Error> => {
72
- return new Promise((resolve, reject) => {
73
- AuthService.auth0Client.checkSession({}, (e: Error, id: IIdentity) => {
74
- if (!e) {
75
- resolve(id);
76
- } else {
77
- reject(e);
78
- }
79
- });
80
- });
81
- };
82
- }
@@ -1,153 +0,0 @@
1
- import * as Cookies from 'js-cookie';
2
- import axios, { AxiosResponse, AxiosError } from 'axios';
3
- import { IIdentity } from './Auth0';
4
-
5
- export interface IHubSession {
6
- sub: string;
7
- organization_id: string;
8
- story_id: string;
9
- }
10
-
11
- export default class SessionService {
12
- private static readonly LOGIN_STORY_ID_CACHE: string = 'imp_hub_last_story_id';
13
-
14
- private static readonly LOGIN_ORG_ID_CACHE: string = 'imp_hub_last_org_id';
15
-
16
- private static readonly SESSION_COOKIE_NAME: string = 'auth_state';
17
-
18
- private static readonly FRESH_COOKIE: IHubSession = {
19
- sub: '',
20
- organization_id: '',
21
- story_id: ''
22
- };
23
-
24
- /*
25
- Get list of accessible services with themes from Imposium API
26
- */
27
- public static getAccessData = (
28
- idToken: string,
29
- baseUrl?: string,
30
- getTotalRenders: boolean = false,
31
- accountId?: string
32
- ): Promise<any[]> => {
33
- return new Promise((resolve, reject) => {
34
- let accessUrl = baseUrl ? `${baseUrl}/access` : SessionService.determineAccessUrl();
35
- const headers: any = { Authorization: `Bearer ${idToken}` };
36
-
37
- if (getTotalRenders) {
38
- accessUrl += '?include_total_renders=true';
39
- }
40
-
41
- if (accountId && accountId !== 'undefined') {
42
- headers['X-Imposium-Account-Id'] = accountId;
43
- }
44
-
45
- axios
46
- .get(accessUrl, { headers })
47
- .then((res: AxiosResponse) => {
48
- resolve(res.data ? res.data : []);
49
- })
50
- .catch((e: AxiosError) => {
51
- reject(e);
52
- });
53
- });
54
- };
55
-
56
- public static getSession = (): IHubSession =>
57
- Cookies.getJSON(SessionService.SESSION_COOKIE_NAME);
58
-
59
- public static removeSession = (): void => {
60
- const domain: string = SessionService.scrapeDomain();
61
- Cookies.remove(SessionService.SESSION_COOKIE_NAME, { domain });
62
- SessionService.clearCachedOrgId();
63
- SessionService.clearCachedStoryId();
64
- };
65
-
66
- public static buildFreshSession = (
67
- freshIdentity: IIdentity,
68
- orgId: string = null,
69
- storyId: string = null
70
- ): void => {
71
- const {
72
- idTokenPayload: { sub, exp }
73
- } = freshIdentity;
74
-
75
- const freshSession: any = {
76
- sub
77
- };
78
-
79
- if (orgId) {
80
- freshSession.organization_id = orgId;
81
- }
82
-
83
- if (storyId) {
84
- freshSession.story_id = storyId;
85
- }
86
-
87
- SessionService.storeSession(freshSession, exp);
88
- };
89
-
90
- public static storeSession = (values: any, auth0Expiry: number): void => {
91
- const cookieData: IHubSession = { ...SessionService.FRESH_COOKIE, ...values };
92
- const domain: string = SessionService.scrapeDomain();
93
- const expiry: Date = new Date(auth0Expiry * 1000);
94
-
95
- Cookies.set(SessionService.SESSION_COOKIE_NAME, cookieData, { domain, expires: expiry });
96
- };
97
-
98
- public static cacheOrgId = (organizationId: string): void => {
99
- localStorage.setItem(SessionService.LOGIN_ORG_ID_CACHE, organizationId);
100
- };
101
-
102
- public static clearCachedOrgId = () => {
103
- localStorage.removeItem(SessionService.LOGIN_ORG_ID_CACHE);
104
- };
105
-
106
- public static getCachedOrgId = (): string => {
107
- return localStorage.getItem(SessionService.LOGIN_ORG_ID_CACHE);
108
- };
109
-
110
- public static cacheStoryId = (storyId: string): void => {
111
- localStorage.setItem(SessionService.LOGIN_STORY_ID_CACHE, storyId);
112
- };
113
-
114
- public static clearCachedStoryId = (): void => {
115
- localStorage.removeItem(SessionService.LOGIN_STORY_ID_CACHE);
116
- };
117
-
118
- public static getCachedStoryId = (): string => {
119
- return localStorage.getItem(SessionService.LOGIN_STORY_ID_CACHE);
120
- };
121
-
122
- public static updateSession = (values: any, auth0Expiry: number): void => {
123
- const prevCookieData: IHubSession = SessionService.getSession();
124
- const nextCookieData: IHubSession = { ...prevCookieData, ...values };
125
-
126
- SessionService.storeSession(nextCookieData, auth0Expiry);
127
- };
128
-
129
- /*
130
- Determine which domain to assign cookie to
131
- */
132
- private static scrapeDomain = (): string => {
133
- const domainParts: string[] = window.location.host.split('.').reverse();
134
- return domainParts.length > 2 ? `.${domainParts[1]}.${domainParts[0].split(':')[0]}` : null;
135
- };
136
-
137
- /*
138
- Figure out which access endpoint to hit based on env
139
- */
140
- private static determineAccessUrl = (): string => {
141
- const {
142
- location: { hostname, host }
143
- } = window;
144
-
145
- if (hostname === 'localhost') {
146
- return 'https://api/access';
147
- } else if (host.includes('.staging.')) {
148
- return 'https://api.staging.imposium.com/access';
149
- } else {
150
- return 'https://api.imposium.com/access';
151
- }
152
- };
153
- }