Skip to content

Commit

Permalink
feat: reissuing eid
Browse files Browse the repository at this point in the history
  • Loading branch information
RiccardoMolinari95 committed Dec 23, 2024
1 parent 0b7f0e0 commit aa53709
Show file tree
Hide file tree
Showing 16 changed files with 226 additions and 26 deletions.
8 changes: 8 additions & 0 deletions locales/en/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3475,6 +3475,7 @@ features:
valid: L'ultima verifica è del {{date}}.
expiring: Verifica la tua identità entro il {{date}}.
expired: È necessario un rapido passaggio di verifica per continuare a usare Documenti su IO.
action: Inizia
MDL:
expiring:
title: "Patente su IO: documento in scadenza"
Expand Down Expand Up @@ -3528,6 +3529,13 @@ features:
openPdf: "Show document"
shareButton: Save or share
fiscalCode: Your Fiscal Code
eid:
verificationExpired:
title: Verifica la tua identità
contentStart: "È un passaggio di sicurezza necessario per continuare ad usare "
contentBold: Documenti su IO
contentEnd: "."
primaryAction: Inizia
trustmark:
cta: Mostra certificato di autenticità
description: Mostra il QR Code per attestare l’autenticità del documento quando ti viene richiesto.
Expand Down
8 changes: 8 additions & 0 deletions locales/it/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3475,6 +3475,7 @@ features:
valid: L'ultima verifica è del {{date}}.
expiring: Verifica la tua identità entro il {{date}}.
expired: È necessario un rapido passaggio di verifica per continuare a usare Documenti su IO.
action: Inizia
MDL:
expiring:
title: "Patente su IO: documento in scadenza"
Expand Down Expand Up @@ -3528,6 +3529,13 @@ features:
openPdf: "Mostra documento"
shareButton: Salva o condividi
fiscalCode: Il tuo Codice Fiscale
eid:
verificationExpired:
title: Verifica la tua identità
contentStart: "È un passaggio di sicurezza necessario per continuare ad usare "
contentBold: Documenti su IO
contentEnd: "."
primaryAction: Inizia
trustmark:
cta: Mostra certificato di autenticità
description: Mostra il QR Code per attestare l’autenticità del documento quando ti viene richiesto.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const ItwEidInfoBottomSheetContent = ({
</React.Fragment>
))}
</View>
<ItwEidLifecycleAlert />
<ItwEidLifecycleAlert navigation={navigation} />
<IOMarkdown
content={I18n.t(
"features.itWallet.presentation.bottomSheets.eidInfo.contentBottom"
Expand Down
23 changes: 20 additions & 3 deletions ts/features/itwallet/common/components/ItwEidLifecycleAlert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
ItwJwtCredentialStatus,
StoredCredential
} from "../utils/itwTypesUtils";
import { useIONavigation } from "../../../../navigation/params/AppParamsList";
import { ITW_ROUTES } from "../../navigation/routes";

const defaultLifecycleStatus: Array<ItwJwtCredentialStatus> = [
"valid",
Expand All @@ -27,17 +29,28 @@ type Props = {
* The eID statuses that will render the alert.
*/
lifecycleStatus?: Array<ItwJwtCredentialStatus>;
navigation: ReturnType<typeof useIONavigation>;
};

/**
* This component renders an alert that displays information on the eID status.
*/
export const ItwEidLifecycleAlert = ({
lifecycleStatus = defaultLifecycleStatus
lifecycleStatus = defaultLifecycleStatus,
navigation
}: Props) => {
const eidOption = useIOSelector(itwCredentialsEidSelector);
const maybeEidStatus = useIOSelector(itwCredentialsEidStatusSelector);

const startEidReissuing = () => {
navigation.navigate(ITW_ROUTES.MAIN, {
screen: ITW_ROUTES.IDENTIFICATION.MODE_SELECTION,
params: {
eidReissuing: true
}
});
};

const Content = ({
eid,
eidStatus
Expand Down Expand Up @@ -73,14 +86,18 @@ export const ItwEidLifecycleAlert = ({
{
date: format(eid.jwt.expiration, "DD-MM-YYYY")
}
)
),
action: I18n.t("features.itWallet.presentation.bottomSheets.eidInfo.alert.action"),
onPress: startEidReissuing
},
jwtExpired: {
testID: "itwEidLifecycleAlertTestID_jwtExpired",
variant: "error",
content: I18n.t(
"features.itWallet.presentation.bottomSheets.eidInfo.alert.expired"
)
),
action: I18n.t("features.itWallet.presentation.bottomSheets.eidInfo.alert.action"),
onPress: startEidReissuing
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ import {
import { itwDisabledIdentificationMethodsSelector } from "../../../../store/reducers/backendStatus/remoteConfig";
import { IOScrollViewWithLargeHeader } from "../../../../components/ui/IOScrollViewWithLargeHeader";
import { isCIEAuthenticationSupportedSelector } from "../../machine/eid/selectors";
import { Route, useRoute } from "@react-navigation/native";
import { ITW_ROUTES } from "../../navigation/routes";

export type ItwIdentificationModeSelectionScreenNavigationParams = {
eidReissuing?: boolean;
} | undefined;

export const ItwIdentificationModeSelectionScreen = () => {
const machineRef = ItwEidIssuanceMachineContext.useActorRef();
Expand Down Expand Up @@ -45,6 +51,25 @@ export const ItwIdentificationModeSelectionScreen = () => {
[isCieAuthenticationSupported]
);

const route =
useRoute<
Route<
typeof ITW_ROUTES.IDENTIFICATION.MODE_SELECTION,
ItwIdentificationModeSelectionScreenNavigationParams
>
>();


const { eidReissuing } = route.params || {};

useFocusEffect(
useCallback(() => {
if (eidReissuing) {
machineRef.send({ type: "start-reissuing" });
}
}, [eidReissuing, machineRef])
);

useFocusEffect(trackItWalletIDMethod);

const handleSpidPress = useCallback(() => {
Expand Down
12 changes: 11 additions & 1 deletion ts/features/itwallet/machine/credential/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,17 @@ export default (
CredentialIssuanceEvents
>) => {
assert(context.credential, "credential is undefined");
store.dispatch(itwCredentialsStore([context.credential]));

let cred = context.credential;

cred = {
...cred,
jwt: {
expiration: '2024-12-22T23:59:59Z',
}
};

store.dispatch(itwCredentialsStore([cred]));
},

flagCredentialAsRequested: ({
Expand Down
10 changes: 9 additions & 1 deletion ts/features/itwallet/machine/eid/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,15 @@ export const createEidIssuanceActionsImplementation = (
context
}: ActionArgs<Context, EidIssuanceEvents, EidIssuanceEvents>) => {
assert(context.eid, "eID is undefined");
store.dispatch(itwCredentialsStore([context.eid]));

let eid = context.eid;
eid = {
...eid,
jwt: {
expiration: '2024-12-22T23:59:59Z',
}
};
store.dispatch(itwCredentialsStore([eid]));
},

requestAssistance: () => {},
Expand Down
4 changes: 3 additions & 1 deletion ts/features/itwallet/machine/eid/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export type Context = {
authenticationContext: AuthenticationContext | undefined;
eid: StoredCredential | undefined;
failure: IssuanceFailure | undefined;
isReissuing: boolean;
};

export const InitialContext: Context = {
Expand All @@ -50,5 +51,6 @@ export const InitialContext: Context = {
identification: undefined,
authenticationContext: undefined,
eid: undefined,
failure: undefined
failure: undefined,
isReissuing: false
};
7 changes: 6 additions & 1 deletion ts/features/itwallet/machine/eid/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ export type ExternalErrorEvent = {
error?: Error;
};

export type StartReissuing = {
type: "start-reissuing";
};

export type EidIssuanceEvents =
| Reset
| Start
Expand All @@ -101,4 +105,5 @@ export type EidIssuanceEvents =
| Abort
| RevokeWalletInstance
| ErrorActorEvent
| ExternalErrorEvent;
| ExternalErrorEvent
| StartReissuing;
50 changes: 39 additions & 11 deletions ts/features/itwallet/machine/eid/machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ export const itwEidIssuanceMachine = setup({
callbackUrl: event.authRedirectUrl
}
};
})
}),
setIsReissuing: assign(({ context }) => ({
...context,
isReissuing: true
})),
},
actors: {
createWalletInstance: fromPromise<string>(notImplemented),
Expand All @@ -92,7 +96,8 @@ export const itwEidIssuanceMachine = setup({
isSessionExpired: notImplemented,
isOperationAborted: notImplemented,
hasValidWalletInstanceAttestation: notImplemented,
isNFCEnabled: ({ context }) => context.cieContext?.isNFCEnabled || false
isNFCEnabled: ({ context }) => context.cieContext?.isNFCEnabled || false,
isReissuing: ({ context }) => context.isReissuing === true
}
}).createMachine({
id: "itwEidIssuanceMachine",
Expand Down Expand Up @@ -121,6 +126,10 @@ export const itwEidIssuanceMachine = setup({
},
"revoke-wallet-instance": {
target: "WalletInstanceRevocation"
},
'start-reissuing': {
target: "UserIdentification",
actions: "setIsReissuing"
}
}
},
Expand Down Expand Up @@ -274,7 +283,15 @@ export const itwEidIssuanceMachine = setup({
target: "CieID"
}
],
back: "#itwEidIssuanceMachine.IpzsPrivacyAcceptance"
back: [
{
guard: "isReissuing",
target: "#itwEidIssuanceMachine.Idle"
},
{
target: "#itwEidIssuanceMachine.IpzsPrivacyAcceptance",
}
]
}
},
CieID: {
Expand Down Expand Up @@ -554,14 +571,25 @@ export const itwEidIssuanceMachine = setup({
},
DisplayingPreview: {
on: {
"add-to-wallet": {
actions: [
"storeEidCredential",
"setWalletInstanceToValid",
"trackWalletInstanceCreation"
],
target: "#itwEidIssuanceMachine.Success"
},
"add-to-wallet": [
{
guard: "isReissuing",
actions: [
"storeEidCredential",
"setWalletInstanceToValid",
"trackWalletInstanceCreation",
"navigateToWallet"
]
},
{
actions: [
"storeEidCredential",
"setWalletInstanceToValid",
"trackWalletInstanceCreation"
],
target: "#itwEidIssuanceMachine.Success"
}
],
close: {
actions: ["closeIssuance"]
}
Expand Down
4 changes: 3 additions & 1 deletion ts/features/itwallet/navigation/ItwParamsList.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ItwIdentificationModeSelectionScreenNavigationParams } from "../identification/screens/ItwIdentificationModeSelectionScreen";
import { ItwCieWrongCiePinScreenNavigationParams } from "../identification/screens/cie/ItwCieWrongCiePinScreen";
import { ItwIssuanceCredentialAsyncContinuationNavigationParams } from "../issuance/screens/ItwIssuanceCredentialAsyncContinuationScreen";
import { ItwPresentationCredentialAttachmentNavigationParams } from "../presentation/screens/ItwPresentationCredentialAttachmentScreen";
Expand All @@ -13,7 +14,7 @@ export type ItwParamsList = {
[ITW_ROUTES.DISCOVERY.IPZS_PRIVACY]: undefined;
[ITW_ROUTES.DISCOVERY.ALREADY_ACTIVE_SCREEN]: undefined;
// IDENTIFICATION
[ITW_ROUTES.IDENTIFICATION.MODE_SELECTION]: undefined;
[ITW_ROUTES.IDENTIFICATION.MODE_SELECTION]: ItwIdentificationModeSelectionScreenNavigationParams;
// IDENTIFICATION SPID
[ITW_ROUTES.IDENTIFICATION.IDP_SELECTION]: undefined;
[ITW_ROUTES.IDENTIFICATION.SPID.LOGIN]: undefined;
Expand Down Expand Up @@ -46,6 +47,7 @@ export type ItwParamsList = {
[ITW_ROUTES.PRESENTATION
.CREDENTIAL_CARD_MODAL]: ItwPresentationCredentialCardModalNavigationParams;
[ITW_ROUTES.PRESENTATION.CREDENTIAL_FISCAL_CODE_MODAL]: undefined;
[ITW_ROUTES.PRESENTATION.EID_VERIFICATION_EXPIRED]: undefined;
// PLAYGROUNDS
[ITW_ROUTES.PLAYGROUNDS]: undefined;
[ITW_ROUTES.IDENTITY_NOT_MATCHING_SCREEN]: undefined;
Expand Down
5 changes: 5 additions & 0 deletions ts/features/itwallet/navigation/ItwStackNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { ItwCredentialTrustmarkScreen } from "../trustmark/screens/ItwCredential
import { ItwAlreadyActiveScreen } from "../discovery/screens/ItwAlreadyActiveScreen";
import { ItwParamsList } from "./ItwParamsList";
import { ITW_ROUTES } from "./routes";
import { ItwPresentationEidVerificationExpiredScreen } from "../presentation/screens/ItwPresentationEidVerificationExpiredScreen";

const Stack = createStackNavigator<ItwParamsList>();

Expand Down Expand Up @@ -225,6 +226,10 @@ const InnerNavigator = () => {
component={ItwLifecycleWalletRevocationScreen}
options={{ headerShown: false, gestureEnabled: false }}
/>
<Stack.Screen
name={ITW_ROUTES.PRESENTATION.EID_VERIFICATION_EXPIRED}
component={ItwPresentationEidVerificationExpiredScreen}
/>
</Stack.Navigator>
);
};
3 changes: 2 additions & 1 deletion ts/features/itwallet/navigation/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export const ITW_ROUTES = {
CREDENTIAL_TRUSTMARK: "ITW_PRESENTATION_CREDENTIAL_TRUSTMARK",
CREDENTIAL_CARD_MODAL: "ITW_PRESENTATION_CREDENTIAL_CARD_MODAL",
CREDENTIAL_FISCAL_CODE_MODAL:
"ITW_PRESENTATION_CREDENTIAL_FISCAL_CODE_MODAL"
"ITW_PRESENTATION_CREDENTIAL_FISCAL_CODE_MODAL",
EID_VERIFICATION_EXPIRED: "ITW_PRESENTATION_EID_VERIFICATION_EXPIRED",
} as const,
PLAYGROUNDS: "ITW_PLAYGROUNDS" as const,
IDENTITY_NOT_MATCHING_SCREEN: "ITW_IDENTITY_NOT_MATCHING_SCREEN" as const,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
} from "../../machine/credential/selectors";
import { ItwCredentialIssuanceMachineContext } from "../../machine/provider";
import { ItwOnboardingModuleCredential } from "../components/ItwOnboardingModuleCredential";
import { ITW_ROUTES } from "../../navigation/routes";

// List of available credentials to show to the user
const availableCredentials = [
Expand Down Expand Up @@ -100,13 +101,22 @@ const ItwCredentialOnboardingSection = () => {

const itwCredentialsTypes = useIOSelector(itwCredentialsTypesSelector);

const isWalletValid = useIOSelector(itwLifecycleIsValidSelector);
const navigation = useIONavigation();

const beginCredentialIssuance = useCallback(
(type: string) => {
machineRef.send({
type: "select-credential",
credentialType: type,
skipNavigation: true
});
if (!isWalletValid) {
navigation.navigate(ITW_ROUTES.MAIN, {
screen: ITW_ROUTES.PRESENTATION.EID_VERIFICATION_EXPIRED
});
} else {
machineRef.send({
type: "select-credential",
credentialType: type,
skipNavigation: true
});
}
},
[machineRef]
);
Expand Down
Loading

0 comments on commit aa53709

Please sign in to comment.