@beinformed/ui 1.63.11 → 1.63.13
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/CHANGELOG.md +14 -0
- package/esm/hooks/__tests__/useAuthentication.spec.js.flow +46 -3
- package/esm/hooks/useAuthentication.js +10 -6
- package/esm/hooks/useAuthentication.js.flow +16 -10
- package/esm/hooks/useAuthentication.js.map +1 -1
- package/esm/models/application/ApplicationModel.js +15 -2
- package/esm/models/application/ApplicationModel.js.flow +17 -0
- package/esm/models/application/ApplicationModel.js.map +1 -1
- package/esm/models/attributes/input-constraints/PasswordThreeConsecutiveCharactersNotAllowedConstraint.js.flow +1 -3
- package/esm/models/attributes/input-constraints/PasswordThreeConsecutiveCharactersNotAllowedConstraint.js.map +1 -1
- package/esm/utils/helpers/createHash.js +1 -1
- package/esm/utils/helpers/createHash.js.flow +1 -1
- package/esm/utils/helpers/createHash.js.map +1 -1
- package/esm/utils/helpers/createUUID.js.flow +1 -1
- package/esm/utils/helpers/createUUID.js.map +1 -1
- package/lib/hooks/useAuthentication.js +9 -5
- package/lib/hooks/useAuthentication.js.map +1 -1
- package/lib/models/application/ApplicationModel.js +15 -2
- package/lib/models/application/ApplicationModel.js.map +1 -1
- package/lib/models/attributes/input-constraints/PasswordThreeConsecutiveCharactersNotAllowedConstraint.js.map +1 -1
- package/lib/utils/helpers/createHash.js +4 -5
- package/lib/utils/helpers/createHash.js.map +1 -1
- package/lib/utils/helpers/createUUID.js.map +1 -1
- package/package.json +9 -8
- package/src/hooks/__tests__/useAuthentication.spec.js +46 -3
- package/src/hooks/useAuthentication.js +16 -10
- package/src/models/application/ApplicationModel.js +17 -0
- package/src/models/attributes/input-constraints/PasswordThreeConsecutiveCharactersNotAllowedConstraint.js +1 -3
- package/src/utils/helpers/createHash.js +1 -1
- package/src/utils/helpers/createUUID.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.63.13](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.63.12...v1.63.13) (2025-12-09)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **authentication:** cache `primaryAuthenticationType` for use in session ([158e7e8](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/158e7e8b810ad257653ae23489cfded365e6784c))
|
|
11
|
+
|
|
12
|
+
## [1.63.12](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.63.11...v1.63.12) (2025-12-08)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* **authentication:** update `useApplication` usage ([4e210b5](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/4e210b564386f3b261175e0a0ffbfec62b6d7f0b))
|
|
18
|
+
|
|
5
19
|
## [1.63.11](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.63.9...v1.63.11) (2025-11-27)
|
|
6
20
|
|
|
7
21
|
|
|
@@ -6,16 +6,27 @@ import xhrMock from "xhr-mock";
|
|
|
6
6
|
|
|
7
7
|
import { useLogin, useLogout } from "../useAuthentication";
|
|
8
8
|
import Href from "../../models/href/Href";
|
|
9
|
+
import { useLocation } from "react-router";
|
|
9
10
|
|
|
10
11
|
const middlewares = [thunk];
|
|
11
12
|
const mockStore = configureMockStore(middlewares);
|
|
12
13
|
|
|
14
|
+
jest.mock("react-router", () => ({
|
|
15
|
+
...jest.requireActual("react-router"), // Keep other methods from react-router as is
|
|
16
|
+
useLocation: jest.fn(), // Mock useLocation
|
|
17
|
+
}));
|
|
18
|
+
|
|
13
19
|
const JSON_TYPE = "application/json";
|
|
14
20
|
|
|
15
21
|
describe("authentication hooks", () => {
|
|
16
22
|
// replace the real XHR object with the mock XHR object before each test
|
|
17
23
|
// eslint-disable-next-line jest/no-hooks
|
|
18
|
-
beforeEach(() =>
|
|
24
|
+
beforeEach(() => {
|
|
25
|
+
useLocation.mockReturnValue({
|
|
26
|
+
state: null,
|
|
27
|
+
});
|
|
28
|
+
xhrMock.setup();
|
|
29
|
+
});
|
|
19
30
|
|
|
20
31
|
// put the real XHR object back and clear the mocks after each test
|
|
21
32
|
// eslint-disable-next-line jest/no-hooks
|
|
@@ -25,6 +36,11 @@ describe("authentication hooks", () => {
|
|
|
25
36
|
expect.assertions(10);
|
|
26
37
|
|
|
27
38
|
xhrMock
|
|
39
|
+
.get(`/BeInformed`, (req, res) => {
|
|
40
|
+
expect(req.header("accept")).toBe(JSON_TYPE);
|
|
41
|
+
expect(req.header("Content-Type")).toBe(JSON_TYPE);
|
|
42
|
+
return res.status(200).body({ data: "ok" });
|
|
43
|
+
})
|
|
28
44
|
.get("/BeInformed/login", (req, res) => {
|
|
29
45
|
expect(req.header("accept")).toBe(JSON_TYPE);
|
|
30
46
|
expect(req.header("Content-Type")).toBe(
|
|
@@ -42,7 +58,13 @@ describe("authentication hooks", () => {
|
|
|
42
58
|
return res.status(200).body({ data: "ok" });
|
|
43
59
|
});
|
|
44
60
|
|
|
45
|
-
const store = mockStore({
|
|
61
|
+
const store = mockStore({
|
|
62
|
+
auth: {},
|
|
63
|
+
modularui: {},
|
|
64
|
+
router: { location: {} },
|
|
65
|
+
i18n: { locale: "en" },
|
|
66
|
+
});
|
|
67
|
+
|
|
46
68
|
/**
|
|
47
69
|
*/
|
|
48
70
|
const wrapper = ({ children }) => (
|
|
@@ -61,6 +83,14 @@ describe("authentication hooks", () => {
|
|
|
61
83
|
|
|
62
84
|
expect(store.getActions()).toStrictEqual([
|
|
63
85
|
{ type: "START_PROGRESS" },
|
|
86
|
+
expect.objectContaining({
|
|
87
|
+
type: "MODULARUI/FETCH",
|
|
88
|
+
payload: expect.objectContaining({
|
|
89
|
+
key: "application(/)(en)",
|
|
90
|
+
}),
|
|
91
|
+
}),
|
|
92
|
+
{ type: "START_PROGRESS" },
|
|
93
|
+
{ type: "FINISH_PROGRESS" },
|
|
64
94
|
{ type: "START_PROGRESS" },
|
|
65
95
|
expect.objectContaining({
|
|
66
96
|
type: "MODULARUI/FETCH",
|
|
@@ -85,7 +115,12 @@ describe("authentication hooks", () => {
|
|
|
85
115
|
return res.status(200).body({ data: "ok" });
|
|
86
116
|
});
|
|
87
117
|
|
|
88
|
-
const store = mockStore({
|
|
118
|
+
const store = mockStore({
|
|
119
|
+
auth: {},
|
|
120
|
+
modularui: {},
|
|
121
|
+
router: { location: {} },
|
|
122
|
+
i18n: { locale: "en" },
|
|
123
|
+
});
|
|
89
124
|
|
|
90
125
|
/**
|
|
91
126
|
*/
|
|
@@ -105,6 +140,14 @@ describe("authentication hooks", () => {
|
|
|
105
140
|
|
|
106
141
|
expect(store.getActions()).toStrictEqual([
|
|
107
142
|
{ type: "START_PROGRESS" },
|
|
143
|
+
expect.objectContaining({
|
|
144
|
+
type: "MODULARUI/FETCH",
|
|
145
|
+
payload: expect.objectContaining({
|
|
146
|
+
key: "application(/)(en)",
|
|
147
|
+
}),
|
|
148
|
+
}),
|
|
149
|
+
{ type: "START_PROGRESS" },
|
|
150
|
+
{ type: "FINISH_PROGRESS" },
|
|
108
151
|
{ type: "MODULARUI/RESET" },
|
|
109
152
|
{ type: "START_PROGRESS" },
|
|
110
153
|
expect.objectContaining({
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import { useSelector, useDispatch } from "react-redux";
|
|
2
|
-
import { getApplication } from "../redux/_modularui/ModularUISelectors";
|
|
3
2
|
import { login, logout, resetAuthErrors } from "../redux/actions";
|
|
4
3
|
import Cache from "../utils/browser/Cache";
|
|
5
|
-
import {
|
|
4
|
+
import { getBasePath, getBasePathServer, INTERNAL_LOGIN_TYPE } from "../constants";
|
|
6
5
|
import { IllegalStateException } from "../exceptions";
|
|
7
6
|
import { Authenticate } from "../modularui";
|
|
7
|
+
import { useApplication } from "./useModularUIModel";
|
|
8
8
|
/**
|
|
9
9
|
*/
|
|
10
10
|
export const useLogin = () => {
|
|
11
11
|
Cache.setItem("isRedirectLogin", false);
|
|
12
12
|
const dispatch = useDispatch();
|
|
13
|
-
const application =
|
|
13
|
+
const application = useApplication();
|
|
14
14
|
const auth = useSelector(state => state.auth);
|
|
15
15
|
const isAuthenticated = application?.isLoggedIn ?? false;
|
|
16
|
+
const primaryAuthenticationType = Cache.getItem("primaryAuthenticationType");
|
|
16
17
|
return {
|
|
17
18
|
isAuthenticated,
|
|
18
|
-
|
|
19
|
+
primaryAuthenticationType: primaryAuthenticationType ?? application?.authenticationTypes[0],
|
|
20
|
+
authenticationTypes: application?.authenticationTypes ?? [],
|
|
19
21
|
errorMessage: auth.error,
|
|
20
22
|
resetErrors: () => dispatch(resetAuthErrors()),
|
|
21
23
|
login: (username, password) => dispatch(login(username, password)),
|
|
@@ -36,13 +38,15 @@ export const useLogin = () => {
|
|
|
36
38
|
*/
|
|
37
39
|
export const useLogout = () => {
|
|
38
40
|
const dispatch = useDispatch();
|
|
39
|
-
const application =
|
|
41
|
+
const application = useApplication();
|
|
40
42
|
const BASE_PATH = getBasePath();
|
|
41
43
|
const authenticate = new Authenticate();
|
|
44
|
+
const primaryAuthenticationType = Cache.getItem("primaryAuthenticationType");
|
|
42
45
|
const isAuthenticated = application?.isLoggedIn ?? false;
|
|
43
46
|
return {
|
|
44
47
|
isAuthenticated,
|
|
45
|
-
|
|
48
|
+
primaryAuthenticationType: primaryAuthenticationType ?? application?.authenticationTypes[0],
|
|
49
|
+
authenticationTypes: application?.authenticationTypes ?? [],
|
|
46
50
|
logout: () => {
|
|
47
51
|
const type = authenticate.authenticationType;
|
|
48
52
|
if (type === INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT) {
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import { useSelector, useDispatch } from "react-redux";
|
|
3
3
|
|
|
4
|
-
import { getApplication } from "../redux/_modularui/ModularUISelectors";
|
|
5
4
|
import { login, logout, resetAuthErrors } from "../redux/actions";
|
|
6
5
|
|
|
7
6
|
import Cache from "../utils/browser/Cache";
|
|
8
7
|
import {
|
|
9
|
-
DEFAULT_AUTHENTICATION_TYPE,
|
|
10
8
|
getBasePath,
|
|
11
9
|
getBasePathServer,
|
|
12
10
|
INTERNAL_LOGIN_TYPE,
|
|
13
11
|
} from "../constants";
|
|
14
12
|
import { IllegalStateException } from "../exceptions";
|
|
15
13
|
import { Authenticate } from "../modularui";
|
|
14
|
+
import { useApplication } from "./useModularUIModel";
|
|
16
15
|
|
|
17
16
|
import type { ResetAuthErrorsAction } from "../redux/types";
|
|
18
17
|
import type { AuthenticationType } from "../models/types";
|
|
19
18
|
|
|
20
19
|
type LoginHook = {
|
|
21
20
|
isAuthenticated: boolean,
|
|
21
|
+
primaryAuthenticationType: AuthenticationType,
|
|
22
22
|
authenticationTypes: Array<AuthenticationType>,
|
|
23
23
|
errorMessage: ?string,
|
|
24
24
|
resetErrors: () => ResetAuthErrorsAction,
|
|
@@ -27,6 +27,7 @@ type LoginHook = {
|
|
|
27
27
|
};
|
|
28
28
|
type LogoutHook = {
|
|
29
29
|
isAuthenticated: boolean,
|
|
30
|
+
primaryAuthenticationType: AuthenticationType,
|
|
30
31
|
authenticationTypes: Array<AuthenticationType>,
|
|
31
32
|
logout: () => void,
|
|
32
33
|
logoutUrl: string,
|
|
@@ -39,16 +40,18 @@ export const useLogin = (): LoginHook => {
|
|
|
39
40
|
|
|
40
41
|
const dispatch = useDispatch();
|
|
41
42
|
|
|
42
|
-
const application =
|
|
43
|
+
const application = useApplication();
|
|
43
44
|
const auth = useSelector((state) => state.auth);
|
|
44
45
|
|
|
45
46
|
const isAuthenticated = application?.isLoggedIn ?? false;
|
|
46
47
|
|
|
48
|
+
const primaryAuthenticationType = Cache.getItem("primaryAuthenticationType");
|
|
49
|
+
|
|
47
50
|
return {
|
|
48
51
|
isAuthenticated,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
],
|
|
52
|
+
primaryAuthenticationType:
|
|
53
|
+
primaryAuthenticationType ?? application?.authenticationTypes[0],
|
|
54
|
+
authenticationTypes: application?.authenticationTypes ?? [],
|
|
52
55
|
errorMessage: auth.error,
|
|
53
56
|
resetErrors: () => dispatch(resetAuthErrors()),
|
|
54
57
|
login: (username: string, password: string) =>
|
|
@@ -77,18 +80,21 @@ export const useLogin = (): LoginHook => {
|
|
|
77
80
|
*/
|
|
78
81
|
export const useLogout = (): LogoutHook => {
|
|
79
82
|
const dispatch = useDispatch();
|
|
80
|
-
|
|
83
|
+
|
|
84
|
+
const application = useApplication();
|
|
81
85
|
|
|
82
86
|
const BASE_PATH = getBasePath();
|
|
83
87
|
|
|
84
88
|
const authenticate = new Authenticate();
|
|
85
89
|
|
|
90
|
+
const primaryAuthenticationType = Cache.getItem("primaryAuthenticationType");
|
|
91
|
+
|
|
86
92
|
const isAuthenticated = application?.isLoggedIn ?? false;
|
|
87
93
|
return {
|
|
88
94
|
isAuthenticated,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
],
|
|
95
|
+
primaryAuthenticationType:
|
|
96
|
+
primaryAuthenticationType ?? application?.authenticationTypes[0],
|
|
97
|
+
authenticationTypes: application?.authenticationTypes ?? [],
|
|
92
98
|
logout: () => {
|
|
93
99
|
const type = authenticate.authenticationType;
|
|
94
100
|
if (type === INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuthentication.js","names":["useSelector","useDispatch","
|
|
1
|
+
{"version":3,"file":"useAuthentication.js","names":["useSelector","useDispatch","login","logout","resetAuthErrors","Cache","getBasePath","getBasePathServer","INTERNAL_LOGIN_TYPE","IllegalStateException","Authenticate","useApplication","useLogin","setItem","dispatch","application","auth","state","isAuthenticated","isLoggedIn","primaryAuthenticationType","getItem","authenticationTypes","errorMessage","error","resetErrors","username","password","redirectLogin","authenticationType","authentication","redirectUri","window","location","assign","useLogout","BASE_PATH","authenticate","type","PAC4J_INDIRECT","redirectToLogout","origin","url","getLogoutUrl","logoutUrl"],"sources":["../../src/hooks/useAuthentication.js"],"sourcesContent":["// @flow\nimport { useSelector, useDispatch } from \"react-redux\";\n\nimport { login, logout, resetAuthErrors } from \"../redux/actions\";\n\nimport Cache from \"../utils/browser/Cache\";\nimport {\n getBasePath,\n getBasePathServer,\n INTERNAL_LOGIN_TYPE,\n} from \"../constants\";\nimport { IllegalStateException } from \"../exceptions\";\nimport { Authenticate } from \"../modularui\";\nimport { useApplication } from \"./useModularUIModel\";\n\nimport type { ResetAuthErrorsAction } from \"../redux/types\";\nimport type { AuthenticationType } from \"../models/types\";\n\ntype LoginHook = {\n isAuthenticated: boolean,\n primaryAuthenticationType: AuthenticationType,\n authenticationTypes: Array<AuthenticationType>,\n errorMessage: ?string,\n resetErrors: () => ResetAuthErrorsAction,\n login: (username: string, password: string) => void,\n redirectLogin: (authenticationType: AuthenticationType) => void,\n};\ntype LogoutHook = {\n isAuthenticated: boolean,\n primaryAuthenticationType: AuthenticationType,\n authenticationTypes: Array<AuthenticationType>,\n logout: () => void,\n logoutUrl: string,\n};\n\n/**\n */\nexport const useLogin = (): LoginHook => {\n Cache.setItem(\"isRedirectLogin\", false);\n\n const dispatch = useDispatch();\n\n const application = useApplication();\n const auth = useSelector((state) => state.auth);\n\n const isAuthenticated = application?.isLoggedIn ?? false;\n\n const primaryAuthenticationType = Cache.getItem(\"primaryAuthenticationType\");\n\n return {\n isAuthenticated,\n primaryAuthenticationType:\n primaryAuthenticationType ?? application?.authenticationTypes[0],\n authenticationTypes: application?.authenticationTypes ?? [],\n errorMessage: auth.error,\n resetErrors: () => dispatch(resetAuthErrors()),\n login: (username: string, password: string) =>\n dispatch(login(username, password)),\n redirectLogin: (authenticationType: AuthenticationType) => {\n if (Cache.getItem(\"isRedirectLogin\")) {\n // prevent endless loop in redirects when authentication type can't be redirected\n throw new IllegalStateException(\n `Could not redirect to '${\n authenticationType.authentication\n }' using url: '${authenticationType.redirectUri ?? \"\"}'`,\n );\n }\n\n if (!isAuthenticated) {\n Cache.setItem(\"isRedirectLogin\", true);\n window.location.assign(\n `${getBasePathServer()}${authenticationType.redirectUri ?? \"\"}`,\n );\n }\n },\n };\n};\n\n/**\n */\nexport const useLogout = (): LogoutHook => {\n const dispatch = useDispatch();\n\n const application = useApplication();\n\n const BASE_PATH = getBasePath();\n\n const authenticate = new Authenticate();\n\n const primaryAuthenticationType = Cache.getItem(\"primaryAuthenticationType\");\n\n const isAuthenticated = application?.isLoggedIn ?? false;\n return {\n isAuthenticated,\n primaryAuthenticationType:\n primaryAuthenticationType ?? application?.authenticationTypes[0],\n authenticationTypes: application?.authenticationTypes ?? [],\n logout: () => {\n const type = authenticate.authenticationType;\n if (type === INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT) {\n authenticate.redirectToLogout();\n } else if (Cache.getItem(\"isRedirectLogin\")) {\n const origin = window.location.origin;\n const url = `${authenticate.getLogoutUrl()}?url=${origin}${BASE_PATH}`;\n Cache.setItem(\"isRedirectLogin\", false);\n window.location.assign(url);\n } else {\n return dispatch(logout());\n }\n },\n logoutUrl: authenticate.getLogoutUrl(),\n };\n};\n"],"mappings":"AACA,SAASA,WAAW,EAAEC,WAAW,QAAQ,aAAa;AAEtD,SAASC,KAAK,EAAEC,MAAM,EAAEC,eAAe,QAAQ,kBAAkB;AAEjE,OAAOC,KAAK,MAAM,wBAAwB;AAC1C,SACEC,WAAW,EACXC,iBAAiB,EACjBC,mBAAmB,QACd,cAAc;AACrB,SAASC,qBAAqB,QAAQ,eAAe;AACrD,SAASC,YAAY,QAAQ,cAAc;AAC3C,SAASC,cAAc,QAAQ,qBAAqB;AAsBpD;AACA;AACA,OAAO,MAAMC,QAAQ,GAAGA,CAAA,KAAiB;EACvCP,KAAK,CAACQ,OAAO,CAAC,iBAAiB,EAAE,KAAK,CAAC;EAEvC,MAAMC,QAAQ,GAA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
|
import { NotAllowedUriException } from "../../exceptions";
|
|
8
8
|
import { DEFAULT_AUTHENTICATION_TYPE } from "../../constants";
|
|
9
|
+
import Cache from "../../utils/browser/Cache";
|
|
9
10
|
/**
|
|
10
11
|
* The Application model
|
|
11
12
|
*/
|
|
12
13
|
export default class ApplicationModel extends ResourceModel {
|
|
13
|
-
constructor(
|
|
14
|
-
super(
|
|
14
|
+
constructor(modularuiResponse) {
|
|
15
|
+
super(modularuiResponse);
|
|
16
|
+
|
|
17
|
+
// store authentication type in session cache, to make it available when application is no longer available (when not permitted for example)
|
|
15
18
|
_defineProperty(this, "_userServices", void 0);
|
|
19
|
+
Cache.setItem("primaryAuthenticationType", this.primaryAuthenticationType);
|
|
16
20
|
}
|
|
21
|
+
|
|
17
22
|
/**
|
|
18
23
|
* Retrieve type of model
|
|
19
24
|
*/
|
|
@@ -72,6 +77,14 @@ export default class ApplicationModel extends ResourceModel {
|
|
|
72
77
|
return [DEFAULT_AUTHENTICATION_TYPE];
|
|
73
78
|
}
|
|
74
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Returns the primary authentication type
|
|
82
|
+
* @returns {AuthenticationType}
|
|
83
|
+
*/
|
|
84
|
+
get primaryAuthenticationType() {
|
|
85
|
+
return this.authenticationTypes[0];
|
|
86
|
+
}
|
|
87
|
+
|
|
75
88
|
/**
|
|
76
89
|
* Getting the tab links
|
|
77
90
|
*/
|
|
@@ -7,6 +7,8 @@ import { NotAllowedUriException } from "../../exceptions";
|
|
|
7
7
|
|
|
8
8
|
import { DEFAULT_AUTHENTICATION_TYPE } from "../../constants";
|
|
9
9
|
|
|
10
|
+
import Cache from "../../utils/browser/Cache";
|
|
11
|
+
|
|
10
12
|
import type { ModularUIModel, AuthenticationType } from "../types";
|
|
11
13
|
import type { ModularUIResponse } from "../../modularui";
|
|
12
14
|
import type LinkCollection from "../links/LinkCollection";
|
|
@@ -18,6 +20,13 @@ import type Href from "../href/Href";
|
|
|
18
20
|
export default class ApplicationModel extends ResourceModel {
|
|
19
21
|
_userServices: ?UserServicesModel;
|
|
20
22
|
|
|
23
|
+
constructor(modularuiResponse: ModularUIResponse) {
|
|
24
|
+
super(modularuiResponse);
|
|
25
|
+
|
|
26
|
+
// store authentication type in session cache, to make it available when application is no longer available (when not permitted for example)
|
|
27
|
+
Cache.setItem("primaryAuthenticationType", this.primaryAuthenticationType);
|
|
28
|
+
}
|
|
29
|
+
|
|
21
30
|
/**
|
|
22
31
|
* Retrieve type of model
|
|
23
32
|
*/
|
|
@@ -91,6 +100,14 @@ export default class ApplicationModel extends ResourceModel {
|
|
|
91
100
|
return [DEFAULT_AUTHENTICATION_TYPE];
|
|
92
101
|
}
|
|
93
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Returns the primary authentication type
|
|
105
|
+
* @returns {AuthenticationType}
|
|
106
|
+
*/
|
|
107
|
+
get primaryAuthenticationType(): AuthenticationType {
|
|
108
|
+
return this.authenticationTypes[0];
|
|
109
|
+
}
|
|
110
|
+
|
|
94
111
|
/**
|
|
95
112
|
* Getting the tab links
|
|
96
113
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApplicationModel.js","names":["ResourceModel","LinkModel","UserServicesModel","NotAllowedUriException","DEFAULT_AUTHENTICATION_TYPE","ApplicationModel","constructor","
|
|
1
|
+
{"version":3,"file":"ApplicationModel.js","names":["ResourceModel","LinkModel","UserServicesModel","NotAllowedUriException","DEFAULT_AUTHENTICATION_TYPE","Cache","ApplicationModel","constructor","modularuiResponse","_defineProperty","setItem","primaryAuthenticationType","type","modelName","isApplicableModel","data","contributions","resourcetype","getInitialChildModelLinks","userService","links","getLinkByKey","href","path","setChildModels","models","userServiceModel","_findInstanceProperty","call","model","userServices","label","getContribution","authenticationTypes","_context","Function","bind","_sortInstanceProperty","a","b","isPrimary","tabs","getLinksByGroup","modelcatalog","create","modelOptions","_userServices","isLoggedIn","userHref","userLink","userMustChangePassword","mustChangePassword"],"sources":["../../../src/models/application/ApplicationModel.js"],"sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\nimport LinkModel from \"../links/LinkModel\";\nimport UserServicesModel from \"../user/UserServicesModel\";\n\nimport { NotAllowedUriException } from \"../../exceptions\";\n\nimport { DEFAULT_AUTHENTICATION_TYPE } from \"../../constants\";\n\nimport Cache from \"../../utils/browser/Cache\";\n\nimport type { ModularUIModel, AuthenticationType } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type Href from \"../href/Href\";\n\n/**\n * The Application model\n */\nexport default class ApplicationModel extends ResourceModel {\n _userServices: ?UserServicesModel;\n\n constructor(modularuiResponse: ModularUIResponse) {\n super(modularuiResponse);\n\n // store authentication type in session cache, to make it available when application is no longer available (when not permitted for example)\n Cache.setItem(\"primaryAuthenticationType\", this.primaryAuthenticationType);\n }\n\n /**\n * Retrieve type of model\n */\n get type(): string {\n return \"Application\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ApplicationModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"Application\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const userService = this.links.getLinkByKey(\"UserServices\");\n if (userService && userService.href.path === \"/login\") {\n throw new NotAllowedUriException(\n \"The user service (Login panel) should not have the uri '/login', use a different URI because this uri matches the login service.\",\n );\n }\n\n return userService ? [userService] : [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n const userServiceModel = models.find(\n (model) => model.type === \"UserServices\",\n );\n\n if (userServiceModel) {\n this.userServices = userServiceModel;\n }\n }\n\n /**\n * Getting the label of the application\n */\n get label(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Getting the authentication types of the application\n */\n get authenticationTypes(): Array<AuthenticationType> {\n const authenticationTypes = this.getContribution(\"security\", [\n DEFAULT_AUTHENTICATION_TYPE,\n ]);\n\n if (authenticationTypes) {\n //put primary first\n return authenticationTypes?.sort(\n (a: AuthenticationType, b: AuthenticationType) =>\n a.isPrimary === b.isPrimary ? 0 : a.isPrimary ? -1 : 1,\n );\n }\n\n return [DEFAULT_AUTHENTICATION_TYPE];\n }\n\n /**\n * Returns the primary authentication type\n * @returns {AuthenticationType}\n */\n get primaryAuthenticationType(): AuthenticationType {\n return this.authenticationTypes[0];\n }\n\n /**\n * Getting the tab links\n */\n get tabs(): LinkCollection {\n return this.links.getLinksByGroup(\"tab\");\n }\n\n /**\n * Get modelcatalog link\n */\n get modelcatalog(): LinkModel {\n return LinkModel.create(\n \"modelcatalog\",\n \"/modelcatalog\",\n \"Model catalog\",\n this.modelOptions,\n );\n }\n\n /**\n * Set the userservices for this application\n */\n set userServices(model: ?ModularUIModel) {\n this._userServices = model instanceof UserServicesModel ? model : null;\n }\n\n /**\n * returns the userservices configured for this application\n */\n get userServices(): ?UserServicesModel {\n return this._userServices ? this._userServices : null;\n }\n\n /**\n * Indicates if the user is logged in\n */\n get isLoggedIn(): boolean {\n return this.userServices?.isLoggedIn ?? false;\n }\n\n /**\n * Retrieve link to the user information,\n * only available when the user services are available\n */\n get userHref(): Href | null {\n if (this.userServices?.userLink) {\n return this.userServices.userLink.href;\n }\n\n return null;\n }\n\n /**\n */\n get userMustChangePassword(): boolean {\n return this.userServices?.mustChangePassword ?? false;\n }\n}\n"],"mappings":";;;AACA,OAAOA,aAAa,MAAM,uBAAuB;AACjD,OAAOC,SAAS,MAAM,oBAAoB;AAC1C,OAAOC,iBAAiB,MAAM,2BAA2B;AAEzD,SAASC,sBAAsB,QAAQ,kBAAkB;AAEzD,SAASC,2BAA2B,QAAQ,iBAAiB;AAE7D,OAAOC,KAAK,MAAM,2BAA2B;AAO7C;AACA;AACA;AACA,eAAe,MAAMC,gBAAgB,SAASN,aAAa,CAAC;EAG1DO,WAAWA,CAACC,iBAAoC,EAAE;IAChD,KAAK,CAACA,iBAAiB,CAAC;;IAExB;IAAAC,eAAA;IACAJ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IAAI,CAACnB,YAAY,CAACmB,QAAQ,CAAC3B,IAAI;IACxC;IAEA,OAAO,IAAI;EACb;;EAEA;AACF;EACE,IAAI4B,sBAAsBA,CAAA,EAAY;IACpC,OAAO,IAAI,CAACpB,YAAY,EAAEqB,kBAAkB,IAAI,KAAK;EACvD;AACF","ignoreList":[]}
|
|
@@ -3,9 +3,7 @@ import type { IConstraintModel } from "../../types";
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
*/
|
|
6
|
-
class PasswordThreeConsecutiveCharactersNotAllowedConstraint
|
|
7
|
-
implements IConstraintModel
|
|
8
|
-
{
|
|
6
|
+
class PasswordThreeConsecutiveCharactersNotAllowedConstraint implements IConstraintModel {
|
|
9
7
|
_maxSequence: number;
|
|
10
8
|
|
|
11
9
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PasswordThreeConsecutiveCharactersNotAllowedConstraint.js","names":["PasswordThreeConsecutiveCharactersNotAllowedConstraint","constructor","maxSequence","_defineProperty","_maxSequence","id","hasValidation","defaultMessage","parameters","hasNoSequenceOfIdenticalCharacters","value","_context","_filterInstanceProperty","split","call","char","i","indexOf","some","sequence","_repeatInstanceProperty","_includesInstanceProperty","validate","isMandatoryConstraint"],"sources":["../../../../src/models/attributes/input-constraints/PasswordThreeConsecutiveCharactersNotAllowedConstraint.js"],"sourcesContent":["// @flow\nimport type { IConstraintModel } from \"../../types\";\n\n/**\n */\nclass PasswordThreeConsecutiveCharactersNotAllowedConstraint
|
|
1
|
+
{"version":3,"file":"PasswordThreeConsecutiveCharactersNotAllowedConstraint.js","names":["PasswordThreeConsecutiveCharactersNotAllowedConstraint","constructor","maxSequence","_defineProperty","_maxSequence","id","hasValidation","defaultMessage","parameters","hasNoSequenceOfIdenticalCharacters","value","_context","_filterInstanceProperty","split","call","char","i","indexOf","some","sequence","_repeatInstanceProperty","_includesInstanceProperty","validate","isMandatoryConstraint"],"sources":["../../../../src/models/attributes/input-constraints/PasswordThreeConsecutiveCharactersNotAllowedConstraint.js"],"sourcesContent":["// @flow\nimport type { IConstraintModel } from \"../../types\";\n\n/**\n */\nclass PasswordThreeConsecutiveCharactersNotAllowedConstraint implements IConstraintModel {\n _maxSequence: number;\n\n /**\n */\n constructor(maxSequence: number = 2) {\n this._maxSequence = maxSequence;\n }\n\n /**\n */\n get id(): string {\n return \"Constraint.Password.ThreeConsecutiveCharactersNotAllowed\";\n }\n\n /**\n */\n get maxSequence(): number {\n return this._maxSequence;\n }\n\n /**\n */\n hasValidation(): boolean {\n return true;\n }\n\n /**\n */\n get defaultMessage(): string {\n return \"Must not contain any character more than twice consecutively\";\n }\n\n /**\n */\n get parameters(): { \"max-sequence\": number } {\n return {\n \"max-sequence\": this.maxSequence,\n };\n }\n\n /**\n */\n hasNoSequenceOfIdenticalCharacters(value: string): boolean {\n return !value\n .split(\"\")\n .filter((char, i) => value.indexOf(char) === i)\n .some((char) => {\n const sequence = char.repeat(this.maxSequence + 1);\n return value.includes(sequence);\n });\n }\n\n /**\n */\n validate(value: string): boolean {\n return this.hasNoSequenceOfIdenticalCharacters(value);\n }\n\n /**\n */\n get isMandatoryConstraint(): boolean {\n return false;\n }\n}\n\nexport default PasswordThreeConsecutiveCharactersNotAllowedConstraint;\n"],"mappings":";;;;AAGA;AACA;AACA,MAAMA,sDAAsD,CAA6B;EAGvF;AACF;EACEC,WAAWA,CAACC,WAAmB,GAAG,CAAC,EAAE;IAAAC,eAAA;IACnC,IAAI,CAACC,YAAY,GAAGF,WAAW;EACjC;;EAEA;AACF;EACE,IAAIG,EAAEA,CAAA,EAAW;IACf,OAAO,0DAA0D;EACnE;;EAEA;AACF;EACE,IAAIH,WAAWA,CAAA,EAAW;IACxB,OAAO,IAAI,CAACE,YAAY;EAC1B;;EAEA;AACF;EACEE,aAAaA,CAAA,EAAY;IACvB,OAAO,IAAI;EACb;;EAEA;AACF;EACE,IAAIC,cAAcA,CAAA,EAAW;IAC3B,OAAO,8DAA8D;EACvE;;EAEA;AACF;EACE,IAAIC,UAAUA,CAAA,EAA+B;IAC3C,OAAO;MACL,cAAc,EAAE,IAAI,CAACN;IACvB,CAAC;EACH;;EAEA;AACF;EACEO,kCAAkCA,CAACC,KAAa,EAAW;IAAA,IAAAC,QAAA;IACzD,OAAO,CAACC,uBAAA,CAAAD,QAAA,GAAAD,KAAK,CACVG,KAAK,CAAC,EAAE,CAAC,EAAAC,IAAA,CAAAH,QAAA,EACF,CAACI,IAAI,EAAEC,CAAC,KAAKN,KAAK,CAACO,OAAO,CAACF,IAAI,CAAC,KAAKC,CAAC,CAAC,CAC9CE,IAAI,CAAEH,IAAI,IAAK;MACd,MAAMI,QAAQ,GAAGC,uBAAA,CAAAL,IAAI,EAAAD,IAAA,CAAJC,IAAI,EAAQ,IAAI,CAACb,WAAW,GAAG,CAAC,CAAC;MAClD,OAAOmB,yBAAA,CAAAX,KAAK,EAAAI,IAAA,CAALJ,KAAK,EAAUS,QAAQ,CAAC;IACjC,CAAC,CAAC;EACN;;EAEA;AACF;EACEG,QAAQA,CAACZ,KAAa,EAAW;IAC/B,OAAO,IAAI,CAACD,kCAAkC,CAACC,KAAK,CAAC;EACvD;;EAEA;AACF;EACE,IAAIa,qBAAqBA,CAAA,EAAY;IACnC,OAAO,KAAK;EACd;AACF;AAEA,eAAevB,sDAAsD","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createHash.js","names":["hash","createHash","str","createHashFromHref","href","fragment","hrefString","toString","join"],"sources":["../../../src/utils/helpers/createHash.js"],"sourcesContent":["// @flow\nimport hash from \"hash-it\";\n\nimport type Href from \"../../models/href/Href\";\nimport type { SectionFragment } from \"../../models\";\n\n/**\n * https://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/\n */\nconst createHash = (str: string): number => {\n return hash(str);\n};\n\n/**\n */\nconst createHashFromHref = (href: Href, fragment?: SectionFragment): number => {\n const hrefString = href.hash\n ? [href.toString(), href.hash].join(\"#\")\n : href.toString();\n\n if (fragment) {\n return hash({ hrefString, fragment });\n }\n\n return hash(hrefString);\n};\n\nexport { createHash, createHashFromHref };\n"],"mappings":"AACA,
|
|
1
|
+
{"version":3,"file":"createHash.js","names":["hash","createHash","str","createHashFromHref","href","fragment","hrefString","toString","join"],"sources":["../../../src/utils/helpers/createHash.js"],"sourcesContent":["// @flow\nimport { hash } from \"hash-it\";\n\nimport type Href from \"../../models/href/Href\";\nimport type { SectionFragment } from \"../../models\";\n\n/**\n * https://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/\n */\nconst createHash = (str: string): number => {\n return hash(str);\n};\n\n/**\n */\nconst createHashFromHref = (href: Href, fragment?: SectionFragment): number => {\n const hrefString = href.hash\n ? [href.toString(), href.hash].join(\"#\")\n : href.toString();\n\n if (fragment) {\n return hash({ hrefString, fragment });\n }\n\n return hash(hrefString);\n};\n\nexport { createHash, createHashFromHref };\n"],"mappings":"AACA,SAASA,IAAI,QAAQ,SAAS;AAK9B;AACA;AACA;AACA,MAAMC,UAAU,GAAIC,GAAW,IAAa;EAC1C,OAAOF,IAAI,CAACE,GAAG,CAAC;AAClB,CAAC;;AAED;AACA;AACA,MAAMC,kBAAkB,GAAGA,CAACC,IAAU,EAAEC,QAA0B,KAAa;EAC7E,MAAMC,UAAU,GAAGF,IAAI,CAACJ,IAAI,GACxB,CAACI,IAAI,CAACG,QAAQ,CAAC,CAAC,EAAEH,IAAI,CAACJ,IAAI,CAAC,CAACQ,IAAI,CAAC,GAAG,CAAC,GACtCJ,IAAI,CAACG,QAAQ,CAAC,CAAC;EAEnB,IAAIF,QAAQ,EAAE;IACZ,OAAOL,IAAI,CAAC;MAAEM,UAAU;MAAED;IAAS,CAAC,CAAC;EACvC;EAEA,OAAOL,IAAI,CAACM,UAAU,CAAC;AACzB,CAAC;AAED,SAASL,UAAU,EAAEE,kBAAkB","ignoreList":[]}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
const createUUID = (): string => {
|
|
5
5
|
let d = new Date().getTime();
|
|
6
6
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
7
|
-
const r = (d + Math.random() * 16) % 16 | 0;
|
|
7
|
+
const r = ((d + Math.random() * 16) % 16) | 0;
|
|
8
8
|
d = Math.floor(d / 16);
|
|
9
9
|
return (c === "x" ? r : (r & 0x3) | 0x8).toString(16);
|
|
10
10
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createUUID.js","names":["createUUID","d","Date","getTime","replace","c","r","Math","random","floor","toString"],"sources":["../../../src/utils/helpers/createUUID.js"],"sourcesContent":["// @flow\n/**\n */\nconst createUUID = (): string => {\n let d = new Date().getTime();\n return \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g, (c) => {\n const r = (d + Math.random() * 16) % 16 | 0;\n d = Math.floor(d / 16);\n return (c === \"x\" ? r : (r & 0x3) | 0x8).toString(16);\n });\n};\n\nexport default createUUID;\n"],"mappings":"AACA;AACA;AACA,MAAMA,UAAU,GAAGA,CAAA,KAAc;EAC/B,IAAIC,CAAC,GAAG,IAAIC,IAAI,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC;EAC5B,OAAO,sCAAsC,CAACC,OAAO,CAAC,OAAO,EAAGC,CAAC,IAAK;IACpE,MAAMC,CAAC,
|
|
1
|
+
{"version":3,"file":"createUUID.js","names":["createUUID","d","Date","getTime","replace","c","r","Math","random","floor","toString"],"sources":["../../../src/utils/helpers/createUUID.js"],"sourcesContent":["// @flow\n/**\n */\nconst createUUID = (): string => {\n let d = new Date().getTime();\n return \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g, (c) => {\n const r = ((d + Math.random() * 16) % 16) | 0;\n d = Math.floor(d / 16);\n return (c === \"x\" ? r : (r & 0x3) | 0x8).toString(16);\n });\n};\n\nexport default createUUID;\n"],"mappings":"AACA;AACA;AACA,MAAMA,UAAU,GAAGA,CAAA,KAAc;EAC/B,IAAIC,CAAC,GAAG,IAAIC,IAAI,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC;EAC5B,OAAO,sCAAsC,CAACC,OAAO,CAAC,OAAO,EAAGC,CAAC,IAAK;IACpE,MAAMC,CAAC,GAAI,CAACL,CAAC,GAAGM,IAAI,CAACC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,GAAI,CAAC;IAC7CP,CAAC,GAAGM,IAAI,CAACE,KAAK,CAACR,CAAC,GAAG,EAAE,CAAC;IACtB,OAAO,CAACI,CAAC,KAAK,GAAG,GAAGC,CAAC,GAAIA,CAAC,GAAG,GAAG,GAAI,GAAG,EAAEI,QAAQ,CAAC,EAAE,CAAC;EACvD,CAAC,CAAC;AACJ,CAAC;AAED,eAAeV,UAAU","ignoreList":[]}
|
|
@@ -6,23 +6,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.useLogout = exports.useLogin = void 0;
|
|
8
8
|
var _reactRedux = require("react-redux");
|
|
9
|
-
var _ModularUISelectors = require("../redux/_modularui/ModularUISelectors");
|
|
10
9
|
var _actions = require("../redux/actions");
|
|
11
10
|
var _Cache = _interopRequireDefault(require("../utils/browser/Cache"));
|
|
12
11
|
var _constants = require("../constants");
|
|
13
12
|
var _exceptions = require("../exceptions");
|
|
14
13
|
var _modularui = require("../modularui");
|
|
14
|
+
var _useModularUIModel = require("./useModularUIModel");
|
|
15
15
|
/**
|
|
16
16
|
*/
|
|
17
17
|
const useLogin = () => {
|
|
18
18
|
_Cache.default.setItem("isRedirectLogin", false);
|
|
19
19
|
const dispatch = (0, _reactRedux.useDispatch)();
|
|
20
|
-
const application = (0,
|
|
20
|
+
const application = (0, _useModularUIModel.useApplication)();
|
|
21
21
|
const auth = (0, _reactRedux.useSelector)(state => state.auth);
|
|
22
22
|
const isAuthenticated = application?.isLoggedIn ?? false;
|
|
23
|
+
const primaryAuthenticationType = _Cache.default.getItem("primaryAuthenticationType");
|
|
23
24
|
return {
|
|
24
25
|
isAuthenticated,
|
|
25
|
-
|
|
26
|
+
primaryAuthenticationType: primaryAuthenticationType ?? application?.authenticationTypes[0],
|
|
27
|
+
authenticationTypes: application?.authenticationTypes ?? [],
|
|
26
28
|
errorMessage: auth.error,
|
|
27
29
|
resetErrors: () => dispatch((0, _actions.resetAuthErrors)()),
|
|
28
30
|
login: (username, password) => dispatch((0, _actions.login)(username, password)),
|
|
@@ -44,13 +46,15 @@ const useLogin = () => {
|
|
|
44
46
|
exports.useLogin = useLogin;
|
|
45
47
|
const useLogout = () => {
|
|
46
48
|
const dispatch = (0, _reactRedux.useDispatch)();
|
|
47
|
-
const application = (0,
|
|
49
|
+
const application = (0, _useModularUIModel.useApplication)();
|
|
48
50
|
const BASE_PATH = (0, _constants.getBasePath)();
|
|
49
51
|
const authenticate = new _modularui.Authenticate();
|
|
52
|
+
const primaryAuthenticationType = _Cache.default.getItem("primaryAuthenticationType");
|
|
50
53
|
const isAuthenticated = application?.isLoggedIn ?? false;
|
|
51
54
|
return {
|
|
52
55
|
isAuthenticated,
|
|
53
|
-
|
|
56
|
+
primaryAuthenticationType: primaryAuthenticationType ?? application?.authenticationTypes[0],
|
|
57
|
+
authenticationTypes: application?.authenticationTypes ?? [],
|
|
54
58
|
logout: () => {
|
|
55
59
|
const type = authenticate.authenticationType;
|
|
56
60
|
if (type === _constants.INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuthentication.js","names":["_reactRedux","require","
|
|
1
|
+
{"version":3,"file":"useAuthentication.js","names":["_reactRedux","require","_actions","_Cache","_interopRequireDefault","_constants","_exceptions","_modularui","_useModularUIModel","useLogin","Cache","setItem","dispatch","useDispatch","application","useApplication","auth","useSelector","state","isAuthenticated","isLoggedIn","primaryAuthenticationType","getItem","authenticationTypes","errorMessage","error","resetErrors","resetAuthErrors","login","username","password","redirectLogin","authenticationType","IllegalStateException","authentication","redirectUri","window","location","assign","getBasePathServer","exports","useLogout","BASE_PATH","getBasePath","authenticate","Authenticate","logout","type","INTERNAL_LOGIN_TYPE","PAC4J_INDIRECT","redirectToLogout","origin","url","getLogoutUrl","logoutUrl"],"sources":["../../src/hooks/useAuthentication.js"],"sourcesContent":["// @flow\nimport { useSelector, useDispatch } from \"react-redux\";\n\nimport { login, logout, resetAuthErrors } from \"../redux/actions\";\n\nimport Cache from \"../utils/browser/Cache\";\nimport {\n getBasePath,\n getBasePathServer,\n INTERNAL_LOGIN_TYPE,\n} from \"../constants\";\nimport { IllegalStateException } from \"../exceptions\";\nimport { Authenticate } from \"../modularui\";\nimport { useApplication } from \"./useModularUIModel\";\n\nimport type { ResetAuthErrorsAction } from \"../redux/types\";\nimport type { AuthenticationType } from \"../models/types\";\n\ntype LoginHook = {\n isAuthenticated: boolean,\n primaryAuthenticationType: AuthenticationType,\n authenticationTypes: Array<AuthenticationType>,\n errorMessage: ?string,\n resetErrors: () => ResetAuthErrorsAction,\n login: (username: string, password: string) => void,\n redirectLogin: (authenticationType: AuthenticationType) => void,\n};\ntype LogoutHook = {\n isAuthenticated: boolean,\n primaryAuthenticationType: AuthenticationType,\n authenticationTypes: Array<AuthenticationType>,\n logout: () => void,\n logoutUrl: string,\n};\n\n/**\n */\nexport const useLogin = (): LoginHook => {\n Cache.setItem(\"isRedirectLogin\", false);\n\n const dispatch = useDispatch();\n\n const application = useApplication();\n const auth = useSelector((state) => state.auth);\n\n const isAuthenticated = application?.isLoggedIn ?? false;\n\n const primaryAuthenticationType = Cache.getItem(\"primaryAuthenticationType\");\n\n return {\n isAuthenticated,\n primaryAuthenticationType:\n primaryAuthenticationType ?? application?.authenticationTypes[0],\n authenticationTypes: application?.authenticationTypes ?? [],\n errorMessage: auth.error,\n resetErrors: () => dispatch(resetAuthErrors()),\n login: (username: string, password: string) =>\n dispatch(login(username, password)),\n redirectLogin: (authenticationType: AuthenticationType) => {\n if (Cache.getItem(\"isRedirectLogin\")) {\n // prevent endless loop in redirects when authentication type can't be redirected\n throw new IllegalStateException(\n `Could not redirect to '${\n authenticationType.authentication\n }' using url: '${authenticationType.redirectUri ?? \"\"}'`,\n );\n }\n\n if (!isAuthenticated) {\n Cache.setItem(\"isRedirectLogin\", true);\n window.location.assign(\n `${getBasePathServer()}${authenticationType.redirectUri ?? \"\"}`,\n );\n }\n },\n };\n};\n\n/**\n */\nexport const useLogout = (): LogoutHook => {\n const dispatch = useDispatch();\n\n const application = useApplication();\n\n const BASE_PATH = getBasePath();\n\n const authenticate = new Authenticate();\n\n const primaryAuthenticationType = Cache.getItem(\"primaryAuthenticationType\");\n\n const isAuthenticated = application?.isLoggedIn ?? false;\n return {\n isAuthenticated,\n primaryAuthenticationType:\n primaryAuthenticationType ?? application?.authenticationTypes[0],\n authenticationTypes: application?.authenticationTypes ?? [],\n logout: () => {\n const type = authenticate.authenticationType;\n if (type === INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT) {\n authenticate.redirectToLogout();\n } else if (Cache.getItem(\"isRedirectLogin\")) {\n const origin = window.location.origin;\n const url = `${authenticate.getLogoutUrl()}?url=${origin}${BASE_PATH}`;\n Cache.setItem(\"isRedirectLogin\", false);\n window.location.assign(url);\n } else {\n return dispatch(logout());\n }\n },\n logoutUrl: authenticate.getLogoutUrl(),\n };\n};\n"],"mappings":";;;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAKA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,kBAAA,GAAAP,OAAA;AAsBA;AACA;AACO,MAAMQ,QAAQ,GAAGA,CAAA,KAAiB;EACvCC,cAAK,CAACC,OAAO,CAAC,iBAAiB,EAAE,KAAK,CAAC;EAEvC,MAAMC,QAAQ,GAAG,I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A","ignoreList":[]}
|
|
@@ -13,14 +13,19 @@ var _LinkModel = _interopRequireDefault(require("../links/LinkModel"));
|
|
|
13
13
|
var _UserServicesModel = _interopRequireDefault(require("../user/UserServicesModel"));
|
|
14
14
|
var _exceptions = require("../../exceptions");
|
|
15
15
|
var _constants = require("../../constants");
|
|
16
|
+
var _Cache = _interopRequireDefault(require("../../utils/browser/Cache"));
|
|
16
17
|
/**
|
|
17
18
|
* The Application model
|
|
18
19
|
*/
|
|
19
20
|
class ApplicationModel extends _ResourceModel.default {
|
|
20
|
-
constructor(
|
|
21
|
-
super(
|
|
21
|
+
constructor(modularuiResponse) {
|
|
22
|
+
super(modularuiResponse);
|
|
23
|
+
|
|
24
|
+
// store authentication type in session cache, to make it available when application is no longer available (when not permitted for example)
|
|
22
25
|
(0, _defineProperty2.default)(this, "_userServices", void 0);
|
|
26
|
+
_Cache.default.setItem("primaryAuthenticationType", this.primaryAuthenticationType);
|
|
23
27
|
}
|
|
28
|
+
|
|
24
29
|
/**
|
|
25
30
|
* Retrieve type of model
|
|
26
31
|
*/
|
|
@@ -79,6 +84,14 @@ class ApplicationModel extends _ResourceModel.default {
|
|
|
79
84
|
return [_constants.DEFAULT_AUTHENTICATION_TYPE];
|
|
80
85
|
}
|
|
81
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Returns the primary authentication type
|
|
89
|
+
* @returns {AuthenticationType}
|
|
90
|
+
*/
|
|
91
|
+
get primaryAuthenticationType() {
|
|
92
|
+
return this.authenticationTypes[0];
|
|
93
|
+
}
|
|
94
|
+
|
|
82
95
|
/**
|
|
83
96
|
* Getting the tab links
|
|
84
97
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApplicationModel.js","names":["_ResourceModel","_interopRequireDefault","require","_LinkModel","_UserServicesModel","_exceptions","_constants","ApplicationModel","ResourceModel","constructor","
|
|
1
|
+
{"version":3,"file":"ApplicationModel.js","names":["_ResourceModel","_interopRequireDefault","require","_LinkModel","_UserServicesModel","_exceptions","_constants","_Cache","ApplicationModel","ResourceModel","constructor","modularuiResponse","_defineProperty2","default","Cache","setItem","primaryAuthenticationType","type","modelName","isApplicableModel","data","contributions","resourcetype","getInitialChildModelLinks","userService","links","getLinkByKey","href","path","NotAllowedUriException","setChildModels","models","userServiceModel","_find","call","model","userServices","label","getContribution","authenticationTypes","DEFAULT_AUTHENTICATION_TYPE","_context","Function","bind","_sort","a","b","isPrimary","tabs","getLinksByGroup","modelcatalog","LinkModel","create","modelOptions","_userServices","UserServicesModel","isLoggedIn","userHref","userLink","userMustChangePassword","mustChangePassword","exports"],"sources":["../../../src/models/application/ApplicationModel.js"],"sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\nimport LinkModel from \"../links/LinkModel\";\nimport UserServicesModel from \"../user/UserServicesModel\";\n\nimport { NotAllowedUriException } from \"../../exceptions\";\n\nimport { DEFAULT_AUTHENTICATION_TYPE } from \"../../constants\";\n\nimport Cache from \"../../utils/browser/Cache\";\n\nimport type { ModularUIModel, AuthenticationType } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type Href from \"../href/Href\";\n\n/**\n * The Application model\n */\nexport default class ApplicationModel extends ResourceModel {\n _userServices: ?UserServicesModel;\n\n constructor(modularuiResponse: ModularUIResponse) {\n super(modularuiResponse);\n\n // store authentication type in session cache, to make it available when application is no longer available (when not permitted for example)\n Cache.setItem(\"primaryAuthenticationType\", this.primaryAuthenticationType);\n }\n\n /**\n * Retrieve type of model\n */\n get type(): string {\n return \"Application\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ApplicationModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"Application\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const userService = this.links.getLinkByKey(\"UserServices\");\n if (userService && userService.href.path === \"/login\") {\n throw new NotAllowedUriException(\n \"The user service (Login panel) should not have the uri '/login', use a different URI because this uri matches the login service.\",\n );\n }\n\n return userService ? [userService] : [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n const userServiceModel = models.find(\n (model) => model.type === \"UserServices\",\n );\n\n if (userServiceModel) {\n this.userServices = userServiceModel;\n }\n }\n\n /**\n * Getting the label of the application\n */\n get label(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Getting the authentication types of the application\n */\n get authenticationTypes(): Array<AuthenticationType> {\n const authenticationTypes = this.getContribution(\"security\", [\n DEFAULT_AUTHENTICATION_TYPE,\n ]);\n\n if (authenticationTypes) {\n //put primary first\n return authenticationTypes?.sort(\n (a: AuthenticationType, b: AuthenticationType) =>\n a.isPrimary === b.isPrimary ? 0 : a.isPrimary ? -1 : 1,\n );\n }\n\n return [DEFAULT_AUTHENTICATION_TYPE];\n }\n\n /**\n * Returns the primary authentication type\n * @returns {AuthenticationType}\n */\n get primaryAuthenticationType(): AuthenticationType {\n return this.authenticationTypes[0];\n }\n\n /**\n * Getting the tab links\n */\n get tabs(): LinkCollection {\n return this.links.getLinksByGroup(\"tab\");\n }\n\n /**\n * Get modelcatalog link\n */\n get modelcatalog(): LinkModel {\n return LinkModel.create(\n \"modelcatalog\",\n \"/modelcatalog\",\n \"Model catalog\",\n this.modelOptions,\n );\n }\n\n /**\n * Set the userservices for this application\n */\n set userServices(model: ?ModularUIModel) {\n this._userServices = model instanceof UserServicesModel ? model : null;\n }\n\n /**\n * returns the userservices configured for this application\n */\n get userServices(): ?UserServicesModel {\n return this._userServices ? this._userServices : null;\n }\n\n /**\n * Indicates if the user is logged in\n */\n get isLoggedIn(): boolean {\n return this.userServices?.isLoggedIn ?? false;\n }\n\n /**\n * Retrieve link to the user information,\n * only available when the user services are available\n */\n get userHref(): Href | null {\n if (this.userServices?.userLink) {\n return this.userServices.userLink.href;\n }\n\n return null;\n }\n\n /**\n */\n get userMustChangePassword(): boolean {\n return this.userServices?.must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;EACE,IAAIjB,YAAYA,CAACD,KAAsB,EAAE;IACvC,IAAI,CAACmB,aAAa,GAAGnB,KAAK,YAAYoB,0BAAiB,GAAGpB,KAAK,GAAG,IAAI;EACxE;;EAEA;AACF;AACA;EACE,IAAIC,YAAYA,CAAA,EAAuB;IACrC,OAAO,IAAI,CAACkB,aAAa,GAAG,IAAI,CAACA,aAAa,GAAG,IAAI;EACvD;;EAEA;AACF;AACA;EACE,IAAIE,UAAUA,CAAA,EAAY;IACxB,OAAO,IAAI,CAACpB,YAAY,EAAEoB,UAAU,IAAI,KAAK;EAC/C;;EAEA;AACF;AACA;AACA;EACE,IAAIC,QAAQA,CAAA,EAAgB;IAC1B,IAAI,IAAI,CAACrB,YAAY,EAAEsB,QAAQ,EAAE;MAC/B,OAAO,IAAI,CAACtB,YAAY,CAACsB,QAAQ,CAAC/B,IAAI;IACxC;IAEA,OAAO,IAAI;EACb;;EAEA;AACF;EACE,IAAIgC,sBAAsBA,CAAA,EAAY;IACpC,OAAO,IAAI,CAACvB,YAAY,EAAEwB,kBAAkB,IAAI,KAAK;EACvD;AACF;AAACC,OAAA,CAAAhD,OAAA,GAAAL,gBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PasswordThreeConsecutiveCharactersNotAllowedConstraint.js","names":["PasswordThreeConsecutiveCharactersNotAllowedConstraint","constructor","maxSequence","_defineProperty2","default","_maxSequence","id","hasValidation","defaultMessage","parameters","hasNoSequenceOfIdenticalCharacters","value","_context","_filter","split","call","char","i","indexOf","some","sequence","_repeat","_includes","validate","isMandatoryConstraint","_default","exports"],"sources":["../../../../src/models/attributes/input-constraints/PasswordThreeConsecutiveCharactersNotAllowedConstraint.js"],"sourcesContent":["// @flow\nimport type { IConstraintModel } from \"../../types\";\n\n/**\n */\nclass PasswordThreeConsecutiveCharactersNotAllowedConstraint
|
|
1
|
+
{"version":3,"file":"PasswordThreeConsecutiveCharactersNotAllowedConstraint.js","names":["PasswordThreeConsecutiveCharactersNotAllowedConstraint","constructor","maxSequence","_defineProperty2","default","_maxSequence","id","hasValidation","defaultMessage","parameters","hasNoSequenceOfIdenticalCharacters","value","_context","_filter","split","call","char","i","indexOf","some","sequence","_repeat","_includes","validate","isMandatoryConstraint","_default","exports"],"sources":["../../../../src/models/attributes/input-constraints/PasswordThreeConsecutiveCharactersNotAllowedConstraint.js"],"sourcesContent":["// @flow\nimport type { IConstraintModel } from \"../../types\";\n\n/**\n */\nclass PasswordThreeConsecutiveCharactersNotAllowedConstraint implements IConstraintModel {\n _maxSequence: number;\n\n /**\n */\n constructor(maxSequence: number = 2) {\n this._maxSequence = maxSequence;\n }\n\n /**\n */\n get id(): string {\n return \"Constraint.Password.ThreeConsecutiveCharactersNotAllowed\";\n }\n\n /**\n */\n get maxSequence(): number {\n return this._maxSequence;\n }\n\n /**\n */\n hasValidation(): boolean {\n return true;\n }\n\n /**\n */\n get defaultMessage(): string {\n return \"Must not contain any character more than twice consecutively\";\n }\n\n /**\n */\n get parameters(): { \"max-sequence\": number } {\n return {\n \"max-sequence\": this.maxSequence,\n };\n }\n\n /**\n */\n hasNoSequenceOfIdenticalCharacters(value: string): boolean {\n return !value\n .split(\"\")\n .filter((char, i) => value.indexOf(char) === i)\n .some((char) => {\n const sequence = char.repeat(this.maxSequence + 1);\n return value.includes(sequence);\n });\n }\n\n /**\n */\n validate(value: string): boolean {\n return this.hasNoSequenceOfIdenticalCharacters(value);\n }\n\n /**\n */\n get isMandatoryConstraint(): boolean {\n return false;\n }\n}\n\nexport default PasswordThreeConsecutiveCharactersNotAllowedConstraint;\n"],"mappings":";;;;;;;;;;;AAGA;AACA;AACA,MAAMA,sDAAsD,CAA6B;EAGvF;AACF;EACEC,WAAWA,CAACC,WAAmB,GAAG,CAAC,EAAE;IAAA,IAAAC,gBAAA,CAAAC,OAAA;IACnC,IAAI,CAACC,YAAY,GAAGH,WAAW;EACjC;;EAEA;AACF;EACE,IAAII,EAAEA,CAAA,EAAW;IACf,OA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|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.createHashFromHref = exports.createHash = void 0;
|
|
8
|
-
var _hashIt =
|
|
7
|
+
var _hashIt = require("hash-it");
|
|
9
8
|
/**
|
|
10
9
|
* https://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/
|
|
11
10
|
*/
|
|
12
11
|
const createHash = str => {
|
|
13
|
-
return (0, _hashIt.
|
|
12
|
+
return (0, _hashIt.hash)(str);
|
|
14
13
|
};
|
|
15
14
|
|
|
16
15
|
/**
|
|
@@ -19,12 +18,12 @@ exports.createHash = createHash;
|
|
|
19
18
|
const createHashFromHref = (href, fragment) => {
|
|
20
19
|
const hrefString = href.hash ? [href.toString(), href.hash].join("#") : href.toString();
|
|
21
20
|
if (fragment) {
|
|
22
|
-
return (0, _hashIt.
|
|
21
|
+
return (0, _hashIt.hash)({
|
|
23
22
|
hrefString,
|
|
24
23
|
fragment
|
|
25
24
|
});
|
|
26
25
|
}
|
|
27
|
-
return (0, _hashIt.
|
|
26
|
+
return (0, _hashIt.hash)(hrefString);
|
|
28
27
|
};
|
|
29
28
|
exports.createHashFromHref = createHashFromHref;
|
|
30
29
|
//# sourceMappingURL=createHash.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createHash.js","names":["_hashIt","
|
|
1
|
+
{"version":3,"file":"createHash.js","names":["_hashIt","require","createHash","str","hash","exports","createHashFromHref","href","fragment","hrefString","toString","join"],"sources":["../../../src/utils/helpers/createHash.js"],"sourcesContent":["// @flow\nimport { hash } from \"hash-it\";\n\nimport type Href from \"../../models/href/Href\";\nimport type { SectionFragment } from \"../../models\";\n\n/**\n * https://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/\n */\nconst createHash = (str: string): number => {\n return hash(str);\n};\n\n/**\n */\nconst createHashFromHref = (href: Href, fragment?: SectionFragment): number => {\n const hrefString = href.hash\n ? [href.toString(), href.hash].join(\"#\")\n : href.toString();\n\n if (fragment) {\n return hash({ hrefString, fragment });\n }\n\n return hash(hrefString);\n};\n\nexport { createHash, createHashFromHref };\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAKA;AACA;AACA;AACA,MAAMC,UAAU,GAAIC,GAAW,IAAa;EAC1C,OAAO,IAAAC,YAAI,EAACD,GAAG,CAAC;AAClB,CAAC;;AAED;AACA;AADAE,OAAA,CAAAH,UAAA,GAAAA,UAAA;AAEA,MAAMI,kBAAkB,GAAGA,CAACC,IAAU,EAAEC,QAA0B,KAAa;EAC7E,MAAMC,UAAU,GAAGF,IAAI,CAACH,IAAI,GACxB,CAACG,IAAI,CAACG,QAAQ,CAAC,CAAC,EAAEH,IAAI,CAACH,IAAI,CAAC,CAACO,IAAI,CAAC,GAAG,CAAC,GACtCJ,IAAI,CAACG,QAAQ,CAAC,CAAC;EAEnB,IAAIF,QAAQ,EAAE;IACZ,OAAO,IAAAJ,YAAI,EAAC;MAAEK,UAAU;MAAED;IAAS,CAAC,CAAC;EACvC;EAEA,OAAO,IAAAJ,YAAI,EAACK,UAAU,CAAC;AACzB,CAAC;AAACJ,OAAA,CAAAC,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createUUID.js","names":["createUUID","d","Date","getTime","replace","c","r","Math","random","floor","toString","_default","exports","default"],"sources":["../../../src/utils/helpers/createUUID.js"],"sourcesContent":["// @flow\n/**\n */\nconst createUUID = (): string => {\n let d = new Date().getTime();\n return \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g, (c) => {\n const r = (d + Math.random() * 16) % 16 | 0;\n d = Math.floor(d / 16);\n return (c === \"x\" ? r : (r & 0x3) | 0x8).toString(16);\n });\n};\n\nexport default createUUID;\n"],"mappings":";;;;;;AACA;AACA;AACA,MAAMA,UAAU,GAAGA,CAAA,KAAc;EAC/B,IAAIC,CAAC,GAAG,IAAIC,IAAI,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC;EAC5B,OAAO,sCAAsC,CAACC,OAAO,CAAC,OAAO,EAAGC,CAAC,IAAK;IACpE,MAAMC,CAAC,
|
|
1
|
+
{"version":3,"file":"createUUID.js","names":["createUUID","d","Date","getTime","replace","c","r","Math","random","floor","toString","_default","exports","default"],"sources":["../../../src/utils/helpers/createUUID.js"],"sourcesContent":["// @flow\n/**\n */\nconst createUUID = (): string => {\n let d = new Date().getTime();\n return \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g, (c) => {\n const r = ((d + Math.random() * 16) % 16) | 0;\n d = Math.floor(d / 16);\n return (c === \"x\" ? r : (r & 0x3) | 0x8).toString(16);\n });\n};\n\nexport default createUUID;\n"],"mappings":";;;;;;AACA;AACA;AACA,MAAMA,UAAU,GAAGA,CAAA,KAAc;EAC/B,IAAIC,CAAC,GAAG,IAAIC,IAAI,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC;EAC5B,OAAO,sCAAsC,CAACC,OAAO,CAAC,OAAO,EAAGC,CAAC,IAAK;IACpE,MAAMC,CAAC,GAAI,CAACL,CAAC,GAAGM,IAAI,CAACC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,GAAI,CAAC;IAC7CP,CAAC,GAAGM,IAAI,CAACE,KAAK,CAACR,CAAC,GAAG,EAAE,CAAC;IACtB,OAAO,CAACI,CAAC,KAAK,GAAG,GAAGC,CAAC,GAAIA,CAAC,GAAG,GAAG,GAAI,GAAG,EAAEI,QAAQ,CAAC,EAAE,CAAC;EACvD,CAAC,CAAC;AACJ,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEab,UAAU","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beinformed/ui",
|
|
3
|
-
"version": "1.63.
|
|
3
|
+
"version": "1.63.13",
|
|
4
4
|
"description": "Toolbox for be informed javascript layouts",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"bugs": "https://support.beinformed.com",
|
|
@@ -71,13 +71,14 @@
|
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@babel/runtime-corejs3": "^7.28.4",
|
|
73
73
|
"@date-fns/tz": "^1.4.1",
|
|
74
|
+
"baseline-browser-mapping": "^2.9.5",
|
|
74
75
|
"big.js": "^7.0.1",
|
|
75
76
|
"date-fns": "^4.1.0",
|
|
76
77
|
"deepmerge": "^4.3.1",
|
|
77
78
|
"dequal": "^2.0.3",
|
|
78
79
|
"file-size": "^1.0.0",
|
|
79
80
|
"format-message": "^6.2.4",
|
|
80
|
-
"hash-it": "^
|
|
81
|
+
"hash-it": "^7.0.1",
|
|
81
82
|
"html-entities": "^2.6.0",
|
|
82
83
|
"iban": "^0.0.14",
|
|
83
84
|
"js-cookie": "^3.0.5",
|
|
@@ -106,7 +107,7 @@
|
|
|
106
107
|
"babel-jest": "^30.2.0",
|
|
107
108
|
"babel-plugin-styled-components": "^2.1.4",
|
|
108
109
|
"cherry-pick": "^0.5.0",
|
|
109
|
-
"commit-and-tag-version": "^12.6.
|
|
110
|
+
"commit-and-tag-version": "^12.6.1",
|
|
110
111
|
"cross-env": "^7.0.3",
|
|
111
112
|
"documentation": "^14.0.3",
|
|
112
113
|
"eslint": "^8.57.0",
|
|
@@ -131,17 +132,17 @@
|
|
|
131
132
|
"jscodeshift": "^17.3.0",
|
|
132
133
|
"lint-staged": "^15.5.1",
|
|
133
134
|
"polished": "^4.3.1",
|
|
134
|
-
"prettier": "^3.
|
|
135
|
-
"react": "^19.2.
|
|
136
|
-
"react-dom": "^19.2.
|
|
135
|
+
"prettier": "^3.7.4",
|
|
136
|
+
"react": "^19.2.1",
|
|
137
|
+
"react-dom": "^19.2.1",
|
|
137
138
|
"react-helmet-async": "^2.0.5",
|
|
138
139
|
"react-redux": "^8.1.3",
|
|
139
140
|
"react-router": "^5.0.0",
|
|
140
|
-
"react-test-renderer": "^19.2.
|
|
141
|
+
"react-test-renderer": "^19.2.1",
|
|
141
142
|
"redux": "^4.2.1",
|
|
142
143
|
"redux-mock-store": "^1.5.5",
|
|
143
144
|
"redux-thunk": "^2.4.2",
|
|
144
|
-
"rimraf": "^6.1.
|
|
145
|
+
"rimraf": "^6.1.2",
|
|
145
146
|
"styled-components": "^5.3.11",
|
|
146
147
|
"typescript": "^5.9.3",
|
|
147
148
|
"xhr-mock": "^2.5.1"
|
|
@@ -6,16 +6,27 @@ import xhrMock from "xhr-mock";
|
|
|
6
6
|
|
|
7
7
|
import { useLogin, useLogout } from "../useAuthentication";
|
|
8
8
|
import Href from "../../models/href/Href";
|
|
9
|
+
import { useLocation } from "react-router";
|
|
9
10
|
|
|
10
11
|
const middlewares = [thunk];
|
|
11
12
|
const mockStore = configureMockStore(middlewares);
|
|
12
13
|
|
|
14
|
+
jest.mock("react-router", () => ({
|
|
15
|
+
...jest.requireActual("react-router"), // Keep other methods from react-router as is
|
|
16
|
+
useLocation: jest.fn(), // Mock useLocation
|
|
17
|
+
}));
|
|
18
|
+
|
|
13
19
|
const JSON_TYPE = "application/json";
|
|
14
20
|
|
|
15
21
|
describe("authentication hooks", () => {
|
|
16
22
|
// replace the real XHR object with the mock XHR object before each test
|
|
17
23
|
// eslint-disable-next-line jest/no-hooks
|
|
18
|
-
beforeEach(() =>
|
|
24
|
+
beforeEach(() => {
|
|
25
|
+
useLocation.mockReturnValue({
|
|
26
|
+
state: null,
|
|
27
|
+
});
|
|
28
|
+
xhrMock.setup();
|
|
29
|
+
});
|
|
19
30
|
|
|
20
31
|
// put the real XHR object back and clear the mocks after each test
|
|
21
32
|
// eslint-disable-next-line jest/no-hooks
|
|
@@ -25,6 +36,11 @@ describe("authentication hooks", () => {
|
|
|
25
36
|
expect.assertions(10);
|
|
26
37
|
|
|
27
38
|
xhrMock
|
|
39
|
+
.get(`/BeInformed`, (req, res) => {
|
|
40
|
+
expect(req.header("accept")).toBe(JSON_TYPE);
|
|
41
|
+
expect(req.header("Content-Type")).toBe(JSON_TYPE);
|
|
42
|
+
return res.status(200).body({ data: "ok" });
|
|
43
|
+
})
|
|
28
44
|
.get("/BeInformed/login", (req, res) => {
|
|
29
45
|
expect(req.header("accept")).toBe(JSON_TYPE);
|
|
30
46
|
expect(req.header("Content-Type")).toBe(
|
|
@@ -42,7 +58,13 @@ describe("authentication hooks", () => {
|
|
|
42
58
|
return res.status(200).body({ data: "ok" });
|
|
43
59
|
});
|
|
44
60
|
|
|
45
|
-
const store = mockStore({
|
|
61
|
+
const store = mockStore({
|
|
62
|
+
auth: {},
|
|
63
|
+
modularui: {},
|
|
64
|
+
router: { location: {} },
|
|
65
|
+
i18n: { locale: "en" },
|
|
66
|
+
});
|
|
67
|
+
|
|
46
68
|
/**
|
|
47
69
|
*/
|
|
48
70
|
const wrapper = ({ children }) => (
|
|
@@ -61,6 +83,14 @@ describe("authentication hooks", () => {
|
|
|
61
83
|
|
|
62
84
|
expect(store.getActions()).toStrictEqual([
|
|
63
85
|
{ type: "START_PROGRESS" },
|
|
86
|
+
expect.objectContaining({
|
|
87
|
+
type: "MODULARUI/FETCH",
|
|
88
|
+
payload: expect.objectContaining({
|
|
89
|
+
key: "application(/)(en)",
|
|
90
|
+
}),
|
|
91
|
+
}),
|
|
92
|
+
{ type: "START_PROGRESS" },
|
|
93
|
+
{ type: "FINISH_PROGRESS" },
|
|
64
94
|
{ type: "START_PROGRESS" },
|
|
65
95
|
expect.objectContaining({
|
|
66
96
|
type: "MODULARUI/FETCH",
|
|
@@ -85,7 +115,12 @@ describe("authentication hooks", () => {
|
|
|
85
115
|
return res.status(200).body({ data: "ok" });
|
|
86
116
|
});
|
|
87
117
|
|
|
88
|
-
const store = mockStore({
|
|
118
|
+
const store = mockStore({
|
|
119
|
+
auth: {},
|
|
120
|
+
modularui: {},
|
|
121
|
+
router: { location: {} },
|
|
122
|
+
i18n: { locale: "en" },
|
|
123
|
+
});
|
|
89
124
|
|
|
90
125
|
/**
|
|
91
126
|
*/
|
|
@@ -105,6 +140,14 @@ describe("authentication hooks", () => {
|
|
|
105
140
|
|
|
106
141
|
expect(store.getActions()).toStrictEqual([
|
|
107
142
|
{ type: "START_PROGRESS" },
|
|
143
|
+
expect.objectContaining({
|
|
144
|
+
type: "MODULARUI/FETCH",
|
|
145
|
+
payload: expect.objectContaining({
|
|
146
|
+
key: "application(/)(en)",
|
|
147
|
+
}),
|
|
148
|
+
}),
|
|
149
|
+
{ type: "START_PROGRESS" },
|
|
150
|
+
{ type: "FINISH_PROGRESS" },
|
|
108
151
|
{ type: "MODULARUI/RESET" },
|
|
109
152
|
{ type: "START_PROGRESS" },
|
|
110
153
|
expect.objectContaining({
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import { useSelector, useDispatch } from "react-redux";
|
|
3
3
|
|
|
4
|
-
import { getApplication } from "../redux/_modularui/ModularUISelectors";
|
|
5
4
|
import { login, logout, resetAuthErrors } from "../redux/actions";
|
|
6
5
|
|
|
7
6
|
import Cache from "../utils/browser/Cache";
|
|
8
7
|
import {
|
|
9
|
-
DEFAULT_AUTHENTICATION_TYPE,
|
|
10
8
|
getBasePath,
|
|
11
9
|
getBasePathServer,
|
|
12
10
|
INTERNAL_LOGIN_TYPE,
|
|
13
11
|
} from "../constants";
|
|
14
12
|
import { IllegalStateException } from "../exceptions";
|
|
15
13
|
import { Authenticate } from "../modularui";
|
|
14
|
+
import { useApplication } from "./useModularUIModel";
|
|
16
15
|
|
|
17
16
|
import type { ResetAuthErrorsAction } from "../redux/types";
|
|
18
17
|
import type { AuthenticationType } from "../models/types";
|
|
19
18
|
|
|
20
19
|
type LoginHook = {
|
|
21
20
|
isAuthenticated: boolean,
|
|
21
|
+
primaryAuthenticationType: AuthenticationType,
|
|
22
22
|
authenticationTypes: Array<AuthenticationType>,
|
|
23
23
|
errorMessage: ?string,
|
|
24
24
|
resetErrors: () => ResetAuthErrorsAction,
|
|
@@ -27,6 +27,7 @@ type LoginHook = {
|
|
|
27
27
|
};
|
|
28
28
|
type LogoutHook = {
|
|
29
29
|
isAuthenticated: boolean,
|
|
30
|
+
primaryAuthenticationType: AuthenticationType,
|
|
30
31
|
authenticationTypes: Array<AuthenticationType>,
|
|
31
32
|
logout: () => void,
|
|
32
33
|
logoutUrl: string,
|
|
@@ -39,16 +40,18 @@ export const useLogin = (): LoginHook => {
|
|
|
39
40
|
|
|
40
41
|
const dispatch = useDispatch();
|
|
41
42
|
|
|
42
|
-
const application =
|
|
43
|
+
const application = useApplication();
|
|
43
44
|
const auth = useSelector((state) => state.auth);
|
|
44
45
|
|
|
45
46
|
const isAuthenticated = application?.isLoggedIn ?? false;
|
|
46
47
|
|
|
48
|
+
const primaryAuthenticationType = Cache.getItem("primaryAuthenticationType");
|
|
49
|
+
|
|
47
50
|
return {
|
|
48
51
|
isAuthenticated,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
],
|
|
52
|
+
primaryAuthenticationType:
|
|
53
|
+
primaryAuthenticationType ?? application?.authenticationTypes[0],
|
|
54
|
+
authenticationTypes: application?.authenticationTypes ?? [],
|
|
52
55
|
errorMessage: auth.error,
|
|
53
56
|
resetErrors: () => dispatch(resetAuthErrors()),
|
|
54
57
|
login: (username: string, password: string) =>
|
|
@@ -77,18 +80,21 @@ export const useLogin = (): LoginHook => {
|
|
|
77
80
|
*/
|
|
78
81
|
export const useLogout = (): LogoutHook => {
|
|
79
82
|
const dispatch = useDispatch();
|
|
80
|
-
|
|
83
|
+
|
|
84
|
+
const application = useApplication();
|
|
81
85
|
|
|
82
86
|
const BASE_PATH = getBasePath();
|
|
83
87
|
|
|
84
88
|
const authenticate = new Authenticate();
|
|
85
89
|
|
|
90
|
+
const primaryAuthenticationType = Cache.getItem("primaryAuthenticationType");
|
|
91
|
+
|
|
86
92
|
const isAuthenticated = application?.isLoggedIn ?? false;
|
|
87
93
|
return {
|
|
88
94
|
isAuthenticated,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
],
|
|
95
|
+
primaryAuthenticationType:
|
|
96
|
+
primaryAuthenticationType ?? application?.authenticationTypes[0],
|
|
97
|
+
authenticationTypes: application?.authenticationTypes ?? [],
|
|
92
98
|
logout: () => {
|
|
93
99
|
const type = authenticate.authenticationType;
|
|
94
100
|
if (type === INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT) {
|
|
@@ -7,6 +7,8 @@ import { NotAllowedUriException } from "../../exceptions";
|
|
|
7
7
|
|
|
8
8
|
import { DEFAULT_AUTHENTICATION_TYPE } from "../../constants";
|
|
9
9
|
|
|
10
|
+
import Cache from "../../utils/browser/Cache";
|
|
11
|
+
|
|
10
12
|
import type { ModularUIModel, AuthenticationType } from "../types";
|
|
11
13
|
import type { ModularUIResponse } from "../../modularui";
|
|
12
14
|
import type LinkCollection from "../links/LinkCollection";
|
|
@@ -18,6 +20,13 @@ import type Href from "../href/Href";
|
|
|
18
20
|
export default class ApplicationModel extends ResourceModel {
|
|
19
21
|
_userServices: ?UserServicesModel;
|
|
20
22
|
|
|
23
|
+
constructor(modularuiResponse: ModularUIResponse) {
|
|
24
|
+
super(modularuiResponse);
|
|
25
|
+
|
|
26
|
+
// store authentication type in session cache, to make it available when application is no longer available (when not permitted for example)
|
|
27
|
+
Cache.setItem("primaryAuthenticationType", this.primaryAuthenticationType);
|
|
28
|
+
}
|
|
29
|
+
|
|
21
30
|
/**
|
|
22
31
|
* Retrieve type of model
|
|
23
32
|
*/
|
|
@@ -91,6 +100,14 @@ export default class ApplicationModel extends ResourceModel {
|
|
|
91
100
|
return [DEFAULT_AUTHENTICATION_TYPE];
|
|
92
101
|
}
|
|
93
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Returns the primary authentication type
|
|
105
|
+
* @returns {AuthenticationType}
|
|
106
|
+
*/
|
|
107
|
+
get primaryAuthenticationType(): AuthenticationType {
|
|
108
|
+
return this.authenticationTypes[0];
|
|
109
|
+
}
|
|
110
|
+
|
|
94
111
|
/**
|
|
95
112
|
* Getting the tab links
|
|
96
113
|
*/
|
|
@@ -3,9 +3,7 @@ import type { IConstraintModel } from "../../types";
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
*/
|
|
6
|
-
class PasswordThreeConsecutiveCharactersNotAllowedConstraint
|
|
7
|
-
implements IConstraintModel
|
|
8
|
-
{
|
|
6
|
+
class PasswordThreeConsecutiveCharactersNotAllowedConstraint implements IConstraintModel {
|
|
9
7
|
_maxSequence: number;
|
|
10
8
|
|
|
11
9
|
/**
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
const createUUID = (): string => {
|
|
5
5
|
let d = new Date().getTime();
|
|
6
6
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
7
|
-
const r = (d + Math.random() * 16) % 16 | 0;
|
|
7
|
+
const r = ((d + Math.random() * 16) % 16) | 0;
|
|
8
8
|
d = Math.floor(d / 16);
|
|
9
9
|
return (c === "x" ? r : (r & 0x3) | 0x8).toString(16);
|
|
10
10
|
});
|