1
- import type { ProofFormatSpec } from '../../../formats/models/ProofFormatServiceOptions'
1
+ import type { ProofAttachmentFormat } from '../../../formats/models/ProofFormatServiceOptions'
2
2
3
3
import { 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'
5
5
6
6
import { AgentMessage } from '../../../../../agent/AgentMessage'
7
7
import { uuid } from '../../../../../utils/uuid'
8
+ import { ProofFormatSpec } from '../../../formats/models/ProofFormatServiceOptions'
8
9
import { PresentationPreview } from '../../v1/models/PresentationPreview'
9
10
10
11
import { Attachment } from 'packages/core/src/decorators/attachment/Attachment'
11
12
12
13
export interface V2ProposePresentationMessageOptions {
13
14
id ?: string
14
- formats : ProofFormatSpec
15
- filtersAttach : Attachment [ ]
16
15
comment ?: string
17
- presentationProposal : PresentationPreview
16
+ goalCode ?: string
17
+ willConfirm ?: boolean
18
+ attachmentInfo : ProofAttachmentFormat [ ]
18
19
}
19
20
20
21
export class V2ProposalPresentationMessage extends AgentMessage {
@@ -23,40 +24,48 @@ export class V2ProposalPresentationMessage extends AgentMessage {
23
24
if ( options ) {
24
25
this . id = options . id ?? uuid ( )
25
26
this . comment = options . comment
26
- this . presentationProposal = options . presentationProposal
27
- this . formats = options . formats
28
- this . filtersAttach = options . filtersAttach
27
+ this . goalCode = options . goalCode
28
+ this . willConfirm = options . willConfirm ?? false
29
+
30
+ for ( const entry of options . attachmentInfo ) {
31
+ this . addProposalsAttachment ( entry )
32
+ }
29
33
}
30
34
}
31
35
36
+ public addProposalsAttachment ( attachment : ProofAttachmentFormat ) {
37
+ this . formats . push ( attachment . format )
38
+ this . proposalsAttach . push ( attachment . attachment )
39
+ }
40
+
32
41
@Equals ( V2ProposalPresentationMessage . type )
33
42
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 [ ]
43
+ public static readonly type = `https://didcomm.org/present-proof/2.0/propose-presentation`
44
44
45
- /**
46
- * Provides some human readable information about the proposed presentation.
47
- */
48
45
@IsString ( )
49
46
@IsOptional ( )
50
47
public comment ?: string
51
48
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
49
+ @Expose ( { name : 'goal_code' } )
50
+ @IsString ( )
51
+ @IsOptional ( )
52
+ public goalCode ?: string
53
+
54
+ @Expose ( { name : 'will_confirm' } )
55
+ @IsBoolean ( )
56
+ public willConfirm = false
57
+
58
+ @Expose ( { name : 'formats' } )
59
+ @Type ( ( ) => ProofFormatSpec )
60
+ @IsArray ( )
61
+ @ValidateNested ( { each : true } )
62
+ @IsInstance ( ProofFormatSpec , { each : true } )
63
+ public formats ! : ProofFormatSpec [ ]
60
64
61
- public formats ! : ProofFormatSpec
65
+ @Expose ( { name : 'proposals~attach' } )
66
+ @Type ( ( ) => Attachment )
67
+ @IsArray ( )
68
+ @ValidateNested ( { each : true } )
69
+ @IsInstance ( Attachment , { each : true } )
70
+ public proposalsAttach ! : Attachment [ ]
62
71
}
0 commit comments