@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
|
@@ -1,208 +1,101 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import NoAccess from '../no-access/NoAccess';
|
|
3
2
|
import Header from '../header/Header';
|
|
4
|
-
import SessionService from '../../services/Session';
|
|
5
|
-
import AuthService from '../../services/Auth0';
|
|
6
|
-
import { connect } from 'react-redux';
|
|
7
|
-
import { bindActionCreators } from 'redux';
|
|
8
|
-
import { login, clearCachedAuth } from '../../redux/actions/auth';
|
|
9
3
|
import { validateAccessLevel } from '../../Util';
|
|
10
|
-
import { setAccessData } from '../../redux/actions/access';
|
|
11
4
|
import { ConfirmModal } from '../confirm-modal/ConfirmModal';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this.doCheckSession(true);
|
|
34
|
-
};
|
|
35
|
-
/*
|
|
36
|
-
Check the auth0 session expiry
|
|
37
|
-
*/
|
|
38
|
-
componentDidUpdate = (prevProps) => {
|
|
39
|
-
const { auth } = this.props;
|
|
40
|
-
let validAccessLevel;
|
|
41
|
-
if (auth) {
|
|
42
|
-
const { idTokenPayload: { exp } } = auth;
|
|
43
|
-
const validSession = AuthService.checkExpiry(exp);
|
|
44
|
-
if (!validSession) {
|
|
45
|
-
this.props.clearCachedAuth();
|
|
46
|
-
this.doCheckSession();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
if (this.props.organizationId !== prevProps.organizationId ||
|
|
50
|
-
this.props.access !== prevProps.access) {
|
|
51
|
-
validAccessLevel = validateAccessLevel(this.props.organizationId, this.props.serviceId, this.props.access);
|
|
52
|
-
if (!this.state.restrictAccess && !validAccessLevel) {
|
|
53
|
-
this.setState({ restrictAccess: true });
|
|
54
|
-
}
|
|
55
|
-
if (this.state.restrictAccess && validAccessLevel) {
|
|
56
|
-
this.setState({ restrictAccess: false });
|
|
57
|
-
}
|
|
5
|
+
import API from '../../services/API';
|
|
6
|
+
import { useAuth0 } from '@auth0/auth0-react';
|
|
7
|
+
const APP_WRAPPER_ERROR_STATES = {
|
|
8
|
+
UNAUTHORIZED_ORG: 'UNAUTHORIZED_ORG',
|
|
9
|
+
UNAUTHORIZED_APP: 'UNAUTHORIZED_APP'
|
|
10
|
+
};
|
|
11
|
+
export const AppWrapper = (props) => {
|
|
12
|
+
const [blockRender, setBlockRender] = React.useState(true);
|
|
13
|
+
const { children, organizationId, storyId, hideStoryPicker, hideDocs, hideOrgPicker, CrMLink, baseUrl, api, serviceId } = props;
|
|
14
|
+
const { isAuthenticated, isLoading, getAccessTokenSilently, loginWithRedirect, logout } = useAuth0();
|
|
15
|
+
const [errorState, setErrorState] = React.useState(null);
|
|
16
|
+
React.useEffect(() => {
|
|
17
|
+
void doCheckSession(true);
|
|
18
|
+
}, [isAuthenticated, isLoading]);
|
|
19
|
+
const getCachedStoryAndOrgForService = (freshAccess, sId) => {
|
|
20
|
+
const service = freshAccess.services.find((s) => s.id === sId);
|
|
21
|
+
if (service) {
|
|
22
|
+
return {
|
|
23
|
+
story_id: service.story_id,
|
|
24
|
+
organization_id: service.organization_id
|
|
25
|
+
};
|
|
58
26
|
}
|
|
59
27
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const session = SessionService.getSession();
|
|
70
|
-
if (session && session.story_id && session.organization_id) {
|
|
71
|
-
const org = freshAccess.organizations.find((o) => o.id === session.organization_id);
|
|
72
|
-
if (org) {
|
|
73
|
-
const story = org.stories.find((s) => s.id === session.story_id);
|
|
74
|
-
if (story) {
|
|
75
|
-
return { orgId: org.id, storyId: story.id };
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return null;
|
|
80
|
-
};
|
|
81
|
-
// If the org ID is not provided, but the storyID is provided, find the org ID if we can, if not, use the first org ID found and we'll show the story not found interface
|
|
82
|
-
if (!initialOrganizationId && initialStoryId) {
|
|
83
|
-
const org = freshAccess.organizations.find((o) => o.stories.find((s) => s.id === initialStoryId));
|
|
84
|
-
if (org) {
|
|
85
|
-
initialOrganizationId = org.id;
|
|
86
|
-
}
|
|
87
|
-
else if (firstOrg) {
|
|
88
|
-
initialOrganizationId = firstOrg.id;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
if (!initialStoryId) {
|
|
92
|
-
// If storyID is not provided, try to use the one from the previous session
|
|
93
|
-
const sessionIds = getIDsFromSession();
|
|
94
|
-
if (sessionIds) {
|
|
95
|
-
initialOrganizationId = sessionIds.orgId;
|
|
96
|
-
initialStoryId = sessionIds.storyId;
|
|
28
|
+
const propagateCreds = (freshAccess, token) => {
|
|
29
|
+
const { storyId: initialStoryId, organizationId: initialOrganizationId } = props;
|
|
30
|
+
// If an org and story ID was passed in, we're following a deeplink. Verify we have access to it, and if so, propagate those IDs and set them on the service
|
|
31
|
+
if (initialOrganizationId && initialStoryId) {
|
|
32
|
+
// Validate the user has access to the orgId and storyID passed in, if not, show the "Unauthorized" interface
|
|
33
|
+
const validAccessLevel = validateAccessLevel(initialOrganizationId, serviceId, freshAccess);
|
|
34
|
+
if (validAccessLevel) {
|
|
35
|
+
props.onAuthenticated(token, initialOrganizationId, initialStoryId);
|
|
36
|
+
setBlockRender(false);
|
|
97
37
|
}
|
|
98
38
|
else {
|
|
99
|
-
|
|
100
|
-
if (firstOrg) {
|
|
101
|
-
initialOrganizationId = firstOrg.id;
|
|
102
|
-
const story = firstOrg.stories[0];
|
|
103
|
-
if (story) {
|
|
104
|
-
initialStoryId = story.id;
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
initialStoryId = null;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
initialOrganizationId = null;
|
|
112
|
-
initialStoryId = null;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
// If at least one org was found, propagate that
|
|
117
|
-
if (initialOrganizationId) {
|
|
118
|
-
SessionService.buildFreshSession(freshIdentity, initialOrganizationId, initialStoryId);
|
|
119
|
-
onAuthenticated(initialOrganizationId, initialStoryId);
|
|
120
|
-
if (this.state.blockRender) {
|
|
121
|
-
this.setState({ blockRender: false });
|
|
39
|
+
setErrorState(APP_WRAPPER_ERROR_STATES.UNAUTHORIZED_APP);
|
|
122
40
|
}
|
|
123
|
-
// If
|
|
41
|
+
// If no orgID or storyID was passed in from the URL use the cached orgID and story ID on the service
|
|
124
42
|
}
|
|
125
43
|
else {
|
|
126
|
-
|
|
44
|
+
const { story_id, organization_id } = getCachedStoryAndOrgForService(freshAccess, serviceId);
|
|
45
|
+
props.onAuthenticated(token, organization_id, story_id);
|
|
46
|
+
setBlockRender(false);
|
|
127
47
|
}
|
|
128
48
|
};
|
|
129
|
-
/*
|
|
130
|
-
Bust cached creds if exist, invoke auth failure handler
|
|
131
|
-
*/
|
|
132
|
-
handleCheckSessionFailure = (e) => {
|
|
133
|
-
if (this.props.storyId) {
|
|
134
|
-
SessionService.cacheStoryId(this.props.storyId);
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
SessionService.clearCachedStoryId();
|
|
138
|
-
}
|
|
139
|
-
if (this.props.organizationId) {
|
|
140
|
-
SessionService.cacheOrgId(this.props.organizationId);
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
SessionService.clearCachedOrgId();
|
|
144
|
-
}
|
|
145
|
-
this.props.clearCachedAuth();
|
|
146
|
-
this.props.onAuthenticationFailure(e);
|
|
147
|
-
};
|
|
148
49
|
/*
|
|
149
50
|
Check auth0 session, pull Imposium access creds on success and initialize app-wrapper
|
|
150
51
|
*/
|
|
151
|
-
doCheckSession = (
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
this.setState({ blockRender: true });
|
|
52
|
+
const doCheckSession = async (doBlockRender = false) => {
|
|
53
|
+
if (doBlockRender) {
|
|
54
|
+
setBlockRender(true);
|
|
155
55
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
56
|
+
// If we're authenticated, get the access token, pull the access data, and propagate back to the parent component
|
|
57
|
+
if (isAuthenticated) {
|
|
58
|
+
let token;
|
|
59
|
+
try {
|
|
60
|
+
token = await getAccessTokenSilently();
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
// Trigger a logout if we can't get the access token
|
|
64
|
+
onLogout();
|
|
65
|
+
}
|
|
66
|
+
const orgId = organizationId ? organizationId : null;
|
|
67
|
+
const tempAPI = new API(baseUrl, token, orgId);
|
|
68
|
+
tempAPI
|
|
69
|
+
.getAccessData(false)
|
|
162
70
|
.then((freshAccess) => {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
this.propagateCreds(freshAccess, freshIdentity);
|
|
71
|
+
props.setAccessData(freshAccess);
|
|
72
|
+
propagateCreds(freshAccess, token);
|
|
166
73
|
})
|
|
167
74
|
.catch((e) => {
|
|
168
|
-
|
|
75
|
+
setErrorState(APP_WRAPPER_ERROR_STATES.UNAUTHORIZED_ORG);
|
|
169
76
|
});
|
|
170
|
-
|
|
171
|
-
.catch((e) => {
|
|
172
|
-
this.handleCheckSessionFailure(e);
|
|
173
|
-
});
|
|
174
|
-
};
|
|
175
|
-
render = () => {
|
|
176
|
-
const { blockRender, restrictAccess } = this.state;
|
|
177
|
-
const { children, showRequestAccess, allowUnauthenticatedRender } = this.props;
|
|
178
|
-
let innerContent;
|
|
179
|
-
if (!blockRender && restrictAccess) {
|
|
180
|
-
const showNoOrgs = this.props.access &&
|
|
181
|
-
this.props.access.organizations &&
|
|
182
|
-
this.props.access.organizations.length === 0;
|
|
183
|
-
const errorIndicator = showNoOrgs ? (React.createElement(NoAccess, { email: this.props.auth.idTokenPayload.userEmail, key: 'restriction-msg', type: 'no-orgs' })) : showRequestAccess ? (AppWrapper.RESTRICTED_REQUEST) : (AppWrapper.RESTRICTED_BLOCK);
|
|
184
|
-
innerContent = [
|
|
185
|
-
typeof children[0] === 'object' && children[0].type === Header && children[0],
|
|
186
|
-
errorIndicator
|
|
187
|
-
];
|
|
77
|
+
// If we're not loading, and we're not authenticated, call login, and cache story + org ID from URL if it's there
|
|
188
78
|
}
|
|
189
|
-
if (
|
|
190
|
-
|
|
79
|
+
else if (!isLoading && !isAuthenticated) {
|
|
80
|
+
void loginWithRedirect({
|
|
81
|
+
appState: { returnTo: window.location.href }
|
|
82
|
+
});
|
|
191
83
|
}
|
|
192
|
-
return (React.createElement("div", { id: 'app', className: 'app' },
|
|
193
|
-
innerContent,
|
|
194
|
-
React.createElement(ConfirmModal, null)));
|
|
195
84
|
};
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
|
|
85
|
+
const onLogout = () => {
|
|
86
|
+
setBlockRender(true);
|
|
87
|
+
void logout({ logoutParams: { returnTo: window.location.origin } });
|
|
88
|
+
};
|
|
89
|
+
let innerContent;
|
|
90
|
+
if (errorState) {
|
|
91
|
+
innerContent = errorState;
|
|
92
|
+
}
|
|
93
|
+
else if (!blockRender) {
|
|
94
|
+
innerContent = children;
|
|
95
|
+
}
|
|
96
|
+
return (React.createElement("div", { id: 'app', className: 'app' },
|
|
97
|
+
React.createElement(Header, { onLogout: onLogout, activeServiceId: serviceId, baseUrl: baseUrl, api: api, activeOrganization: organizationId, activeStory: storyId, hideStoryPicker: hideStoryPicker, hideDocs: hideDocs, showFTLogo: false, hideOrgPicker: hideOrgPicker, CrMLink: CrMLink, onStoryChange: props.onStoryChange, onOrganizationChange: props.onOrganizationChange }),
|
|
98
|
+
innerContent,
|
|
99
|
+
React.createElement(ConfirmModal, null)));
|
|
206
100
|
};
|
|
207
|
-
export default connect(mapStateToProps, mapDispatchToProps)(AppWrapper);
|
|
208
101
|
//# sourceMappingURL=AppWrapper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppWrapper.js","sourceRoot":"","sources":["../../../../src/components/app-wrapper/AppWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,
|
|
1
|
+
{"version":3,"file":"AppWrapper.js","sourceRoot":"","sources":["../../../../src/components/app-wrapper/AppWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,GAAqB,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAmB9C,MAAM,wBAAwB,GAAG;IAC7B,gBAAgB,EAAE,kBAAkB;IACpC,gBAAgB,EAAE,kBAAkB;CACvC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAuB,EAAE,EAAE;IAClD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3D,MAAM,EACF,QAAQ,EACR,cAAc,EACd,OAAO,EACP,eAAe,EACf,QAAQ,EACR,aAAa,EACb,OAAO,EACP,OAAO,EACP,GAAG,EACH,SAAS,EACZ,GAAG,KAAK,CAAC;IACV,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,EAAE,GACnF,QAAQ,EAAE,CAAC;IACf,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAEzD,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,KAAK,cAAc,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC,EAAE,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC,CAAC;IAEjC,MAAM,8BAA8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C;IAEF,IAAI,YAAiB,CAAC;IAEtB,IAAI,UAAU,EAAE,CAAC;QACb,YAAY,GAAG,UAAU,CAAC;IAC9B,CAAC;SAAM,IAAI,CAAC,WAAW,EAAE,CAAC;QACtB,YAAY,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAED,OAAO,CACH,6BACI,EAAE,EAAC,KAAK,EACR,SAAS,EAAC,KAAK;QACf,oBAAC,MAAM,IACH,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,SAAS,EAC1B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,GAAG,EACR,kBAAkB,EAAE,cAAc,EAClC,WAAW,EAAE,OAAO,EACpB,eAAe,EAAE,eAAe,EAChC,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,KAAK,EACjB,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,KAAK,CAAC,aAAa,EAClC,oBAAoB,EAAE,KAAK,CAAC,oBAAoB,GAClD;QACD,YAAY;QACb,oBAAC,YAAY,OAAG,CACd,CACT,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { IIdentity } from '../../services/Auth0';
|
|
3
2
|
import { IImposiumAPI } from '../../services/API';
|
|
4
3
|
export interface IAppWrapperProps {
|
|
4
|
+
auth0: any;
|
|
5
|
+
auth0Code: string;
|
|
5
6
|
baseUrl: string;
|
|
6
7
|
api: IImposiumAPI;
|
|
7
8
|
children: React.ReactChildren;
|
|
8
|
-
auth0Domain: string;
|
|
9
|
-
auth0ClientId: string;
|
|
10
9
|
organizationId: string;
|
|
11
10
|
serviceId: number;
|
|
12
11
|
access: any;
|
|
13
|
-
auth: any;
|
|
14
12
|
setAccessData(accessData: any): any;
|
|
15
13
|
onAuthenticated: (activeOrgId: string, activeStoryId: string) => any;
|
|
16
14
|
onStoryChange(storyId: string): any;
|
|
17
15
|
onOrganizationChange(orgId: string, storyId: string): any;
|
|
18
|
-
onAuthenticationFailure: (e: Error) => any;
|
|
19
|
-
login: (id: IIdentity) => any;
|
|
20
|
-
logout: (doFederatedLogout: boolean) => any;
|
|
21
|
-
clearCachedAuth: () => any;
|
|
22
16
|
storyId?: string;
|
|
23
17
|
CrMLink?: string;
|
|
24
18
|
hideStoryPicker?: boolean;
|
|
@@ -28,5 +22,5 @@ export interface IAppWrapperProps {
|
|
|
28
22
|
export interface IAppWrapperState {
|
|
29
23
|
blockRender: boolean;
|
|
30
24
|
}
|
|
31
|
-
declare const _default:
|
|
25
|
+
declare const _default: React.ComponentType<Omit<import("@auth0/auth0-react").WithAuth0Props, "auth0">>;
|
|
32
26
|
export default _default;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import Header from '../header/Header';
|
|
3
|
-
import AuthService from '../../services/Auth0';
|
|
4
3
|
import { connect } from 'react-redux';
|
|
5
4
|
import { bindActionCreators } from 'redux';
|
|
6
|
-
import { login, clearCachedAuth } from '../../redux/actions/auth';
|
|
7
5
|
import { validateAccessLevel } from '../../Util';
|
|
8
6
|
import { setAccessData } from '../../redux/actions/access';
|
|
9
7
|
import { ConfirmModal } from '../confirm-modal/ConfirmModal';
|
|
10
8
|
import API from '../../services/API';
|
|
11
9
|
import SessionService from '../../services/Session';
|
|
10
|
+
import { withAuth0, withAuthenticationRequired } from '@auth0/auth0-react';
|
|
12
11
|
class AppWrapper extends React.Component {
|
|
13
12
|
constructor(p) {
|
|
14
13
|
super(p);
|
|
@@ -17,25 +16,24 @@ class AppWrapper extends React.Component {
|
|
|
17
16
|
};
|
|
18
17
|
}
|
|
19
18
|
componentDidMount = () => {
|
|
20
|
-
|
|
21
|
-
AuthService.bindToClient(auth0ClientId, auth0Domain);
|
|
22
|
-
// Always check the session
|
|
23
|
-
this.doCheckSession(true);
|
|
19
|
+
void this.doCheckSession(true);
|
|
24
20
|
};
|
|
25
21
|
/*
|
|
26
22
|
Check the auth0 session expiry
|
|
27
23
|
*/
|
|
28
24
|
componentDidUpdate = (prevProps) => {
|
|
29
|
-
const { auth } = this.props;
|
|
25
|
+
// const { auth } = this.props;
|
|
30
26
|
// let validAccessLevel: boolean;
|
|
31
|
-
if (auth) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
// if (auth) {
|
|
28
|
+
// const {
|
|
29
|
+
// idTokenPayload: { exp }
|
|
30
|
+
// } = auth;
|
|
31
|
+
// const validSession: boolean = AuthService.checkExpiry(exp);
|
|
32
|
+
// if (!validSession) {
|
|
33
|
+
// // this.props.clearCachedAuth();
|
|
34
|
+
// this.doCheckSession();
|
|
35
|
+
// }
|
|
36
|
+
// }
|
|
39
37
|
};
|
|
40
38
|
/*
|
|
41
39
|
Emit creds to React parent
|
|
@@ -49,7 +47,7 @@ class AppWrapper extends React.Component {
|
|
|
49
47
|
};
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
|
-
propagateCreds = (freshAccess
|
|
50
|
+
propagateCreds = (freshAccess) => {
|
|
53
51
|
const { storyId: initialStoryId, organizationId: initialOrganizationId, onAuthenticated } = this.props;
|
|
54
52
|
// If an org and story ID was passed in, we're following a deeplink. Verify we have access to it, and if so, propagate those IDs and set them on the service
|
|
55
53
|
if (initialOrganizationId && initialStoryId) {
|
|
@@ -87,36 +85,35 @@ class AppWrapper extends React.Component {
|
|
|
87
85
|
SessionService.clearCachedOrgId();
|
|
88
86
|
}
|
|
89
87
|
// this.props.clearCachedAuth();
|
|
90
|
-
this.props.onAuthenticationFailure(e);
|
|
88
|
+
// this.props.onAuthenticationFailure(e);
|
|
91
89
|
};
|
|
92
90
|
/*
|
|
93
91
|
Check auth0 session, pull Imposium access creds on success and initialize app-wrapper
|
|
94
92
|
*/
|
|
95
|
-
doCheckSession = (blockRender = false) => {
|
|
96
|
-
const { baseUrl } = this.props;
|
|
93
|
+
doCheckSession = async (blockRender = false) => {
|
|
94
|
+
const { auth0, baseUrl } = this.props;
|
|
97
95
|
if (blockRender) {
|
|
98
96
|
this.setState({ blockRender: true });
|
|
99
97
|
}
|
|
100
|
-
|
|
101
|
-
.
|
|
98
|
+
if (auth0.isAuthenticated) {
|
|
99
|
+
const token = await auth0.getAccessTokenSilently();
|
|
102
100
|
const orgId = this.props.organizationId
|
|
103
101
|
? this.props.organizationId
|
|
104
102
|
: null;
|
|
105
|
-
const api = new API(baseUrl,
|
|
103
|
+
const api = new API(baseUrl, token, orgId);
|
|
106
104
|
api.getAccessData(false)
|
|
107
105
|
.then((freshAccess) => {
|
|
108
106
|
this.props.setAccessData(freshAccess);
|
|
109
|
-
this.
|
|
110
|
-
this.propagateCreds(freshAccess, freshIdentity);
|
|
107
|
+
this.propagateCreds(freshAccess);
|
|
111
108
|
})
|
|
112
109
|
.catch((e) => {
|
|
113
110
|
// this.setState({ restrictAccess: true, blockRender: false });
|
|
114
111
|
// TODO: push to a different route here?
|
|
115
112
|
});
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
auth0.loginWithRedirect();
|
|
116
|
+
}
|
|
120
117
|
};
|
|
121
118
|
render = () => {
|
|
122
119
|
const { blockRender } = this.state;
|
|
@@ -126,20 +123,20 @@ class AppWrapper extends React.Component {
|
|
|
126
123
|
innerContent = children;
|
|
127
124
|
}
|
|
128
125
|
return (React.createElement("div", { id: 'app', className: 'app' },
|
|
129
|
-
React.createElement(Header, { activeServiceId: this.props.serviceId, baseUrl: baseUrl, api: api, activeOrganization: organizationId, activeStory: storyId, hideStoryPicker: hideStoryPicker, hideDocs: hideDocs, showFTLogo: false, hideOrgPicker: hideOrgPicker, CrMLink: CrMLink, onStoryChange: this.props.onStoryChange, onOrganizationChange: this.props.onOrganizationChange
|
|
126
|
+
React.createElement(Header, { activeServiceId: this.props.serviceId, baseUrl: baseUrl, api: api, activeOrganization: organizationId, activeStory: storyId, hideStoryPicker: hideStoryPicker, hideDocs: hideDocs, showFTLogo: false, hideOrgPicker: hideOrgPicker, CrMLink: CrMLink, onStoryChange: this.props.onStoryChange, onOrganizationChange: this.props.onOrganizationChange }),
|
|
130
127
|
innerContent,
|
|
131
128
|
React.createElement(ConfirmModal, null)));
|
|
132
129
|
};
|
|
133
130
|
}
|
|
134
131
|
const mapDispatchToProps = (dispatch) => {
|
|
135
132
|
return bindActionCreators({
|
|
136
|
-
login,
|
|
133
|
+
// login,
|
|
137
134
|
setAccessData,
|
|
138
|
-
clearCachedAuth
|
|
135
|
+
// clearCachedAuth
|
|
139
136
|
}, dispatch);
|
|
140
137
|
};
|
|
141
138
|
const mapStateToProps = (state) => {
|
|
142
|
-
return {
|
|
139
|
+
return { access: state.access };
|
|
143
140
|
};
|
|
144
|
-
export default connect(mapStateToProps, mapDispatchToProps)(AppWrapper);
|
|
141
|
+
export default withAuth0(withAuthenticationRequired(connect(mapStateToProps, mapDispatchToProps)(AppWrapper)));
|
|
145
142
|
//# sourceMappingURL=AppWrapperV2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppWrapperV2.js","sourceRoot":"","sources":["../../../../src/components/app-wrapper/AppWrapperV2.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,
|
|
1
|
+
{"version":3,"file":"AppWrapperV2.js","sourceRoot":"","sources":["../../../../src/components/app-wrapper/AppWrapperV2.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,aA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AC,KAAK,CAAC;QAEzH,IAAI,YAAiB,CAAC;QAEtB,IAAI,CAAC,WAAW,EAAC,CAAC;YACd,YAAY,GAAG,QAAQ,CAAC;QAC5B,CAAC;QAED,OAAO,CACH,6BACI,EAAE,EAAC,KAAK,EACR,SAAS,EAAC,KAAK;YACf,oBAAC,MAAM,IACH,eAAe,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EACrC,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,GAAG,EACR,kBAAkB,EAAE,cAAc,EAClC,WAAW,EAAE,OAAO,EACpB,eAAe,EAAE,eAAe,EAChC,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,KAAK,EACjB,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,EACvC,oBAAoB,EAAE,IAAI,CAAC,KAAK,CAAC,oBAAoB,GACvD;YACD,YAAY;YACb,oBAAC,YAAY,OAAG,CACd,CACT,CAAC;IACN,CAAC,CAAC;CACL;AAED,MAAM,kBAAkB,GAAG,CAAC,QAAQ,EAAE,EAAE;IACpC,OAAO,kBAAkB,CACrB;QACI,SAAS;QACT,aAAa;QACb,kBAAkB;KACrB,EACD,QAAQ,CACX,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,KAAK,EAAO,EAAE;IACnC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;AACpC,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC,0BAA0B,CAAC,OAAO,CAAC,eAAe,EAAE,kBAAkB,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -3,38 +3,14 @@ import Header from '../header/Header';
|
|
|
3
3
|
import { validateAccessLevel } from '../../Util';
|
|
4
4
|
import { ConfirmModal } from '../confirm-modal/ConfirmModal';
|
|
5
5
|
import API from '../../services/API';
|
|
6
|
-
import SessionService from '../../services/Session';
|
|
7
6
|
import { useAuth0 } from '@auth0/auth0-react';
|
|
8
|
-
export const
|
|
7
|
+
export const AppWrapper = (props) => {
|
|
9
8
|
const [blockRender, setBlockRender] = React.useState(true);
|
|
10
9
|
const { children, organizationId, storyId, hideStoryPicker, hideDocs, hideOrgPicker, CrMLink, baseUrl, api, serviceId } = props;
|
|
11
10
|
const { isAuthenticated, isLoading, getAccessTokenSilently, loginWithRedirect, logout } = useAuth0();
|
|
12
11
|
React.useEffect(() => {
|
|
13
12
|
void doCheckSession(true);
|
|
14
13
|
}, [isAuthenticated, isLoading]);
|
|
15
|
-
// public componentDidMount = (): void => {
|
|
16
|
-
// void this.doCheckSession(true);
|
|
17
|
-
// };
|
|
18
|
-
/*
|
|
19
|
-
Check the auth0 session expiry
|
|
20
|
-
*/
|
|
21
|
-
// public componentDidUpdate = (prevProps): void => {
|
|
22
|
-
// const { auth } = this.props;
|
|
23
|
-
// let validAccessLevel: boolean;
|
|
24
|
-
// if (auth) {
|
|
25
|
-
// const {
|
|
26
|
-
// idTokenPayload: { exp }
|
|
27
|
-
// } = auth;
|
|
28
|
-
// const validSession: boolean = AuthService.checkExpiry(exp);
|
|
29
|
-
// if (!validSession) {
|
|
30
|
-
// // this.props.clearCachedAuth();
|
|
31
|
-
// this.doCheckSession();
|
|
32
|
-
// }
|
|
33
|
-
// }
|
|
34
|
-
// };
|
|
35
|
-
/*
|
|
36
|
-
Emit creds to React parent
|
|
37
|
-
*/
|
|
38
14
|
const getCachedStoryAndOrgForService = (freshAccess, sId) => {
|
|
39
15
|
const service = freshAccess.services.find((s) => s.id === sId);
|
|
40
16
|
if (service) {
|
|
@@ -46,10 +22,6 @@ export const AppWrapperV3 = (props) => {
|
|
|
46
22
|
};
|
|
47
23
|
const propagateCreds = (freshAccess, token) => {
|
|
48
24
|
const { storyId: initialStoryId, organizationId: initialOrganizationId } = props;
|
|
49
|
-
const cachedOrgId = SessionService.getCachedOrgId() || null;
|
|
50
|
-
const cachedStoryId = SessionService.getCachedStoryId() || null;
|
|
51
|
-
console.log('cached ids');
|
|
52
|
-
console.log(cachedOrgId, cachedStoryId);
|
|
53
25
|
// If an org and story ID was passed in, we're following a deeplink. Verify we have access to it, and if so, propagate those IDs and set them on the service
|
|
54
26
|
if (initialOrganizationId && initialStoryId) {
|
|
55
27
|
// Validate the user has access to the orgId and storyID passed in, if not, show the "Unauthorized" interface
|
|
@@ -95,22 +67,13 @@ export const AppWrapperV3 = (props) => {
|
|
|
95
67
|
// If we're not loading, and we're not authenticated, call login, and cache story + org ID from URL if it's there
|
|
96
68
|
}
|
|
97
69
|
else if (!isLoading && !isAuthenticated) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
SessionService.clearCachedStoryId();
|
|
103
|
-
}
|
|
104
|
-
if (organizationId) {
|
|
105
|
-
SessionService.cacheOrgId(organizationId);
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
SessionService.clearCachedOrgId();
|
|
109
|
-
}
|
|
110
|
-
void loginWithRedirect();
|
|
70
|
+
void loginWithRedirect({
|
|
71
|
+
appState: { returnTo: window.location.href }
|
|
72
|
+
});
|
|
111
73
|
}
|
|
112
74
|
};
|
|
113
75
|
const onLogout = () => {
|
|
76
|
+
setBlockRender(true);
|
|
114
77
|
void logout({ logoutParams: { returnTo: window.location.origin } });
|
|
115
78
|
};
|
|
116
79
|
let innerContent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppWrapperV3.js","sourceRoot":"","sources":["../../../../src/components/app-wrapper/AppWrapperV3.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,GAAqB,MAAM,oBAAoB,CAAC;AACvD,OAAO,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