[Injimob-685] fix download error issue which we are getting when the received vc is tampered (#1268)

* [INJIMOB-685] remove received vc metadata from storage when it is tampered or failed to store vc into storage

Signed-off-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>

* [INJIMOB-685] remove redundant store error in request machine

Signed-off-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>

* [INJIMOB-685] remove redundant logic to remove the tampered vc metadata

Signed-off-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>

* [INJIMOB-685] fix the logic of checking if tampered vc is myvc or received vc

Signed-off-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>

* [INJIMOB-685] fix tampering of received vcs

If the received vc is tampered, we should be deleting the vc file & metadata of it. Since the metadata removal was not performed, we were getting download error. This is resolved here.

Co-authored-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>
Signed-off-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>

* [INJIMOB-685] remove unused state and actions in requestMachine

After adding timestamp to the incoming received vc, every vc shared from wallet is condered as separate vc. Due to this reason, the check if the incoming vc is already available in our received vcs will always be returning false. Thus removing the mergingIncomingVcrelated states in requestMachine to avoid unnecessary checks.

Co-authored-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>
Signed-off-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>

* [INJIMOB-685] remove sharing reason related code

Co-authored-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>
Signed-off-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>

* [INJIMOB_685] remove unused event in vc machine

Signed-off-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>

---------

Signed-off-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>
Signed-off-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>
Co-authored-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>
This commit is contained in:
PuBHARGAVI
2024-02-19 15:45:58 +05:30
committed by GitHub
parent 0b4ff67cf9
commit 291243f4d5
17 changed files with 342 additions and 255 deletions

View File

@@ -78,7 +78,7 @@ fileignoreconfig:
- filename: assets/fingerprint_icon.svg - filename: assets/fingerprint_icon.svg
checksum: b2d3a50ca1336f60123d96a8cc8ea663c3316ed2d8c31833bce7e393ca51695b checksum: b2d3a50ca1336f60123d96a8cc8ea663c3316ed2d8c31833bce7e393ca51695b
- filename: machines/store.ts - filename: machines/store.ts
checksum: b4a74db48536aab62d36ab2c2398f112134af8f0e1fe1b54947a5a93c200ad77 checksum: 5ec376c6314b5b91d10bbf770359d0227d9f991dc6306851ed1df6244e5674b8
- filename: assets/Flip_Camera_Icon.svg - filename: assets/Flip_Camera_Icon.svg
checksum: 736b5a7ddb86bd4376229ce198dbf8a663e7ac89fc3311bd4f19afd4a2b36ffd checksum: 736b5a7ddb86bd4376229ce198dbf8a663e7ac89fc3311bd4f19afd4a2b36ffd
- filename: assets/Finger_Print_Icon.svg - filename: assets/Finger_Print_Icon.svg
@@ -121,8 +121,6 @@ fileignoreconfig:
checksum: 02655ff3d7f8a8ea4f3664485f98c961802c598242ec44408594a2ddb721fa5e checksum: 02655ff3d7f8a8ea4f3664485f98c961802c598242ec44408594a2ddb721fa5e
- filename: screens/Settings/BackupController.tsx - filename: screens/Settings/BackupController.tsx
checksum: 4a031b46646aa982c8f40e4c7fe0bd3e05a76a6af1ff1c2de7350ba6ebf9a839 checksum: 4a031b46646aa982c8f40e4c7fe0bd3e05a76a6af1ff1c2de7350ba6ebf9a839
- filename: machines/backupRestore.typegen.ts
checksum: ac9c154060c7c1adb3392ac8c78a42cae5ca3faea3b4b0166dd00d4ca38b290d
- filename: machines/settings.typegen.ts - filename: machines/settings.typegen.ts
checksum: e4ae05822f1b1c23f3f70d03dd46fd8f29ba6b52d40f2f24c121f536fbb5f2c4 checksum: e4ae05822f1b1c23f3f70d03dd46fd8f29ba6b52d40f2f24c121f536fbb5f2c4
- filename: .env - filename: .env
@@ -148,7 +146,7 @@ fileignoreconfig:
- filename: machines/backupAndRestore/backup.ts - filename: machines/backupAndRestore/backup.ts
checksum: d3453abfc10400e094b841e84283efc194a4fe0443c63ec880c5ddd6741f5293 checksum: d3453abfc10400e094b841e84283efc194a4fe0443c63ec880c5ddd6741f5293
- filename: machines/backupAndRestore/backup.typegen.ts - filename: machines/backupAndRestore/backup.typegen.ts
checksum: 297e29da97e8d2c94b20b1aa17e069e3ca41a299ed4a595c9ca8810ea8bcdf2d checksum: 483e237dc29256d7718d0c6137084da79a7d297d9eb86fa9689bc1170bb9f185
- filename: components/BackupAndRestoreAllScreenBanner.tsx - filename: components/BackupAndRestoreAllScreenBanner.tsx
checksum: 2c98e7e83959c9dac4dd12da32f81483c3d334bd05e279637cf465475fbf54b8 checksum: 2c98e7e83959c9dac4dd12da32f81483c3d334bd05e279637cf465475fbf54b8
checksum: f26489ce4ac607884437ad06c3117cc34d6cbcbcd3dd5719790fbe01a0853ee5 checksum: f26489ce4ac607884437ad06c3117cc34d6cbcbcd3dd5719790fbe01a0853ee5
@@ -180,8 +178,6 @@ fileignoreconfig:
checksum: a98ff1a0dd96d3ead4b8191320be8b0c7a558cda6b0de39f1c62aaa8efef9fb8 checksum: a98ff1a0dd96d3ead4b8191320be8b0c7a558cda6b0de39f1c62aaa8efef9fb8
- filename: components/HelpScreen.tsx - filename: components/HelpScreen.tsx
checksum: bbc69143bd37d065bba3800396301db5a0318e8b7ba51ecd49142dda68783a01 checksum: bbc69143bd37d065bba3800396301db5a0318e8b7ba51ecd49142dda68783a01
- filename: machines/backupRestore.ts
checksum: 433cecb9295c7052731600d16c601c1b6df9cc5a1b9f435423f81aae54d33d47
- filename: machines/backupAndRestore/backupAndRestoreSetup.typegen.ts - filename: machines/backupAndRestore/backupAndRestoreSetup.typegen.ts
checksum: 8203331f1628e01faa5e553e749372be278b477ca2d34a0cdafee1438248fb3c checksum: 8203331f1628e01faa5e553e749372be278b477ca2d34a0cdafee1438248fb3c
- filename: package-lock.json - filename: package-lock.json
@@ -190,27 +186,31 @@ fileignoreconfig:
checksum: 82974a6b9363512472272245e9b433f92e63377e58ba306980876b745181a09c checksum: 82974a6b9363512472272245e9b433f92e63377e58ba306980876b745181a09c
- filename: machines/backupAndRestore/backup.ts - filename: machines/backupAndRestore/backup.ts
checksum: 71cba6237f203a4a8df931a1b02669351466657f64fb6690545248fbad62f8b8 checksum: 71cba6237f203a4a8df931a1b02669351466657f64fb6690545248fbad62f8b8
- filename: machines/backupAndRestore/backup.typegen.ts
checksum: 8811354a68d23e6deb91b1d43347aa70b3ef4467d36276269bdf34e9be411dce
- filename: machines/backupAndRestore/backupAndRestoreSetup.ts - filename: machines/backupAndRestore/backupAndRestoreSetup.ts
checksum: 5eca5414d28f523bb920cffa1f51b484ec549a240667d37723773c224fc51792 checksum: 5eca5414d28f523bb920cffa1f51b484ec549a240667d37723773c224fc51792
- filename: shared/VCMetadata.ts - filename: shared/VCMetadata.ts
checksum: e93f988415bf91064e2cf5fbc09ff6c7226798baa5da721fa0715d5d0d6afddf checksum: e93f988415bf91064e2cf5fbc09ff6c7226798baa5da721fa0715d5d0d6afddf
- filename: machines/backupAndRestore/backup.ts - filename: machines/backupAndRestore/backup.ts
checksum: 0127424d704e7dbefcb13e2d66d687e8fa94812728b4eb6bfa7768028425e9b3 checksum: 0127424d704e7dbefcb13e2d66d687e8fa94812728b4eb6bfa7768028425e9b3
- filename: machines/backupAndRestore/backup.typegen.ts
checksum: 7ddb7fa85112d52a0e486c06d066f7adcfb8445f7e9818eb9a2c8b0e70f5a8f9
- filename: machines/backupRestore.ts - filename: machines/backupRestore.ts
checksum: 8f8725bb55dbc98083f819c74754a8eac258d15038e391a16ca1ab55a53d61f3 checksum: 71415a5e8de490af506070f8add50f864d559a8077542fc0b3d8ed18f0b33063
- filename: machines/backupRestore.typegen.ts - filename: machines/backupRestore.typegen.ts
checksum: 85e92ddec56da8dcdd28b5a29dfabd88dd0435e619f822488bc4e19b83872289 checksum: 85e92ddec56da8dcdd28b5a29dfabd88dd0435e619f822488bc4e19b83872289
- filename: machines/backupAndRestore/backupAndRestoreSetup.typegen.ts - filename: machines/backupAndRestore/backupAndRestoreSetup.typegen.ts
checksum: dd5dc9c42800328c268f3e6d6c96a16e9686dbfa59735e721250dae3ce37e009 checksum: dd5dc9c42800328c268f3e6d6c96a16e9686dbfa59735e721250dae3ce37e009
- filename: ios/Podfile.lock - filename: ios/Podfile.lock
checksum: 235f31beadf3833ac763ed1b79e00f588e56990873806627b5abf8643992336a checksum: 235f31beadf3833ac763ed1b79e00f588e56990873806627b5abf8643992336a
- filename: machines/backupAndRestore/backup.typegen.ts
checksum: 8811354a68d23e6deb91b1d43347aa70b3ef4467d36276269bdf34e9be411dce
- filename: machines/backupAndRestore/backupAndRestoreSetup.typegen.ts - filename: machines/backupAndRestore/backupAndRestoreSetup.typegen.ts
checksum: dd5dc9c42800328c268f3e6d6c96a16e9686dbfa59735e721250dae3ce37e009 checksum: dd5dc9c42800328c268f3e6d6c96a16e9686dbfa59735e721250dae3ce37e009
- filename: injitest/src/main/java/inji/pages/BackupAndRestorePage.java
checksum: 750d001f5fedb393901004933917c4a0ca73af19a2a84cf4863512c664ae0ccd
- filename: injitest/src/test/java/androidTestCases/VcDownloadAndVerifyUsingSunbirdTest.java
checksum: 39d270982ada73f036ab4c61811f31cf7fa9a92cccc4ef03b7862765ff9b11cd
- filename: injitest/src/test/java/iosTestCases/VcDownloadAndVerifyUsingEsignetTest.java
checksum: d7ef3eda605d4785716b8babde586d9fe3ecd43e090336783e64c1923b68e18e
- filename: injitest/src/test/java/iosTestCases/ChangeLanguageTest.java
checksum: 0ac8c4f3b00138c52d83d719fd8f16c5521290417561c7cf604ade88fa092bc8
- filename: injitest/src/test/java/androidTestCases/VcBackupAndRestoreTest.java
checksum: cbcbd4c4a185b5af1f23a93467e60cb2128faed718ce2499980e9658e43f19a6
version: "" version: ""

View File

@@ -1,13 +1,11 @@
import {format, formatDistanceToNow, parse} from 'date-fns'; import {format, parse} from 'date-fns';
import React from 'react'; import React from 'react';
import * as DateFnsLocale from 'date-fns/locale';
import {useTranslation} from 'react-i18next'; import {useTranslation} from 'react-i18next';
import {Dimensions, Image, ImageBackground, View} from 'react-native'; import {Dimensions, Image, ImageBackground, View} from 'react-native';
import {Icon} from 'react-native-elements'; import {Icon} from 'react-native-elements';
import {CredentialSubject, VC} from '../../../types/VC/ExistingMosipVC/vc'; import {CredentialSubject, VC} from '../../../types/VC/ExistingMosipVC/vc';
import {Button, Column, Row, Text} from '../../ui'; import {Button, Column, Row, Text} from '../../ui';
import {Theme} from '../../ui/styleUtils'; import {Theme} from '../../ui/styleUtils';
import {TextItem} from '../../ui/TextItem';
import VerifiedIcon from '../../VerifiedIcon'; import VerifiedIcon from '../../VerifiedIcon';
import {getLocalizedField} from '../../../i18n'; import {getLocalizedField} from '../../../i18n';
import {CREDENTIAL_REGISTRY_EDIT} from 'react-native-dotenv'; import {CREDENTIAL_REGISTRY_EDIT} from 'react-native-dotenv';
@@ -15,7 +13,6 @@ import {QrCodeOverlay} from '../../QrCodeOverlay';
import {VCMetadata} from '../../../shared/VCMetadata'; import {VCMetadata} from '../../../shared/VCMetadata';
import { import {
VcIdType, VcIdType,
VCSharingReason,
VerifiableCredential, VerifiableCredential,
VerifiablePresentation, VerifiablePresentation,
} from '../../../types/VC/EsignetMosipVC/vc'; } from '../../../types/VC/EsignetMosipVC/vc';
@@ -352,28 +349,6 @@ export const MosipVCItemDetails: React.FC<
</Column> </Column>
</ImageBackground> </ImageBackground>
{props.vc?.reason?.length > 0 && (
<Text
testID="reasonForSharingTitle"
margin="24 24 16 24"
weight="semibold">
{t('reasonForSharing')}
</Text>
)}
{props.vc?.reason?.map((reason, index) => (
<TextItem
testID="reason"
key={index}
divider
label={formatDistanceToNow(reason.timestamp, {
addSuffix: true,
locale: DateFnsLocale[i18n.language],
})}
text={reason.message}
/>
))}
{props.activeTab !== 1 ? ( {props.activeTab !== 1 ? (
props.isBindingPending ? ( props.isBindingPending ? (
<Column style={Theme.Styles.openCardBgContainer} padding="10"> <Column style={Theme.Styles.openCardBgContainer} padding="10">
@@ -477,7 +452,6 @@ export interface EsignetVC {
isVerified: boolean; isVerified: boolean;
lastVerifiedOn: number; lastVerifiedOn: number;
locked: boolean; locked: boolean;
reason?: VCSharingReason[];
shouldVerifyPresence?: boolean; shouldVerifyPresence?: boolean;
walletBindingResponse?: WalletBindingResponse; walletBindingResponse?: WalletBindingResponse;
credentialRegistry: string; credentialRegistry: string;

View File

@@ -1,18 +1,14 @@
import {formatDistanceToNow} from 'date-fns';
import React, {useEffect, useState} from 'react'; import React, {useEffect, useState} from 'react';
import * as DateFnsLocale from 'date-fns/locale';
import {useTranslation} from 'react-i18next'; import {useTranslation} from 'react-i18next';
import {Image, ImageBackground} from 'react-native'; import {Image, ImageBackground} from 'react-native';
import {Icon} from 'react-native-elements'; import {Icon} from 'react-native-elements';
import {VC} from '../../../types/VC/ExistingMosipVC/vc'; import {VC} from '../../../types/VC/ExistingMosipVC/vc';
import {Button, Column, Row, Text} from '../../ui'; import {Button, Column, Row, Text} from '../../ui';
import {Theme} from '../../ui/styleUtils'; import {Theme} from '../../ui/styleUtils';
import {TextItem} from '../../ui/TextItem';
import {QrCodeOverlay} from '../../QrCodeOverlay'; import {QrCodeOverlay} from '../../QrCodeOverlay';
import {VCMetadata} from '../../../shared/VCMetadata'; import {VCMetadata} from '../../../shared/VCMetadata';
import { import {
VcIdType, VcIdType,
VCSharingReason,
VerifiableCredential, VerifiableCredential,
VerifiablePresentation, VerifiablePresentation,
} from '../../../types/VC/EsignetMosipVC/vc'; } from '../../../types/VC/EsignetMosipVC/vc';
@@ -126,28 +122,6 @@ export const VCDetailView: React.FC<
</Row> </Row>
</ImageBackground> </ImageBackground>
{props.vc?.reason?.length > 0 && (
<Text
testID="reasonForSharingTitle"
margin="24 24 16 24"
weight="semibold">
{t('reasonForSharing')}
</Text>
)}
{props.vc?.reason?.map((reason, index) => (
<TextItem
testID="reason"
key={index}
divider
label={formatDistanceToNow(reason.timestamp, {
addSuffix: true,
locale: DateFnsLocale[i18n.language],
})}
text={reason.message}
/>
))}
{props.activeTab !== 1 ? ( {props.activeTab !== 1 ? (
props.isBindingPending && props.isBindingPending &&
isActivationNeeded(props.vc.vcMetadata.issuer) ? ( isActivationNeeded(props.vc.vcMetadata.issuer) ? (
@@ -246,7 +220,6 @@ export interface EsignetVC {
isVerified: boolean; isVerified: boolean;
lastVerifiedOn: number; lastVerifiedOn: number;
locked: boolean; locked: boolean;
reason?: VCSharingReason[];
shouldVerifyPresence?: boolean; shouldVerifyPresence?: boolean;
walletBindingResponse?: WalletBindingResponse; walletBindingResponse?: WalletBindingResponse;
credentialRegistry: string; credentialRegistry: string;

View File

@@ -13,6 +13,11 @@ export interface Typegen0 {
data: unknown; data: unknown;
__tip: 'See the XState TS docs to learn how to strongly type this.'; __tip: 'See the XState TS docs to learn how to strongly type this.';
}; };
'done.invoke.vc-item-openid4vci.kebabPopUp.triggerAutoBackup:invocation[0]': {
type: 'done.invoke.vc-item-openid4vci.kebabPopUp.triggerAutoBackup:invocation[0]';
data: unknown;
__tip: 'See the XState TS docs to learn how to strongly type this.';
};
'done.invoke.vc-item-openid4vci.requestingBindingOtp:invocation[0]': { 'done.invoke.vc-item-openid4vci.requestingBindingOtp:invocation[0]': {
type: 'done.invoke.vc-item-openid4vci.requestingBindingOtp:invocation[0]'; type: 'done.invoke.vc-item-openid4vci.requestingBindingOtp:invocation[0]';
data: unknown; data: unknown;
@@ -48,6 +53,7 @@ export interface Typegen0 {
invokeSrcNameMap: { invokeSrcNameMap: {
addWalletBindnigId: 'done.invoke.vc-item-openid4vci.addingWalletBindingId:invocation[0]'; addWalletBindnigId: 'done.invoke.vc-item-openid4vci.addingWalletBindingId:invocation[0]';
generateKeyPair: 'done.invoke.vc-item-openid4vci.addKeyPair:invocation[0]'; generateKeyPair: 'done.invoke.vc-item-openid4vci.addKeyPair:invocation[0]';
isUserSignedAlready: 'done.invoke.vc-item-openid4vci.kebabPopUp.triggerAutoBackup:invocation[0]';
requestBindingOtp: requestBindingOtp:
| 'done.invoke.vc-item-openid4vci.acceptingBindingOtp.resendOTP:invocation[0]' | 'done.invoke.vc-item-openid4vci.acceptingBindingOtp.resendOTP:invocation[0]'
| 'done.invoke.vc-item-openid4vci.requestingBindingOtp:invocation[0]'; | 'done.invoke.vc-item-openid4vci.requestingBindingOtp:invocation[0]';
@@ -64,7 +70,7 @@ export interface Typegen0 {
| 'DISMISS' | 'DISMISS'
| 'done.invoke.vc-item-openid4vci.requestingBindingOtp:invocation[0]'; | 'done.invoke.vc-item-openid4vci.requestingBindingOtp:invocation[0]';
clearTransactionId: 'DISMISS'; clearTransactionId: 'DISMISS';
logVCremoved: 'STORE_RESPONSE'; logVCremoved: 'done.invoke.vc-item-openid4vci.kebabPopUp.triggerAutoBackup:invocation[0]';
logWalletBindingFailure: logWalletBindingFailure:
| 'error.platform.vc-item-openid4vci.addKeyPair:invocation[0]' | 'error.platform.vc-item-openid4vci.addKeyPair:invocation[0]'
| 'error.platform.vc-item-openid4vci.addingWalletBindingId:invocation[0]' | 'error.platform.vc-item-openid4vci.addingWalletBindingId:invocation[0]'
@@ -74,7 +80,7 @@ export interface Typegen0 {
| 'done.invoke.vc-item-openid4vci.addingWalletBindingId:invocation[0]' | 'done.invoke.vc-item-openid4vci.addingWalletBindingId:invocation[0]'
| 'done.invoke.vc-item-openid4vci.updatingPrivateKey:invocation[0]'; | 'done.invoke.vc-item-openid4vci.updatingPrivateKey:invocation[0]';
removeVcItem: 'CONFIRM'; removeVcItem: 'CONFIRM';
removedVc: 'STORE_RESPONSE'; removedVc: 'done.invoke.vc-item-openid4vci.kebabPopUp.triggerAutoBackup:invocation[0]';
requestStoredContext: 'GET_VC_RESPONSE' | 'REFRESH'; requestStoredContext: 'GET_VC_RESPONSE' | 'REFRESH';
requestVcContext: 'DISMISS' | 'xstate.init'; requestVcContext: 'DISMISS' | 'xstate.init';
sendActivationFailedEndEvent: sendActivationFailedEndEvent:
@@ -84,6 +90,7 @@ export interface Typegen0 {
sendActivationSuccessEvent: sendActivationSuccessEvent:
| 'done.invoke.vc-item-openid4vci.addingWalletBindingId:invocation[0]' | 'done.invoke.vc-item-openid4vci.addingWalletBindingId:invocation[0]'
| 'done.invoke.vc-item-openid4vci.updatingPrivateKey:invocation[0]'; | 'done.invoke.vc-item-openid4vci.updatingPrivateKey:invocation[0]';
sendBackupEvent: 'done.invoke.vc-item-openid4vci.kebabPopUp.triggerAutoBackup:invocation[0]';
sendVcUpdated: 'PIN_CARD'; sendVcUpdated: 'PIN_CARD';
sendWalletBindingSuccess: 'SHOW_BINDING_STATUS'; sendWalletBindingSuccess: 'SHOW_BINDING_STATUS';
setContext: 'GET_VC_RESPONSE' | 'STORE_RESPONSE'; setContext: 'GET_VC_RESPONSE' | 'STORE_RESPONSE';
@@ -129,10 +136,12 @@ export interface Typegen0 {
isCustomSecureKeystore: isCustomSecureKeystore:
| 'done.invoke.vc-item-openid4vci.addKeyPair:invocation[0]' | 'done.invoke.vc-item-openid4vci.addKeyPair:invocation[0]'
| 'done.invoke.vc-item-openid4vci.addingWalletBindingId:invocation[0]'; | 'done.invoke.vc-item-openid4vci.addingWalletBindingId:invocation[0]';
isSignedIn: 'done.invoke.vc-item-openid4vci.kebabPopUp.triggerAutoBackup:invocation[0]';
}; };
eventsCausingServices: { eventsCausingServices: {
addWalletBindnigId: 'done.invoke.vc-item-openid4vci.addKeyPair:invocation[0]'; addWalletBindnigId: 'done.invoke.vc-item-openid4vci.addKeyPair:invocation[0]';
generateKeyPair: 'INPUT_OTP'; generateKeyPair: 'INPUT_OTP';
isUserSignedAlready: 'STORE_RESPONSE';
requestBindingOtp: 'CONFIRM' | 'RESEND_OTP'; requestBindingOtp: 'CONFIRM' | 'RESEND_OTP';
updatePrivateKey: 'done.invoke.vc-item-openid4vci.addingWalletBindingId:invocation[0]'; updatePrivateKey: 'done.invoke.vc-item-openid4vci.addingWalletBindingId:invocation[0]';
}; };
@@ -150,6 +159,7 @@ export interface Typegen0 {
| 'kebabPopUp.removeWallet' | 'kebabPopUp.removeWallet'
| 'kebabPopUp.removingVc' | 'kebabPopUp.removingVc'
| 'kebabPopUp.showActivities' | 'kebabPopUp.showActivities'
| 'kebabPopUp.triggerAutoBackup'
| 'pinCard' | 'pinCard'
| 'requestingBindingOtp' | 'requestingBindingOtp'
| 'showBindingWarning' | 'showBindingWarning'
@@ -158,7 +168,12 @@ export interface Typegen0 {
| 'updatingPrivateKey' | 'updatingPrivateKey'
| { | {
acceptingBindingOtp?: 'idle' | 'resendOTP'; acceptingBindingOtp?: 'idle' | 'resendOTP';
kebabPopUp?: 'idle' | 'removeWallet' | 'removingVc' | 'showActivities'; kebabPopUp?:
| 'idle'
| 'removeWallet'
| 'removingVc'
| 'showActivities'
| 'triggerAutoBackup';
}; };
tags: never; tags: never;
} }

View File

@@ -169,7 +169,7 @@ export const ExistingMosipVCItemMachine =
}, },
], ],
TAMPERED_VC: { TAMPERED_VC: {
actions: ['sendTamperedVc', 'removeTamperedVcItem'], actions: 'sendTamperedVc',
}, },
}, },
}, },
@@ -1235,16 +1235,6 @@ export const ExistingMosipVCItemMachine =
{to: context => context.serviceRefs.store}, {to: context => context.serviceRefs.store},
), ),
removeTamperedVcItem: send(
_context => {
return StoreEvents.REMOVE(
MY_VCS_STORE_KEY,
_context.vcMetadata.getVcKey(),
);
},
{to: context => context.serviceRefs.store},
),
logVCremoved: send( logVCremoved: send(
(context, _) => (context, _) =>
ActivityLogEvents.LOG_ACTIVITY({ ActivityLogEvents.LOG_ACTIVITY({

View File

@@ -24,6 +24,11 @@ export interface Typegen0 {
data: unknown; data: unknown;
__tip: 'See the XState TS docs to learn how to strongly type this.'; __tip: 'See the XState TS docs to learn how to strongly type this.';
}; };
'done.invoke.vc-item.checkingServerData.downloadingCredential.triggerAutoBackupForVcDownload:invocation[0]': {
type: 'done.invoke.vc-item.checkingServerData.downloadingCredential.triggerAutoBackupForVcDownload:invocation[0]';
data: unknown;
__tip: 'See the XState TS docs to learn how to strongly type this.';
};
'done.invoke.vc-item.checkingServerData.loadDownloadLimitConfig:invocation[0]': { 'done.invoke.vc-item.checkingServerData.loadDownloadLimitConfig:invocation[0]': {
type: 'done.invoke.vc-item.checkingServerData.loadDownloadLimitConfig:invocation[0]'; type: 'done.invoke.vc-item.checkingServerData.loadDownloadLimitConfig:invocation[0]';
data: unknown; data: unknown;
@@ -34,6 +39,11 @@ export interface Typegen0 {
data: unknown; data: unknown;
__tip: 'See the XState TS docs to learn how to strongly type this.'; __tip: 'See the XState TS docs to learn how to strongly type this.';
}; };
'done.invoke.vc-item.kebabPopUp.removingVc.triggerAutoBackup:invocation[0]': {
type: 'done.invoke.vc-item.kebabPopUp.removingVc.triggerAutoBackup:invocation[0]';
data: unknown;
__tip: 'See the XState TS docs to learn how to strongly type this.';
};
'done.invoke.vc-item.requestingBindingOtp:invocation[0]': { 'done.invoke.vc-item.requestingBindingOtp:invocation[0]': {
type: 'done.invoke.vc-item.requestingBindingOtp:invocation[0]'; type: 'done.invoke.vc-item.requestingBindingOtp:invocation[0]';
data: unknown; data: unknown;
@@ -116,6 +126,9 @@ export interface Typegen0 {
checkStatus: 'done.invoke.checkStatus'; checkStatus: 'done.invoke.checkStatus';
downloadCredential: 'done.invoke.downloadCredential'; downloadCredential: 'done.invoke.downloadCredential';
generateKeyPair: 'done.invoke.vc-item.addKeyPair:invocation[0]'; generateKeyPair: 'done.invoke.vc-item.addKeyPair:invocation[0]';
isUserSignedAlready:
| 'done.invoke.vc-item.checkingServerData.downloadingCredential.triggerAutoBackupForVcDownload:invocation[0]'
| 'done.invoke.vc-item.kebabPopUp.removingVc.triggerAutoBackup:invocation[0]';
loadDownloadLimitConfig: 'done.invoke.vc-item.checkingServerData.loadDownloadLimitConfig:invocation[0]'; loadDownloadLimitConfig: 'done.invoke.vc-item.checkingServerData.loadDownloadLimitConfig:invocation[0]';
requestBindingOtp: requestBindingOtp:
| 'done.invoke.vc-item.acceptingBindingOtp.resendOTP:invocation[0]' | 'done.invoke.vc-item.acceptingBindingOtp.resendOTP:invocation[0]'
@@ -162,7 +175,7 @@ export interface Typegen0 {
| 'done.invoke.vc-item.checkingServerData.loadDownloadLimitConfig:invocation[0]'; | 'done.invoke.vc-item.checkingServerData.loadDownloadLimitConfig:invocation[0]';
logDownloaded: 'STORE_RESPONSE'; logDownloaded: 'STORE_RESPONSE';
logRevoked: 'STORE_RESPONSE'; logRevoked: 'STORE_RESPONSE';
logVCremoved: 'STORE_RESPONSE'; logVCremoved: 'done.invoke.vc-item.kebabPopUp.removingVc.triggerAutoBackup:invocation[0]';
logWalletBindingFailure: logWalletBindingFailure:
| 'error.platform.vc-item.addKeyPair:invocation[0]' | 'error.platform.vc-item.addKeyPair:invocation[0]'
| 'error.platform.vc-item.addingWalletBindingId:invocation[0]' | 'error.platform.vc-item.addingWalletBindingId:invocation[0]'
@@ -172,8 +185,7 @@ export interface Typegen0 {
| 'done.invoke.vc-item.addingWalletBindingId:invocation[0]' | 'done.invoke.vc-item.addingWalletBindingId:invocation[0]'
| 'done.invoke.vc-item.updatingPrivateKey:invocation[0]'; | 'done.invoke.vc-item.updatingPrivateKey:invocation[0]';
markVcValid: 'done.invoke.vc-item.verifyingCredential:invocation[0]'; markVcValid: 'done.invoke.vc-item.verifyingCredential:invocation[0]';
refreshMyVcs: 'STORE_RESPONSE'; refreshMyVcs: 'done.invoke.vc-item.kebabPopUp.removingVc.triggerAutoBackup:invocation[0]';
removeTamperedVcItem: 'TAMPERED_VC';
removeVcFromInProgressDownloads: 'STORE_RESPONSE'; removeVcFromInProgressDownloads: 'STORE_RESPONSE';
removeVcItem: 'CONFIRM'; removeVcItem: 'CONFIRM';
removeVcMetaDataFromStorage: 'STORE_ERROR'; removeVcMetaDataFromStorage: 'STORE_ERROR';
@@ -188,6 +200,9 @@ export interface Typegen0 {
sendActivationSuccessEvent: sendActivationSuccessEvent:
| 'done.invoke.vc-item.addingWalletBindingId:invocation[0]' | 'done.invoke.vc-item.addingWalletBindingId:invocation[0]'
| 'done.invoke.vc-item.updatingPrivateKey:invocation[0]'; | 'done.invoke.vc-item.updatingPrivateKey:invocation[0]';
sendBackupEvent:
| 'done.invoke.vc-item.checkingServerData.downloadingCredential.triggerAutoBackupForVcDownload:invocation[0]'
| 'done.invoke.vc-item.kebabPopUp.removingVc.triggerAutoBackup:invocation[0]';
sendDownloadLimitExpire: sendDownloadLimitExpire:
| 'FAILED' | 'FAILED'
| 'error.platform.vc-item.checkingServerData.verifyingDownloadLimitExpiry:invocation[0]'; | 'error.platform.vc-item.checkingServerData.verifyingDownloadLimitExpiry:invocation[0]';
@@ -256,6 +271,9 @@ export interface Typegen0 {
| 'done.invoke.vc-item.addKeyPair:invocation[0]' | 'done.invoke.vc-item.addKeyPair:invocation[0]'
| 'done.invoke.vc-item.addingWalletBindingId:invocation[0]'; | 'done.invoke.vc-item.addingWalletBindingId:invocation[0]';
isDownloadAllowed: 'POLL'; isDownloadAllowed: 'POLL';
isSignedIn:
| 'done.invoke.vc-item.checkingServerData.downloadingCredential.triggerAutoBackupForVcDownload:invocation[0]'
| 'done.invoke.vc-item.kebabPopUp.removingVc.triggerAutoBackup:invocation[0]';
isVcValid: ''; isVcValid: '';
}; };
eventsCausingServices: { eventsCausingServices: {
@@ -266,6 +284,7 @@ export interface Typegen0 {
checkStatus: 'done.invoke.vc-item.checkingServerData.verifyingDownloadLimitExpiry:invocation[0]'; checkStatus: 'done.invoke.vc-item.checkingServerData.verifyingDownloadLimitExpiry:invocation[0]';
downloadCredential: 'DOWNLOAD_READY'; downloadCredential: 'DOWNLOAD_READY';
generateKeyPair: 'INPUT_OTP'; generateKeyPair: 'INPUT_OTP';
isUserSignedAlready: 'STORE_RESPONSE';
loadDownloadLimitConfig: 'STORE_RESPONSE'; loadDownloadLimitConfig: 'STORE_RESPONSE';
requestBindingOtp: 'CONFIRM' | 'RESEND_OTP'; requestBindingOtp: 'CONFIRM' | 'RESEND_OTP';
requestLock: 'INPUT_OTP'; requestLock: 'INPUT_OTP';
@@ -287,6 +306,8 @@ export interface Typegen0 {
| 'checkingServerData' | 'checkingServerData'
| 'checkingServerData.checkingStatus' | 'checkingServerData.checkingStatus'
| 'checkingServerData.downloadingCredential' | 'checkingServerData.downloadingCredential'
| 'checkingServerData.downloadingCredential.idle'
| 'checkingServerData.downloadingCredential.triggerAutoBackupForVcDownload'
| 'checkingServerData.loadDownloadLimitConfig' | 'checkingServerData.loadDownloadLimitConfig'
| 'checkingServerData.savingFailed' | 'checkingServerData.savingFailed'
| 'checkingServerData.savingFailed.idle' | 'checkingServerData.savingFailed.idle'
@@ -303,6 +324,7 @@ export interface Typegen0 {
| 'kebabPopUp.idle' | 'kebabPopUp.idle'
| 'kebabPopUp.removeWallet' | 'kebabPopUp.removeWallet'
| 'kebabPopUp.removingVc' | 'kebabPopUp.removingVc'
| 'kebabPopUp.removingVc.triggerAutoBackup'
| 'kebabPopUp.showActivities' | 'kebabPopUp.showActivities'
| 'lockingVc' | 'lockingVc'
| 'loggingRevoke' | 'loggingRevoke'
@@ -326,9 +348,17 @@ export interface Typegen0 {
| 'loadDownloadLimitConfig' | 'loadDownloadLimitConfig'
| 'savingFailed' | 'savingFailed'
| 'verifyingDownloadLimitExpiry' | 'verifyingDownloadLimitExpiry'
| {savingFailed?: 'idle' | 'viewingVc'}; | {
downloadingCredential?: 'idle' | 'triggerAutoBackupForVcDownload';
savingFailed?: 'idle' | 'viewingVc';
};
invalid?: 'backend' | 'otp'; invalid?: 'backend' | 'otp';
kebabPopUp?: 'idle' | 'removeWallet' | 'removingVc' | 'showActivities'; kebabPopUp?:
| 'idle'
| 'removeWallet'
| 'removingVc'
| 'showActivities'
| {removingVc?: 'triggerAutoBackup'};
}; };
tags: never; tags: never;
} }

View File

@@ -35,7 +35,6 @@ const model = createModel(
VC_ADDED: (vcMetadata: VCMetadata) => ({vcMetadata}), VC_ADDED: (vcMetadata: VCMetadata) => ({vcMetadata}),
REMOVE_VC_FROM_CONTEXT: (vcMetadata: VCMetadata) => ({vcMetadata}), REMOVE_VC_FROM_CONTEXT: (vcMetadata: VCMetadata) => ({vcMetadata}),
VC_METADATA_UPDATED: (vcMetadata: VCMetadata) => ({vcMetadata}), VC_METADATA_UPDATED: (vcMetadata: VCMetadata) => ({vcMetadata}),
VC_RECEIVED: (vcMetadata: VCMetadata) => ({vcMetadata}),
VC_DOWNLOADED: (vc: VC) => ({vc}), VC_DOWNLOADED: (vc: VC) => ({vc}),
VC_DOWNLOADED_FROM_OPENID4VCI: (vc: VC, vcMetadata: VCMetadata) => ({ VC_DOWNLOADED_FROM_OPENID4VCI: (vc: VC, vcMetadata: VCMetadata) => ({
vc, vc,
@@ -56,6 +55,7 @@ const model = createModel(
REMOVE_TAMPERED_VCS: () => ({}), REMOVE_TAMPERED_VCS: () => ({}),
DOWNLOAD_LIMIT_EXPIRED: (vcMetadata: VCMetadata) => ({vcMetadata}), DOWNLOAD_LIMIT_EXPIRED: (vcMetadata: VCMetadata) => ({vcMetadata}),
DELETE_VC: () => ({}), DELETE_VC: () => ({}),
REFRESH_VCS_METADATA: () => ({}),
}, },
}, },
); );
@@ -136,13 +136,7 @@ export const vcMachine =
receivedVcs: { receivedVcs: {
initial: 'idle', initial: 'idle',
states: { states: {
idle: { idle: {},
on: {
REFRESH_RECEIVED_VCS: {
target: 'refreshing',
},
},
},
refreshing: { refreshing: {
entry: 'loadReceivedVcs', entry: 'loadReceivedVcs',
on: { on: {
@@ -156,9 +150,6 @@ export const vcMachine =
}, },
}, },
on: { on: {
GET_RECEIVED_VCS: {
actions: 'getReceivedVcsResponse',
},
GET_VC_ITEM: { GET_VC_ITEM: {
actions: 'getVcItemResponse', actions: 'getVcItemResponse',
}, },
@@ -189,11 +180,9 @@ export const vcMachine =
RESET_WALLET_BINDING_SUCCESS: { RESET_WALLET_BINDING_SUCCESS: {
actions: 'resetWalletBindingSuccess', actions: 'resetWalletBindingSuccess',
}, },
VC_RECEIVED: [ REFRESH_RECEIVED_VCS: {
{ target: '#vc.ready.receivedVcs.refreshing',
actions: 'prependToReceivedVcs', },
},
],
TAMPERED_VC: { TAMPERED_VC: {
actions: 'setTamperedVcs', actions: 'setTamperedVcs',
target: 'tamperedVCs', target: 'tamperedVCs',
@@ -223,20 +212,26 @@ export const vcMachine =
onDone: [ onDone: [
{ {
cond: 'isSignedIn', cond: 'isSignedIn',
actions: [ actions: 'sendBackupEvent',
'sendBackupEvent', target: 'refreshVcsMetadata',
'removeTamperedVcs',
'logTamperedVCsremoved',
],
target: '#vc.ready.myVcs.refreshing',
}, },
{ {
actions: ['removeTamperedVcs', 'logTamperedVCsremoved'], target: 'refreshVcsMetadata',
target: '#vc.ready.myVcs.refreshing',
}, },
], ],
}, },
}, },
refreshVcsMetadata: {
entry: ['logTamperedVCsremoved', send('REFRESH_VCS_METADATA')],
on: {
REFRESH_VCS_METADATA: {
target: [
'#vc.ready.myVcs.refreshing',
'#vc.ready.receivedVcs.refreshing',
],
},
},
},
}, },
}, },
deletingFailedVcs: { deletingFailedVcs: {
@@ -390,13 +385,6 @@ export const vcMachine =
}, },
), ),
removeTamperedVcs: model.assign({
myVcs: (context, event) =>
context.myVcs.filter(
value => !context.tamperedVcs.some(item => item?.equals(value)),
),
}),
logTamperedVCsremoved: send( logTamperedVCsremoved: send(
context => context =>
ActivityLogEvents.LOG_ACTIVITY(ActivityLog.logTamperedVCs()), ActivityLogEvents.LOG_ACTIVITY(ActivityLog.logTamperedVCs()),
@@ -417,22 +405,11 @@ export const vcMachine =
resetWalletBindingSuccess: model.assign({ resetWalletBindingSuccess: model.assign({
walletBindingSuccess: false, walletBindingSuccess: false,
}), }),
prependToReceivedVcs: model.assign({
receivedVcs: (context, event) => [
event.vcMetadata,
...context.receivedVcs,
],
}),
}, },
guards: { guards: {
isSignedIn: (_context, event) => isSignedIn: (_context, event) =>
(event.data as isSignedInResult).isSignedIn, (event.data as isSignedInResult).isSignedIn,
hasExistingReceivedVc: (context, event) =>
context.receivedVcs.find(vcMetadata =>
vcMetadata.equals(event.vcMetadata),
) != null,
}, },
services: { services: {

View File

@@ -3,9 +3,16 @@
export interface Typegen0 { export interface Typegen0 {
'@@xstate/typegen': true; '@@xstate/typegen': true;
internalEvents: { internalEvents: {
'done.invoke.vc.tamperedVCs.triggerAutoBackupForTamperedVcDeletion:invocation[0]': {
type: 'done.invoke.vc.tamperedVCs.triggerAutoBackupForTamperedVcDeletion:invocation[0]';
data: unknown;
__tip: 'See the XState TS docs to learn how to strongly type this.';
};
'xstate.init': {type: 'xstate.init'}; 'xstate.init': {type: 'xstate.init'};
}; };
invokeSrcNameMap: {}; invokeSrcNameMap: {
isUserSignedAlready: 'done.invoke.vc.tamperedVCs.triggerAutoBackupForTamperedVcDeletion:invocation[0]';
};
missingImplementations: { missingImplementations: {
actions: never; actions: never;
delays: never; delays: never;
@@ -14,21 +21,21 @@ export interface Typegen0 {
}; };
eventsCausingActions: { eventsCausingActions: {
addVcToInProgressDownloads: 'ADD_VC_TO_IN_PROGRESS_DOWNLOADS'; addVcToInProgressDownloads: 'ADD_VC_TO_IN_PROGRESS_DOWNLOADS';
getReceivedVcsResponse: 'GET_RECEIVED_VCS';
getVcItemResponse: 'GET_VC_ITEM'; getVcItemResponse: 'GET_VC_ITEM';
loadMyVcs: loadMyVcs:
| 'DOWNLOAD_LIMIT_EXPIRED' | 'DOWNLOAD_LIMIT_EXPIRED'
| 'REFRESH_MY_VCS' | 'REFRESH_MY_VCS'
| 'REMOVE_TAMPERED_VCS' | 'REFRESH_VCS_METADATA'
| 'STORE_RESPONSE' | 'STORE_RESPONSE'
| 'xstate.init'; | 'xstate.init';
loadReceivedVcs: 'REFRESH_RECEIVED_VCS' | 'STORE_RESPONSE'; loadReceivedVcs:
logTamperedVCsremoved: 'REMOVE_TAMPERED_VCS'; | 'REFRESH_RECEIVED_VCS'
| 'REFRESH_VCS_METADATA'
| 'STORE_RESPONSE';
logTamperedVCsremoved: 'done.invoke.vc.tamperedVCs.triggerAutoBackupForTamperedVcDeletion:invocation[0]';
prependToMyVcs: 'VC_ADDED'; prependToMyVcs: 'VC_ADDED';
prependToReceivedVcs: 'VC_RECEIVED';
removeDownloadFailedVcsFromStorage: 'DELETE_VC'; removeDownloadFailedVcsFromStorage: 'DELETE_VC';
removeDownloadingFailedVcsFromMyVcs: 'STORE_RESPONSE'; removeDownloadingFailedVcsFromMyVcs: 'STORE_RESPONSE';
removeTamperedVcs: 'REMOVE_TAMPERED_VCS';
removeVcFromInProgressDownlods: removeVcFromInProgressDownlods:
| 'DOWNLOAD_LIMIT_EXPIRED' | 'DOWNLOAD_LIMIT_EXPIRED'
| 'REMOVE_VC_FROM_IN_PROGRESS_DOWNLOADS'; | 'REMOVE_VC_FROM_IN_PROGRESS_DOWNLOADS';
@@ -36,6 +43,7 @@ export interface Typegen0 {
resetAreAllVcsDownloaded: 'RESET_ARE_ALL_VCS_DOWNLOADED'; resetAreAllVcsDownloaded: 'RESET_ARE_ALL_VCS_DOWNLOADED';
resetDownloadFailedVcs: 'STORE_RESPONSE'; resetDownloadFailedVcs: 'STORE_RESPONSE';
resetWalletBindingSuccess: 'RESET_WALLET_BINDING_SUCCESS'; resetWalletBindingSuccess: 'RESET_WALLET_BINDING_SUCCESS';
sendBackupEvent: 'done.invoke.vc.tamperedVCs.triggerAutoBackupForTamperedVcDeletion:invocation[0]';
setDownloadedVCFromOpenId4VCI: 'VC_DOWNLOADED_FROM_OPENID4VCI'; setDownloadedVCFromOpenId4VCI: 'VC_DOWNLOADED_FROM_OPENID4VCI';
setDownloadedVc: 'VC_DOWNLOADED'; setDownloadedVc: 'VC_DOWNLOADED';
setDownloadingFailedVcs: 'DOWNLOAD_LIMIT_EXPIRED'; setDownloadingFailedVcs: 'DOWNLOAD_LIMIT_EXPIRED';
@@ -47,8 +55,12 @@ export interface Typegen0 {
updateMyVcs: 'VC_METADATA_UPDATED'; updateMyVcs: 'VC_METADATA_UPDATED';
}; };
eventsCausingDelays: {}; eventsCausingDelays: {};
eventsCausingGuards: {}; eventsCausingGuards: {
eventsCausingServices: {}; isSignedIn: 'done.invoke.vc.tamperedVCs.triggerAutoBackupForTamperedVcDeletion:invocation[0]';
};
eventsCausingServices: {
isUserSignedAlready: 'REMOVE_TAMPERED_VCS';
};
matchesStates: matchesStates:
| 'deletingFailedVcs' | 'deletingFailedVcs'
| 'init' | 'init'
@@ -62,6 +74,8 @@ export interface Typegen0 {
| 'ready.receivedVcs.idle' | 'ready.receivedVcs.idle'
| 'ready.receivedVcs.refreshing' | 'ready.receivedVcs.refreshing'
| 'tamperedVCs' | 'tamperedVCs'
| 'tamperedVCs.refreshVcsMetadata'
| 'tamperedVCs.triggerAutoBackupForTamperedVcDeletion'
| { | {
init?: 'myVcs' | 'receivedVcs'; init?: 'myVcs' | 'receivedVcs';
ready?: ready?:
@@ -71,6 +85,9 @@ export interface Typegen0 {
myVcs?: 'idle' | 'refreshing'; myVcs?: 'idle' | 'refreshing';
receivedVcs?: 'idle' | 'refreshing'; receivedVcs?: 'idle' | 'refreshing';
}; };
tamperedVCs?:
| 'refreshVcsMetadata'
| 'triggerAutoBackupForTamperedVcDeletion';
}; };
tags: never; tags: never;
} }

View File

@@ -304,8 +304,8 @@ export const requestMachine =
actions: ['sendVCReceivingDisconnectedEvent'], actions: ['sendVCReceivingDisconnectedEvent'],
}, },
VC_RECEIVED: { VC_RECEIVED: {
target: 'reviewing.accepting',
actions: 'setIncomingVc', actions: 'setIncomingVc',
target: 'reviewing.accepting',
}, },
}, },
}, },
@@ -364,44 +364,17 @@ export const requestMachine =
}, },
}, },
accepting: { accepting: {
initial: 'requestingReceivedVcs', initial: 'prependingReceivedVcMetadata',
states: { states: {
requestingReceivedVcs: { prependingReceivedVcMetadata: {
entry: 'requestReceivedVcs', entry: 'prependReceivedVcMetadata',
on: {
VC_RESPONSE: [
{
target: 'requestingExistingVc',
cond: 'hasExistingVc',
},
{
target: 'prependingReceivedVc',
},
],
},
},
requestingExistingVc: {
entry: 'requestExistingVc',
on: {
STORE_RESPONSE: {
target: 'mergingIncomingVc',
},
},
},
mergingIncomingVc: {
entry: 'mergeIncomingVc',
on: {
STORE_RESPONSE: {
target: '#request.reviewing.accepted',
},
},
},
prependingReceivedVc: {
entry: 'prependReceivedVc',
on: { on: {
STORE_RESPONSE: { STORE_RESPONSE: {
target: 'storingVc', target: 'storingVc',
}, },
STORE_ERROR: {
target: '#request.reviewing.savingFailed',
},
}, },
}, },
storingVc: { storingVc: {
@@ -410,14 +383,13 @@ export const requestMachine =
STORE_RESPONSE: { STORE_RESPONSE: {
target: '#request.reviewing.accepted', target: '#request.reviewing.accepted',
}, },
STORE_ERROR: {
actions: 'removeReceivedVcMetadataFromStorage',
target: '#request.reviewing.savingFailed',
},
}, },
}, },
}, },
on: {
STORE_ERROR: {
target: '#request.reviewing.savingFailed',
},
},
}, },
accepted: { accepted: {
entry: [ entry: [
@@ -556,10 +528,6 @@ export const requestMachine =
Linking.openSettings(); Linking.openSettings();
}, },
requestReceivedVcs: send(VcEvents.GET_RECEIVED_VCS(), {
to: context => context.serviceRefs.vc,
}),
setReadyForBluetoothStateCheck: model.assign({ setReadyForBluetoothStateCheck: model.assign({
readyForBluetoothStateCheck: () => true, readyForBluetoothStateCheck: () => true,
}), }),
@@ -623,7 +591,7 @@ export const requestMachine =
}, },
}), }),
prependReceivedVc: send( prependReceivedVcMetadata: send(
context => { context => {
if (context.incomingVc) { if (context.incomingVc) {
context.incomingVc.vcMetadata.timestamp = Date.now(); context.incomingVc.vcMetadata.timestamp = Date.now();
@@ -636,22 +604,11 @@ export const requestMachine =
{to: context => context.serviceRefs.store}, {to: context => context.serviceRefs.store},
), ),
requestExistingVc: send( removeReceivedVcMetadataFromStorage: send(
context => context => {
StoreEvents.GET(VCMetadata.fromVC(context.incomingVc).getVcKey()), return StoreEvents.REMOVE_VC_METADATA(
{to: context => context.serviceRefs.store}, RECEIVED_VCS_STORE_KEY,
), VCMetadata.fromVC(context.incomingVc?.vcMetadata).getVcKey(),
mergeIncomingVc: send(
(context, event) => {
const existing = event.response as VC;
const updated: VC = {
...existing,
reason: existing.reason.concat(context.incomingVc.reason),
};
return StoreEvents.SET(
VCMetadata.fromVC(updated).getVcKey(),
updated,
); );
}, },
{to: context => context.serviceRefs.store}, {to: context => context.serviceRefs.store},
@@ -699,14 +656,9 @@ export const requestMachine =
{to: context => context.serviceRefs.activityLog}, {to: context => context.serviceRefs.activityLog},
), ),
sendVcReceived: send( sendVcReceived: send(VcEvents.REFRESH_RECEIVED_VCS(), {
context => { to: context => context.serviceRefs.vc,
return VcEvents.VC_RECEIVED( }),
VCMetadata.fromVC(context.incomingVc?.vcMetadata),
);
},
{to: context => context.serviceRefs.vc},
),
clearShouldVerifyPresence: assign({ clearShouldVerifyPresence: assign({
incomingVc: context => ({ incomingVc: context => ({

View File

@@ -0,0 +1,190 @@
// This file was automatically generated. Edits will be overwritten
export interface Typegen0 {
'@@xstate/typegen': true;
internalEvents: {
'': {type: ''};
'done.invoke.request.checkStorage:invocation[0]': {
type: 'done.invoke.request.checkStorage:invocation[0]';
data: unknown;
__tip: 'See the XState TS docs to learn how to strongly type this.';
};
'done.invoke.request.reviewing.verifyingVp:invocation[0]': {
type: 'done.invoke.request.reviewing.verifyingVp:invocation[0]';
data: unknown;
__tip: 'See the XState TS docs to learn how to strongly type this.';
};
'xstate.after(DESTROY_TIMEOUT)#request.clearingConnection': {
type: 'xstate.after(DESTROY_TIMEOUT)#request.clearingConnection';
};
'xstate.after(SHARING_TIMEOUT)#request.waitingForVc.inProgress': {
type: 'xstate.after(SHARING_TIMEOUT)#request.waitingForVc.inProgress';
};
'xstate.init': {type: 'xstate.init'};
'xstate.stop': {type: 'xstate.stop'};
};
invokeSrcNameMap: {
advertiseDevice: 'done.invoke.request.waitingForConnection:invocation[0]';
checkBluetoothService: 'done.invoke.request.checkingBluetoothService.checking:invocation[0]';
checkNearByDevicesPermission: 'done.invoke.request.checkNearbyDevicesPermission.checking:invocation[0]';
checkStorageAvailability: 'done.invoke.request.checkStorage:invocation[0]';
disconnect:
| 'done.invoke.request.clearingConnection:invocation[0]'
| 'done.invoke.request.reviewing.navigatingToHistory:invocation[0]'
| 'done.invoke.request.reviewing.navigatingToHome:invocation[0]';
monitorConnection: 'done.invoke.request:invocation[0]';
receiveVc: 'done.invoke.request.waitingForVc:invocation[0]';
requestBluetooth: 'done.invoke.request.checkingBluetoothService.requesting:invocation[0]';
requestNearByDevicesPermission: 'done.invoke.request.checkNearbyDevicesPermission.requesting:invocation[0]';
sendVcResponse:
| 'done.invoke.request.reviewing.accepted:invocation[0]'
| 'done.invoke.request.reviewing.rejected:invocation[0]'
| 'done.invoke.request.reviewing.savingFailed:invocation[0]';
verifyVp: 'done.invoke.request.reviewing.verifyingVp:invocation[0]';
};
missingImplementations: {
actions: never;
delays: never;
guards: never;
services: never;
};
eventsCausingActions: {
clearShouldVerifyPresence:
| 'ACCEPT'
| 'BLE_ERROR'
| 'CANCEL'
| 'FACE_INVALID'
| 'FACE_VALID'
| 'REJECT'
| 'RESET'
| 'SCREEN_BLUR'
| 'SCREEN_FOCUS'
| 'xstate.stop';
logReceived: 'CANCEL' | 'REJECT' | 'STORE_ERROR' | 'STORE_RESPONSE';
openAppPermission: 'GOTO_SETTINGS';
prependReceivedVcMetadata:
| 'ACCEPT'
| 'DISMISS'
| 'FACE_VALID'
| 'VC_RECEIVED'
| 'done.invoke.request.reviewing.verifyingVp:invocation[0]';
registerLoggers:
| 'DISCONNECT'
| 'RESET'
| 'xstate.after(DESTROY_TIMEOUT)#request.clearingConnection';
removeLoggers:
| 'DISCONNECT'
| 'RESET'
| 'SCREEN_BLUR'
| 'xstate.after(DESTROY_TIMEOUT)#request.clearingConnection'
| 'xstate.init';
removeReceivedVcMetadataFromStorage: 'STORE_ERROR';
sendBLEConnectionErrorEvent: 'BLE_ERROR';
sendVCReceiveFailedEvent: 'FACE_INVALID';
sendVCReceiveFlowTimeoutEndEvent: 'CANCEL';
sendVCReceiveRejectedEvent: 'CANCEL' | 'REJECT' | 'STORE_ERROR';
sendVCReceiveSuccessEvent: 'STORE_RESPONSE';
sendVCReceivingDisconnectedEvent: 'DISCONNECT';
sendVCReceivingStartEvent: 'CONNECTED';
sendVCReceivingTerminatedEvent: 'CANCEL';
sendVcReceived: 'STORE_RESPONSE';
setBleError: 'BLE_ERROR';
setIncomingVc: 'VC_RECEIVED';
setOpenID4VpUri: 'ADV_STARTED';
setReadyForBluetoothStateCheck: 'NEARBY_ENABLED';
setReceiveLogTypeDiscarded: 'CANCEL' | 'REJECT' | 'STORE_ERROR';
setReceiveLogTypeRegular: 'ACCEPT' | 'STORE_RESPONSE';
setReceiveLogTypeUnverified: 'FACE_INVALID';
setReceiveLogTypeVerified: 'FACE_VALID';
setReceiverInfo: 'CONNECTED';
setSenderInfo: 'CONNECTED';
storeVc: 'STORE_RESPONSE';
};
eventsCausingDelays: {
DESTROY_TIMEOUT: '' | 'DISMISS';
SHARING_TIMEOUT: 'CONNECTED';
};
eventsCausingGuards: {
isMinimumStorageLimitReached: 'done.invoke.request.checkStorage:invocation[0]';
};
eventsCausingServices: {
advertiseDevice:
| 'DISCONNECT'
| 'RESET'
| 'xstate.after(DESTROY_TIMEOUT)#request.clearingConnection';
checkBluetoothService: 'NEARBY_ENABLED';
checkNearByDevicesPermission:
| 'APP_ACTIVE'
| 'RESET'
| 'done.invoke.request.checkStorage:invocation[0]';
checkStorageAvailability: 'SCREEN_FOCUS';
disconnect: '' | 'DISMISS' | 'GO_TO_RECEIVED_VC_TAB';
monitorConnection: 'xstate.init';
receiveVc: 'CONNECTED';
requestBluetooth: 'BLUETOOTH_STATE_DISABLED';
requestNearByDevicesPermission: 'NEARBY_DISABLED';
sendVcResponse: 'CANCEL' | 'REJECT' | 'STORE_ERROR' | 'STORE_RESPONSE';
verifyVp: never;
};
matchesStates:
| 'bluetoothDenied'
| 'cancelling'
| 'checkNearbyDevicesPermission'
| 'checkNearbyDevicesPermission.checking'
| 'checkNearbyDevicesPermission.requesting'
| 'checkStorage'
| 'checkingBluetoothService'
| 'checkingBluetoothService.checking'
| 'checkingBluetoothService.enabled'
| 'checkingBluetoothService.requesting'
| 'clearingConnection'
| 'disconnected'
| 'handlingBleError'
| 'inactive'
| 'nearByDevicesPermissionDenied'
| 'reviewing'
| 'reviewing.accepted'
| 'reviewing.accepting'
| 'reviewing.accepting.prependingReceivedVcMetadata'
| 'reviewing.accepting.storingVc'
| 'reviewing.displayingIncomingVC'
| 'reviewing.idle'
| 'reviewing.invalidIdentity'
| 'reviewing.navigatingToHistory'
| 'reviewing.navigatingToHome'
| 'reviewing.navigatingToReceivedCards'
| 'reviewing.rejected'
| 'reviewing.savingFailed'
| 'reviewing.savingFailed.idle'
| 'reviewing.savingFailed.viewingVc'
| 'reviewing.verifyingIdentity'
| 'reviewing.verifyingVp'
| 'storageLimitReached'
| 'waitingForConnection'
| 'waitingForVc'
| 'waitingForVc.inProgress'
| 'waitingForVc.timeout'
| {
checkNearbyDevicesPermission?: 'checking' | 'requesting';
checkingBluetoothService?: 'checking' | 'enabled' | 'requesting';
reviewing?:
| 'accepted'
| 'accepting'
| 'displayingIncomingVC'
| 'idle'
| 'invalidIdentity'
| 'navigatingToHistory'
| 'navigatingToHome'
| 'navigatingToReceivedCards'
| 'rejected'
| 'savingFailed'
| 'verifyingIdentity'
| 'verifyingVp'
| {
accepting?: 'prependingReceivedVcMetadata' | 'storingVc';
savingFailed?: 'idle' | 'viewingVc';
};
waitingForVc?: 'inProgress' | 'timeout';
};
tags: never;
}

View File

@@ -69,7 +69,6 @@ const model = createModel(
selectedVc: {} as VC, selectedVc: {} as VC,
bleError: {} as BLEError, bleError: {} as BLEError,
createdVp: null as VC, createdVp: null as VC,
reason: '',
loggers: [] as EmitterSubscription[], loggers: [] as EmitterSubscription[],
vcName: '', vcName: '',
verificationImage: {} as CameraCapturedPicture, verificationImage: {} as CameraCapturedPicture,
@@ -107,7 +106,6 @@ const model = createModel(
NEARBY_DISABLED: () => ({}), NEARBY_DISABLED: () => ({}),
GOTO_SETTINGS: () => ({}), GOTO_SETTINGS: () => ({}),
START_PERMISSION_CHECK: () => ({}), START_PERMISSION_CHECK: () => ({}),
UPDATE_REASON: (reason: string) => ({reason}),
LOCATION_ENABLED: () => ({}), LOCATION_ENABLED: () => ({}),
LOCATION_DISABLED: () => ({}), LOCATION_DISABLED: () => ({}),
LOCATION_REQUEST: () => ({}), LOCATION_REQUEST: () => ({}),
@@ -494,14 +492,11 @@ export const scanMachine =
}, },
reviewing: { reviewing: {
entry: ['resetShouldVerifyPresence'], entry: ['resetShouldVerifyPresence'],
exit: ['clearReason', 'clearCreatedVp'], exit: ['clearCreatedVp'],
initial: 'selectingVc', initial: 'selectingVc',
states: { states: {
selectingVc: { selectingVc: {
on: { on: {
UPDATE_REASON: {
actions: 'setReason',
},
DISCONNECT: { DISCONNECT: {
target: '#scan.disconnected', target: '#scan.disconnected',
}, },
@@ -805,12 +800,6 @@ export const scanMachine =
bleError: (_context, event) => event.bleError, bleError: (_context, event) => event.bleError,
}), }),
setReason: model.assign({
reason: (_context, event) => event.reason,
}),
clearReason: assign({reason: ''}),
setSelectedVc: assign({ setSelectedVc: assign({
selectedVc: (context, event) => { selectedVc: (context, event) => {
return { return {
@@ -1140,11 +1129,6 @@ export const scanMachine =
...(vp != null ? vp : context.selectedVc), ...(vp != null ? vp : context.selectedVc),
}; };
const reason = [];
if (context.reason.trim() !== '') {
reason.push({message: context.reason, timestamp: Date.now()});
}
const statusCallback = (event: WalletDataEvent) => { const statusCallback = (event: WalletDataEvent) => {
if (event.type === EventTypes.onDataSent) { if (event.type === EventTypes.onDataSent) {
callback({type: 'VC_SENT'}); callback({type: 'VC_SENT'});
@@ -1160,7 +1144,6 @@ export const scanMachine =
wallet.sendData( wallet.sendData(
JSON.stringify({ JSON.stringify({
...vc, ...vc,
reason,
}), }),
); );
const subscription = subscribe(statusCallback); const subscription = subscribe(statusCallback);

View File

@@ -62,15 +62,6 @@ export interface Typegen0 {
| 'SCREEN_BLUR' | 'SCREEN_BLUR'
| 'SCREEN_FOCUS' | 'SCREEN_FOCUS'
| 'xstate.stop'; | 'xstate.stop';
clearReason:
| ''
| 'BLE_ERROR'
| 'DISCONNECT'
| 'DISMISS'
| 'RESET'
| 'SCREEN_BLUR'
| 'SCREEN_FOCUS'
| 'xstate.stop';
clearUri: clearUri:
| 'DISCONNECT' | 'DISCONNECT'
| 'DISMISS' | 'DISMISS'
@@ -104,7 +95,6 @@ export interface Typegen0 {
setCreatedVp: 'done.invoke.scan.reviewing.creatingVp:invocation[0]'; setCreatedVp: 'done.invoke.scan.reviewing.creatingVp:invocation[0]';
setLinkCode: 'SCAN'; setLinkCode: 'SCAN';
setReadyForBluetoothStateCheck: 'BLUETOOTH_PERMISSION_ENABLED'; setReadyForBluetoothStateCheck: 'BLUETOOTH_PERMISSION_ENABLED';
setReason: 'UPDATE_REASON';
setReceiverInfo: 'CONNECTED'; setReceiverInfo: 'CONNECTED';
setSelectedVc: 'SELECT_VC'; setSelectedVc: 'SELECT_VC';
setSenderInfo: 'CONNECTED'; setSenderInfo: 'CONNECTED';

View File

@@ -7,10 +7,6 @@ export function selectReceiverInfo(state: State) {
return state.context.receiverInfo; return state.context.receiverInfo;
} }
export function selectReason(state: State) {
return state.context.reason;
}
export function selectVcName(state: State) { export function selectVcName(state: State) {
return state.context.vcName; return state.context.vcName;
} }

View File

@@ -12,7 +12,12 @@ import {
import {createModel} from 'xstate/lib/model'; import {createModel} from 'xstate/lib/model';
import {generateSecureRandom} from 'react-native-securerandom'; import {generateSecureRandom} from 'react-native-securerandom';
import {log} from 'xstate/lib/actions'; import {log} from 'xstate/lib/actions';
import {isIOS, MY_VCS_STORE_KEY, SETTINGS_STORE_KEY} from '../shared/constants'; import {
isIOS,
MY_VCS_STORE_KEY,
RECEIVED_VCS_STORE_KEY,
SETTINGS_STORE_KEY,
} from '../shared/constants';
import SecureKeystore from '@mosip/secure-keystore'; import SecureKeystore from '@mosip/secure-keystore';
import { import {
AUTH_TIMEOUT, AUTH_TIMEOUT,
@@ -711,7 +716,18 @@ export async function removeItem(
try { try {
if (value === null && VCMetadata.isVCKey(key)) { if (value === null && VCMetadata.isVCKey(key)) {
await Storage.removeItem(key); await Storage.removeItem(key);
await removeVCMetaData(MY_VCS_STORE_KEY, key, encryptionKey); const myVcs: VCMetadata[] = (await Storage.getItem(
MY_VCS_STORE_KEY,
encryptionKey,
)) as VCMetadata[];
const isTamperedVcInMyVCs = !!myVcs?.filter(
(vcMetadata: VCMetadata) => vcMetadata.getVcKey() === key,
).length;
if (isTamperedVcInMyVCs) {
await removeVCMetaData(MY_VCS_STORE_KEY, key, encryptionKey);
} else {
await removeVCMetaData(RECEIVED_VCS_STORE_KEY, key, encryptionKey);
}
} else if (key === MY_VCS_STORE_KEY) { } else if (key === MY_VCS_STORE_KEY) {
const data = await Storage.getItem(key, encryptionKey); const data = await Storage.getItem(key, encryptionKey);
let list: Object[] = []; let list: Object[] = [];

View File

@@ -6,7 +6,6 @@ import {ExistingMosipVCItemMachine} from '../../machines/VCItemMachine/ExistingM
import {GlobalContext} from '../../shared/GlobalContext'; import {GlobalContext} from '../../shared/GlobalContext';
import { import {
selectIsSelectingVc, selectIsSelectingVc,
selectReason,
selectReceiverInfo, selectReceiverInfo,
selectSelectedVc, selectSelectedVc,
selectVcName, selectVcName,
@@ -40,7 +39,6 @@ export function useSendVcScreen() {
}, },
receiverInfo: useSelector(scanService, selectReceiverInfo), receiverInfo: useSelector(scanService, selectReceiverInfo),
reason: useSelector(scanService, selectReason),
vcName: useSelector(scanService, selectVcName), vcName: useSelector(scanService, selectVcName),
shareableVcsMetadata: useSelector(vcService, selectShareableVcsMetadata), shareableVcsMetadata: useSelector(vcService, selectShareableVcsMetadata),
selectedVc: useSelector(scanService, selectSelectedVc), selectedVc: useSelector(scanService, selectSelectedVc),
@@ -55,8 +53,6 @@ export function useSendVcScreen() {
VERIFY_AND_ACCEPT_REQUEST: () => VERIFY_AND_ACCEPT_REQUEST: () =>
scanService.send(ScanEvents.VERIFY_AND_ACCEPT_REQUEST()), scanService.send(ScanEvents.VERIFY_AND_ACCEPT_REQUEST()),
DISMISS: () => scanService.send(ScanEvents.DISMISS()), DISMISS: () => scanService.send(ScanEvents.DISMISS()),
UPDATE_REASON: (reason: string) =>
scanService.send(ScanEvents.UPDATE_REASON(reason)),
UPDATE_VC_NAME: (vcName: string) => UPDATE_VC_NAME: (vcName: string) =>
scanService.send(ScanEvents.UPDATE_VC_NAME(vcName)), scanService.send(ScanEvents.UPDATE_VC_NAME(vcName)),
FACE_VALID: () => scanService.send(ScanEvents.FACE_VALID()), FACE_VALID: () => scanService.send(ScanEvents.FACE_VALID()),

View File

@@ -10,7 +10,6 @@ export interface VC {
requestId?: string; requestId?: string;
isVerified?: boolean; isVerified?: boolean;
lastVerifiedOn: number; lastVerifiedOn: number;
reason?: VCSharingReason[];
shouldVerifyPresence?: boolean; shouldVerifyPresence?: boolean;
walletBindingResponse?: WalletBindingResponse; walletBindingResponse?: WalletBindingResponse;
credentialRegistry?: string; credentialRegistry?: string;
@@ -18,11 +17,6 @@ export interface VC {
hashedId?: string; hashedId?: string;
} }
export interface VCSharingReason {
timestamp: number;
message: string;
}
export type VcIdType = 'UIN' | 'VID'; export type VcIdType = 'UIN' | 'VID';
export interface DecodedCredential { export interface DecodedCredential {

View File

@@ -12,18 +12,12 @@ export interface VC {
isVerified: boolean; isVerified: boolean;
lastVerifiedOn: number; lastVerifiedOn: number;
locked: boolean; locked: boolean;
reason?: VCSharingReason[];
shouldVerifyPresence?: boolean; shouldVerifyPresence?: boolean;
walletBindingResponse?: WalletBindingResponse; walletBindingResponse?: WalletBindingResponse;
credentialRegistry?: string; credentialRegistry?: string;
isPinned?: boolean; isPinned?: boolean;
} }
export interface VCSharingReason {
timestamp: number;
message: string;
}
export type VcIdType = 'UIN' | 'VID'; export type VcIdType = 'UIN' | 'VID';
export interface DecodedCredential { export interface DecodedCredential {