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

feat(IT Wallet): [SIW-1972] Remote presentation same device #6689

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d73f30d
feat: scan qr code for remote presentation
RiccardoMolinari95 Jan 31, 2025
b2da4d3
Merge branch 'master' into SIW-1960-scan-qr-code-remote-presentation
RiccardoMolinari95 Jan 31, 2025
fc799a5
chore: add missing locales
RiccardoMolinari95 Jan 31, 2025
624a3d8
chore: updated regex for itw_remote barcode
RiccardoMolinari95 Jan 31, 2025
786f4f3
Merge branch 'master' into SIW-1960-scan-qr-code-remote-presentation
RiccardoMolinari95 Jan 31, 2025
196a756
fix: prettify
RiccardoMolinari95 Jan 31, 2025
f28f1c2
chore: improvement itw remote qr code decoding
RiccardoMolinari95 Feb 3, 2025
7a96824
Merge branch 'master' into SIW-1960-scan-qr-code-remote-presentation
RiccardoMolinari95 Feb 3, 2025
1728d91
chore: fix import
RiccardoMolinari95 Feb 3, 2025
2452726
refactor: change qrCodePayload in remoteRequestPayload
RiccardoMolinari95 Feb 3, 2025
e76db18
Merge branch 'master' into SIW-1960-scan-qr-code-remote-presentation
RiccardoMolinari95 Feb 3, 2025
3ffe18f
Merge branch 'master' into SIW-1960-scan-qr-code-remote-presentation
RiccardoMolinari95 Feb 4, 2025
b2316b4
Merge branch 'master' into SIW-1960-scan-qr-code-remote-presentation
RiccardoMolinari95 Feb 5, 2025
b08c736
feat: remote presentation same device
RiccardoMolinari95 Feb 5, 2025
bb3467e
Merge branch 'master' into SIW-1960-scan-qr-code-remote-presentation
RiccardoMolinari95 Feb 5, 2025
376cdb7
Merge commit 'bb3467edda126575d6972dfd11080f9abb192be6' into SIW-1972…
RiccardoMolinari95 Feb 5, 2025
37e3c03
Merge remote-tracking branch 'origin/master' into SIW-1972-remote-pre…
RiccardoMolinari95 Feb 10, 2025
1118a71
chore: removed ItwEidClaimsSelectionScreen
RiccardoMolinari95 Feb 10, 2025
08153e0
chore: deep link remote presentation
RiccardoMolinari95 Feb 10, 2025
8f446a6
chore: handle remote payload deeplinks
mastro993 Feb 12, 2025
23f5b22
Merge remote-tracking branch 'origin/master' into SIW-1972-remote-pre…
RiccardoMolinari95 Feb 12, 2025
1cb60d7
fix: tsc:noemit
RiccardoMolinari95 Feb 12, 2025
efdd2e8
chore: added action to navigate in claims disclosure screen, fix test
RiccardoMolinari95 Feb 12, 2025
e61472f
test: add test for ItwRemoteRequestValidationScreen
RiccardoMolinari95 Feb 12, 2025
4dfea5b
chore: prettify
RiccardoMolinari95 Feb 12, 2025
52aa476
test: fix test
RiccardoMolinari95 Feb 12, 2025
4928f9f
refactor: change state name in remote presentation machine
RiccardoMolinari95 Feb 13, 2025
90be309
Merge branch 'master' into SIW-1972-remote-presentation-same-device
RiccardoMolinari95 Feb 13, 2025
f2a0a91
chore: add more paylod validation for qr code and deep link in remote…
RiccardoMolinari95 Feb 13, 2025
4ff90e5
Merge remote-tracking branch 'origin/master' into SIW-1972-remote-pre…
RiccardoMolinari95 Feb 13, 2025
4eaccb7
chore: deleted unused type
RiccardoMolinari95 Feb 13, 2025
205eea3
test: fix
RiccardoMolinari95 Feb 13, 2025
91ffd03
chore: navigateToClaimsDisclosureScreen uses navigation replace
RiccardoMolinari95 Feb 14, 2025
edc51dd
chore: change decoder for itw remote
RiccardoMolinari95 Feb 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions ts/features/barcode/screens/BarcodeScanScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ import { useHardwareBackButton } from "../../../hooks/useHardwareBackButton";
import { usePagoPaPayment } from "../../payments/checkout/hooks/usePagoPaPayment";
import { FCI_ROUTES } from "../../fci/navigation/routes";
import { paymentAnalyticsDataSelector } from "../../payments/history/store/selectors";
import { ITW_REMOTE_ROUTES } from "../../itwallet/presentation/remote/navigation/routes.ts";
import { isIdPayLocallyEnabledSelector } from "../../../store/reducers/persistedPreferences.ts";
import { ITW_REMOTE_ROUTES } from "../../itwallet/presentation/remote/navigation/routes.ts";

const BarcodeScanScreen = () => {
const navigation = useNavigation<IOStackNavigationProp<AppParamsList>>();
Expand Down Expand Up @@ -156,10 +156,8 @@ const BarcodeScanScreen = () => {
break;
case "ITW_REMOTE":
navigation.navigate(ITW_REMOTE_ROUTES.MAIN, {
screen: ITW_REMOTE_ROUTES.CLAIMS_DISCLOSURE,
params: {
itwRemoteRequestPayload: barcode.itwRemoteRequestPayload
}
screen: ITW_REMOTE_ROUTES.REQUEST_VALIDATION,
params: barcode.itwRemoteRequestPayload
});
break;
}
Expand Down
12 changes: 6 additions & 6 deletions ts/features/barcode/types/__tests__/decoders.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ describe("test decodeIOBarcode function", () => {
O.some({
type: "ITW_REMOTE",
itwRemoteRequestPayload: {
clientId: "abc123xy",
requestUri: "https://example.com/callback",
client_id: "abc123xy",
request_uri: "https://example.com/callback",
state: "hyqizm592",
requestUriMethod: "GET"
request_uri_method: "GET"
}
})
);
Expand All @@ -117,10 +117,10 @@ describe("test decodeIOBarcode function", () => {
O.some({
type: "ITW_REMOTE",
itwRemoteRequestPayload: {
clientId: "abc123xy",
requestUri: "https://example.com/callback",
client_id: "abc123xy",
request_uri: "https://example.com/callback",
state: "hyqizm592",
requestUriMethod: "POST"
request_uri_method: "POST"
}
})
);
Expand Down
29 changes: 10 additions & 19 deletions ts/features/barcode/types/decoders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ import * as A from "fp-ts/lib/Array";
import * as E from "fp-ts/lib/Either";
import * as O from "fp-ts/lib/Option";
import { pipe } from "fp-ts/lib/function";
import { sequenceS } from "fp-ts/lib/Apply";
import { decodePosteDataMatrix } from "../../../utils/payment";
import { SignatureRequestDetailView } from "../../../../definitions/fci/SignatureRequestDetailView";
import { decodePosteDataMatrix } from "../../../utils/payment";
import { ItwRemoteRequestPayload } from "../../itwallet/presentation/remote/Utils/itwRemoteTypeUtils.ts";
import { getUrlParam } from "../../itwallet/common/utils/itwUrlUtils.ts";
import { IOBarcodeType } from "./IOBarcode";

// Discriminated barcode type
Expand Down Expand Up @@ -119,25 +117,18 @@ const decodeItwRemoteBarcode: IOBarcodeDecoderFn = (data: string) =>
O.fromNullable(
data.match(/^https:\/\/continua\.io\.pagopa\.it\/itw\/auth\?(.*)$/)
),
O.chain(([url]) =>
sequenceS(O.Monad)({
clientId: getUrlParam(url, "client_id"),
requestUri: getUrlParam(url, "request_uri"),
state: getUrlParam(url, "state"),
requestUriMethod: pipe(
getUrlParam(url, "request_uri_method"),
O.alt(() => O.some("GET"))
)
O.map(match => new URLSearchParams(match[1])),
O.chainEitherK(params =>
ItwRemoteRequestPayload.decode({
client_id: params.get("client_id"),
request_uri: params.get("request_uri"),
state: params.get("state"),
request_uri_method: params.get("request_uri_method") ?? "GET"
})
),
O.map(({ clientId, requestUri, state, requestUriMethod }) => ({
O.map(itwRemoteRequestPayload => ({
type: "ITW_REMOTE",
itwRemoteRequestPayload: {
clientId,
requestUri,
state,
requestUriMethod
}
itwRemoteRequestPayload
}))
);

Expand Down
9 changes: 9 additions & 0 deletions ts/features/itwallet/navigation/useItwLinkingOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { AppParamsList } from "../../../navigation/params/AppParamsList";
import { useIOSelector } from "../../../store/hooks";
import { isItwEnabledSelector } from "../common/store/selectors/remoteConfig";
import { itwLifecycleIsValidSelector } from "../lifecycle/store/selectors";
import { ITW_REMOTE_ROUTES } from "../presentation/remote/navigation/routes.ts";
import { ITW_ROUTES } from "./routes";

/**
Expand Down Expand Up @@ -30,6 +31,14 @@ export const useItwLinkingOptions = (): PathConfigMap<AppParamsList> => {
}
})
}
},
[ITW_REMOTE_ROUTES.MAIN]: {
path: "itw/auth",
screens: {
[ITW_REMOTE_ROUTES.REQUEST_VALIDATION]: {
path: ""
}
}
}
};
};
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import * as t from "io-ts";
import { NonEmptyString } from "@pagopa/ts-commons/lib/strings";

// TODO: This will be imported from io-react-native-wallet, when the type will be available
// Remote presentation QR code data
export type ItwRemoteRequestPayload = {
clientId: string;
requestUri: string;
state: string;
requestUriMethod?: string;
};
export const ItwRemoteRequestPayload = t.intersection([
t.type({
client_id: NonEmptyString,
request_uri: NonEmptyString,
state: NonEmptyString
}),
t.partial({
request_uri_method: t.union([t.string, t.null, t.undefined])
})
]);

export type ItwRemoteRequestPayload = t.TypeOf<typeof ItwRemoteRequestPayload>;
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import _ from "lodash";
import { StateFrom, createActor } from "xstate";
import { ItwRemoteMachine, itwRemoteMachine } from "../machine.ts";
import { ItwRemoteRequestPayload } from "../../Utils/itwRemoteTypeUtils.ts";

const T_CLIENT_ID = "clientId";
const T_REQUEST_URI = "https://example.com";
Expand All @@ -12,6 +13,7 @@ describe("itwRemoteMachine", () => {
const navigateToDiscoveryScreen = jest.fn();
const navigateToWallet = jest.fn();
const navigateToFailureScreen = jest.fn();
const navigateToClaimsDisclosureScreen = jest.fn();
const closeIssuance = jest.fn();

const isWalletActive = jest.fn();
Expand All @@ -21,6 +23,7 @@ describe("itwRemoteMachine", () => {
navigateToDiscoveryScreen,
navigateToWallet,
navigateToFailureScreen,
navigateToClaimsDisclosureScreen,
closeIssuance
},
actors: {},
Expand Down Expand Up @@ -49,10 +52,10 @@ describe("itwRemoteMachine", () => {
actor.send({
type: "start",
payload: {
clientId: T_CLIENT_ID,
requestUri: T_REQUEST_URI,
client_id: T_CLIENT_ID,
request_uri: T_REQUEST_URI,
state: T_STATE
}
} as ItwRemoteRequestPayload
});

expect(actor.getSnapshot().value).toStrictEqual("Failure");
Expand All @@ -67,10 +70,10 @@ describe("itwRemoteMachine", () => {
value: "Failure",
context: {
payload: {
clientId: T_CLIENT_ID,
requestUri: T_REQUEST_URI,
client_id: T_CLIENT_ID,
request_uri: T_REQUEST_URI,
state: T_STATE
}
} as ItwRemoteRequestPayload
}
} as MachineSnapshot);

Expand All @@ -91,10 +94,10 @@ describe("itwRemoteMachine", () => {
value: "Failure",
context: {
payload: {
clientId: T_CLIENT_ID,
requestUri: T_REQUEST_URI,
client_id: T_CLIENT_ID,
request_uri: T_REQUEST_URI,
state: T_STATE
}
} as ItwRemoteRequestPayload
}
} as MachineSnapshot);

Expand All @@ -116,12 +119,13 @@ describe("itwRemoteMachine", () => {
actor.send({
type: "start",
payload: {
clientId: T_CLIENT_ID,
requestUri: T_REQUEST_URI,
client_id: T_CLIENT_ID,
request_uri: T_REQUEST_URI,
state: T_STATE
}
} as ItwRemoteRequestPayload
});

expect(navigateToClaimsDisclosureScreen).toHaveBeenCalledTimes(1);
expect(actor.getSnapshot().value).toStrictEqual("ClaimsDisclosure");
});
});
6 changes: 6 additions & 0 deletions ts/features/itwallet/presentation/remote/machine/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ export const createRemoteActionsImplementation = (
});
},

navigateToClaimsDisclosureScreen: () => {
navigation.replace(ITW_REMOTE_ROUTES.MAIN, {
screen: ITW_REMOTE_ROUTES.CLAIMS_DISCLOSURE
});
},

closeIssuance: () => {
navigation.popToTop();
}
Expand Down
11 changes: 6 additions & 5 deletions ts/features/itwallet/presentation/remote/machine/machine.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { assign, not, setup } from "xstate";
import { ItwTags } from "../../../machine/tags";
import { InitialContext, Context } from "./context";
import { mapEventToFailure, RemoteFailureType } from "./failure";
import { RemoteEvents } from "./events";
Expand All @@ -18,6 +17,7 @@ export const itwRemoteMachine = setup({
navigateToFailureScreen: notImplemented,
navigateToDiscoveryScreen: notImplemented,
navigateToWallet: notImplemented,
navigateToClaimsDisclosureScreen: notImplemented,
closeIssuance: notImplemented
},
actors: {},
Expand All @@ -38,13 +38,13 @@ export const itwRemoteMachine = setup({
actions: assign(({ event }) => ({
payload: event.payload
})),
target: "PayloadValidation"
target: "PreliminaryChecks"
}
}
},
PayloadValidation: {
description: "Validating the remote request payload before proceeding",
tags: [ItwTags.Loading],
PreliminaryChecks: {
description:
"Perform preliminary checks on the wallet and necessary conditions before proceeding",
always: [
{
guard: not("isWalletActive"),
Expand All @@ -62,6 +62,7 @@ export const itwRemoteMachine = setup({
]
},
ClaimsDisclosure: {
entry: "navigateToClaimsDisclosureScreen",
description:
"Display the list of claims to disclose for the verifiable presentation",
on: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { ItwRemoteClaimsDisclosureScreenNavigationParams } from "../screens/ItwRemoteClaimsDisclosureScreen.tsx";
import { ItwRemoteRequestValidationScreenNavigationParams } from "../screens/ItwRemoteRequestValidationScreen.tsx";
import { ITW_REMOTE_ROUTES } from "./routes.ts";

export type ItwRemoteParamsList = {
[ITW_REMOTE_ROUTES.CLAIMS_DISCLOSURE]: ItwRemoteClaimsDisclosureScreenNavigationParams;
[ITW_REMOTE_ROUTES.REQUEST_VALIDATION]: ItwRemoteRequestValidationScreenNavigationParams;
[ITW_REMOTE_ROUTES.CLAIMS_DISCLOSURE]: undefined;
[ITW_REMOTE_ROUTES.FAILURE]: undefined;
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import {
ItwRemoteMachineContext,
ItwRemoteMachineProvider
} from "../machine/provider.tsx";

import { ItwRemoteClaimsDisclosureScreen } from "../screens/ItwRemoteClaimsDisclosureScreen.tsx";
import { ItwRemoteRequestValidationScreen } from "../screens/ItwRemoteRequestValidationScreen.tsx";
import { ItwRemoteFailureScreen } from "../screens/ItwRemoteFailureScreen.tsx";
import { ITW_REMOTE_ROUTES } from "./routes.ts";
import { ItwRemoteParamsList } from "./ItwRemoteParamsList.ts";
Expand All @@ -24,14 +26,19 @@ const InnerNavigator = () => {

return (
<Stack.Navigator
initialRouteName={ITW_REMOTE_ROUTES.CLAIMS_DISCLOSURE}
initialRouteName={ITW_REMOTE_ROUTES.REQUEST_VALIDATION}
screenOptions={{ gestureEnabled: isGestureEnabled }}
screenListeners={{
beforeRemove: () => {
itwRemoteMachineRef.send({ type: "back" });
}
}}
>
<Stack.Screen
name={ITW_REMOTE_ROUTES.REQUEST_VALIDATION}
component={ItwRemoteRequestValidationScreen}
options={hiddenHeader}
/>
<Stack.Screen
name={ITW_REMOTE_ROUTES.CLAIMS_DISCLOSURE}
component={ItwRemoteClaimsDisclosureScreen}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const ITW_REMOTE_ROUTES = {
MAIN: "ITW_REMOTE_MAIN" as const,
REQUEST_VALIDATION: "ITW_REMOTE_REQUEST_VALIDATION" as const,
CLAIMS_DISCLOSURE: "ITW_REMOTE_CLAIMS_DISCLOSURE" as const,
FAILURE: "ITW_REMOTE_FAILURE" as const
};
Loading
Loading