@pagopa/selfcare-common-frontend 1.35.0 → 1.35.1

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.
Files changed (287) hide show
  1. package/CHANGELOG.md +875 -1
  2. package/README.md +34 -8
  3. package/examples/locale/en.d.ts +20 -0
  4. package/examples/locale/en.js +18 -0
  5. package/examples/locale/index.js +4 -0
  6. package/examples/locale/it.d.ts +20 -0
  7. package/examples/locale/it.js +19 -0
  8. package/{common-polyfill.d.ts → lib/common-polyfill.d.ts} +0 -1
  9. package/lib/common-polyfill.js +9 -0
  10. package/lib/components/BackComponent.d.ts +7 -0
  11. package/lib/components/BackComponent.js +8 -0
  12. package/lib/components/CustomAlert.d.ts +12 -0
  13. package/lib/components/CustomAlert.js +7 -0
  14. package/{components → lib/components}/CustomAvatar.d.ts +2 -3
  15. package/lib/components/CustomAvatar.js +13 -0
  16. package/{components → lib/components}/CustomPagination.d.ts +7 -3
  17. package/lib/components/CustomPagination.js +25 -0
  18. package/{components → lib/components}/EndingPage.d.ts +15 -3
  19. package/lib/components/EndingPage.js +4 -0
  20. package/lib/components/ErrorBoundary/ErrorBoundary.d.ts +11 -0
  21. package/lib/components/ErrorBoundary/ErrorBoundary.js +93 -0
  22. package/{components → lib/components}/ErrorBoundary/components/BlockingErrorPage.d.ts +2 -3
  23. package/lib/components/ErrorBoundary/components/BlockingErrorPage.js +11 -0
  24. package/{components → lib/components}/FilterModal.d.ts +3 -3
  25. package/lib/components/FilterModal.js +29 -0
  26. package/{components → lib/components}/Footer/Footer.d.ts +2 -3
  27. package/lib/components/Footer/Footer.js +179 -0
  28. package/{components → lib/components}/Footer/FooterConfig.js +5 -9
  29. package/{components → lib/components}/Header/Header.d.ts +11 -6
  30. package/lib/components/Header/Header.js +45 -0
  31. package/{components → lib/components}/Loading/LoadingOverlay.d.ts +1 -2
  32. package/lib/components/Loading/LoadingOverlay.js +13 -0
  33. package/lib/components/LoadingOverlayComponent.d.ts +7 -0
  34. package/lib/components/LoadingOverlayComponent.js +25 -0
  35. package/{components → lib/components}/NavigationBar.d.ts +5 -4
  36. package/lib/components/NavigationBar.js +17 -0
  37. package/{components → lib/components}/SessionModal.d.ts +3 -3
  38. package/lib/components/SessionModal.js +17 -0
  39. package/{components → lib/components}/TitleBox.d.ts +7 -7
  40. package/lib/components/TitleBox.js +9 -0
  41. package/{components → lib/components}/Toast.d.ts +3 -3
  42. package/lib/components/Toast.js +25 -0
  43. package/{components → lib/components}/ToastWrapper.d.ts +2 -2
  44. package/lib/components/ToastWrapper.js +12 -0
  45. package/{components → lib/components}/UnloadEventHandler.d.ts +1 -2
  46. package/lib/components/UnloadEventHandler.js +29 -0
  47. package/{components → lib/components}/UserNotifyHandle.d.ts +1 -2
  48. package/lib/components/UserNotifyHandle.js +62 -0
  49. package/{components → lib/components}/icons/CheckIllustrationIcon.d.ts +1 -2
  50. package/lib/components/icons/CheckIllustrationIcon.js +3 -0
  51. package/lib/components/icons/ConfirmIcon.js +4 -0
  52. package/{components → lib/components}/icons/ErrorIcon.d.ts +1 -2
  53. package/lib/components/icons/ErrorIcon.js +3 -0
  54. package/lib/components/icons/ErrorIconExclamation.js +4 -0
  55. package/lib/components/icons/FaultIcon.js +4 -0
  56. package/{components → lib/components}/icons/PagoPaIcon.d.ts +1 -2
  57. package/lib/components/icons/PagoPaIcon.js +3 -0
  58. package/{components → lib/components}/icons/PagoPaIconColored.d.ts +1 -2
  59. package/lib/components/icons/PagoPaIconColored.js +3 -0
  60. package/{components → lib/components}/icons/PagoPaMiniIcon.d.ts +1 -2
  61. package/lib/components/icons/PagoPaMiniIcon.js +3 -0
  62. package/lib/components/tests/FilterModal.test.d.ts +1 -0
  63. package/lib/components/tests/FilterModal.test.js +37 -0
  64. package/{config → lib/config}/env.d.ts +4 -1
  65. package/{config → lib/config}/env.js +13 -17
  66. package/lib/consentManagementConfigure.d.ts +1 -0
  67. package/{consentManagementConfigure.js → lib/consentManagementConfigure.js} +5 -8
  68. package/{decorators → lib/decorators}/__mocks__/withLogin.d.ts +1 -2
  69. package/lib/decorators/__mocks__/withLogin.js +18 -0
  70. package/{decorators → lib/decorators}/withLogin.d.ts +1 -2
  71. package/{decorators → lib/decorators}/withLogin.js +13 -18
  72. package/{decorators → lib/decorators}/withRetrievedValue.d.ts +1 -1
  73. package/{decorators → lib/decorators}/withRetrievedValue.js +9 -14
  74. package/lib/hooks/useErrorDispatcher.js +7 -0
  75. package/{hooks → lib/hooks}/useFakePagination.d.ts +3 -3
  76. package/{hooks → lib/hooks}/useFakePagination.js +9 -15
  77. package/lib/hooks/useFocus.d.ts +1 -0
  78. package/lib/hooks/useFocus.js +8 -0
  79. package/lib/hooks/useLiveAnnouncerWithRegion.d.ts +4 -0
  80. package/lib/hooks/useLiveAnnouncerWithRegion.js +19 -0
  81. package/lib/hooks/useLoading.js +10 -0
  82. package/lib/hooks/useLogin.js +40 -0
  83. package/lib/hooks/usePermissions.d.ts +7 -0
  84. package/lib/hooks/usePermissions.js +25 -0
  85. package/lib/hooks/useReduxCachedValue.d.ts +22 -0
  86. package/{hooks → lib/hooks}/useReduxCachedValue.js +10 -17
  87. package/{hooks → lib/hooks}/useUnloadEventInterceptor.d.ts +3 -3
  88. package/{hooks → lib/hooks}/useUnloadEventInterceptor.js +24 -32
  89. package/lib/hooks/useUserNotify.js +7 -0
  90. package/{index.d.ts → lib/index.d.ts} +11 -8
  91. package/lib/index.js +36 -0
  92. package/{locale/it.d.ts → lib/locale/de.d.ts} +4 -1
  93. package/{locale → lib/locale}/de.js +31 -31
  94. package/{locale → lib/locale}/en.d.ts +4 -1
  95. package/{locale → lib/locale}/en.js +30 -30
  96. package/{locale → lib/locale}/fr.d.ts +5 -2
  97. package/{locale → lib/locale}/fr.js +26 -26
  98. package/{locale/de.d.ts → lib/locale/it.d.ts} +8 -2
  99. package/{locale → lib/locale}/it.js +11 -8
  100. package/lib/locale/locale-utils.js +45 -0
  101. package/{locale → lib/locale}/sl.d.ts +5 -2
  102. package/{locale → lib/locale}/sl.js +31 -31
  103. package/{model → lib/model}/AppError.d.ts +1 -1
  104. package/lib/model/AppError.js +1 -0
  105. package/lib/model/JwtUser.d.ts +9 -0
  106. package/lib/model/JwtUser.js +1 -0
  107. package/{model → lib/model}/Page.d.ts +1 -1
  108. package/lib/model/Page.js +1 -0
  109. package/{model → lib/model}/PageRequest.d.ts +1 -1
  110. package/lib/model/PageRequest.js +1 -0
  111. package/{model → lib/model}/PageResource.d.ts +1 -1
  112. package/lib/model/PageResource.js +1 -0
  113. package/lib/model/User.d.ts +8 -0
  114. package/lib/model/User.js +1 -0
  115. package/{model → lib/model}/UserNotify.d.ts +1 -2
  116. package/lib/model/UserNotify.js +1 -0
  117. package/lib/redux/slices/appStateSlice.d.ts +58 -0
  118. package/{redux → lib/redux}/slices/appStateSlice.js +15 -9
  119. package/lib/redux/slices/permissionsSlice.d.ts +12 -0
  120. package/lib/redux/slices/permissionsSlice.js +23 -0
  121. package/lib/redux/slices/productsSlice.d.ts +204 -0
  122. package/lib/redux/slices/productsSlice.js +26 -0
  123. package/lib/redux/slices/userSlice.d.ts +36 -0
  124. package/lib/redux/slices/userSlice.js +17 -0
  125. package/{services → lib/services}/analyticsService.d.ts +2 -1
  126. package/{services → lib/services}/analyticsService.js +31 -28
  127. package/{services → lib/services}/assistanceService.d.ts +1 -1
  128. package/lib/services/assistanceService.js +14 -0
  129. package/lib/services/errorService.js +8 -0
  130. package/{utils → lib/utils}/api-utils.d.ts +3 -3
  131. package/{utils → lib/utils}/api-utils.js +28 -23
  132. package/lib/utils/constants.d.ts +67 -0
  133. package/lib/utils/constants.js +82 -0
  134. package/lib/utils/productId2ProductTitle.d.ts +1 -0
  135. package/lib/utils/productId2ProductTitle.js +13 -0
  136. package/lib/utils/routes-utils.js +2 -0
  137. package/{utils → lib/utils}/storage-utils.d.ts +3 -3
  138. package/{utils → lib/utils}/storage-utils.js +4 -12
  139. package/{utils → lib/utils}/storage.d.ts +6 -0
  140. package/lib/utils/storage.js +31 -0
  141. package/lib/utils/utils.d.ts +11 -0
  142. package/lib/utils/utils.js +148 -0
  143. package/{utils → lib/utils}/verifyChecksumMatchWithTaxCode.js +1 -6
  144. package/{utils → lib/utils}/verifyNameMatchWithTaxCode.d.ts +1 -1
  145. package/lib/utils/verifyNameMatchWithTaxCode.js +27 -0
  146. package/{utils → lib/utils}/verifySurnameMatchWithTaxCode.d.ts +1 -1
  147. package/lib/utils/verifySurnameMatchWithTaxCode.js +17 -0
  148. package/package.json +54 -79
  149. package/build.info +0 -2
  150. package/common-polyfill.js +0 -13
  151. package/common-polyfill.js.map +0 -1
  152. package/components/BackComponent.d.ts +0 -6
  153. package/components/BackComponent.js +0 -12
  154. package/components/BackComponent.js.map +0 -1
  155. package/components/CustomAvatar.js +0 -18
  156. package/components/CustomAvatar.js.map +0 -1
  157. package/components/CustomPagination.js +0 -31
  158. package/components/CustomPagination.js.map +0 -1
  159. package/components/EndingPage.js +0 -7
  160. package/components/EndingPage.js.map +0 -1
  161. package/components/ErrorBoundary/ErrorBoundary.d.ts +0 -11
  162. package/components/ErrorBoundary/ErrorBoundary.js +0 -98
  163. package/components/ErrorBoundary/ErrorBoundary.js.map +0 -1
  164. package/components/ErrorBoundary/components/BlockingErrorPage.js +0 -15
  165. package/components/ErrorBoundary/components/BlockingErrorPage.js.map +0 -1
  166. package/components/FilterModal.js +0 -37
  167. package/components/FilterModal.js.map +0 -1
  168. package/components/Footer/Footer.js +0 -213
  169. package/components/Footer/Footer.js.map +0 -1
  170. package/components/Footer/FooterConfig.js.map +0 -1
  171. package/components/Header/Header.js +0 -24
  172. package/components/Header/Header.js.map +0 -1
  173. package/components/Loading/LoadingOverlay.js +0 -18
  174. package/components/Loading/LoadingOverlay.js.map +0 -1
  175. package/components/LoadingOverlayComponent.d.ts +0 -7
  176. package/components/LoadingOverlayComponent.js +0 -20
  177. package/components/LoadingOverlayComponent.js.map +0 -1
  178. package/components/NavigationBar.js +0 -21
  179. package/components/NavigationBar.js.map +0 -1
  180. package/components/SessionModal.js +0 -21
  181. package/components/SessionModal.js.map +0 -1
  182. package/components/TitleBox.js +0 -13
  183. package/components/TitleBox.js.map +0 -1
  184. package/components/Toast.js +0 -29
  185. package/components/Toast.js.map +0 -1
  186. package/components/ToastWrapper.js +0 -16
  187. package/components/ToastWrapper.js.map +0 -1
  188. package/components/UnloadEventHandler.js +0 -35
  189. package/components/UnloadEventHandler.js.map +0 -1
  190. package/components/UserNotifyHandle.js +0 -67
  191. package/components/UserNotifyHandle.js.map +0 -1
  192. package/components/icons/CheckIllustrationIcon.js +0 -7
  193. package/components/icons/CheckIllustrationIcon.js.map +0 -1
  194. package/components/icons/ConfirmIcon.js +0 -7
  195. package/components/icons/ConfirmIcon.js.map +0 -1
  196. package/components/icons/ErrorIcon.js +0 -7
  197. package/components/icons/ErrorIcon.js.map +0 -1
  198. package/components/icons/ErrorIconExclamation.js +0 -7
  199. package/components/icons/ErrorIconExclamation.js.map +0 -1
  200. package/components/icons/FaultIcon.js +0 -7
  201. package/components/icons/FaultIcon.js.map +0 -1
  202. package/components/icons/PagoPaIcon.js +0 -7
  203. package/components/icons/PagoPaIcon.js.map +0 -1
  204. package/components/icons/PagoPaIconColored.js +0 -7
  205. package/components/icons/PagoPaIconColored.js.map +0 -1
  206. package/components/icons/PagoPaMiniIcon.js +0 -7
  207. package/components/icons/PagoPaMiniIcon.js.map +0 -1
  208. package/config/env.js.map +0 -1
  209. package/consentManagementConfigure.js.map +0 -1
  210. package/decorators/__mocks__/withLogin.js +0 -27
  211. package/decorators/__mocks__/withLogin.js.map +0 -1
  212. package/decorators/withLogin.js.map +0 -1
  213. package/decorators/withRetrievedValue.js.map +0 -1
  214. package/hooks/useErrorDispatcher.js +0 -11
  215. package/hooks/useErrorDispatcher.js.map +0 -1
  216. package/hooks/useFakePagination.js.map +0 -1
  217. package/hooks/useLoading.js +0 -14
  218. package/hooks/useLoading.js.map +0 -1
  219. package/hooks/useLogin.js +0 -44
  220. package/hooks/useLogin.js.map +0 -1
  221. package/hooks/useReduxCachedValue.d.ts +0 -14
  222. package/hooks/useReduxCachedValue.js.map +0 -1
  223. package/hooks/useUnloadEventInterceptor.js.map +0 -1
  224. package/hooks/useUserNotify.js +0 -11
  225. package/hooks/useUserNotify.js.map +0 -1
  226. package/index.js +0 -76
  227. package/index.js.map +0 -1
  228. package/locale/de.js.map +0 -1
  229. package/locale/en.js.map +0 -1
  230. package/locale/fr.js.map +0 -1
  231. package/locale/it.js.map +0 -1
  232. package/locale/locale-utils.js +0 -36
  233. package/locale/locale-utils.js.map +0 -1
  234. package/locale/sl.js.map +0 -1
  235. package/model/AppError.js +0 -3
  236. package/model/AppError.js.map +0 -1
  237. package/model/Page.js +0 -3
  238. package/model/Page.js.map +0 -1
  239. package/model/PageRequest.js +0 -3
  240. package/model/PageRequest.js.map +0 -1
  241. package/model/PageResource.js +0 -3
  242. package/model/PageResource.js.map +0 -1
  243. package/model/User.d.ts +0 -7
  244. package/model/User.js +0 -3
  245. package/model/User.js.map +0 -1
  246. package/model/UserNotify.js +0 -3
  247. package/model/UserNotify.js.map +0 -1
  248. package/redux/slices/appStateSlice.d.ts +0 -76
  249. package/redux/slices/appStateSlice.js.map +0 -1
  250. package/redux/slices/userSlice.d.ts +0 -18
  251. package/redux/slices/userSlice.js +0 -21
  252. package/redux/slices/userSlice.js.map +0 -1
  253. package/services/analyticsService.js.map +0 -1
  254. package/services/assistanceService.js +0 -20
  255. package/services/assistanceService.js.map +0 -1
  256. package/services/errorService.js +0 -13
  257. package/services/errorService.js.map +0 -1
  258. package/utils/api-utils.js.map +0 -1
  259. package/utils/constants.d.ts +0 -19
  260. package/utils/constants.js +0 -32
  261. package/utils/constants.js.map +0 -1
  262. package/utils/routes-utils.js +0 -7
  263. package/utils/routes-utils.js.map +0 -1
  264. package/utils/storage-utils.js.map +0 -1
  265. package/utils/storage.js +0 -9
  266. package/utils/storage.js.map +0 -1
  267. package/utils/utils.d.ts +0 -3
  268. package/utils/utils.js +0 -13
  269. package/utils/utils.js.map +0 -1
  270. package/utils/verifyChecksumMatchWithTaxCode.js.map +0 -1
  271. package/utils/verifyNameMatchWithTaxCode.js +0 -26
  272. package/utils/verifyNameMatchWithTaxCode.js.map +0 -1
  273. package/utils/verifySurnameMatchWithTaxCode.js +0 -23
  274. package/utils/verifySurnameMatchWithTaxCode.js.map +0 -1
  275. /package/{consentManagementConfigure.d.ts → examples/locale/index.d.ts} +0 -0
  276. /package/{components → lib/components}/Footer/FooterConfig.d.ts +0 -0
  277. /package/{components → lib/components}/icons/ConfirmIcon.d.ts +0 -0
  278. /package/{components → lib/components}/icons/ErrorIconExclamation.d.ts +0 -0
  279. /package/{components → lib/components}/icons/FaultIcon.d.ts +0 -0
  280. /package/{hooks → lib/hooks}/useErrorDispatcher.d.ts +0 -0
  281. /package/{hooks → lib/hooks}/useLoading.d.ts +0 -0
  282. /package/{hooks → lib/hooks}/useLogin.d.ts +0 -0
  283. /package/{hooks → lib/hooks}/useUserNotify.d.ts +0 -0
  284. /package/{locale → lib/locale}/locale-utils.d.ts +0 -0
  285. /package/{services → lib/services}/errorService.d.ts +0 -0
  286. /package/{utils → lib/utils}/routes-utils.d.ts +0 -0
  287. /package/{utils → lib/utils}/verifyChecksumMatchWithTaxCode.d.ts +0 -0
@@ -1,13 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractResponse = exports.buildFetchApi = exports.onRedirectToLogin = void 0;
4
- const Either_1 = require("fp-ts/lib/Either");
5
- const ts_commons_1 = require("@pagopa/ts-commons");
6
- const fetch_1 = require("@pagopa/ts-commons/lib/fetch");
7
- const env_1 = require("../config/env");
8
- const appStateSlice_1 = require("../redux/slices/appStateSlice");
1
+ import { agent } from '@pagopa/ts-commons';
2
+ import { AbortableFetch, setFetchTimeout, toFetch } from '@pagopa/ts-commons/lib/fetch';
3
+ import { isRight, toError } from 'fp-ts/lib/Either';
4
+ import { CONFIG } from '../config/env';
5
+ import { appStateActions } from '../redux/slices/appStateSlice';
6
+ import { isPagoPaUser } from './storage';
9
7
  /** To show an error popup to inform of the not valid session */
10
- const onRedirectToLogin = (store) => store.dispatch(appStateSlice_1.appStateActions.addError({
8
+ export const onRedirectToLogin = (store) => store.dispatch(appStateActions.addError({
11
9
  id: 'tokenNotValid',
12
10
  error: new Error(),
13
11
  techDescription: 'token expired or not valid',
@@ -16,37 +14,46 @@ const onRedirectToLogin = (store) => store.dispatch(appStateSlice_1.appStateActi
16
14
  displayableTitle: 'Sessione scaduta',
17
15
  displayableDescription: 'Stai per essere rediretto alla pagina di login...',
18
16
  }));
19
- exports.onRedirectToLogin = onRedirectToLogin;
20
17
  /** Return the implementation of fetch configured with a timeout */
21
- const buildFetchApi = (timeoutMs = 300000) => {
18
+ export const buildFetchApi = (timeoutMs = 300000) => {
22
19
  // Must be an https endpoint so we use an https agent
23
- const abortableFetch = (0, fetch_1.AbortableFetch)(ts_commons_1.agent.getHttpFetch(process.env));
24
- const fetchWithTimeout = (0, fetch_1.toFetch)((0, fetch_1.setFetchTimeout)(timeoutMs, abortableFetch));
20
+ const abortableFetch = AbortableFetch(agent.getHttpFetch(process.env));
21
+ const fetchWithTimeout = toFetch(setFetchTimeout(timeoutMs, abortableFetch));
25
22
  // tslint:disable-next-line: no-any
26
23
  return fetchWithTimeout;
27
24
  };
28
- exports.buildFetchApi = buildFetchApi;
25
+ const LOGIN_URL = isPagoPaUser() ? CONFIG.URL_FE.LOGOUT_GOOGLE : CONFIG.URL_FE.LOGOUT;
29
26
  /** Extract the response of a @pagopa/openapi-codegen-ts generated client rest invocation having status code successHttpStatus.
30
27
  If notValidTokenHttpStatus is not null and the returned status is equal to notValidTokenHttpStatus, it will call the onRedirectToLogin function and will schedule the redirect towards logout path.
31
28
  If notAuthorizedTokenHttpStatus is not null and the returned status is equal to notAuthorizedTokenHttpStatus, it will throw an Error with message "Operation not allowed".
32
29
  If emptyResponseHttpStatus is not null and the returned status is equal to emptyResponseHttpStatus, it will return a promise that resolve to null value.
33
30
  Other statuses will return will throw a generic error. */
34
- const extractResponse = async (response, successHttpStatus, onRedirectToLogin, notValidTokenHttpStatus = 401, notAuthorizedTokenHttpStatus = 403, emptyResponseHttpStatus = 404) => {
35
- if ((0, Either_1.isRight)(response)) {
36
- if (response.right.status === successHttpStatus) {
31
+ export const extractResponse = async (response, successHttpStatus, onRedirectToLogin, notValidTokenHttpStatus = 401, notAuthorizedTokenHttpStatus = 403, emptyResponseHttpStatus = 404) => {
32
+ const successCodes = Array.isArray(successHttpStatus) ? successHttpStatus : [successHttpStatus];
33
+ if (isRight(response)) {
34
+ if (successCodes.includes(response.right.status)) {
37
35
  return response.right.value;
38
36
  }
39
37
  else if (notValidTokenHttpStatus && response.right.status === notValidTokenHttpStatus) {
40
38
  onRedirectToLogin();
41
- window.setTimeout(() => window.location.assign(env_1.CONFIG.URL_FE.LOGOUT), 2000);
39
+ window.setTimeout(() => window.location.assign(LOGIN_URL), 2000);
42
40
  return new Promise(() => null);
43
41
  }
44
42
  else if (notAuthorizedTokenHttpStatus &&
45
43
  response.right.status === notAuthorizedTokenHttpStatus) {
46
- throw new Error(`Operation not allowed!`);
44
+ const error = new Error(`Operation not allowed!`);
45
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
46
+ // @ts-ignore
47
+ // eslint-disable-next-line functional/immutable-data
48
+ error.httpStatus = response.right.status;
49
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
50
+ // @ts-ignore
51
+ // eslint-disable-next-line functional/immutable-data
52
+ error.httpBody = response.right.value;
53
+ throw error;
47
54
  }
48
55
  else if (emptyResponseHttpStatus && response.right.status === emptyResponseHttpStatus) {
49
- return new Promise((resolve) => resolve(null));
56
+ return Promise.resolve(null);
50
57
  }
51
58
  else {
52
59
  console.error(JSON.stringify(response.right));
@@ -65,8 +72,6 @@ const extractResponse = async (response, successHttpStatus, onRedirectToLogin, n
65
72
  else {
66
73
  console.error('Something gone wrong while fetching data');
67
74
  console.error(JSON.stringify(response.left));
68
- throw (0, Either_1.toError)(response.left);
75
+ throw toError(response.left);
69
76
  }
70
77
  };
71
- exports.extractResponse = extractResponse;
72
- //# sourceMappingURL=api-utils.js.map
@@ -0,0 +1,67 @@
1
+ export declare const LOADING_TASK_LOGIN_CHECK = "LOGIN_CHECK";
2
+ export declare const LOADING_TASK_RETRIEVE_CACHED_VALUES = "RETRIEVE_CACHED_VALUES";
3
+ export type UserRole = 'ADMIN' | 'LIMITED' | 'ADMIN_EA';
4
+ export declare const emailRegexp: RegExp;
5
+ /** The short and long labels used for the roles of selfcare's projects */
6
+ export declare const roleLabels: {
7
+ [key in UserRole]: {
8
+ shortLabelKey: string;
9
+ longLabelKey: string;
10
+ descriptionKey: string;
11
+ };
12
+ };
13
+ /** The short and long labels used for the roles of PNPG */
14
+ export declare const pnpgRoleLabels: {
15
+ [key in UserRole]: {
16
+ shortLabelKey: string;
17
+ longLabelKey: string;
18
+ descriptionKey: string;
19
+ };
20
+ };
21
+ export declare enum Actions {
22
+ ManageProductGroups = "Selc:ManageProductGroups",
23
+ UpdateProductUsers = "Selc:UpdateProductUsers",
24
+ DeleteProductUsers = "Selc:DeleteProductUsers",
25
+ CreateProductUsers = "Selc:CreateProductUsers",
26
+ ListProductUsers = "Selc:ListProductUsers",
27
+ ListAllProductUsers = "Selc:ListAllProductUsers",
28
+ ListProductGroups = "Selc:ListProductGroups",
29
+ ListAllProductGroups = "Selc:ListAllProductGroups",
30
+ ViewDelegations = "Selc:ViewDelegations",
31
+ CreateDelegation = "Selc:CreateDelegation",
32
+ ViewManagedInstitutions = "Selc:ViewManagedInstitutions",
33
+ AccessProductBackoffice = "Selc:AccessProductBackoffice",
34
+ AccessProductBackofficeAdmin = "Selc:AccessProductBackofficeAdmin",
35
+ ListActiveProducts = "Selc:ListActiveProducts",
36
+ ListAvailableProducts = "Selc:ListAvailableProducts",
37
+ RequestProductAccess = "Selc:RequestProductAccess",
38
+ ViewBilling = "Selc:ViewBilling",
39
+ UploadLogo = "Selc:UploadLogo",
40
+ UpdateInstitution = "Selc:UpdateInstitutionData",
41
+ ViewContract = "Selc:ViewContract",
42
+ UpdateGeoTaxonomy = "Selc:UpdateGeoTaxonomy"
43
+ }
44
+ export declare const PRODUCT_IDS: {
45
+ PAGOPA: string;
46
+ DASHBOARD_PSP: string;
47
+ IO: string;
48
+ IO_PREMIUM: string;
49
+ SEND: string;
50
+ SEND_DEV: string;
51
+ INTEROP: string;
52
+ INTEROP_ATTESTAZIONE: string;
53
+ INTEROP_COLLAUDO: string;
54
+ IDPAY: string;
55
+ IDPAY_MERCHANT: string;
56
+ IO_SIGN: string;
57
+ FD: string;
58
+ FD_GARANTITO: string;
59
+ CIBAN: string;
60
+ CGN: string;
61
+ };
62
+ export declare const ALLOWED_PREFIXES: string[];
63
+ /**
64
+ * Validates if a product ID matches our allowed prefixes.
65
+ * @param productId - The ID from the FE or API
66
+ */
67
+ export declare const isProductAllowed: (productId: string) => boolean;
@@ -0,0 +1,82 @@
1
+ export const LOADING_TASK_LOGIN_CHECK = 'LOGIN_CHECK';
2
+ export const LOADING_TASK_RETRIEVE_CACHED_VALUES = 'RETRIEVE_CACHED_VALUES';
3
+ export const emailRegexp = new RegExp('^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,6}$');
4
+ const commonRolesAdminLabels = {
5
+ shortLabelKey: 'common.roles.admin.shortLabel',
6
+ longLabelKey: 'common.roles.admin.longLabel',
7
+ descriptionKey: 'common.roles.admin.description',
8
+ };
9
+ /** The short and long labels used for the roles of selfcare's projects */
10
+ export const roleLabels = {
11
+ ADMIN: commonRolesAdminLabels,
12
+ ADMIN_EA: commonRolesAdminLabels,
13
+ LIMITED: {
14
+ shortLabelKey: 'common.roles.limited.shortLabel',
15
+ longLabelKey: 'common.roles.limited.longLabel',
16
+ descriptionKey: 'common.roles.limited.description',
17
+ },
18
+ };
19
+ const commonRolesPnpgAdminLabels = {
20
+ shortLabelKey: 'common.pnpgRoles.admin.shortLabel',
21
+ longLabelKey: 'common.pnpgRoles.admin.longLabel',
22
+ descriptionKey: 'common.pnpgRoles.admin.description',
23
+ };
24
+ /** The short and long labels used for the roles of PNPG */
25
+ export const pnpgRoleLabels = {
26
+ ADMIN: commonRolesPnpgAdminLabels,
27
+ ADMIN_EA: commonRolesPnpgAdminLabels,
28
+ LIMITED: {
29
+ shortLabelKey: 'common.pnpgRoles.limited.shortLabel',
30
+ longLabelKey: 'common.pnpgRoles.limited.longLabel',
31
+ descriptionKey: 'common.pnpgRoles.limited.description',
32
+ },
33
+ };
34
+ export var Actions;
35
+ (function (Actions) {
36
+ Actions["ManageProductGroups"] = "Selc:ManageProductGroups";
37
+ Actions["UpdateProductUsers"] = "Selc:UpdateProductUsers";
38
+ Actions["DeleteProductUsers"] = "Selc:DeleteProductUsers";
39
+ Actions["CreateProductUsers"] = "Selc:CreateProductUsers";
40
+ Actions["ListProductUsers"] = "Selc:ListProductUsers";
41
+ Actions["ListAllProductUsers"] = "Selc:ListAllProductUsers";
42
+ Actions["ListProductGroups"] = "Selc:ListProductGroups";
43
+ Actions["ListAllProductGroups"] = "Selc:ListAllProductGroups";
44
+ Actions["ViewDelegations"] = "Selc:ViewDelegations";
45
+ Actions["CreateDelegation"] = "Selc:CreateDelegation";
46
+ Actions["ViewManagedInstitutions"] = "Selc:ViewManagedInstitutions";
47
+ Actions["AccessProductBackoffice"] = "Selc:AccessProductBackoffice";
48
+ Actions["AccessProductBackofficeAdmin"] = "Selc:AccessProductBackofficeAdmin";
49
+ Actions["ListActiveProducts"] = "Selc:ListActiveProducts";
50
+ Actions["ListAvailableProducts"] = "Selc:ListAvailableProducts";
51
+ Actions["RequestProductAccess"] = "Selc:RequestProductAccess";
52
+ Actions["ViewBilling"] = "Selc:ViewBilling";
53
+ Actions["UploadLogo"] = "Selc:UploadLogo";
54
+ Actions["UpdateInstitution"] = "Selc:UpdateInstitutionData";
55
+ Actions["ViewContract"] = "Selc:ViewContract";
56
+ Actions["UpdateGeoTaxonomy"] = "Selc:UpdateGeoTaxonomy";
57
+ })(Actions || (Actions = {}));
58
+ export const PRODUCT_IDS = {
59
+ PAGOPA: 'prod-pagopa',
60
+ DASHBOARD_PSP: 'prod-dashboard-psp',
61
+ IO: 'prod-io',
62
+ IO_PREMIUM: 'prod-io-premium',
63
+ SEND: 'prod-pn',
64
+ SEND_DEV: 'prod-pn-dev',
65
+ INTEROP: 'prod-interop',
66
+ INTEROP_ATTESTAZIONE: 'prod-interop-atst',
67
+ INTEROP_COLLAUDO: 'prod-interop-collaudo',
68
+ IDPAY: 'prod-idpay',
69
+ IDPAY_MERCHANT: 'prod-idpay-merchant',
70
+ IO_SIGN: 'prod-io-sign',
71
+ FD: 'prod-fd',
72
+ FD_GARANTITO: 'prod-fd-garantito',
73
+ CIBAN: 'prod-ciban',
74
+ CGN: 'prod-cgn',
75
+ };
76
+ // TODO remove this. Moved this logic into env files
77
+ export const ALLOWED_PREFIXES = ['prod-interop', 'prod-pn'];
78
+ /**
79
+ * Validates if a product ID matches our allowed prefixes.
80
+ * @param productId - The ID from the FE or API
81
+ */
82
+ export const isProductAllowed = (productId) => ALLOWED_PREFIXES.some((prefix) => productId.startsWith(prefix));
@@ -0,0 +1 @@
1
+ export declare const productId2ProductTitle: (productId: string) => string;
@@ -0,0 +1,13 @@
1
+ export const productId2ProductTitle = (productId) => {
2
+ const productMap = {
3
+ 'prod-io': 'IO',
4
+ 'prod-pn': 'SEND - Servizio Notifiche Digitali',
5
+ 'prod-interop': 'Interoperabilità',
6
+ 'prod-pagopa': 'Piattaforma pagoPA',
7
+ 'prod-idpay': 'IDPay',
8
+ 'prod-cgn': 'Carta Giovani',
9
+ 'prod-io-sign': 'Firma con IO',
10
+ 'prod-fd': 'Fideiussioni Digitali',
11
+ };
12
+ return productMap[productId];
13
+ };
@@ -0,0 +1,2 @@
1
+ /** It will resolve the path variables in path using the provided map */
2
+ export const resolvePathVariables = (path, pathVariables) => Object.keys(pathVariables).reduce((result, key) => result.replace(`:${key}`, pathVariables[key]), path);
@@ -1,12 +1,12 @@
1
- declare type StorageValue = string | number | object;
2
- declare type StorageValueType = 'string' | 'number' | 'object';
1
+ type StorageValue = string | number | object;
2
+ type StorageValueType = 'string' | 'number' | 'object';
3
3
  /** It will delete a key from the session storage. If local is true, it will use the local session storage instead. */
4
4
  export declare function storageDelete(key: string, local?: boolean): void;
5
5
  /** It will store a key/value pair in the session storage. If local is true, it will use the local session storage instead. */
6
6
  export declare function storageWrite(key: string, value: StorageValue, type: StorageValueType, local?: boolean): void;
7
7
  /** It will read a key from the session storage. If local is true, it will use the local session storage instead. */
8
8
  export declare function storageRead(key: string, type: StorageValueType, local?: boolean): any;
9
- export declare type StorageOps<T> = {
9
+ export type StorageOps<T> = {
10
10
  delete: () => void;
11
11
  read: () => T;
12
12
  write: (value: T) => void;
@@ -1,14 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.storageOpsBuilder = exports.storageRead = exports.storageWrite = exports.storageDelete = void 0;
4
1
  /** It will delete a key from the session storage. If local is true, it will use the local session storage instead. */
5
- function storageDelete(key, local) {
2
+ export function storageDelete(key, local) {
6
3
  const storage = local ? window.localStorage : window.sessionStorage;
7
4
  storage.removeItem(key);
8
5
  }
9
- exports.storageDelete = storageDelete;
10
6
  /** It will store a key/value pair in the session storage. If local is true, it will use the local session storage instead. */
11
- function storageWrite(key, value, type, local) {
7
+ export function storageWrite(key, value, type, local) {
12
8
  const stringifyFn = {
13
9
  string: () => value,
14
10
  number: () => String(value),
@@ -18,9 +14,8 @@ function storageWrite(key, value, type, local) {
18
14
  const storage = local ? window.localStorage : window.sessionStorage;
19
15
  storage.setItem(key, stringified);
20
16
  }
21
- exports.storageWrite = storageWrite;
22
17
  /** It will read a key from the session storage. If local is true, it will use the local session storage instead. */
23
- function storageRead(key, type, local) {
18
+ export function storageRead(key, type, local) {
24
19
  const storage = local ? window.localStorage : window.sessionStorage;
25
20
  const value = storage.getItem(key);
26
21
  if (value === null) {
@@ -33,14 +28,11 @@ function storageRead(key, type, local) {
33
28
  };
34
29
  return parseFn[type]();
35
30
  }
36
- exports.storageRead = storageRead;
37
31
  /** Build an object with a complete set of operation to perform on the same key */
38
- function storageOpsBuilder(key, type, local) {
32
+ export function storageOpsBuilder(key, type, local) {
39
33
  return {
40
34
  delete: () => storageDelete(key, local),
41
35
  read: () => storageRead(key, type, local),
42
36
  write: (value) => storageWrite(key, value, type, local),
43
37
  };
44
38
  }
45
- exports.storageOpsBuilder = storageOpsBuilder;
46
- //# sourceMappingURL=storage-utils.js.map
@@ -1,5 +1,11 @@
1
1
  import { User } from '../model/User';
2
+ import { JwtUser } from '../model/JwtUser';
2
3
  /** An object containing a complete set of operation on the storage regarding the key used to store in the storage the loggedUser token in selfcare projects */
3
4
  export declare const storageTokenOps: import("./storage-utils").StorageOps<string>;
4
5
  /** An object containing a complete set of operation on the storage regarding the key used to store in the storage the loggedUser in selfcare projects */
5
6
  export declare const storageUserOps: import("./storage-utils").StorageOps<User>;
7
+ /** Decode and then convert the jwt into a JWTUser object */
8
+ export declare const parseJwt: (token: string) => JwtUser | null;
9
+ /** Determines whether the token has expired */
10
+ export declare const isExpiredToken: (token: string) => boolean;
11
+ export declare const isPagoPaUser: () => boolean;
@@ -0,0 +1,31 @@
1
+ import { storageOpsBuilder } from './storage-utils';
2
+ /** An object containing a complete set of operation on the storage regarding the key used to store in the storage the loggedUser token in selfcare projects */
3
+ export const storageTokenOps = storageOpsBuilder('token', 'string', true);
4
+ /** An object containing a complete set of operation on the storage regarding the key used to store in the storage the loggedUser in selfcare projects */
5
+ export const storageUserOps = storageOpsBuilder('user', 'object', true);
6
+ function decodeUTF8(binary) {
7
+ const bytes = new Uint8Array(binary.length);
8
+ // eslint-disable-next-line functional/no-let
9
+ for (let b = 0; b < bytes.length; ++b) {
10
+ // eslint-disable-next-line functional/immutable-data
11
+ bytes[b] = binary.charCodeAt(b);
12
+ }
13
+ const decoder = new TextDecoder('utf-8');
14
+ return decoder.decode(bytes);
15
+ }
16
+ /** Decode and then convert the jwt into a JWTUser object */
17
+ export const parseJwt = (token) => {
18
+ try {
19
+ return JSON.parse(decodeUTF8(atob(token.split('.')[1])));
20
+ }
21
+ catch (e) {
22
+ return null;
23
+ }
24
+ };
25
+ /** Determines whether the token has expired */
26
+ export const isExpiredToken = (token) => {
27
+ const jwtUser = parseJwt(token);
28
+ const tokenExpDate = new Date(Number(jwtUser.exp) * 1000);
29
+ return new Date() >= tokenExpDate;
30
+ };
31
+ export const isPagoPaUser = () => storageUserOps.read()?.iss === 'PAGOPA';
@@ -0,0 +1,11 @@
1
+ export declare const formatDateAsLongString: (date: Date) => string;
2
+ export declare const specialCharacters: {
3
+ [key: string]: string;
4
+ };
5
+ export declare const specialChar2NormalChar: (char: string) => string;
6
+ export declare const acceptedVowels: RegExp;
7
+ export declare const acceptedConsonants: RegExp;
8
+ export declare const isPecEmail: (email: string) => boolean;
9
+ type AppArea = 'imprese' | 'ar_backstage' | 'area_riservata';
10
+ export declare const getAppArea: () => AppArea;
11
+ export {};
@@ -0,0 +1,148 @@
1
+ import { isPagoPaUser } from './storage';
2
+ export const formatDateAsLongString = (date) => {
3
+ const ye = new Intl.DateTimeFormat('it', { year: 'numeric' }).format(date);
4
+ const mo = new Intl.DateTimeFormat('it', { month: 'long' }).format(date);
5
+ const da = new Intl.DateTimeFormat('it', { day: '2-digit' }).format(date);
6
+ return `${da} ${mo} ${ye}`;
7
+ };
8
+ export const specialCharacters = {
9
+ À: 'A',
10
+ Á: 'A',
11
+ Â: 'A',
12
+ Ã: 'A',
13
+ Ä: 'A',
14
+ Å: 'A',
15
+ Æ: 'AE',
16
+ Ç: 'C',
17
+ È: 'E',
18
+ É: 'E',
19
+ Ê: 'E',
20
+ Ë: 'E',
21
+ Ì: 'I',
22
+ Í: 'I',
23
+ Î: 'I',
24
+ Ï: 'I',
25
+ Ð: 'D',
26
+ Ñ: 'N',
27
+ Ò: 'O',
28
+ Ó: 'O',
29
+ Ô: 'O',
30
+ Õ: 'O',
31
+ Ö: 'O',
32
+ Ø: 'O',
33
+ Ù: 'U',
34
+ Ú: 'U',
35
+ Û: 'U',
36
+ Ü: 'U',
37
+ Ý: 'Y',
38
+ Þ: 'TH',
39
+ ß: 'SS',
40
+ Ā: 'A',
41
+ Ē: 'E',
42
+ Ī: 'I',
43
+ Ō: 'O',
44
+ Ū: 'U',
45
+ Ų: 'U',
46
+ Ĺ: 'L',
47
+ Ŕ: 'R',
48
+ Ŝ: 'S',
49
+ Ţ: 'T',
50
+ Ŵ: 'W',
51
+ Ŷ: 'Y',
52
+ Ź: 'Z',
53
+ Ż: 'Z',
54
+ Ẑ: 'Z',
55
+ Ẓ: 'Z',
56
+ Ẕ: 'E',
57
+ Ğ: 'G',
58
+ İ: 'I',
59
+ Ş: 'S',
60
+ Ț: 'T',
61
+ Ă: 'A',
62
+ Ḩ: 'H',
63
+ Ṧ: 'S',
64
+ ẞ: 'B',
65
+ Ȳ: 'Y',
66
+ Α: 'A',
67
+ Β: 'B',
68
+ Γ: 'G',
69
+ Δ: 'D',
70
+ Ε: 'E',
71
+ Ζ: 'Z',
72
+ Η: 'H',
73
+ Θ: 'TH',
74
+ Ι: 'I',
75
+ Κ: 'K',
76
+ Ǩ: 'K',
77
+ Λ: 'L',
78
+ Μ: 'M',
79
+ Ν: 'N',
80
+ Ξ: 'X',
81
+ Ο: 'O',
82
+ Π: 'P',
83
+ Ρ: 'R',
84
+ Σ: 'S',
85
+ Τ: 'T',
86
+ Υ: 'Y',
87
+ Φ: 'F',
88
+ Χ: 'CH',
89
+ Ψ: 'PS',
90
+ Ω: 'O',
91
+ א: 'A',
92
+ ב: 'B',
93
+ ג: 'G',
94
+ ד: 'D',
95
+ أ: 'A',
96
+ ج: 'J',
97
+ ɐ: 'a',
98
+ ʍ: 'w',
99
+ ɥ: 'h',
100
+ ɲ: 'n',
101
+ Ž: 'Z',
102
+ Œ: 'OE',
103
+ Ǟ: 'A',
104
+ Ǽ: 'AE',
105
+ Ǣ: 'AE',
106
+ Š: 'S',
107
+ Nj: 'N',
108
+ Ǧ: 'G',
109
+ Ḃ: 'B',
110
+ Ḋ: 'D',
111
+ Ḫ: 'H',
112
+ Ķ: 'K',
113
+ Ḻ: 'L',
114
+ Ḵ: 'K',
115
+ Ṅ: 'N',
116
+ Ṯ: 'T',
117
+ Ɓ: 'B',
118
+ Ƈ: 'C',
119
+ Ɣ: 'G',
120
+ Ɲ: 'N',
121
+ Ƥ: 'P',
122
+ Ƨ: 'S',
123
+ Ƭ: 'T',
124
+ Ʋ: 'V',
125
+ Ƴ: 'Y',
126
+ Ƶ: 'Z',
127
+ Č: 'C',
128
+ };
129
+ export const specialChar2NormalChar = (char) => specialCharacters[char] || char;
130
+ export const acceptedVowels = /[aeiouàèìòùáéíóúäëïöüâêîôûæœǝɐɑɒ]/gi;
131
+ export const acceptedConsonants = /[bcdfghjklmnpqrstvwxyzñçčšžǩßḃḍḫķḻḳṅṯẓẟẝƁƇƔƝƤƧƬƲƳƵʍʜʎɹɾʃʒʔɲ]/gi;
132
+ const PEC_PATTERNS = [/@pec\./i, /@postecert\./i, /@legalmail\./i];
133
+ export const isPecEmail = (email) => PEC_PATTERNS.some((pattern) => pattern.test(email));
134
+ const IMPRESE_URL_PREFIXES = [
135
+ 'https://imprese.notifichedigitali.it',
136
+ 'https://imprese.uat.notifichedigitali.it',
137
+ 'https://pnpg.dev.selfcare.pagopa.it',
138
+ ];
139
+ export const getAppArea = () => {
140
+ const currentUrl = window.location.origin + window.location.pathname;
141
+ if (IMPRESE_URL_PREFIXES.some((prefix) => currentUrl.startsWith(prefix))) {
142
+ return 'imprese';
143
+ }
144
+ if (isPagoPaUser()) {
145
+ return 'ar_backstage';
146
+ }
147
+ return 'area_riservata';
148
+ };
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.verifyChecksumMatchWithTaxCode = void 0;
4
- const verifyChecksumMatchWithTaxCode = (fiscalCode) => {
1
+ export const verifyChecksumMatchWithTaxCode = (fiscalCode) => {
5
2
  const charactersArray = [...fiscalCode.toLocaleUpperCase()];
6
3
  const onlyEvenFiscalCodeElements = charactersArray.filter((_c, i) => i % 2 !== 0);
7
4
  const onlyOddFiscalCodeElements = charactersArray.filter((_c, i) => i % 2 === 0);
@@ -13,7 +10,6 @@ const verifyChecksumMatchWithTaxCode = (fiscalCode) => {
13
10
  const resultingChecksumFromConversion = number2ChecksumConverter(number2Convert2Checksum);
14
11
  return resultingChecksumFromConversion !== insertedCheckSum;
15
12
  };
16
- exports.verifyChecksumMatchWithTaxCode = verifyChecksumMatchWithTaxCode;
17
13
  const evenCharactersConverter2Numbers = (evenCharacters) => {
18
14
  const conversionMap = {
19
15
  '0': 0,
@@ -129,4 +125,3 @@ const number2ChecksumConverter = (remainder) => {
129
125
  };
130
126
  return conversionMap[remainder];
131
127
  };
132
- //# sourceMappingURL=verifyChecksumMatchWithTaxCode.js.map
@@ -3,4 +3,4 @@
3
3
  * It covers the possible cases and return: TRUE, when the three letters of name in taxCode doesn't match
4
4
  * with the name entered by the user, otherwise FALSE when they match.
5
5
  * */
6
- export declare const verifyNameMatchWithTaxCode: (name: string, fiscalCode?: string | undefined) => string | false | undefined;
6
+ export declare const verifyNameMatchWithTaxCode: (name: string, fiscalCode?: string) => boolean | "" | undefined;
@@ -0,0 +1,27 @@
1
+ /** It allows you to verify that the name that the user would be entering corresponds or not with the
2
+ * characters given to the name in the taxcode.
3
+ * It covers the possible cases and return: TRUE, when the three letters of name in taxCode doesn't match
4
+ * with the name entered by the user, otherwise FALSE when they match.
5
+ * */
6
+ import { acceptedConsonants, acceptedVowels, specialChar2NormalChar } from './utils';
7
+ export const verifyNameMatchWithTaxCode = (name, fiscalCode) => {
8
+ const fiscalCodeName = fiscalCode?.substring(3, 6).toUpperCase();
9
+ const consonantsName = name?.match(acceptedConsonants)
10
+ ? name
11
+ ?.toUpperCase()
12
+ ?.match(acceptedConsonants)
13
+ ?.map(specialChar2NormalChar)
14
+ ?.join('')
15
+ .replace(/\s/g, '')
16
+ .replace(/'/g, '')
17
+ .replace(/-/g, '')
18
+ : '';
19
+ const fiscalCodeConsonantName = consonantsName && consonantsName.length >= 4
20
+ ? `${consonantsName?.slice(0, 1)}${consonantsName?.slice(2, 4)}`
21
+ : consonantsName;
22
+ const vowelsName = name?.match(acceptedVowels)
23
+ ? name?.toUpperCase()?.match(acceptedVowels)?.map(specialChar2NormalChar).join('')
24
+ : '';
25
+ const expectedFiscalCodeName = `${fiscalCodeConsonantName}${vowelsName}XX`.substring(0, 3);
26
+ return fiscalCodeName && fiscalCodeName !== expectedFiscalCodeName;
27
+ };
@@ -3,4 +3,4 @@
3
3
  * It covers the possible cases and return: TRUE, when the three letters of surname in taxCode doesn't match
4
4
  * with the surname entered by the user, otherwise FALSE when they match.
5
5
  * */
6
- export declare const verifySurnameMatchWithTaxCode: (surname: string, fiscalCode?: string | undefined) => string | false | undefined;
6
+ export declare const verifySurnameMatchWithTaxCode: (surname: string, fiscalCode?: string) => boolean | "" | undefined;
@@ -0,0 +1,17 @@
1
+ /** It allows you to verify that the surname that the user would be entering corresponds or not with the
2
+ * characters given to the surname in the taxcode.
3
+ * It covers the possible cases and return: TRUE, when the three letters of surname in taxCode doesn't match
4
+ * with the surname entered by the user, otherwise FALSE when they match.
5
+ * */
6
+ import { acceptedConsonants, acceptedVowels, specialChar2NormalChar } from './utils';
7
+ export const verifySurnameMatchWithTaxCode = (surname, fiscalCode) => {
8
+ const fiscalCodeSurname = fiscalCode?.substring(0, 3).toUpperCase();
9
+ const vowelsSurname = fiscalCodeSurname?.match(acceptedVowels)
10
+ ? surname?.toUpperCase().match(acceptedVowels)?.map(specialChar2NormalChar).join('')
11
+ : '';
12
+ const consonantsSurname = fiscalCodeSurname?.match(acceptedConsonants)
13
+ ? surname?.toUpperCase().match(acceptedConsonants)?.map(specialChar2NormalChar).join('')
14
+ : '';
15
+ const expectedFiscalCodeSurname = `${consonantsSurname}${vowelsSurname}XX`.substring(0, 3);
16
+ return fiscalCodeSurname && fiscalCodeSurname !== expectedFiscalCodeSurname;
17
+ };