@imposium-hub/components 2.5.17 → 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.
- package/dist/cjs/Util.js +1 -2
- package/dist/cjs/Util.js.map +1 -1
- package/dist/cjs/components/app-wrapper/AppWrapper.d.ts +14 -22
- package/dist/cjs/components/app-wrapper/AppWrapper.js +170 -216
- package/dist/cjs/components/app-wrapper/AppWrapper.js.map +1 -1
- package/dist/cjs/components/app-wrapper/AppWrapperV2.d.ts +3 -9
- package/dist/cjs/components/app-wrapper/AppWrapperV2.js +119 -45
- package/dist/cjs/components/app-wrapper/AppWrapperV2.js.map +1 -1
- package/dist/cjs/components/app-wrapper/AppWrapperV3.d.ts +1 -1
- package/dist/cjs/components/app-wrapper/AppWrapperV3.js +7 -44
- package/dist/cjs/components/app-wrapper/AppWrapperV3.js.map +1 -1
- package/dist/cjs/components/compositions/TextLayer.js +0 -1
- package/dist/cjs/components/compositions/TextLayer.js.map +1 -1
- package/dist/cjs/components/header/Header.d.ts +6 -5
- package/dist/cjs/components/header/Header.js +46 -62
- package/dist/cjs/components/header/Header.js.map +1 -1
- package/dist/cjs/index.d.ts +2 -7
- package/dist/cjs/index.js +5 -17
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/redux/actions/asset-uploads.js +0 -1
- package/dist/cjs/redux/actions/asset-uploads.js.map +1 -1
- package/dist/cjs/services/API.d.ts +6 -0
- package/dist/cjs/services/API.js +38 -9
- package/dist/cjs/services/API.js.map +1 -1
- package/dist/cjs/services/Session.d.ts +0 -11
- package/dist/cjs/services/Session.js +3 -126
- package/dist/cjs/services/Session.js.map +1 -1
- package/dist/esm/Util.js +1 -2
- package/dist/esm/Util.js.map +1 -1
- package/dist/esm/components/app-wrapper/AppWrapper.d.ts +14 -22
- package/dist/esm/components/app-wrapper/AppWrapper.js +75 -182
- package/dist/esm/components/app-wrapper/AppWrapper.js.map +1 -1
- package/dist/esm/components/app-wrapper/AppWrapperV2.d.ts +3 -9
- package/dist/esm/components/app-wrapper/AppWrapperV2.js +30 -33
- package/dist/esm/components/app-wrapper/AppWrapperV2.js.map +1 -1
- package/dist/esm/components/app-wrapper/AppWrapperV3.d.ts +1 -1
- package/dist/esm/components/app-wrapper/AppWrapperV3.js +5 -42
- package/dist/esm/components/app-wrapper/AppWrapperV3.js.map +1 -1
- package/dist/esm/components/compositions/TextLayer.js +0 -1
- package/dist/esm/components/compositions/TextLayer.js.map +1 -1
- package/dist/esm/components/header/Header.d.ts +6 -5
- package/dist/esm/components/header/Header.js +46 -60
- package/dist/esm/components/header/Header.js.map +1 -1
- package/dist/esm/index.d.ts +2 -7
- package/dist/esm/index.js +2 -7
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/redux/actions/asset-uploads.js +0 -1
- package/dist/esm/redux/actions/asset-uploads.js.map +1 -1
- package/dist/esm/services/API.d.ts +6 -0
- package/dist/esm/services/API.js +37 -9
- package/dist/esm/services/API.js.map +1 -1
- package/dist/esm/services/Session.d.ts +0 -11
- package/dist/esm/services/Session.js +3 -84
- package/dist/esm/services/Session.js.map +1 -1
- package/package.json +3 -2
- package/src/Util.ts +1 -2
- package/src/components/app-wrapper/AppWrapper.tsx +131 -272
- package/src/components/compositions/TextLayer.tsx +0 -1
- package/src/components/header/Header.tsx +55 -80
- package/src/index.ts +1 -14
- package/src/redux/actions/asset-uploads.ts +0 -1
- package/src/services/API.ts +48 -9
- package/src/components/auth-gate/AuthGate.tsx +0 -84
- package/src/redux/actions/auth.ts +0 -30
- package/src/redux/reducers/auth.ts +0 -33
- package/src/services/Auth0.ts +0 -82
- package/src/services/Session.ts +0 -153
package/src/services/Session.ts
DELETED
|
@@ -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
|
-
}
|