Skip to content
7 changes: 0 additions & 7 deletions locales/it/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -5140,13 +5140,6 @@
"action": "Inizia"
}
},
"authSource": {
"anis": "ANIS - Anagrafe Nazionale dell'istruzione superiore",
"mdi": "Ministero dell'Interno",
"mef": "MEF - Ragioneria Generale dello Stato",
"inps": "Istituto Nazionale di Previdenza Sociale",
"mit": "MIT - Direzione Generale per la Motorizzazione"
},
"bottomSheets": {
"eidInfo": {
"title": "Documenti su IO:\nidentità verificata",
Expand Down
30 changes: 19 additions & 11 deletions ts/features/itwallet/common/components/ItwIssuanceMetadata.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import { Divider, ListItemInfo } from "@pagopa/io-app-design-system";
import { useMemo } from "react";
import I18n from "i18next";
import { useItwInfoBottomSheet } from "../hooks/useItwInfoBottomSheet";
import { StoredCredential } from "../utils/itwTypesUtils";
import { useMemo } from "react";
import { useIOSelector } from "../../../../store/hooks";
import { generateDynamicUrlSelector } from "../../../../store/reducers/backendStatus/remoteConfig";
import { ITW_IPZS_PRIVACY_URL_BODY } from "../../../../urls";
import {
getMixPanelCredential,
trackWalletCredentialShowAuthSource,
trackWalletCredentialShowIssuer
} from "../../analytics";
import { ITW_IPZS_PRIVACY_URL_BODY } from "../../../../urls";
import { useIOSelector } from "../../../../store/hooks";
import { generateDynamicUrlSelector } from "../../../../store/reducers/backendStatus/remoteConfig";
import { getAuthSource, getItwAuthSource } from "../utils/itwMetadataUtils.ts";
import { itwCredentialsCatalogueByTypesSelector } from "../../credentialsCatalogue/store/selectors/index.ts";
import { itwLifecycleIsITWalletValidSelector } from "../../lifecycle/store/selectors";
import { useItwInfoBottomSheet } from "../hooks/useItwInfoBottomSheet";
import { isItwCredential } from "../utils/itwCredentialUtils.ts";
import { getAuthSource, getItwAuthSource } from "../utils/itwMetadataUtils.ts";
import { CredentialType } from "../utils/itwMocksUtils";
import { itwLifecycleIsITWalletValidSelector } from "../../lifecycle/store/selectors";
import { StoredCredential } from "../utils/itwTypesUtils";

type ItwIssuanceMetadataProps = {
credential: StoredCredential;
Expand Down Expand Up @@ -101,9 +102,16 @@ export const ItwIssuanceMetadata = ({
credential.credentialType,
isItwL3
);
const authSource = itwCredential
? getItwAuthSource(credential)
: getAuthSource(credential);

const credentialsFromCatalogue = useIOSelector(
itwCredentialsCatalogueByTypesSelector
);

const authSource =
itwCredential && credentialsFromCatalogue
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think this is correct. Currently itwCredential is true for credentials obtained with L3, so SPID/CieID L2 users won't see the auth source. It should be sufficient to check if the credential type is in the catalogue, or fallback to the old method.

? getItwAuthSource(credentialsFromCatalogue[credential.credentialType])
: getAuthSource(credential);

const releasedByKey =
itwCredential && credential.credentialType === CredentialType.PID
? "releasedByPid"
Expand Down
46 changes: 8 additions & 38 deletions ts/features/itwallet/common/utils/itwMetadataUtils.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,15 @@
import I18n from "i18next";
import { pipe } from "fp-ts/function";
import * as O from "fp-ts/Option";
import { CredentialType } from "./itwMocksUtils.ts";
import { StoredCredential } from "./itwTypesUtils.ts";
import { DigitalCredentialMetadata } from "./itwCredentialsCatalogueUtils.ts";

/**
* Mapping of credential types to their respective authentication sources.
* This is temporary until we wait the implementation of the VCT/Credential catalog
* Add more mappings as needed.
*/
const ItwCredentialAuthSource: {
[type: string]: string;
} = {
[CredentialType.EUROPEAN_HEALTH_INSURANCE_CARD]: I18n.t(
"features.itWallet.presentation.authSource.mef"
),
[CredentialType.EUROPEAN_DISABILITY_CARD]: I18n.t(
"features.itWallet.presentation.authSource.inps"
),
[CredentialType.DRIVING_LICENSE]: I18n.t(
"features.itWallet.presentation.authSource.mit"
),
[CredentialType.EDUCATION_DEGREE]: I18n.t(
"features.itWallet.presentation.authSource.anis"
),
[CredentialType.EDUCATION_ENROLLMENT]: I18n.t(
"features.itWallet.presentation.authSource.anis"
),
[CredentialType.RESIDENCY]: I18n.t(
"features.itWallet.presentation.authSource.mdi"
)
};

/**
* Get the authentication source for a given credential based on its type.
* This is temporary until we wait the implementation of the VCT/Credential catalog
* @param credential - The credential to get the authentication source for.
*/
export const getItwAuthSource = (
credential: StoredCredential
): string | undefined => ItwCredentialAuthSource[credential.credentialType];
export const getItwAuthSource = (credential: DigitalCredentialMetadata) =>
pipe(
credential.authentic_sources?.[0],
O.fromNullable,
O.map(source => source.organization_name),
O.toUndefined
);

/**
* Get the authentication source for a given credential based on its configuration.
Expand Down
39 changes: 36 additions & 3 deletions ts/features/itwallet/common/utils/itwMocksUtils.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import dc from "../../__mocks__/dc.json";
import eid from "../../__mocks__/eid.json";
import mdl from "../../__mocks__/mdl.json";
import mdlL3 from "../../__mocks__/L3/mdlL3.json";
import tsL3 from "../../__mocks__/L3/tsL3.json";
import dcL3 from "../../__mocks__/L3/dcL3.json";
import edL3 from "../../__mocks__/L3/edL3.json";
import eeL3 from "../../__mocks__/L3/eeL3.json";
import mdlL3 from "../../__mocks__/L3/mdlL3.json";
import resL3 from "../../__mocks__/L3/resL3.json";
import tsL3 from "../../__mocks__/L3/tsL3.json";
import mdl from "../../__mocks__/mdl.json";
import statusAssertion from "../../__mocks__/statusAssertion.json";
import ts from "../../__mocks__/ts.json";
import { DigitalCredentialMetadata } from "./itwCredentialsCatalogueUtils";
import { ParsedStatusAssertion, StoredCredential } from "./itwTypesUtils";

export const ISSUER_MOCK_NAME = "Istituto Poligrafico e Zecca dello Stato";
Expand Down Expand Up @@ -46,3 +47,35 @@ export const ItwStoredCredentialsMocks = {
export const ItwStatusAssertionMocks = {
mdl: statusAssertion as ParsedStatusAssertion
};

export const ItwCredentialFromCatalogueMocks: DigitalCredentialMetadata = {
name: "Tessera Sanitaria Digitale",
description:
"Versione Digitale della Tessera Sanitaria - Tessera europea di assicurazione malattia",
claims: [],
purposes: [],
version: "1.0",
credential_type: "EuropeanHealthInsuranceCard",
legal_type: "pub-eaa",
validity_info: {
max_validity_days: 365,
status_methods: [],
allowed_states: []
},
authentication: {
user_auth_required: true,
min_loa: "high",
supported_eid_schemes: ["it_wallet"]
},
issuers: [],
authentic_sources: [
{
organization_name: "MEF - Ragioneria Generale dello Stato",
organization_code: "m_ef",
id: "https://www.rgs.mef.gov.it",
organization_country: "IT",
source_type: "public"
}
],
formats: []
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe("ItwCredentialPreviewClaimsList", () => {

function renderComponent() {
const globalState = appReducer(undefined, applicationChangeState("active"));

return renderScreenWithNavigationStoreContext<GlobalState>(
() => (
<ItwCredentialPreviewClaimsList data={ItwStoredCredentialsMocks.ts} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe("ItwPresentationClaimsSection", () => {

function renderComponent() {
const globalState = appReducer(undefined, applicationChangeState("active"));

return renderScreenWithNavigationStoreContext<GlobalState>(
() => (
<ItwPresentationClaimsSection
Expand Down
Loading