@zengenti/contensis-react-base 3.0.2-beta.2 → 3.0.2-beta.21
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/cjs/{App-ee485b92.js → App-21a7d836.js} +120 -432
- package/cjs/App-21a7d836.js.map +1 -0
- package/cjs/ContensisDeliveryApi-c079b03a.js +231 -0
- package/cjs/ContensisDeliveryApi-c079b03a.js.map +1 -0
- package/cjs/{RouteLoader-3aa6456e.js → RouteLoader-7f0d107a.js} +23 -37
- package/{esm/RouteLoader-5171c63f.js.map → cjs/RouteLoader-7f0d107a.js.map} +1 -1
- package/cjs/{ToJs-a9a8522b.js → ToJs-6e9cfa69.js} +3 -4
- package/cjs/{ToJs-a9a8522b.js.map → ToJs-6e9cfa69.js.map} +1 -1
- package/cjs/client.js +20 -27
- package/cjs/client.js.map +1 -1
- package/cjs/contensis-react-base.js +124 -188
- package/cjs/contensis-react-base.js.map +1 -1
- package/cjs/forms.js +1488 -272
- package/cjs/forms.js.map +1 -1
- package/cjs/{fromJSLeaveImmer-e74c673c.js → fromJSLeaveImmer-7c363211.js} +1 -4
- package/cjs/{fromJSLeaveImmer-e74c673c.js.map → fromJSLeaveImmer-7c363211.js.map} +1 -1
- package/cjs/{login-840860bc.js → login-2a6b5be0.js} +64 -113
- package/cjs/login-2a6b5be0.js.map +1 -0
- package/cjs/{reducers-3a4f8971.js → reducers-9afb5f89.js} +14 -31
- package/cjs/reducers-9afb5f89.js.map +1 -0
- package/cjs/redux.js +17 -17
- package/cjs/redux.js.map +1 -1
- package/cjs/routing.js +6 -7
- package/cjs/routing.js.map +1 -1
- package/cjs/{sagas-8a20e424.js → sagas-e04b94c1.js} +225 -301
- package/cjs/sagas-e04b94c1.js.map +1 -0
- package/cjs/search.js +68 -94
- package/cjs/search.js.map +1 -1
- package/cjs/{selectors-656da4b7.js → selectors-bcca60f4.js} +89 -8
- package/cjs/selectors-bcca60f4.js.map +1 -0
- package/cjs/urls-6fcaf4c6.js.map +1 -1
- package/cjs/user.js +4 -13
- package/cjs/user.js.map +1 -1
- package/cjs/util.js +45 -53
- package/cjs/util.js.map +1 -1
- package/cjs/{version-78dfc3bd.js → version-4077e706.js} +50 -159
- package/cjs/version-4077e706.js.map +1 -0
- package/cjs/version-fe28099e.js +98 -0
- package/cjs/version-fe28099e.js.map +1 -0
- package/esm/{App-640239d2.js → App-2af18a99.js} +102 -412
- package/esm/App-2af18a99.js.map +1 -0
- package/esm/ContensisDeliveryApi-5660ee0e.js +227 -0
- package/esm/ContensisDeliveryApi-5660ee0e.js.map +1 -0
- package/esm/{RouteLoader-5171c63f.js → RouteLoader-6eac364e.js} +22 -36
- package/{cjs/RouteLoader-3aa6456e.js.map → esm/RouteLoader-6eac364e.js.map} +1 -1
- package/esm/{ToJs-4e02a04d.js → ToJs-9b30636a.js} +3 -4
- package/esm/{ToJs-4e02a04d.js.map → ToJs-9b30636a.js.map} +1 -1
- package/esm/client.js +15 -22
- package/esm/client.js.map +1 -1
- package/esm/contensis-react-base.js +119 -183
- package/esm/contensis-react-base.js.map +1 -1
- package/esm/forms.js +1490 -274
- package/esm/forms.js.map +1 -1
- package/esm/{fromJSLeaveImmer-0114ffcf.js → fromJSLeaveImmer-e2dacd63.js} +1 -4
- package/esm/{fromJSLeaveImmer-0114ffcf.js.map → fromJSLeaveImmer-e2dacd63.js.map} +1 -1
- package/esm/{login-57395c9c.js → login-71ff3fcb.js} +63 -112
- package/esm/login-71ff3fcb.js.map +1 -0
- package/esm/{reducers-8e5d6232.js → reducers-3d5c37d1.js} +14 -31
- package/esm/reducers-3d5c37d1.js.map +1 -0
- package/esm/redux.js +9 -8
- package/esm/redux.js.map +1 -1
- package/esm/routing.js +3 -4
- package/esm/routing.js.map +1 -1
- package/esm/{sagas-e576b6f6.js → sagas-933a8fc8.js} +177 -254
- package/esm/sagas-933a8fc8.js.map +1 -0
- package/esm/search.js +69 -95
- package/esm/search.js.map +1 -1
- package/esm/{selectors-a5e5835b.js → selectors-74de49a3.js} +75 -8
- package/esm/selectors-74de49a3.js.map +1 -0
- package/esm/urls-eac9a747.js.map +1 -1
- package/esm/user.js +6 -15
- package/esm/user.js.map +1 -1
- package/esm/util.js +42 -53
- package/esm/util.js.map +1 -1
- package/esm/version-b15807c5.js +87 -0
- package/esm/version-b15807c5.js.map +1 -0
- package/esm/{version-e3a5ec66.js → version-ef107106.js} +37 -142
- package/esm/version-ef107106.js.map +1 -0
- package/models/redux/appstate.d.ts +1 -0
- package/models/routing/redux/selectors.d.ts +2 -1
- package/models/search/models/Queries.d.ts +2 -1
- package/models/search/models/Search.d.ts +2 -0
- package/models/search/models/SearchActions.d.ts +3 -3
- package/models/search/redux/actions.d.ts +6 -6
- package/models/search/redux/util.d.ts +1 -1
- package/models/search/search/expressions.d.ts +1 -1
- package/models/server/features/linkdepth-api/search.d.ts +1 -1
- package/models/util/ContensisDeliveryApi.d.ts +6 -0
- package/models/util/index.d.ts +1 -0
- package/package.json +1 -1
- package/cjs/App-ee485b92.js.map +0 -1
- package/cjs/actions-8dc9e8de.js +0 -87
- package/cjs/actions-8dc9e8de.js.map +0 -1
- package/cjs/login-840860bc.js.map +0 -1
- package/cjs/reducers-3a4f8971.js.map +0 -1
- package/cjs/sagas-8a20e424.js.map +0 -1
- package/cjs/selectors-656da4b7.js.map +0 -1
- package/cjs/version-78dfc3bd.js.map +0 -1
- package/cjs/version-eba6d09b.js +0 -20
- package/cjs/version-eba6d09b.js.map +0 -1
- package/esm/App-640239d2.js.map +0 -1
- package/esm/actions-180948dd.js +0 -72
- package/esm/actions-180948dd.js.map +0 -1
- package/esm/login-57395c9c.js.map +0 -1
- package/esm/reducers-8e5d6232.js.map +0 -1
- package/esm/sagas-e576b6f6.js.map +0 -1
- package/esm/selectors-a5e5835b.js.map +0 -1
- package/esm/version-2485e2fb.js +0 -15
- package/esm/version-2485e2fb.js.map +0 -1
- package/esm/version-e3a5ec66.js.map +0 -1
|
@@ -5,12 +5,10 @@ var immutable = require('immutable');
|
|
|
5
5
|
const fromJSOrdered = js => {
|
|
6
6
|
return typeof js !== 'object' || js === null ? js : Array.isArray(js) ? immutable.Seq(js).map(fromJSOrdered).toList() : immutable.Seq(js).map(fromJSOrdered).toOrderedMap();
|
|
7
7
|
};
|
|
8
|
-
|
|
9
8
|
var fromJSOrdered$1 = fromJSOrdered;
|
|
10
9
|
|
|
11
10
|
const fromJSLeaveImmer = js => {
|
|
12
11
|
const immutableObj = fromJSOrdered$1(js);
|
|
13
|
-
|
|
14
12
|
if (immutableObj && 'set' in immutableObj && typeof immutableObj.set === 'function') {
|
|
15
13
|
// convert the immer parts of the state back
|
|
16
14
|
// to plain JS while retuning an immutable state object
|
|
@@ -20,9 +18,8 @@ const fromJSLeaveImmer = js => {
|
|
|
20
18
|
});
|
|
21
19
|
return immutableState;
|
|
22
20
|
}
|
|
23
|
-
|
|
24
21
|
return immutableObj;
|
|
25
22
|
};
|
|
26
23
|
|
|
27
24
|
exports["default"] = fromJSLeaveImmer;
|
|
28
|
-
//# sourceMappingURL=fromJSLeaveImmer-
|
|
25
|
+
//# sourceMappingURL=fromJSLeaveImmer-7c363211.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fromJSLeaveImmer-
|
|
1
|
+
{"version":3,"file":"fromJSLeaveImmer-7c363211.js","sources":["../src/util/fromJSOrdered.js","../src/util/fromJSLeaveImmer.js"],"sourcesContent":["import { Seq } from 'immutable';\n\nconst fromJSOrdered = js => {\n return typeof js !== 'object' || js === null\n ? js\n : Array.isArray(js)\n ? Seq(js).map(fromJSOrdered).toList()\n : Seq(js).map(fromJSOrdered).toOrderedMap();\n};\n\nexport default fromJSOrdered;\n","import fromJSOrdered from './fromJSOrdered';\n\nconst fromJSLeaveImmer = js => {\n const immutableObj = fromJSOrdered(js);\n if (\n immutableObj &&\n 'set' in immutableObj &&\n typeof immutableObj.set === 'function'\n ) {\n // convert the immer parts of the state back\n // to plain JS while retuning an immutable state object\n let immutableState = immutableObj;\n [\n 'immer',\n 'form',\n 'forms',\n 'navigation',\n 'routing',\n 'search',\n 'user',\n 'version',\n ].map(key => {\n if (js[key] && immutableObj.get(key))\n immutableState = immutableState.set(key, js[key]);\n });\n return immutableState;\n }\n return immutableObj;\n};\nexport default fromJSLeaveImmer;\n"],"names":["fromJSOrdered","js","Array","isArray","Seq","map","toList","toOrderedMap","fromJSLeaveImmer","immutableObj","set","immutableState","key","get"],"mappings":";;;;AAEA,MAAMA,aAAa,GAAGC,EAAE,IAAI;AAC1B,EAAA,OAAO,OAAOA,EAAE,KAAK,QAAQ,IAAIA,EAAE,KAAK,IAAI,GACxCA,EAAE,GACFC,KAAK,CAACC,OAAO,CAACF,EAAE,CAAC,GACjBG,aAAG,CAACH,EAAE,CAAC,CAACI,GAAG,CAACL,aAAa,CAAC,CAACM,MAAM,EAAE,GACnCF,aAAG,CAACH,EAAE,CAAC,CAACI,GAAG,CAACL,aAAa,CAAC,CAACO,YAAY,EAAE,CAAA;AAC/C,CAAC,CAAA;AAED,sBAAeP,aAAa;;ACRtBQ,MAAAA,gBAAgB,GAAGP,EAAE,IAAI;AAC7B,EAAA,MAAMQ,YAAY,GAAGT,eAAa,CAACC,EAAE,CAAC,CAAA;AACtC,EAAA,IACEQ,YAAY,IACZ,KAAK,IAAIA,YAAY,IACrB,OAAOA,YAAY,CAACC,GAAG,KAAK,UAAU,EACtC;AACA;AACA;IACA,IAAIC,cAAc,GAAGF,YAAY,CAAA;IACjC,CACE,OAAO,EACP,MAAM,EACN,OAAO,EACP,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,MAAM,EACN,SAAS,CACV,CAACJ,GAAG,CAACO,GAAG,IAAI;MACX,IAAIX,EAAE,CAACW,GAAG,CAAC,IAAIH,YAAY,CAACI,GAAG,CAACD,GAAG,CAAC,EAClCD,cAAc,GAAGA,cAAc,CAACD,GAAG,CAACE,GAAG,EAAEX,EAAE,CAACW,GAAG,CAAC,CAAC,CAAA;AACrD,KAAC,CAAC,CAAA;AACF,IAAA,OAAOD,cAAc,CAAA;AACvB,GAAA;AACA,EAAA,OAAOF,YAAY,CAAA;AACrB;;;;"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var effects = require('@redux-saga/core/effects');
|
|
4
|
-
var reducers = require('./reducers-
|
|
5
|
-
var ToJs = require('./ToJs-
|
|
6
|
-
var
|
|
7
|
-
var selectors = require('./selectors-656da4b7.js');
|
|
4
|
+
var reducers = require('./reducers-9afb5f89.js');
|
|
5
|
+
var ToJs = require('./ToJs-6e9cfa69.js');
|
|
6
|
+
var selectors = require('./selectors-bcca60f4.js');
|
|
8
7
|
var mapJson = require('jsonpath-mapper');
|
|
9
8
|
var awaitToJs = require('await-to-js');
|
|
10
9
|
var JSCookie = require('js-cookie');
|
|
@@ -48,6 +47,7 @@ const clientCredentials = {
|
|
|
48
47
|
var mapClientCredentials = (obj => mapJson__default["default"](obj, clientCredentials));
|
|
49
48
|
|
|
50
49
|
// import { Client } from 'contensis-management-api';
|
|
50
|
+
|
|
51
51
|
const getManagementApiClient = async ({
|
|
52
52
|
bearerToken,
|
|
53
53
|
bearerTokenExpiryDate,
|
|
@@ -57,14 +57,10 @@ const getManagementApiClient = async ({
|
|
|
57
57
|
username,
|
|
58
58
|
password
|
|
59
59
|
}) => {
|
|
60
|
-
const rootUrl = SERVERS.api || SERVERS.cms;
|
|
61
|
-
/* global
|
|
62
|
-
|
|
63
|
-
const projectId = PROJECTS[0].id;
|
|
64
|
-
/* global PROJECTS */
|
|
60
|
+
const rootUrl = SERVERS.api || SERVERS.cms; /* global SERVERS */
|
|
61
|
+
const projectId = PROJECTS[0].id; /* global PROJECTS */
|
|
65
62
|
|
|
66
63
|
let config = {};
|
|
67
|
-
|
|
68
64
|
if (refreshToken) {
|
|
69
65
|
config = {
|
|
70
66
|
clientType: 'contensis_classic_refresh_token',
|
|
@@ -81,11 +77,11 @@ const getManagementApiClient = async ({
|
|
|
81
77
|
}
|
|
82
78
|
};
|
|
83
79
|
}
|
|
84
|
-
|
|
85
80
|
const {
|
|
86
81
|
Client
|
|
87
82
|
} = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('contensis-management-api')); });
|
|
88
|
-
const client = Client.create({
|
|
83
|
+
const client = Client.create({
|
|
84
|
+
...config,
|
|
89
85
|
projectId,
|
|
90
86
|
rootUrl
|
|
91
87
|
});
|
|
@@ -98,9 +94,9 @@ const getManagementApiClient = async ({
|
|
|
98
94
|
};
|
|
99
95
|
|
|
100
96
|
const COOKIE_VALID_DAYS = 1; // 0 = Session cookie
|
|
97
|
+
|
|
101
98
|
// Override the default js-cookie conversion / encoding
|
|
102
99
|
// methods so the written values work with Contensis sites
|
|
103
|
-
|
|
104
100
|
const Cookies = JSCookie__default["default"].withConverter({
|
|
105
101
|
read: value => decodeURIComponent(value),
|
|
106
102
|
write: value => encodeURIComponent(value)
|
|
@@ -108,32 +104,24 @@ const Cookies = JSCookie__default["default"].withConverter({
|
|
|
108
104
|
class CookieHelper {
|
|
109
105
|
static GetCookie(name) {
|
|
110
106
|
const cookie = Cookies.get(name);
|
|
111
|
-
|
|
112
107
|
if (typeof cookie === 'undefined') {
|
|
113
108
|
return null;
|
|
114
109
|
}
|
|
115
|
-
|
|
116
110
|
return cookie;
|
|
117
111
|
}
|
|
118
|
-
|
|
119
112
|
static SetCookie(name, value, maxAgeDays = COOKIE_VALID_DAYS) {
|
|
120
113
|
if (maxAgeDays === 0) Cookies.set(name, value);else Cookies.set(name, value, {
|
|
121
114
|
expires: maxAgeDays
|
|
122
115
|
});
|
|
123
116
|
}
|
|
124
|
-
|
|
125
117
|
static DeleteCookie(name) {
|
|
126
118
|
Cookies.remove(name);
|
|
127
119
|
}
|
|
128
|
-
|
|
129
120
|
}
|
|
130
121
|
|
|
131
122
|
const context$1 = typeof window != 'undefined' ? window : global;
|
|
132
|
-
const requireOidc = process.env.NODE_ENV === 'development' ? WSFED_LOGIN === 'true'
|
|
133
|
-
/* global
|
|
134
|
-
: context$1.WSFED_LOGIN === 'true';
|
|
135
|
-
const servers = SERVERS;
|
|
136
|
-
/* global SERVERS */
|
|
123
|
+
const requireOidc = process.env.NODE_ENV === 'development' ? WSFED_LOGIN === 'true' /* global WSFED_LOGIN */ : context$1.WSFED_LOGIN === 'true';
|
|
124
|
+
const servers = SERVERS; /* global SERVERS */
|
|
137
125
|
|
|
138
126
|
const userManagerConfig = typeof window !== 'undefined' ? {
|
|
139
127
|
authority: `${servers.cms}/authenticate/`,
|
|
@@ -149,9 +137,7 @@ const createUserManager = async config => {
|
|
|
149
137
|
try {
|
|
150
138
|
const {
|
|
151
139
|
UserManager
|
|
152
|
-
} = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
|
|
153
|
-
/* webpackChunkName: "oidcclient" */
|
|
154
|
-
'oidc-client')); });
|
|
140
|
+
} = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require( /* webpackChunkName: "oidcclient" */'oidc-client')); });
|
|
155
141
|
return new UserManager(config);
|
|
156
142
|
} catch (e) {
|
|
157
143
|
console.error('Exception in createUserManager: ', e);
|
|
@@ -172,7 +158,6 @@ class LoginHelper {
|
|
|
172
158
|
if (contensisClassicToken) CookieHelper.SetCookie(LOGIN_COOKIE, contensisClassicToken);
|
|
173
159
|
if (refreshToken) CookieHelper.SetCookie(REFRESH_TOKEN_COOKIE, refreshToken);
|
|
174
160
|
}
|
|
175
|
-
|
|
176
161
|
static GetCachedCredentials() {
|
|
177
162
|
return {
|
|
178
163
|
bearerToken: null,
|
|
@@ -182,27 +167,22 @@ class LoginHelper {
|
|
|
182
167
|
contensisClassicToken: CookieHelper.GetCookie(LOGIN_COOKIE)
|
|
183
168
|
};
|
|
184
169
|
}
|
|
185
|
-
|
|
186
170
|
static ClearCachedCredentials() {
|
|
187
171
|
CookieHelper.DeleteCookie(LOGIN_COOKIE);
|
|
188
172
|
CookieHelper.DeleteCookie(REFRESH_TOKEN_COOKIE);
|
|
189
|
-
|
|
190
173
|
if (LoginHelper.WSFED_LOGIN && typeof window !== 'undefined') {
|
|
191
174
|
// remove any oidc keys left over in localStorage
|
|
192
175
|
const {
|
|
193
176
|
localStorage
|
|
194
177
|
} = window;
|
|
195
178
|
const keys = [];
|
|
196
|
-
|
|
197
179
|
for (let i = 0; i < localStorage.length; i++) {
|
|
198
180
|
const key = localStorage.key(i);
|
|
199
181
|
if (typeof key === 'string' && key.startsWith('oidc.')) keys.push(localStorage.key(i));
|
|
200
182
|
}
|
|
201
|
-
|
|
202
183
|
keys.forEach(key => localStorage.removeItem(key));
|
|
203
184
|
}
|
|
204
185
|
}
|
|
205
|
-
|
|
206
186
|
static async LoginUser({
|
|
207
187
|
username,
|
|
208
188
|
password,
|
|
@@ -217,16 +197,17 @@ class LoginHelper {
|
|
|
217
197
|
};
|
|
218
198
|
let transientClient;
|
|
219
199
|
let user;
|
|
220
|
-
|
|
221
200
|
if (username && password) {
|
|
222
201
|
// Get a management client with username and password
|
|
223
202
|
transientClient = await getManagementApiClient({
|
|
224
203
|
username,
|
|
225
204
|
password
|
|
226
|
-
});
|
|
205
|
+
});
|
|
227
206
|
|
|
228
|
-
|
|
207
|
+
// Ensure the client has requested a bearer token
|
|
208
|
+
const [loginError, clientBearerToken] = await awaitToJs.to(transientClient.ensureBearerToken());
|
|
229
209
|
|
|
210
|
+
// Problem getting token with username and password
|
|
230
211
|
if (loginError) {
|
|
231
212
|
authenticationState = {
|
|
232
213
|
clientCredentials: null,
|
|
@@ -236,9 +217,9 @@ class LoginHelper {
|
|
|
236
217
|
isError: true
|
|
237
218
|
};
|
|
238
219
|
LoginHelper.ClearCachedCredentials();
|
|
239
|
-
}
|
|
240
|
-
|
|
220
|
+
}
|
|
241
221
|
|
|
222
|
+
// Got a token using username and password
|
|
242
223
|
if (clientBearerToken) {
|
|
243
224
|
// Set credentials so we can continue to GetUserDetails
|
|
244
225
|
credentials = mapClientCredentials(transientClient);
|
|
@@ -250,15 +231,14 @@ class LoginHelper {
|
|
|
250
231
|
isError: false
|
|
251
232
|
};
|
|
252
233
|
}
|
|
253
|
-
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// If we have credentials supplied by a successful username and password login
|
|
254
237
|
// or clientCredentials supplied in the options argument we can continue to
|
|
255
238
|
// fetch the user's details
|
|
256
|
-
|
|
257
|
-
|
|
258
239
|
if (credentials) {
|
|
259
240
|
const client = transientClient || (await getManagementApiClient(credentials));
|
|
260
241
|
const [error, userDetails] = await LoginHelper.GetUserDetails(client);
|
|
261
|
-
|
|
262
242
|
if (error) {
|
|
263
243
|
authenticationState = {
|
|
264
244
|
clientCredentials: null,
|
|
@@ -281,27 +261,22 @@ class LoginHelper {
|
|
|
281
261
|
};
|
|
282
262
|
}
|
|
283
263
|
}
|
|
284
|
-
|
|
285
264
|
return {
|
|
286
265
|
authenticationState,
|
|
287
266
|
user
|
|
288
267
|
};
|
|
289
268
|
}
|
|
290
|
-
|
|
291
269
|
static LogoutUser(redirectPath) {
|
|
292
270
|
LoginHelper.ClearCachedCredentials();
|
|
293
|
-
|
|
294
271
|
if (LoginHelper.WSFED_LOGIN) {
|
|
295
272
|
LoginHelper.WsFedLogout(redirectPath);
|
|
296
273
|
} else {
|
|
297
274
|
if (redirectPath) LoginHelper.ClientRedirectToPath(redirectPath);else LoginHelper.ClientRedirectToSignInPage();
|
|
298
275
|
}
|
|
299
276
|
}
|
|
300
|
-
|
|
301
277
|
static ClientRedirectToHome(location) {
|
|
302
278
|
if (typeof window != 'undefined') {
|
|
303
279
|
let url = '/';
|
|
304
|
-
|
|
305
280
|
if (location) {
|
|
306
281
|
const {
|
|
307
282
|
search,
|
|
@@ -310,11 +285,9 @@ class LoginHelper {
|
|
|
310
285
|
url = search ? `${url}${search}` : url;
|
|
311
286
|
url = hash ? `${url}${hash}` : url;
|
|
312
287
|
}
|
|
313
|
-
|
|
314
288
|
window.location.href = url;
|
|
315
289
|
}
|
|
316
290
|
}
|
|
317
|
-
|
|
318
291
|
static async ClientRedirectToSignInPage(redirectPath) {
|
|
319
292
|
if (LoginHelper.WSFED_LOGIN) {
|
|
320
293
|
await LoginHelper.WsFedLogout();
|
|
@@ -326,20 +299,17 @@ class LoginHelper {
|
|
|
326
299
|
if (typeof location !== 'undefined' && redirectPath !== LoginHelper.LOGIN_ROUTE) location.replace(url);
|
|
327
300
|
}
|
|
328
301
|
}
|
|
329
|
-
|
|
330
302
|
static ClientRedirectToAccessDeniedPage(originalPath) {
|
|
331
303
|
let url = LoginHelper.ACCESS_DENIED_ROUTE;
|
|
332
304
|
if (originalPath === url) return;
|
|
333
305
|
if (typeof originalPath === 'string') url = `${url}?original_uri=${originalPath}`;
|
|
334
306
|
if (typeof location !== 'undefined') location.href = url;
|
|
335
307
|
}
|
|
336
|
-
|
|
337
308
|
static ClientRedirectToPath(redirectPath) {
|
|
338
309
|
if (typeof redirectPath === 'string') {
|
|
339
310
|
if (typeof location !== 'undefined') window.location.href = redirectPath;
|
|
340
311
|
} else LoginHelper.ClientRedirectToHome();
|
|
341
312
|
}
|
|
342
|
-
|
|
343
313
|
static async WsFedLogin(redirectUri) {
|
|
344
314
|
const userManager = await createUserManager(userManagerConfig);
|
|
345
315
|
userManager.signinRedirect({
|
|
@@ -348,22 +318,18 @@ class LoginHelper {
|
|
|
348
318
|
redirect_uri: redirectUri || window.location.toString()
|
|
349
319
|
});
|
|
350
320
|
}
|
|
351
|
-
|
|
352
321
|
static RemoveSecurityTokenQuery() {
|
|
353
322
|
const params = new URLSearchParams(window.location.search);
|
|
354
|
-
|
|
355
323
|
if (params.has('securitytoken') || params.has('securityToken')) {
|
|
356
324
|
params.delete('securitytoken');
|
|
357
325
|
params.delete('securityToken');
|
|
358
326
|
window.location = `${window.location.pathname}${params.toString() ? `?${params}` : ''}`;
|
|
359
327
|
}
|
|
360
328
|
}
|
|
361
|
-
|
|
362
329
|
static async WsFedLogout(redirectPath) {
|
|
363
330
|
await fetch(`${LoginHelper.CMS_URL}/authenticate/logout?jsonResponseRequired=true`, {
|
|
364
331
|
credentials: 'include'
|
|
365
332
|
});
|
|
366
|
-
|
|
367
333
|
if (redirectPath) {
|
|
368
334
|
window.location = redirectPath;
|
|
369
335
|
} else {
|
|
@@ -372,7 +338,6 @@ class LoginHelper {
|
|
|
372
338
|
LoginHelper.RemoveSecurityTokenQuery();
|
|
373
339
|
}
|
|
374
340
|
}
|
|
375
|
-
|
|
376
341
|
static async GetCredentialsForSecurityToken(securityToken) {
|
|
377
342
|
const [error, response] = await awaitToJs.to(fetch(`${LoginHelper.CMS_URL}/REST/Contensis/Security/IsAuthenticated`, {
|
|
378
343
|
method: 'POST',
|
|
@@ -387,7 +352,6 @@ class LoginHelper {
|
|
|
387
352
|
if (error) return [{
|
|
388
353
|
message: 'Failed to fetch credentials'
|
|
389
354
|
}];
|
|
390
|
-
|
|
391
355
|
if (response.ok) {
|
|
392
356
|
const [parseError, body] = await awaitToJs.to(response.json());
|
|
393
357
|
if (parseError) return [parseError];
|
|
@@ -395,26 +359,22 @@ class LoginHelper {
|
|
|
395
359
|
LogonResult,
|
|
396
360
|
ApplicationData = []
|
|
397
361
|
} = body;
|
|
398
|
-
|
|
399
362
|
if (LogonResult !== 0) {
|
|
400
363
|
return [{
|
|
401
364
|
message: 'Security token is invalid',
|
|
402
365
|
data: ApplicationData
|
|
403
366
|
}];
|
|
404
367
|
}
|
|
405
|
-
|
|
406
368
|
if (ApplicationData.length > 0) {
|
|
407
369
|
let refreshToken;
|
|
408
370
|
ApplicationData.forEach(item => {
|
|
409
371
|
if (item.Key === 'ContensisSecurityRefreshToken') refreshToken = item.Value;
|
|
410
372
|
});
|
|
411
|
-
|
|
412
373
|
if (!refreshToken) {
|
|
413
374
|
return [{
|
|
414
375
|
message: 'Fetch credentials: Unable to find ContensisSecurityRefreshToken'
|
|
415
376
|
}];
|
|
416
377
|
}
|
|
417
|
-
|
|
418
378
|
return [undefined, refreshToken];
|
|
419
379
|
} else {
|
|
420
380
|
return [{
|
|
@@ -426,53 +386,50 @@ class LoginHelper {
|
|
|
426
386
|
message: `Fetch credentials error: ${response.status} ${response.statusText}`
|
|
427
387
|
}];
|
|
428
388
|
}
|
|
429
|
-
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// static isZengentiStaff(email) {
|
|
430
392
|
// const emailRefs = ['@zengenti', '@contensis'];
|
|
393
|
+
|
|
431
394
|
// return emailRefs.some(emailRef => {
|
|
432
395
|
// if (email.includes(emailRef)) {
|
|
433
396
|
// return true;
|
|
434
397
|
// }
|
|
435
398
|
// });
|
|
436
399
|
// }
|
|
437
|
-
|
|
438
|
-
|
|
439
400
|
}
|
|
440
|
-
LoginHelper.CMS_URL = SERVERS.cms
|
|
441
|
-
/* global
|
|
442
|
-
;
|
|
443
|
-
LoginHelper.WSFED_LOGIN = process.env.NODE_ENV === 'development' ? WSFED_LOGIN === 'true'
|
|
444
|
-
/* global WSFED_LOGIN */
|
|
445
|
-
: context.WSFED_LOGIN === 'true';
|
|
401
|
+
LoginHelper.CMS_URL = SERVERS.cms /* global SERVERS */;
|
|
402
|
+
LoginHelper.WSFED_LOGIN = process.env.NODE_ENV === 'development' ? WSFED_LOGIN === 'true' /* global WSFED_LOGIN */ : context.WSFED_LOGIN === 'true';
|
|
446
403
|
LoginHelper.LOGIN_ROUTE = '/account/login';
|
|
447
404
|
LoginHelper.ACCESS_DENIED_ROUTE = '/account/access-denied';
|
|
448
|
-
|
|
449
405
|
LoginHelper.GetUserDetails = async client => {
|
|
450
406
|
let userError,
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
407
|
+
groupsError,
|
|
408
|
+
user = {},
|
|
409
|
+
groupsResult;
|
|
454
410
|
[userError, user] = await awaitToJs.to(client.security.users.getCurrent());
|
|
455
|
-
|
|
456
411
|
if (user && user.id) {
|
|
457
412
|
[groupsError, groupsResult] = await awaitToJs.to(client.security.users.getUserGroups({
|
|
458
413
|
userId: user.id,
|
|
459
|
-
includeInherited: true
|
|
460
|
-
|
|
414
|
+
includeInherited: true,
|
|
415
|
+
pageOptions: {
|
|
416
|
+
pageSize: 100
|
|
417
|
+
}
|
|
418
|
+
}));
|
|
419
|
+
// Set groups attribute in user object to be the items
|
|
461
420
|
// array from the getUserGroups result
|
|
421
|
+
if (groupsResult && groupsResult.items) user.groups = groupsResult.items;
|
|
462
422
|
|
|
463
|
-
|
|
423
|
+
//If groups call fails then log the error but allow the user to login still
|
|
464
424
|
// eslint-disable-next-line no-console
|
|
465
|
-
|
|
466
425
|
if (groupsError) console.log(groupsError);
|
|
467
426
|
}
|
|
468
|
-
|
|
469
427
|
return [userError, user];
|
|
470
428
|
};
|
|
471
429
|
|
|
472
430
|
const loginSagas = [effects.takeEvery(reducers.LOGIN_USER, loginUserSaga), effects.takeEvery(reducers.LOGOUT_USER, logoutUserSaga), effects.takeEvery(reducers.VALIDATE_USER, validateUserSaga), effects.takeEvery(reducers.SET_AUTHENTICATION_STATE, redirectAfterSuccessfulLoginSaga)];
|
|
473
431
|
function* handleRequiresLoginSaga(action) {
|
|
474
432
|
var _entry$sys;
|
|
475
|
-
|
|
476
433
|
const {
|
|
477
434
|
entry,
|
|
478
435
|
requireLogin,
|
|
@@ -481,22 +438,24 @@ function* handleRequiresLoginSaga(action) {
|
|
|
481
438
|
},
|
|
482
439
|
staticRoute
|
|
483
440
|
} = action;
|
|
484
|
-
let userLoggedIn = yield effects.select(ToJs.selectUserIsAuthenticated);
|
|
441
|
+
let userLoggedIn = yield effects.select(ToJs.selectUserIsAuthenticated);
|
|
485
442
|
|
|
443
|
+
// Check for a securityToken in querystring
|
|
486
444
|
const currentQs = selectors.queryParams(yield effects.select(selectors.selectCurrentSearch));
|
|
487
|
-
const securityToken = currentQs.securityToken || currentQs.securitytoken;
|
|
445
|
+
const securityToken = currentQs.securityToken || currentQs.securitytoken;
|
|
488
446
|
|
|
447
|
+
// Check if any of the defined routes have "requireLogin" attribute
|
|
489
448
|
const {
|
|
490
449
|
requireLogin: authRoute
|
|
491
450
|
} = staticRoute && staticRoute.route || {};
|
|
492
451
|
const {
|
|
493
452
|
requireLogin: authContentType
|
|
494
|
-
} = entry && findContentTypeMapping(ContentTypeMappings, entry === null || entry === void 0 ? void 0 : (_entry$sys = entry.sys) === null || _entry$sys === void 0 ? void 0 : _entry$sys.contentTypeId) || {};
|
|
495
|
-
// array of groups we can merge all the arrays and match on any group supplied
|
|
453
|
+
} = entry && findContentTypeMapping(ContentTypeMappings, entry === null || entry === void 0 ? void 0 : (_entry$sys = entry.sys) === null || _entry$sys === void 0 ? void 0 : _entry$sys.contentTypeId) || {};
|
|
496
454
|
|
|
455
|
+
// If requireLogin, authRoute or authContentType has been specified as an
|
|
456
|
+
// array of groups we can merge all the arrays and match on any group supplied
|
|
497
457
|
const routeRequiresGroups = [...(Array.isArray(authContentType) && authContentType || []), ...(Array.isArray(authRoute) && authRoute || []), ...(Array.isArray(requireLogin) && requireLogin || [])];
|
|
498
458
|
const routeRequiresLogin = !!authContentType || !!authRoute || !!requireLogin;
|
|
499
|
-
|
|
500
459
|
if (!userLoggedIn) {
|
|
501
460
|
// If cookies or securityToken are found on any route change
|
|
502
461
|
// always validate and login the user
|
|
@@ -505,13 +464,13 @@ function* handleRequiresLoginSaga(action) {
|
|
|
505
464
|
userLoggedIn = yield effects.call(validateUserSaga, {
|
|
506
465
|
securityToken
|
|
507
466
|
});
|
|
508
|
-
}
|
|
467
|
+
}
|
|
468
|
+
// otherwise do a non blocking put to handle validation in the background
|
|
509
469
|
else yield effects.put({
|
|
510
470
|
type: reducers.VALIDATE_USER,
|
|
511
471
|
securityToken
|
|
512
472
|
});
|
|
513
473
|
}
|
|
514
|
-
|
|
515
474
|
if (routeRequiresLogin) {
|
|
516
475
|
// If a security token is in the querystring and we are not already
|
|
517
476
|
// logged in something is wrong and we won't bother going on another redirect loop
|
|
@@ -524,13 +483,11 @@ function* handleRequiresLoginSaga(action) {
|
|
|
524
483
|
}
|
|
525
484
|
}
|
|
526
485
|
}
|
|
527
|
-
|
|
528
486
|
function* validateUserSaga({
|
|
529
487
|
securityToken
|
|
530
488
|
}) {
|
|
531
489
|
// Check for refreshToken in cookies
|
|
532
490
|
let clientCredentials = LoginHelper.GetCachedCredentials();
|
|
533
|
-
|
|
534
491
|
if (securityToken || clientCredentials.refreshToken) {
|
|
535
492
|
// We only attempt to validate the user if one of the stored
|
|
536
493
|
// tokens are found, in this case we set loading state manually
|
|
@@ -540,11 +497,10 @@ function* validateUserSaga({
|
|
|
540
497
|
authenticationState: {
|
|
541
498
|
isLoading: true
|
|
542
499
|
}
|
|
543
|
-
});
|
|
500
|
+
});
|
|
501
|
+
// If we have just a security token we will call a CMS endpoint
|
|
544
502
|
// and provide us with a RefreshToken cookie we can use during login
|
|
545
|
-
|
|
546
503
|
const [error, refreshToken] = yield LoginHelper.GetCredentialsForSecurityToken(securityToken);
|
|
547
|
-
|
|
548
504
|
if (refreshToken) {
|
|
549
505
|
// Set cookies and reload values
|
|
550
506
|
LoginHelper.SetLoginCookies({
|
|
@@ -552,9 +508,9 @@ function* validateUserSaga({
|
|
|
552
508
|
refreshToken
|
|
553
509
|
});
|
|
554
510
|
clientCredentials = LoginHelper.GetCachedCredentials();
|
|
555
|
-
}
|
|
556
|
-
|
|
511
|
+
}
|
|
557
512
|
|
|
513
|
+
// Log the user in if a refreshToken is found
|
|
558
514
|
if (clientCredentials.refreshToken) yield effects.call(loginUserSaga, {
|
|
559
515
|
clientCredentials
|
|
560
516
|
});else if (error) yield effects.put({
|
|
@@ -564,20 +520,20 @@ function* validateUserSaga({
|
|
|
564
520
|
errorMessage: (error === null || error === void 0 ? void 0 : error.message) || error && 'toString' in error && error.toString()
|
|
565
521
|
}
|
|
566
522
|
});
|
|
567
|
-
}
|
|
568
|
-
|
|
523
|
+
}
|
|
569
524
|
|
|
525
|
+
// Tell any callers have we successfully logged in?
|
|
570
526
|
return yield effects.select(ToJs.selectUserIsAuthenticated);
|
|
571
527
|
}
|
|
572
|
-
|
|
573
528
|
function* loginUserSaga(action = {}) {
|
|
574
529
|
const {
|
|
575
530
|
username,
|
|
576
531
|
password,
|
|
577
532
|
clientCredentials
|
|
578
|
-
} = action;
|
|
579
|
-
// just redirect them to the Identity Provider sign in
|
|
533
|
+
} = action;
|
|
580
534
|
|
|
535
|
+
// If a WSFED_LOGIN site has dispatched the loginUser action
|
|
536
|
+
// just redirect them to the Identity Provider sign in
|
|
581
537
|
if (action.type === reducers.LOGIN_USER && LoginHelper.WSFED_LOGIN) LoginHelper.ClientRedirectToSignInPage();
|
|
582
538
|
const {
|
|
583
539
|
authenticationState,
|
|
@@ -593,33 +549,30 @@ function* loginUserSaga(action = {}) {
|
|
|
593
549
|
user
|
|
594
550
|
});
|
|
595
551
|
}
|
|
596
|
-
|
|
597
552
|
const removeHostnamePart = path => {
|
|
598
553
|
// eslint-disable-next-line no-console
|
|
599
554
|
console.log(path);
|
|
600
|
-
const relativePath = '/' + path.split('/').splice(3).join('/');
|
|
601
|
-
|
|
555
|
+
const relativePath = '/' + path.split('/').splice(3).join('/');
|
|
556
|
+
// eslint-disable-next-line no-console
|
|
602
557
|
console.log(relativePath);
|
|
603
558
|
return relativePath;
|
|
604
559
|
};
|
|
605
|
-
|
|
606
560
|
function* redirectAfterSuccessfulLoginSaga() {
|
|
607
561
|
const isLoggedIn = yield effects.select(ToJs.selectUserIsAuthenticated);
|
|
608
562
|
const {
|
|
609
563
|
redirect_uri: redirectPath,
|
|
610
564
|
ReturnURL: assetRedirectPath
|
|
611
565
|
} = selectors.queryParams(yield effects.select(selectors.selectCurrentSearch));
|
|
612
|
-
|
|
613
566
|
if (isLoggedIn && assetRedirectPath && typeof window != 'undefined') {
|
|
614
|
-
const path = removeHostnamePart(assetRedirectPath);
|
|
567
|
+
const path = removeHostnamePart(assetRedirectPath);
|
|
568
|
+
// This has to be a hard href to get the app to
|
|
615
569
|
// leave React and hit the server for the IIS hosted assets
|
|
616
|
-
|
|
617
|
-
|
|
570
|
+
window.location.href = path;
|
|
571
|
+
// yield put(setRoute(path)); // does not work in this scenario
|
|
618
572
|
} else if (isLoggedIn && redirectPath) {
|
|
619
|
-
yield effects.put(
|
|
573
|
+
yield effects.put(selectors.setRoute(redirectPath));
|
|
620
574
|
}
|
|
621
575
|
}
|
|
622
|
-
|
|
623
576
|
function* logoutUserSaga({
|
|
624
577
|
redirectPath
|
|
625
578
|
}) {
|
|
@@ -629,10 +582,8 @@ function* logoutUserSaga({
|
|
|
629
582
|
});
|
|
630
583
|
yield LoginHelper.LogoutUser(redirectPath);
|
|
631
584
|
}
|
|
632
|
-
|
|
633
585
|
function* refreshSecurityToken() {
|
|
634
586
|
const clientCredentials = yield effects.select(ToJs.selectClientCredentials, 'js');
|
|
635
|
-
|
|
636
587
|
if (Object.keys(clientCredentials).length > 0) {
|
|
637
588
|
const client = yield getManagementApiClient(clientCredentials);
|
|
638
589
|
yield client.authenticate();
|
|
@@ -651,4 +602,4 @@ exports.getManagementApiClient = getManagementApiClient;
|
|
|
651
602
|
exports.handleRequiresLoginSaga = handleRequiresLoginSaga;
|
|
652
603
|
exports.loginSagas = loginSagas;
|
|
653
604
|
exports.refreshSecurityToken = refreshSecurityToken;
|
|
654
|
-
//# sourceMappingURL=login-
|
|
605
|
+
//# sourceMappingURL=login-2a6b5be0.js.map
|