From 98a5f291eb410a0884002038b01afcf6684d885b Mon Sep 17 00:00:00 2001 From: LazyAfternoons Date: Thu, 11 Jan 2024 17:03:03 +0100 Subject: [PATCH] chore(IT Wallet): [SIW-789] Refactor folders and files structure (#5384) ## Short description Depends on #5373 This PR focuses on enhancing the organization and coherence of the project's folder and file structure. No changes to the logic have been made whatsoever. While a detailed breakdown of each modification isn't provided due to the high number of changes. They can be reviewed in the `Files changed` section or by pulling the branch locally to inspect the updated folder structure and file names. It also adds a state migration needed due to the changes which basically resets it. ## How to test Check the new structure and names statically then test again each flow. Everything should work just as before. --- .../barcode/screens/BarcodeScanScreen.tsx | 2 +- .../it-wallet/components/ItwClaimsWrapper.tsx | 2 +- .../components/ItwCredentialCard.tsx | 4 +- .../components/ItwCredentialClaimsList.tsx | 4 +- .../components/cie/CieNfcOverlay.tsx | 8 +- .../it-wallet/navigation/ItwParamsList.ts | 51 +++--- ts/features/it-wallet/navigation/ItwRoutes.ts | 38 ++-- .../navigation/ItwStackNavigator.tsx | 92 +++++----- ts/features/it-wallet/saga/index.ts | 25 +-- .../it-wallet/saga/itwActivationSaga.ts | 46 ++++- .../it-wallet/saga/itwAuthenticationSaga.ts | 38 ---- ...ceSaga.ts => itwIssuanceCredentialSaga.ts} | 135 +++++++------- ...ieSaga.ts => itwIssuancePidCieAuthSaga.ts} | 60 +++---- ...dIssuanceSaga.ts => itwIssuancePidSaga.ts} | 62 +++---- ...ProximitySaga.ts => itwPrProximitySaga.ts} | 13 +- .../saga/itwPrRemoteCredentialSaga.ts | 51 ++++++ .../it-wallet/saga/itwPrRemotePidSaga.ts | 165 ++++++++++++++++++ .../it-wallet/saga/itwRpInitializationSaga.ts | 74 -------- .../it-wallet/saga/itwRpPresentationSaga.ts | 94 ---------- ts/features/it-wallet/saga/itwRpSaga.ts | 24 --- ts/features/it-wallet/saga/itwWiaSaga.ts | 6 +- .../it-wallet/saga/new/itwPresentationSaga.ts | 45 ----- .../it-wallet/screens/ItwHomeScreen.tsx | 18 +- .../ItwIssuanceCredentialAuthScreen.tsx} | 22 +-- .../ItwIssuanceCredentialCatalogScreen.tsx} | 16 +- .../ItwIssuanceCredentialChecksScreen.tsx} | 24 +-- .../ItwIssuanceCredentialPreviewScreen.tsx} | 24 +-- .../pid/ItwIssuancePidAuthInfoScreen.tsx} | 10 +- .../pid/ItwIssuancePidAuthScreen.tsx} | 6 +- .../pid/ItwIssuancePidInfoScreen.tsx} | 6 +- .../pid/ItwIssuancePidPreviewScreen.tsx} | 30 ++-- .../pid/ItwIssuancePidRequestScreen.tsx} | 22 +-- .../pid/ItwIssuancePidStoreScreen.tsx | 46 +++++ .../pid/cie/ItwCieCardReaderScreen.tsx | 30 ++-- .../pid/cie/ItwCieConsentDataUsageScreen.tsx | 24 +-- .../pid/cie/ItwCieExpiredOrInvalidScreen.tsx | 4 +- .../cie/ItwCiePinLockedTemporarilyScreen.tsx | 4 +- .../pid/cie/ItwCiePinScreen.tsx | 8 +- .../pid/cie/ItwCieWrongPinScreen.tsx | 6 +- .../issuing/pid/ItwIssuingPidAddingScreen.tsx | 96 ---------- .../presentation/ItwPrCredentialDetails.tsx | 2 +- .../screens/presentation/ItwPrPidDetails.tsx | 8 +- .../ItwPrProximityQrCodeScreen.tsx | 12 +- .../ItwPrRemoteCredentialChecksScreen.tsx | 16 +- .../ItwPrRemoteCredentialDataScreen.tsx | 12 +- .../ItwPrRemoteCredentialResultScreen.tsx | 10 +- .../remote/pid/ItwPrRemotePidChecksScreen.tsx | 22 +-- .../remote/pid/ItwPrRemotePidDataScreen.tsx | 12 +- .../remote/pid/ItwPrRemotePidResultScreen.tsx | 20 ++- ts/features/it-wallet/store/actions/index.ts | 28 +-- .../store/actions/itwCredentialsActions.ts | 63 ------- .../store/actions/itwIssuanceActions.ts | 43 ----- .../actions/itwIssuanceCredentialActions.ts | 46 +++++ .../store/actions/itwIssuancePidActions.ts | 34 ++++ ...Actions.ts => itwIssuancePidCieActions.ts} | 42 ++--- .../actions/itwPersistedCredentialsActions.ts | 16 ++ .../actions/itwPrRemoteCredentialActions.ts | 24 +++ .../store/actions/itwPrRemotePidActions.ts | 36 ++++ .../store/actions/itwPresentationActions.ts | 24 --- .../it-wallet/store/actions/itwRpActions.ts | 37 ---- ts/features/it-wallet/store/reducers/index.ts | 110 +++++++----- .../it-wallet/store/reducers/itwCieReducer.ts | 112 ------------ .../reducers/itwCredentialsChecksReducer.ts | 56 ------ .../store/reducers/itwCredentialsReducer.ts | 112 ------------ .../reducers/itwIssuanceCredentialReducer.ts | 121 +++++++++++++ .../reducers/itwIssuancePidCieAuthReducer.ts | 112 ++++++++++++ ...PidReducer.ts => itwIssuancePidReducer.ts} | 28 +-- .../itwPersistedCredentialsReducer.ts | 80 +++++++++ ...ityReducer.ts => itwPrProximityReducer.ts} | 26 +-- .../reducers/itwPrRemoteCredentialReducer.ts | 93 ++++++++++ .../store/reducers/itwPrRemotePidReducer.ts | 120 +++++++++++++ .../reducers/itwRpInitializationReducer.ts | 104 ----------- .../reducers/itwRpPresentationReducer.ts | 70 -------- .../it-wallet/store/reducers/itwWiaReducer.ts | 8 +- .../store/reducers/new/itwIssuanceReducer.ts | 118 ------------- .../reducers/new/itwPresentationReducer.ts | 88 ---------- ...lsKeychain.ts => itwCredentialsStorage.ts} | 2 +- .../utils/{alert.ts => itwAlertsUtils.ts} | 2 +- .../it-wallet/utils/itwButtonsUtils.tsx | 9 - .../utils/{cie.ts => itwCieUtils.ts} | 10 +- ts/features/it-wallet/utils/itwClaimsUtils.ts | 4 +- ts/features/it-wallet/utils/itwErrorsUtils.ts | 4 +- .../utils/{mocks.ts => itwMocksUtils.ts} | 0 .../it-wallet/{saga => utils}/itwSagaUtils.ts | 0 .../utils/{types.ts => itwTypesUtils.ts} | 8 +- ts/features/it-wallet/utils/navigation.ts | 11 -- 86 files changed, 1586 insertions(+), 1764 deletions(-) delete mode 100644 ts/features/it-wallet/saga/itwAuthenticationSaga.ts rename ts/features/it-wallet/saga/{new/itwIssuanceSaga.ts => itwIssuanceCredentialSaga.ts} (80%) rename ts/features/it-wallet/saga/{itwCieSaga.ts => itwIssuancePidCieAuthSaga.ts} (58%) rename ts/features/it-wallet/saga/{itwPidIssuanceSaga.ts => itwIssuancePidSaga.ts} (75%) rename ts/features/it-wallet/saga/{itwProximitySaga.ts => itwPrProximitySaga.ts} (90%) create mode 100644 ts/features/it-wallet/saga/itwPrRemoteCredentialSaga.ts create mode 100644 ts/features/it-wallet/saga/itwPrRemotePidSaga.ts delete mode 100644 ts/features/it-wallet/saga/itwRpInitializationSaga.ts delete mode 100644 ts/features/it-wallet/saga/itwRpPresentationSaga.ts delete mode 100644 ts/features/it-wallet/saga/itwRpSaga.ts delete mode 100644 ts/features/it-wallet/saga/new/itwPresentationSaga.ts rename ts/features/it-wallet/screens/{issuing/credential/ItwIssuingCredentialAuthScreen.tsx => issuance/credential/ItwIssuanceCredentialAuthScreen.tsx} (89%) rename ts/features/it-wallet/screens/{issuing/credential/ItwIssuingCredentialCatalogScreen.tsx => issuance/credential/ItwIssuanceCredentialCatalogScreen.tsx} (89%) rename ts/features/it-wallet/screens/{issuing/credential/ItwIssuingCredentialChecksScreen.tsx => issuance/credential/ItwIssuanceCredentialChecksScreen.tsx} (89%) rename ts/features/it-wallet/screens/{issuing/credential/ItwIssuingCredentialPreviewScreen.tsx => issuance/credential/ItwIssuanceCredentialPreviewScreen.tsx} (90%) rename ts/features/it-wallet/screens/{issuing/pid/ItwIssuingPidAuthInfoScreen.tsx => issuance/pid/ItwIssuancePidAuthInfoScreen.tsx} (94%) rename ts/features/it-wallet/screens/{issuing/pid/ItwIssuingPidAuthScreen.tsx => issuance/pid/ItwIssuancePidAuthScreen.tsx} (97%) rename ts/features/it-wallet/screens/{issuing/pid/ItwIssuingPidInfoScreen.tsx => issuance/pid/ItwIssuancePidInfoScreen.tsx} (95%) rename ts/features/it-wallet/screens/{issuing/pid/ItwPidPreviewScreen.tsx => issuance/pid/ItwIssuancePidPreviewScreen.tsx} (85%) rename ts/features/it-wallet/screens/{issuing/pid/ItwIssuingPidRequestScreen.tsx => issuance/pid/ItwIssuancePidRequestScreen.tsx} (84%) create mode 100644 ts/features/it-wallet/screens/issuance/pid/ItwIssuancePidStoreScreen.tsx rename ts/features/it-wallet/screens/{issuing => issuance}/pid/cie/ItwCieCardReaderScreen.tsx (94%) rename ts/features/it-wallet/screens/{issuing => issuance}/pid/cie/ItwCieConsentDataUsageScreen.tsx (93%) rename ts/features/it-wallet/screens/{issuing => issuance}/pid/cie/ItwCieExpiredOrInvalidScreen.tsx (96%) rename ts/features/it-wallet/screens/{issuing => issuance}/pid/cie/ItwCiePinLockedTemporarilyScreen.tsx (97%) rename ts/features/it-wallet/screens/{issuing => issuance}/pid/cie/ItwCiePinScreen.tsx (93%) rename ts/features/it-wallet/screens/{issuing => issuance}/pid/cie/ItwCieWrongPinScreen.tsx (95%) delete mode 100644 ts/features/it-wallet/screens/issuing/pid/ItwIssuingPidAddingScreen.tsx delete mode 100644 ts/features/it-wallet/store/actions/itwCredentialsActions.ts delete mode 100644 ts/features/it-wallet/store/actions/itwIssuanceActions.ts create mode 100644 ts/features/it-wallet/store/actions/itwIssuanceCredentialActions.ts create mode 100644 ts/features/it-wallet/store/actions/itwIssuancePidActions.ts rename ts/features/it-wallet/store/actions/{itwCieActions.ts => itwIssuancePidCieActions.ts} (53%) create mode 100644 ts/features/it-wallet/store/actions/itwPersistedCredentialsActions.ts create mode 100644 ts/features/it-wallet/store/actions/itwPrRemoteCredentialActions.ts create mode 100644 ts/features/it-wallet/store/actions/itwPrRemotePidActions.ts delete mode 100644 ts/features/it-wallet/store/actions/itwPresentationActions.ts delete mode 100644 ts/features/it-wallet/store/actions/itwRpActions.ts delete mode 100644 ts/features/it-wallet/store/reducers/itwCieReducer.ts delete mode 100644 ts/features/it-wallet/store/reducers/itwCredentialsChecksReducer.ts delete mode 100644 ts/features/it-wallet/store/reducers/itwCredentialsReducer.ts create mode 100644 ts/features/it-wallet/store/reducers/itwIssuanceCredentialReducer.ts create mode 100644 ts/features/it-wallet/store/reducers/itwIssuancePidCieAuthReducer.ts rename ts/features/it-wallet/store/reducers/{itwPidReducer.ts => itwIssuancePidReducer.ts} (63%) create mode 100644 ts/features/it-wallet/store/reducers/itwPersistedCredentialsReducer.ts rename ts/features/it-wallet/store/reducers/{itwProximityReducer.ts => itwPrProximityReducer.ts} (72%) create mode 100644 ts/features/it-wallet/store/reducers/itwPrRemoteCredentialReducer.ts create mode 100644 ts/features/it-wallet/store/reducers/itwPrRemotePidReducer.ts delete mode 100644 ts/features/it-wallet/store/reducers/itwRpInitializationReducer.ts delete mode 100644 ts/features/it-wallet/store/reducers/itwRpPresentationReducer.ts delete mode 100644 ts/features/it-wallet/store/reducers/new/itwIssuanceReducer.ts delete mode 100644 ts/features/it-wallet/store/reducers/new/itwPresentationReducer.ts rename ts/features/it-wallet/store/storages/{credentialsKeychain.ts => itwCredentialsStorage.ts} (94%) rename ts/features/it-wallet/utils/{alert.ts => itwAlertsUtils.ts} (88%) delete mode 100644 ts/features/it-wallet/utils/itwButtonsUtils.tsx rename ts/features/it-wallet/utils/{cie.ts => itwCieUtils.ts} (70%) rename ts/features/it-wallet/utils/{mocks.ts => itwMocksUtils.ts} (100%) rename ts/features/it-wallet/{saga => utils}/itwSagaUtils.ts (100%) rename ts/features/it-wallet/utils/{types.ts => itwTypesUtils.ts} (88%) delete mode 100644 ts/features/it-wallet/utils/navigation.ts diff --git a/ts/features/barcode/screens/BarcodeScanScreen.tsx b/ts/features/barcode/screens/BarcodeScanScreen.tsx index baf92871c46..bd593eb1a33 100644 --- a/ts/features/barcode/screens/BarcodeScanScreen.tsx +++ b/ts/features/barcode/screens/BarcodeScanScreen.tsx @@ -149,7 +149,7 @@ const BarcodeScanScreen = () => { }; NavigationService.dispatchNavigationAction( CommonActions.navigate(ITW_ROUTES.MAIN, { - screen: ITW_ROUTES.PRESENTATION.PID.REMOTE.CHECKS, + screen: ITW_ROUTES.PRESENTATION.PID.REMOTE.INIT, params }) ); diff --git a/ts/features/it-wallet/components/ItwClaimsWrapper.tsx b/ts/features/it-wallet/components/ItwClaimsWrapper.tsx index 0ad8935a88a..19f6b735259 100644 --- a/ts/features/it-wallet/components/ItwClaimsWrapper.tsx +++ b/ts/features/it-wallet/components/ItwClaimsWrapper.tsx @@ -4,7 +4,7 @@ import { H6, IOColors } from "@pagopa/io-app-design-system"; import { CredentialCatalogDisplay, getImageFromCredentialType -} from "../utils/mocks"; +} from "../utils/itwMocksUtils"; /** * Props of the component. diff --git a/ts/features/it-wallet/components/ItwCredentialCard.tsx b/ts/features/it-wallet/components/ItwCredentialCard.tsx index 1dd3cfb89a0..040b5472802 100644 --- a/ts/features/it-wallet/components/ItwCredentialCard.tsx +++ b/ts/features/it-wallet/components/ItwCredentialCard.tsx @@ -10,8 +10,8 @@ import customVariables from "../../../theme/variables"; import { CredentialCatalogDisplay, getImageFromCredentialType -} from "../utils/mocks"; -import { ParsedCredential } from "../utils/types"; +} from "../utils/itwMocksUtils"; +import { ParsedCredential } from "../utils/itwTypesUtils"; /** * Common props for the component. diff --git a/ts/features/it-wallet/components/ItwCredentialClaimsList.tsx b/ts/features/it-wallet/components/ItwCredentialClaimsList.tsx index 2e5aae65461..f1eec0911d9 100644 --- a/ts/features/it-wallet/components/ItwCredentialClaimsList.tsx +++ b/ts/features/it-wallet/components/ItwCredentialClaimsList.tsx @@ -5,9 +5,9 @@ import { SdJwt } from "@pagopa/io-react-native-wallet"; import { useNavigation } from "@react-navigation/native"; import I18n from "../../../i18n"; import { useItwInfoBottomSheet } from "../hooks/useItwInfoBottomSheet"; -import { StoredCredential } from "../utils/types"; +import { StoredCredential } from "../utils/itwTypesUtils"; import { parseClaims, sortClaims } from "../utils/itwClaimsUtils"; -import { CredentialType, mapAssuranceLevel } from "../utils/mocks"; +import { CredentialType, mapAssuranceLevel } from "../utils/itwMocksUtils"; import { IOStackNavigationProp } from "../../../navigation/params/AppParamsList"; import { ItwParamsList } from "../navigation/ItwParamsList"; import ItwCredentialClaim from "./ItwCredentialClaim"; diff --git a/ts/features/it-wallet/components/cie/CieNfcOverlay.tsx b/ts/features/it-wallet/components/cie/CieNfcOverlay.tsx index 920afd6f849..8eb152f9cfb 100644 --- a/ts/features/it-wallet/components/cie/CieNfcOverlay.tsx +++ b/ts/features/it-wallet/components/cie/CieNfcOverlay.tsx @@ -13,18 +13,18 @@ import { ScreenContentHeader } from "../../../../components/screens/ScreenConten import { ITW_ROUTES } from "../../navigation/ItwRoutes"; import { IOStackNavigationRouteProps } from "../../../../navigation/params/AppParamsList"; import { ItwParamsList } from "../../navigation/ItwParamsList"; -import { openNFCSettings } from "../../utils/cie"; +import { itwOpenNFCSettings } from "../../utils/itwCieUtils"; type NavigationProps = IOStackNavigationRouteProps< ItwParamsList, - "ITW_ISSUING_PID_CIE_CARD_READER_SCREEN" + "ITW_ISSUANCE_PID_CIE_CARD_READER_SCREEN" >; type Props = ReduxProps & NavigationProps; export default class CieNfcOverlay extends React.PureComponent { private handleOnPressActivateNFC = async () => { - await openNFCSettings(); + await itwOpenNFCSettings(); }; // FIX ME: the same alert is displayed during all the onboarding @@ -42,7 +42,7 @@ export default class CieNfcOverlay extends React.PureComponent { style: "default", onPress: () => this.props.navigation.navigate(ITW_ROUTES.MAIN, { - screen: ITW_ROUTES.ISSUING.PID.AUTH_INFO + screen: ITW_ROUTES.ISSUANCE.PID.AUTH_INFO }) } ] diff --git a/ts/features/it-wallet/navigation/ItwParamsList.ts b/ts/features/it-wallet/navigation/ItwParamsList.ts index 6e51aa00421..c88b14c39b7 100644 --- a/ts/features/it-wallet/navigation/ItwParamsList.ts +++ b/ts/features/it-wallet/navigation/ItwParamsList.ts @@ -1,48 +1,49 @@ import { ItwPrCredentialDetailsScreenNavigationParams } from "../screens/presentation/ItwPrCredentialDetails"; -import { ItwIssuingPidRequestScreenNavigationParams } from "../screens/issuing/pid/ItwIssuingPidRequestScreen"; -import { ItwCieCardReaderScreenNavigationParams } from "../screens/issuing/pid/cie/ItwCieCardReaderScreen"; -import { ItwCieConsentDataUsageScreenNavigationParams } from "../screens/issuing/pid/cie/ItwCieConsentDataUsageScreen"; -import { ItwCieWrongPinScreenNavigationParams } from "../screens/issuing/pid/cie/ItwCieWrongPinScreen"; +import { ItwIssuancePidRequestScreenNavigationParams } from "../screens/issuance/pid/ItwIssuancePidRequestScreen"; +import { ItwCieCardReaderScreenNavigationParams } from "../screens/issuance/pid/cie/ItwCieCardReaderScreen"; +import { ItwCieConsentDataUsageScreenNavigationParams } from "../screens/issuance/pid/cie/ItwCieConsentDataUsageScreen"; +import { ItwCieWrongPinScreenNavigationParams } from "../screens/issuance/pid/cie/ItwCieWrongPinScreen"; import { ItwPrRemotePidChecksScreenNavigationParams } from "../screens/presentation/remote/pid/ItwPrRemotePidChecksScreen"; import { ITW_ROUTES } from "./ItwRoutes"; export type ItwParamsList = { - // ISSUING PID - [ITW_ROUTES.ISSUING.PID.INFO]: undefined; - [ITW_ROUTES.ISSUING.PID.AUTH]: undefined; - [ITW_ROUTES.ISSUING.PID.AUTH_INFO]: undefined; - [ITW_ROUTES.ISSUING.PID.REQUEST]: ItwIssuingPidRequestScreenNavigationParams; - [ITW_ROUTES.ISSUING.PID.PREVIEW]: undefined; - [ITW_ROUTES.ISSUING.PID.ADDING]: undefined; + // ISSUANCE PID + [ITW_ROUTES.ISSUANCE.PID.INFO]: undefined; + [ITW_ROUTES.ISSUANCE.PID.AUTH]: undefined; + [ITW_ROUTES.ISSUANCE.PID.AUTH_INFO]: undefined; + [ITW_ROUTES.ISSUANCE.PID + .REQUEST]: ItwIssuancePidRequestScreenNavigationParams; + [ITW_ROUTES.ISSUANCE.PID.PREVIEW]: undefined; + [ITW_ROUTES.ISSUANCE.PID.STORE]: undefined; - // ISSUING PID CIE - [ITW_ROUTES.ISSUING.PID.CIE.EXPIRED_SCREEN]: undefined; - [ITW_ROUTES.ISSUING.PID.CIE.PIN_SCREEN]: undefined; - [ITW_ROUTES.ISSUING.PID.CIE + // ISSUANCE PID CIE + [ITW_ROUTES.ISSUANCE.PID.CIE.EXPIRED_SCREEN]: undefined; + [ITW_ROUTES.ISSUANCE.PID.CIE.PIN_SCREEN]: undefined; + [ITW_ROUTES.ISSUANCE.PID.CIE .CARD_READER_SCREEN]: ItwCieCardReaderScreenNavigationParams; - [ITW_ROUTES.ISSUING.PID.CIE + [ITW_ROUTES.ISSUANCE.PID.CIE .CONSENT_DATA_USAGE]: ItwCieConsentDataUsageScreenNavigationParams; - [ITW_ROUTES.ISSUING.PID.CIE + [ITW_ROUTES.ISSUANCE.PID.CIE .WRONG_PIN_SCREEN]: ItwCieWrongPinScreenNavigationParams; - [ITW_ROUTES.ISSUING.PID.CIE.PIN_TEMP_LOCKED_SCREEN]: undefined; + [ITW_ROUTES.ISSUANCE.PID.CIE.PIN_TEMP_LOCKED_SCREEN]: undefined; - // ISSUING CREDENTIALS - [ITW_ROUTES.ISSUING.CREDENTIAL.CATALOG]: undefined; - [ITW_ROUTES.ISSUING.CREDENTIAL.CHECKS]: undefined; - [ITW_ROUTES.ISSUING.CREDENTIAL.AUTH]: undefined; - [ITW_ROUTES.ISSUING.CREDENTIAL.PREVIEW]: undefined; + // ISSUANCE CREDENTIALS + [ITW_ROUTES.ISSUANCE.CREDENTIAL.CATALOG]: undefined; + [ITW_ROUTES.ISSUANCE.CREDENTIAL.CHECKS]: undefined; + [ITW_ROUTES.ISSUANCE.CREDENTIAL.AUTH]: undefined; + [ITW_ROUTES.ISSUANCE.CREDENTIAL.PREVIEW]: undefined; // PRESENTATION REMOTE PID [ITW_ROUTES.PRESENTATION.PID.DETAILS]: undefined; [ITW_ROUTES.PRESENTATION.PID.REMOTE - .CHECKS]: ItwPrRemotePidChecksScreenNavigationParams; + .INIT]: ItwPrRemotePidChecksScreenNavigationParams; [ITW_ROUTES.PRESENTATION.PID.REMOTE.DATA]: undefined; [ITW_ROUTES.PRESENTATION.PID.REMOTE.RESULT]: undefined; // PRESENTATION REMOTE CREDENTIAL [ITW_ROUTES.PRESENTATION.CREDENTIAL .DETAILS]: ItwPrCredentialDetailsScreenNavigationParams; - [ITW_ROUTES.PRESENTATION.CREDENTIAL.REMOTE.CHECKS]: undefined; + [ITW_ROUTES.PRESENTATION.CREDENTIAL.REMOTE.INIT]: undefined; [ITW_ROUTES.PRESENTATION.CREDENTIAL.REMOTE.DATA]: undefined; [ITW_ROUTES.PRESENTATION.CREDENTIAL.REMOTE.RESULT]: undefined; diff --git a/ts/features/it-wallet/navigation/ItwRoutes.ts b/ts/features/it-wallet/navigation/ItwRoutes.ts index 1b90e9b1c0a..b85efeb9fd9 100644 --- a/ts/features/it-wallet/navigation/ItwRoutes.ts +++ b/ts/features/it-wallet/navigation/ItwRoutes.ts @@ -1,34 +1,34 @@ export const ITW_ROUTES = { MAIN: "ITW_MAIN" as const, - ISSUING: { + ISSUANCE: { PID: { CIE: { - EXPIRED_SCREEN: "ITW_ISSUING_PID_CIE_EXPIRED_SCREEN", - PIN_SCREEN: "ITW_ISSUING_PID_CIE_PIN_SCREEN", - CARD_READER_SCREEN: "ITW_ISSUING_PID_CIE_CARD_READER_SCREEN", - CONSENT_DATA_USAGE: "ITW_ISSUING_PID_CIE_CONSENT_DATA_USAGE", - WRONG_PIN_SCREEN: "ITW_ISSUING_PID_CIE_WRONG_PIN_SCREEN", - PIN_TEMP_LOCKED_SCREEN: "ITW_ISSUING_PID_CIE_PIN_TEMP_LOCKED_SCREEN" + EXPIRED_SCREEN: "ITW_ISSUANCE_PID_CIE_EXPIRED_SCREEN", + PIN_SCREEN: "ITW_ISSUANCE_PID_CIE_PIN_SCREEN", + CARD_READER_SCREEN: "ITW_ISSUANCE_PID_CIE_CARD_READER_SCREEN", + CONSENT_DATA_USAGE: "ITW_ISSUANCE_PID_CIE_CONSENT_DATA_USAGE", + WRONG_PIN_SCREEN: "ITW_ISSUANCE_PID_CIE_WRONG_PIN_SCREEN", + PIN_TEMP_LOCKED_SCREEN: "ITW_ISSUANCE_PID_CIE_PIN_TEMP_LOCKED_SCREEN" } as const, - INFO: "ITW_ISSUING_PID_INFO", - AUTH: "ITW_ISSUING_PID_AUTH", - AUTH_INFO: "ITW_ISSUING_PID_AUTH_INFO", - REQUEST: "ITW_ISSUING_PID_REQUEST", - PREVIEW: "ITW_ISSUING_PID_PREVIEW", - ADDING: "ITW_ISSUING_PID_ADDING" + INFO: "ITW_ISSUANCE_PID_INFO", + AUTH: "ITW_ISSUANCE_PID_AUTH", + AUTH_INFO: "ITW_ISSUANCE_PID_AUTH_INFO", + REQUEST: "ITW_ISSUANCE_PID_REQUEST", + PREVIEW: "ITW_ISSUANCE_PID_PREVIEW", + STORE: "ITW_ISSUANCE_PID_STORE" } as const, CREDENTIAL: { - CATALOG: "ITW_ISSUING_CREDENTIAL_CATALOG", - CHECKS: "ITW_ISSUING_CREDENTIAL_CHECKS", - AUTH: "ITW_ISSUING_CREDENTIAL_AUTH", - PREVIEW: "ITW_ISSUING_CREDENTIAL_PREVIEW" + CATALOG: "ITW_ISSUANCE_CREDENTIAL_CATALOG", + CHECKS: "ITW_ISSUANCE_CREDENTIAL_CHECKS", + AUTH: "ITW_ISSUANCE_CREDENTIAL_AUTH", + PREVIEW: "ITW_ISSUANCE_CREDENTIAL_PREVIEW" } as const } as const, PRESENTATION: { PID: { DETAILS: "ITW_PRESENTATION_PID_DETAILS", REMOTE: { - CHECKS: "ITW_PRESENTATION_PID_REMOTE_CHECKS", + INIT: "ITW_PRESENTATION_PID_REMOTE_INIT", DATA: "ITW_PRESENTATION_PID_REMOTE_DATA", RESULT: "ITW_PRESENTATION_PID_REMOTE_RESULT" } as const @@ -36,7 +36,7 @@ export const ITW_ROUTES = { CREDENTIAL: { DETAILS: "ITW_PRESENTATION_CREDENTIAL_DETAILS", REMOTE: { - CHECKS: "ITW_PRESENTATION_CREDENTIAL_CHECKS", + INIT: "ITW_PRESENTATION_CREDENTIAL_INIT", DATA: "ITW_PRESENTATION_CREDENTIAL_DATA", RESULT: "ITW_PRESETATION_CREDENTIAL_RESULT" } as const diff --git a/ts/features/it-wallet/navigation/ItwStackNavigator.tsx b/ts/features/it-wallet/navigation/ItwStackNavigator.tsx index 3b499c6fc15..1439901f7a9 100644 --- a/ts/features/it-wallet/navigation/ItwStackNavigator.tsx +++ b/ts/features/it-wallet/navigation/ItwStackNavigator.tsx @@ -1,31 +1,31 @@ import * as React from "react"; import { createStackNavigator } from "@react-navigation/stack"; import { isGestureEnabled } from "../../../utils/navigation"; -import ItwCiePinScreen from "../screens/issuing/pid/cie/ItwCiePinScreen"; -import ItwCieCardReaderScreen from "../screens/issuing/pid/cie/ItwCieCardReaderScreen"; -import ItwCieConsentDataUsageScreen from "../screens/issuing/pid/cie/ItwCieConsentDataUsageScreen"; -import ItwCieExpiredOrInvalidScreen from "../screens/issuing/pid/cie/ItwCieExpiredOrInvalidScreen"; -import ItwCieWrongPinScreen from "../screens/issuing/pid/cie/ItwCieWrongPinScreen"; -import ItwIssuingPidInfoScreen from "../screens/issuing/pid/ItwIssuingPidInfoScreen"; -import ItwIssuingPidAuthInfoScreen from "../screens/issuing/pid/ItwIssuingPidAuthInfoScreen"; -import ItwPidPreviewScreen from "../screens/issuing/pid/ItwPidPreviewScreen"; -import ItwIssuingPidAddingScreen from "../screens/issuing/pid/ItwIssuingPidAddingScreen"; +import ItwCiePinScreen from "../screens/issuance/pid/cie/ItwCiePinScreen"; +import ItwCieCardReaderScreen from "../screens/issuance/pid/cie/ItwCieCardReaderScreen"; +import ItwCieConsentDataUsageScreen from "../screens/issuance/pid/cie/ItwCieConsentDataUsageScreen"; +import ItwCieExpiredOrInvalidScreen from "../screens/issuance/pid/cie/ItwCieExpiredOrInvalidScreen"; +import ItwCieWrongPinScreen from "../screens/issuance/pid/cie/ItwCieWrongPinScreen"; +import ItwIssuancePidInfoScreen from "../screens/issuance/pid/ItwIssuancePidInfoScreen"; +import ItwIssuingPidAuthInfoScreen from "../screens/issuance/pid/ItwIssuancePidAuthInfoScreen"; +import ItwIssuancePidPreviewScreen from "../screens/issuance/pid/ItwIssuancePidPreviewScreen"; +import ItwIssuingPidStoreScreen from "../screens/issuance/pid/ItwIssuancePidStoreScreen"; import ItwPrPidDetails from "../screens/presentation/ItwPrPidDetails"; -import ItwIssuingPidRequestScreen from "../screens/issuing/pid/ItwIssuingPidRequestScreen"; +import ItwIssuancePidRequestScreen from "../screens/issuance/pid/ItwIssuancePidRequestScreen"; import ItwPrRemotePidChecksScreen from "../screens/presentation/remote/pid/ItwPrRemotePidChecksScreen"; import ItwPrRemotePidResultScreen from "../screens/presentation/remote/pid/ItwPrRemotePidResultScreen"; -import ItwIssuingPidAuthScreen from "../screens/issuing/pid/ItwIssuingPidAuthScreen"; +import ItwIssuancePidAuthScreen from "../screens/issuance/pid/ItwIssuancePidAuthScreen"; import ItwGenericNotAvailableScreen from "../screens/generic/ItwGenericNotAvailableScreen"; -import ItwIssuingCredentialPreviewScreen from "../screens/issuing/credential/ItwIssuingCredentialPreviewScreen"; -import ItwIssuingCredentialAuthScreen from "../screens/issuing/credential/ItwIssuingCredentialAuthScreen"; -import ItwPrRemoteCredentialChecksScreen from "../screens/presentation/remote/credential/ItwPrRemoteCredentialChecksScreen"; +import ItwIssuanceCredentialPreviewScreen from "../screens/issuance/credential/ItwIssuanceCredentialPreviewScreen"; +import ItwIssuanceCredentialAuthScreen from "../screens/issuance/credential/ItwIssuanceCredentialAuthScreen"; import ItwPrRemoteCredentialDataScreen from "../screens/presentation/remote/credential/ItwPrRemoteCredentialDataScreen"; import ItwPrRemoteCredentialResultScreen from "../screens/presentation/remote/credential/ItwPrRemoteCredentialResultScreen"; -import ItwIssuingCredentialsChecksScreen from "../screens/issuing/credential/ItwIssuingCredentialChecksScreen"; -import ItwIssuingCredentialCatalogScreen from "../screens/issuing/credential/ItwIssuingCredentialCatalogScreen"; +import ItwIssuanceCredentialChecksScreen from "../screens/issuance/credential/ItwIssuanceCredentialChecksScreen"; +import ItwIssuanceCredentialCatalogScreen from "../screens/issuance/credential/ItwIssuanceCredentialCatalogScreen"; import ItwPrCredentialDetailsScreen from "../screens/presentation/ItwPrCredentialDetails"; import ItwPrRemotePidDataScreen from "../screens/presentation/remote/pid/ItwPrRemotePidDataScreen"; import ItwPrProximityQrCodeScreen from "../screens/presentation/ItwPrProximityQrCodeScreen"; +import ItwPrRemoteCredentialInitScreen from "../screens/presentation/remote/credential/ItwPrRemoteCredentialChecksScreen"; import { ItwParamsList } from "./ItwParamsList"; import { ITW_ROUTES } from "./ItwRoutes"; @@ -36,70 +36,70 @@ export const ItwStackNavigator = () => ( headerMode={"none"} screenOptions={{ gestureEnabled: isGestureEnabled }} > - {/* ISSUING PID CIE */} + {/* ISSUANCE PID CIE */} - {/* ISSUING PID */} + {/* ISSUANCE PID */} - {/* ISSUING CREDENTIAL */} + {/* ISSUANCE CREDENTIAL */} {/* PRESENTATION PID */} @@ -108,7 +108,7 @@ export const ItwStackNavigator = () => ( component={ItwPrPidDetails} /> ( component={ItwPrCredentialDetailsScreen} /> { + // Watch for login by CIE + const watchCieAuthentication = yield* fork(watchItwPidIssuingCieAuthSaga); + + // Wait until the user has successfully authenticated with CIE + // FIXME: show an error on LOGIN_FAILED? + const action = yield* take(itwLoginSuccess); + + yield* cancel(watchCieAuthentication); + + // stop cie manager from listening nfc + yield* call(itwStopCieManager); + + return action.payload.token; +} + +export function* handleStopAuthenticationSaga(): Generator< + ReduxSagaEffect, + void, + any +> { + // stop cie manager from listening nfc + yield* call(itwStopCieManager); +} + export function* handleActivationStart(): SagaIterator { yield* call( NavigationService.dispatchNavigationAction, CommonActions.navigate(ITW_ROUTES.MAIN, { - screen: ITW_ROUTES.ISSUING.PID.INFO + screen: ITW_ROUTES.ISSUANCE.PID.INFO }) ); yield* call(handleStartAuthenticationSaga); diff --git a/ts/features/it-wallet/saga/itwAuthenticationSaga.ts b/ts/features/it-wallet/saga/itwAuthenticationSaga.ts deleted file mode 100644 index 63dfdee175a..00000000000 --- a/ts/features/it-wallet/saga/itwAuthenticationSaga.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { call, cancel, fork, take } from "typed-redux-saga/macro"; -import { ReduxSagaEffect } from "../../../types/utils"; -import { SessionToken } from "../../../types/SessionToken"; -import { loginSuccess } from "../store/actions/itwCieActions"; -import { stopCieManager, watchCieAuthenticationSaga } from "./itwCieSaga"; - -/** - * A saga that makes the user go through the authentication process until - * a SessionToken gets produced. - */ -export function* handleStartAuthenticationSaga(): Generator< - ReduxSagaEffect, - SessionToken, - any -> { - // Watch for login by CIE - const watchCieAuthentication = yield* fork(watchCieAuthenticationSaga); - - // Wait until the user has successfully authenticated with CIE - // FIXME: show an error on LOGIN_FAILED? - const action = yield* take(loginSuccess); - - yield* cancel(watchCieAuthentication); - - // stop cie manager from listening nfc - yield* call(stopCieManager); - - return action.payload.token; -} - -export function* handleStopAuthenticationSaga(): Generator< - ReduxSagaEffect, - void, - any -> { - // stop cie manager from listening nfc - yield* call(stopCieManager); -} diff --git a/ts/features/it-wallet/saga/new/itwIssuanceSaga.ts b/ts/features/it-wallet/saga/itwIssuanceCredentialSaga.ts similarity index 80% rename from ts/features/it-wallet/saga/new/itwIssuanceSaga.ts rename to ts/features/it-wallet/saga/itwIssuanceCredentialSaga.ts index 6457143d3d4..6c2f1576514 100644 --- a/ts/features/it-wallet/saga/new/itwIssuanceSaga.ts +++ b/ts/features/it-wallet/saga/itwIssuanceCredentialSaga.ts @@ -11,52 +11,55 @@ import { toError } from "fp-ts/lib/Either"; import { CommonActions } from "@react-navigation/native"; import { IOToast } from "@pagopa/io-app-design-system"; import { - itwConfirmStoreCredential, - itwIssuanceChecks, - itwIssuanceGetCredential -} from "../../store/actions/itwIssuanceActions"; -import { ItWalletErrorTypes } from "../../utils/itwErrorsUtils"; -import { itwWiaRequest } from "../../store/actions/itwWiaActions"; + itwIssuanceCredentialStore, + itwIssuanceCredentialChecks, + itwIssuanceCredential +} from "../store/actions/itwIssuanceCredentialActions"; +import { ItWalletErrorTypes } from "../utils/itwErrorsUtils"; +import { itwWiaRequest } from "../store/actions/itwWiaActions"; import { - itwCredentialsPidSelector, - itwCredentialsSelector -} from "../../store/reducers/itwCredentialsReducer"; + itwPersistedCredentialsValuePidSelector, + itwPersistedCredentialsValueSelector +} from "../store/reducers/itwPersistedCredentialsReducer"; import { ITW_PID_KEY_TAG, ITW_WIA_KEY_TAG, getOrGenerateCyptoKey -} from "../../utils/itwSecureStorageUtils"; -import { itwCredentialsAddCredential } from "../../store/actions/itwCredentialsActions"; +} from "../utils/itwSecureStorageUtils"; import { - itwIssuanceChecksDataSelector, + itwIssuanceCredentialChecksValueSelector, itwIssuanceResultDataSelector -} from "../../store/reducers/new/itwIssuanceReducer"; -import I18n from "../../../../i18n"; -import NavigationService from "../../../../navigation/NavigationService"; -import ROUTES from "../../../../navigation/routes"; -import { walletProviderBaseUrl } from "../../../../config"; -import { StoredCredential } from "../../utils/types"; -import { verifyPin } from "../itwSagaUtils"; +} from "../store/reducers/itwIssuanceCredentialReducer"; +import I18n from "../../../i18n"; +import NavigationService from "../../../navigation/NavigationService"; +import ROUTES from "../../../navigation/routes"; +import { walletProviderBaseUrl } from "../../../config"; +import { StoredCredential } from "../utils/itwTypesUtils"; +import { verifyPin } from "../utils/itwSagaUtils"; +import { itwPersistedCredentialsStore } from "../store/actions/itwPersistedCredentialsActions"; /** * Watcher for issuance related sagas. */ -export function* watchItwIssuanceSaga(): SagaIterator { - yield* takeLatest(itwIssuanceChecks.request, handleIssuanceChecks); +export function* watchItwIssuanceCredentialSaga(): SagaIterator { yield* takeLatest( - itwIssuanceGetCredential.request, - handleIssuanceGetCredential + itwIssuanceCredentialChecks.request, + handleItwIssuanceCredentialChecks + ); + yield* takeLatest(itwIssuanceCredential.request, handleItwIssuanceCredential); + yield* takeLatest( + itwIssuanceCredentialStore, + handleItwIssuanceCredentialStore ); - yield* takeLatest(itwConfirmStoreCredential, handleAddCredentialWithPin); } /** * Saga which handles the issuance checks before starting the issuance flow. * @param payload - The payload of the action which includes the credentialType, the issuerUrl and the displayData which are currently mocked. */ -export function* handleIssuanceChecks({ +export function* handleItwIssuanceCredentialChecks({ payload: { credentialType, issuerUrl, displayData } -}: ActionType): SagaIterator { +}: ActionType): SagaIterator { try { // Issuer conf + trust const { issuerConf } = yield* call( @@ -76,19 +79,21 @@ export function* handleIssuanceChecks({ } // check if credential is already in the wallet - const storedCredentials = yield* select(itwCredentialsSelector); + const storedCredentials = yield* select( + itwPersistedCredentialsValueSelector + ); const found = storedCredentials .filter(O.isSome) .find(e => e.value.credentialType === credentialType); if (found) { yield* put( - itwIssuanceChecks.failure({ + itwIssuanceCredentialChecks.failure({ code: ItWalletErrorTypes.CREDENTIAL_ALREADY_EXISTING_ERROR }) ); } else { yield* put( - itwIssuanceChecks.success({ + itwIssuanceCredentialChecks.success({ credentialType, issuerUrl, displayData, @@ -100,7 +105,7 @@ export function* handleIssuanceChecks({ } catch (e) { const res = toError(e); yield* put( - itwIssuanceChecks.failure({ + itwIssuanceCredentialChecks.failure({ code: ItWalletErrorTypes.CREDENTIAL_CHECKS_GENERIC_ERROR, message: res.message }) @@ -111,10 +116,12 @@ export function* handleIssuanceChecks({ /** * Saga which handles the issuance flow. */ -export function* handleIssuanceGetCredential(): SagaIterator { +export function* handleItwIssuanceCredential(): SagaIterator { try { yield* call(verifyPin); - const issuanceData = yield* select(itwIssuanceChecksDataSelector); + const issuanceData = yield* select( + itwIssuanceCredentialChecksValueSelector + ); if (O.isNone(issuanceData)) { throw new Error("Unexpected issuanceData"); @@ -193,7 +200,7 @@ export function* handleIssuanceGetCredential(): SagaIterator { ); yield* put( - itwIssuanceGetCredential.success({ + itwIssuanceCredential.success({ issuerConf, keyTag, credential, @@ -207,7 +214,7 @@ export function* handleIssuanceGetCredential(): SagaIterator { } catch (e) { const res = toError(e); yield* put( - itwIssuanceGetCredential.failure({ + itwIssuanceCredential.failure({ code: ItWalletErrorTypes.CREDENTIAL_CHECKS_GENERIC_ERROR, message: res.message }) @@ -215,35 +222,6 @@ export function* handleIssuanceGetCredential(): SagaIterator { } } -/** - * Saga which handles the addition of a credential to the wallet by showing the pin screen. - */ -function* handleAddCredentialWithPin() { - try { - const resultData = yield* select(itwIssuanceResultDataSelector); - if (O.isNone(resultData)) { - throw new Error(); - } - yield* call(verifyPin); - yield* put(itwCredentialsAddCredential.success(resultData.value)); - - yield* call( - NavigationService.dispatchNavigationAction, - CommonActions.navigate(ROUTES.MAIN, { - screen: ROUTES.ITWALLET_HOME - }) - ); - - IOToast.success( - I18n.t("features.itWallet.issuing.credentialPreviewScreen.toast.success") - ); - } catch (e) { - IOToast.error( - I18n.t("features.itWallet.issuing.credentialPreviewScreen.toast.failure") - ); - } -} - /** * Function which handles the completion of the user authorization with the PID. * @param requestURI - The request URI. @@ -338,7 +316,7 @@ function* getWalletInstanceAttestation(): Iterator< * @returns the PID and the crypto context. */ function* getPID(): Iterator { - const maybePid = yield* select(itwCredentialsPidSelector); + const maybePid = yield* select(itwPersistedCredentialsValuePidSelector); if (O.isNone(maybePid)) { const message = `Expecting response_code from sendAuthorizationResponse, received undefined`; throw new Error(message); @@ -346,3 +324,32 @@ function* getPID(): Iterator { const pidCryptoContext = createCryptoContextFor(ITW_PID_KEY_TAG); return yield* call(() => [maybePid.value, pidCryptoContext] as const); } + +/** + * Saga which handles the addition of a credential to the wallet by showing the pin screen. + */ +function* handleItwIssuanceCredentialStore() { + try { + const resultData = yield* select(itwIssuanceResultDataSelector); + if (O.isNone(resultData)) { + throw new Error(); + } + yield* call(verifyPin); + yield* put(itwPersistedCredentialsStore(resultData.value)); + + yield* call( + NavigationService.dispatchNavigationAction, + CommonActions.navigate(ROUTES.MAIN, { + screen: ROUTES.ITWALLET_HOME + }) + ); + + IOToast.success( + I18n.t("features.itWallet.issuing.credentialPreviewScreen.toast.success") + ); + } catch (e) { + IOToast.error( + I18n.t("features.itWallet.issuing.credentialPreviewScreen.toast.failure") + ); + } +} diff --git a/ts/features/it-wallet/saga/itwCieSaga.ts b/ts/features/it-wallet/saga/itwIssuancePidCieAuthSaga.ts similarity index 58% rename from ts/features/it-wallet/saga/itwCieSaga.ts rename to ts/features/it-wallet/saga/itwIssuancePidCieAuthSaga.ts index c982c320ed3..c1a87bfe992 100644 --- a/ts/features/it-wallet/saga/itwCieSaga.ts +++ b/ts/features/it-wallet/saga/itwIssuancePidCieAuthSaga.ts @@ -3,31 +3,31 @@ import { Millisecond } from "@pagopa/ts-commons/lib/units"; import { SagaIterator } from "redux-saga"; import { call, put, takeLatest } from "typed-redux-saga/macro"; import { - cieIsSupported, - hasApiLevelSupport, - hasNFCFeature, - nfcIsEnabled -} from "../store/actions/itwCieActions"; + itwCieIsSupported, + itwHasApiLevelSupport, + itwHasNFCFeature, + itwNfcIsEnabled +} from "../store/actions/itwIssuancePidCieActions"; import { SagaCallReturnType } from "../../../types/utils"; import { convertUnknownToError } from "../../../utils/errors"; import { startTimer } from "../../../utils/timer"; -export function* watchCieAuthenticationSaga(): SagaIterator { - // Trigger a saga on nfcIsEnabled to check if NFC is enabled or not - yield* takeLatest(nfcIsEnabled.request, checkNfcEnablementSaga); +export function* watchItwPidIssuingCieAuthSaga(): SagaIterator { + // Trigger a saga on itwNfcIsEnabled to check if NFC is enabled or not + yield* takeLatest(itwNfcIsEnabled.request, itwCheckNfcEnablementSaga); // check if the device is compliant with CIE authentication yield* call( - checkCieAvailabilitySaga, + itwCheckCieAvailabilitySaga, cieManager.isCIEAuthenticationSupported ); // check if the device has the API Level compliant with CIE authentication - yield* call(checkHasApiLevelSupportSaga, cieManager.hasApiLevelSupport); + yield* call(itwCheckHasApiLevelSupportSaga, cieManager.hasApiLevelSupport); // check if the device has the NFC Feature to support CIE authentication - yield* call(checkHasNfcFeatureSaga, cieManager.hasNFCFeature); + yield* call(itwCheckitwHasNFCFeatureSaga, cieManager.hasNFCFeature); } // stop cie manager to listen nfc tags -export function* stopCieManager(): SagaIterator { +export function* itwStopCieManager(): SagaIterator { try { cieManager.removeAllListeners(); yield* call(cieManager.stopListeningNFC); @@ -40,15 +40,15 @@ export function* stopCieManager(): SagaIterator { * check if the device has the API Level to support CIE authentication * see https://github.com/pagopa/io-cie-android-sdk/blob/29cc1165bbd3d90d61239369f22ec78b2e4c8f6c/index.js#L155 */ -export function* checkHasApiLevelSupportSaga( - hasApiLevelSupported: (typeof cieManager)["hasApiLevelSupport"] +export function* itwCheckHasApiLevelSupportSaga( + itwHasApiLevelSupported: (typeof cieManager)["hasApiLevelSupport"] ): SagaIterator { try { - const response: SagaCallReturnType = - yield* call(hasApiLevelSupported); - yield* put(hasApiLevelSupport.success(response)); + const response: SagaCallReturnType = + yield* call(itwHasApiLevelSupported); + yield* put(itwHasApiLevelSupport.success(response)); } catch (e) { - yield* put(hasApiLevelSupport.failure(convertUnknownToError(e))); + yield* put(itwHasApiLevelSupport.failure(convertUnknownToError(e))); } } @@ -56,15 +56,15 @@ export function* checkHasApiLevelSupportSaga( * check if the device has the NFC Feature to support CIE authentication * see https://github.com/pagopa/io-cie-android-sdk/blob/29cc1165bbd3d90d61239369f22ec78b2e4c8f6c/index.js#L169 */ -export function* checkHasNfcFeatureSaga( - hasNfcFeatureSupported: (typeof cieManager)["hasNFCFeature"] +export function* itwCheckitwHasNFCFeatureSaga( + itwHasNFCFeatureSupported: (typeof cieManager)["hasNFCFeature"] ): SagaIterator { try { - const response: SagaCallReturnType = - yield* call(hasNfcFeatureSupported); - yield* put(hasNFCFeature.success(response)); + const response: SagaCallReturnType = + yield* call(itwHasNFCFeatureSupported); + yield* put(itwHasNFCFeature.success(response)); } catch (e) { - yield* put(hasNFCFeature.failure(convertUnknownToError(e))); + yield* put(itwHasNFCFeature.failure(convertUnknownToError(e))); } } @@ -72,27 +72,27 @@ export function* checkHasNfcFeatureSaga( * check if the device is compatible with CIE authentication * see https://github.com/pagopa/io-cie-android-sdk/blob/29cc1165bbd3d90d61239369f22ec78b2e4c8f6c/index.js#L125 */ -export function* checkCieAvailabilitySaga( +export function* itwCheckCieAvailabilitySaga( isCIEAuthenticationSupported: (typeof cieManager)["isCIEAuthenticationSupported"] ): SagaIterator { try { const response: SagaCallReturnType = yield* call(isCIEAuthenticationSupported); - yield* put(cieIsSupported.success(response)); + yield* put(itwCieIsSupported.success(response)); } catch (e) { - yield* put(cieIsSupported.failure(convertUnknownToError(e))); + yield* put(itwCieIsSupported.failure(convertUnknownToError(e))); } } const CIE_NFC_STATUS_INTERVAL = 1500 as Millisecond; /** * checks if the nfc is enabled. If it is NOT enbled it checks again with a delay */ -export function* checkNfcEnablementSaga(): SagaIterator { +export function* itwCheckNfcEnablementSaga(): SagaIterator { try { while (true) { const isNfcEnabled: SagaCallReturnType = yield* call(cieManager.isNFCEnabled); - yield* put(nfcIsEnabled.success(isNfcEnabled)); + yield* put(itwNfcIsEnabled.success(isNfcEnabled)); if (isNfcEnabled) { return; } @@ -102,6 +102,6 @@ export function* checkNfcEnablementSaga(): SagaIterator { yield* call(startTimer, CIE_NFC_STATUS_INTERVAL); } } catch (e) { - yield* put(nfcIsEnabled.failure(convertUnknownToError(e))); // TODO: check e type + yield* put(itwNfcIsEnabled.failure(convertUnknownToError(e))); // TODO: check e type } } diff --git a/ts/features/it-wallet/saga/itwPidIssuanceSaga.ts b/ts/features/it-wallet/saga/itwIssuancePidSaga.ts similarity index 75% rename from ts/features/it-wallet/saga/itwPidIssuanceSaga.ts rename to ts/features/it-wallet/saga/itwIssuancePidSaga.ts index 10819c7244d..f96b1a65f53 100644 --- a/ts/features/it-wallet/saga/itwPidIssuanceSaga.ts +++ b/ts/features/it-wallet/saga/itwIssuancePidSaga.ts @@ -6,13 +6,9 @@ import { createCryptoContextFor } from "@pagopa/io-react-native-wallet"; import { ActionType } from "typesafe-actions"; -import * as O from "fp-ts/lib/Option"; +import { CommonActions } from "@react-navigation/native"; import { itwWiaSelector } from "../store/reducers/itwWiaReducer"; import { ItWalletErrorTypes } from "../utils/itwErrorsUtils"; -import { - itwCredentialsAddPid, - itwPid -} from "../store/actions/itwCredentialsActions"; import { itwLifecycleValid } from "../store/actions/itwLifecycleActions"; import { walletProviderBaseUrl } from "../../../config"; import { @@ -20,7 +16,14 @@ import { ITW_WIA_KEY_TAG, getOrGenerateCyptoKey } from "../utils/itwSecureStorageUtils"; -import { verifyPin } from "./itwSagaUtils"; +import { + itwIssuancePid, + itwIssuancePidStore +} from "../store/actions/itwIssuancePidActions"; +import { verifyPin } from "../utils/itwSagaUtils"; +import { itwPersistedCredentialsStore } from "../store/actions/itwPersistedCredentialsActions"; +import NavigationService from "../../../navigation/NavigationService"; +import { ITW_ROUTES } from "../navigation/ItwRoutes"; /** * A dummy implementation of CompleteUserAuthorization that uses static values. @@ -34,25 +37,25 @@ const completeUserAuthorizationWithCIE: Credential.Issuance.CompleteUserAuthoriz /** * Watcher for the IT wallet PID related sagas. */ -export function* watchPidSaga(): SagaIterator { +export function* watchItwIssuancePidSaga(): SagaIterator { /** * Handles a PID issuing request. */ - yield* takeLatest(itwPid.request, handlePidRequest); + yield* takeLatest(itwIssuancePid.request, handleItwIssuancePidSaga); /** * Handles adding a PID to the wallet. */ - yield* takeLatest(itwCredentialsAddPid.request, handleCredentialsAddPid); + yield* takeLatest(itwIssuancePidStore, handleItwIssuancePidStoreSaga); } /* * This saga handles the PID issuing. * It calls the getPid function to get an encoded PID. */ -export function* handlePidRequest({ +export function* handleItwIssuancePidSaga({ payload: { type, issuerUrl, pidData, ...displayData } -}: ActionType): SagaIterator { +}: ActionType): SagaIterator { try { const wiaOption = yield* select(itwWiaSelector); if (isSome(wiaOption)) { @@ -99,7 +102,7 @@ export function* handlePidRequest({ } ); - // Perform strong user authorization to the PID Issuer + // Perform strong user authorozation to the PID Issuer const { code } = yield* call( completeUserAuthorizationWithCIE, requestUri, @@ -119,7 +122,7 @@ export function* handlePidRequest({ ); // Generate fresh key for PID binding - // ensure the key exists befor starting the issuing process + // ensure the key esists befor starting the issuing process yield* call(getOrGenerateCyptoKey, ITW_PID_KEY_TAG); const credentialCryptoContext = createCryptoContextFor(ITW_PID_KEY_TAG); @@ -146,7 +149,7 @@ export function* handlePidRequest({ ); yield* put( - itwPid.success({ + itwIssuancePid.success({ issuerConf, keyTag: ITW_PID_KEY_TAG, credential, @@ -159,15 +162,15 @@ export function* handlePidRequest({ ); } else { yield* put( - itwPid.failure({ - code: ItWalletErrorTypes.PID_ISSUING_ERROR + itwIssuancePid.failure({ + code: ItWalletErrorTypes.PID_ISSUANCE_ERROR }) ); } } catch (err) { yield* put( - itwPid.failure({ - code: ItWalletErrorTypes.PID_ISSUING_ERROR + itwIssuancePid.failure({ + code: ItWalletErrorTypes.PID_ISSUANCE_ERROR }) ); } @@ -177,19 +180,16 @@ export function* handlePidRequest({ * This saga handles adding a PID to the wallet. * As a side effect, it sets the lifecycle of the wallet to valid. */ -export function* handleCredentialsAddPid( - action: ActionType +export function* handleItwIssuancePidStoreSaga( + action: ActionType ): SagaIterator { yield* call(verifyPin); - const pid = action.payload; - if (O.isSome(pid)) { - yield* put(itwCredentialsAddPid.success(pid.value)); - yield* put(itwLifecycleValid()); - } else { - yield* put( - itwCredentialsAddPid.failure({ - code: ItWalletErrorTypes.CREDENTIAL_ADD_ERROR - }) - ); - } + yield* put(itwPersistedCredentialsStore(action.payload)); + yield* put(itwLifecycleValid()); + yield* call( + NavigationService.dispatchNavigationAction, + CommonActions.navigate(ITW_ROUTES.MAIN, { + screen: ITW_ROUTES.ISSUANCE.PID.STORE + }) + ); } diff --git a/ts/features/it-wallet/saga/itwProximitySaga.ts b/ts/features/it-wallet/saga/itwPrProximitySaga.ts similarity index 90% rename from ts/features/it-wallet/saga/itwProximitySaga.ts rename to ts/features/it-wallet/saga/itwPrProximitySaga.ts index c13efb77b0c..65117f98e9c 100644 --- a/ts/features/it-wallet/saga/itwProximitySaga.ts +++ b/ts/features/it-wallet/saga/itwPrProximitySaga.ts @@ -11,18 +11,21 @@ import { } from "../store/actions/itwProximityActions"; import { ItWalletErrorTypes } from "../utils/itwErrorsUtils"; -export function* watchItwProximitySaga(): SagaIterator { +export function* watchItwPrProximitySaga(): SagaIterator { // Trigger a saga on bleIsEnabled to check if BLE is enabled or not yield* takeLatest(bleIsEnabled.request, checkBleEnablementSaga); // Start Proximity Manager yield* takeLatest( startProximityManager.request, - handleStartProximityManagerSaga + handleItwPrProximityStartManagerSaga ); // Get QR code request - yield* takeLatest(generateQrCode.request, handleGenerateQrCodeSaga); + yield* takeLatest( + generateQrCode.request, + handleItwPrProximityGenerateQrCodeSaga + ); // Stop Proximity Manager yield* takeLatest( @@ -32,7 +35,7 @@ export function* watchItwProximitySaga(): SagaIterator { } // start proximity manager -function* handleStartProximityManagerSaga( +function* handleItwPrProximityStartManagerSaga( action: ReturnType ): SagaIterator { try { @@ -58,7 +61,7 @@ function* handleStartProximityManagerSaga( } // generate qr code -function* handleGenerateQrCodeSaga(): SagaIterator { +function* handleItwPrProximityGenerateQrCodeSaga(): SagaIterator { try { const qrCode = yield* call(ProximityManager.generateQrCode); yield* put(generateQrCode.success(qrCode)); diff --git a/ts/features/it-wallet/saga/itwPrRemoteCredentialSaga.ts b/ts/features/it-wallet/saga/itwPrRemoteCredentialSaga.ts new file mode 100644 index 00000000000..bc6798ca55d --- /dev/null +++ b/ts/features/it-wallet/saga/itwPrRemoteCredentialSaga.ts @@ -0,0 +1,51 @@ +import { SagaIterator } from "redux-saga"; +import { put, delay, takeLatest, select, call } from "typed-redux-saga/macro"; +import { + itwPrRemoteCredential, + itwPrRemoteCredentialInit +} from "../store/actions/itwPrRemoteCredentialActions"; +import { itwLifecycleIsValidSelector } from "../store/reducers/itwLifecycleReducer"; +import { ItWalletErrorTypes } from "../utils/itwErrorsUtils"; +import { verifyPin } from "../utils/itwSagaUtils"; + +export function* watchItwPrRemoteCredentialSaga(): SagaIterator { + yield* takeLatest( + itwPrRemoteCredentialInit.request, + handleItwPrRemoteCredentialInitSaga + ); + yield* takeLatest( + itwPrRemoteCredential.request, + handleItwPrRemoteCredentialSaga + ); +} + +/* + * This saga handles the RP presentation checks. + * TODO: add the actual implementation as it currently only delays and returns success. + * action: ActionType + */ +export function* handleItwPrRemoteCredentialInitSaga(): SagaIterator { + // Check if the lifecycle is valid + const isItwLifecycleValid = yield* select(itwLifecycleIsValidSelector); + if (!isItwLifecycleValid) { + yield* put( + itwPrRemoteCredentialInit.failure({ + code: ItWalletErrorTypes.WALLET_NOT_VALID_ERROR + }) + ); + return; + } + yield* delay(1500); + yield* put(itwPrRemoteCredentialInit.success()); +} + +/** + * This saga handles the RP presentation. + * TODO: add the actual implementation as it currently only delays and returns success. + * action: ActionType + */ +export function* handleItwPrRemoteCredentialSaga(): SagaIterator { + yield* call(verifyPin); + yield* delay(1500); + yield* put(itwPrRemoteCredential.success()); +} diff --git a/ts/features/it-wallet/saga/itwPrRemotePidSaga.ts b/ts/features/it-wallet/saga/itwPrRemotePidSaga.ts new file mode 100644 index 00000000000..f9f5d03359d --- /dev/null +++ b/ts/features/it-wallet/saga/itwPrRemotePidSaga.ts @@ -0,0 +1,165 @@ +import { SagaIterator } from "redux-saga"; +import { call, put, select, take, takeLatest } from "typed-redux-saga/macro"; +import { ActionType } from "typesafe-actions"; +import { + Trust, + createCryptoContextFor, + Credential +} from "@pagopa/io-react-native-wallet"; +import * as O from "fp-ts/lib/Option"; +import { + itwPrRemotePidInit, + itwPrRemotePidPresentation +} from "../store/actions/itwPrRemotePidActions"; +import { itwPrRemotePidInitValueSelector } from "../store/reducers/itwPrRemotePidReducer"; +import { itwPersistedCredentialsValuePidSelector } from "../store/reducers/itwPersistedCredentialsReducer"; +import { + ITW_PID_KEY_TAG, + ITW_WIA_KEY_TAG +} from "../utils/itwSecureStorageUtils"; +import { itwWiaSelector } from "../store/reducers/itwWiaReducer"; +import { ItWalletErrorTypes } from "../utils/itwErrorsUtils"; +import { verifyPin } from "../utils/itwSagaUtils"; +import { itwLifecycleIsValidSelector } from "../store/reducers/itwLifecycleReducer"; +import { itwWiaRequest } from "../store/actions/itwWiaActions"; + +/** + * Watcher for the IT wallet Relying Party related sagas. + */ +export function* watchItwPrRemotePid(): SagaIterator { + /** + * Handles the PID remote presentation initialization flow to an RP. + */ + yield* takeLatest(itwPrRemotePidInit.request, handleItwPrRemotePidInitSaga); + + /** + * Handles the PID remote presentation flow to an RP. + */ + yield* takeLatest( + itwPrRemotePidPresentation.request, + handleItwPrRemotePidSaga + ); +} + +/* + * This saga handles the RP initialization. + * It calls the getRequestObject method of the RP solution + */ +export function* handleItwPrRemotePidInitSaga( + action: ActionType +): SagaIterator { + try { + // Check if the lifecycle is valid + const isItwLifecycleValid = yield* select(itwLifecycleIsValidSelector); + if (!isItwLifecycleValid) { + yield* put( + itwPrRemotePidInit.failure({ + code: ItWalletErrorTypes.WALLET_NOT_VALID_ERROR + }) + ); + return; + } + + const { authReqUrl, clientId } = action.payload; + + // Get WIA + yield* put(itwWiaRequest.request()); + const wia = yield* take(itwWiaRequest.success); + + // Create crypto context + const wiaCryptoContext = createCryptoContextFor(ITW_WIA_KEY_TAG); + + // Get entity configuration for RP + const { + payload: { metadata: rpEntityConfiguration } + } = yield* call(Trust.getRelyingPartyEntityConfiguration, clientId); + + // Get request object configuration + const { requestObject } = yield* call( + Credential.Presentation.getRequestObject, + authReqUrl, + rpEntityConfiguration, + { + wiaCryptoContext, + walletInstanceAttestation: wia.payload + } + ); + + yield* put( + itwPrRemotePidInit.success({ + requestObject, + rpEntityConfiguration + }) + ); + } catch (e) { + yield* put( + itwPrRemotePidInit.failure({ + code: ItWalletErrorTypes.RP_INITIALIZATION_ERROR + }) + ); + } +} + +/* + * This saga handles the RP presentation. + * It calls the sendAuthorizationResponse method of the RP solution + */ +export function* handleItwPrRemotePidSaga( + _: ActionType +): SagaIterator { + try { + yield* call(verifyPin); + + // TODO: this claims should be selected by user + const claims = [ + "unique_id", + "given_name", + "family_name", + "birthdate", + "place_of_birth", + "tax_id_number", + "evidence" + ]; + + const maybeInitValue = yield* select(itwPrRemotePidInitValueSelector); + + const pidToken = yield* select(itwPersistedCredentialsValuePidSelector); + + if (O.isNone(maybeInitValue) || O.isNone(pidToken)) { + throw new Error("Request object is not defined"); + } else { + // Create PID crypto context + const pidCryptoContext = createCryptoContextFor(ITW_PID_KEY_TAG); + + // We suppose the WIA has already been loaded into the state from previous steps + const maybeWalletInstanceAttestation = yield* select(itwWiaSelector); + + if (O.isNone(maybeWalletInstanceAttestation)) { + throw new Error("WalletInstanceAttestation is not defined"); + } + + const walletInstanceAttestation = maybeWalletInstanceAttestation.value; + + const { requestObject, rpEntityConfiguration } = maybeInitValue.value; + + // Submit authorization response + const result = yield* call( + Credential.Presentation.sendAuthorizationResponse, + requestObject, + rpEntityConfiguration, + [pidToken.value.credential, claims, pidCryptoContext], + { + walletInstanceAttestation + } + ); + + yield* put(itwPrRemotePidPresentation.success(result)); + } + } catch (e) { + yield* put( + itwPrRemotePidPresentation.failure({ + code: ItWalletErrorTypes.RP_PRESENTATION_ERROR + }) + ); + } +} diff --git a/ts/features/it-wallet/saga/itwRpInitializationSaga.ts b/ts/features/it-wallet/saga/itwRpInitializationSaga.ts deleted file mode 100644 index 83c6370e5c8..00000000000 --- a/ts/features/it-wallet/saga/itwRpInitializationSaga.ts +++ /dev/null @@ -1,74 +0,0 @@ -import { SagaIterator } from "redux-saga"; -import { call, put, select, take } from "typed-redux-saga/macro"; -import { ActionType } from "typesafe-actions"; -import { - Credential, - createCryptoContextFor, - Trust -} from "@pagopa/io-react-native-wallet"; -import { itwRpInitialization } from "../store/actions/itwRpActions"; -import { ItWalletErrorTypes } from "../utils/itwErrorsUtils"; -import { itwWiaRequest } from "../store/actions/itwWiaActions"; -import { itwLifecycleIsValidSelector } from "../store/reducers/itwLifecycleReducer"; -import { ITW_WIA_KEY_TAG } from "../utils/itwSecureStorageUtils"; - -/* - * This saga handles the RP initialization. - * It calls the getRequestObject method of the RP solution - */ -export function* handleItwRpInitializationSaga( - action: ActionType -): SagaIterator { - try { - // Check if the lifecycle is valid - const isItwLifecycleValid = yield* select(itwLifecycleIsValidSelector); - if (!isItwLifecycleValid) { - yield* put( - itwRpInitialization.failure({ - code: ItWalletErrorTypes.WALLET_NOT_VALID_ERROR - }) - ); - return; - } - - const { authReqUrl, clientId } = action.payload; - - // Get WIA - yield* put(itwWiaRequest.request()); - const wia = yield* take(itwWiaRequest.success); - - // Create crypto context - const wiaCryptoContext = createCryptoContextFor(ITW_WIA_KEY_TAG); - - // Get entity configuration for RP - const { - payload: { metadata: rpEntityConfiguration } - } = yield* call(Trust.getRelyingPartyEntityConfiguration, clientId); - - // Get request object configuration - const { requestObject } = yield* call( - Credential.Presentation.getRequestObject, - authReqUrl, - rpEntityConfiguration, - { - wiaCryptoContext, - walletInstanceAttestation: wia.payload - } - ); - - yield* put( - itwRpInitialization.success({ - requestObject, - entity: rpEntityConfiguration, - authReqUrl, - clientId - }) - ); - } catch (e) { - yield* put( - itwRpInitialization.failure({ - code: ItWalletErrorTypes.RP_INITIALIZATION_ERROR - }) - ); - } -} diff --git a/ts/features/it-wallet/saga/itwRpPresentationSaga.ts b/ts/features/it-wallet/saga/itwRpPresentationSaga.ts deleted file mode 100644 index 496b3e45e2d..00000000000 --- a/ts/features/it-wallet/saga/itwRpPresentationSaga.ts +++ /dev/null @@ -1,94 +0,0 @@ -import { SagaIterator } from "redux-saga"; -import { call, put, select } from "typed-redux-saga/macro"; -import * as O from "fp-ts/lib/Option"; -import { ActionType } from "typesafe-actions"; -import { - Credential, - createCryptoContextFor -} from "@pagopa/io-react-native-wallet"; - -import { - itwRpInitializationEntityValueSelector, - itwRpInitializationRequestObjectValueSelector -} from "../store/reducers/itwRpInitializationReducer"; -import { itwRpPresentation } from "../store/actions/itwRpActions"; -import { ItWalletErrorTypes } from "../utils/itwErrorsUtils"; -import { itwCredentialsPidSelector } from "../store/reducers/itwCredentialsReducer"; -import { itwWiaSelector } from "../store/reducers/itwWiaReducer"; -import { ITW_PID_KEY_TAG } from "../utils/itwSecureStorageUtils"; -import { verifyPin } from "./itwSagaUtils"; - -/* - * This saga handles the RP presentation. - * It calls the sendAuthorizationResponse method of the RP solution - */ -export function* handleItwRpPresentationSaga( - _: ActionType -): SagaIterator { - try { - yield* call(verifyPin); - - // TODO: this claims should be selected by user - const claims = [ - "unique_id", - "given_name", - "family_name", - "birthdate", - "place_of_birth", - "tax_id_number", - "evidence" - ]; - - const requestObjectValue = yield* select( - itwRpInitializationRequestObjectValueSelector - ); - - const pidToken = yield* select(itwCredentialsPidSelector); - - if (O.isNone(requestObjectValue) || O.isNone(pidToken)) { - throw new Error("Request object is not defined"); - } else { - // Create PID crypto context - const pidCryptoContext = createCryptoContextFor(ITW_PID_KEY_TAG); - // Retrieve entity configuration for RP - const maybeEntityConfiguration = yield* select( - itwRpInitializationEntityValueSelector - ); - - // We suppose the WIA has already been loaded into the state from previous steps - const maybeWalletInstanceAttestation = yield* select(itwWiaSelector); - - if (O.isNone(maybeWalletInstanceAttestation)) { - throw new Error("WalletInstanceAttestation is not defined"); - } - - if (O.isNone(maybeEntityConfiguration)) { - throw new Error("Entity is not defined"); - } - - const walletInstanceAttestation = maybeWalletInstanceAttestation.value; - - const requestObject = requestObjectValue.value; - const rpEntityConfiguration = maybeEntityConfiguration.value; - - // Submit authorization response - const result = yield* call( - Credential.Presentation.sendAuthorizationResponse, - requestObject, - rpEntityConfiguration, - [pidToken.value.credential, claims, pidCryptoContext], - { - walletInstanceAttestation - } - ); - - yield* put(itwRpPresentation.success(result)); - } - } catch (e) { - yield* put( - itwRpPresentation.failure({ - code: ItWalletErrorTypes.RP_PRESENTATION_ERROR - }) - ); - } -} diff --git a/ts/features/it-wallet/saga/itwRpSaga.ts b/ts/features/it-wallet/saga/itwRpSaga.ts deleted file mode 100644 index 0d5d3eb2d4a..00000000000 --- a/ts/features/it-wallet/saga/itwRpSaga.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { SagaIterator } from "redux-saga"; -import { takeLatest } from "typed-redux-saga/macro"; - -import { - itwRpInitialization, - itwRpPresentation -} from "../store/actions/itwRpActions"; -import { handleItwRpInitializationSaga } from "./itwRpInitializationSaga"; -import { handleItwRpPresentationSaga } from "./itwRpPresentationSaga"; - -/** - * Watcher for the IT wallet Relying Party related sagas. - */ -export function* watchItwRpSaga(): SagaIterator { - /** - * Handles the ITW RP initialization flow. - */ - yield* takeLatest(itwRpInitialization.request, handleItwRpInitializationSaga); - - /** - * Handles the ITW RP presentation flow. - */ - yield* takeLatest(itwRpPresentation.request, handleItwRpPresentationSaga); -} diff --git a/ts/features/it-wallet/saga/itwWiaSaga.ts b/ts/features/it-wallet/saga/itwWiaSaga.ts index 2e3db35ce1c..48252795f02 100644 --- a/ts/features/it-wallet/saga/itwWiaSaga.ts +++ b/ts/features/it-wallet/saga/itwWiaSaga.ts @@ -10,7 +10,7 @@ import DeviceInfo from "react-native-device-info"; import { toError } from "fp-ts/lib/Either"; import { idpSelector } from "../../../store/reducers/authentication"; import { ItWalletErrorTypes } from "../utils/itwErrorsUtils"; -import { isCIEAuthenticationSupported } from "../utils/cie"; +import { itwIsCIEAuthenticationSupported } from "../utils/itwCieUtils"; import { itwWiaRequest } from "../store/actions/itwWiaActions"; import { walletProviderBaseUrl } from "../../../config"; import { @@ -36,7 +36,7 @@ export function* watchItwWiaSaga(): SagaIterator { export function* handleWiaRequest(): SagaIterator { const idp = yield* select(idpSelector); const hasLoggedInWithCie = isSome(idp) && idp.value.name === "cie"; - const isCieSupported = yield* call(isCIEAuthenticationSupported); + const isCieSupported = yield* call(itwIsCIEAuthenticationSupported); const isEmulator = yield* call(DeviceInfo.isEmulator); if (hasLoggedInWithCie || isCieSupported || isEmulator) { try { @@ -60,7 +60,7 @@ export function* handleWiaRequest(): SagaIterator { const { message } = toError(e); yield* put( itwWiaRequest.failure({ - code: ItWalletErrorTypes.WIA_ISSUING_ERROR, + code: ItWalletErrorTypes.WIA_ISSUANCE_ERROR, message }) ); diff --git a/ts/features/it-wallet/saga/new/itwPresentationSaga.ts b/ts/features/it-wallet/saga/new/itwPresentationSaga.ts deleted file mode 100644 index 7074c7b3074..00000000000 --- a/ts/features/it-wallet/saga/new/itwPresentationSaga.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { SagaIterator } from "redux-saga"; -import { put, delay, takeLatest, select, call } from "typed-redux-saga/macro"; -import { - itwPresentation, - itwPresentationChecks -} from "../../store/actions/itwPresentationActions"; -import { itwLifecycleIsValidSelector } from "../../store/reducers/itwLifecycleReducer"; -import { ItWalletErrorTypes } from "../../utils/itwErrorsUtils"; -import { verifyPin } from "../itwSagaUtils"; - -export function* watchItwPresentationSaga(): SagaIterator { - yield* takeLatest(itwPresentationChecks.request, itwPresentationChecksSaga); - yield* takeLatest(itwPresentation.request, itwPresentationSaga); -} - -/* - * This saga handles the RP presentation checks. - * TODO: add the actual implementation as it currently only delays and returns success. - * action: ActionType - */ -export function* itwPresentationChecksSaga(): SagaIterator { - // Check if the lifecycle is valid - const isItwLifecycleValid = yield* select(itwLifecycleIsValidSelector); - if (!isItwLifecycleValid) { - yield* put( - itwPresentationChecks.failure({ - code: ItWalletErrorTypes.WALLET_NOT_VALID_ERROR - }) - ); - return; - } - yield* delay(1500); - yield* put(itwPresentationChecks.success()); -} - -/** - * This saga handles the RP presentation. - * TODO: add the actual implementation as it currently only delays and returns success. - * action: ActionType - */ -export function* itwPresentationSaga(): SagaIterator { - yield* call(verifyPin); - yield* delay(1500); - yield* put(itwPresentation.success()); -} diff --git a/ts/features/it-wallet/screens/ItwHomeScreen.tsx b/ts/features/it-wallet/screens/ItwHomeScreen.tsx index ed0f0e0444b..3c0764e12db 100644 --- a/ts/features/it-wallet/screens/ItwHomeScreen.tsx +++ b/ts/features/it-wallet/screens/ItwHomeScreen.tsx @@ -22,14 +22,14 @@ import { IOStackNavigationProp } from "../../../navigation/params/AppParamsList" import { ItwParamsList } from "../navigation/ItwParamsList"; import { itwLifecycleIsOperationalSelector } from "../store/reducers/itwLifecycleReducer"; import { - itwCredentialsPidSelector, - itwCredentialsSelector -} from "../store/reducers/itwCredentialsReducer"; + itwPersistedCredentialsValuePidSelector, + itwPersistedCredentialsValueSelector +} from "../store/reducers/itwPersistedCredentialsReducer"; import { useItwResetFlow } from "../hooks/useItwResetFlow"; import ItwCredentialCard from "../components/ItwCredentialCard"; -import { CredentialType } from "../utils/mocks"; +import { CredentialType } from "../utils/itwMocksUtils"; import ItwKoView from "../components/ItwKoView"; -import { StoredCredential } from "../utils/types"; +import { StoredCredential } from "../utils/itwTypesUtils"; const contextualHelpMarkdown: ContextualHelpPropsMarkdown = { title: "wallet.contextualHelpTitle", @@ -46,8 +46,8 @@ const ItwHomeScreen = () => { const isItWalletOperational = useIOSelector( itwLifecycleIsOperationalSelector ); - const decodedPid = useIOSelector(itwCredentialsPidSelector); - const credentials = useIOSelector(itwCredentialsSelector); + const decodedPid = useIOSelector(itwPersistedCredentialsValuePidSelector); + const credentials = useIOSelector(itwPersistedCredentialsValueSelector); const [selectedBadgeIdx, setSelectedBadgeIdx] = useState(0); const badgesLabels = [ I18n.t("features.itWallet.homeScreen.categories.any"), @@ -64,7 +64,7 @@ const ItwHomeScreen = () => { */ const onPressAddCredentials = () => { navigation.navigate(ITW_ROUTES.MAIN, { - screen: ITW_ROUTES.ISSUING.CREDENTIAL.CATALOG + screen: ITW_ROUTES.ISSUANCE.CREDENTIAL.CATALOG }); }; @@ -74,7 +74,7 @@ const ItwHomeScreen = () => { */ const onLongPressCredential = () => { navigation.navigate(ITW_ROUTES.MAIN, { - screen: ITW_ROUTES.PRESENTATION.CREDENTIAL.REMOTE.CHECKS + screen: ITW_ROUTES.PRESENTATION.CREDENTIAL.REMOTE.INIT }); }; diff --git a/ts/features/it-wallet/screens/issuing/credential/ItwIssuingCredentialAuthScreen.tsx b/ts/features/it-wallet/screens/issuance/credential/ItwIssuanceCredentialAuthScreen.tsx similarity index 89% rename from ts/features/it-wallet/screens/issuing/credential/ItwIssuingCredentialAuthScreen.tsx rename to ts/features/it-wallet/screens/issuance/credential/ItwIssuanceCredentialAuthScreen.tsx index c63282c6db1..7f7c19e0399 100644 --- a/ts/features/it-wallet/screens/issuing/credential/ItwIssuingCredentialAuthScreen.tsx +++ b/ts/features/it-wallet/screens/issuance/credential/ItwIssuanceCredentialAuthScreen.tsx @@ -23,26 +23,26 @@ import { IOStackNavigationProp } from "../../../../../navigation/params/AppParam import { ItwParamsList } from "../../../navigation/ItwParamsList"; import I18n from "../../../../../i18n"; import ItwBulletList from "../../../components/ItwBulletList"; -import { getRequestedClaims } from "../../../utils/mocks"; -import { showCancelAlert } from "../../../utils/alert"; +import { getRequestedClaims } from "../../../utils/itwMocksUtils"; +import { itwShowCancelAlert } from "../../../utils/itwAlertsUtils"; import ROUTES from "../../../../../navigation/routes"; import { ITW_ROUTES } from "../../../navigation/ItwRoutes"; import ItwKoView from "../../../components/ItwKoView"; import { getItwGenericMappedError } from "../../../utils/itwErrorsUtils"; import ItwTextInfo from "../../../components/ItwTextInfo"; import { useItwInfoBottomSheet } from "../../../hooks/useItwInfoBottomSheet"; -import { itwCredentialsPidSelector } from "../../../store/reducers/itwCredentialsReducer"; -import { StoredCredential } from "../../../utils/types"; -import { itwIssuanceChecksDataSelector } from "../../../store/reducers/new/itwIssuanceReducer"; +import { itwPersistedCredentialsValuePidSelector } from "../../../store/reducers/itwPersistedCredentialsReducer"; +import { StoredCredential } from "../../../utils/itwTypesUtils"; +import { itwIssuanceCredentialChecksValueSelector } from "../../../store/reducers/itwIssuanceCredentialReducer"; import { getEvidenceOrganizationName } from "../../../utils/itwClaimsUtils"; /** * This screen displays the information about the credential that is going to be shared * with the issuer. */ -const ItwIssuingCredentialAuthScreen = () => { - const pid = useIOSelector(itwCredentialsPidSelector); - const checks = useIOSelector(itwIssuanceChecksDataSelector); +const ItwIssuanceCredentialAuthScreen = () => { + const pid = useIOSelector(itwPersistedCredentialsValuePidSelector); + const checks = useIOSelector(itwIssuanceCredentialChecksValueSelector); const navigation = useNavigation>(); const toast = useIOToast(); const organization = pipe( @@ -168,7 +168,7 @@ const ItwIssuingCredentialAuthScreen = () => { buttonProps: { color: "primary", accessibilityLabel: I18n.t("global.buttons.cancel"), - onPress: () => showCancelAlert(alertOnPress), + onPress: () => itwShowCancelAlert(alertOnPress), label: I18n.t("global.buttons.cancel") } }} @@ -178,7 +178,7 @@ const ItwIssuingCredentialAuthScreen = () => { color: "primary", accessibilityLabel: I18n.t("global.buttons.continue"), onPress: () => - navigation.navigate(ITW_ROUTES.ISSUING.CREDENTIAL.PREVIEW), + navigation.navigate(ITW_ROUTES.ISSUANCE.CREDENTIAL.PREVIEW), label: I18n.t("global.buttons.continue") } }} @@ -210,4 +210,4 @@ const ItwIssuingCredentialAuthScreen = () => { ); }; -export default ItwIssuingCredentialAuthScreen; +export default ItwIssuanceCredentialAuthScreen; diff --git a/ts/features/it-wallet/screens/issuing/credential/ItwIssuingCredentialCatalogScreen.tsx b/ts/features/it-wallet/screens/issuance/credential/ItwIssuanceCredentialCatalogScreen.tsx similarity index 89% rename from ts/features/it-wallet/screens/issuing/credential/ItwIssuingCredentialCatalogScreen.tsx rename to ts/features/it-wallet/screens/issuance/credential/ItwIssuanceCredentialCatalogScreen.tsx index f6f74297b02..fcc4d94130f 100644 --- a/ts/features/it-wallet/screens/issuing/credential/ItwIssuingCredentialCatalogScreen.tsx +++ b/ts/features/it-wallet/screens/issuance/credential/ItwIssuanceCredentialCatalogScreen.tsx @@ -17,24 +17,24 @@ import { getCredentialsCatalog, CredentialCatalogAvailableItem, CredentialCatalogItem -} from "../../../utils/mocks"; +} from "../../../utils/itwMocksUtils"; import ListItemLoadingItw from "../../../components/ListItems/ListItemLoadingItw"; import { IOStackNavigationProp } from "../../../../../navigation/params/AppParamsList"; import { ItwParamsList } from "../../../navigation/ItwParamsList"; import { ITW_ROUTES } from "../../../navigation/ItwRoutes"; import { useIODispatch, useIOSelector } from "../../../../../store/hooks"; -import { itwIssuanceChecksSelector } from "../../../store/reducers/new/itwIssuanceReducer"; -import { itwIssuanceChecks } from "../../../store/actions/itwIssuanceActions"; +import { itwIssuanceCredentialChecksSelector } from "../../../store/reducers/itwIssuanceCredentialReducer"; +import { itwIssuanceCredentialChecks } from "../../../store/actions/itwIssuanceCredentialActions"; const NONE_LOADING = -1; /** * Renders a preview screen which displays a visual representation and the claims contained in the PID. */ -const ItwIssuingCredentialCatalogScreen = () => { +const ItwIssuanceCredentialCatalogScreen = () => { const dispatch = useIODispatch(); const navigation = useNavigation>(); - const preliminaryChecks = useIOSelector(itwIssuanceChecksSelector); + const preliminaryChecks = useIOSelector(itwIssuanceCredentialChecksSelector); const [loadingIndex, setLoadingIndex] = React.useState(NONE_LOADING); const catalog = getCredentialsCatalog(); @@ -52,7 +52,7 @@ const ItwIssuingCredentialCatalogScreen = () => { */ useEffect(() => { if (loadingIndex !== NONE_LOADING && !pot.isLoading(preliminaryChecks)) { - navigation.navigate(ITW_ROUTES.ISSUING.CREDENTIAL.CHECKS); + navigation.navigate(ITW_ROUTES.ISSUANCE.CREDENTIAL.CHECKS); setLoadingIndex(NONE_LOADING); } }, [loadingIndex, navigation, preliminaryChecks]); @@ -65,7 +65,7 @@ const ItwIssuingCredentialCatalogScreen = () => { }: CredentialCatalogAvailableItem & { index: number }) => { setLoadingIndex(index); dispatch( - itwIssuanceChecks.request({ + itwIssuanceCredentialChecks.request({ displayData, issuerUrl, credentialType @@ -146,4 +146,4 @@ const ItwIssuingCredentialCatalogScreen = () => { ); }; -export default ItwIssuingCredentialCatalogScreen; +export default ItwIssuanceCredentialCatalogScreen; diff --git a/ts/features/it-wallet/screens/issuing/credential/ItwIssuingCredentialChecksScreen.tsx b/ts/features/it-wallet/screens/issuance/credential/ItwIssuanceCredentialChecksScreen.tsx similarity index 89% rename from ts/features/it-wallet/screens/issuing/credential/ItwIssuingCredentialChecksScreen.tsx rename to ts/features/it-wallet/screens/issuance/credential/ItwIssuanceCredentialChecksScreen.tsx index bde42f1ab53..7e4b7e446a6 100644 --- a/ts/features/it-wallet/screens/issuing/credential/ItwIssuingCredentialChecksScreen.tsx +++ b/ts/features/it-wallet/screens/issuance/credential/ItwIssuanceCredentialChecksScreen.tsx @@ -13,11 +13,11 @@ import { ItwParamsList } from "../../../navigation/ItwParamsList"; import { ITW_ROUTES } from "../../../navigation/ItwRoutes"; import { useIOSelector } from "../../../../../store/hooks"; import { - itwIssuanceChecksSelector, - IssuanceData -} from "../../../store/reducers/new/itwIssuanceReducer"; + itwIssuanceCredentialChecksSelector, + ItwIssuanceCredentialData +} from "../../../store/reducers/itwIssuanceCredentialReducer"; import ItwContinueScreen from "../../../components/ItwContinueView"; -import { showCancelAlert } from "../../../utils/alert"; +import { itwShowCancelAlert } from "../../../utils/itwAlertsUtils"; import { ItWalletError, ItWalletErrorTypes, @@ -31,23 +31,23 @@ import ROUTES from "../../../../../navigation/routes"; * Screen that displays the result of the credential issuance checks * by folding the preliminaryChecks pot. */ -const ItwIssuingCredentialsChecksScreen = () => { +const ItwIssuanceCredentialChecksScreen = () => { const toast = useIOToast(); const navigation = useNavigation>(); - const preliminaryChecks = useIOSelector(itwIssuanceChecksSelector); + const preliminaryChecks = useIOSelector(itwIssuanceCredentialChecksSelector); /** * When the user confirms the issuance, the user is redirected to the presentation screen. */ const onUserConfirmIssuance = () => { - navigation.navigate(ITW_ROUTES.ISSUING.CREDENTIAL.AUTH); + navigation.navigate(ITW_ROUTES.ISSUANCE.CREDENTIAL.AUTH); }; /** * When the user aborts the issuance, the user is redirected to the messages home screen. */ const onUserAbortIssuance = () => { - showCancelAlert(() => { + itwShowCancelAlert(() => { navigation.navigate(ROUTES.MAIN, { screen: ROUTES.MESSAGES_HOME }); toast.info( I18n.t("features.itWallet.issuing.credentialsChecksScreen.toast.cancel") @@ -68,7 +68,11 @@ const ItwIssuingCredentialsChecksScreen = () => { * Content view which asks the user to confirm the issuance of the credential. * @param issuanceData - the issuance data of the credential used to display the credential title. */ - const ConfirmView = ({ issuanceData }: { issuanceData: IssuanceData }) => ( + const ConfirmView = ({ + issuanceData + }: { + issuanceData: ItwIssuanceCredentialData; + }) => ( { return ; }; -export default ItwIssuingCredentialsChecksScreen; +export default ItwIssuanceCredentialChecksScreen; diff --git a/ts/features/it-wallet/screens/issuing/credential/ItwIssuingCredentialPreviewScreen.tsx b/ts/features/it-wallet/screens/issuance/credential/ItwIssuanceCredentialPreviewScreen.tsx similarity index 90% rename from ts/features/it-wallet/screens/issuing/credential/ItwIssuingCredentialPreviewScreen.tsx rename to ts/features/it-wallet/screens/issuance/credential/ItwIssuanceCredentialPreviewScreen.tsx index f9bd98c610f..0dea86ee5bd 100644 --- a/ts/features/it-wallet/screens/issuing/credential/ItwIssuingCredentialPreviewScreen.tsx +++ b/ts/features/it-wallet/screens/issuance/credential/ItwIssuanceCredentialPreviewScreen.tsx @@ -21,7 +21,7 @@ import { ItwParamsList } from "../../../navigation/ItwParamsList"; import { IOStackNavigationProp } from "../../../../../navigation/params/AppParamsList"; import { useIODispatch, useIOSelector } from "../../../../../store/hooks"; import ItwCredentialClaimsList from "../../../components/ItwCredentialClaimsList"; -import { showCancelAlert } from "../../../utils/alert"; +import { itwShowCancelAlert } from "../../../utils/itwAlertsUtils"; import ROUTES from "../../../../../navigation/routes"; import ItwKoView from "../../../components/ItwKoView"; import { @@ -30,22 +30,22 @@ import { } from "../../../utils/itwErrorsUtils"; import { useOnFirstRender } from "../../../../../utils/hooks/useOnFirstRender"; import { - itwConfirmStoreCredential, - itwIssuanceGetCredential -} from "../../../store/actions/itwIssuanceActions"; -import { itwIssuanceResultSelector } from "../../../store/reducers/new/itwIssuanceReducer"; + itwIssuanceCredentialStore, + itwIssuanceCredential +} from "../../../store/actions/itwIssuanceCredentialActions"; +import { itwIssuanceCredentialResultSelector } from "../../../store/reducers/itwIssuanceCredentialReducer"; import ItwLoadingSpinnerOverlay from "../../../components/ItwLoadingSpinnerOverlay"; import { ForceScrollDownView } from "../../../../../components/ForceScrollDownView"; import ItwFooterVerticalButtons from "../../../components/ItwFooterVerticalButtons"; import { ITW_ROUTES } from "../../../navigation/ItwRoutes"; -import { StoredCredential } from "../../../utils/types"; +import { StoredCredential } from "../../../utils/itwTypesUtils"; /** * Renders a preview screen which displays a visual representation and the claims contained in the credential. */ -const ItwIssuingCredentialPreviewScreen = () => { +const ItwIssuanceCredentialPreviewScreen = () => { const navigation = useNavigation>(); - const issuanceResult = useIOSelector(itwIssuanceResultSelector); + const issuanceResult = useIOSelector(itwIssuanceCredentialResultSelector); const bannerViewRef = React.createRef(); const toast = useIOToast(); const dispatch = useIODispatch(); @@ -54,7 +54,7 @@ const ItwIssuingCredentialPreviewScreen = () => { * Starts the issuance process when the screen is rendered for the first time. */ useOnFirstRender(() => { - dispatch(itwIssuanceGetCredential.request()); + dispatch(itwIssuanceCredential.request()); }); /** @@ -73,7 +73,7 @@ const ItwIssuingCredentialPreviewScreen = () => { */ const ContentView = ({ data }: { data: StoredCredential }) => { const addOnPress = () => { - dispatch(itwConfirmStoreCredential()); + dispatch(itwIssuanceCredentialStore()); }; const bottomButtonProps: ButtonSolidProps = { @@ -81,7 +81,7 @@ const ItwIssuingCredentialPreviewScreen = () => { color: "contrast", label: I18n.t("global.buttons.cancel"), accessibilityLabel: I18n.t("global.buttons.cancel"), - onPress: () => showCancelAlert(alertOnPress) + onPress: () => itwShowCancelAlert(alertOnPress) }; const topButtonProps: ButtonSolidProps = { @@ -195,4 +195,4 @@ const ItwIssuingCredentialPreviewScreen = () => { return ; }; -export default ItwIssuingCredentialPreviewScreen; +export default ItwIssuanceCredentialPreviewScreen; diff --git a/ts/features/it-wallet/screens/issuing/pid/ItwIssuingPidAuthInfoScreen.tsx b/ts/features/it-wallet/screens/issuance/pid/ItwIssuancePidAuthInfoScreen.tsx similarity index 94% rename from ts/features/it-wallet/screens/issuing/pid/ItwIssuingPidAuthInfoScreen.tsx rename to ts/features/it-wallet/screens/issuance/pid/ItwIssuancePidAuthInfoScreen.tsx index ef7d39cb4d5..892e20fbf32 100644 --- a/ts/features/it-wallet/screens/issuing/pid/ItwIssuingPidAuthInfoScreen.tsx +++ b/ts/features/it-wallet/screens/issuance/pid/ItwIssuancePidAuthInfoScreen.tsx @@ -16,7 +16,7 @@ import { profileNameSelector, profileSurnameSelector } from "../../../../../store/reducers/profile"; -import { pidDataMock } from "../../../utils/mocks"; +import { pidDataMock } from "../../../utils/itwMocksUtils"; import { formatDateToYYYYMMDD } from "../../../../../utils/dates"; import { isIos } from "../../../../../utils/platform"; import { itwWiaStateSelector } from "../../../store/reducers/itwWiaReducer"; @@ -32,7 +32,7 @@ import { /** * Renders the screen which displays the information about the authentication process to obtain a Wallet Instance. */ -const ItwIssuingPidAuthInfoScreen = () => { +const ItwIssuancePidAuthInfoScreen = () => { const navigation = useNavigation(); const dispatch = useIODispatch(); const wia = useIOSelector(itwWiaStateSelector); @@ -50,7 +50,7 @@ const ItwIssuingPidAuthInfoScreen = () => { * PID data from the profile store or a mock if the data is not available. */ const bypassCieLogin = () => { - navigation.navigate(ITW_ROUTES.ISSUING.PID.REQUEST, { + navigation.navigate(ITW_ROUTES.ISSUANCE.PID.REQUEST, { pidData: { name: name ?? pidDataMock.name, surname: surname ?? pidDataMock.surname, @@ -91,7 +91,7 @@ const ItwIssuingPidAuthInfoScreen = () => { onPress: () => isIos ? bypassCieLogin() - : navigation.navigate(ITW_ROUTES.ISSUING.PID.CIE.PIN_SCREEN) + : navigation.navigate(ITW_ROUTES.ISSUANCE.PID.CIE.PIN_SCREEN) }} onPictogramPress={() => bypassCieLogin()} secondaryAction={{ @@ -132,4 +132,4 @@ const ItwIssuingPidAuthInfoScreen = () => { return ; }; -export default ItwIssuingPidAuthInfoScreen; +export default ItwIssuancePidAuthInfoScreen; diff --git a/ts/features/it-wallet/screens/issuing/pid/ItwIssuingPidAuthScreen.tsx b/ts/features/it-wallet/screens/issuance/pid/ItwIssuancePidAuthScreen.tsx similarity index 97% rename from ts/features/it-wallet/screens/issuing/pid/ItwIssuingPidAuthScreen.tsx rename to ts/features/it-wallet/screens/issuance/pid/ItwIssuancePidAuthScreen.tsx index 4afdf82e7d8..2b105a86b69 100644 --- a/ts/features/it-wallet/screens/issuing/pid/ItwIssuingPidAuthScreen.tsx +++ b/ts/features/it-wallet/screens/issuance/pid/ItwIssuancePidAuthScreen.tsx @@ -30,7 +30,7 @@ import { useItwInfoBottomSheet } from "../../../hooks/useItwInfoBottomSheet"; * Renders the screen which display a list of features (or trusty providers) * to activate the wallet. */ -const ItwIssuingPidAuthScreen = () => { +const ItwIssuancePidAuthScreen = () => { const navigation = useNavigation(); const { present, bottomSheet } = useItwInfoBottomSheet({ @@ -51,7 +51,7 @@ const ItwIssuingPidAuthScreen = () => { title: I18n.t("features.itWallet.featuresInfoScreen.list.cie"), subTitle: I18n.t("features.itWallet.featuresInfoScreen.list.cieSubTitle"), icon: "fiscalCodeIndividual", - onPress: () => navigation.navigate(ITW_ROUTES.ISSUING.PID.AUTH_INFO), + onPress: () => navigation.navigate(ITW_ROUTES.ISSUANCE.PID.AUTH_INFO), accessibilityLabel: I18n.t( "features.itWallet.featuresInfoScreen.list.cie" ), @@ -204,4 +204,4 @@ const ItwIssuingPidAuthScreen = () => { ); }; -export default ItwIssuingPidAuthScreen; +export default ItwIssuancePidAuthScreen; diff --git a/ts/features/it-wallet/screens/issuing/pid/ItwIssuingPidInfoScreen.tsx b/ts/features/it-wallet/screens/issuance/pid/ItwIssuancePidInfoScreen.tsx similarity index 95% rename from ts/features/it-wallet/screens/issuing/pid/ItwIssuingPidInfoScreen.tsx rename to ts/features/it-wallet/screens/issuance/pid/ItwIssuancePidInfoScreen.tsx index 58a3f98ab22..f19cdd14b6e 100644 --- a/ts/features/it-wallet/screens/issuing/pid/ItwIssuingPidInfoScreen.tsx +++ b/ts/features/it-wallet/screens/issuance/pid/ItwIssuancePidInfoScreen.tsx @@ -19,7 +19,7 @@ import itwCardImage from "../../../assets/img/issuing/itw_card.png"; import { isAndroid } from "../../../../../utils/platform"; import ItwFooterVerticalButtons from "../../../components/ItwFooterVerticalButtons"; -const ItwIssuingPidInfoScreen = () => { +const ItwIssuancePidInfoScreen = () => { const dispatch = useIODispatch(); const navigation = useNavigation(); @@ -37,7 +37,7 @@ const ItwIssuingPidInfoScreen = () => { color: "primary", fullWidth: true, accessibilityLabel: I18n.t("features.itWallet.activationScreen.confirm"), - onPress: () => navigation.navigate(ITW_ROUTES.ISSUING.PID.AUTH), + onPress: () => navigation.navigate(ITW_ROUTES.ISSUANCE.PID.AUTH), label: I18n.t("features.itWallet.activationScreen.confirm") }; @@ -98,4 +98,4 @@ const ItwIssuingPidInfoScreen = () => { ); }; -export default ItwIssuingPidInfoScreen; +export default ItwIssuancePidInfoScreen; diff --git a/ts/features/it-wallet/screens/issuing/pid/ItwPidPreviewScreen.tsx b/ts/features/it-wallet/screens/issuance/pid/ItwIssuancePidPreviewScreen.tsx similarity index 85% rename from ts/features/it-wallet/screens/issuing/pid/ItwPidPreviewScreen.tsx rename to ts/features/it-wallet/screens/issuance/pid/ItwIssuancePidPreviewScreen.tsx index 45a4acaced3..3e32e01d181 100644 --- a/ts/features/it-wallet/screens/issuing/pid/ItwPidPreviewScreen.tsx +++ b/ts/features/it-wallet/screens/issuance/pid/ItwIssuancePidPreviewScreen.tsx @@ -17,13 +17,12 @@ import I18n from "../../../../../i18n"; import { emptyContextualHelp } from "../../../../../utils/emptyContextualHelp"; import { ITW_ROUTES } from "../../../navigation/ItwRoutes"; import { IOStackNavigationProp } from "../../../../../navigation/params/AppParamsList"; -import { useIOSelector } from "../../../../../store/hooks"; +import { useIODispatch, useIOSelector } from "../../../../../store/hooks"; import ItwCredentialCard from "../../../components/ItwCredentialCard"; import { ForceScrollDownView } from "../../../../../components/ForceScrollDownView"; import ItwFooterVerticalButtons from "../../../components/ItwFooterVerticalButtons"; -import { showCancelAlert } from "../../../utils/alert"; +import { itwShowCancelAlert } from "../../../utils/itwAlertsUtils"; import ROUTES from "../../../../../navigation/routes"; -import { CredentialType } from "../../../utils/mocks"; import BaseScreenComponent from "../../../../../components/screens/BaseScreenComponent"; import { ItwParamsList } from "../../../navigation/ItwParamsList"; import ItwKoView from "../../../components/ItwKoView"; @@ -32,16 +31,17 @@ import { ItWalletError } from "../../../utils/itwErrorsUtils"; import ItwCredentialClaimsList from "../../../components/ItwCredentialClaimsList"; -import { StoredCredential } from "../../../utils/types"; -import { itwPidValueSelector } from "../../../store/reducers/itwPidReducer"; +import { StoredCredential } from "../../../utils/itwTypesUtils"; +import { itwIssuancePidValueSelector } from "../../../store/reducers/itwIssuancePidReducer"; +import { itwIssuancePidStore } from "../../../store/actions/itwIssuancePidActions"; /** * Renders a preview screen which displays a visual representation and the claims contained in the PID. */ -const ItwPidPreviewScreen = () => { +const ItwIssuancePidPreviewScreen = () => { const navigation = useNavigation>(); - const pid = useIOSelector(itwPidValueSelector); - const pidType = CredentialType.PID; + const pid = useIOSelector(itwIssuancePidValueSelector); + const dispatch = useIODispatch(); /** * Renders the content of the screen if the PID is decoded. @@ -66,18 +66,18 @@ const ItwPidPreviewScreen = () => { accessibilityLabel: I18n.t( "features.itWallet.issuing.pidPreviewScreen.buttons.cancel" ), - onPress: () => showCancelAlert(alertOnPress) + onPress: () => itwShowCancelAlert(alertOnPress) }; - const topButtonProps: ButtonSolidProps = { + const topButtonProps = (pid: StoredCredential): ButtonSolidProps => ({ color: "primary", fullWidth: true, accessibilityLabel: I18n.t( "features.itWallet.issuing.pidPreviewScreen.buttons.add" ), - onPress: () => navigation.navigate(ITW_ROUTES.ISSUING.PID.ADDING), + onPress: () => dispatch(itwIssuancePidStore(pid)), label: I18n.t("features.itWallet.issuing.pidPreviewScreen.buttons.add") - }; + }); return ( { @@ -129,7 +129,7 @@ const ItwPidPreviewScreen = () => { @@ -158,4 +158,4 @@ const ItwPidPreviewScreen = () => { return ; }; -export default ItwPidPreviewScreen; +export default ItwIssuancePidPreviewScreen; diff --git a/ts/features/it-wallet/screens/issuing/pid/ItwIssuingPidRequestScreen.tsx b/ts/features/it-wallet/screens/issuance/pid/ItwIssuancePidRequestScreen.tsx similarity index 84% rename from ts/features/it-wallet/screens/issuing/pid/ItwIssuingPidRequestScreen.tsx rename to ts/features/it-wallet/screens/issuance/pid/ItwIssuancePidRequestScreen.tsx index bf9149f21e5..cc47c137732 100644 --- a/ts/features/it-wallet/screens/issuing/pid/ItwIssuingPidRequestScreen.tsx +++ b/ts/features/it-wallet/screens/issuance/pid/ItwIssuancePidRequestScreen.tsx @@ -14,38 +14,38 @@ import { IOStackNavigationProp } from "../../../../../navigation/params/AppParam import { useIODispatch, useIOSelector } from "../../../../../store/hooks"; import ItwLoadingSpinnerOverlay from "../../../components/ItwLoadingSpinnerOverlay"; import { ITW_ROUTES } from "../../../navigation/ItwRoutes"; -import { itwPidSelector } from "../../../store/reducers/itwPidReducer"; -import { itwPid } from "../../../store/actions/itwCredentialsActions"; +import { itwIssuancePidSelector } from "../../../store/reducers/itwIssuancePidReducer"; import { itwActivationStop } from "../../../store/actions/itwActivationActions"; import ItwKoView from "../../../components/ItwKoView"; import { ItWalletError, getItwGenericMappedError } from "../../../utils/itwErrorsUtils"; -import { getPidCredentialCatalogItem } from "../../../utils/mocks"; +import { getPidCredentialCatalogItem } from "../../../utils/itwMocksUtils"; +import { itwIssuancePid } from "../../../store/actions/itwIssuancePidActions"; /** - * ItwIssuingPidRequestScreen's navigation params. + * ItwIssuancePidRequestScreen's navigation params. * The pidData consists of the data needed to request a PID. */ -export type ItwIssuingPidRequestScreenNavigationParams = { +export type ItwIssuancePidRequestScreenNavigationParams = { pidData: PidData; }; /** * Renders a preview screen which requests a PID. */ -const ItwIssuingPidRequestScreen = () => { +const ItwIssuancePidRequestScreen = () => { const route = useRoute< Route< "ITW_ACTIVATION_PID_REQUEST", - ItwIssuingPidRequestScreenNavigationParams + ItwIssuancePidRequestScreenNavigationParams > >(); const navigation = useNavigation>(); const dispatch = useIODispatch(); - const pid = useIOSelector(itwPidSelector); + const pid = useIOSelector(itwIssuancePidSelector); const pidCredentialCatalogItem = getPidCredentialCatalogItem(); /** @@ -53,7 +53,7 @@ const ItwIssuingPidRequestScreen = () => { */ useOnFirstRender(() => { dispatch( - itwPid.request({ + itwIssuancePid.request({ ...pidCredentialCatalogItem, pidData: route.params.pidData }) @@ -67,7 +67,7 @@ const ItwIssuingPidRequestScreen = () => { */ useEffect(() => { if (pot.isSome(pid)) { - navigation.navigate(ITW_ROUTES.ISSUING.PID.PREVIEW); + navigation.navigate(ITW_ROUTES.ISSUANCE.PID.PREVIEW); } }, [navigation, pid]); @@ -120,4 +120,4 @@ const ItwIssuingPidRequestScreen = () => { ); }; -export default ItwIssuingPidRequestScreen; +export default ItwIssuancePidRequestScreen; diff --git a/ts/features/it-wallet/screens/issuance/pid/ItwIssuancePidStoreScreen.tsx b/ts/features/it-wallet/screens/issuance/pid/ItwIssuancePidStoreScreen.tsx new file mode 100644 index 00000000000..18f72c4cc7c --- /dev/null +++ b/ts/features/it-wallet/screens/issuance/pid/ItwIssuancePidStoreScreen.tsx @@ -0,0 +1,46 @@ +import React from "react"; +import { useNavigation } from "@react-navigation/native"; +import { SafeAreaView } from "react-native-safe-area-context"; +import { IOStyles } from "@pagopa/io-app-design-system"; +import I18n from "../../../../../i18n"; +import ItwContinueView from "../../../components/ItwContinueView"; +import { + AppParamsList, + IOStackNavigationProp +} from "../../../../../navigation/params/AppParamsList"; +import ROUTES from "../../../../../navigation/routes"; + +/** + * Renders an activation screen which displays a loading screen while the PID is being added and a success screen when the PID is added. + */ +const ItwIssuancePidStoreScreen = () => { + const navigation = useNavigation>(); + + return ( + + + navigation.navigate(ROUTES.MAIN, { + screen: ROUTES.ITWALLET_HOME + }) + }} + /> + + ); +}; + +export default ItwIssuancePidStoreScreen; diff --git a/ts/features/it-wallet/screens/issuing/pid/cie/ItwCieCardReaderScreen.tsx b/ts/features/it-wallet/screens/issuance/pid/cie/ItwCieCardReaderScreen.tsx similarity index 94% rename from ts/features/it-wallet/screens/issuing/pid/cie/ItwCieCardReaderScreen.tsx rename to ts/features/it-wallet/screens/issuance/pid/cie/ItwCieCardReaderScreen.tsx index 581ac68aa77..9da58cb6e9b 100644 --- a/ts/features/it-wallet/screens/issuing/pid/cie/ItwCieCardReaderScreen.tsx +++ b/ts/features/it-wallet/screens/issuance/pid/cie/ItwCieCardReaderScreen.tsx @@ -50,11 +50,11 @@ import CieReadingCardAnimation, { ReadingState } from "../../../../components/cie/CieReadingCardAnimation"; import { - CieAuthenticationErrorPayload, - CieAuthenticationErrorReason, - cieAuthenticationError -} from "../../../../store/actions/itwCieActions"; -import { isNfcEnabledSelector } from "../../../../store/reducers/itwCieReducer"; + ItwCieAuthenticationErrorPayload, + ItwCieAuthenticationErrorReason, + itwCieAuthenticationError +} from "../../../../store/actions/itwIssuancePidCieActions"; +import { itwIsNfcEnabledSelector } from "../../../../store/reducers/itwIssuancePidCieAuthReducer"; import BaseScreenComponent from "../../../../../../components/screens/BaseScreenComponent"; import CieNfcOverlay from "../../../../components/cie/CieNfcOverlay"; @@ -65,7 +65,7 @@ export type ItwCieCardReaderScreenNavigationParams = { type NavigationProps = IOStackNavigationRouteProps< ItwParamsList, - "ITW_ISSUING_PID_CIE_CARD_READER_SCREEN" + "ITW_ISSUANCE_PID_CIE_CARD_READER_SCREEN" >; type Props = NavigationProps & ReduxProps & ReturnType; @@ -91,13 +91,13 @@ type State = { }; type setErrorParameter = { - eventReason: CieAuthenticationErrorReason; + eventReason: ItwCieAuthenticationErrorReason; errorDescription?: string; navigation?: () => void; }; // A subset of Cie Events (errors) which is of interest to analytics -const analyticActions = new Map([ +const analyticActions = new Map([ // Reading interrupted before the sdk complete the reading ["Transmission Error", I18n.t("authentication.cie.card.error.onTagLost")], ["ON_TAG_LOST", I18n.t("authentication.cie.card.error.onTagLost")], @@ -245,8 +245,8 @@ class ItwCieCardReaderScreen extends React.PureComponent { ); }; - private dispatchAnalyticEvent = (error: CieAuthenticationErrorPayload) => { - this.props.dispatch(cieAuthenticationError(error)); + private dispatchAnalyticEvent = (error: ItwCieAuthenticationErrorPayload) => { + this.props.dispatch(itwCieAuthenticationError(error)); }; private handleCieEvent = async (event: CEvent) => { @@ -277,7 +277,7 @@ class ItwCieCardReaderScreen extends React.PureComponent { eventReason: event.event, navigation: () => this.props.navigation.navigate(ITW_ROUTES.MAIN, { - screen: ITW_ROUTES.ISSUING.PID.CIE.PIN_TEMP_LOCKED_SCREEN + screen: ITW_ROUTES.ISSUANCE.PID.CIE.PIN_TEMP_LOCKED_SCREEN }) }); break; @@ -288,7 +288,7 @@ class ItwCieCardReaderScreen extends React.PureComponent { eventReason: event.event, navigation: () => this.props.navigation.navigate(ITW_ROUTES.MAIN, { - screen: ITW_ROUTES.ISSUING.PID.CIE.WRONG_PIN_SCREEN, + screen: ITW_ROUTES.ISSUANCE.PID.CIE.WRONG_PIN_SCREEN, params: { remainingCount: event.attemptsLeft } @@ -303,7 +303,7 @@ class ItwCieCardReaderScreen extends React.PureComponent { eventReason: event.event, navigation: () => this.props.navigation.navigate(ITW_ROUTES.MAIN, { - screen: ITW_ROUTES.ISSUING.PID.CIE.EXPIRED_SCREEN + screen: ITW_ROUTES.ISSUANCE.PID.CIE.EXPIRED_SCREEN }) }); break; @@ -377,7 +377,7 @@ class ItwCieCardReaderScreen extends React.PureComponent { setTimeout( async () => { this.props.navigation.navigate(ITW_ROUTES.MAIN, { - screen: ITW_ROUTES.ISSUING.PID.CIE.CONSENT_DATA_USAGE, + screen: ITW_ROUTES.ISSUANCE.PID.CIE.CONSENT_DATA_USAGE, params: { cieConsentUri, pidData @@ -515,7 +515,7 @@ class ItwCieCardReaderScreen extends React.PureComponent { } const mapStateToProps = (state: GlobalState) => { - const isEnabled = isNfcEnabledSelector(state); + const isEnabled = itwIsNfcEnabledSelector(state); return { isNfcEnabled: pot.getOrElse(isEnabled, false), assistanceToolConfig: assistanceToolConfigSelector(state) diff --git a/ts/features/it-wallet/screens/issuing/pid/cie/ItwCieConsentDataUsageScreen.tsx b/ts/features/it-wallet/screens/issuance/pid/cie/ItwCieConsentDataUsageScreen.tsx similarity index 93% rename from ts/features/it-wallet/screens/issuing/pid/cie/ItwCieConsentDataUsageScreen.tsx rename to ts/features/it-wallet/screens/issuance/pid/cie/ItwCieConsentDataUsageScreen.tsx index 4a4165ad825..74b7d31a7f0 100644 --- a/ts/features/it-wallet/screens/issuing/pid/cie/ItwCieConsentDataUsageScreen.tsx +++ b/ts/features/it-wallet/screens/issuance/pid/cie/ItwCieConsentDataUsageScreen.tsx @@ -20,9 +20,9 @@ import { originSchemasWhiteList } from "../../../../../../screens/authentication import { ItwParamsList } from "../../../../navigation/ItwParamsList"; import { ITW_ROUTES } from "../../../../navigation/ItwRoutes"; import { - loginFailure, - loginSuccess -} from "../../../../store/actions/itwCieActions"; + itwLoginFailure, + itwLoginSuccess +} from "../../../../store/actions/itwIssuancePidCieActions"; export type ItwCieConsentDataUsageScreenNavigationParams = { cieConsentUri: string; @@ -35,7 +35,7 @@ type OwnProps = { type NavigationProps = IOStackNavigationRouteProps< ItwParamsList, - "ITW_ISSUING_PID_CIE_CONSENT_DATA_USAGE" + "ITW_ISSUANCE_PID_CIE_CONSENT_DATA_USAGE" >; type State = { @@ -81,7 +81,7 @@ class ItwCieConsentDataUsageScreen extends React.Component { private resetNavigation = () => { this.props.navigation.navigate(ITW_ROUTES.MAIN, { - screen: ITW_ROUTES.ISSUING.PID.AUTH_INFO + screen: ITW_ROUTES.ISSUANCE.PID.AUTH_INFO }); }; @@ -212,9 +212,12 @@ class ItwCieConsentDataUsageScreen extends React.Component { "features.itWallet.issuing.infoConsent.footer.confirm" ), onPress: () => - this.props.navigation.navigate(ITW_ROUTES.ISSUING.PID.REQUEST, { - pidData: this.props.route.params.pidData - }), + this.props.navigation.navigate( + ITW_ROUTES.ISSUANCE.PID.REQUEST, + { + pidData: this.props.route.params.pidData + } + ), label: I18n.t( "features.itWallet.issuing.infoConsent.footer.confirm" ) @@ -230,8 +233,9 @@ class ItwCieConsentDataUsageScreen extends React.Component { const mapDispatchToProps = (dispatch: Dispatch) => ({ loginSuccess: (token: SessionToken) => - dispatch(loginSuccess({ token, idp: "cie" })), - loginFailure: (error: Error) => dispatch(loginFailure({ error, idp: "cie" })) + dispatch(itwLoginSuccess({ token, idp: "cie" })), + loginFailure: (error: Error) => + dispatch(itwLoginFailure({ error, idp: "cie" })) }); export default connect(null, mapDispatchToProps)(ItwCieConsentDataUsageScreen); diff --git a/ts/features/it-wallet/screens/issuing/pid/cie/ItwCieExpiredOrInvalidScreen.tsx b/ts/features/it-wallet/screens/issuance/pid/cie/ItwCieExpiredOrInvalidScreen.tsx similarity index 96% rename from ts/features/it-wallet/screens/issuing/pid/cie/ItwCieExpiredOrInvalidScreen.tsx rename to ts/features/it-wallet/screens/issuance/pid/cie/ItwCieExpiredOrInvalidScreen.tsx index 1f17c111f5c..1b00f612e07 100644 --- a/ts/features/it-wallet/screens/issuing/pid/cie/ItwCieExpiredOrInvalidScreen.tsx +++ b/ts/features/it-wallet/screens/issuance/pid/cie/ItwCieExpiredOrInvalidScreen.tsx @@ -20,7 +20,7 @@ const bookingUrl = I18n.t("cie.booking_url"); const browseToLink = () => openLink(bookingUrl); type NavigationProps = IOStackNavigationRouteProps< ItwParamsList, - "ITW_ISSUING_PID_CIE_EXPIRED_SCREEN" + "ITW_ISSUANCE_PID_CIE_EXPIRED_SCREEN" >; type Props = ReduxProps & NavigationProps; @@ -31,7 +31,7 @@ class ItwCieExpiredOrInvalidScreen extends React.PureComponent { private handleGoBack = () => this.props.navigation.navigate(ITW_ROUTES.MAIN, { - screen: ITW_ROUTES.ISSUING.PID.AUTH_INFO + screen: ITW_ROUTES.ISSUANCE.PID.AUTH_INFO }); public render(): React.ReactNode { diff --git a/ts/features/it-wallet/screens/issuing/pid/cie/ItwCiePinLockedTemporarilyScreen.tsx b/ts/features/it-wallet/screens/issuance/pid/cie/ItwCiePinLockedTemporarilyScreen.tsx similarity index 97% rename from ts/features/it-wallet/screens/issuing/pid/cie/ItwCiePinLockedTemporarilyScreen.tsx rename to ts/features/it-wallet/screens/issuance/pid/cie/ItwCiePinLockedTemporarilyScreen.tsx index f3734a9ef78..f32ea46bc68 100644 --- a/ts/features/it-wallet/screens/issuing/pid/cie/ItwCiePinLockedTemporarilyScreen.tsx +++ b/ts/features/it-wallet/screens/issuance/pid/cie/ItwCiePinLockedTemporarilyScreen.tsx @@ -18,7 +18,7 @@ import { ITW_ROUTES } from "../../../../navigation/ItwRoutes"; type NavigationProps = IOStackNavigationRouteProps< ItwParamsList, - "ITW_ISSUING_PID_CIE_PIN_TEMP_LOCKED_SCREEN" + "ITW_ISSUANCE_PID_CIE_PIN_TEMP_LOCKED_SCREEN" >; type Props = NavigationProps & ReduxProps; @@ -77,7 +77,7 @@ class ItwCiePinLockedTemporarilyScreen extends React.PureComponent< private handleGoBack = () => this.props.navigation.navigate(ITW_ROUTES.MAIN, { - screen: ITW_ROUTES.ISSUING.PID.AUTH_INFO + screen: ITW_ROUTES.ISSUANCE.PID.AUTH_INFO }); public render(): React.ReactNode { diff --git a/ts/features/it-wallet/screens/issuing/pid/cie/ItwCiePinScreen.tsx b/ts/features/it-wallet/screens/issuance/pid/cie/ItwCiePinScreen.tsx similarity index 93% rename from ts/features/it-wallet/screens/issuing/pid/cie/ItwCiePinScreen.tsx rename to ts/features/it-wallet/screens/issuance/pid/cie/ItwCiePinScreen.tsx index 0aa4f2da447..23cf8d68546 100644 --- a/ts/features/it-wallet/screens/issuing/pid/cie/ItwCiePinScreen.tsx +++ b/ts/features/it-wallet/screens/issuance/pid/cie/ItwCiePinScreen.tsx @@ -36,13 +36,13 @@ import { setAccessibilityFocus } from "../../../../../../utils/accessibility"; import { ItwParamsList } from "../../../../navigation/ItwParamsList"; import { ITW_ROUTES } from "../../../../navigation/ItwRoutes"; import { CieRequestAuthenticationOverlay } from "../../../../components/cie/CieRequestAuthenticationOverlay"; -import { nfcIsEnabled } from "../../../../store/actions/itwCieActions"; +import { itwNfcIsEnabled } from "../../../../store/actions/itwIssuancePidCieActions"; import ItwTextInfo from "../../../../components/ItwTextInfo"; import BaseScreenComponent from "../../../../../../components/screens/BaseScreenComponent"; import CiePinpad from "../../../../components/cie/CiePinpad"; const mapDispatchToProps = (dispatch: Dispatch) => ({ - requestNfcEnabledCheck: () => dispatch(nfcIsEnabled.request()) + requestNfcEnabledCheck: () => dispatch(itwNfcIsEnabled.request()) }); type Props = ReduxProps & ReturnType; @@ -67,7 +67,7 @@ const ItwCiePinScreen: React.FC = props => { const { showAnimatedModal, hideModal } = useContext(LightModalContext); const navigation = useNavigation< - IOStackNavigationProp + IOStackNavigationProp >(); const [pin, setPin] = useState(""); const pinPadViewRef = useRef(null); @@ -83,7 +83,7 @@ const ItwCiePinScreen: React.FC = props => { useEffect(() => { if (authUrlGenerated !== undefined) { - navigation.navigate(ITW_ROUTES.ISSUING.PID.CIE.CARD_READER_SCREEN, { + navigation.navigate(ITW_ROUTES.ISSUANCE.PID.CIE.CARD_READER_SCREEN, { ciePin: pin, authorizationUri: authUrlGenerated }); diff --git a/ts/features/it-wallet/screens/issuing/pid/cie/ItwCieWrongPinScreen.tsx b/ts/features/it-wallet/screens/issuance/pid/cie/ItwCieWrongPinScreen.tsx similarity index 95% rename from ts/features/it-wallet/screens/issuing/pid/cie/ItwCieWrongPinScreen.tsx rename to ts/features/it-wallet/screens/issuance/pid/cie/ItwCieWrongPinScreen.tsx index 7a025a3a15b..45406a46fcb 100644 --- a/ts/features/it-wallet/screens/issuing/pid/cie/ItwCieWrongPinScreen.tsx +++ b/ts/features/it-wallet/screens/issuance/pid/cie/ItwCieWrongPinScreen.tsx @@ -19,7 +19,7 @@ export type ItwCieWrongPinScreenNavigationParams = { type NavigationProps = IOStackNavigationRouteProps< ItwParamsList, - "ITW_ISSUING_PID_CIE_WRONG_PIN_SCREEN" + "ITW_ISSUANCE_PID_CIE_WRONG_PIN_SCREEN" >; type Props = NavigationProps & ReturnType; @@ -28,13 +28,13 @@ class ItwCieWrongPinScreen extends React.PureComponent { // TODO: use redux to handle control? private navigateToCiePinScreen = async () => { this.props.navigation.navigate(ITW_ROUTES.MAIN, { - screen: ITW_ROUTES.ISSUING.PID.CIE.PIN_SCREEN + screen: ITW_ROUTES.ISSUANCE.PID.CIE.PIN_SCREEN }); }; private resetAuthentication = () => { this.props.navigation.navigate(ITW_ROUTES.MAIN, { - screen: ITW_ROUTES.ISSUING.PID.AUTH_INFO + screen: ITW_ROUTES.ISSUANCE.PID.AUTH_INFO }); }; diff --git a/ts/features/it-wallet/screens/issuing/pid/ItwIssuingPidAddingScreen.tsx b/ts/features/it-wallet/screens/issuing/pid/ItwIssuingPidAddingScreen.tsx deleted file mode 100644 index 67fa6d66a69..00000000000 --- a/ts/features/it-wallet/screens/issuing/pid/ItwIssuingPidAddingScreen.tsx +++ /dev/null @@ -1,96 +0,0 @@ -import React from "react"; -import { useNavigation } from "@react-navigation/native"; -import * as pot from "@pagopa/ts-commons/lib/pot"; -import { VSpacer } from "@pagopa/io-app-design-system"; -import { useOnFirstRender } from "../../../../../utils/hooks/useOnFirstRender"; -import { useIODispatch, useIOSelector } from "../../../../../store/hooks"; -import ItwLoadingSpinnerOverlay from "../../../components/ItwLoadingSpinnerOverlay"; -import I18n from "../../../../../i18n"; -import { itwPidValueSelector } from "../../../store/reducers/itwPidReducer"; -import { itwCredentialsAddPid } from "../../../store/actions/itwCredentialsActions"; -import { itwActivationCompleted } from "../../../store/actions/itwActivationActions"; -import { ItwCredentialsStateSelector } from "../../../store/reducers/itwCredentialsReducer"; -import { - ItWalletError, - getItwGenericMappedError -} from "../../../utils/itwErrorsUtils"; -import ItwContinueView from "../../../components/ItwContinueView"; -import ItwKoView from "../../../components/ItwKoView"; - -/** - * Renders an activation screen which displays a loading screen while the PID is being added and a success screen when the PID is added. - */ -const ItwIssuingPidAddingScreen = () => { - const dispatch = useIODispatch(); - const pid = useIOSelector(itwPidValueSelector); - const navigation = useNavigation(); - const credentialsState = useIOSelector(ItwCredentialsStateSelector); - - useOnFirstRender(() => { - dispatch(itwCredentialsAddPid.request(pid)); - }); - - const LoadingView = () => ( - - <> - - ); - - const SuccessView = () => ( - <> - dispatch(itwActivationCompleted()) - }} - /> - - - ); - - /** - * Error view component which currently displays a generic error. - * @param error - optional ItWalletError to be displayed. - */ - const ErrorView = ({ error: _ }: { error?: ItWalletError }) => { - const mappedError = getItwGenericMappedError(() => navigation.goBack()); - return ; - }; - - const RenderMask = () => - pot.fold( - credentialsState, - () => , - () => , - () => , - err => , - _ => , - () => , - () => , - (_, err) => - ); - - return ; -}; - -export default ItwIssuingPidAddingScreen; diff --git a/ts/features/it-wallet/screens/presentation/ItwPrCredentialDetails.tsx b/ts/features/it-wallet/screens/presentation/ItwPrCredentialDetails.tsx index d946bbfa4a5..27f2d50ed4a 100644 --- a/ts/features/it-wallet/screens/presentation/ItwPrCredentialDetails.tsx +++ b/ts/features/it-wallet/screens/presentation/ItwPrCredentialDetails.tsx @@ -17,7 +17,7 @@ import ItwCredentialClaimsList from "../../components/ItwCredentialClaimsList"; import ItwClaimsWrapper from "../../components/ItwClaimsWrapper"; import { ITW_ROUTES } from "../../navigation/ItwRoutes"; import { IOStackNavigationProp } from "../../../../navigation/params/AppParamsList"; -import { StoredCredential } from "../../utils/types"; +import { StoredCredential } from "../../utils/itwTypesUtils"; export type ItwPrCredentialDetailsScreenNavigationParams = { credential: StoredCredential; diff --git a/ts/features/it-wallet/screens/presentation/ItwPrPidDetails.tsx b/ts/features/it-wallet/screens/presentation/ItwPrPidDetails.tsx index 59dbd869ab2..780b18d8920 100644 --- a/ts/features/it-wallet/screens/presentation/ItwPrPidDetails.tsx +++ b/ts/features/it-wallet/screens/presentation/ItwPrPidDetails.tsx @@ -16,13 +16,13 @@ import { useIOSelector } from "../../../../store/hooks"; import { IOStyles } from "../../../../components/core/variables/IOStyles"; import { IOStackNavigationProp } from "../../../../navigation/params/AppParamsList"; import { ItwParamsList } from "../../navigation/ItwParamsList"; -import { CredentialType } from "../../utils/mocks"; +import { CredentialType } from "../../utils/itwMocksUtils"; import ItwClaimsWrapper from "../../components/ItwClaimsWrapper"; import { ITW_ROUTES } from "../../navigation/ItwRoutes"; import ItwKoView from "../../components/ItwKoView"; import { getItwGenericMappedError } from "../../utils/itwErrorsUtils"; -import { itwCredentialsPidSelector } from "../../store/reducers/itwCredentialsReducer"; -import { StoredCredential } from "../../utils/types"; +import { itwPersistedCredentialsValuePidSelector } from "../../store/reducers/itwPersistedCredentialsReducer"; +import { StoredCredential } from "../../utils/itwTypesUtils"; import ItwCredentialClaimsList from "../../components/ItwCredentialClaimsList"; /** @@ -31,7 +31,7 @@ import ItwCredentialClaimsList from "../../components/ItwCredentialClaimsList"; */ const ItwPrPidDetails = () => { const navigation = useNavigation>(); - const pid = useIOSelector(itwCredentialsPidSelector); + const pid = useIOSelector(itwPersistedCredentialsValuePidSelector); const bannerViewRef = React.createRef(); const spacerSize = 32; diff --git a/ts/features/it-wallet/screens/presentation/ItwPrProximityQrCodeScreen.tsx b/ts/features/it-wallet/screens/presentation/ItwPrProximityQrCodeScreen.tsx index 5f19537bfba..c902086f746 100644 --- a/ts/features/it-wallet/screens/presentation/ItwPrProximityQrCodeScreen.tsx +++ b/ts/features/it-wallet/screens/presentation/ItwPrProximityQrCodeScreen.tsx @@ -28,7 +28,7 @@ import I18n from "../../../../i18n"; import BaseScreenComponent from "../../../../components/screens/BaseScreenComponent"; import ItwKoView from "../../components/ItwKoView"; import { getItwGenericMappedError } from "../../utils/itwErrorsUtils"; -import { mockedmDLResponse } from "../../utils/mocks"; +import { mockedmDLResponse } from "../../utils/itwMocksUtils"; import ItwContinueView from "../../components/ItwContinueView"; import ROUTES from "../../../../navigation/routes"; import { useIODispatch, useIOSelector } from "../../../../store/hooks"; @@ -38,9 +38,9 @@ import { stopProximityManager } from "../../store/actions/itwProximityActions"; import { - proximityStatusSelector, - qrcodeSelector -} from "../../store/reducers/itwProximityReducer"; + itwPrProximitySelector, + itwPrProximityQrCodeSelector +} from "../../store/reducers/itwPrProximityReducer"; /** * A screen that shows a QR code to be scanned by the other device @@ -54,8 +54,8 @@ const ItwPrProximityQrCodeScreen = () => { const [isProximityCompleted, setIsProximityCompleted] = React.useState(false); const navigation = useNavigation>(); const dispatch = useIODispatch(); - const proximityStatus = useIOSelector(proximityStatusSelector); - const qrCode = useIOSelector(qrcodeSelector); + const proximityStatus = useIOSelector(itwPrProximitySelector); + const qrCode = useIOSelector(itwPrProximityQrCodeSelector); useOnFirstRender(() => { handleAndroidPermissions().catch(_ => setIsError(true)); diff --git a/ts/features/it-wallet/screens/presentation/remote/credential/ItwPrRemoteCredentialChecksScreen.tsx b/ts/features/it-wallet/screens/presentation/remote/credential/ItwPrRemoteCredentialChecksScreen.tsx index e2067dc7d91..dfca55f429f 100644 --- a/ts/features/it-wallet/screens/presentation/remote/credential/ItwPrRemoteCredentialChecksScreen.tsx +++ b/ts/features/it-wallet/screens/presentation/remote/credential/ItwPrRemoteCredentialChecksScreen.tsx @@ -3,8 +3,7 @@ import * as pot from "@pagopa/ts-commons/lib/pot"; import { useNavigation } from "@react-navigation/native"; import { SafeAreaView } from "react-native-safe-area-context"; import { IOStyles } from "@pagopa/io-app-design-system"; -import { itwPresentationChecks } from "../../../../store/actions/itwPresentationActions"; -import { itwPresentationChecksSelector } from "../../../../store/reducers/new/itwPresentationReducer"; +import { itwPrRemoteCredentialInit } from "../../../../store/actions/itwPrRemoteCredentialActions"; import { useIODispatch, useIOSelector } from "../../../../../../store/hooks"; import { useOnFirstRender } from "../../../../../../utils/hooks/useOnFirstRender"; import ItwLoadingSpinnerOverlay from "../../../../components/ItwLoadingSpinnerOverlay"; @@ -15,7 +14,7 @@ import { IOStackNavigationProp } from "../../../../../../navigation/params/AppParamsList"; import { ItwParamsList } from "../../../../navigation/ItwParamsList"; -import { getRpMock } from "../../../../utils/mocks"; +import { getRpMock } from "../../../../utils/itwMocksUtils"; import { ITW_ROUTES } from "../../../../navigation/ItwRoutes"; import ItwKoView from "../../../../components/ItwKoView"; import { itwActivationStart } from "../../../../store/actions/itwActivationActions"; @@ -25,6 +24,7 @@ import { ItwErrorMapping, getItwGenericMappedError } from "../../../../utils/itwErrorsUtils"; +import { itwPrRemoteCredentialInitSelector } from "../../../../store/reducers/itwPrRemoteCredentialReducer"; /** * This screen is used to perform different checks before initiating the presentation flow. @@ -32,15 +32,15 @@ import { * It shows an error screen if the checks fail. * The view is rendered based on the state of the checks pot. */ -const ItwPrRemoteCredentialChecksScreen = () => { +const ItwPrRemoteCredentialInitScreen = () => { const dispatch = useIODispatch(); - const checksPot = useIOSelector(itwPresentationChecksSelector); + const initPot = useIOSelector(itwPrRemoteCredentialInitSelector); const navigation = useNavigation>(); const rpMock = getRpMock(); useOnFirstRender(() => { - dispatch(itwPresentationChecks.request()); + dispatch(itwPrRemoteCredentialInit.request()); }); const LoadingView = () => ( @@ -114,7 +114,7 @@ const ItwPrRemoteCredentialChecksScreen = () => { const RenderMask = () => pot.fold( - checksPot, + initPot, () => , () => , () => , @@ -128,4 +128,4 @@ const ItwPrRemoteCredentialChecksScreen = () => { return ; }; -export default ItwPrRemoteCredentialChecksScreen; +export default ItwPrRemoteCredentialInitScreen; diff --git a/ts/features/it-wallet/screens/presentation/remote/credential/ItwPrRemoteCredentialDataScreen.tsx b/ts/features/it-wallet/screens/presentation/remote/credential/ItwPrRemoteCredentialDataScreen.tsx index db3ed216abe..ddcb30e36e7 100644 --- a/ts/features/it-wallet/screens/presentation/remote/credential/ItwPrRemoteCredentialDataScreen.tsx +++ b/ts/features/it-wallet/screens/presentation/remote/credential/ItwPrRemoteCredentialDataScreen.tsx @@ -28,21 +28,21 @@ import { emptyContextualHelp } from "../../../../../../utils/emptyContextualHelp import ItwOptionalClaimsList from "../../../../components/ItwOptionalClaimsList"; import { ITW_ROUTES } from "../../../../navigation/ItwRoutes"; import { useItwInfoBottomSheet } from "../../../../hooks/useItwInfoBottomSheet"; -import { getRpMock } from "../../../../utils/mocks"; -import { showCancelAlert } from "../../../../utils/alert"; +import { getRpMock } from "../../../../utils/itwMocksUtils"; +import { itwShowCancelAlert } from "../../../../utils/itwAlertsUtils"; import ItwKoView from "../../../../components/ItwKoView"; import { getItwGenericMappedError } from "../../../../utils/itwErrorsUtils"; import { ForceScrollDownView } from "../../../../../../components/ForceScrollDownView"; import ItwTextInfo from "../../../../components/ItwTextInfo"; -import { itwCredentialsPidSelector } from "../../../../store/reducers/itwCredentialsReducer"; -import { StoredCredential } from "../../../../utils/types"; +import { itwPersistedCredentialsValuePidSelector } from "../../../../store/reducers/itwPersistedCredentialsReducer"; +import { StoredCredential } from "../../../../utils/itwTypesUtils"; /** * This screen displays the information about the credential that is going to be shared * with the issuer. */ const ItwPrRemoteCredentialDataScreen = () => { - const pid = useIOSelector(itwCredentialsPidSelector); + const pid = useIOSelector(itwPersistedCredentialsValuePidSelector); const navigation = useNavigation>(); const rpMock = getRpMock(); const { present, bottomSheet } = useItwInfoBottomSheet({ @@ -180,7 +180,7 @@ const ItwPrRemoteCredentialDataScreen = () => { buttonProps: { color: "primary", accessibilityLabel: I18n.t("global.buttons.cancel"), - onPress: () => showCancelAlert(alertOnPress), + onPress: () => itwShowCancelAlert(alertOnPress), label: I18n.t("global.buttons.cancel") } }} diff --git a/ts/features/it-wallet/screens/presentation/remote/credential/ItwPrRemoteCredentialResultScreen.tsx b/ts/features/it-wallet/screens/presentation/remote/credential/ItwPrRemoteCredentialResultScreen.tsx index f56dd8a696b..f2b61aa8f18 100644 --- a/ts/features/it-wallet/screens/presentation/remote/credential/ItwPrRemoteCredentialResultScreen.tsx +++ b/ts/features/it-wallet/screens/presentation/remote/credential/ItwPrRemoteCredentialResultScreen.tsx @@ -3,8 +3,7 @@ import * as pot from "@pagopa/ts-commons/lib/pot"; import { useNavigation } from "@react-navigation/native"; import { SafeAreaView } from "react-native-safe-area-context"; import { IOStyles } from "@pagopa/io-app-design-system"; -import { itwPresentation } from "../../../../store/actions/itwPresentationActions"; -import { itwPresentationResultSelector } from "../../../../store/reducers/new/itwPresentationReducer"; +import { itwPrRemoteCredential } from "../../../../store/actions/itwPrRemoteCredentialActions"; import { useIODispatch, useIOSelector } from "../../../../../../store/hooks"; import { useOnFirstRender } from "../../../../../../utils/hooks/useOnFirstRender"; import ItwLoadingSpinnerOverlay from "../../../../components/ItwLoadingSpinnerOverlay"; @@ -15,9 +14,10 @@ import { IOStackNavigationProp } from "../../../../../../navigation/params/AppParamsList"; import { ItwParamsList } from "../../../../navigation/ItwParamsList"; -import { getRpMock } from "../../../../utils/mocks"; +import { getRpMock } from "../../../../utils/itwMocksUtils"; import ItwKoView from "../../../../components/ItwKoView"; import { getItwGenericMappedError } from "../../../../utils/itwErrorsUtils"; +import { itwPrRemoteCredentialResultSelector } from "../../../../store/reducers/itwPrRemoteCredentialReducer"; /** * This screen is used to perform different checks before initiating the presentation flow. @@ -27,13 +27,13 @@ import { getItwGenericMappedError } from "../../../../utils/itwErrorsUtils"; */ const ItwPrRemoteCredentialResultScreen = () => { const dispatch = useIODispatch(); - const resultPot = useIOSelector(itwPresentationResultSelector); + const resultPot = useIOSelector(itwPrRemoteCredentialResultSelector); const navigation = useNavigation>(); const rpMock = getRpMock(); useOnFirstRender(() => { - dispatch(itwPresentation.request()); + dispatch(itwPrRemoteCredential.request()); }); const LoadingView = () => ( diff --git a/ts/features/it-wallet/screens/presentation/remote/pid/ItwPrRemotePidChecksScreen.tsx b/ts/features/it-wallet/screens/presentation/remote/pid/ItwPrRemotePidChecksScreen.tsx index 7b34eae505f..11107906db1 100644 --- a/ts/features/it-wallet/screens/presentation/remote/pid/ItwPrRemotePidChecksScreen.tsx +++ b/ts/features/it-wallet/screens/presentation/remote/pid/ItwPrRemotePidChecksScreen.tsx @@ -7,13 +7,12 @@ import I18n from "../../../../../../i18n"; import { useIODispatch, useIOSelector } from "../../../../../../store/hooks"; import { useOnFirstRender } from "../../../../../../utils/hooks/useOnFirstRender"; import { ItwParamsList } from "../../../../navigation/ItwParamsList"; -import { - RpData, - itwRpInitializationSelector -} from "../../../../store/reducers/itwRpInitializationReducer"; import ItwLoadingSpinnerOverlay from "../../../../components/ItwLoadingSpinnerOverlay"; -import { itwRpInitialization } from "../../../../store/actions/itwRpActions"; -import { rpPidMock } from "../../../../utils/mocks"; +import { + ItwPrRemotePidInitData, + itwPrRemotePidInit +} from "../../../../store/actions/itwPrRemotePidActions"; +import { rpPidMock } from "../../../../utils/itwMocksUtils"; import { ITW_ROUTES } from "../../../../navigation/ItwRoutes"; import ItwKoView from "../../../../components/ItwKoView"; import { @@ -25,33 +24,34 @@ import { import { IOStackNavigationProp } from "../../../../../../navigation/params/AppParamsList"; import ItwContinueView from "../../../../components/ItwContinueView"; import { itwActivationStart } from "../../../../store/actions/itwActivationActions"; +import { itwPrRemotePidInitSelector } from "../../../../store/reducers/itwPrRemotePidReducer"; /** * ItwPrRemotePidChecksScreenNavigationParams's navigation params. * The authReqUrl is the url to use to start the RP flow. */ -export type ItwPrRemotePidChecksScreenNavigationParams = RpData; +export type ItwPrRemotePidChecksScreenNavigationParams = ItwPrRemotePidInitData; /** - * Type of the route props for the ItwIssuingPidRequestScreen. + * Type of the route props for the ItwIssuancePidRequestScreen. */ type ItwPrRemotePidChecksScreenRouteProps = RouteProp< ItwParamsList, - "ITW_PRESENTATION_PID_REMOTE_CHECKS" + "ITW_PRESENTATION_PID_REMOTE_INIT" >; const ItwPrRemotePidChecksScreen = () => { const route = useRoute(); const dispatch = useIODispatch(); const navigation = useNavigation>(); - const initStatus = useIOSelector(itwRpInitializationSelector); + const initStatus = useIOSelector(itwPrRemotePidInitSelector); /** * Dispatches the action to start the RP flow on first render. */ useOnFirstRender(() => { dispatch( - itwRpInitialization.request({ + itwPrRemotePidInit.request({ authReqUrl: route.params.authReqUrl, clientId: route.params.clientId }) diff --git a/ts/features/it-wallet/screens/presentation/remote/pid/ItwPrRemotePidDataScreen.tsx b/ts/features/it-wallet/screens/presentation/remote/pid/ItwPrRemotePidDataScreen.tsx index 12777608914..cc69be46934 100644 --- a/ts/features/it-wallet/screens/presentation/remote/pid/ItwPrRemotePidDataScreen.tsx +++ b/ts/features/it-wallet/screens/presentation/remote/pid/ItwPrRemotePidDataScreen.tsx @@ -24,10 +24,10 @@ import { ItwParamsList } from "../../../../navigation/ItwParamsList"; import BaseScreenComponent from "../../../../../../components/screens/BaseScreenComponent"; import { emptyContextualHelp } from "../../../../../../utils/emptyContextualHelp"; import I18n from "../../../../../../i18n"; -import { showCancelAlert } from "../../../../utils/alert"; +import { itwShowCancelAlert } from "../../../../utils/itwAlertsUtils"; import ItwTextInfo from "../../../../components/ItwTextInfo"; import ItwBulletList from "../../../../components/ItwBulletList"; -import { rpPidMock } from "../../../../utils/mocks"; +import { rpPidMock } from "../../../../utils/itwMocksUtils"; import { ITW_ROUTES } from "../../../../navigation/ItwRoutes"; import interno from "../../../../../../../img/features/it-wallet/interno.png"; import { useItwInfoBottomSheet } from "../../../../hooks/useItwInfoBottomSheet"; @@ -35,11 +35,11 @@ import ItwKoView from "../../../../components/ItwKoView"; import { getItwGenericMappedError } from "../../../../utils/itwErrorsUtils"; import ROUTES from "../../../../../../navigation/routes"; import { ForceScrollDownView } from "../../../../../../components/ForceScrollDownView"; -import { itwCredentialsPidSelector } from "../../../../store/reducers/itwCredentialsReducer"; -import { StoredCredential } from "../../../../utils/types"; +import { itwPersistedCredentialsValuePidSelector } from "../../../../store/reducers/itwPersistedCredentialsReducer"; +import { StoredCredential } from "../../../../utils/itwTypesUtils"; const ItwPrRemotePidDataScreen = () => { - const pid = useIOSelector(itwCredentialsPidSelector); + const pid = useIOSelector(itwPersistedCredentialsValuePidSelector); const navigation = useNavigation>(); const { present, bottomSheet } = useItwInfoBottomSheet({ title: rpPidMock.organizationName, @@ -167,7 +167,7 @@ const ItwPrRemotePidDataScreen = () => { buttonProps: { color: "primary", accessibilityLabel: I18n.t("global.buttons.cancel"), - onPress: () => showCancelAlert(alertOnPress), + onPress: () => itwShowCancelAlert(alertOnPress), label: I18n.t("global.buttons.cancel") } }} diff --git a/ts/features/it-wallet/screens/presentation/remote/pid/ItwPrRemotePidResultScreen.tsx b/ts/features/it-wallet/screens/presentation/remote/pid/ItwPrRemotePidResultScreen.tsx index 65b0d12074b..dc4b46cf615 100644 --- a/ts/features/it-wallet/screens/presentation/remote/pid/ItwPrRemotePidResultScreen.tsx +++ b/ts/features/it-wallet/screens/presentation/remote/pid/ItwPrRemotePidResultScreen.tsx @@ -8,11 +8,13 @@ import I18n from "../../../../../../i18n"; import { IOStyles } from "../../../../../../components/core/variables/IOStyles"; import { useIODispatch, useIOSelector } from "../../../../../../store/hooks"; import { useOnFirstRender } from "../../../../../../utils/hooks/useOnFirstRender"; -import { itwRpPresentationSelector } from "../../../../store/reducers/itwRpPresentationReducer"; -import { itwRpInitializationEntityValueSelector } from "../../../../store/reducers/itwRpInitializationReducer"; -import { itwRpPresentation } from "../../../../store/actions/itwRpActions"; +import { + itwPrRemotePidInitValueSelector, + itwPrRemotePidResultSelector +} from "../../../../store/reducers/itwPrRemotePidReducer"; +import { itwPrRemotePidPresentation } from "../../../../store/actions/itwPrRemotePidActions"; import { ItwParamsList } from "../../../../navigation/ItwParamsList"; -import { rpPidMock } from "../../../../utils/mocks"; +import { rpPidMock } from "../../../../utils/itwMocksUtils"; import ItwLoadingSpinnerOverlay from "../../../../components/ItwLoadingSpinnerOverlay"; import { IOStackNavigationProp } from "../../../../../../navigation/params/AppParamsList"; import ROUTES from "../../../../../../navigation/routes"; @@ -21,15 +23,15 @@ import { getItwGenericMappedError } from "../../../../utils/itwErrorsUtils"; const ItwPrRemotePidResultScreen = () => { const dispatch = useIODispatch(); - const presentationResult = useIOSelector(itwRpPresentationSelector); - const rpEntity = useIOSelector(itwRpInitializationEntityValueSelector); + const prResult = useIOSelector(itwPrRemotePidResultSelector); + const initValue = useIOSelector(itwPrRemotePidInitValueSelector); const navigation = useNavigation>(); /** * Dispatches the action to start the RP presentation flow after the user confirms. */ useOnFirstRender(() => { - dispatch(itwRpPresentation.request()); + dispatch(itwPrRemotePidPresentation.request()); }); /** @@ -88,14 +90,14 @@ const ItwPrRemotePidResultScreen = () => { */ const RenderMask = () => pipe( - rpEntity, + initValue, O.fold( () => , ( _ // some equals to the RP federation entity ) => pot.fold( - presentationResult, + prResult, () => , () => , () => , diff --git a/ts/features/it-wallet/store/actions/index.ts b/ts/features/it-wallet/store/actions/index.ts index bd9158e9be7..f662b81a101 100644 --- a/ts/features/it-wallet/store/actions/index.ts +++ b/ts/features/it-wallet/store/actions/index.ts @@ -1,23 +1,29 @@ -import { ItwCredentialsActions } from "./itwCredentialsActions"; -import { ItwCieAuthenticationActions } from "./itwCieActions"; +import { ItwPersistedCredentialsActions } from "./itwPersistedCredentialsActions"; +import { ItwIssuancePidCieAuthActions } from "./itwIssuancePidCieActions"; import { ItwActivationActions } from "./itwActivationActions"; import { ItwWiaActions } from "./itwWiaActions"; import { ItwLifecycleActions } from "./itwLifecycleActions"; -import { ItwRpActions } from "./itwRpActions"; -import { ItwPresentationChecks } from "./itwPresentationActions"; -import { itwIssuanceActions } from "./itwIssuanceActions"; +import { ItwRpActions } from "./itwPrRemotePidActions"; +import { itwPrRemoteCredentialInit } from "./itwPrRemoteCredentialActions"; +import { ItwIssuanceCredentialActions } from "./itwIssuanceCredentialActions"; import { ItwProximityActions } from "./itwProximityActions"; +import { ItwIssuancePidActions } from "./itwIssuancePidActions"; /** * Action types for the IT Wallet feature */ export type ItWalletActions = - | itwIssuanceActions - | ItwActivationActions - | ItwWiaActions + /* GENERIC */ | ItwLifecycleActions - | ItwCredentialsActions - | ItwCieAuthenticationActions + | ItwWiaActions + | ItwActivationActions + /* ISSUANCE */ + | ItwIssuancePidCieAuthActions + | ItwIssuancePidActions + | ItwIssuanceCredentialActions + /* PERSISTED CREDENTIALS */ + | ItwPersistedCredentialsActions + /* PRESENTATION */ | ItwRpActions - | ItwPresentationChecks + | itwPrRemoteCredentialInit | ItwProximityActions; diff --git a/ts/features/it-wallet/store/actions/itwCredentialsActions.ts b/ts/features/it-wallet/store/actions/itwCredentialsActions.ts deleted file mode 100644 index 5ce65bde813..00000000000 --- a/ts/features/it-wallet/store/actions/itwCredentialsActions.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { ActionType, createAsyncAction } from "typesafe-actions"; -import * as O from "fp-ts/lib/Option"; - -import { PidData } from "@pagopa/io-react-native-cie-pid"; -import { ItWalletError } from "../../utils/itwErrorsUtils"; -import { StoredCredential } from "../../utils/types"; -import { - CredentialCatalogAvailableItem, - PidCredentialCatalogItem -} from "./../../utils/mocks"; - -/** - * Action which requests a PID issuing. - */ -export const itwPid = createAsyncAction( - "ITW_CREDENTIALS_PID_REQUEST", - "ITW_CREDENTIALS_PID_SUCCESS", - "ITW_CREDENTIALS_PID_FAILURE" -)< - PidCredentialCatalogItem & { pidData: PidData }, - StoredCredential, - ItWalletError ->(); - -/** - * Action which adds the PID to the wallet. - */ -export const itwCredentialsAddPid = createAsyncAction( - "ITW_CREDENTIAL_ADD_PID_REQUEST", - "ITW_CREDENTIAL_ADD_PID_SUCCESS", - "ITW_CREDENTIAL_ADD_PID_FAILURE" -), StoredCredential, ItWalletError>(); - -/** - * Action to check if the citizen can add a credential to the wallet. - */ -export const itwCredentialsChecks = createAsyncAction( - "ITW_CREDENTIALS_CHECKS_REQUEST", - "ITW_CREDENTIALS_CHECKS_SUCCESS", - "ITW_CREDENTIALS_CHECKS_FAILURE" -)< - CredentialCatalogAvailableItem, - CredentialCatalogAvailableItem, - ItWalletError ->(); - -/** - * Action to add a credential to the wallet. - */ -export const itwCredentialsAddCredential = createAsyncAction( - "ITW_CREDENTIALS_ADD_REQUEST", - "ITW_CREDENTIALS_ADD_SUCCESS", - "ITW_CREDENTIALS_ADD_FAILURE" -)(); - -/** - * Type for credentials related actions. - */ -export type ItwCredentialsActions = - | ActionType - | ActionType - | ActionType - | ActionType; diff --git a/ts/features/it-wallet/store/actions/itwIssuanceActions.ts b/ts/features/it-wallet/store/actions/itwIssuanceActions.ts deleted file mode 100644 index a4871812a07..00000000000 --- a/ts/features/it-wallet/store/actions/itwIssuanceActions.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { - ActionType, - createAsyncAction, - createStandardAction -} from "typesafe-actions"; -import { ItWalletError } from "../../utils/itwErrorsUtils"; -import { IssuanceData } from "../reducers/new/itwIssuanceReducer"; -import { - CredentialDefinition, - StartIssuanceFlow, - StoredCredential -} from "../../utils/types"; - -/** - * Actions for the issuance checks flow. - */ -export const itwIssuanceChecks = createAsyncAction( - "ITW_ISSUANCE_CHECKS_REQUEST", - "ITW_ISSUANCE_CHECKS_SUCCESS", - "ITW_ISSUANCE_CHECKS_FAILURE", - "ITW_ISSUANCE_CHECKS_CANCEL" -)(); - -/** - * Actions for the issuance flow. - */ -export const itwIssuanceGetCredential = createAsyncAction( - "ITW_ISSUANCE_GET_CREDENTIAL_REQUEST", - "ITW_ISSUANCE_GET_CREDENTIAL_SUCCESS", - "ITW_ISSUANCE_GET_CREDENTIAL_FAILURE" -)(); - -/** - * Action which is dispatched when the user confirms the storage of the credential. - */ -export const itwConfirmStoreCredential = createStandardAction( - "ITW_CONFIRM_STORE_CREDENTIAL" -)(); - -export type itwIssuanceActions = - | ActionType - | ActionType - | ActionType; diff --git a/ts/features/it-wallet/store/actions/itwIssuanceCredentialActions.ts b/ts/features/it-wallet/store/actions/itwIssuanceCredentialActions.ts new file mode 100644 index 00000000000..61a1b894161 --- /dev/null +++ b/ts/features/it-wallet/store/actions/itwIssuanceCredentialActions.ts @@ -0,0 +1,46 @@ +import { + ActionType, + createAsyncAction, + createStandardAction +} from "typesafe-actions"; +import { ItWalletError } from "../../utils/itwErrorsUtils"; +import { ItwIssuanceCredentialData } from "../reducers/itwIssuanceCredentialReducer"; +import { + CredentialDefinition, + StartIssuanceFlow, + StoredCredential +} from "../../utils/itwTypesUtils"; + +/** + * Actions for the issuance checks flow. + */ +export const itwIssuanceCredentialChecks = createAsyncAction( + "ITW_ISSUANCE_CREDENTIAL_CHECKS_REQUEST", + "ITW_ISSUANCE_CREDENTIAL_CHECKS_SUCCESS", + "ITW_ISSUANCE_CREDENTIAL_CHECKS_FAILURE" +)< + StartIssuanceFlow & CredentialDefinition, + ItwIssuanceCredentialData, + ItWalletError +>(); + +/** + * Actions for the issuance flow. + */ +export const itwIssuanceCredential = createAsyncAction( + "ITW_ISSUANCE_CREDENTIAL_REQUEST", + "ITW_ISSUANCE_CREDENTIAL_SUCCESS", + "ITW_ISSUANCE_CREDENTIAL_FAILURE" +)(); + +/** + * Action which is dispatched when the user confirms the storage of the credential. + */ +export const itwIssuanceCredentialStore = createStandardAction( + "ITW_CONFIRM_STORE_CREDENTIAL" +)(); + +export type ItwIssuanceCredentialActions = + | ActionType + | ActionType + | ActionType; diff --git a/ts/features/it-wallet/store/actions/itwIssuancePidActions.ts b/ts/features/it-wallet/store/actions/itwIssuancePidActions.ts new file mode 100644 index 00000000000..089cc304452 --- /dev/null +++ b/ts/features/it-wallet/store/actions/itwIssuancePidActions.ts @@ -0,0 +1,34 @@ +import { + ActionType, + createAsyncAction, + createStandardAction +} from "typesafe-actions"; +import { PidData } from "@pagopa/io-react-native-cie-pid"; +import { PidCredentialCatalogItem } from "../../utils/itwMocksUtils"; +import { StoredCredential } from "../../utils/itwTypesUtils"; +import { ItWalletError } from "../../utils/itwErrorsUtils"; + +/** + * Action which requests a PID issuing. + */ +export const itwIssuancePid = createAsyncAction( + "ITW_ISSUANCE_PID_REQUEST", + "ITW_ISSUANCE_PID_SUCCESS", + "ITW_ISSUANCE_PID_FAILURE" +)< + PidCredentialCatalogItem & { pidData: PidData }, + StoredCredential, + ItWalletError +>(); + +/** + * Action which requests a PID storing. + */ +export const itwIssuancePidStore = createStandardAction( + "ITW_ISSUANCE_PID_STORE" +)(); + +/** + * Type for pid issuance related actions. + */ +export type ItwIssuancePidActions = ActionType; diff --git a/ts/features/it-wallet/store/actions/itwCieActions.ts b/ts/features/it-wallet/store/actions/itwIssuancePidCieActions.ts similarity index 53% rename from ts/features/it-wallet/store/actions/itwCieActions.ts rename to ts/features/it-wallet/store/actions/itwIssuancePidCieActions.ts index 6743a53a976..4995ae7bdaf 100644 --- a/ts/features/it-wallet/store/actions/itwCieActions.ts +++ b/ts/features/it-wallet/store/actions/itwIssuancePidCieActions.ts @@ -11,63 +11,63 @@ import { import { SessionToken } from "../../../../types/SessionToken"; import { IdpData } from "../../../../../definitions/content/IdpData"; -export const hasApiLevelSupport = createAsyncAction( +export const itwHasApiLevelSupport = createAsyncAction( "ITW_CIE_HAS_API_LEVEL_REQUEST", "ITW_CIE_HAS_API_LEVEL_SUCCESS", "ITW_CIE_HAS_API_LEVEL_FAILURE" )(); -export const hasNFCFeature = createAsyncAction( +export const itwHasNFCFeature = createAsyncAction( "ITW_CIE_HAS_NFC_FEATURE_REQUEST", "ITW_CIE_HAS_NFC_FEATURE_SUCCESS", "ITW_CIE_HAS_NFC_FEATURE_FAILURE" )(); -export const cieIsSupported = createAsyncAction( +export const itwCieIsSupported = createAsyncAction( "ITW_CIE_IS_SUPPORTED_REQUEST", "ITW_CIE_IS_SUPPORTED_SUCCESS", "ITW_CIE_IS_SUPPORTED_FAILURE" )(); -export const nfcIsEnabled = createAsyncAction( +export const itwNfcIsEnabled = createAsyncAction( "ITW_NFC_IS_ENABLED_REQUEST", "ITW_NFC_IS_ENABLED_SUCCESS", "ITW_NFC_IS_ENABLED_FAILURE" )(); -export const updateReadingState = createAsyncAction( +export const itwUpdateReadingState = createAsyncAction( "ITW_UPDATE_READING_STATE_REQUEST", "ITW_UPDATE_READING_STATE_SUCCESS", "ITW_UPDATE_READING_STATE_FAILURE" )(); -export const loginSuccess = createStandardAction("ITW_LOGIN_SUCCESS")<{ +export const itwLoginSuccess = createStandardAction("ITW_LOGIN_SUCCESS")<{ token: SessionToken; idp: keyof IdpData; }>(); -export const loginFailure = createStandardAction("ITW_LOGIN_FAILURE")<{ +export const itwLoginFailure = createStandardAction("ITW_LOGIN_FAILURE")<{ error: Error; idp: keyof IdpData | undefined; }>(); -export type CieAuthenticationErrorReason = CEvent["event"] | "GENERIC"; +export type ItwCieAuthenticationErrorReason = CEvent["event"] | "GENERIC"; -export type CieAuthenticationErrorPayload = { - reason: CieAuthenticationErrorReason; +export type ItwCieAuthenticationErrorPayload = { + reason: ItwCieAuthenticationErrorReason; cieDescription?: string; }; -export const cieAuthenticationError = createStandardAction( +export const itwCieAuthenticationError = createStandardAction( "ITW_CIE_AUTHENTICATION_ERROR" -)(); +)(); -export type ItwCieAuthenticationActions = - | ActionType - | ActionType - | ActionType - | ActionType - | ActionType - | ActionType - | ActionType - | ActionType; +export type ItwIssuancePidCieAuthActions = + | ActionType + | ActionType + | ActionType + | ActionType + | ActionType + | ActionType + | ActionType + | ActionType; diff --git a/ts/features/it-wallet/store/actions/itwPersistedCredentialsActions.ts b/ts/features/it-wallet/store/actions/itwPersistedCredentialsActions.ts new file mode 100644 index 00000000000..c4800a8443c --- /dev/null +++ b/ts/features/it-wallet/store/actions/itwPersistedCredentialsActions.ts @@ -0,0 +1,16 @@ +import { ActionType, createStandardAction } from "typesafe-actions"; +import { StoredCredential } from "../../utils/itwTypesUtils"; + +/** + * Action to add a credential to the wallet. + */ +export const itwPersistedCredentialsStore = createStandardAction( + "ITW_CREDENTIALS_STORE" +)(); + +/** + * Type for credentials related actions. + */ +export type ItwPersistedCredentialsActions = ActionType< + typeof itwPersistedCredentialsStore +>; diff --git a/ts/features/it-wallet/store/actions/itwPrRemoteCredentialActions.ts b/ts/features/it-wallet/store/actions/itwPrRemoteCredentialActions.ts new file mode 100644 index 00000000000..327eb6d0a25 --- /dev/null +++ b/ts/features/it-wallet/store/actions/itwPrRemoteCredentialActions.ts @@ -0,0 +1,24 @@ +import { ActionType, createAsyncAction } from "typesafe-actions"; +import { ItWalletError } from "../../utils/itwErrorsUtils"; + +/** + * Async action which starts the presentation checks. + */ +export const itwPrRemoteCredentialInit = createAsyncAction( + "ITW_PR_REMOTE_CREDENTIAL_INIT_REQUEST", + "ITW_PR_REMOTE_CREDENTIAL_INIT_SUCCESS", + "ITW_PR_REMOTE_CREDENTIAL_INIT_FAILURE" +)(); + +/** + * Async action which starts the presentation request. + */ +export const itwPrRemoteCredential = createAsyncAction( + "ITW_PR_REMOTE_CREDENTIAL_REQUEST", + "ITW_PR_REMOTE_CREDENTIAL_SUCCESS", + "ITW_PR_REMOTE_CREDENTIAL_FAILURE" +)(); + +export type itwPrRemoteCredentialInit = + | ActionType + | ActionType; diff --git a/ts/features/it-wallet/store/actions/itwPrRemotePidActions.ts b/ts/features/it-wallet/store/actions/itwPrRemotePidActions.ts new file mode 100644 index 00000000000..95482c57245 --- /dev/null +++ b/ts/features/it-wallet/store/actions/itwPrRemotePidActions.ts @@ -0,0 +1,36 @@ +import { ActionType, createAsyncAction } from "typesafe-actions"; +import { ItWalletError } from "../../utils/itwErrorsUtils"; +import { + ItwPrRemotePidInit, + ItwPrRemotePidResult +} from "../reducers/itwPrRemotePidReducer"; + +export type ItwPrRemotePidInitData = { + authReqUrl: string; + clientId: string; +}; + +/** + * ITW RP initialization unsigned DPoP + */ +export const itwPrRemotePidInit = createAsyncAction( + "ITW_PR_REMOTE_PID_INIT_REQUEST", + "ITW_PR_REMOTE_PID_INIT_SUCCESS", + "ITW_PR_REMOTE_PID_INIT_FAILURE" +)(); + +/** + * ITW RP presentation prepare token + */ +export const itwPrRemotePidPresentation = createAsyncAction( + "ITW_PR_REMOTE_PID_PRESENTATION_REQUEST", + "ITW_PR_REMOTE_PID_PRESENTATION_SUCCESS", + "ITW_PR_REMOTE_PID_PRESENTATION_FAILURE" +)(); + +/** + * Type for activation related actions. + */ +export type ItwRpActions = + | ActionType + | ActionType; diff --git a/ts/features/it-wallet/store/actions/itwPresentationActions.ts b/ts/features/it-wallet/store/actions/itwPresentationActions.ts deleted file mode 100644 index 534a8d731a6..00000000000 --- a/ts/features/it-wallet/store/actions/itwPresentationActions.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { ActionType, createAsyncAction } from "typesafe-actions"; -import { ItWalletError } from "../../utils/itwErrorsUtils"; - -/** - * Async action which starts the presentation checks. - */ -export const itwPresentationChecks = createAsyncAction( - "ITW_PRESENTATION_CHECKS_REQUEST", - "ITW_PRESENTATION_CHECKS_SUCCESS", - "ITW_PRESETATION_CHECKS_FAILURE" -)(); - -/** - * Async action which starts the presentation request. - */ -export const itwPresentation = createAsyncAction( - "ITW_PRESENTATION_REQUEST", - "ITW_PRESENTATION_SUCCESS", - "ITW_PRESENTATION_FAILURE" -)(); - -export type ItwPresentationChecks = - | ActionType - | ActionType; diff --git a/ts/features/it-wallet/store/actions/itwRpActions.ts b/ts/features/it-wallet/store/actions/itwRpActions.ts deleted file mode 100644 index 5b704a1d07b..00000000000 --- a/ts/features/it-wallet/store/actions/itwRpActions.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { ActionType, createAsyncAction } from "typesafe-actions"; -import { Trust } from "@pagopa/io-react-native-wallet"; -import { ItWalletError } from "../../utils/itwErrorsUtils"; -import { RequestObject } from "../../utils/types"; -import { RpData } from "../reducers/itwRpInitializationReducer"; - -/** - * ITW RP initialization unsigned DPoP - */ -export const itwRpInitialization = createAsyncAction( - "ITW_RP_INITIALIZATION_REQUEST", - "ITW_RP_INITIALIZATION_SUCCESS", - "ITW_RP_INITIALIZATION_FAILURE" -)< - RpData, - { - requestObject: RequestObject; - entity: Trust.RelyingPartyEntityConfiguration["payload"]["metadata"]; - } & RpData, - ItWalletError ->(); - -/** - * ITW RP presentation prepare token - */ -export const itwRpPresentation = createAsyncAction( - "ITW_RP_PRESENTATION_REQUEST", - "ITW_RP_PRESENTATION_SUCCESS", - "ITW_RP_PRESENTATION_FAILURE" -)(); - -/** - * Type for activation related actions. - */ -export type ItwRpActions = - | ActionType - | ActionType; diff --git a/ts/features/it-wallet/store/reducers/index.ts b/ts/features/it-wallet/store/reducers/index.ts index dd52762bb72..9ed9313581b 100644 --- a/ts/features/it-wallet/store/reducers/index.ts +++ b/ts/features/it-wallet/store/reducers/index.ts @@ -9,29 +9,31 @@ import { } from "redux-persist"; import AsyncStorage from "@react-native-async-storage/async-storage"; import { Action } from "../../../../store/actions/types"; -import createCredentialsKeychain from "../storages/credentialsKeychain"; +import itwCreateCredentialsStorage from "../storages/itwCredentialsStorage"; import { isDevEnv } from "../../../../utils/environment"; -import itwCieReducer, { ItwCieState } from "./itwCieReducer"; -import itwWia, { ItwWIAState } from "./itwWiaReducer"; -import itwCredentials, { ItwCredentialsState } from "./itwCredentialsReducer"; +import itwIssuancePidAuthCieReducer, { + ItwIssuancePidCieAuthState +} from "./itwIssuancePidCieAuthReducer"; +import itwWia, { ItwWiaState } from "./itwWiaReducer"; +import itwCredentials, { + ItwPersistedCredentialsState +} from "./itwPersistedCredentialsReducer"; import itwLifeCycle, { ItwLifecycleState } from "./itwLifecycleReducer"; -import itwPid, { ItwPidState } from "./itwPidReducer"; -import itwRpInitializationReducer, { - ItwRpInitializationState -} from "./itwRpInitializationReducer"; -import itwRpPresentationReducer, { - ItwRpPresentationState -} from "./itwRpPresentationReducer"; -import itwCredentialsChecksReducer, { - ItwCredentialsChecksState -} from "./itwCredentialsChecksReducer"; -import itwPresentationReducer, { - ItwPresentationState -} from "./new/itwPresentationReducer"; -import itwIssuanceReducer, { ItwIssuanceState } from "./new/itwIssuanceReducer"; -import itwProximityReducer, { ItwProximityState } from "./itwProximityReducer"; +import itwPidReducer, { ItwIssuancePidState } from "./itwIssuancePidReducer"; +import itwPrRemotePidReducer, { + ItwPrRemotePidState +} from "./itwPrRemotePidReducer"; +import itwPrRemoteCredentialReducer, { + ItwPrRemoteCredentialState +} from "./itwPrRemoteCredentialReducer"; +import itwIssuanceCredentialReducer, { + ItwIssuanceCredentialState +} from "./itwIssuanceCredentialReducer"; +import itwPrProximityReducer, { + ItwPrProximityState +} from "./itwPrProximityReducer"; -const CURRENT_REDUX_ITW_STORE_VERSION = 3; +const CURRENT_REDUX_ITW_STORE_VERSION = 5; const itwStoreMigration: MigrationManifest = { /** @@ -41,10 +43,18 @@ const itwStoreMigration: MigrationManifest = { /** * Version 3 where we reset the state due to redux state changes. */ - "3": (): PersistedState => undefined as unknown as PersistedState + "3": (): PersistedState => undefined as unknown as PersistedState, + /** + * Version 4 where we reset the state due to redux state changes. + */ + "4": (): PersistedState => undefined as unknown as PersistedState, + /** + * Version 5 where we reset the state due to redux state changes. + */ + "5": (): PersistedState => undefined as unknown as PersistedState }; -const CURRENT_REDUX_ITW_CREDENTIALS_STORE_VERSION = 2; +const CURRENT_REDUX_ITW_CREDENTIALS_STORE_VERSION = 5; const itwCredentialsStoreMigration: MigrationManifest = { /** @@ -52,23 +62,33 @@ const itwCredentialsStoreMigration: MigrationManifest = { */ "2": (): PersistedState => undefined as unknown as PersistedState, /** - * Version 2 where we reset the state due to redux state changes. + * Version 3 where we reset the state due to redux state changes. */ - "3": (): PersistedState => undefined as unknown as PersistedState + "3": (): PersistedState => undefined as unknown as PersistedState, + /** + * Version 4 where we reset the state due to redux state changes. + */ + "4": (): PersistedState => undefined as unknown as PersistedState, + /** + * Version 5 where we reset the state due to redux state changes. + */ + "5": (): PersistedState => undefined as unknown as PersistedState }; export type ItWalletState = { - wia: ItwWIAState; - credentials: ItwCredentialsState & PersistPartial; - credentialsChecks: ItwCredentialsChecksState; - activation: ItwCieState; + /* GENERIC */ lifecycle: ItwLifecycleState; - pid: ItwPidState; - rpInit: ItwRpInitializationState; - rpPresentation: ItwRpPresentationState; - presentation: ItwPresentationState; - issuance: ItwIssuanceState; - proximity: ItwProximityState; + wia: ItwWiaState; + /* ISSUANCE */ + issuancePidCieAuth: ItwIssuancePidCieAuthState; + issuancePid: ItwIssuancePidState; + issuanceCredential: ItwIssuanceCredentialState; + /* PERSISTED CREDENTIALS */ + credentials: ItwPersistedCredentialsState & PersistPartial; + /* PRESENTATION REMOTE */ + prRemotePid: ItwPrRemotePidState; + prRemoteCredential: ItwPrRemoteCredentialState; + prProximity: ItwPrProximityState; }; export type PersistedItWalletState = ItWalletState & PersistPartial; @@ -83,23 +103,25 @@ const persistConfig: PersistConfig = { const credentialsPersistConfig = { key: "credentials", - storage: createCredentialsKeychain(), + storage: itwCreateCredentialsStorage(), version: CURRENT_REDUX_ITW_CREDENTIALS_STORE_VERSION, migrate: createMigrate(itwCredentialsStoreMigration, { debug: isDevEnv }) }; const reducers = combineReducers({ + /* GENERIC */ + lifecycle: itwLifeCycle, wia: itwWia, + /* ISSUANCE */ + issuancePidCieAuth: itwIssuancePidAuthCieReducer, + issuancePid: itwPidReducer, + issuanceCredential: itwIssuanceCredentialReducer, + /* PERSISTED CREDENTIALS */ credentials: persistReducer(credentialsPersistConfig, itwCredentials), - credentialsChecks: itwCredentialsChecksReducer, - activation: itwCieReducer, - lifecycle: itwLifeCycle, - pid: itwPid, - rpInit: itwRpInitializationReducer, - rpPresentation: itwRpPresentationReducer, - presentation: itwPresentationReducer, - issuance: itwIssuanceReducer, - proximity: itwProximityReducer + /* PRESENTATION REMOTE */ + prRemotePid: itwPrRemotePidReducer, + prRemoteCredential: itwPrRemoteCredentialReducer, + prProximity: itwPrProximityReducer }); const itwReducer = persistReducer( diff --git a/ts/features/it-wallet/store/reducers/itwCieReducer.ts b/ts/features/it-wallet/store/reducers/itwCieReducer.ts deleted file mode 100644 index 8554381b2a0..00000000000 --- a/ts/features/it-wallet/store/reducers/itwCieReducer.ts +++ /dev/null @@ -1,112 +0,0 @@ -/** - * A reducer for the authentication by CIE - */ -import * as pot from "@pagopa/ts-commons/lib/pot"; -import { getType } from "typesafe-actions"; - -import { Action } from "../../../../store/actions/types"; -import { GlobalState } from "../../../../store/reducers/types"; -import { - cieIsSupported, - hasApiLevelSupport, - hasNFCFeature, - nfcIsEnabled, - updateReadingState -} from "../actions/itwCieActions"; - -export type ItwCieState = { - hasApiLevelSupport: pot.Pot; - hasNFCFeature: pot.Pot; - isCieSupported: pot.Pot; - isNfcEnabled: pot.Pot; - readingEvent: pot.Pot; -}; - -const INITIAL_STATE: ItwCieState = { - hasApiLevelSupport: pot.none, - hasNFCFeature: pot.none, - isCieSupported: pot.none, - isNfcEnabled: pot.none, - readingEvent: pot.none -}; - -export default function itwCieReducer( - state: ItwCieState = INITIAL_STATE, - action: Action -): ItwCieState { - switch (action.type) { - case getType(cieIsSupported.success): - return { - ...state, - isCieSupported: pot.some(action.payload) - }; - case getType(cieIsSupported.failure): - return { - ...state, - isCieSupported: pot.toError(state.isCieSupported, action.payload) - }; - case getType(hasApiLevelSupport.success): - return { - ...state, - hasApiLevelSupport: pot.some(action.payload) - }; - case getType(hasApiLevelSupport.failure): - return { - ...state, - hasApiLevelSupport: pot.toError( - state.hasApiLevelSupport, - action.payload - ) - }; - case getType(hasNFCFeature.success): - return { - ...state, - hasNFCFeature: pot.some(action.payload) - }; - case getType(hasNFCFeature.failure): - return { - ...state, - hasNFCFeature: pot.toError(state.hasNFCFeature, action.payload) - }; - case getType(nfcIsEnabled.success): - return { - ...state, - isNfcEnabled: pot.some(action.payload) - }; - case getType(nfcIsEnabled.failure): - return { - ...state, - isNfcEnabled: pot.toError(state.isNfcEnabled, action.payload) - }; - - case getType(updateReadingState.success): - return { - ...state, - readingEvent: pot.some(action.payload) - }; - case getType(updateReadingState.failure): - return { - ...state, - readingEvent: pot.toError(state.readingEvent, action.payload) - }; - - default: - return state; - } -} - -// Selectors -export const hasNFCFeatureSelector = (state: GlobalState) => - state.features.itWallet.activation.hasNFCFeature; - -export const hasApiLevelSupportSelector = (state: GlobalState) => - state.features.itWallet.activation.hasApiLevelSupport; - -export const isCieSupportedSelector = (state: GlobalState) => - state.features.itWallet.activation.isCieSupported; - -export const isNfcEnabledSelector = (state: GlobalState) => - state.features.itWallet.activation.isNfcEnabled; - -export const readingEventSelector = (state: GlobalState) => - state.features.itWallet.activation.readingEvent; diff --git a/ts/features/it-wallet/store/reducers/itwCredentialsChecksReducer.ts b/ts/features/it-wallet/store/reducers/itwCredentialsChecksReducer.ts deleted file mode 100644 index 196577f8d7f..00000000000 --- a/ts/features/it-wallet/store/reducers/itwCredentialsChecksReducer.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { getType } from "typesafe-actions"; -import * as pot from "@pagopa/ts-commons/lib/pot"; -import * as O from "fp-ts/lib/Option"; -import { Action } from "../../../../store/actions/types"; -import { GlobalState } from "../../../../store/reducers/types"; -import { itwCredentialsChecks } from "../actions/itwCredentialsActions"; -import { ItWalletError } from "../../utils/itwErrorsUtils"; -import { CredentialCatalogAvailableItem } from "../../utils/mocks"; - -export type ItwCredentialsChecksState = pot.Pot< - O.Option, - ItWalletError ->; - -const emptyState: ItwCredentialsChecksState = pot.none; - -/** - * This reducer handles the checks state before adding a new credentials. - * Currently it handles a mocked credential. - * A saga is attached to the itwCredentialsChecks action which handles the required checks. - * @param state the current state - * @param action the dispatched action - * @returns the result state - */ -const reducer = ( - state: ItwCredentialsChecksState = emptyState, - action: Action -): ItwCredentialsChecksState => { - switch (action.type) { - case getType(itwCredentialsChecks.request): - return pot.toLoading(state); - case getType(itwCredentialsChecks.success): - return pot.some(O.some(action.payload)); - case getType(itwCredentialsChecks.failure): - return pot.toError(state, action.payload); - } - return state; -}; - -/** - * Selects the credentials state of the wallet. - * @param state - the global state - * @returns the credentials pot state of the wallet. - */ -export const ItwCredentialsChecksSelector = (state: GlobalState) => - state.features.itWallet.credentialsChecks; - -/** - * Selects the checked credential which is going to be added to the wallet. - * @param state - the global state - * @returns an Option containing the checked credential. - */ -export const ItwCredentialsCheckCredentialSelector = (state: GlobalState) => - pot.getOrElse(state.features.itWallet.credentialsChecks, O.none); - -export default reducer; diff --git a/ts/features/it-wallet/store/reducers/itwCredentialsReducer.ts b/ts/features/it-wallet/store/reducers/itwCredentialsReducer.ts deleted file mode 100644 index 475b1794d94..00000000000 --- a/ts/features/it-wallet/store/reducers/itwCredentialsReducer.ts +++ /dev/null @@ -1,112 +0,0 @@ -import { getType } from "typesafe-actions"; -import * as O from "fp-ts/lib/Option"; - -import * as pot from "@pagopa/ts-commons/lib/pot"; -import { Action } from "../../../../store/actions/types"; -import { GlobalState } from "../../../../store/reducers/types"; -import { - itwCredentialsAddCredential, - itwCredentialsAddPid -} from "../actions/itwCredentialsActions"; -import { ItWalletError } from "../../utils/itwErrorsUtils"; -import { StoredCredential } from "../../utils/types"; -import { itwLifecycleOperational } from "../actions/itwLifecycleActions"; - -/** - * The type of credentials stored in the wallet. - * The PID is a particular credential which is stored separately. - */ -type ItwCredentialsType = { - pid: O.Option; - credentials: Array>; -}; - -export type ItwCredentialsState = pot.Pot; - -const emptyState: ItwCredentialsState = pot.none; - -/** - * This reducer handles the credentials state. - * Currently it only handles adding the PID to the wallet. - * A saga is attached to the itwCredentialsAddPid action which handles the PID issuing. - * @param state the current state - * @param action the dispatched action - * @returns the result state - */ -const reducer = ( - state: ItwCredentialsState = emptyState, - action: Action -): ItwCredentialsState => { - switch (action.type) { - /** - * PID related actions, will be merged with generic credentials in the future. - */ - case getType(itwCredentialsAddPid.request): - return pot.toLoading(state); - case getType(itwCredentialsAddPid.success): - return pot.some({ credentials: [], pid: O.some(action.payload) }); // credentials is always empty when adding a PID - case getType(itwCredentialsAddPid.failure): - return pot.toError(state, action.payload); - /** - * Credentials related actions. - */ - case getType(itwCredentialsAddCredential.success): - return pot.some({ - pid: pot.getOrElse( - pot.map(state, credentials => credentials.pid), - O.none // TODO: this should never happen, but we should handle it - ), - credentials: [ - ...pot.getOrElse( - pot.map(state, credentials => credentials.credentials), - [] - ), - O.some(action.payload) - ] - }); - /** - * Reset the state when the wallet is operational. - */ - case getType(itwLifecycleOperational): - return emptyState; - } - return state; -}; - -/** - * Selects the credentials state of the wallet. - * @param state - the global state - * @returns the credentials pot state of the wallet. - */ -export const ItwCredentialsStateSelector = (state: GlobalState) => - state.features.itWallet.credentials; - -/** - * Selects the PID stored in the wallet. - * @param state - the global state - * @returns the PID from the wallet. - */ -export const itwCredentialsPidSelector = (state: GlobalState) => - pot.getOrElse( - pot.map( - state.features.itWallet.credentials, - credentials => credentials.pid - ), - O.none - ); - -/** - * Selects the credentials stored in the wallet. - * @param state - the global state - * @returns the credentials array from the wallet or an empty array if the pot is empty. - */ -export const itwCredentialsSelector = (state: GlobalState) => - pot.getOrElse( - pot.map( - state.features.itWallet.credentials, - credentials => credentials.credentials - ), - [] - ); - -export default reducer; diff --git a/ts/features/it-wallet/store/reducers/itwIssuanceCredentialReducer.ts b/ts/features/it-wallet/store/reducers/itwIssuanceCredentialReducer.ts new file mode 100644 index 00000000000..9ba61d79813 --- /dev/null +++ b/ts/features/it-wallet/store/reducers/itwIssuanceCredentialReducer.ts @@ -0,0 +1,121 @@ +import * as pot from "@pagopa/ts-commons/lib/pot"; +import * as O from "fp-ts/lib/Option"; +import { getType } from "typesafe-actions"; +import { Action } from "../../../../store/actions/types"; +import { GlobalState } from "../../../../store/reducers/types"; +import { ItWalletError } from "../../utils/itwErrorsUtils"; +import { + itwIssuanceCredentialChecks, + itwIssuanceCredential +} from "../actions/itwIssuanceCredentialActions"; +import { CredentialCatalogDisplay } from "../../utils/itwMocksUtils"; +import { + CredentialConfigurationSchema, + CredentialDefinition, + IssuerConfiguration, + StoredCredential +} from "../../utils/itwTypesUtils"; + +export type ItwIssuanceCredentialData = { + credentialType: string; + issuerUrl: string; + displayData: CredentialCatalogDisplay; + credentialConfigurationSchema: CredentialConfigurationSchema; + issuerConf: IssuerConfiguration; +} & CredentialDefinition; + +/** + * Type of the state managed by the reducer for the issuance flow. + */ +export type ItwIssuanceCredentialState = { + /** + * Preliminary checks pot. + */ + checks: pot.Pot, ItWalletError>; + /** + * Issuance result pot. + */ + result: pot.Pot, ItWalletError>; +}; + +/** + * Empty state constant which sets the initial state of the reducer. + */ +const EMPTY_STATE: ItwIssuanceCredentialState = { + checks: pot.none, + result: pot.none +}; + +const reducer = ( + state: ItwIssuanceCredentialState = EMPTY_STATE, + action: Action +): ItwIssuanceCredentialState => { + switch (action.type) { + /** + * Preliminary checks section. + */ + case getType(itwIssuanceCredentialChecks.request): + return { + ...state, + checks: pot.toLoading(state.checks) + }; + case getType(itwIssuanceCredentialChecks.success): + return { + ...state, + checks: pot.some(O.some(action.payload)) + }; + case getType(itwIssuanceCredentialChecks.failure): + return { + ...state, + checks: pot.toError(state.checks, action.payload) + }; + + /** + * Obtain phase + */ + case getType(itwIssuanceCredential.request): + return { + ...state, + result: pot.toLoading(state.result) + }; + case getType(itwIssuanceCredential.success): + return { + ...state, + result: pot.some(O.some(action.payload)) + }; + case getType(itwIssuanceCredential.failure): + return { + ...state, + result: pot.toError(state.result, action.payload) + }; + + default: + return state; + } +}; + +export const itwIssuanceCredentialResultSelector = (state: GlobalState) => + state.features.itWallet.issuanceCredential.result; + +export const itwIssuanceResultDataSelector = (state: GlobalState) => + pot.getOrElse( + pot.map( + state.features.itWallet.issuanceCredential.result, + result => result + ), + O.none + ); + +export const itwIssuanceCredentialChecksSelector = (state: GlobalState) => + state.features.itWallet.issuanceCredential.checks; + +export const itwIssuanceCredentialChecksValueSelector = (state: GlobalState) => + pot.getOrElse( + pot.map( + state.features.itWallet.issuanceCredential.checks, + checks => checks + ), + O.none + ); + +export default reducer; diff --git a/ts/features/it-wallet/store/reducers/itwIssuancePidCieAuthReducer.ts b/ts/features/it-wallet/store/reducers/itwIssuancePidCieAuthReducer.ts new file mode 100644 index 00000000000..cf849ff0d6b --- /dev/null +++ b/ts/features/it-wallet/store/reducers/itwIssuancePidCieAuthReducer.ts @@ -0,0 +1,112 @@ +/** + * A reducer for the authentication by CIE + */ +import * as pot from "@pagopa/ts-commons/lib/pot"; +import { getType } from "typesafe-actions"; + +import { Action } from "../../../../store/actions/types"; +import { GlobalState } from "../../../../store/reducers/types"; +import { + itwCieIsSupported, + itwHasApiLevelSupport, + itwHasNFCFeature, + itwNfcIsEnabled, + itwUpdateReadingState +} from "../actions/itwIssuancePidCieActions"; + +export type ItwIssuancePidCieAuthState = { + itwHasApiLevelSupport: pot.Pot; + itwHasNFCFeature: pot.Pot; + isCieSupported: pot.Pot; + isNfcEnabled: pot.Pot; + readingEvent: pot.Pot; +}; + +const INITIAL_STATE: ItwIssuancePidCieAuthState = { + itwHasApiLevelSupport: pot.none, + itwHasNFCFeature: pot.none, + isCieSupported: pot.none, + isNfcEnabled: pot.none, + readingEvent: pot.none +}; + +export default function itwIssuancePidAuthCieReducer( + state: ItwIssuancePidCieAuthState = INITIAL_STATE, + action: Action +): ItwIssuancePidCieAuthState { + switch (action.type) { + case getType(itwCieIsSupported.success): + return { + ...state, + isCieSupported: pot.some(action.payload) + }; + case getType(itwCieIsSupported.failure): + return { + ...state, + isCieSupported: pot.toError(state.isCieSupported, action.payload) + }; + case getType(itwHasApiLevelSupport.success): + return { + ...state, + itwHasApiLevelSupport: pot.some(action.payload) + }; + case getType(itwHasApiLevelSupport.failure): + return { + ...state, + itwHasApiLevelSupport: pot.toError( + state.itwHasApiLevelSupport, + action.payload + ) + }; + case getType(itwHasNFCFeature.success): + return { + ...state, + itwHasNFCFeature: pot.some(action.payload) + }; + case getType(itwHasNFCFeature.failure): + return { + ...state, + itwHasNFCFeature: pot.toError(state.itwHasNFCFeature, action.payload) + }; + case getType(itwNfcIsEnabled.success): + return { + ...state, + isNfcEnabled: pot.some(action.payload) + }; + case getType(itwNfcIsEnabled.failure): + return { + ...state, + isNfcEnabled: pot.toError(state.isNfcEnabled, action.payload) + }; + + case getType(itwUpdateReadingState.success): + return { + ...state, + readingEvent: pot.some(action.payload) + }; + case getType(itwUpdateReadingState.failure): + return { + ...state, + readingEvent: pot.toError(state.readingEvent, action.payload) + }; + + default: + return state; + } +} + +// Selectors +export const itwHasNFCFeatureSelector = (state: GlobalState) => + state.features.itWallet.issuancePidCieAuth.itwHasNFCFeature; + +export const itwHasApiLevelSupportSelector = (state: GlobalState) => + state.features.itWallet.issuancePidCieAuth.itwHasApiLevelSupport; + +export const itwIsCieSupportedSelector = (state: GlobalState) => + state.features.itWallet.issuancePidCieAuth.isCieSupported; + +export const itwIsNfcEnabledSelector = (state: GlobalState) => + state.features.itWallet.issuancePidCieAuth.isNfcEnabled; + +export const itwReadingEventSelector = (state: GlobalState) => + state.features.itWallet.issuancePidCieAuth.readingEvent; diff --git a/ts/features/it-wallet/store/reducers/itwPidReducer.ts b/ts/features/it-wallet/store/reducers/itwIssuancePidReducer.ts similarity index 63% rename from ts/features/it-wallet/store/reducers/itwPidReducer.ts rename to ts/features/it-wallet/store/reducers/itwIssuancePidReducer.ts index 06e7ac67bae..8a1f1d949ea 100644 --- a/ts/features/it-wallet/store/reducers/itwPidReducer.ts +++ b/ts/features/it-wallet/store/reducers/itwIssuancePidReducer.ts @@ -4,16 +4,16 @@ import * as O from "fp-ts/lib/Option"; import { Action } from "../../../../store/actions/types"; import { ItWalletError } from "../../utils/itwErrorsUtils"; import { GlobalState } from "../../../../store/reducers/types"; -import { itwPid } from "../actions/itwCredentialsActions"; -import { StoredCredential } from "../../utils/types"; +import { StoredCredential } from "../../utils/itwTypesUtils"; +import { itwIssuancePid } from "../actions/itwIssuancePidActions"; -export type ItwPidType = { +type ItwPidIssuance = { pid: O.Option; }; -export type ItwPidState = pot.Pot; +export type ItwIssuancePidState = pot.Pot; -const emptyState: ItwPidState = pot.none; +const emptyState: ItwIssuancePidState = pot.none; /** * This reducer handles the PID issuing state. @@ -24,17 +24,17 @@ const emptyState: ItwPidState = pot.none; * @returns the result state */ const reducer = ( - state: ItwPidState = emptyState, + state: ItwIssuancePidState = emptyState, action: Action -): ItwPidState => { +): ItwIssuancePidState => { switch (action.type) { - case getType(itwPid.request): + case getType(itwIssuancePid.request): return pot.toLoading(state); - case getType(itwPid.success): + case getType(itwIssuancePid.success): return pot.some({ pid: O.some(action.payload) }); - case getType(itwPid.failure): + case getType(itwIssuancePid.failure): return pot.toError(state, action.payload); } return state; @@ -45,17 +45,17 @@ const reducer = ( * @param state - the global state * @returns the PID pot state. */ -export const itwPidSelector = (state: GlobalState) => - state.features.itWallet.pid; +export const itwIssuancePidSelector = (state: GlobalState) => + state.features.itWallet.issuancePid; /** * Selects the PID value from the global state. * @param state - the global state * @returns the pid value. */ -export const itwPidValueSelector = (state: GlobalState) => +export const itwIssuancePidValueSelector = (state: GlobalState) => pot.getOrElse( - pot.map(state.features.itWallet.pid, pid => pid.pid), + pot.map(state.features.itWallet.issuancePid, value => value.pid), O.none ); diff --git a/ts/features/it-wallet/store/reducers/itwPersistedCredentialsReducer.ts b/ts/features/it-wallet/store/reducers/itwPersistedCredentialsReducer.ts new file mode 100644 index 00000000000..9d548256fbf --- /dev/null +++ b/ts/features/it-wallet/store/reducers/itwPersistedCredentialsReducer.ts @@ -0,0 +1,80 @@ +import { getType } from "typesafe-actions"; +import * as O from "fp-ts/lib/Option"; +import { Action } from "../../../../store/actions/types"; +import { GlobalState } from "../../../../store/reducers/types"; +import { itwPersistedCredentialsStore } from "../actions/itwPersistedCredentialsActions"; +import { StoredCredential } from "../../utils/itwTypesUtils"; +import { itwLifecycleOperational } from "../actions/itwLifecycleActions"; +import { CredentialType } from "../../utils/itwMocksUtils"; + +export type ItwPersistedCredentialsState = { + pid: O.Option; + credentials: Array>; +}; + +const emptyState: ItwPersistedCredentialsState = { + pid: O.none, + credentials: [] +}; + +/** + * This reducer handles the credentials state. + * Currently it only handles adding the PID to the wallet. + * A saga is attached to the itwPersistedCredentialsStorePid action which handles the PID issuing. + * @param state the current state + * @param action the dispatched action + * @returns the result state + */ +const reducer = ( + state: ItwPersistedCredentialsState = emptyState, + action: Action +): ItwPersistedCredentialsState => { + switch (action.type) { + case getType(itwPersistedCredentialsStore): + if (action.payload.credentialType === CredentialType.PID) { + return { credentials: [], pid: O.some(action.payload) }; // Reset the credential array when a new PID is added + } else { + if (O.isSome(state.pid)) { + return { + pid: state.pid, + credentials: [...state.credentials, O.some(action.payload)] + }; + } else { + return state; // If the PID is not present, the credential is not added + } + } + + /** + * Reset the state when the wallet is operational. + */ + case getType(itwLifecycleOperational): + return emptyState; + } + return state; +}; + +/** + * Selects the credentials state of the wallet. + * @param state - the global state + * @returns the credentials pot state of the wallet. + */ +export const itwPersistedCredentialsSelector = (state: GlobalState) => + state.features.itWallet.credentials; + +/** + * Selects the PID stored in the wallet. + * @param state - the global state + * @returns the PID from the wallet. + */ +export const itwPersistedCredentialsValuePidSelector = (state: GlobalState) => + state.features.itWallet.credentials.pid; + +/** + * Selects the credentials stored in the wallet. + * @param state - the global state + * @returns the credentials array from the wallet or an empty array if the pot is empty. + */ +export const itwPersistedCredentialsValueSelector = (state: GlobalState) => + state.features.itWallet.credentials.credentials; + +export default reducer; diff --git a/ts/features/it-wallet/store/reducers/itwProximityReducer.ts b/ts/features/it-wallet/store/reducers/itwPrProximityReducer.ts similarity index 72% rename from ts/features/it-wallet/store/reducers/itwProximityReducer.ts rename to ts/features/it-wallet/store/reducers/itwPrProximityReducer.ts index 2ceec410043..e217ac33c89 100644 --- a/ts/features/it-wallet/store/reducers/itwProximityReducer.ts +++ b/ts/features/it-wallet/store/reducers/itwPrProximityReducer.ts @@ -15,7 +15,7 @@ import { } from "../actions/itwProximityActions"; import { ItWalletError } from "../../utils/itwErrorsUtils"; -export type ItwProximityState = { +export type ItwPrProximityState = { hasBLEFeature: pot.Pot; isBleEnabled: pot.Pot; qrCode: pot.Pot; @@ -23,7 +23,7 @@ export type ItwProximityState = { status: pot.Pot; }; -const INITIAL_STATE: ItwProximityState = { +const INITIAL_STATE: ItwPrProximityState = { hasBLEFeature: pot.none, isBleEnabled: pot.none, qrCode: pot.none, @@ -31,10 +31,10 @@ const INITIAL_STATE: ItwProximityState = { status: pot.none }; -export default function itwProximityReducer( - state: ItwProximityState = INITIAL_STATE, +export default function itwPrProximityReducer( + state: ItwPrProximityState = INITIAL_STATE, action: Action -): ItwProximityState { +): ItwPrProximityState { switch (action.type) { case getType(proximityManagerStatus): return { @@ -73,17 +73,17 @@ export default function itwProximityReducer( } // Selectors -export const hasBLEFeatureSelector = (state: GlobalState) => - state.features.itWallet.proximity.hasBLEFeature; +export const itwPrProximityHasBLEFeatureSelector = (state: GlobalState) => + state.features.itWallet.prProximity.hasBLEFeature; -export const proximityStatusSelector = (state: GlobalState) => +export const itwPrProximitySelector = (state: GlobalState) => pot.getOrElse( - pot.map(state.features.itWallet.proximity.status, status => status), + pot.map(state.features.itWallet.prProximity.status, status => status), ProximityManagerStatusEnum.STOPPED ); -export const isBleEnabledSelector = (state: GlobalState) => - state.features.itWallet.proximity.isBleEnabled; +export const itwPrProximityIsBleEnabledSelector = (state: GlobalState) => + state.features.itWallet.prProximity.isBleEnabled; -export const qrcodeSelector = (state: GlobalState) => - state.features.itWallet.proximity.qrCode; +export const itwPrProximityQrCodeSelector = (state: GlobalState) => + state.features.itWallet.prProximity.qrCode; diff --git a/ts/features/it-wallet/store/reducers/itwPrRemoteCredentialReducer.ts b/ts/features/it-wallet/store/reducers/itwPrRemoteCredentialReducer.ts new file mode 100644 index 00000000000..2a75eac1dfc --- /dev/null +++ b/ts/features/it-wallet/store/reducers/itwPrRemoteCredentialReducer.ts @@ -0,0 +1,93 @@ +/** + * A reducer for the authentication by CIE + */ +import * as pot from "@pagopa/ts-commons/lib/pot"; +import { getType } from "typesafe-actions"; +import { Action } from "../../../../store/actions/types"; +import { GlobalState } from "../../../../store/reducers/types"; +import { ItWalletError } from "../../utils/itwErrorsUtils"; +import { + itwPrRemoteCredential, + itwPrRemoteCredentialInit +} from "../actions/itwPrRemoteCredentialActions"; + +/** + * Type of the state managed by the reducer for the presentation flow. + * Currently it only manages the checks required before starting the presentation. + */ +export type ItwPrRemoteCredentialState = { + init: pot.Pot; + result: pot.Pot; +}; + +/** + * Empty state constant which sets the initial state of the reducer. + */ +const EMPTY_STATE: ItwPrRemoteCredentialState = { + init: pot.none, + result: pot.none +}; + +const reducer = ( + state: ItwPrRemoteCredentialState = EMPTY_STATE, + action: Action +): ItwPrRemoteCredentialState => { + switch (action.type) { + /** + * Presentation checks section. + */ + case getType(itwPrRemoteCredentialInit.request): + return { + ...state, + init: pot.toLoading(state.init) + }; + case getType(itwPrRemoteCredentialInit.success): + return { + ...state, + init: pot.some(true) + }; + case getType(itwPrRemoteCredentialInit.failure): + return { + ...state, + init: pot.toError(state.init, action.payload) + }; + /** + * Presentation request section. + */ + case getType(itwPrRemoteCredential.request): + return { + ...state, + result: pot.toLoading(state.result) + }; + case getType(itwPrRemoteCredential.success): + return { + ...state, + result: pot.some(true) + }; + case getType(itwPrRemoteCredential.failure): + return { + ...state, + result: pot.toError(state.result, action.payload) + }; + default: + return state; + } +}; + +/** + * Selector for the presentation init pot state. + * @param state - the global state + * @returns the checks state pot + */ +export const itwPrRemoteCredentialInitSelector = (state: GlobalState) => + state.features.itWallet.prRemoteCredential.init; + +/** + * Selector for the presentation result pot state. + * @param state - the global state + * @returns the checks state pot + */ +export const itwPrRemoteCredentialResultSelector = (state: GlobalState) => + state.features.itWallet.prRemoteCredential.result; + +export default reducer; diff --git a/ts/features/it-wallet/store/reducers/itwPrRemotePidReducer.ts b/ts/features/it-wallet/store/reducers/itwPrRemotePidReducer.ts new file mode 100644 index 00000000000..825fe8c3bbb --- /dev/null +++ b/ts/features/it-wallet/store/reducers/itwPrRemotePidReducer.ts @@ -0,0 +1,120 @@ +import { getType } from "typesafe-actions"; +import * as pot from "@pagopa/ts-commons/lib/pot"; +import * as O from "fp-ts/lib/Option"; +import { Action } from "../../../../store/actions/types"; +import { ItWalletError } from "../../utils/itwErrorsUtils"; +import { GlobalState } from "../../../../store/reducers/types"; +import { + itwPrRemotePidInit, + itwPrRemotePidPresentation +} from "../actions/itwPrRemotePidActions"; +import { + RequestObject, + RpEntityConfiguration +} from "../../utils/itwTypesUtils"; + +/** + * Type for the result of the initialization process. + */ +export type ItwPrRemotePidInit = { + requestObject: RequestObject; + rpEntityConfiguration: RpEntityConfiguration; +}; + +/** + * Type fo the result of the pid presentation process. + */ +export type ItwPrRemotePidResult = { + status: string; + response_code?: string; +}; + +export type ItwPrRemotePidState = { + init: pot.Pot, ItWalletError>; + result: pot.Pot, ItWalletError>; +}; + +const emptyState: ItwPrRemotePidState = { + init: pot.none, + result: pot.none +}; + +/** + * This reducer handles the RP state. + * It manipulates a pot which maps to an error if the RP faced an error. + * A saga is attached to the request action which handles the RP side effects. + * @param state the current state + * @param action the dispatched action + * @returns the result state + */ +const reducer = ( + state: ItwPrRemotePidState = emptyState, + action: Action +): ItwPrRemotePidState => { + switch (action.type) { + /** + * INIT + */ + case getType(itwPrRemotePidInit.request): + return { + init: pot.toLoading(state.init), + result: pot.none + }; + case getType(itwPrRemotePidInit.success): + return { + ...state, + init: pot.some(O.some(action.payload)) + }; + case getType(itwPrRemotePidInit.failure): + return { + ...state, + init: pot.toError(state.init, action.payload) + }; + + /** + * RESULT + */ + case getType(itwPrRemotePidPresentation.request): + return { + ...state, + result: pot.toLoading(state.result) + }; + case getType(itwPrRemotePidPresentation.success): + return { + ...state, + result: pot.some(O.some(action.payload)) + }; + case getType(itwPrRemotePidPresentation.failure): + return { + ...state, + result: pot.toError(state.result, action.payload) + }; + } + return state; +}; + +/** + * Selects the PID remote presentation init pot from the global state. + * @param state - the global state + * @returns a pot representing the init process state + */ +export const itwPrRemotePidInitSelector = (state: GlobalState) => + state.features.itWallet.prRemotePid.init; + +/** + * Selects the PID remote presentation init pot from the global state. + * @param state - the global state + * @returns a pot representing the init process state + */ +export const itwPrRemotePidInitValueSelector = (state: GlobalState) => + pot.getOrElse(state.features.itWallet.prRemotePid.init, O.none); + +/** + * Selects the PID remote presentation result pot from the global state. + * @param state - the global state + * @returns a pot representing the remote presentation result process state + */ +export const itwPrRemotePidResultSelector = (state: GlobalState) => + state.features.itWallet.prRemotePid.result; + +export default reducer; diff --git a/ts/features/it-wallet/store/reducers/itwRpInitializationReducer.ts b/ts/features/it-wallet/store/reducers/itwRpInitializationReducer.ts deleted file mode 100644 index 8b868b7fc22..00000000000 --- a/ts/features/it-wallet/store/reducers/itwRpInitializationReducer.ts +++ /dev/null @@ -1,104 +0,0 @@ -import { getType } from "typesafe-actions"; -import * as pot from "@pagopa/ts-commons/lib/pot"; -import * as O from "fp-ts/lib/Option"; -import { Trust } from "@pagopa/io-react-native-wallet"; -import { Action } from "../../../../store/actions/types"; -import { ItWalletError } from "../../utils/itwErrorsUtils"; -import { GlobalState } from "../../../../store/reducers/types"; -import { itwRpInitialization } from "../actions/itwRpActions"; -import { RequestObject } from "../../utils/types"; - -export type RpData = { - authReqUrl: string; - clientId: string; -}; - -export type ItwRpInitializationType = { - requestObject: O.Option; - entity: O.Option< - Trust.RelyingPartyEntityConfiguration["payload"]["metadata"] - >; - data: O.Option; -}; - -export type ItwRpInitializationState = pot.Pot< - ItwRpInitializationType, - ItWalletError ->; - -const emptyState: ItwRpInitializationState = pot.none; - -/** - * This reducer handles the RP state. - * It manipulates a pot which maps to an error if the RP faced an error. - * A saga is attached to the request action which handles the RP side effects. - * @param state the current state - * @param action the dispatched action - * @returns the result state - */ -const reducer = ( - state: ItwRpInitializationState = emptyState, - action: Action -): ItwRpInitializationState => { - switch (action.type) { - case getType(itwRpInitialization.request): - return pot.toLoading(state); - case getType(itwRpInitialization.success): - return pot.some({ - requestObject: O.some(action.payload.requestObject), - entity: O.some(action.payload.entity), - data: O.some({ - authReqUrl: action.payload.authReqUrl, - clientId: action.payload.clientId - }) - }); - case getType(itwRpInitialization.failure): - return pot.toError(state, action.payload); - } - return state; -}; - -/** - * Selects the RP pod state from the global state. - * @param state - the global state - * @returns the RP pot state. - */ -export const itwRpInitializationSelector = (state: GlobalState) => - state.features.itWallet.rpInit; - -/** - * Selects the RP value from the global state. - * @param state - the global state - * @returns the rp requestObject value. - */ -export const itwRpInitializationRequestObjectValueSelector = ( - state: GlobalState -) => - pot.getOrElse( - pot.map(state.features.itWallet.rpInit, rpInit => rpInit.requestObject), - O.none - ); - -/** - * Selects the RP entity configuration from the global state. - * @param state - the global state - * @returns the rp entity value. - */ -export const itwRpInitializationEntityValueSelector = (state: GlobalState) => - pot.getOrElse( - pot.map(state.features.itWallet.rpInit, rpInit => rpInit.entity), - O.none - ); - -/** - * Selects the RP data configuration from the global state. - * @param state - the global state - * @returns the rp data value which contains the authReqUrl and the clientId. - */ -export const itwRpInitializationDataValueSelector = (state: GlobalState) => - pot.getOrElse( - pot.map(state.features.itWallet.rpInit, rpInit => rpInit.data), - O.none - ); - -export default reducer; diff --git a/ts/features/it-wallet/store/reducers/itwRpPresentationReducer.ts b/ts/features/it-wallet/store/reducers/itwRpPresentationReducer.ts deleted file mode 100644 index 6b16d7a6771..00000000000 --- a/ts/features/it-wallet/store/reducers/itwRpPresentationReducer.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { getType } from "typesafe-actions"; -import * as pot from "@pagopa/ts-commons/lib/pot"; -import * as O from "fp-ts/lib/Option"; -import { Action } from "../../../../store/actions/types"; -import { ItWalletError } from "../../utils/itwErrorsUtils"; -import { GlobalState } from "../../../../store/reducers/types"; -import { itwRpPresentation } from "../actions/itwRpActions"; - -export type ItwRpPresentationType = { - result: O.Option<{ - status: string; - response_code?: string; - }>; -}; - -export type ItwRpPresentationState = pot.Pot< - ItwRpPresentationType, - ItWalletError ->; - -const emptyState: ItwRpPresentationState = pot.none; - -/** - * This reducer handles the RP presentation state. - * It manipulates a pot which maps to an error if the RP faced an error. - * A saga is attached to the request action which handles the RP presentation flow. - * @param state the current state - * @param action the dispatched action - * @returns the result state - */ -const reducer = ( - state: ItwRpPresentationState = emptyState, - action: Action -): ItwRpPresentationState => { - switch (action.type) { - case getType(itwRpPresentation.request): - return pot.toLoading(state); - case getType(itwRpPresentation.success): - return pot.some({ - result: O.some(action.payload) - }); - case getType(itwRpPresentation.failure): - return pot.toError(state, action.payload); - } - return state; -}; - -/** - * Selects the RP presentation pod state from the global state. - * @param state - the global state - * @returns the RP presentation pot state. - */ -export const itwRpPresentationSelector = (state: GlobalState) => - state.features.itWallet.rpPresentation; - -/** - * Selects the RP presentation result value from the global state. - * @param state - the global state - * @returns the RP presentation result string value or a none Option if unavailable. - */ -export const itwRpPresentationResultSelector = (state: GlobalState) => - pot.getOrElse( - pot.map( - state.features.itWallet.rpPresentation, - rpPresentation => rpPresentation.result - ), - O.none - ); - -export default reducer; diff --git a/ts/features/it-wallet/store/reducers/itwWiaReducer.ts b/ts/features/it-wallet/store/reducers/itwWiaReducer.ts index 74c00e7df4b..1d6f0807690 100644 --- a/ts/features/it-wallet/store/reducers/itwWiaReducer.ts +++ b/ts/features/it-wallet/store/reducers/itwWiaReducer.ts @@ -7,9 +7,9 @@ import { ItWalletError } from "../../utils/itwErrorsUtils"; import { itwWiaRequest } from "../actions/itwWiaActions"; import { itwLifecycleOperational } from "../actions/itwLifecycleActions"; -export type ItwWIAState = pot.Pot, ItWalletError>; +export type ItwWiaState = pot.Pot, ItWalletError>; -const emptyState: ItwWIAState = pot.none; +const emptyState: ItwWiaState = pot.none; /** * This reducer handles the WIA issuing state. @@ -20,9 +20,9 @@ const emptyState: ItwWIAState = pot.none; * @returns the result state */ const reducer = ( - state: ItwWIAState = emptyState, + state: ItwWiaState = emptyState, action: Action -): ItwWIAState => { +): ItwWiaState => { switch (action.type) { case getType(itwWiaRequest.request): return pot.toLoading(state); diff --git a/ts/features/it-wallet/store/reducers/new/itwIssuanceReducer.ts b/ts/features/it-wallet/store/reducers/new/itwIssuanceReducer.ts deleted file mode 100644 index b71ac6c883c..00000000000 --- a/ts/features/it-wallet/store/reducers/new/itwIssuanceReducer.ts +++ /dev/null @@ -1,118 +0,0 @@ -import * as pot from "@pagopa/ts-commons/lib/pot"; -import * as O from "fp-ts/lib/Option"; -import { getType } from "typesafe-actions"; -import { Action } from "../../../../../store/actions/types"; -import { GlobalState } from "../../../../../store/reducers/types"; -import { ItWalletError } from "../../../utils/itwErrorsUtils"; -import { - itwIssuanceChecks, - itwIssuanceGetCredential -} from "../../actions/itwIssuanceActions"; -import { CredentialCatalogDisplay } from "../../../utils/mocks"; -import { - CredentialConfigurationSchema, - CredentialDefinition, - IssuerConfiguration, - StoredCredential -} from "../../../utils/types"; - -export type IssuanceData = { - credentialType: string; - issuerUrl: string; - displayData: CredentialCatalogDisplay; - credentialConfigurationSchema: CredentialConfigurationSchema; - issuerConf: IssuerConfiguration; -} & CredentialDefinition; - -/** - * Type of the state managed by the reducer for the issuance flow. - */ -export type ItwIssuanceState = { - /** - * Preliminary checks pot. - */ - checks: pot.Pot, ItWalletError>; - /** - * Issuance result pot. - */ - issuanceResult: pot.Pot, ItWalletError>; -}; - -/** - * Empty state constant which sets the initial state of the reducer. - */ -const EMPTY_STATE: ItwIssuanceState = { - checks: pot.none, - issuanceResult: pot.none -}; - -const reducer = ( - state: ItwIssuanceState = EMPTY_STATE, - action: Action -): ItwIssuanceState => { - switch (action.type) { - /** - * Preliminary checks section. - */ - case getType(itwIssuanceChecks.request): - return { - ...state, - checks: pot.toLoading(state.checks) - }; - case getType(itwIssuanceChecks.success): - return { - ...state, - checks: pot.some(O.some(action.payload)) - }; - case getType(itwIssuanceChecks.failure): - return { - ...state, - checks: pot.toError(state.checks, action.payload) - }; - - /** - * Obtain phase - */ - case getType(itwIssuanceGetCredential.request): - return { - ...state, - issuanceResult: pot.toLoading(state.issuanceResult) - }; - case getType(itwIssuanceGetCredential.success): - return { - ...state, - issuanceResult: pot.some(O.some(action.payload)) - }; - case getType(itwIssuanceGetCredential.failure): - return { - ...state, - issuanceResult: pot.toError(state.issuanceResult, action.payload) - }; - - default: - return state; - } -}; - -export const itwIssuanceResultSelector = (state: GlobalState) => - state.features.itWallet.issuance.issuanceResult; - -export const itwIssuanceResultDataSelector = (state: GlobalState) => - pot.getOrElse( - pot.map( - state.features.itWallet.issuance.issuanceResult, - issuanceResultData => issuanceResultData - ), - O.none - ); - -export const itwIssuanceChecksSelector = (state: GlobalState) => - state.features.itWallet.issuance.checks; - -export const itwIssuanceChecksDataSelector = (state: GlobalState) => - pot.getOrElse( - pot.map(state.features.itWallet.issuance.checks, checks => checks), - O.none - ); - -export default reducer; diff --git a/ts/features/it-wallet/store/reducers/new/itwPresentationReducer.ts b/ts/features/it-wallet/store/reducers/new/itwPresentationReducer.ts deleted file mode 100644 index 57862d95e3b..00000000000 --- a/ts/features/it-wallet/store/reducers/new/itwPresentationReducer.ts +++ /dev/null @@ -1,88 +0,0 @@ -/** - * A reducer for the authentication by CIE - */ -import * as pot from "@pagopa/ts-commons/lib/pot"; -import { getType } from "typesafe-actions"; -import { Action } from "../../../../../store/actions/types"; -import { GlobalState } from "../../../../../store/reducers/types"; -import { ItWalletError } from "../../../utils/itwErrorsUtils"; -import { - itwPresentation, - itwPresentationChecks -} from "../../actions/itwPresentationActions"; - -/** - * Type of the state managed by the reducer for the presentation flow. - * Currently it only manages the checks required before starting the presentation. - */ -export type ItwPresentationState = { - checks: pot.Pot; - presentation: pot.Pot; -}; - -/** - * Empty state constant which sets the initial state of the reducer. - */ -const EMPTY_STATE: ItwPresentationState = { - checks: pot.none, - presentation: pot.none -}; - -const reducer = ( - state: ItwPresentationState = EMPTY_STATE, - action: Action -): ItwPresentationState => { - switch (action.type) { - /** - * Presentation checks section. - */ - case getType(itwPresentationChecks.request): - return { - ...state, - checks: pot.toLoading(state.checks) - }; - case getType(itwPresentationChecks.success): - return { - ...state, - checks: pot.some(true) - }; - case getType(itwPresentationChecks.failure): - return { - ...state, - checks: pot.toError(state.checks, action.payload) - }; - /** - * Presentation request section. - */ - case getType(itwPresentation.request): - return { - ...state, - presentation: pot.toLoading(state.presentation) - }; - case getType(itwPresentation.success): - return { - ...state, - presentation: pot.some(true) - }; - case getType(itwPresentation.failure): - return { - ...state, - presentation: pot.toError(state.presentation, action.payload) - }; - default: - return state; - } -}; - -/** - * Selector for the presentation checks pot state. - * @param state - the global state - * @returns the checks state pot - */ -export const itwPresentationChecksSelector = (state: GlobalState) => - state.features.itWallet.presentation.checks; - -export const itwPresentationResultSelector = (state: GlobalState) => - state.features.itWallet.presentation.presentation; - -export default reducer; diff --git a/ts/features/it-wallet/store/storages/credentialsKeychain.ts b/ts/features/it-wallet/store/storages/itwCredentialsStorage.ts similarity index 94% rename from ts/features/it-wallet/store/storages/credentialsKeychain.ts rename to ts/features/it-wallet/store/storages/itwCredentialsStorage.ts index 404e80795b6..5fdd61fa074 100644 --- a/ts/features/it-wallet/store/storages/credentialsKeychain.ts +++ b/ts/features/it-wallet/store/storages/itwCredentialsStorage.ts @@ -9,7 +9,7 @@ import { Storage } from "redux-persist"; */ const USERNAME = "CREDENTIALS_PERSIST"; -export default function createCredentialsKeychain(): Storage { +export default function itwCreateCredentialsStorage(): Storage { return { getItem: async key => { try { diff --git a/ts/features/it-wallet/utils/alert.ts b/ts/features/it-wallet/utils/itwAlertsUtils.ts similarity index 88% rename from ts/features/it-wallet/utils/alert.ts rename to ts/features/it-wallet/utils/itwAlertsUtils.ts index 19e2000a611..0c149d32206 100644 --- a/ts/features/it-wallet/utils/alert.ts +++ b/ts/features/it-wallet/utils/itwAlertsUtils.ts @@ -5,7 +5,7 @@ import I18n from "../../../i18n"; * Credetes a cancel action confirmation alert. * @param onPress - the callback to be called when the user confirms the action */ -export const showCancelAlert = (onPress: () => void) => { +export const itwShowCancelAlert = (onPress: () => void) => { Alert.alert(I18n.t("features.itWallet.generic.alert.title"), undefined, [ { text: I18n.t("features.itWallet.generic.alert.cancel"), diff --git a/ts/features/it-wallet/utils/itwButtonsUtils.tsx b/ts/features/it-wallet/utils/itwButtonsUtils.tsx deleted file mode 100644 index 749fae5542d..00000000000 --- a/ts/features/it-wallet/utils/itwButtonsUtils.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import I18n from "../../../i18n"; - -export const cancelButtonProps = (onPress: () => void) => ({ - block: true, - light: false, - bordered: true, - onPress, - title: I18n.t("features.itWallet.generic.close") -}); diff --git a/ts/features/it-wallet/utils/cie.ts b/ts/features/it-wallet/utils/itwCieUtils.ts similarity index 70% rename from ts/features/it-wallet/utils/cie.ts rename to ts/features/it-wallet/utils/itwCieUtils.ts index e35f24d3aca..bcdb99cafee 100644 --- a/ts/features/it-wallet/utils/cie.ts +++ b/ts/features/it-wallet/utils/itwCieUtils.ts @@ -15,10 +15,12 @@ const mockLaunchCieID = () => Promise.reject("ops"); const test = Platform.OS !== "android"; -export const isCIEAuthenticationSupported = test +export const itwIsCIEAuthenticationSupported = test ? mockIsCIEAuthenticationSupported : realIsCIEAuthenticationSupported; -export const isNfcEnabled = test ? mockIsNfcEnabled : realIsNfcEnabled; -export const openNFCSettings = test ? mockOpenNfcSettings : realOpenNfcSettings; -export const launchCieID = test ? mockLaunchCieID : realLaunchCieID; +export const itwIsNfcEnabled = test ? mockIsNfcEnabled : realIsNfcEnabled; +export const itwOpenNFCSettings = test + ? mockOpenNfcSettings + : realOpenNfcSettings; +export const itwLaunchCieID = test ? mockLaunchCieID : realLaunchCieID; diff --git a/ts/features/it-wallet/utils/itwClaimsUtils.ts b/ts/features/it-wallet/utils/itwClaimsUtils.ts index df156e43bb1..0b9a418ae04 100644 --- a/ts/features/it-wallet/utils/itwClaimsUtils.ts +++ b/ts/features/it-wallet/utils/itwClaimsUtils.ts @@ -10,8 +10,8 @@ import * as O from "fp-ts/lib/Option"; import * as E from "fp-ts/lib/Either"; import { Locales } from "../../../../locales/locales"; import I18n from "../../../i18n"; -import { ParsedCredential } from "./types"; -import { CredentialCatalogDisplay } from "./mocks"; +import { ParsedCredential } from "./itwTypesUtils"; +import { CredentialCatalogDisplay } from "./itwMocksUtils"; /** * diff --git a/ts/features/it-wallet/utils/itwErrorsUtils.ts b/ts/features/it-wallet/utils/itwErrorsUtils.ts index 423fc19e28c..dc7f53da8b1 100644 --- a/ts/features/it-wallet/utils/itwErrorsUtils.ts +++ b/ts/features/it-wallet/utils/itwErrorsUtils.ts @@ -31,8 +31,8 @@ export type ItwErrorMapping = ( */ export enum ItWalletErrorTypes { NFC_NOT_SUPPORTED = "NFC_NOT_SUPPORTED", - WIA_ISSUING_ERROR = "WIA_ISSUING_ERROR", // not mapped yet, - PID_ISSUING_ERROR = "PID_ISSUING_ERR", // not mapped yet + WIA_ISSUANCE_ERROR = "WIA_ISSUANCE_ERROR", // not mapped yet, + PID_ISSUANCE_ERROR = "PID_ISSUANCE_ERR", // not mapped yet PID_DECODING_ERROR = "PID_DECODING_ERROR", // not mapped yet RP_INITIALIZATION_ERROR = "RP_INITIALIZATION_ERROR", // not mapped yet WALLET_NOT_VALID_ERROR = "WALLET_NOT_VALID_ERROR", // not mapped yet diff --git a/ts/features/it-wallet/utils/mocks.ts b/ts/features/it-wallet/utils/itwMocksUtils.ts similarity index 100% rename from ts/features/it-wallet/utils/mocks.ts rename to ts/features/it-wallet/utils/itwMocksUtils.ts diff --git a/ts/features/it-wallet/saga/itwSagaUtils.ts b/ts/features/it-wallet/utils/itwSagaUtils.ts similarity index 100% rename from ts/features/it-wallet/saga/itwSagaUtils.ts rename to ts/features/it-wallet/utils/itwSagaUtils.ts diff --git a/ts/features/it-wallet/utils/types.ts b/ts/features/it-wallet/utils/itwTypesUtils.ts similarity index 88% rename from ts/features/it-wallet/utils/types.ts rename to ts/features/it-wallet/utils/itwTypesUtils.ts index a8e61c55209..d94f44049b3 100644 --- a/ts/features/it-wallet/utils/types.ts +++ b/ts/features/it-wallet/utils/itwTypesUtils.ts @@ -1,5 +1,5 @@ import { Credential, Trust } from "@pagopa/io-react-native-wallet"; -import { CredentialCatalogDisplay } from "./mocks"; +import { CredentialCatalogDisplay } from "./itwMocksUtils"; /** * Alias type for the return type of the start issuance flow operation. @@ -25,6 +25,12 @@ export type RequestObject = Awaited< ReturnType >["requestObject"]; +/** + * Alias type for the relying party entity configuration. + */ +export type RpEntityConfiguration = + Trust.RelyingPartyEntityConfiguration["payload"]["metadata"]; + /** * Alias for the CredentialConfigurationSchema type. */ diff --git a/ts/features/it-wallet/utils/navigation.ts b/ts/features/it-wallet/utils/navigation.ts deleted file mode 100644 index 6bb05aedc00..00000000000 --- a/ts/features/it-wallet/utils/navigation.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { CommonActions } from "@react-navigation/native"; -import NavigationService from "../../../navigation/NavigationService"; -import ROUTES from "../../../navigation/routes"; - -/** - * Navigates to the ITW home screen without the need of having the correct navigation context. - */ -export const navigateToItWalletHome = () => - NavigationService.dispatchNavigationAction( - CommonActions.navigate(ROUTES.ITWALLET_HOME) - );