@@ -21,6 +21,7 @@ import {
2121} from 'class-validator' ;
2222import { ApiProperty , ApiPropertyOptional } from '@nestjs/swagger' ;
2323import { Type } from 'class-transformer' ;
24+ import { dateToSeconds } from '@credebl/common/date-only' ;
2425
2526/* ========= disclosureFrame custom validator ========= */
2627function 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 ========= */
121140export 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
149175export 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 ;
0 commit comments