1- import type { V2ProofFormatSpec } from '../formats/V2ProofFormat '
1+ import type { ProofAttachmentFormat } from '../../../ formats/models/ProofFormatServiceOptions '
22
33import { Expose , Type } from 'class-transformer'
4- import { Equals , IsArray , IsInstance , IsOptional , IsString , ValidateNested } from 'class-validator'
4+ import { Equals , IsArray , IsBoolean , IsInstance , IsOptional , IsString , ValidateNested } from 'class-validator'
55
66import { AgentMessage } from '../../../../../agent/AgentMessage'
7- import { Attachment } from '../../../../../decorators/attachment/Attachment'
87import { uuid } from '../../../../../utils/uuid'
9- import { PresentationPreview } from '../../v1/models/PresentationPreview'
10- import { PRES_20_PROPOSAL } from '../formats/MessageTypes'
8+ import { ProofFormatSpec } from '../../../formats/models/ProofFormatServiceOptions'
9+
10+ import { Attachment } from 'packages/core/src/decorators/attachment/Attachment'
1111
1212export interface V2ProposePresentationMessageOptions {
1313 id ?: string
14- formats : V2ProofFormatSpec
14+ formats : ProofFormatSpec
1515 filtersAttach : Attachment [ ]
1616 comment ?: string
17- presentationProposal : PresentationPreview
17+ goalCode ?: string
18+ willConfirm ?: boolean
19+ attachmentInfo : ProofAttachmentFormat [ ]
1820}
1921
2022export class V2ProposalPresentationMessage extends AgentMessage {
@@ -23,40 +25,48 @@ export class V2ProposalPresentationMessage extends AgentMessage {
2325 if ( options ) {
2426 this . id = options . id ?? uuid ( )
2527 this . comment = options . comment
26- this . presentationProposal = options . presentationProposal
27- this . formats = options . formats
28- this . filtersAttach = options . filtersAttach
28+ this . goalCode = options . goalCode
29+ this . willConfirm = options . willConfirm ?? false
30+
31+ for ( const entry of options . attachmentInfo ) {
32+ this . addProposalsAttachment ( entry )
33+ }
2934 }
3035 }
3136
37+ public addProposalsAttachment ( attachment : ProofAttachmentFormat ) {
38+ this . formats . push ( attachment . format )
39+ this . proposalsAttach . push ( attachment . attachment )
40+ }
41+
3242 @Equals ( V2ProposalPresentationMessage . type )
3343 public readonly type = V2ProposalPresentationMessage . type
34- public static readonly type = `https://didcomm.org/${ PRES_20_PROPOSAL } `
35-
36- @Expose ( { name : 'filters~attach' } )
37- @Type ( ( ) => Attachment )
38- @IsArray ( )
39- @ValidateNested ( {
40- each : true ,
41- } )
42- @IsInstance ( Attachment , { each : true } )
43- public filtersAttach ! : Attachment [ ]
44+ public static readonly type = `https://didcomm.org/present-proof/2.0/propose-presentation`
4445
45- /**
46- * Provides some human readable information about the proposed presentation.
47- */
4846 @IsString ( )
4947 @IsOptional ( )
5048 public comment ?: string
5149
52- /**
53- * Represents the presentation example that prover wants to provide.
54- */
55- @Expose ( { name : 'presentation_proposal' } )
56- @Type ( ( ) => PresentationPreview )
57- @ValidateNested ( )
58- @IsInstance ( PresentationPreview )
59- public presentationProposal ! : PresentationPreview
50+ @Expose ( { name : 'goal_code' } )
51+ @IsString ( )
52+ @IsOptional ( )
53+ public goalCode ?: string
54+
55+ @Expose ( { name : 'will_confirm' } )
56+ @IsBoolean ( )
57+ public willConfirm = false
58+
59+ @Expose ( { name : 'formats' } )
60+ @Type ( ( ) => ProofFormatSpec )
61+ @IsArray ( )
62+ @ValidateNested ( { each : true } )
63+ @IsInstance ( ProofFormatSpec , { each : true } )
64+ public formats ! : ProofFormatSpec [ ]
6065
61- public formats ! : V2ProofFormatSpec
66+ @Expose ( { name : 'proposals~attach' } )
67+ @Type ( ( ) => Attachment )
68+ @IsArray ( )
69+ @ValidateNested ( { each : true } )
70+ @IsInstance ( Attachment , { each : true } )
71+ public proposalsAttach ! : Attachment [ ]
6272}
0 commit comments