Skip to content

Commit b304eaf

Browse files
committed
fix: added validityInfo for credential validity check
Signed-off-by: Rinkal Bhojani <[email protected]>
1 parent eaf18d4 commit b304eaf

File tree

7 files changed

+529
-360
lines changed

7 files changed

+529
-360
lines changed

apps/api-gateway/src/oid4vc-issuance/dtos/issuer-sessions.dto.ts

Lines changed: 54 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
} from 'class-validator';
2222
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
2323
import { Type } from 'class-transformer';
24+
import { dateToSeconds } from '@credebl/common/date-only';
2425

2526
/* ========= disclosureFrame custom validator ========= */
2627
function isDisclosureFrameValue(v: unknown): boolean {
@@ -117,6 +118,24 @@ function ExactlyOneOf(keys: string[], options?: ValidationOptions) {
117118
return Validate(ExactlyOneOfConstraint, keys, options);
118119
}
119120

121+
export class ValidityInfo {
122+
@ApiProperty({
123+
example: '2025-04-23T14:34:09.188Z',
124+
required: true
125+
})
126+
@IsString()
127+
@IsNotEmpty()
128+
validFrom: Date;
129+
130+
@ApiProperty({
131+
example: '2026-05-03T14:34:09.188Z',
132+
required: true
133+
})
134+
@IsString()
135+
@IsNotEmpty()
136+
validUntil: Date;
137+
}
138+
120139
/* ========= Request DTOs ========= */
121140
export class CredentialRequestDto {
122141
@ApiProperty({
@@ -137,13 +156,20 @@ export class CredentialRequestDto {
137156
payload!: Record<string, unknown>;
138157

139158
@ApiPropertyOptional({
140-
description: 'Selective disclosure: claim -> boolean (or nested map)',
141-
example: { name: true, DOB: true, additionalProp3: false },
159+
example: { validFrom: '2025-04-23T14:34:09.188Z', validUntil: '2026-05-03T14:34:09.188Z' },
142160
required: false
143161
})
144162
@IsOptional()
145-
@IsDisclosureFrame()
146-
disclosureFrame?: Record<string, boolean | Record<string, boolean>>;
163+
validityInfo?: ValidityInfo;
164+
165+
// @ApiPropertyOptional({
166+
// description: 'Selective disclosure: claim -> boolean (or nested map)',
167+
// example: { name: true, DOB: true, additionalProp3: false },
168+
// required: false
169+
// })
170+
// @IsOptional()
171+
// @IsDisclosureFrame()
172+
// disclosureFrame?: Record<string, boolean | Record<string, boolean>>;
147173
}
148174

149175
export class CreateOidcCredentialOfferDto {
@@ -257,20 +283,33 @@ export class CredentialDto {
257283

258284
@ApiProperty({
259285
description: 'Credential payload (namespace data, validity info, etc.)',
260-
example: {
261-
namespaces: {
262-
'org.iso.23220.photoID.1': {
263-
birth_date: '1970-02-14',
264-
family_name: 'Müller-Lüdenscheid',
265-
given_name: 'Ford Praxibetel',
266-
document_number: 'LA001801M'
286+
example: [
287+
{
288+
namespaces: {
289+
'org.iso.23220.photoID.1': {
290+
birth_date: '1970-02-14',
291+
family_name: 'Müller-Lüdenscheid',
292+
given_name: 'Ford Praxibetel',
293+
document_number: 'LA001801M'
294+
}
295+
},
296+
validityInfo: {
297+
validFrom: '2025-04-23T14:34:09.188Z',
298+
validUntil: '2026-05-03T14:34:09.188Z'
267299
}
268300
},
269-
validityInfo: {
270-
validFrom: '2025-04-23T14:34:09.188Z',
271-
validUntil: '2026-05-03T14:34:09.188Z'
301+
{
302+
full_name: 'Garry',
303+
address: {
304+
street_address: 'M.G. Road',
305+
locality: 'Pune',
306+
country: 'India'
307+
},
308+
iat: 1698151532,
309+
nbf: dateToSeconds(new Date()),
310+
exp: dateToSeconds(new Date(Date.now() + 5 * 365 * 24 * 60 * 60 * 1000))
272311
}
273-
}
312+
]
274313
})
275314
@ValidateNested()
276315
payload: object;

apps/oid4vc-issuance/interfaces/oid4vc-issuer-sessions.interfaces.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ export enum AuthenticationType {
3030
export type DisclosureFrame = Record<string, boolean | Record<string, boolean>>;
3131

3232
export interface CredentialPayload {
33-
validityInfo: {
34-
validFrom: Date;
35-
validUntil: Date;
36-
};
3733
[key: string]: unknown; // extensible for mDoc or other formats
3834
}
3935

4036
export interface CredentialRequest {
41-
credentialSupportedId?: string;
37+
// credentialSupportedId?: string;
4238
templateId: string;
43-
format: CredentialFormat; // "vc+sd-jwt" | "mso_mdoc"
39+
// format: CredentialFormat; // "vc+sd-jwt" | "mso_mdoc"
4440
payload: CredentialPayload; // user-supplied payload (without vct)
45-
disclosureFrame?: DisclosureFrame; // only relevant for vc+sd-jwt
41+
// disclosureFrame?: DisclosureFrame; // only relevant for vc+sd-jwt
42+
validityInfo?: {
43+
validFrom: Date;
44+
validUntil: Date;
45+
};
4646
}
4747

4848
export interface CreateOidcCredentialOffer {

apps/oid4vc-issuance/interfaces/oid4vc-template.interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export interface ClaimDisplay {
4343
}
4444

4545
export interface Claim {
46-
path: string[];
46+
path?: string[];
4747
display?: ClaimDisplay[];
4848
mandatory?: boolean;
4949
}

0 commit comments

Comments
 (0)