1
- import type { V2ProofFormatSpec } from '../formats/V2ProofFormat '
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
- import { Attachment } from '../../../../../decorators/attachment/Attachment'
8
7
import { 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'
11
11
12
12
export interface V2ProposePresentationMessageOptions {
13
13
id ?: string
14
- formats : V2ProofFormatSpec
14
+ formats : ProofFormatSpec
15
15
filtersAttach : Attachment [ ]
16
16
comment ?: string
17
- presentationProposal : PresentationPreview
17
+ goalCode ?: string
18
+ willConfirm ?: boolean
19
+ attachmentInfo : ProofAttachmentFormat [ ]
18
20
}
19
21
20
22
export class V2ProposalPresentationMessage extends AgentMessage {
@@ -23,40 +25,48 @@ export class V2ProposalPresentationMessage extends AgentMessage {
23
25
if ( options ) {
24
26
this . id = options . id ?? uuid ( )
25
27
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
+ }
29
34
}
30
35
}
31
36
37
+ public addProposalsAttachment ( attachment : ProofAttachmentFormat ) {
38
+ this . formats . push ( attachment . format )
39
+ this . proposalsAttach . push ( attachment . attachment )
40
+ }
41
+
32
42
@Equals ( V2ProposalPresentationMessage . type )
33
43
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`
44
45
45
- /**
46
- * Provides some human readable information about the proposed presentation.
47
- */
48
46
@IsString ( )
49
47
@IsOptional ( )
50
48
public comment ?: string
51
49
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 [ ]
60
65
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 [ ]
62
72
}
0 commit comments