@pagopa/selfcare-common-frontend 1.35.0 → 1.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +883 -1
- package/README.md +34 -8
- package/examples/locale/en.d.ts +20 -0
- package/examples/locale/en.js +18 -0
- package/examples/locale/index.js +4 -0
- package/examples/locale/it.d.ts +20 -0
- package/examples/locale/it.js +19 -0
- package/{common-polyfill.d.ts → lib/common-polyfill.d.ts} +0 -1
- package/lib/common-polyfill.js +9 -0
- package/lib/components/BackComponent.d.ts +7 -0
- package/lib/components/BackComponent.js +8 -0
- package/lib/components/CustomAlert.d.ts +12 -0
- package/lib/components/CustomAlert.js +7 -0
- package/{components → lib/components}/CustomAvatar.d.ts +2 -3
- package/lib/components/CustomAvatar.js +13 -0
- package/{components → lib/components}/CustomPagination.d.ts +7 -3
- package/lib/components/CustomPagination.js +25 -0
- package/{components → lib/components}/EndingPage.d.ts +15 -3
- package/lib/components/EndingPage.js +4 -0
- package/lib/components/ErrorBoundary/ErrorBoundary.d.ts +11 -0
- package/lib/components/ErrorBoundary/ErrorBoundary.js +93 -0
- package/{components → lib/components}/ErrorBoundary/components/BlockingErrorPage.d.ts +2 -3
- package/lib/components/ErrorBoundary/components/BlockingErrorPage.js +11 -0
- package/{components → lib/components}/FilterModal.d.ts +3 -3
- package/lib/components/FilterModal.js +29 -0
- package/{components → lib/components}/Footer/Footer.d.ts +2 -3
- package/lib/components/Footer/Footer.js +179 -0
- package/{components → lib/components}/Footer/FooterConfig.js +5 -9
- package/{components → lib/components}/Header/Header.d.ts +11 -6
- package/lib/components/Header/Header.js +45 -0
- package/{components → lib/components}/Loading/LoadingOverlay.d.ts +1 -2
- package/lib/components/Loading/LoadingOverlay.js +13 -0
- package/lib/components/LoadingOverlayComponent.d.ts +7 -0
- package/lib/components/LoadingOverlayComponent.js +25 -0
- package/{components → lib/components}/NavigationBar.d.ts +5 -4
- package/lib/components/NavigationBar.js +17 -0
- package/{components → lib/components}/SessionModal.d.ts +3 -3
- package/lib/components/SessionModal.js +17 -0
- package/{components → lib/components}/TitleBox.d.ts +7 -7
- package/lib/components/TitleBox.js +9 -0
- package/{components → lib/components}/Toast.d.ts +3 -3
- package/lib/components/Toast.js +25 -0
- package/{components → lib/components}/ToastWrapper.d.ts +2 -2
- package/lib/components/ToastWrapper.js +12 -0
- package/{components → lib/components}/UnloadEventHandler.d.ts +1 -2
- package/lib/components/UnloadEventHandler.js +29 -0
- package/{components → lib/components}/UserNotifyHandle.d.ts +1 -2
- package/lib/components/UserNotifyHandle.js +62 -0
- package/{components → lib/components}/icons/CheckIllustrationIcon.d.ts +1 -2
- package/lib/components/icons/CheckIllustrationIcon.js +3 -0
- package/lib/components/icons/ConfirmIcon.js +4 -0
- package/{components → lib/components}/icons/ErrorIcon.d.ts +1 -2
- package/lib/components/icons/ErrorIcon.js +3 -0
- package/lib/components/icons/ErrorIconExclamation.js +4 -0
- package/lib/components/icons/FaultIcon.js +4 -0
- package/{components → lib/components}/icons/PagoPaIcon.d.ts +1 -2
- package/lib/components/icons/PagoPaIcon.js +3 -0
- package/{components → lib/components}/icons/PagoPaIconColored.d.ts +1 -2
- package/lib/components/icons/PagoPaIconColored.js +3 -0
- package/{components → lib/components}/icons/PagoPaMiniIcon.d.ts +1 -2
- package/lib/components/icons/PagoPaMiniIcon.js +3 -0
- package/lib/components/tests/FilterModal.test.d.ts +1 -0
- package/lib/components/tests/FilterModal.test.js +37 -0
- package/{config → lib/config}/env.d.ts +4 -1
- package/{config → lib/config}/env.js +13 -17
- package/lib/consentManagementConfigure.d.ts +1 -0
- package/{consentManagementConfigure.js → lib/consentManagementConfigure.js} +5 -8
- package/{decorators → lib/decorators}/__mocks__/withLogin.d.ts +1 -2
- package/lib/decorators/__mocks__/withLogin.js +18 -0
- package/{decorators → lib/decorators}/withLogin.d.ts +1 -2
- package/{decorators → lib/decorators}/withLogin.js +13 -18
- package/{decorators → lib/decorators}/withRetrievedValue.d.ts +1 -1
- package/{decorators → lib/decorators}/withRetrievedValue.js +9 -14
- package/lib/hooks/useErrorDispatcher.js +7 -0
- package/{hooks → lib/hooks}/useFakePagination.d.ts +3 -3
- package/{hooks → lib/hooks}/useFakePagination.js +9 -15
- package/lib/hooks/useFocus.d.ts +1 -0
- package/lib/hooks/useFocus.js +8 -0
- package/lib/hooks/useLiveAnnouncerWithRegion.d.ts +4 -0
- package/lib/hooks/useLiveAnnouncerWithRegion.js +19 -0
- package/lib/hooks/useLoading.js +10 -0
- package/lib/hooks/useLogin.js +40 -0
- package/lib/hooks/usePermissions.d.ts +7 -0
- package/lib/hooks/usePermissions.js +25 -0
- package/lib/hooks/useReduxCachedValue.d.ts +22 -0
- package/{hooks → lib/hooks}/useReduxCachedValue.js +10 -17
- package/{hooks → lib/hooks}/useUnloadEventInterceptor.d.ts +3 -3
- package/{hooks → lib/hooks}/useUnloadEventInterceptor.js +24 -32
- package/lib/hooks/useUserNotify.js +7 -0
- package/{index.d.ts → lib/index.d.ts} +11 -8
- package/lib/index.js +36 -0
- package/{locale/it.d.ts → lib/locale/de.d.ts} +4 -1
- package/{locale → lib/locale}/de.js +31 -31
- package/{locale → lib/locale}/en.d.ts +4 -1
- package/{locale → lib/locale}/en.js +30 -30
- package/{locale → lib/locale}/fr.d.ts +5 -2
- package/{locale → lib/locale}/fr.js +26 -26
- package/{locale/de.d.ts → lib/locale/it.d.ts} +8 -2
- package/{locale → lib/locale}/it.js +11 -8
- package/lib/locale/locale-utils.js +45 -0
- package/{locale → lib/locale}/sl.d.ts +5 -2
- package/{locale → lib/locale}/sl.js +31 -31
- package/{model → lib/model}/AppError.d.ts +1 -1
- package/lib/model/AppError.js +1 -0
- package/lib/model/JwtUser.d.ts +9 -0
- package/lib/model/JwtUser.js +1 -0
- package/{model → lib/model}/Page.d.ts +1 -1
- package/lib/model/Page.js +1 -0
- package/{model → lib/model}/PageRequest.d.ts +1 -1
- package/lib/model/PageRequest.js +1 -0
- package/{model → lib/model}/PageResource.d.ts +1 -1
- package/lib/model/PageResource.js +1 -0
- package/lib/model/User.d.ts +8 -0
- package/lib/model/User.js +1 -0
- package/{model → lib/model}/UserNotify.d.ts +1 -2
- package/lib/model/UserNotify.js +1 -0
- package/lib/redux/slices/appStateSlice.d.ts +58 -0
- package/{redux → lib/redux}/slices/appStateSlice.js +15 -9
- package/lib/redux/slices/permissionsSlice.d.ts +12 -0
- package/lib/redux/slices/permissionsSlice.js +23 -0
- package/lib/redux/slices/productsSlice.d.ts +204 -0
- package/lib/redux/slices/productsSlice.js +26 -0
- package/lib/redux/slices/userSlice.d.ts +36 -0
- package/lib/redux/slices/userSlice.js +17 -0
- package/{services → lib/services}/analyticsService.d.ts +2 -1
- package/{services → lib/services}/analyticsService.js +31 -28
- package/{services → lib/services}/assistanceService.d.ts +1 -1
- package/lib/services/assistanceService.js +14 -0
- package/lib/services/errorService.js +8 -0
- package/{utils → lib/utils}/api-utils.d.ts +3 -3
- package/{utils → lib/utils}/api-utils.js +28 -23
- package/lib/utils/constants.d.ts +69 -0
- package/lib/utils/constants.js +83 -0
- package/lib/utils/productId2ProductTitle.d.ts +1 -0
- package/lib/utils/productId2ProductTitle.js +13 -0
- package/lib/utils/routes-utils.js +2 -0
- package/{utils → lib/utils}/storage-utils.d.ts +3 -3
- package/{utils → lib/utils}/storage-utils.js +4 -12
- package/{utils → lib/utils}/storage.d.ts +6 -0
- package/lib/utils/storage.js +31 -0
- package/lib/utils/utils.d.ts +11 -0
- package/lib/utils/utils.js +148 -0
- package/{utils → lib/utils}/verifyChecksumMatchWithTaxCode.js +1 -6
- package/{utils → lib/utils}/verifyNameMatchWithTaxCode.d.ts +1 -1
- package/lib/utils/verifyNameMatchWithTaxCode.js +27 -0
- package/{utils → lib/utils}/verifySurnameMatchWithTaxCode.d.ts +1 -1
- package/lib/utils/verifySurnameMatchWithTaxCode.js +17 -0
- package/package.json +54 -79
- package/build.info +0 -2
- package/common-polyfill.js +0 -13
- package/common-polyfill.js.map +0 -1
- package/components/BackComponent.d.ts +0 -6
- package/components/BackComponent.js +0 -12
- package/components/BackComponent.js.map +0 -1
- package/components/CustomAvatar.js +0 -18
- package/components/CustomAvatar.js.map +0 -1
- package/components/CustomPagination.js +0 -31
- package/components/CustomPagination.js.map +0 -1
- package/components/EndingPage.js +0 -7
- package/components/EndingPage.js.map +0 -1
- package/components/ErrorBoundary/ErrorBoundary.d.ts +0 -11
- package/components/ErrorBoundary/ErrorBoundary.js +0 -98
- package/components/ErrorBoundary/ErrorBoundary.js.map +0 -1
- package/components/ErrorBoundary/components/BlockingErrorPage.js +0 -15
- package/components/ErrorBoundary/components/BlockingErrorPage.js.map +0 -1
- package/components/FilterModal.js +0 -37
- package/components/FilterModal.js.map +0 -1
- package/components/Footer/Footer.js +0 -213
- package/components/Footer/Footer.js.map +0 -1
- package/components/Footer/FooterConfig.js.map +0 -1
- package/components/Header/Header.js +0 -24
- package/components/Header/Header.js.map +0 -1
- package/components/Loading/LoadingOverlay.js +0 -18
- package/components/Loading/LoadingOverlay.js.map +0 -1
- package/components/LoadingOverlayComponent.d.ts +0 -7
- package/components/LoadingOverlayComponent.js +0 -20
- package/components/LoadingOverlayComponent.js.map +0 -1
- package/components/NavigationBar.js +0 -21
- package/components/NavigationBar.js.map +0 -1
- package/components/SessionModal.js +0 -21
- package/components/SessionModal.js.map +0 -1
- package/components/TitleBox.js +0 -13
- package/components/TitleBox.js.map +0 -1
- package/components/Toast.js +0 -29
- package/components/Toast.js.map +0 -1
- package/components/ToastWrapper.js +0 -16
- package/components/ToastWrapper.js.map +0 -1
- package/components/UnloadEventHandler.js +0 -35
- package/components/UnloadEventHandler.js.map +0 -1
- package/components/UserNotifyHandle.js +0 -67
- package/components/UserNotifyHandle.js.map +0 -1
- package/components/icons/CheckIllustrationIcon.js +0 -7
- package/components/icons/CheckIllustrationIcon.js.map +0 -1
- package/components/icons/ConfirmIcon.js +0 -7
- package/components/icons/ConfirmIcon.js.map +0 -1
- package/components/icons/ErrorIcon.js +0 -7
- package/components/icons/ErrorIcon.js.map +0 -1
- package/components/icons/ErrorIconExclamation.js +0 -7
- package/components/icons/ErrorIconExclamation.js.map +0 -1
- package/components/icons/FaultIcon.js +0 -7
- package/components/icons/FaultIcon.js.map +0 -1
- package/components/icons/PagoPaIcon.js +0 -7
- package/components/icons/PagoPaIcon.js.map +0 -1
- package/components/icons/PagoPaIconColored.js +0 -7
- package/components/icons/PagoPaIconColored.js.map +0 -1
- package/components/icons/PagoPaMiniIcon.js +0 -7
- package/components/icons/PagoPaMiniIcon.js.map +0 -1
- package/config/env.js.map +0 -1
- package/consentManagementConfigure.js.map +0 -1
- package/decorators/__mocks__/withLogin.js +0 -27
- package/decorators/__mocks__/withLogin.js.map +0 -1
- package/decorators/withLogin.js.map +0 -1
- package/decorators/withRetrievedValue.js.map +0 -1
- package/hooks/useErrorDispatcher.js +0 -11
- package/hooks/useErrorDispatcher.js.map +0 -1
- package/hooks/useFakePagination.js.map +0 -1
- package/hooks/useLoading.js +0 -14
- package/hooks/useLoading.js.map +0 -1
- package/hooks/useLogin.js +0 -44
- package/hooks/useLogin.js.map +0 -1
- package/hooks/useReduxCachedValue.d.ts +0 -14
- package/hooks/useReduxCachedValue.js.map +0 -1
- package/hooks/useUnloadEventInterceptor.js.map +0 -1
- package/hooks/useUserNotify.js +0 -11
- package/hooks/useUserNotify.js.map +0 -1
- package/index.js +0 -76
- package/index.js.map +0 -1
- package/locale/de.js.map +0 -1
- package/locale/en.js.map +0 -1
- package/locale/fr.js.map +0 -1
- package/locale/it.js.map +0 -1
- package/locale/locale-utils.js +0 -36
- package/locale/locale-utils.js.map +0 -1
- package/locale/sl.js.map +0 -1
- package/model/AppError.js +0 -3
- package/model/AppError.js.map +0 -1
- package/model/Page.js +0 -3
- package/model/Page.js.map +0 -1
- package/model/PageRequest.js +0 -3
- package/model/PageRequest.js.map +0 -1
- package/model/PageResource.js +0 -3
- package/model/PageResource.js.map +0 -1
- package/model/User.d.ts +0 -7
- package/model/User.js +0 -3
- package/model/User.js.map +0 -1
- package/model/UserNotify.js +0 -3
- package/model/UserNotify.js.map +0 -1
- package/redux/slices/appStateSlice.d.ts +0 -76
- package/redux/slices/appStateSlice.js.map +0 -1
- package/redux/slices/userSlice.d.ts +0 -18
- package/redux/slices/userSlice.js +0 -21
- package/redux/slices/userSlice.js.map +0 -1
- package/services/analyticsService.js.map +0 -1
- package/services/assistanceService.js +0 -20
- package/services/assistanceService.js.map +0 -1
- package/services/errorService.js +0 -13
- package/services/errorService.js.map +0 -1
- package/utils/api-utils.js.map +0 -1
- package/utils/constants.d.ts +0 -19
- package/utils/constants.js +0 -32
- package/utils/constants.js.map +0 -1
- package/utils/routes-utils.js +0 -7
- package/utils/routes-utils.js.map +0 -1
- package/utils/storage-utils.js.map +0 -1
- package/utils/storage.js +0 -9
- package/utils/storage.js.map +0 -1
- package/utils/utils.d.ts +0 -3
- package/utils/utils.js +0 -13
- package/utils/utils.js.map +0 -1
- package/utils/verifyChecksumMatchWithTaxCode.js.map +0 -1
- package/utils/verifyNameMatchWithTaxCode.js +0 -26
- package/utils/verifyNameMatchWithTaxCode.js.map +0 -1
- package/utils/verifySurnameMatchWithTaxCode.js +0 -23
- package/utils/verifySurnameMatchWithTaxCode.js.map +0 -1
- /package/{consentManagementConfigure.d.ts → examples/locale/index.d.ts} +0 -0
- /package/{components → lib/components}/Footer/FooterConfig.d.ts +0 -0
- /package/{components → lib/components}/icons/ConfirmIcon.d.ts +0 -0
- /package/{components → lib/components}/icons/ErrorIconExclamation.d.ts +0 -0
- /package/{components → lib/components}/icons/FaultIcon.d.ts +0 -0
- /package/{hooks → lib/hooks}/useErrorDispatcher.d.ts +0 -0
- /package/{hooks → lib/hooks}/useLoading.d.ts +0 -0
- /package/{hooks → lib/hooks}/useLogin.d.ts +0 -0
- /package/{hooks → lib/hooks}/useUserNotify.d.ts +0 -0
- /package/{locale → lib/locale}/locale-utils.d.ts +0 -0
- /package/{services → lib/services}/errorService.d.ts +0 -0
- /package/{utils → lib/utils}/routes-utils.d.ts +0 -0
- /package/{utils → lib/utils}/verifyChecksumMatchWithTaxCode.d.ts +0 -0
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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(
|
|
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 =
|
|
24
|
-
const fetchWithTimeout =
|
|
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
|
-
|
|
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
|
-
|
|
36
|
-
|
|
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(
|
|
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
|
-
|
|
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
|
|
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
|
|
75
|
+
throw toError(response.left);
|
|
69
76
|
}
|
|
70
77
|
};
|
|
71
|
-
exports.extractResponse = extractResponse;
|
|
72
|
-
//# sourceMappingURL=api-utils.js.map
|
|
@@ -0,0 +1,69 @@
|
|
|
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 const Actions: {
|
|
22
|
+
readonly ManageProductGroups: "Selc:ManageProductGroups";
|
|
23
|
+
readonly UpdateProductUsers: "Selc:UpdateProductUsers";
|
|
24
|
+
readonly DeleteProductUsers: "Selc:DeleteProductUsers";
|
|
25
|
+
readonly CreateProductUsers: "Selc:CreateProductUsers";
|
|
26
|
+
readonly ListProductUsers: "Selc:ListProductUsers";
|
|
27
|
+
readonly ListAllProductUsers: "Selc:ListAllProductUsers";
|
|
28
|
+
readonly ListProductGroups: "Selc:ListProductGroups";
|
|
29
|
+
readonly ListAllProductGroups: "Selc:ListAllProductGroups";
|
|
30
|
+
readonly ViewDelegations: "Selc:ViewDelegations";
|
|
31
|
+
readonly CreateDelegation: "Selc:CreateDelegation";
|
|
32
|
+
readonly ViewManagedInstitutions: "Selc:ViewManagedInstitutions";
|
|
33
|
+
readonly AccessProductBackoffice: "Selc:AccessProductBackoffice";
|
|
34
|
+
readonly AccessProductBackofficeAdmin: "Selc:AccessProductBackofficeAdmin";
|
|
35
|
+
readonly ListActiveProducts: "Selc:ListActiveProducts";
|
|
36
|
+
readonly ListAvailableProducts: "Selc:ListAvailableProducts";
|
|
37
|
+
readonly RequestProductAccess: "Selc:RequestProductAccess";
|
|
38
|
+
readonly ViewBilling: "Selc:ViewBilling";
|
|
39
|
+
readonly UploadLogo: "Selc:UploadLogo";
|
|
40
|
+
readonly UpdateInstitution: "Selc:UpdateInstitutionData";
|
|
41
|
+
readonly ViewContract: "Selc:ViewContract";
|
|
42
|
+
readonly UpdateGeoTaxonomy: "Selc:UpdateGeoTaxonomy";
|
|
43
|
+
readonly ViewAccountPage: "Selc:ViewAccountPage";
|
|
44
|
+
readonly ManageAccountPage: "Selc:ManageAccountPage";
|
|
45
|
+
};
|
|
46
|
+
export declare const PRODUCT_IDS: {
|
|
47
|
+
PAGOPA: string;
|
|
48
|
+
DASHBOARD_PSP: string;
|
|
49
|
+
IO: string;
|
|
50
|
+
IO_PREMIUM: string;
|
|
51
|
+
SEND: string;
|
|
52
|
+
SEND_DEV: string;
|
|
53
|
+
INTEROP: string;
|
|
54
|
+
INTEROP_ATTESTAZIONE: string;
|
|
55
|
+
INTEROP_COLLAUDO: string;
|
|
56
|
+
IDPAY: string;
|
|
57
|
+
IDPAY_MERCHANT: string;
|
|
58
|
+
IO_SIGN: string;
|
|
59
|
+
FD: string;
|
|
60
|
+
FD_GARANTITO: string;
|
|
61
|
+
CIBAN: string;
|
|
62
|
+
CGN: string;
|
|
63
|
+
};
|
|
64
|
+
export declare const ALLOWED_PREFIXES: string[];
|
|
65
|
+
/**
|
|
66
|
+
* Validates if a product ID matches our allowed prefixes.
|
|
67
|
+
* @param productId - The ID from the FE or API
|
|
68
|
+
*/
|
|
69
|
+
export declare const isProductAllowed: (productId: string) => boolean;
|
|
@@ -0,0 +1,83 @@
|
|
|
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 const Actions = {
|
|
35
|
+
ManageProductGroups: 'Selc:ManageProductGroups',
|
|
36
|
+
UpdateProductUsers: 'Selc:UpdateProductUsers',
|
|
37
|
+
DeleteProductUsers: 'Selc:DeleteProductUsers',
|
|
38
|
+
CreateProductUsers: 'Selc:CreateProductUsers',
|
|
39
|
+
ListProductUsers: 'Selc:ListProductUsers',
|
|
40
|
+
ListAllProductUsers: 'Selc:ListAllProductUsers',
|
|
41
|
+
ListProductGroups: 'Selc:ListProductGroups',
|
|
42
|
+
ListAllProductGroups: 'Selc:ListAllProductGroups',
|
|
43
|
+
ViewDelegations: 'Selc:ViewDelegations',
|
|
44
|
+
CreateDelegation: 'Selc:CreateDelegation',
|
|
45
|
+
ViewManagedInstitutions: 'Selc:ViewManagedInstitutions',
|
|
46
|
+
AccessProductBackoffice: 'Selc:AccessProductBackoffice',
|
|
47
|
+
AccessProductBackofficeAdmin: 'Selc:AccessProductBackofficeAdmin',
|
|
48
|
+
ListActiveProducts: 'Selc:ListActiveProducts',
|
|
49
|
+
ListAvailableProducts: 'Selc:ListAvailableProducts',
|
|
50
|
+
RequestProductAccess: 'Selc:RequestProductAccess',
|
|
51
|
+
ViewBilling: 'Selc:ViewBilling',
|
|
52
|
+
UploadLogo: 'Selc:UploadLogo',
|
|
53
|
+
UpdateInstitution: 'Selc:UpdateInstitutionData',
|
|
54
|
+
ViewContract: 'Selc:ViewContract',
|
|
55
|
+
UpdateGeoTaxonomy: 'Selc:UpdateGeoTaxonomy',
|
|
56
|
+
ViewAccountPage: 'Selc:ViewAccountPage',
|
|
57
|
+
ManageAccountPage: 'Selc:ManageAccountPage',
|
|
58
|
+
};
|
|
59
|
+
export const PRODUCT_IDS = {
|
|
60
|
+
PAGOPA: 'prod-pagopa',
|
|
61
|
+
DASHBOARD_PSP: 'prod-dashboard-psp',
|
|
62
|
+
IO: 'prod-io',
|
|
63
|
+
IO_PREMIUM: 'prod-io-premium',
|
|
64
|
+
SEND: 'prod-pn',
|
|
65
|
+
SEND_DEV: 'prod-pn-dev',
|
|
66
|
+
INTEROP: 'prod-interop',
|
|
67
|
+
INTEROP_ATTESTAZIONE: 'prod-interop-atst',
|
|
68
|
+
INTEROP_COLLAUDO: 'prod-interop-collaudo',
|
|
69
|
+
IDPAY: 'prod-idpay',
|
|
70
|
+
IDPAY_MERCHANT: 'prod-idpay-merchant',
|
|
71
|
+
IO_SIGN: 'prod-io-sign',
|
|
72
|
+
FD: 'prod-fd',
|
|
73
|
+
FD_GARANTITO: 'prod-fd-garantito',
|
|
74
|
+
CIBAN: 'prod-ciban',
|
|
75
|
+
CGN: 'prod-cgn',
|
|
76
|
+
};
|
|
77
|
+
// TODO remove this. Moved this logic into env files
|
|
78
|
+
export const ALLOWED_PREFIXES = ['prod-interop', 'prod-pn'];
|
|
79
|
+
/**
|
|
80
|
+
* Validates if a product ID matches our allowed prefixes.
|
|
81
|
+
* @param productId - The ID from the FE or API
|
|
82
|
+
*/
|
|
83
|
+
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
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
+
};
|