mirror of
https://github.com/mosip/inji-wallet.git
synced 2026-01-07 20:53:54 -05:00
* [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>
82 lines
2.0 KiB
TypeScript
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;
|