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

fix the issue of received vc getting stuck in loading state in the verifier #1307

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const model = createModel(
generatedOn: new Date() as Date,
credential: null as DecodedCredential,
verifiableCredential: null as VerifiableCredential,
storeVerifiableCredential: null as VerifiableCredential,
requestId: '',
lastVerifiedOn: null,
locked: false,
Expand Down Expand Up @@ -144,7 +143,7 @@ export const ExistingMosipVCItemMachine =
on: {
GET_VC_RESPONSE: [
{
actions: ['setCredential', 'setStoreVerifiableCredential'],
actions: 'setCredential',
cond: 'hasCredential',
target: 'checkingVerificationStatus',
},
Expand All @@ -160,11 +159,7 @@ export const ExistingMosipVCItemMachine =
on: {
STORE_RESPONSE: [
{
actions: [
'setCredential',
'setStoreVerifiableCredential',
'updateVc',
],
actions: ['setCredential', 'updateVc'],
cond: 'hasCredential',
target: 'checkingVerificationStatus',
},
Expand Down Expand Up @@ -244,7 +239,7 @@ export const ExistingMosipVCItemMachine =
},
],
CREDENTIAL_DOWNLOADED: {
actions: ['setStoreVerifiableCredential'],
actions: 'setCredential',
target: '#vc-item.checkingVerificationStatus',
},
},
Expand Down Expand Up @@ -387,7 +382,7 @@ export const ExistingMosipVCItemMachine =
src: 'verifyCredential',
onDone: [
{
actions: ['setVerifiableCredential', 'storeContext'],
actions: ['storeContext'],
},
],
onError: [
Expand Down Expand Up @@ -788,32 +783,6 @@ export const ExistingMosipVCItemMachine =
},
{
actions: {
setVerifiableCredential: assign(context => {
return {
...context,
verifiableCredential: {
...context.storeVerifiableCredential,
},
storeVerifiableCredential: null,
vcMetadata: context.vcMetadata,
};
}),

setStoreVerifiableCredential: model.assign((context, event) => {
// the VC can be set in response key iff STORE_RESPONSE event comes
// and in vc iff CREDENTIAL_DOWNLOADED event
const eventResponse = event?.response ? event.response : event?.vc;
return {
...context,
...eventResponse,
storeVerifiableCredential: {
...eventResponse.verifiableCredential,
},
verifiableCredential: null,
vcMetadata: context.vcMetadata,
};
}),

removeVcMetaDataFromStorage: send(
context => {
return StoreEvents.REMOVE_VC_METADATA(
Expand Down Expand Up @@ -1133,7 +1102,6 @@ export const ExistingMosipVCItemMachine =
return {
...context,
...event.vc,
vcMetadata: context.vcMetadata,
};
}
}),
Expand Down Expand Up @@ -1465,9 +1433,9 @@ export const ExistingMosipVCItemMachine =
},

verifyCredential: async context => {
if (context.storeVerifiableCredential) {
if (context.verifiableCredential) {
const verificationResult = await verifyCredential(
context.storeVerifiableCredential,
context.verifiableCredential,
);
if (!verificationResult.isVerified) {
throw new Error(verificationResult.errorMessage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,10 @@ export interface Typegen0 {
sendVcUpdated: 'PIN_CARD';
sendVerificationError: 'STORE_RESPONSE';
sendWalletBindingSuccess: 'SHOW_BINDING_STATUS';
setCredential: 'GET_VC_RESPONSE' | 'STORE_RESPONSE';
setCredential:
| 'CREDENTIAL_DOWNLOADED'
| 'GET_VC_RESPONSE'
| 'STORE_RESPONSE';
setDownloadInterval: 'done.invoke.vc-item.checkingServerData.loadDownloadLimitConfig:invocation[0]';
setLock: 'done.invoke.vc-item.requestingLock:invocation[0]';
setMaxDownloadCount: 'done.invoke.vc-item.checkingServerData.loadDownloadLimitConfig:invocation[0]';
Expand All @@ -221,10 +224,6 @@ export interface Typegen0 {
setPrivateKey: 'done.invoke.vc-item.addKeyPair:invocation[0]';
setPublicKey: 'done.invoke.vc-item.addKeyPair:invocation[0]';
setRevoke: 'done.invoke.vc-item.requestingRevoke:invocation[0]';
setStoreVerifiableCredential:
| 'CREDENTIAL_DOWNLOADED'
| 'GET_VC_RESPONSE'
| 'STORE_RESPONSE';
setTempWalletBindingResponse: 'done.invoke.vc-item.addingWalletBindingId:invocation[0]';
setThumbprintForWalletBindingId:
| 'done.invoke.vc-item.addingWalletBindingId:invocation[0]'
Expand All @@ -237,7 +236,6 @@ export interface Typegen0 {
| 'error.platform.vc-item.requestingRevoke:invocation[0]';
setVcKey: 'REMOVE';
setVcMetadata: 'UPDATE_VC_METADATA';
setVerifiableCredential: 'done.invoke.vc-item.verifyingCredential:invocation[0]';
setWalletBindingError:
| 'error.platform.vc-item.acceptingBindingOtp.resendOTP:invocation[0]'
| 'error.platform.vc-item.addKeyPair:invocation[0]'
Expand Down
Loading