From e5a3b6980dc564e840dd633af8b10778efc107ea Mon Sep 17 00:00:00 2001 From: Tilak Puli Date: Thu, 11 May 2023 12:42:41 +0530 Subject: [PATCH] feat(#84): [Pooja|Tilak] fix tuvali API interface change issues with connecting and verification status --- components/ActivityLogText.tsx | 2 +- machines/openIdBle/request.ts | 36 ++++++++++++---- machines/openIdBle/scan.ts | 49 ++++++++++++---------- machines/openIdBle/scan.typegen.ts | 2 + machines/request.ts | 10 ++--- screens/Request/RequestScreen.tsx | 6 +-- screens/Request/RequestScreenController.ts | 4 +- 7 files changed, 70 insertions(+), 39 deletions(-) diff --git a/components/ActivityLogText.tsx b/components/ActivityLogText.tsx index 72bc4a9fdf..3ef0690701 100644 --- a/components/ActivityLogText.tsx +++ b/components/ActivityLogText.tsx @@ -26,6 +26,6 @@ function getActionLabel(activity: ActivityLog, language: string) { locale: DateFnsLocale[language], }), ] - .filter((label) => label.trim() !== '') + .filter((label) => label?.trim() !== '') .join(' ยท '); } diff --git a/machines/openIdBle/request.ts b/machines/openIdBle/request.ts index c12c11aeab..d5235a27b4 100644 --- a/machines/openIdBle/request.ts +++ b/machines/openIdBle/request.ts @@ -29,7 +29,7 @@ const model = createModel( receiverInfo: {} as DeviceInfo, incomingVc: {} as VC, storeError: null as Error, - connectionParams: '', + openId4VpUri: '', loggers: [] as EmitterSubscription[], sharingProtocol: (Platform.OS === 'ios' ? 'ONLINE' @@ -47,6 +47,7 @@ const model = createModel( DISMISS: () => ({}), VC_RECEIVED: (vc: VC) => ({ vc }), CONNECTION_DESTROYED: () => ({}), + ADV_STARTED: (openId4VpUri: string) => ({ openId4VpUri }), CONNECTED: () => ({}), DISCONNECT: () => ({}), BLE_ERROR: () => ({}), @@ -70,8 +71,6 @@ const model = createModel( } ); -export const RequestEvents = model.events; - export const requestMachine = /** @xstate-layout N4IgpgJg5mDOIC5QCcwEcCucAuBiAygMIBKAoqQHID6AQgDICqxA2gAwC6ioADgPawBLbAN4A7LiAAeiAOwA2ABwA6AKwBmA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vKAX07KJ5dEJiN5NKD5ARb1RwfFLZfYeE1-d9MiX0g4D3Y6GwZw3LZmK0cdasNLdcCqFAmTAzOjNdRNX062MxdEQgrEeobMoCkbYhOoXpTEeQD80zN9D9Vtc1X0uExlRCGDM-eDX1ZiSVEqZnI0KCGdM8mbLDGNOjfDb8ohLYDcFHPEQ8TOZmIyZQdQZcPQHYZwdQV-IPZcoGVc1KAobra0dfUCfE1zbMxwLzXEFUvQKS43RbOxKXGrOrBrb8hyXcfIOscgyxbk1zWDLYLzHlBGKCFEXS0rfS5yYUb7X7ejYkUy48RwFoQ8YyeszEeGXnPFVwWDdwfNVy3HetfHQnYnUncnPyzMG0M-GDCy1ShAZwZcKHRidwH5cRCk6JKC6S7VKkiXQymXOhb83k7UQofjXiCRMKkbLOfIRuaKwSSC7HNy7VU3Gk2qlckwu3DwKHAyO9HQPaeGAxfKwoQqnESSnq887xY3SAb81VbUQCPRI0PIGweGY8MsUhAxZCXMU80q-TVAYfRqda4a23LS5QDcM-ZwTQQNWwT5dcwlNEbzYNfk1-IiHkKAVqYUYWYYUnMADajmI9XYESw0dKGynKisbZAZOHRCHEEqvTFa9-GRL-U4u6tJFwLYXpS0dYAtS7IbDEbUHYAoFHFEYNc6zGli7fXfHGgQQ-UeRgiG-GucLEBso6F+EhZGd3R6tKXRZoYKhmudLGlm-fNmyAHVJmoa2Skav3ImrEEmhyEocmjLbYQZa2Rqpw-iDGNAjAr6W65W+6i4rYAsQyFoaEk0c2VQAsH3YqZiZiOgiWRg6osAVglTX06wYdXko2UQ60PECQ3wXwIAA */ model.createMachine( @@ -185,8 +184,12 @@ export const requestMachine = src: 'advertiseDevice', }, on: { + ADV_STARTED: { + actions: ['setOpenID4VpUri'], + }, CONNECTED: { target: 'waitingForVc', + actions: ['setSenderInfo', 'setReceiverInfo'], }, DISCONNECT: { @@ -459,6 +462,24 @@ export const requestMachine = }, }), + setOpenID4VpUri: assign({ + openId4VpUri: (_context, event) => { + return event.openId4VpUri; + }, + }), + + setSenderInfo: assign({ + senderInfo: () => { + return { name: 'Wallet', deviceName: 'Wallet', deviceId: '' }; + }, + }), + + setReceiverInfo: assign({ + receiverInfo: () => { + return { name: 'Verifier', deviceName: 'Verifier', deviceId: '' }; + }, + }), + setStoringError: assign({ storeError: (_context, event) => event.error, }), @@ -594,10 +615,11 @@ export const requestMachine = }, advertiseDevice: () => (callback) => { - verifier.startAdvertisement('OVPMOSIP'); + const openId4VpUri = verifier.startAdvertisement('OVPMOSIP'); + callback({ type: 'ADV_STARTED', openId4VpUri }); const statusCallback = (event: VerifierDataEvent) => { - if (event.type === 'onConnected') { + if (event.type === 'onKeyExchangeSuccess') { callback({ type: 'CONNECTED' }); } }; @@ -680,8 +702,8 @@ export function selectSenderInfo(state: State) { return state.context.senderInfo; } -export function selectConnectionParams(state: State) { - return state.context.connectionParams; +export function selectOpenId4VpUri(state: State) { + return state.context.openId4VpUri; } export function selectIncomingVc(state: State) { diff --git a/machines/openIdBle/scan.ts b/machines/openIdBle/scan.ts index 1b82881968..7060c9ebba 100644 --- a/machines/openIdBle/scan.ts +++ b/machines/openIdBle/scan.ts @@ -8,7 +8,6 @@ import { DoneInvokeEvent, EventFrom, send, - sendParent, spawn, StateFrom, } from 'xstate'; @@ -20,10 +19,7 @@ import { VC, VerifiablePresentation } from '../../types/vc'; import { AppServices } from '../../shared/GlobalContext'; import { ActivityLogEvents, ActivityLogType } from '../activityLog'; import { MY_LOGIN_STORE_KEY, VC_ITEM_STORE_KEY } from '../../shared/constants'; -import { - offlineSubscribe, - offlineSend, -} from '../../shared/openIdBLE/walletEventHandler'; +import { offlineSubscribe } from '../../shared/openIdBLE/walletEventHandler'; import { check, PERMISSIONS, @@ -36,20 +32,12 @@ import { log } from 'xstate/lib/actions'; import { isBLEEnabled } from '../../lib/smartshare'; import { createQrLoginMachine, qrLoginMachine } from '../QrLoginMachine'; import { StoreEvents } from '../store'; -import { - ExchangeSenderInfoEvent, - SendVcEvent, - SendVcStatus, -} from '../../shared/openIdBLE/smartshareEvent'; import { WalletDataEvent } from 'react-native-openid4vp-ble/lib/typescript/types/bleshare'; -import { enIE } from 'date-fns/locale'; const { wallet } = openIdBLE; type SharingProtocol = 'OFFLINE' | 'ONLINE'; -const SendVcResponseType = 'send-vc:response'; - const model = createModel( { serviceRefs: {} as AppServices, @@ -108,10 +96,8 @@ const model = createModel( ); const QR_LOGIN_REF_ID = 'QrLogin'; -export const ScanEvents = model.events; - export const scanMachine = - /** @xstate-layout N4IgpgJg5mDOIC5SwMYEMB2BiAygYQCUBRIgOQH0AhAGQFUCBtABgF1FQAHAe1gEsAXXlwzsQAD0QBWAMySAdAHYAHDICcKgCwaAjKskAmADQgAnomkbVc1ZaV3t+6dL0KNAXzfHUmXIRIUAMQB5PFocZjYkEG4+QWFRCQQAWn1VK10mJSZ9fW1ZPO0FYzMEJ205QqVpBVUANm0lVRqZDy90DDkUAAswFABrXgwoSgAbAFcwfi4ufi6cMAAnADdeFDBOnv7BqCwaWiIAFSCgg4AJcjIAQRoiABEI0RiBIREoxKStDTlajVrpPPq2kKtUkxSkMmszV0kiYDSa2laIG8HW6vQGQ1GEymMzmixWaw2aO2uzoh2OZ3ItwAkjhrtQ7g8ok84q9QIl9ExaopJA5fpJVExZEZTFJlN9XFUObDGgoEZ4ke1CVsMeNJtNZvNlqt1gswABHCawQRDEn7I4nc5XG73ViPHjPeJvRBJbRMeQNepKX5u71KYUlKrlVSFSTKDTSWo2Wr6RHIpXo4aq7EavHauS6g1wY07PZki2Uml0hm2pn2lkJKTZOSSP52GoKWoKSR2MEIVxcjT6WpKJvt-T12OK1HKxNY9W4rUEsAYNAAIxGkCwjM4ZZeFeS2g08kknYUsgbEa7DVbdXKOWkSj+nMskdUg8wcnnY5xt2nvEXAHETkFyDhDgcqVID9whLFdYjXJ0EGDBRFB+AwHDSbJqhPBs5ByBROTqVJVH0Gt7xRBc0AWbY8GEDBehZLA8CCUhSCIPAAJoykiBwA4CCCABNYtIjAh1WXERBNyUb5ryvZQDG7I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I4g4lPE5m6CKpSOqNmvYrAy9Ug0cVpzWkormDAGZ3qw7PCGaEhLznVXsUOoSPRFFwWjkrqO2E+oquotBzhGPPnLPKXKNJGhVUVFVB-V7EGTSiMPwJCL2I-LSQoWqgXJnXv1CERklVSFKx7Pzgl0MK2OFt-wOOjwtxKKZqquqk0GskluSGlulPlCwKf0araEaHznHMFrVpMIIMRLrxzB32b2RNDJGvdkvG6Q8tjSwNDlNtCBZoL01VskNtsQQtLiFodpFsRIOIAM2CAJAJYk1KMh6H1v9EQLHJlCn2eVKjzivQBhVs2LwJjt-zELb0Zt+lgPTtBEVHaP7A1DSDz2BE7FSSKzGthPVtCJfChs9rTp7BFF7Cz38KskF0HXm20CWnBFjWlSRgsCAA */ model.createMachine( { predictableActionArguments: true, @@ -285,6 +271,7 @@ export const scanMachine = on: { CONNECTED: { target: 'reviewing', + actions: ['setSenderInfo', 'setReceiverInfo'], }, }, }, @@ -536,6 +523,18 @@ export const scanMachine = openId4VpUri: '', }), + setSenderInfo: assign({ + senderInfo: () => { + return { name: 'Wallet', deviceName: 'Wallet', deviceId: '' }; + }, + }), + + setReceiverInfo: assign({ + receiverInfo: () => { + return { name: 'Verifier', deviceName: 'Verifier', deviceId: '' }; + }, + }), + setReason: model.assign({ reason: (_context, event) => event.reason, }), @@ -745,8 +744,16 @@ export const scanMachine = ); }, - startConnection: (context) => () => { + startConnection: (context) => (callback) => { wallet.startConnection('OVPMOSIP', context.openId4VpUri); + const statusCallback = (event: WalletDataEvent) => { + if (event.type === 'onKeyExchangeSuccess') { + callback({ type: 'CONNECTED' }); + } + }; + + const subscription = offlineSubscribe(statusCallback); + return () => subscription?.remove(); }, sendVc: (context) => (callback) => { @@ -765,11 +772,11 @@ export const scanMachine = } else if (event.type === 'onVerificationStatusReceived') { callback({ type: - event.status === 'APPROVED' ? 'VC_ACCEPTED' : 'VC_REJECTED', + event.status === 'ACCEPTED' ? 'VC_ACCEPTED' : 'VC_REJECTED', }); } }; - wallet.send(JSON.stringify(vc)); + wallet.sendData(JSON.stringify(vc)); const subscription = offlineSubscribe(statusCallback); return () => subscription?.remove(); }, @@ -882,11 +889,11 @@ export function selectIsConnectingTimeout(state: State) { } //TODO: post discussion with team remove the selectIsExchangingDeviceInfo & selectIsExchangingDeviceInfoTimeOut functions -export function selectIsExchangingDeviceInfo(state: State) { +export function selectIsExchangingDeviceInfo() { return true; } -export function selectIsExchangingDeviceInfoTimeout(state: State) { +export function selectIsExchangingDeviceInfoTimeout() { return true; } diff --git a/machines/openIdBle/scan.typegen.ts b/machines/openIdBle/scan.typegen.ts index 6d01af1c8d..e194adce3f 100644 --- a/machines/openIdBle/scan.typegen.ts +++ b/machines/openIdBle/scan.typegen.ts @@ -88,7 +88,9 @@ export interface Typegen0 { setCreatedVp: 'done.invoke.scan.reviewing.creatingVp:invocation[0]'; setLinkCode: 'SCAN'; setReason: 'UPDATE_REASON'; + setReceiverInfo: 'CONNECTED'; setSelectedVc: 'SELECT_VC'; + setSenderInfo: 'CONNECTED'; setShareLogTypeUnverified: 'ACCEPT_REQUEST'; setShareLogTypeVerified: 'FACE_VALID'; setUri: 'SCAN'; diff --git a/machines/request.ts b/machines/request.ts index be85322450..8b689ee1ca 100644 --- a/machines/request.ts +++ b/machines/request.ts @@ -41,7 +41,7 @@ const model = createModel( senderInfo: {} as DeviceInfo, receiverInfo: {} as DeviceInfo, incomingVc: {} as VC, - connectionParams: '', + openId4VpUri: '', loggers: [] as EmitterSubscription[], sharingProtocol: (Platform.OS === 'ios' ? 'ONLINE' @@ -521,7 +521,7 @@ export const requestMachine = }, generateConnectionParams: assign({ - connectionParams: (context) => { + openId4VpUri: (context) => { if (context.sharingProtocol === 'OFFLINE') { return IdpassSmartshare.getConnectionParameters(); } else { @@ -726,7 +726,7 @@ export const requestMachine = console.log('[request] GNM connected!'); const generatedParams = JSON.parse( - context.connectionParams + context.openId4VpUri ) as ConnectionParams; await onlineSubscribe( @@ -916,8 +916,8 @@ export function selectSenderInfo(state: State) { return state.context.senderInfo; } -export function selectConnectionParams(state: State) { - return state.context.connectionParams; +export function selectOpenIdVpUri(state: State) { + return state.context.openId4VpUri; } export function selectIncomingVc(state: State) { diff --git a/screens/Request/RequestScreen.tsx b/screens/Request/RequestScreen.tsx index 59d6264c5e..80d2991595 100644 --- a/screens/Request/RequestScreen.tsx +++ b/screens/Request/RequestScreen.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { TFunction, useTranslation } from 'react-i18next'; import { Switch } from 'react-native-elements'; -import { I18nManager, Platform } from 'react-native'; +import { Platform } from 'react-native'; import QRCode from 'react-native-qrcode-svg'; import { Centered, Button, Row, Column, Text } from '../../components/ui'; @@ -55,10 +55,10 @@ const SharingQR: React.FC = ({ t, controller }) => { - {controller.connectionParams !== '' ? ( + {controller.openId4VpUri !== '' ? ( ) : null} diff --git a/screens/Request/RequestScreenController.ts b/screens/Request/RequestScreenController.ts index 3c4e196964..0e5d31c190 100644 --- a/screens/Request/RequestScreenController.ts +++ b/screens/Request/RequestScreenController.ts @@ -4,7 +4,6 @@ import { selectIsActive, selectIsFocused } from '../../machines/app'; import { RequestEvents, selectIsBluetoothDenied, - selectConnectionParams, selectIsReviewing, selectSenderInfo, selectIsWaitingForConnection, @@ -21,6 +20,7 @@ import { selectVcLabel } from '../../machines/settings'; import { GlobalContext } from '../../shared/GlobalContext'; import BluetoothStateManager from 'react-native-bluetooth-state-manager'; import { useTranslation } from 'react-i18next'; +import { selectOpenId4VpUri } from '../../machines/openIdBle/request'; export function useRequestScreen() { const { t } = useTranslation('RequestScreen'); @@ -103,7 +103,7 @@ export function useRequestScreen() { requestService, selectIsCheckingBluetoothService ), - connectionParams: useSelector(requestService, selectConnectionParams), + openId4VpUri: useSelector(requestService, selectOpenId4VpUri), senderInfo: useSelector(requestService, selectSenderInfo), isReviewing: useSelector(requestService, selectIsReviewing), isCancelling: useSelector(requestService, selectIsCancelling),