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

chore(IT Wallet): [SIW-1851] Add ephemeral credential Trustmark QR Code #6433

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

mastro993
Copy link
Contributor

@mastro993 mastro993 commented Nov 20, 2024

Short description

This PR introduces a new logic for generating a credential trustmark QR Code along with an updated UI. The logic is implemented using an XState machine, which manages the creation and automatic refresh of the QR Code upon expiration. Before generating the trustmark, the WIA validity is verified, and a new one is fetched if necessary.

List of changes proposed in this pull request

  • Updated io-react-native-wallet version to 0.24.1
  • Added react-native-qrcode-svg package for QR image generation
  • Updated QrCodeImage component:
    • prop value can now be undefined, allowing the display of a placeholder when QR Code is not available
    • added support for passing the QR Code correctionLevel as a prop.
    • used react-native-qrcode-svg instead of rn-qr-generator for generating QR Code images
  • Moved ItwCredentialTrustmark component to ts/features/itwallet/trustmark/components folder
  • Introduced itwTrustmarkUtils.ts in the ts/features/itwallet/common/utils folder, containing functions for obtaining trustmarks using io-react-native-wallet APIs
  • Added new trustmark subfeature:
    • Added ItwCredentialTrustmarkScreen to handle trustmark generation and display
    • Added itwTrustmarkMachine to manage the trustmark QR Code lifecycle, including generation and refresh logic.
  • Removed the generateTrustmarkUrl function from itwCredentialUtils.ts (no longer needed).
  • useMaxBrightness utility refactoring:
    • resolved an issue causing unnecessary rerenders.
    • added the ability to smoothly increase the brightness

How to test

This PR should be tested on iOS and Android.

  1. Navigate to a credential's details screen and click on the "Trustmark" button.
  2. Verify the following:
    • The QR Code is displayed correctly, and the screen brightness is set to maximum.
    • Upon exiting the screen or closing the app, the brightness resets to the previous value.
  3. Simulate a 401 error from the GET /token endpoint using a proxy (e.g., Proxyman):
    • Confirm that the expired session screen is displayed when attempting to view the QR Code.

Preview

Some parts of the following video are censored for privacy reasons

test.mp4

@pagopa-github-bot pagopa-github-bot changed the title [SIW-1851] Add ephemeral credential Trustmark QR Code chore(IT Wallet): [SIW-1851] Add ephemeral credential Trustmark QR Code Nov 20, 2024
@pagopa-github-bot
Copy link
Collaborator

pagopa-github-bot commented Nov 20, 2024

Affected stories

  • ⚙️ SIW-1851: [io-app] Aggiornamento implementazione Trustmark credenziale
    subtask of
    • 🌟 SIW-1826: Come Relying Party vorrei verificare che la credenziale che sto verificando sia valida e autentica

Generated by 🚫 dangerJS against 372c05a

Copy link

codecov bot commented Nov 20, 2024

Codecov Report

Attention: Patch coverage is 32.75862% with 78 lines in your changes missing coverage. Please review.

Project coverage is 47.69%. Comparing base (4f204b4) to head (f0d0c19).
Report is 751 commits behind head on master.

Files with missing lines Patch % Lines
ts/utils/brightness.ts 3.84% 25 Missing ⚠️
ts/features/itwallet/trustmark/machine/actors.ts 6.25% 15 Missing ⚠️
...trustmark/screens/ItwCredentialTrustmarkScreen.tsx 26.66% 11 Missing ⚠️
...et/trustmark/components/ItwCredentialTrustmark.tsx 0.00% 9 Missing ⚠️
ts/features/itwallet/trustmark/machine/actions.ts 12.50% 7 Missing ⚠️
...s/features/itwallet/trustmark/machine/provider.tsx 28.57% 5 Missing ⚠️
ts/features/itwallet/trustmark/machine/machine.ts 75.00% 2 Missing and 1 partial ⚠️
...s/features/itwallet/trustmark/machine/selectors.ts 50.00% 2 Missing ⚠️
ts/features/itwallet/trustmark/machine/guards.ts 75.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6433      +/-   ##
==========================================
- Coverage   48.42%   47.69%   -0.73%     
==========================================
  Files        1488     1618     +130     
  Lines       31617    32365     +748     
  Branches     7669     7463     -206     
==========================================
+ Hits        15311    15438     +127     
- Misses      16238    16873     +635     
+ Partials       68       54      -14     
Files with missing lines Coverage Δ
ts/components/QrCodeImage.tsx 76.92% <100.00%> (ø)
...tures/design-system/core/DSIridescentTrustmark.tsx 33.33% <ø> (ø)
...s/features/itwallet/common/utils/itwClaimsUtils.ts 96.66% <ø> (ø)
...atures/itwallet/common/utils/itwCredentialUtils.ts 88.88% <ø> (ø)
...eatures/itwallet/common/utils/itwTrustmarkUtils.ts 100.00% <100.00%> (ø)
...features/itwallet/navigation/ItwStackNavigator.tsx 36.36% <ø> (ø)
ts/features/itwallet/navigation/routes.ts 100.00% <ø> (ø)
.../screens/ItwPresentationCredentialDetailScreen.tsx 6.45% <ø> (ø)
ts/features/itwallet/trustmark/machine/guards.ts 75.00% <75.00%> (ø)
...s/features/itwallet/trustmark/machine/selectors.ts 50.00% <50.00%> (ø)
... and 7 more

... and 1656 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 48f9aa9...f0d0c19. Read the comment docs.

---- 🚨 Try these New Features:

@mastro993 mastro993 self-assigned this Nov 20, 2024
@mastro993 mastro993 marked this pull request as ready for review November 20, 2024 16:26
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.

2 participants