@beinformed/ui 1.63.11 → 1.63.12

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 CHANGED
@@ -2,6 +2,13 @@
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.12](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.63.11...v1.63.12) (2025-12-08)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **authentication:** update `useApplication` usage ([4e210b5](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/4e210b564386f3b261175e0a0ffbfec62b6d7f0b))
11
+
5
12
  ## [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
13
 
7
14
 
@@ -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(() => xhrMock.setup());
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({ auth: {}, i18n: { locale: "en" } });
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",
@@ -5,12 +5,13 @@ import Cache from "../utils/browser/Cache";
5
5
  import { DEFAULT_AUTHENTICATION_TYPE, getBasePath, getBasePathServer, INTERNAL_LOGIN_TYPE } from "../constants";
6
6
  import { IllegalStateException } from "../exceptions";
7
7
  import { Authenticate } from "../modularui";
8
+ import { useApplication } from "./useModularUIModel";
8
9
  /**
9
10
  */
10
11
  export const useLogin = () => {
11
12
  Cache.setItem("isRedirectLogin", false);
12
13
  const dispatch = useDispatch();
13
- const application = useSelector(getApplication);
14
+ const application = useApplication();
14
15
  const auth = useSelector(state => state.auth);
15
16
  const isAuthenticated = application?.isLoggedIn ?? false;
16
17
  return {
@@ -13,6 +13,7 @@ import {
13
13
  } from "../constants";
14
14
  import { IllegalStateException } from "../exceptions";
15
15
  import { Authenticate } from "../modularui";
16
+ import { useApplication } from "./useModularUIModel";
16
17
 
17
18
  import type { ResetAuthErrorsAction } from "../redux/types";
18
19
  import type { AuthenticationType } from "../models/types";
@@ -39,7 +40,7 @@ export const useLogin = (): LoginHook => {
39
40
 
40
41
  const dispatch = useDispatch();
41
42
 
42
- const application = useSelector(getApplication);
43
+ const application = useApplication();
43
44
  const auth = useSelector((state) => state.auth);
44
45
 
45
46
  const isAuthenticated = application?.isLoggedIn ?? false;
@@ -1 +1 @@
1
- {"version":3,"file":"useAuthentication.js","names":["useSelector","useDispatch","getApplication","login","logout","resetAuthErrors","Cache","DEFAULT_AUTHENTICATION_TYPE","getBasePath","getBasePathServer","INTERNAL_LOGIN_TYPE","IllegalStateException","Authenticate","useLogin","setItem","dispatch","application","auth","state","isAuthenticated","isLoggedIn","authenticationTypes","errorMessage","error","resetErrors","username","password","redirectLogin","authenticationType","getItem","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 { getApplication } from \"../redux/_modularui/ModularUISelectors\";\nimport { login, logout, resetAuthErrors } from \"../redux/actions\";\n\nimport Cache from \"../utils/browser/Cache\";\nimport {\n DEFAULT_AUTHENTICATION_TYPE,\n getBasePath,\n getBasePathServer,\n INTERNAL_LOGIN_TYPE,\n} from \"../constants\";\nimport { IllegalStateException } from \"../exceptions\";\nimport { Authenticate } from \"../modularui\";\n\nimport type { ResetAuthErrorsAction } from \"../redux/types\";\nimport type { AuthenticationType } from \"../models/types\";\n\ntype LoginHook = {\n isAuthenticated: boolean,\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 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 = useSelector(getApplication);\n const auth = useSelector((state) => state.auth);\n\n const isAuthenticated = application?.isLoggedIn ?? false;\n\n return {\n isAuthenticated,\n authenticationTypes: application?.authenticationTypes ?? [\n DEFAULT_AUTHENTICATION_TYPE,\n ],\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 const application = useSelector(getApplication);\n\n const BASE_PATH = getBasePath();\n\n const authenticate = new Authenticate();\n\n const isAuthenticated = application?.isLoggedIn ?? false;\n return {\n isAuthenticated,\n authenticationTypes: application?.authenticationTypes ?? [\n DEFAULT_AUTHENTICATION_TYPE,\n ],\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.getLogoutU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Q,CAACX,MAAM,CAAC,CAAC,CAAC;MAC3B;IACF,CAAC;IACDwC,SAAS,EAAEP,YAAY,CAACM,YAAY,CAAC;EACvC,CAAC;AACH,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"useAuthentication.js","names":["useSelector","useDispatch","getApplication","login","logout","resetAuthErrors","Cache","DEFAULT_AUTHENTICATION_TYPE","getBasePath","getBasePathServer","INTERNAL_LOGIN_TYPE","IllegalStateException","Authenticate","useApplication","useLogin","setItem","dispatch","application","auth","state","isAuthenticated","isLoggedIn","authenticationTypes","errorMessage","error","resetErrors","username","password","redirectLogin","authenticationType","getItem","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 { getApplication } from \"../redux/_modularui/ModularUISelectors\";\nimport { login, logout, resetAuthErrors } from \"../redux/actions\";\n\nimport Cache from \"../utils/browser/Cache\";\nimport {\n DEFAULT_AUTHENTICATION_TYPE,\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 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 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 return {\n isAuthenticated,\n authenticationTypes: application?.authenticationTypes ?? [\n DEFAULT_AUTHENTICATION_TYPE,\n ],\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 const application = useSelector(getApplication);\n\n const BASE_PATH = getBasePath();\n\n const authenticate = new Authenticate();\n\n const isAuthenticated = application?.isLoggedIn ?? false;\n return {\n isAuthenticated,\n authenticationTypes: application?.authenticationTypes ?? [\n DEFAULT_AUTHENTICATION_TYPE,\n ],\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,cAAc,QAAQ,wCAAwC;AACvE,SAASC,KAAK,EAAEC,MAAM,EAAEC,eAAe,QAAQ,kBAAkB;AAEjE,OAAOC,KAAK,MAAM,wBAAwB;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";
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\n implements IConstraintModel\n{\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 PasswordThre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,CAAA,EAAY;IACnC,OAAO,KAAK;EACd;AACF;AAEA,eAAevB,sDAAsD","ignoreList":[]}
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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{ hash } from "hash-it";
2
2
  /**
3
3
  * https://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/
4
4
  */
@@ -1,5 +1,5 @@
1
1
  // @flow
2
- import hash from "hash-it";
2
+ import { hash } from "hash-it";
3
3
 
4
4
  import type Href from "../../models/href/Href";
5
5
  import type { SectionFragment } from "../../models";
@@ -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,OAAOA,IAAI,MAAM,SAAS;AAK1B;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":[]}
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,GAAG,CAACL,CAAC,GAAGM,IAAI,CAACC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC;IAC3CP,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":[]}
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":[]}
@@ -12,12 +12,13 @@ var _Cache = _interopRequireDefault(require("../utils/browser/Cache"));
12
12
  var _constants = require("../constants");
13
13
  var _exceptions = require("../exceptions");
14
14
  var _modularui = require("../modularui");
15
+ var _useModularUIModel = require("./useModularUIModel");
15
16
  /**
16
17
  */
17
18
  const useLogin = () => {
18
19
  _Cache.default.setItem("isRedirectLogin", false);
19
20
  const dispatch = (0, _reactRedux.useDispatch)();
20
- const application = (0, _reactRedux.useSelector)(_ModularUISelectors.getApplication);
21
+ const application = (0, _useModularUIModel.useApplication)();
21
22
  const auth = (0, _reactRedux.useSelector)(state => state.auth);
22
23
  const isAuthenticated = application?.isLoggedIn ?? false;
23
24
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"useAuthentication.js","names":["_reactRedux","require","_ModularUISelectors","_actions","_Cache","_interopRequireDefault","_constants","_exceptions","_modularui","useLogin","Cache","setItem","dispatch","useDispatch","application","useSelector","getApplication","auth","state","isAuthenticated","isLoggedIn","authenticationTypes","DEFAULT_AUTHENTICATION_TYPE","errorMessage","error","resetErrors","resetAuthErrors","login","username","password","redirectLogin","authenticationType","getItem","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 { getApplication } from \"../redux/_modularui/ModularUISelectors\";\nimport { login, logout, resetAuthErrors } from \"../redux/actions\";\n\nimport Cache from \"../utils/browser/Cache\";\nimport {\n DEFAULT_AUTHENTICATION_TYPE,\n getBasePath,\n getBasePathServer,\n INTERNAL_LOGIN_TYPE,\n} from \"../constants\";\nimport { IllegalStateException } from \"../exceptions\";\nimport { Authenticate } from \"../modularui\";\n\nimport type { ResetAuthErrorsAction } from \"../redux/types\";\nimport type { AuthenticationType } from \"../models/types\";\n\ntype LoginHook = {\n isAuthenticated: boolean,\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 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 = useSelector(getApplication);\n const auth = useSelector((state) => state.auth);\n\n const isAuthenticated = application?.isLoggedIn ?? false;\n\n return {\n isAuthenticated,\n authenticationTypes: application?.authenticationTypes ?? [\n DEFAULT_AUTHENTICATION_TYPE,\n ],\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 const application = useSelector(getApplication);\n\n const BASE_PATH = getBasePath();\n\n const authenticate = new Authenticate();\n\n const isAuthenticated = application?.isLoggedIn ?? false;\n return {\n isAuthenticated,\n authenticationTypes: application?.authenticationTypes ?? [\n DEFAULT_AUTHENTICATION_TYPE,\n ],\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,mBAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AAMA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AAoBA;AACA;AACO,MAAMQ,QAAQ,GAAGA,CAAA,KAAiB;EACvCC,cAAK,CAACC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,uBAAW,EAAC,CAAC;EAC9B,MAAMC,WAAW,GAAG,IAAAC,uBAAW,EAACC,kCAAc,CAAC;EAE/C,MAAM0B,SAAS,GAAG,IAAAC,sBAAW,EAAC,CAAC;EAE/B,MAAMC,YAAY,GAAG,IAAIC,uBAAY,CAAC,CAAC;EAEvC,MAAM1B,eAAe,GAAGL,WAAW,EAAEM,UAAU,IAAI,KAAK;EACxD,OAAO;IACLD,eAAe;IACfE,mBAAmB,EAAEP,WAAW,EAAEO,mBAAmB,IAAI,CACvDC,sCAA2B,CAC5B;IACDwB,MAAM,EAAEA,CAAA,KAAM;MACZ,MAAMC,IAAI,GAAGH,YAAY,CAACb,kBAAkB;MAC5C,IAAIgB,IAAI,KAAKC,8BAAmB,CAACC,cAAc,EAAE;QAC/CL,YAAY,CAACM,gBAAgB,CAAC,CAAC;MACjC,CAAC,MAAM,IAAIxC,cAAK,CAACsB,OAAO,CAAC,iBAAiB,CAAC,EAAE;QAC3C,MAAMmB,MAAM,GAAGf,MAAM,CAACC,QAAQ,CAACc,MAAM;QACrC,MAAMC,GAAG,GAAG,GAAGR,YAAY,CAACS,YAAY,CAAC,CAAC,QAAQF,MAAM,GAAGT,SAAS,EAAE;QACtEhC,cAAK,CAACC,OAAO,CAAC,iBAAiB,EAAE,KAAK,CAAC;QACvCyB,MAAM,CAACC,QAAQ,CAACC,MAAM,CAACc,GAAG,CAAC;MAC7B,CAAC,MAAM;QACL,OAAOxC,QAAQ,CAAC,IAAAkC,eAAM,EAAC,CAAC,CAAC;MAC3B;IACF,CAAC;IACDQ,SAAS,EAAEV,YAAY,CAACS,YAAY,CAAC;EACvC,CAAC;AACH,CAAC;AAACb,OAAA,CAAAC,SAAA,GAAAA,SAAA","ignoreList":[]}
1
+ {"version":3,"file":"useAuthentication.js","names":["_reactRedux","require","_ModularUISelectors","_actions","_Cache","_interopRequireDefault","_constants","_exceptions","_modularui","_useModularUIModel","useLogin","Cache","setItem","dispatch","useDispatch","application","useApplication","auth","useSelector","state","isAuthenticated","isLoggedIn","authenticationTypes","DEFAULT_AUTHENTICATION_TYPE","errorMessage","error","resetErrors","resetAuthErrors","login","username","password","redirectLogin","authenticationType","getItem","IllegalStateException","authentication","redirectUri","window","location","assign","getBasePathServer","exports","useLogout","getApplication","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 { getApplication } from \"../redux/_modularui/ModularUISelectors\";\nimport { login, logout, resetAuthErrors } from \"../redux/actions\";\n\nimport Cache from \"../utils/browser/Cache\";\nimport {\n DEFAULT_AUTHENTICATION_TYPE,\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 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 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 return {\n isAuthenticated,\n authenticationTypes: application?.authenticationTypes ?? [\n DEFAULT_AUTHENTICATION_TYPE,\n ],\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 const application = useSelector(getApplication);\n\n const BASE_PATH = getBasePath();\n\n const authenticate = new Authenticate();\n\n const isAuthenticated = application?.isLoggedIn ?? false;\n return {\n isAuthenticated,\n authenticationTypes: application?.authenticationTypes ?? [\n DEFAULT_AUTHENTICATION_TYPE,\n ],\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,mBAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AAMA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AACA,IAAAQ,kBAAA,GAAAR,OAAA;AAoBA;AACA;AACO,MAAMS,QAAQ,GAAGA,CAAA,KAAiB;EACvCC,cAAK,CAACC,OAAO,CAAC,iBAAiB,EAAE,KA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AAW,GAAG,IAAAG,uBAAW,EAACyB,kCAAc,CAAC;EAE/C,MAAMC,SAAS,GAAG,IAAAC,sBAAW,EAAC,CAAC;EAE/B,MAAMC,YAAY,GAAG,IAAIC,uBAAY,CAAC,CAAC;EAEvC,MAAM3B,eAAe,GAAGL,WAAW,EAAEM,UAAU,IAAI,KAAK;EACxD,OAAO;IACLD,eAAe;IACfE,mBAAmB,EAAEP,WAAW,EAAEO,mBAAmB,IAAI,CACvDC,sCAA2B,CAC5B;IACDyB,MAAM,EAAEA,CAAA,KAAM;MACZ,MAAMC,IAAI,GAAGH,YAAY,CAACd,kBAAkB;MAC5C,IAAIiB,IAAI,KAAKC,8BAAmB,CAACC,cAAc,EAAE;QAC/CL,YAAY,CAACM,gBAAgB,CAAC,CAAC;MACjC,CAAC,MAAM,IAAIzC,cAAK,CAACsB,OAAO,CAAC,iBAAiB,CAAC,EAAE;QAC3C,MAAMoB,MAAM,GAAGhB,MAAM,CAACC,QAAQ,CAACe,MAAM;QACrC,MAAMC,GAAG,GAAG,GAAGR,YAAY,CAACS,YAAY,CAAC,CAAC,QAAQF,MAAM,GAAGT,SAAS,EAAE;QACtEjC,cAAK,CAACC,OAAO,CAAC,iBAAiB,EAAE,KAAK,CAAC;QACvCyB,MAAM,CAACC,QAAQ,CAACC,MAAM,CAACe,GAAG,CAAC;MAC7B,CAAC,MAAM;QACL,OAAOzC,QAAQ,CAAC,IAAAmC,eAAM,EAAC,CAAC,CAAC;MAC3B;IACF,CAAC;IACDQ,SAAS,EAAEV,YAAY,CAACS,YAAY,CAAC;EACvC,CAAC;AACH,CAAC;AAACd,OAAA,CAAAC,SAAA,GAAAA,SAAA","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\n implements IConstraintModel\n{\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,CAE5D;EAGE;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,OAAO,0DAA0D;EACnE;;EAEA;AACF;EACE,IAAIJ,WAAWA,CAAA,EAAW;IACxB,OAAO,IAAI,CAACG,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,CAACP;IACvB,CAAC;EACH;;EAEA;AACF;EACEQ,kCAAkCA,CAACC,KAAa,EAAW;IAAA,IAAAC,QAAA;IACzD,OAAO,CAAC,IAAAC,OAAA,CAAAT,OAAA,EAAAQ,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,GAAG,IAAAC,OAAA,CAAAjB,OAAA,EAAAY,IAAI,EAAAD,IAAA,CAAJC,IAAI,EAAQ,IAAI,CAACd,WAAW,GAAG,CAAC,CAAC;MAClD,OAAO,IAAAoB,SAAA,CAAAlB,OAAA,EAAAO,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;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAtB,OAAA,GAEcJ,sDAAsD","ignoreList":[]}
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,OAAO,0DAA0D;EACnE;;EAEA;AACF;EACE,IAAIJ,WAAWA,CAAA,EAAW;IACxB,OAAO,IAAI,CAACG,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,CAACP;IACvB,CAAC;EACH;;EAEA;AACF;EACEQ,kCAAkCA,CAACC,KAAa,EAAW;IAAA,IAAAC,QAAA;IACzD,OAAO,CAAC,IAAAC,OAAA,CAAAT,OAAA,EAAAQ,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,GAAG,IAAAC,OAAA,CAAAjB,OAAA,EAAAY,IAAI,EAAAD,IAAA,CAAJC,IAAI,EAAQ,IAAI,CAACd,WAAW,GAAG,CAAC,CAAC;MAClD,OAAO,IAAAoB,SAAA,CAAAlB,OAAA,EAAAO,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;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAtB,OAAA,GAEcJ,sDAAsD","ignoreList":[]}
@@ -1,16 +1,15 @@
1
1
  "use strict";
2
2
 
3
- 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 = _interopRequireDefault(require("hash-it"));
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.default)(str);
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.default)({
21
+ return (0, _hashIt.hash)({
23
22
  hrefString,
24
23
  fragment
25
24
  });
26
25
  }
27
- return (0, _hashIt.default)(hrefString);
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","_interopRequireDefault","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,sBAAA,CAAAC,OAAA;AAKA;AACA;AACA;AACA,MAAMC,UAAU,GAAIC,GAAW,IAAa;EAC1C,OAAO,IAAAC,eAAI,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,eAAI,EAAC;MAAEK,UAAU;MAAED;IAAS,CAAC,CAAC;EACvC;EAEA,OAAO,IAAAJ,eAAI,EAACK,UAAU,CAAC;AACzB,CAAC;AAACJ,OAAA,CAAAC,kBAAA,GAAAA,kBAAA","ignoreList":[]}
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,GAAG,CAACL,CAAC,GAAGM,IAAI,CAACC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC;IAC3CP,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":[]}
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.11",
3
+ "version": "1.63.12",
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.4",
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": "^6.0.0",
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.0",
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.6.2",
135
- "react": "^19.2.0",
136
- "react-dom": "^19.2.0",
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.0",
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.0",
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(() => xhrMock.setup());
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({ auth: {}, i18n: { locale: "en" } });
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",
@@ -13,6 +13,7 @@ import {
13
13
  } from "../constants";
14
14
  import { IllegalStateException } from "../exceptions";
15
15
  import { Authenticate } from "../modularui";
16
+ import { useApplication } from "./useModularUIModel";
16
17
 
17
18
  import type { ResetAuthErrorsAction } from "../redux/types";
18
19
  import type { AuthenticationType } from "../models/types";
@@ -39,7 +40,7 @@ export const useLogin = (): LoginHook => {
39
40
 
40
41
  const dispatch = useDispatch();
41
42
 
42
- const application = useSelector(getApplication);
43
+ const application = useApplication();
43
44
  const auth = useSelector((state) => state.auth);
44
45
 
45
46
  const isAuthenticated = application?.isLoggedIn ?? false;
@@ -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,5 +1,5 @@
1
1
  // @flow
2
- import hash from "hash-it";
2
+ import { hash } from "hash-it";
3
3
 
4
4
  import type Href from "../../models/href/Href";
5
5
  import type { SectionFragment } from "../../models";
@@ -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
  });