Skip to content

Commit bf824d4

Browse files
fix(proofs): add missing goal_code to options
Signed-off-by: NB-Karim <[email protected]>
1 parent 7a021da commit bf824d4

File tree

3 files changed

+49
-36
lines changed

3 files changed

+49
-36
lines changed

packages/core/src/modules/proofs/protocol/v2/messages/V2PresentationMessage.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface V2PresentationMessageOptions {
1313
id?: string
1414
goalCode?: string
1515
comment?: string
16+
willConfirm?: boolean
1617
attachmentInfo: ProofAttachmentFormat[]
1718
}
1819

@@ -23,6 +24,7 @@ export class V2PresentationMessage extends AgentMessage {
2324
this.id = options.id ?? uuid()
2425
this.comment = options.comment
2526
this.goalCode = options.goalCode
27+
this.willConfirm = options.willConfirm ?? false
2628

2729
for (const entry of options.attachmentInfo) {
2830
this.addPresentationsAttachment(entry)
Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
import type { ProofFormatSpec } from '../../../formats/models/ProofFormatServiceOptions'
1+
import type { ProofAttachmentFormat } from '../../../formats/models/ProofFormatServiceOptions'
22

33
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'
55

66
import { AgentMessage } from '../../../../../agent/AgentMessage'
77
import { uuid } from '../../../../../utils/uuid'
8+
import { ProofFormatSpec } from '../../../formats/models/ProofFormatServiceOptions'
89
import { PresentationPreview } from '../../v1/models/PresentationPreview'
910

1011
import { Attachment } from 'packages/core/src/decorators/attachment/Attachment'
1112

1213
export interface V2ProposePresentationMessageOptions {
1314
id?: string
14-
formats: ProofFormatSpec
15-
filtersAttach: Attachment[]
1615
comment?: string
17-
presentationProposal: PresentationPreview
16+
goalCode?: string
17+
willConfirm?: boolean
18+
attachmentInfo: ProofAttachmentFormat[]
1819
}
1920

2021
export class V2ProposalPresentationMessage extends AgentMessage {
@@ -23,40 +24,48 @@ export class V2ProposalPresentationMessage extends AgentMessage {
2324
if (options) {
2425
this.id = options.id ?? uuid()
2526
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+
}
2933
}
3034
}
3135

36+
public addProposalsAttachment(attachment: ProofAttachmentFormat) {
37+
this.formats.push(attachment.format)
38+
this.proposalsAttach.push(attachment.attachment)
39+
}
40+
3241
@Equals(V2ProposalPresentationMessage.type)
3342
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`
4444

45-
/**
46-
* Provides some human readable information about the proposed presentation.
47-
*/
4845
@IsString()
4946
@IsOptional()
5047
public comment?: string
5148

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[]
6064

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[]
6271
}

packages/core/src/modules/proofs/protocol/v2/messages/V2RequestPresentationMessage.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import { uuid } from 'packages/core/src/utils/uuid'
1111

1212
export interface V2RequestPresentationMessageOptions {
1313
id?: string
14-
goalCode?: string
1514
comment?: string
15+
goalCode?: string
16+
willConfirm?: boolean
1617
attachmentInfo: ProofAttachmentFormat[]
1718
}
1819

@@ -23,16 +24,17 @@ export class V2RequestPresentationMessage extends AgentMessage {
2324
this.id = options.id ?? uuid()
2425
this.comment = options.comment
2526
this.goalCode = options.goalCode
27+
this.willConfirm = options.willConfirm ?? false
2628

2729
for (const entry of options.attachmentInfo) {
28-
this.addProposalsAttachment(entry)
30+
this.addRequestPresentationsAttachment(entry)
2931
}
3032
}
3133
}
3234

33-
public addProposalsAttachment(attachment: ProofAttachmentFormat) {
35+
public addRequestPresentationsAttachment(attachment: ProofAttachmentFormat) {
3436
this.formats.push(attachment.format)
35-
this.proposalsAttach.push(attachment.attachment)
37+
this.requestPresentationsAttach.push(attachment.attachment)
3638
}
3739

3840
@Equals(V2RequestPresentationMessage.type)
@@ -59,10 +61,10 @@ export class V2RequestPresentationMessage extends AgentMessage {
5961
@IsInstance(ProofFormatSpec, { each: true })
6062
public formats!: ProofFormatSpec[]
6163

62-
@Expose({ name: 'proposals~attach' })
64+
@Expose({ name: 'request_presentations~attach' })
6365
@Type(() => Attachment)
6466
@IsArray()
6567
@ValidateNested({ each: true })
6668
@IsInstance(Attachment, { each: true })
67-
public proposalsAttach!: Attachment[]
69+
public requestPresentationsAttach!: Attachment[]
6870
}

0 commit comments

Comments
 (0)