forked from pagopa/io-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [LLK-49] Add section status banner for unsupported devices (pag…
…opa#4405) ## Short description This PR adds a local status banner that will be visible to users whose devices do not support a **secure** hardware-based encryption key storage. The banner will inform these users that they will not be able to use future versions of IO on those devices. See this [RFC](https://pagopa.atlassian.net/wiki/spaces/IOAPP/pages/642318620/RFC-0003+Banner+in+app+per+notificare+gli+utenti+possessori+di+device+non+supportati) for more insight. | it | en | | - | - | | <img src="https://user-images.githubusercontent.com/16268789/222101528-22b06767-3a24-4074-8604-38ddab1d2a40.PNG" width="150" /> | <img src="https://user-images.githubusercontent.com/16268789/222101699-cc948966-2cd4-4250-b010-bae6a520a9f1.PNG" width="150" /> | ## List of changes proposed in this pull request - ts/components/SectionStatus/index.tsx: exports `InnerSectionComponent` - ts/screens/messages/MessagesHomeScreen.tsx: adds unsupported device banner shown if no key is found. ## How to test - Verify that the banner is not displayed when Lollipop is disabled, regardless of whether a public key is present or not. - Confirm that the banner is not displayed when Lollipop is enabled and a public key is present. - Ensure that the banner is displayed when Lollipop is enabled and a public key is not present. - Ensure that by tapping on the banner you navigate to the link proposed [here](https://pagopa.atlassian.net/browse/LLK-52). --------- Co-authored-by: Cristiano Tofani <[email protected]> Co-authored-by: Mario Perrotta <[email protected]> Co-authored-by: Alessandro Dell'Oste <[email protected]>
- Loading branch information
1 parent
019aa36
commit c61f288
Showing
12 changed files
with
124 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { PublicKey } from "@pagopa/io-react-native-crypto"; | ||
import { pipe } from "fp-ts/lib/function"; | ||
import * as O from "fp-ts/lib/Option"; | ||
import * as TE from "fp-ts/lib/TaskEither"; | ||
import { useEffect, useState } from "react"; | ||
import { useIOSelector } from "../../../store/hooks"; | ||
import { taskGetPublicKey } from "../../../utils/crypto"; | ||
import { lollipopKeyTagSelector } from "../store/reducers/lollipop"; | ||
|
||
type PKReady = { kind: "ready"; publicKey: PublicKey }; | ||
type PKChecking = { kind: "checking" }; | ||
type PKError = { kind: "error"; error: string }; | ||
type PKStatus = PKReady | PKChecking | PKError; | ||
|
||
export const usePublicKeyState = () => { | ||
const [publicKeyState, setPublicKeyState] = useState<PKStatus>({ | ||
kind: "checking" | ||
}); | ||
const keyTag = useIOSelector(lollipopKeyTagSelector); | ||
|
||
const handleError = (error: string) => | ||
setPublicKeyState({ kind: "error", error }); | ||
|
||
useEffect(() => { | ||
pipe( | ||
keyTag, | ||
O.fold( | ||
() => handleError("Missing key tag"), | ||
tag => | ||
pipe( | ||
tag, | ||
taskGetPublicKey, | ||
TE.map(publicKey => | ||
setPublicKeyState({ kind: "ready", publicKey }) | ||
), | ||
TE.mapLeft(e => handleError(e.message)) | ||
)() | ||
) | ||
); | ||
}, [keyTag]); | ||
return publicKeyState; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters