Skip to content

Commit

Permalink
[INJIMOB-2471] remove setting identifier field in credential wrapper
Browse files Browse the repository at this point in the history
The identitifier in credentialWrapper having the value "$issuer:$protocol:$UUID" was used to construct VC metadata id, issuer and protocol field which is already available in context param. This is now replaced with constructing VC metadata with the required fields available in machine context.

Signed-off-by: KiruthikaJeyashankar <[email protected]>
  • Loading branch information
KiruthikaJeyashankar committed Dec 23, 2024
1 parent 1d355a2 commit 87070e0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ fileignoreconfig:
- filename: injitest/README.md
checksum: 82974a6b9363512472272245e9b433f92e63377e58ba306980876b745181a09c
- filename: shared/VCMetadata.ts
checksum: 4c0f2acc58894e5a427e1317b38d04daff91f64d1e61d6ee2f246ee516ef97ca
checksum: c76bd3c825931ac241d8e4f76b8a7444789f49e3b4e45a599b4dcd574f7971c8
- filename: ios/Podfile.lock
checksum: 43bd4742f2ba13357d8b9c44430bfa3cca0bf9bf8341984fd81174a929c85955
- filename: components/BackupAndRestoreBannerNotification.tsx
Expand Down
35 changes: 18 additions & 17 deletions machines/VerifiableCredential/VCMetaMachine/vc.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,24 @@ export interface CredentialSubject {

type VCContext = (string | Record<string, unknown>)[];

export type Credential = {
credentialConfigurationId: any;
'@context': VCContext;
credentialSubject: CredentialSubject;
id: string;
issuanceDate: string;
issuer: string;
proof: {
created: string;
jws: string;
proofPurpose: 'assertionMethod' | string;
type: 'RsaSignature2018' | string;
verificationMethod: string;
};
type: string[];
} | string
export type Credential =
| {
credentialConfigurationId: any;
'@context': VCContext;
credentialSubject: CredentialSubject;
id: string;
issuanceDate: string;
issuer: string;
proof: {
created: string;
jws: string;
proofPurpose: 'assertionMethod' | string;
type: 'RsaSignature2018' | string;
verificationMethod: string;
};
type: string[];
}
| string;

export interface VerifiableCredential {
issuerLogo: logoType;
Expand All @@ -81,7 +83,6 @@ export interface VerifiableCredentialData {
export interface CredentialWrapper {
verifiableCredential: VerifiableCredential;
format: string;
identifier: string;
generatedOn: Date;
vcMetadata: VCMetadata;
}
Expand Down
20 changes: 7 additions & 13 deletions shared/VCMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import {Protocols} from './openId4VCI/Utils';
import {getMosipIdentifier} from './commonUtil';
import {VCFormat} from './VCFormat';
import {isMosipVC} from './Utils';
import {isMosipVC, UUID} from './Utils';
import {getCredentialType} from '../components/VC/common/VCUtils';

const VC_KEY_PREFIX = 'VC';
Expand Down Expand Up @@ -129,21 +129,15 @@ export function parseMetadatas(metadataStrings: object[]) {
return metadataStrings.map(o => new VCMetadata(o));
}

export const getVCMetadata = (
context: object,
keyType: string,
credType: CredentialTypes,
) => {
const [issuer, protocol, credentialId] =
context.credentialWrapper?.identifier.split(':');
export const getVCMetadata = (context: object, keyType: string) => {
const issuer = context.selectedIssuer.credential_issuer;
const credentialId = context.vcMetadata.id || `${UUID.generate()}_${issuer}`;

//TODO: Can we get the issuer and protocol as context.selectedIssuer.credential_issuer and context.selectedIssuer.protocol respectively?
// This will avoid setting identifier field in credential wrapper and splitting it to get the details
return VCMetadata.fromVC({
requestId: credentialId ?? null,
requestId: credentialId,
issuer: issuer,
protocol: protocol,
id: `${credentialId}_${issuer}`,
protocol: context.selectedIssuer.protocol,
id: credentialId,
timestamp: context.timestamp ?? '',
isVerified: context.vcMetadata.isVerified ?? false,
isExpired: context.vcMetadata.isExpired ?? false,
Expand Down
20 changes: 0 additions & 20 deletions shared/openId4VCI/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,6 @@ export const isActivationNeeded = (issuer: string) => {

export const Issuers_Key_Ref = 'OpenId4VCI_KeyPair';

export const getIdentifier = (
context,
credential: VerifiableCredential,
format: string,
) => {
const credId = UUID.generate();
return (
context.selectedIssuer.issuer_id +
':' +
context.selectedIssuer.protocol +
':' +
credId
);
};

export const updateCredentialInformation = async (
context,
credential: VerifiableCredential,
Expand All @@ -108,11 +93,6 @@ export const updateCredentialInformation = async (
return {
verifiableCredential,
format: context.selectedCredentialType.format,
identifier: getIdentifier(
context,
verifiableCredential,
context.selectedCredentialType.format,
),
generatedOn: new Date(),
vcMetadata: {
...context.vcMetadata,
Expand Down

0 comments on commit 87070e0

Please sign in to comment.