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-1945] Disable screenshots and recordings on ITW screens #6595

Merged
merged 11 commits into from
Jan 15, 2025
Merged
6 changes: 6 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2003,6 +2003,8 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- RNScreenshotPrevent (1.2.1):
- React
- RNSentry (6.4.0):
- DoubleConversion
- glog
Expand Down Expand Up @@ -2180,6 +2182,7 @@ DEPENDENCIES:
- RNReactNativeHapticFeedback (from `../node_modules/react-native-haptic-feedback`)
- RNReanimated (from `../node_modules/react-native-reanimated`)
- RNScreens (from `../node_modules/react-native-screens`)
- RNScreenshotPrevent (from `../node_modules/react-native-screenshot-prevent`)
- "RNSentry (from `../node_modules/@sentry/react-native`)"
- RNShare (from `../node_modules/react-native-share`)
- RNStoreReview (from `../node_modules/react-native-store-review`)
Expand Down Expand Up @@ -2429,6 +2432,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-reanimated"
RNScreens:
:path: "../node_modules/react-native-screens"
RNScreenshotPrevent:
:path: "../node_modules/react-native-screenshot-prevent"
RNSentry:
:path: "../node_modules/@sentry/react-native"
RNShare:
Expand Down Expand Up @@ -2556,6 +2561,7 @@ SPEC CHECKSUMS:
RNReactNativeHapticFeedback: 00ba111b82aa266bb3ee1aa576831c2ea9a9dfad
RNReanimated: 26a5a401a5de1c0cf1a3226873825b00ffa85377
RNScreens: 35bb8e81aeccf111baa0ea01a54231390dbbcfd9
RNScreenshotPrevent: 5f8473abaa2db2476561ef8f3704b66491ce7b01
RNSentry: c5075bc124ebc8afa84e037c7fe257053a0b2cda
RNShare: 694e19d7f74ac4c04de3a8af0649e9ccc03bd8b1
RNStoreReview: 613c43e9132998ed41a65946e20c223c91b36464
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@
"react-native-easing-gradient": "^1.1.1",
"react-native-exception-handler": "^2.10.8",
"react-native-fingerprint-scanner": "git+https://github.com/hieuvp/react-native-fingerprint-scanner.git#9cecc0db326471c571553ea85f7c016fee2f803d",
"react-native-flag-secure-android": "^1.0.3",
"react-native-fs": "^2.18.0",
"react-native-gesture-handler": "^2.18.1",
"react-native-haptic-feedback": "^2.3.3",
Expand All @@ -142,6 +141,7 @@
"react-native-safe-area-context": "^4.10.5",
"react-native-screen-brightness": "^2.0.0-alpha",
"react-native-screens": "^3.35.0",
"react-native-screenshot-prevent": "^1.2.1",
"react-native-share": "^10.2.1",
"react-native-splash-screen": "^3.2.0",
"react-native-store-review": "^0.4.3",
Expand Down
3 changes: 1 addition & 2 deletions ts/RootContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
AppState,
AppStateStatus,
NativeEventSubscription,
Platform,
StatusBar
} from "react-native";
import SplashScreen from "react-native-splash-screen";
Expand Down Expand Up @@ -101,7 +100,7 @@ class RootContainer extends React.PureComponent<Props> {
barStyle={"dark-content"}
backgroundColor={customVariables.androidStatusBarColor}
/>
{Platform.OS === "android" && <FlagSecureComponent />}
<FlagSecureComponent />

<IONavigationContainer
routingInstrumentation={this.props.routingInstumentation}
Expand Down
8 changes: 5 additions & 3 deletions ts/components/FlagSecure.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from "react";
import { useEffect } from "react";
import FlagSecure from "react-native-flag-secure-android";
import RNScreenshotPrevent from "react-native-screenshot-prevent";
import { connect } from "react-redux";
import { isAllowedSnapshotCurrentScreen } from "../store/reducers/allowedSnapshotScreens";
import { GlobalState } from "../store/reducers/types";
Expand All @@ -9,17 +9,19 @@ type Props = ReturnType<typeof mapStateToProps>;

/**
*
* Disable screenshots.
* On Android, it enables or disables FLAG_SECURE based on the isAllowedSnapshotCurrentScreen prop.
* On iOS, uses a hidden secure text field as iOS does not expose an API to disable screenshots.
*
* @param props
* @constructor
*/
const FlagSecureComponent: React.FunctionComponent<Props> = props => {
useEffect(() => {
if (props.isAllowedSnapshotCurrentScreen) {
FlagSecure.deactivate();
RNScreenshotPrevent.disableSecureView();
} else {
FlagSecure.activate();
RNScreenshotPrevent.enableSecureView();
}
}, [props.isAllowedSnapshotCurrentScreen]);
return null;
Expand Down
7 changes: 6 additions & 1 deletion ts/store/reducers/allowedSnapshotScreens.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { createSelector } from "reselect";
import { PaymentsOnboardingRoutes } from "../../features/payments/onboarding/navigation/routes";
import { ITW_ROUTES } from "../../features/itwallet/navigation/routes";
import { isDebugModeEnabledSelector } from "./debug";
import { currentRouteSelector } from "./navigation";

export const screenBlackList = new Set([
PaymentsOnboardingRoutes.PAYMENT_ONBOARDING_SELECT_METHOD as string
PaymentsOnboardingRoutes.PAYMENT_ONBOARDING_SELECT_METHOD as string,
ITW_ROUTES.IDENTIFICATION.CIE.PIN_SCREEN,
ITW_ROUTES.ISSUANCE.CREDENTIAL_TRUST_ISSUER,
ITW_ROUTES.ISSUANCE.CREDENTIAL_PREVIEW,
...Object.values(ITW_ROUTES.PRESENTATION)
]);

/**
Expand Down
19 changes: 11 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13686,7 +13686,6 @@ __metadata:
react-native-easing-gradient: ^1.1.1
react-native-exception-handler: ^2.10.8
react-native-fingerprint-scanner: "git+https://github.com/hieuvp/react-native-fingerprint-scanner.git#9cecc0db326471c571553ea85f7c016fee2f803d"
react-native-flag-secure-android: ^1.0.3
react-native-fs: ^2.18.0
react-native-gesture-handler: ^2.18.1
react-native-get-random-values: ^1.11.0
Expand All @@ -13711,6 +13710,7 @@ __metadata:
react-native-safe-area-context: ^4.10.5
react-native-screen-brightness: ^2.0.0-alpha
react-native-screens: ^3.35.0
react-native-screenshot-prevent: ^1.2.1
react-native-share: ^10.2.1
react-native-splash-screen: ^3.2.0
react-native-store-review: ^0.4.3
Expand Down Expand Up @@ -18908,13 +18908,6 @@ __metadata:
languageName: node
linkType: hard

"react-native-flag-secure-android@npm:^1.0.3":
version: 1.0.3
resolution: "react-native-flag-secure-android@npm:1.0.3"
checksum: 1b95bc83a040e924d4b913284b914559891d35b52505acb981c18ad82ea3139e3a48e7f710a6c52f9fe0bf32374b45fb7c3cd9a18a35f2c1b5f61f49c0a4737c
languageName: node
linkType: hard

"react-native-fs@npm:^2.18.0":
version: 2.18.0
resolution: "react-native-fs@npm:2.18.0"
Expand Down Expand Up @@ -19272,6 +19265,16 @@ __metadata:
languageName: node
linkType: hard

"react-native-screenshot-prevent@npm:^1.2.1":
version: 1.2.1
resolution: "react-native-screenshot-prevent@npm:1.2.1"
peerDependencies:
react: "*"
react-native: "*"
checksum: 5563adea419627ce1a066495c7779ffdfa85bdb9c180b47eb25215175a02fc4af402bf24cea684d208ae18651df9396fb545998dd3c566afe67f119ecfa62a4a
languageName: node
linkType: hard

"react-native-share@npm:^10.2.1":
version: 10.2.1
resolution: "react-native-share@npm:10.2.1"
Expand Down
Loading