Files
inji-wallet/shared/vcVerifier/VcVerifier.ts
KiruthikaJeyashankar 9457ad0d9f [INJIMOB-3647] refactor: update isRevoked data type (#2149)
* [INJIMOB-3647] refactor: modify data type of isRevoked to EvaluationStatus

Type representing any possible value of EvaluationStatus.

- "TRUE" → Condition was evaluated and is positively true
- "FALSE" → Condition was evaluated and is definitively false
- "UNDETERMINED" → Condition could not be evaluated due to an error

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3647] refactor: modify data type of isRevoked to EvaluationStatus

Type representing any possible value of EvaluationStatus.

- "TRUE" → Condition was evaluated and is positively true
- "FALSE" → Condition was evaluated and is definitively false
- "UNDETERMINED" → Condition could not be evaluated due to an error

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3647] refactor: change statuslistVC type to record from string

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

# Conflicts:
#	shared/vcjs/verifyCredential.ts

* [INJIMOB-3647] refactor: update status revoke check to check for null status

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3647] refactor: VCMetadat constructor isRevoked param

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3647] refactor: rename EvaluationStatus to RevocationStatus

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3647] refactor: modify revocation status logs

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

---------

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>
2025-12-01 11:28:11 +05:30

82 lines
2.0 KiB
TypeScript

import {NativeModules} from 'react-native';
export const RevocationStatus = Object.freeze({
TRUE: 'TRUE',
FALSE: 'FALSE',
UNDETERMINED: 'UNDETERMINED',
} as const);
/**
* Type representing any possible value of RevocationStatus.
*
* - "TRUE" → Condition was evaluated and is positively true
* - "FALSE" → Condition was evaluated and is definitively false
* - "UNDETERMINED" → Condition could not be evaluated due to an error
*/
export type RevocationStatusType =
(typeof RevocationStatus)[keyof typeof RevocationStatus];
export type CredentialStatusResult = {
isValid: boolean;
error?: ErrorResult;
statusListVC?: Record<string, any>; // Available only in iOS
};
export type ErrorResult = {
code: string;
message: string;
};
export type VerificationSummaryResult = {
verificationStatus: boolean;
verificationMessage: string;
verificationErrorCode: string;
credentialStatus: Record<string, CredentialStatusResult>;
};
class VCVerifier {
private static instance: VCVerifier;
private vcVerifier;
private constructor() {
this.vcVerifier = NativeModules.VCVerifierModule;
}
static getInstance(): VCVerifier {
if (!VCVerifier.instance) {
VCVerifier.instance = new VCVerifier();
}
return VCVerifier.instance;
}
async getCredentialStatus(
credential: any,
format: string,
): Promise<Record<string, CredentialStatusResult>> {
try {
return await this.vcVerifier.getCredentialStatus(
JSON.stringify(credential),
format,
);
} catch (error) {
throw new Error(`Failed to get credential status: ${error}`);
}
}
async getVerificationSummary(
credentialString: string,
credentialFormat: string,
): Promise<VerificationSummaryResult> {
try {
return await this.vcVerifier.getVerificationSummary(
credentialString,
credentialFormat,
[],
);
} catch (error) {
throw new Error(`Failed to get verification summary: ${error}`);
}
}
}
export default VCVerifier;