Skip to content

feat(IT-Wallet): [SIW-3855] Enrich credential's metadata with verification claim and Wallet's spec version#7838

Open
mastro993 wants to merge 10 commits intomasterfrom
SIW-3855-flatten-stored-credentials-metadata
Open

feat(IT-Wallet): [SIW-3855] Enrich credential's metadata with verification claim and Wallet's spec version#7838
mastro993 wants to merge 10 commits intomasterfrom
SIW-3855-flatten-stored-credentials-metadata

Conversation

@mastro993
Copy link
Contributor

@mastro993 mastro993 commented Feb 5, 2026

Short description

This PR implements IO-WALLET-RFC-0029 by extending the metadata stored with credentials at the time of issuance.

It adds the parsed verification claim directly to the StoredCredential object during credential issuance, eliminating the need to retrieve and re-parse it on subsequent accesses.

Additionally, it introduces the WALLET_SPEC_VERSION constant to track which wallet specification version was used to obtain each credential. This constant is stored in the StoredCredential object at issuance time and will later be replaced by a value directly obtained from the io-react-native-wallet package for better maintainability.

List of changes proposed in this pull request

This pull request refactors and improves the IT Wallet analytics and credential handling code. The main focus is on simplifying property computation for analytics, improving type safety and consistency, and enhancing credential data structures to support future features. It also removes unused or redundant code and introduces a wallet specification versioning system.

Analytics Property Refactoring and Simplification:

  • Simplified the computation of IT Wallet analytics properties by removing the getWalletStatus and getPIDMixpanelStatus helper functions, replacing them with direct selector usage and a unified mapPIDStatusToMixpanel function for status mapping. This reduces indirection and improves readability. [1] [2] [3] [4]
  • Updated property updaters to use the new approach for determining PID and wallet status, further aligning analytics tracking with the latest state shape.

Credential Data Structure Enhancements:

  • Added a spec_version field and a verification field to the StoredCredential type, ensuring credentials now carry wallet specification versioning and a pre-extracted verification object for easier downstream checks. [1] [2] [3]
  • Introduced a Verification type alias for better type safety and clarity when handling verification objects.

Credential Verification Utilities:

  • Refactored the isItwCredential utility to use the new verification field on credentials, simplifying the logic and improving reliability. Added a new extractVerification utility to consistently extract verification data from credentials based on their format.
  • Updated credential issuance and migration logic to use the new extractVerification utility and to include spec_version. [1] [2] [3]

Theme and UI Hook Improvements:

  • Refactored theme hooks (useThemeColorByCredentialType, useHeaderPropsByCredentialType) to always derive L3 design state from the Redux selector, removing the need to pass this as a parameter, which simplifies their usage and reduces potential for errors. [1] [2]
  • Removed the unused useItwFeaturesEnabled hook, cleaning up the codebase.

Constants and Versioning:

  • Introduced a WALLET_SPEC_VERSION constant to track the current wallet specification version, with a placeholder for future dynamic retrieval.

These changes modernize and streamline how IT Wallet analytics and credential data are handled, setting the stage for more robust analytics and easier future enhancements.

How to test

  • On the master branch, obtain a PID and at least one credential
  • Switch to this PR's branch and verify that all Redux migrations execute successfully without errors: you should have all your credentials in the wallet.
  • Confirm that existing credentials are properly migrated with the new metadata fields
  • Verify all screens and flows (Documenti su IO and IT-Wallet) work correctly with both migrated and newly issued credentials
  • Confirm Mixpanel credential properties are still tracked correctly for all events

@mastro993 mastro993 self-assigned this Feb 5, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

PR Title Validation for conventional commit type

All good! PR title follows the conventional commit type.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

Jira Pull Request Link

This Pull Request refers to Jira issues:

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request implements IO-WALLET-RFC-0029 to extend credential metadata at issuance time. The PR adds the verification claim and spec_version to stored credentials, eliminating the need to re-parse verification data on each access. It also significantly simplifies analytics property computation by removing helper functions and reducing indirection.

Changes:

  • Added spec_version and verification fields to StoredCredential type and included them at credential issuance
  • Refactored isItwCredential to use the pre-extracted verification field instead of parsing it each time
  • Simplified analytics property building by removing getWalletStatus and getPIDMixpanelStatus helper functions in favor of direct selector usage
  • Removed the useItwFeaturesEnabled hook and replaced all usages with direct calls to itwLifecycleIsITWalletValidSelector
  • Updated theme hooks (useThemeColorByCredentialType, useHeaderPropsByCredentialType) to derive L3 state internally

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
ts/features/itwallet/common/utils/itwTypesUtils.ts Added Verification type alias and new spec_version and verification fields to StoredCredential
ts/features/itwallet/common/utils/itwCredentialUtils.ts Added extractVerification utility and refactored isItwCredential to use pre-extracted verification field
ts/features/itwallet/common/utils/itwIssuanceUtils.ts Updated PID issuance to include spec_version and verification in stored credentials
ts/features/itwallet/common/utils/itwCredentialIssuanceUtils.ts Updated general credential issuance to include spec_version and verification
ts/features/itwallet/common/utils/constants.ts Added WALLET_SPEC_VERSION constant (placeholder for future dynamic retrieval)
ts/features/itwallet/common/utils/itwStyleUtils.ts Refactored hooks to derive L3 state internally instead of accepting it as a parameter
ts/features/itwallet/common/hooks/useItwFeaturesEnabled.ts Deleted the hook as it's been replaced by direct selector usage
ts/features/itwallet/credentials/store/reducers/migrations.ts Added migration version 7 to populate spec_version and verification on existing credentials
ts/features/itwallet/credentials/store/reducers/tests/migrations.test.ts Added comprehensive tests for migration version 7 including error handling scenarios
ts/features/itwallet/analytics/properties/basePropertyBuilder.ts Simplified property building by removing helper functions and outdated L3 credential check
ts/features/itwallet/analytics/properties/propertyUpdaters.ts Updated to use direct selector calls and simplified status mapping
ts/features/itwallet/analytics/utils/index.ts Updated mapPIDStatusToMixpanel to handle undefined status
ts/features/itwallet/presentation/details/* Replaced useItwFeaturesEnabled hook calls with direct selector usage
Comments suppressed due to low confidence (1)

ts/features/itwallet/analytics/properties/basePropertyBuilder.ts:84

  • The JSDoc comment mentions "If isItwL3 is true and the credential exists but is not an ITW credential, returns not_available" but this check was removed from the implementation (lines 94-97 were deleted in the diff). The comment should be updated to reflect the actual behavior, which no longer validates whether a credential is an ITW credential.
/**
 * Returns the Mixpanel status for a credential type, considering IT Wallet.
 * - If `isItwL3` is explicitly false, returns `"not_available"`.
 * - If `isItwL3` is true and the credential exists but is not an ITW credential, returns `"not_available"`.
 * - Otherwise, retrieves the credential from the store and maps it to Mixpanel status.
 * - Returns `"not_available"` if the credential is missing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Feb 5, 2026

Codecov Report

❌ Patch coverage is 76.36364% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.51%. Comparing base (9d9b101) to head (5755158).
⚠️ Report is 35 commits behind head on master.

Files with missing lines Patch % Lines
.../itwallet/analytics/properties/propertyUpdaters.ts 0.00% 4 Missing ⚠️
...atures/itwallet/common/utils/itwCredentialUtils.ts 86.36% 3 Missing ⚠️
ts/features/itwallet/common/utils/itwStyleUtils.ts 50.00% 2 Missing ⚠️
...ls/components/ItwPresentationDetailsScreenBase.tsx 0.00% 2 Missing ⚠️
...etails/components/ItwPresentationDetailsHeader.tsx 0.00% 1 Missing ⚠️
.../screens/ItwPresentationCredentialDetailScreen.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7838      +/-   ##
==========================================
- Coverage   60.55%   60.51%   -0.04%     
==========================================
  Files        1934     1947      +13     
  Lines       42667    42999     +332     
  Branches     9861     9938      +77     
==========================================
+ Hits        25838    26022     +184     
- Misses      16752    16888     +136     
- Partials       77       89      +12     
Files with missing lines Coverage Δ
...wallet/analytics/properties/basePropertyBuilder.ts 96.00% <100.00%> (+2.25%) ⬆️
ts/features/itwallet/analytics/utils/index.ts 90.00% <ø> (+10.00%) ⬆️
ts/features/itwallet/common/utils/constants.ts 100.00% <100.00%> (ø)
...twallet/common/utils/itwCredentialIssuanceUtils.ts 11.62% <ø> (ø)
...features/itwallet/common/utils/itwIssuanceUtils.ts 18.86% <ø> (ø)
ts/features/itwallet/common/utils/itwTypesUtils.ts 100.00% <ø> (ø)
.../itwallet/credentials/store/reducers/migrations.ts 95.83% <100.00%> (+0.37%) ⬆️
...tails/components/ItwPresentationCredentialCard.tsx 21.05% <ø> (+1.05%) ⬆️
...etails/components/ItwPresentationDetailsHeader.tsx 26.66% <0.00%> (+1.66%) ⬆️
.../screens/ItwPresentationCredentialDetailScreen.tsx 27.63% <0.00%> (ø)
... and 4 more

... and 101 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4dc9389...5755158. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

const pidStatus = itwCredentialsEidStatusSelector(state);

const ITW_STATUS_V2 = getWalletStatus(state);
const ITW_PID = getPIDMixpanelStatus(state, true);
Copy link
Collaborator

@RiccardoMolinari95 RiccardoMolinari95 Feb 9, 2026

Choose a reason for hiding this comment

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

When only eID is available, ITW_ID_V2 should be mapped, but ITW_PID must stay not_available. After upgrade, V2 props must stop being sent to preserve their last value. getPIDMixpanelStatus was used for that.

Image Image

Copy link
Contributor Author

@mastro993 mastro993 Feb 10, 2026

Choose a reason for hiding this comment

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

I've updated the functions. Could you check and verify if they are ok?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Now it works correctly! 💪🏻

* @param credential - The stored credential fields needed to extract verification
* @returns The verification object or undefined if extraction fails
*/
export const extractVerification = ({
Copy link
Collaborator

Choose a reason for hiding this comment

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

The verification claim is going to be simplified in v1.3.3: apparently it will only include trust_framework and assurance_level. Since we are persisting this data now, would it be more future proof to ignore evidence?

Copy link
Contributor Author

@mastro993 mastro993 Feb 10, 2026

Choose a reason for hiding this comment

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

Do you mean by manually removing the evidence claim during the extraction? Do you think ignoring it now might cause problems later?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I would remove evidence: we've never used it and it will be removed soon. I think it's better to consider it as not available since now, so we don't use it and won't need to make it optional in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've dropped evidence from the verification object (5755158).
We just need to make sure to remove this step once we will be on 1.3.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants