Files
inji-wallet/components/ActivityLogEvent.ts
KiruthikaJeyashankar b11aa3d49b [INJIMOB-1458] fallback issuers config if wellknown not available (#1505)
* [INJIMOB-1458] fallback to issuers config if well known is not available

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

* [INJIMOB-1458] set vc metadata id as credential ID & displayId as UIN/PolicyNUmber

Co-authored-by: Swati Goel <meet2swati@gmail.com>
Signed-off-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>

---------

Signed-off-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>
Co-authored-by: Swati Goel <meet2swati@gmail.com>
2024-06-10 10:03:52 +05:30

67 lines
1.6 KiB
TypeScript

import {getIdType} from './VC/common/VCUtils';
export type ActivityLogType =
| '' // replacement for undefined
| 'VC_SHARED'
| 'VC_RECEIVED'
| 'VC_RECEIVED_NOT_SAVED'
| 'VC_DELETED'
| 'VC_DOWNLOADED'
| 'VC_SHARED_WITH_VERIFICATION_CONSENT'
| 'VC_RECEIVED_WITH_PRESENCE_VERIFIED'
| 'VC_RECEIVED_BUT_PRESENCE_VERIFICATION_FAILED'
| 'PRESENCE_VERIFIED_AND_VC_SHARED'
| 'PRESENCE_VERIFICATION_FAILED'
| 'QRLOGIN_SUCCESFULL'
| 'WALLET_BINDING_SUCCESSFULL'
| 'WALLET_BINDING_FAILURE'
| 'VC_REMOVED'
| 'TAMPERED_VC_REMOVED';
export class ActivityLog {
id: string;
idType: string[];
_vcKey: string;
timestamp: number;
deviceName: string;
type: ActivityLogType;
issuer: string;
constructor({
id = '',
idType = [],
_vcKey = '',
type = '',
timestamp = Date.now(),
deviceName = '',
issuer = '',
} = {}) {
this.id = id;
this.idType = idType;
this._vcKey = _vcKey;
this.type = type;
this.timestamp = timestamp;
this.deviceName = deviceName;
this.issuer = issuer;
}
static logTamperedVCs() {
return {
_vcKey: '',
type: 'TAMPERED_VC_REMOVED',
timestamp: Date.now(),
deviceName: '',
vcLabel: '',
issuer: '',
};
}
}
export function getActionText(activity: ActivityLog, t, wellknown: Object) {
if (activity.idType && activity.idType.length !== 0) {
const cardType = getIdType(wellknown, activity.idType);
return `${t(activity.type, {idType: cardType, id: activity.id})}`;
}
return `${t(activity.type, {idType: '', id: activity.id})}`;
}