Skip to content

Commit

Permalink
fix: [IOPID-1714] IOS crashes on EIC malformed URLs (#5660)
Browse files Browse the repository at this point in the history
## Short description
> [!Warning]
> This PR depends on pagopa/io-cie-sdk#51

> [!Important]
> The misleading copy on the error page under the NFC Session Manager is
not a subject of this PR.

> [!Tip]
> Translations ✅


This PR update the `io-cie-sdk` library to handle malformed responses to
avoid crashes on iOS devices in those use cases.

<details><summary>demo</summary>
<p>

| Generic error on iOS NFC Session Manager Alert |
| - |
| <video
src="https://github.com/pagopa/io-app/assets/16268789/22d3ba0b-d1a4-46c9-aeaf-9eac1f7cdd5c"
/> |

</p>
</details> 

## List of changes proposed in this pull request
- Fix UI regression in `LoadingSpinnerOverlay`.
- Add a generic error message in case of malformed URLs.

## How to test
Run the app in production with a real iOS device and try to login with
EIC several times. No crash'd happen.

---------

Co-authored-by: mariateresaventura <[email protected]>
Co-authored-by: Mario Perrotta <[email protected]>
  • Loading branch information
3 people authored Apr 4, 2024
1 parent 94271fc commit 9c640a4
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 53 deletions.
1 change: 1 addition & 0 deletions locales/en/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,7 @@ authentication:
cardLocked: CIE card locked
wrongPin1AttemptLeft: Wrong PIN, you still have 1 attempt
wrongPin2AttemptLeft: Wrong PIN, you still have 2 attempts
genericError: Something went wrong! Please try again.
error:
readerCardLostTitle: Hold the card again for a few seconds
readerCardLostTitleiOS: You removed the card too soon.
Expand Down
1 change: 1 addition & 0 deletions locales/it/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,7 @@ authentication:
cardLocked: Carta CIE bloccata
wrongPin1AttemptLeft: PIN errato, hai ancora 1 tentativo
wrongPin2AttemptLeft: PIN errato, hai ancora 2 tentativi
genericError: Si è verificato un errore imprevisto. Riprova.
error:
readerCardLostTitle: Avvicina nuovamente la carta
readerCardLostTitleiOS: Hai rimosso la carta troppo presto
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"@pagopa/io-react-native-http-client": "^0.1.3",
"@pagopa/io-react-native-login-utils": "^1.0.0",
"@pagopa/io-react-native-zendesk": "^0.3.29",
"@pagopa/react-native-cie": "1.2.0",
"@pagopa/react-native-cie": "^1.2.1",
"@pagopa/ts-commons": "^10.15.0",
"@react-native-async-storage/async-storage": "^1.17.10",
"@react-native-camera-roll/camera-roll": "5.6.1",
Expand Down
78 changes: 31 additions & 47 deletions ts/components/LoadingSpinnerOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import {
hexToRgba
} from "@pagopa/io-app-design-system";
import I18n from "../i18n";
import { useIOSelector } from "../store/hooks";
import { isDesignSystemEnabledSelector } from "../store/reducers/persistedPreferences";
import ButtonDefaultOpacity from "./ButtonDefaultOpacity";
import { Overlay } from "./ui/Overlay";
import { IOStyles } from "./core/variables/IOStyles";
import { Body } from "./core/typography/Body";
Expand Down Expand Up @@ -37,50 +34,37 @@ const LoadingSpinnerOverlay = ({
loadingCaption,
loadingOpacity = 0.7,
onCancel
}: Props) => {
const isDesignSystemEnabled = useIOSelector(isDesignSystemEnabledSelector);
return (
<Overlay
backgroundColor={hexToRgba(IOColors.white, loadingOpacity)}
foreground={
isLoading && (
<BoxedRefreshIndicator
caption={
<View style={styles.textCaption}>
<Body accessible={true} style={{ textAlign: "center" }}>
{loadingCaption || I18n.t("global.remoteStates.wait")}
</Body>
}: Props) => (
<Overlay
backgroundColor={hexToRgba(IOColors.white, loadingOpacity)}
foreground={
isLoading && (
<BoxedRefreshIndicator
caption={
<View style={styles.textCaption}>
<Body accessible={true} style={{ textAlign: "center" }}>
{loadingCaption || I18n.t("global.remoteStates.wait")}
</Body>
</View>
}
action={
onCancel && (
<View style={IOStyles.selfCenter}>
<ButtonOutline
accessibilityLabel={I18n.t("global.buttons.cancel")}
onPress={onCancel}
testID="loadingSpinnerOverlayCancelButton"
label={I18n.t("global.buttons.cancel")}
/>
</View>
}
action={
onCancel && (
<View style={IOStyles.selfCenter}>
{isDesignSystemEnabled ? (
<ButtonOutline
accessibilityLabel={I18n.t("global.buttons.cancel")}
onPress={onCancel}
testID="loadingSpinnerOverlayCancelButton"
label={I18n.t("global.buttons.cancel")}
/>
) : (
<ButtonDefaultOpacity
onPress={onCancel}
cancel={true}
testID={"loadingSpinnerOverlayCancelButton"}
>
<Body>{I18n.t("global.buttons.cancel")}</Body>
</ButtonDefaultOpacity>
)}
</View>
)
}
/>
)
}
>
{children}
</Overlay>
);
};
)
}
/>
)
}
>
{children}
</Overlay>
);

export default LoadingSpinnerOverlay;
3 changes: 2 additions & 1 deletion ts/screens/authentication/cie/CieCardReaderScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,8 @@ class CieCardReaderScreen extends React.PureComponent<Props, State> {
),
wrongPin2AttemptLeft: I18n.t(
"authentication.cie.card.iosAlert.wrongPin2AttemptLeft"
)
),
genericError: I18n.t("authentication.cie.card.iosAlert.genericError")
})
.then(async () => {
await cieManager.startListeningNFC();
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3343,10 +3343,10 @@
write-yaml-file "^4.1.3"
yargs "^15.0.1"

"@pagopa/[email protected].0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@pagopa/react-native-cie/-/react-native-cie-1.2.0.tgz#7c664e810dfb4ea4e86c2a1a9e7c92ce481781a2"
integrity sha512-Dge9dKfsyqNvdc6cn/kEKoAGRQtvsVkO7zNz/oK/CgBGnw9V0h0A1PlogjvN1gsFpGMVuCOC3UiZocxMK95/0A==
"@pagopa/react-native-cie@^1.2.1":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@pagopa/react-native-cie/-/react-native-cie-1.2.1.tgz#f38ca7c714c4943da839d232a4c076cc78f0d833"
integrity sha512-6v5DAzy5aTTBag+1idSyClTWRBhZ66kPoh5WXGxZsbKQQSolWhcTyl7pmWDeVG69UnkhIuy8ggXLGQnkrfOSOw==

"@pagopa/ts-commons@^10.15.0":
version "10.15.0"
Expand Down

0 comments on commit 9c640a4

Please sign in to comment.