Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ITWallet): [SIW-1455] Reissuing expired or expiring eID #6580

Merged
merged 67 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
aa53709
feat: reissuing eid
RiccardoMolinari95 Dec 23, 2024
a0f6f55
refactor: prettify
RiccardoMolinari95 Dec 23, 2024
38afaa3
refactor: reintroduced store of real eid and credential and not mocked
RiccardoMolinari95 Dec 23, 2024
503d15d
test: add test eid reissuing
RiccardoMolinari95 Dec 23, 2024
4daa05b
test: add tests for back button in UserIdentification: ModeSelection
RiccardoMolinari95 Dec 23, 2024
903cb6c
refactor: prettify
RiccardoMolinari95 Dec 23, 2024
d9f0a5c
Merge commit '80d7bd563c8810002384c28a4677de923403bbd2' into SIW-1455…
RiccardoMolinari95 Dec 24, 2024
50f94fa
fix lint
RiccardoMolinari95 Dec 24, 2024
1ba545e
chore: check wia before start eid reisuuing flow
RiccardoMolinari95 Jan 3, 2025
c517752
refactor: deleted assignWalletInstanceAttestationToContext action
RiccardoMolinari95 Jan 3, 2025
d12f249
fix: lint
RiccardoMolinari95 Jan 3, 2025
e8d82be
chore:prettify
RiccardoMolinari95 Jan 3, 2025
7f44f95
test: fix
RiccardoMolinari95 Jan 3, 2025
1159e10
Merge branch 'master' into SIW-1455-credential-expiry-and-reissuing
RiccardoMolinari95 Jan 7, 2025
ef32d1f
Merge branch 'master' into SIW-1455-credential-expiry-and-reissuing
RiccardoMolinari95 Jan 8, 2025
2ca518f
refactor: screen props in ItwIdentificationModeSelectionScreen
RiccardoMolinari95 Jan 8, 2025
decb8ab
chore: prettify
RiccardoMolinari95 Jan 8, 2025
b72bffd
chore: deleted console log
RiccardoMolinari95 Jan 8, 2025
95f5372
test: fix ItwIdentificationModeSelectionScreen test
RiccardoMolinari95 Jan 8, 2025
d19bcf8
test: removed unused prop
RiccardoMolinari95 Jan 8, 2025
9cba6a7
Merge branch 'master' into SIW-1455-credential-expiry-and-reissuing
RiccardoMolinari95 Jan 8, 2025
c2d1773
Merge branch 'master' into SIW-1455-credential-expiry-and-reissuing
RiccardoMolinari95 Jan 8, 2025
151e558
Merge commit '7e5ca4a918ec36b82e77837987da34db647bffdf' into SIW-1455…
RiccardoMolinari95 Jan 13, 2025
f856774
Merge branch 'master' into SIW-1455-credential-expiry-and-reissuing
RiccardoMolinari95 Jan 13, 2025
0fb11ee
refactor: delete unnecessary state in eid machine
RiccardoMolinari95 Jan 13, 2025
cefa620
Merge branch 'master' into SIW-1455-credential-expiry-and-reissuing
RiccardoMolinari95 Jan 13, 2025
29346af
Merge branch 'master' into SIW-1455-credential-expiry-and-reissuing
RiccardoMolinari95 Jan 14, 2025
a7793e6
Merge branch 'master' into SIW-1455-credential-expiry-and-reissuing
RiccardoMolinari95 Jan 14, 2025
5ebd8ae
chore: restored state DisplayingPreview as before
RiccardoMolinari95 Jan 14, 2025
16eb065
Merge branch 'master' into SIW-1455-credential-expiry-and-reissuing
RiccardoMolinari95 Jan 14, 2025
46e0c48
Merge branch 'master' into SIW-1455-credential-expiry-and-reissuing
mastro993 Jan 14, 2025
1df9414
Merge branch 'master' into SIW-1455-credential-expiry-and-reissuing
RiccardoMolinari95 Jan 15, 2025
00f772a
chore: guard with and in eid machine WalletInstanceAttestationObtainm…
RiccardoMolinari95 Jan 15, 2025
49df2b3
test: fix
RiccardoMolinari95 Jan 15, 2025
9c2b27f
Merge commit '40f6224246d1e6a352c07180365fc629dd9185ca' into SIW-1455…
RiccardoMolinari95 Jan 15, 2025
cd11cd4
Merge branch 'master' into SIW-1455-credential-expiry-and-reissuing
RiccardoMolinari95 Jan 16, 2025
de96a78
Merge branch 'master' into SIW-1455-credential-expiry-and-reissuing
RiccardoMolinari95 Jan 16, 2025
2ff4904
Merge branch 'master' into SIW-1455-credential-expiry-and-reissuing
RiccardoMolinari95 Jan 16, 2025
65cedbb
Merge branch 'master' into SIW-1455-credential-expiry-and-reissuing
RiccardoMolinari95 Jan 17, 2025
e03b5aa
Merge branch 'master' into SIW-1455-credential-expiry-and-reissuing
RiccardoMolinari95 Jan 17, 2025
ab5b3a5
refactor: add logic in credential machine
RiccardoMolinari95 Jan 17, 2025
e0fa0e0
chore: lint
RiccardoMolinari95 Jan 17, 2025
cbc0c5f
fix: credential machine guard event
RiccardoMolinari95 Jan 17, 2025
1402024
Merge branch 'master' into SIW-1455-credential-expiry-and-reissuing
RiccardoMolinari95 Jan 17, 2025
ffb88a5
fix: lint
RiccardoMolinari95 Jan 17, 2025
6e4397e
fix: prettify
RiccardoMolinari95 Jan 17, 2025
cf51668
refactor: simplify isSkipNavigation
RiccardoMolinari95 Jan 17, 2025
69c0547
Merge branch 'master' into SIW-1455-credential-expiry-and-reissuing
RiccardoMolinari95 Jan 17, 2025
d0d8ec3
Merge branch 'master' into SIW-1455-credential-expiry-and-reissuing
RiccardoMolinari95 Jan 20, 2025
9523d30
fix: tsc:noemit
RiccardoMolinari95 Jan 20, 2025
c84c6df
Merge branch 'master' into SIW-1455-credential-expiry-and-reissuing
mastro993 Jan 20, 2025
0828a30
fix: guards creation function for credential machine
RiccardoMolinari95 Jan 20, 2025
cd81465
Merge branch 'master' into SIW-1455-credential-expiry-and-reissuing
RiccardoMolinari95 Jan 20, 2025
a96bfb4
fix: lint
RiccardoMolinari95 Jan 20, 2025
5a9a8de
fix: prettier
RiccardoMolinari95 Jan 20, 2025
4afe0c1
Merge branch 'master' into SIW-1455-credential-expiry-and-reissuing
RiccardoMolinari95 Jan 21, 2025
596f497
refactor: removed useMemo from ItwPresentationEidVerificationExpiredS…
RiccardoMolinari95 Jan 21, 2025
a0968d9
Merge branch 'master' into SIW-1455-credential-expiry-and-reissuing
RiccardoMolinari95 Jan 21, 2025
1f20e57
Merge branch 'master' into SIW-1455-credential-expiry-and-reissuing
RiccardoMolinari95 Jan 22, 2025
f346f9e
chore: credential issuing with jwt expired/expiring
RiccardoMolinari95 Jan 22, 2025
3cbfb9b
fix: prettify
RiccardoMolinari95 Jan 22, 2025
cf4e464
refactor: isEidExpired guard in credential machine
RiccardoMolinari95 Jan 22, 2025
3ecbe40
Merge commit '8395b5d594ee6c4e40b19e5b3e661cbdecf5674b' into SIW-1455…
RiccardoMolinari95 Jan 22, 2025
f7b2b03
Merge branch 'master' into SIW-1455-credential-expiry-and-reissuing
RiccardoMolinari95 Jan 23, 2025
e9f3acd
fix:lint
RiccardoMolinari95 Jan 23, 2025
00acf26
fix:prettier
RiccardoMolinari95 Jan 23, 2025
8f0ec75
Merge branch 'master' into SIW-1455-credential-expiry-and-reissuing
mastro993 Jan 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions locales/en/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3496,6 +3496,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 @@ -3551,6 +3552,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
statusAttestationUnknown:
title: Non siamo riusciti a caricare {{credentialName}}
content: Chiudi e riapri l'app per riprovare.
Expand Down
8 changes: 8 additions & 0 deletions locales/it/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3496,6 +3496,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 @@ -3551,6 +3552,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
statusAttestationUnknown:
title: Non siamo riusciti a caricare {{credentialName}}
content: Chiudi e riapri l'app per riprovare.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const ItwEidInfoBottomSheetContent = ({
</Fragment>
))}
</View>
<ItwEidLifecycleAlert />
<ItwEidLifecycleAlert navigation={navigation} />
mastro993 marked this conversation as resolved.
Show resolved Hide resolved
<IOMarkdown
content={I18n.t(
"features.itWallet.presentation.bottomSheets.eidInfo.contentBottom"
Expand Down
27 changes: 24 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
mastro993 marked this conversation as resolved.
Show resolved Hide resolved
}: 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,22 @@ 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 @@ -16,9 +16,20 @@ import {
} from "../../analytics";
import { IOScrollViewWithLargeHeader } from "../../../../components/ui/IOScrollViewWithLargeHeader";
import { isCIEAuthenticationSupportedSelector } from "../../machine/eid/selectors";
import { IOStackNavigationRouteProps } from "../../../../navigation/params/AppParamsList";
import { ItwParamsList } from "../../navigation/ItwParamsList";
import { itwDisabledIdentificationMethodsSelector } from "../../common/store/selectors/remoteConfig";

export const ItwIdentificationModeSelectionScreen = () => {
export type ItwIdentificationModeSelectionScreenNavigationParams = {
eidReissuing?: boolean;
};

type ScreenProps = IOStackNavigationRouteProps<
ItwParamsList,
"ITW_IDENTIFICATION_MODE_SELECTION"
>;

export const ItwIdentificationModeSelectionScreen = (params: ScreenProps) => {
const machineRef = ItwEidIssuanceMachineContext.useActorRef();
const isCieAuthenticationSupported = ItwEidIssuanceMachineContext.useSelector(
isCIEAuthenticationSupportedSelector
Expand All @@ -45,6 +56,16 @@ export const ItwIdentificationModeSelectionScreen = () => {
[isCieAuthenticationSupported]
);

const { eidReissuing } = params.route.params;

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

useFocusEffect(trackItWalletIDMethod);

const handleSpidPress = useCallback(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { ItwEidIssuanceMachineContext } from "../../../machine/provider";
import { itwEidIssuanceMachine } from "../../../machine/eid/machine";
import { ItwLifecycleState } from "../../../lifecycle/store/reducers";
import { ToolEnum } from "../../../../../../definitions/content/AssistanceToolConfig";
import { IOStackNavigationProp } from "../../../../../navigation/params/AppParamsList";
import { ItwParamsList } from "../../../navigation/ItwParamsList";

jest.mock("../../../../../config", () => ({
itwEnabled: true
Expand Down Expand Up @@ -127,10 +129,29 @@ describe("ItwIdentificationModeSelectionScreen", () => {
}
});

const mockNavigation = new Proxy(
{},
{
get: _ => jest.fn()
}
) as unknown as IOStackNavigationProp<
ItwParamsList,
"ITW_IDENTIFICATION_MODE_SELECTION"
>;

const route = {
key: "ITW_IDENTIFICATION_MODE_SELECTION",
name: ITW_ROUTES.IDENTIFICATION.MODE_SELECTION,
params: {}
};

return renderScreenWithNavigationStoreContext<GlobalState>(
() => (
<ItwEidIssuanceMachineContext.Provider logic={logic}>
<ItwIdentificationModeSelectionScreen />
<ItwIdentificationModeSelectionScreen
navigation={mockNavigation}
route={route}
/>
</ItwEidIssuanceMachineContext.Provider>
),
ITW_ROUTES.IDENTIFICATION.MODE_SELECTION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ describe("itwCredentialIssuanceMachine", () => {
const isDeferredIssuance = jest.fn();
const hasValidWalletInstanceAttestation = jest.fn();
const isStatusError = jest.fn();
const isSkipNavigation = jest.fn();
const isEidExpired = jest.fn();

const mockedMachine = itwCredentialIssuanceMachine.provide({
actions: {
Expand Down Expand Up @@ -163,13 +165,17 @@ describe("itwCredentialIssuanceMachine", () => {
isSessionExpired,
isDeferredIssuance,
hasValidWalletInstanceAttestation,
isStatusError
isStatusError,
isSkipNavigation,
isEidExpired
}
});

beforeEach(() => {
onInit.mockImplementation(() => ({ walletInstanceAttestation: undefined }));
hasValidWalletInstanceAttestation.mockImplementation(() => false);
isEidExpired.mockImplementation(() => false);
isSkipNavigation.mockImplementation(() => true);
});

afterEach(() => {
Expand Down Expand Up @@ -595,6 +601,7 @@ describe("itwCredentialIssuanceMachine", () => {
actor.start();

await waitFor(() => expect(onInit).toHaveBeenCalledTimes(1));
isSkipNavigation.mockImplementation(() => false);

requestCredential.mockImplementation(() =>
Promise.resolve({
Expand Down
6 changes: 6 additions & 0 deletions ts/features/itwallet/machine/credential/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ export default (
});
},

navigateToEidVerificationExpiredScreen: () => {
navigation.navigate(ITW_ROUTES.MAIN, {
screen: ITW_ROUTES.PRESENTATION.EID_VERIFICATION_EXPIRED
});
},

closeIssuance: () => {
navigation.popToTop();
},
Expand Down
17 changes: 15 additions & 2 deletions ts/features/itwallet/machine/credential/guards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ import { pipe } from "fp-ts/lib/function";
import * as O from "fp-ts/lib/Option";
import { ItwSessionExpiredError } from "../../api/client";
import { isWalletInstanceAttestationValid } from "../../common/utils/itwAttestationUtils";
import { useIOStore } from "../../../../store/hooks";
import { itwCredentialsEidStatusSelector } from "../../credentials/store/selectors";
import { Context } from "./context";
import { CredentialIssuanceEvents } from "./events";
import { CredentialIssuanceFailureType } from "./failure";

export const createCredentialIssuanceGuardsImplementation = () => ({
export const createCredentialIssuanceGuardsImplementation = (
store: ReturnType<typeof useIOStore>
) => ({
isSessionExpired: ({ event }: { event: CredentialIssuanceEvents }) =>
"error" in event && event.error instanceof ItwSessionExpiredError,

Expand All @@ -21,5 +25,14 @@ export const createCredentialIssuanceGuardsImplementation = () => ({
),

isStatusError: ({ context }: { context: Context }) =>
context.failure?.type === CredentialIssuanceFailureType.INVALID_STATUS
context.failure?.type === CredentialIssuanceFailureType.INVALID_STATUS,

isSkipNavigation: ({ event }: { event: CredentialIssuanceEvents }) =>
event.type === "select-credential" && event.skipNavigation === true,

isEidExpired: () => {
const eidStatus = itwCredentialsEidStatusSelector(store.getState());

return eidStatus === "jwtExpired";
}
});
12 changes: 10 additions & 2 deletions ts/features/itwallet/machine/credential/machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const itwCredentialIssuanceMachine = setup({
navigateToCredentialPreviewScreen: notImplemented,
navigateToFailureScreen: notImplemented,
navigateToWallet: notImplemented,
navigateToEidVerificationExpiredScreen: notImplemented,
closeIssuance: notImplemented,
storeWalletInstanceAttestation: notImplemented,
storeCredential: notImplemented,
Expand Down Expand Up @@ -58,7 +59,9 @@ export const itwCredentialIssuanceMachine = setup({
isSessionExpired: notImplemented,
isDeferredIssuance: notImplemented,
hasValidWalletInstanceAttestation: notImplemented,
isStatusError: notImplemented
isStatusError: notImplemented,
isEidExpired: notImplemented,
isSkipNavigation: notImplemented
}
}).createMachine({
id: "itwCredentialIssuanceMachine",
Expand All @@ -72,7 +75,12 @@ export const itwCredentialIssuanceMachine = setup({
on: {
"select-credential": [
{
guard: ({ event }) => event.skipNavigation === true,
guard: "isEidExpired",
actions: "navigateToEidVerificationExpiredScreen",
target: "Idle"
},
{
guard: "isSkipNavigation",
target: "CheckingWalletInstanceAttestation",
actions: [
assign(({ event }) => ({
Expand Down
Loading
Loading