Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add present proof v2 #979

Merged
Merged
Show file tree
Hide file tree
Changes from 167 commits
Commits
Show all changes
171 commits
Select commit Hold shift + click to select a range
8690411
refactor: initial proof module directory for v1 and v2
NB-PrasadKatkar Dec 14, 2021
a25c14a
feat(PresentProofV2): implemented presentation proposal
NB-PrasadKatkar Jan 6, 2022
ccb0329
feat: present proof v2(work in progress)
NB-PrasadKatkar Jan 13, 2022
1634262
feat: Present Proof v2 (WIP Accept Proposal)
NB-PrasadKatkar Jan 15, 2022
d654752
refactor(proofs): reworked directory structure
NB-KarimStekelenburg Jan 18, 2022
9866b56
Merge branch 'feat/present-proof-v2' of https://github.com/hyperledge…
NB-PrasadKatkar Jan 19, 2022
c2d0c45
Merge branch 'hyperledger-feat/present-proof-v2' into feat/present-pr…
NB-PrasadKatkar Jan 19, 2022
9d7a58a
IndyProofFormatService(Request and Presentation)
NB-PrasadKatkar Jan 23, 2022
4de4303
fix: IndyProofFormatService, V1ProofService
NB-PrasadKatkar Jan 24, 2022
1f8b369
refac: IndyProofFormatService, V1ProofService
NB-PrasadKatkar Jan 25, 2022
20a8da6
feat(proofs): add v2 message types
NB-KarimStekelenburg Jan 25, 2022
1b52eaa
refac: V1ProofService
NB-PrasadKatkar Jan 27, 2022
7a021da
feat(proofs): add v2 message types
NB-KarimStekelenburg Jan 25, 2022
bf824d4
fix(proofs): add missing goal_code to options
NB-KarimStekelenburg Jan 26, 2022
84a2f47
feat(proofs): add getter methods to ProofService
NB-KarimStekelenburg Jan 27, 2022
4a201c1
Merge branch 'feat/present-proof-v2' of https://github.com/hyperledge…
NB-KarimStekelenburg Jan 27, 2022
7e03954
refac: V1ProofService
NB-PrasadKatkar Jan 28, 2022
8c9db7d
feat(proofs): add v2 message types
NB-KarimStekelenburg Jan 25, 2022
c5d0ec6
fix(proofs): add missing goal_code to options
NB-KarimStekelenburg Jan 26, 2022
73d9f5e
feat(proofs): add getter methods to ProofService
NB-KarimStekelenburg Jan 27, 2022
9d8791a
Merge pull request #3 from hyperledger/feat/present-proof-v2
NB-PrasadKatkar Jan 28, 2022
66c146e
Merge branch 'feat/present-proof-v2' of https://github.com/hyperledge…
NB-KarimStekelenburg Jan 29, 2022
c55c4d6
Merge branch 'main' into feat/present-proof-v2
NB-KarimStekelenburg Jan 29, 2022
50481a4
refac: ProofsModule
NB-PrasadKatkar Jan 31, 2022
7eccd99
Merge pull request #4 from hyperledger/feat/present-proof-v2
NB-PrasadKatkar Jan 31, 2022
68afa1b
refac: ProofsModule
NB-PrasadKatkar Jan 31, 2022
ade451b
feat(didcomm-msg): add find method repositoty
NB-KarimStekelenburg Jan 31, 2022
e1c56da
feat(proofs): update V1 service w/ DidCommMessages
NB-KarimStekelenburg Jan 31, 2022
ae3665e
refactor(proofs): clean V1Service imports
NB-KarimStekelenburg Jan 31, 2022
cfe6025
refactor(proofs): clean V1Service imports
NB-KarimStekelenburg Jan 31, 2022
5129009
feat(proofs): add request methods to V2Service
NB-KarimStekelenburg Jan 31, 2022
e635497
Merge pull request #5 from hyperledger/feat/present-proof-v2
NB-PrasadKatkar Feb 2, 2022
6b4e767
refactor(proofs): updated ProofsModule request payload
NB-PrasadKatkar Feb 2, 2022
e135c83
Merge branch 'feat/present-proof-v2' of https://github.com/NB-PrasadK…
NB-PrasadKatkar Feb 2, 2022
db40c41
feat(proofs): added script for Proposal
NB-PrasadKatkar Feb 2, 2022
fb04808
feat(proofs): V2ProofService implementation done
NB-KarimStekelenburg Feb 7, 2022
77c1c13
Merge branch 'main' into feat/present-proof-v2
NB-KarimStekelenburg Feb 7, 2022
a2e1035
Merge remote-tracking branch 'prasad/feat/present-proof-v2' into feat…
NB-KarimStekelenburg Feb 7, 2022
56a2bad
Merge pull request #6 from hyperledger/feat/present-proof-v2
NB-PrasadKatkar Feb 7, 2022
94fa88c
feat(proofs): adding test case
NB-PrasadKatkar Feb 7, 2022
ac23660
Merge branch 'feat/present-proof-v2' of https://github.com/NB-PrasadK…
NB-PrasadKatkar Feb 7, 2022
d735cae
feat(proofs): updated packages in test case
NB-PrasadKatkar Feb 7, 2022
b930fde
refactor(proofs): renamed v1 handlers
NB-KarimStekelenburg Feb 7, 2022
b0b002d
feat(proofs): add auto accept logic
NB-KarimStekelenburg Feb 8, 2022
8ba7652
feat(proofs): add V2 service to ProofsModule
NB-KarimStekelenburg Feb 10, 2022
53461a9
fix(proofs): add V2 handler
NB-KarimStekelenburg Feb 14, 2022
aaf830c
fix(proofs): add final V2 handlers
NB-KarimStekelenburg Feb 14, 2022
b30f5ff
fix(proofs): register V2 handlers
NB-KarimStekelenburg Feb 16, 2022
7251fcf
Merge pull request #7 from hyperledger/feat/present-proof-v2
NB-PrasadKatkar Feb 17, 2022
f8f231a
test: added tests for v1 and v2 proof presentation proposal
NB-PrasadKatkar Feb 22, 2022
3eebaf8
fix: create proof request from proposal
NB-PrasadKatkar Feb 28, 2022
91c5adb
fix: process presentation if no proof proposal was created
NB-PrasadKatkar Mar 1, 2022
f4f06b1
test: working on V2 present proofs
NB-PrasadKatkar Mar 2, 2022
3de00b5
refac: renamed the proofs test files
NB-PrasadKatkar Mar 2, 2022
c9fa068
feat(present-proof v2): added createProofRequestFromProposal method t…
NB-PrasadKatkar Mar 8, 2022
eba2bfe
test(present-proof v2): proposal based scenario
NB-PrasadKatkar Mar 9, 2022
3905fe0
tests(present-proof v2): e2e proof request based scenario
NB-PrasadKatkar Mar 10, 2022
e5d1023
Merge branch 'main' of https://github.com/NB-PrasadKatkar/aries-frame…
NB-PrasadKatkar Mar 10, 2022
65aacfa
Merge branch 'main' of https://github.com/NB-PrasadKatkar/aries-frame…
NB-PrasadKatkar Mar 10, 2022
405fb0d
fix: connectionless-proofs and some tests
NB-PrasadKatkar Mar 12, 2022
88cb5f7
fix: auto accept proof test
NB-PrasadKatkar Mar 12, 2022
dfbd338
fix: demo files with new proof payloads and AckDecorator test
NB-PrasadKatkar Mar 12, 2022
51a7a0e
Merge branch 'main' of https://github.com/NB-PrasadKatkar/aries-frame…
NB-PrasadKatkar Mar 21, 2022
6a5ff87
test: v2 connectionless proofs and auto accept tests
NB-PrasadKatkar Mar 22, 2022
ddc9d8c
Merge branch 'main' of https://github.com/NB-PrasadKatkar/aries-frame…
NB-PrasadKatkar Mar 22, 2022
143280d
fix: check didCommMessages in proof tests
NB-PrasadKatkar Mar 24, 2022
a1bc56b
refac: renamed varibales
NB-PrasadKatkar Mar 25, 2022
30e5142
refac: few comments received on PR
NB-PrasadKatkar Mar 28, 2022
210a131
Merge branch 'main' of https://github.com/NB-PrasadKatkar/aries-frame…
NB-PrasadKatkar Mar 28, 2022
0254ccd
refac: removed commented lines, updates '.', '../' imports, empty err…
NB-PrasadKatkar Mar 28, 2022
d84c8a6
Merge branch 'main' of https://github.com/NB-PrasadKatkar/aries-frame…
NB-PrasadKatkar Mar 28, 2022
39be7e2
refac: proof response coordinator (auto-accept) check
NB-PrasadKatkar Mar 28, 2022
50dc835
Merge branch 'main' of https://github.com/NB-PrasadKatkar/aries-frame…
NB-PrasadKatkar Mar 28, 2022
b65bd48
refac: moved presentation preview in v1
NB-PrasadKatkar Mar 29, 2022
1b135c6
fix: import order
NB-PrasadKatkar Mar 29, 2022
a2ad211
refac: replaced inline interfaces
NB-PrasadKatkar Mar 30, 2022
247ba0a
Merge branch 'main' of https://github.com/NB-PrasadKatkar/aries-frame…
NB-PrasadKatkar Mar 30, 2022
533a02b
fix: lint issues
NB-PrasadKatkar Mar 30, 2022
2a3dd27
Merge branch 'main' of https://github.com/NB-PrasadKatkar/aries-frame…
NB-PrasadKatkar Apr 5, 2022
578fb5a
fix: import path fix after merge conflict issues
NB-PrasadKatkar Apr 5, 2022
4502fb8
fix: V2 proof proposal attachment
NB-PrasadKatkar Apr 8, 2022
22ee18b
refac: proposal interface removed proofPreview
NB-PrasadKatkar Apr 13, 2022
2465290
refac: renamed PresentationPreview to V1PresentationPreview
NB-PrasadKatkar Apr 13, 2022
a853fd7
refac: removed commented lines and renamed interfaces
NB-PrasadKatkar Apr 13, 2022
7e0f055
Merge branch 'main' of https://github.com/NB-PrasadKatkar/aries-frame…
NB-PrasadKatkar Apr 13, 2022
a97ea63
fix: merge conflicts
NB-PrasadKatkar Apr 13, 2022
25d028b
refac: accept proposal removed some not required properties from inte…
NB-PrasadKatkar Apr 14, 2022
2fcbc9a
refac: renamed protocol version enum
NB-PrasadKatkar Apr 14, 2022
2c45f1f
refac: removed version from accept methods
NB-PrasadKatkar Apr 14, 2022
42b1ca7
refac: merged getRequestedCredentialsForProofRequest and autoSelectCr…
NB-PrasadKatkar Apr 15, 2022
9f7be41
Merge branch 'main' of https://github.com/NB-PrasadKatkar/aries-frame…
NB-PrasadKatkar Apr 15, 2022
a47e3ae
refac: async createXXX and processXXX methods in the proof format ser…
NB-PrasadKatkar Apr 15, 2022
30d6933
Merge branch 'main' of https://github.com/NB-PrasadKatkar/aries-frame…
NB-PrasadKatkar Apr 15, 2022
cc31e87
refac: renamed propoerty in RequestProofOptions interface
NB-PrasadKatkar Apr 15, 2022
07d79cd
refac: created constants for proof formats
NB-PrasadKatkar Apr 15, 2022
d46e55b
refac: decline proof handled in module itself
NB-PrasadKatkar Apr 18, 2022
965225a
refac: Presentation Problem report structure changed
NB-PrasadKatkar Apr 18, 2022
fed9e68
refac: removed nonce from module
NB-PrasadKatkar Apr 18, 2022
4c89292
fix: lint issue
NB-PrasadKatkar Apr 18, 2022
9c552c7
refac: few feedback comments resolved
NB-PrasadKatkar Apr 19, 2022
0c0c983
refac: proof module document updated
NB-PrasadKatkar Apr 19, 2022
be00ec1
refac: proof format enums
NB-PrasadKatkar Apr 19, 2022
e2cc0ff
refac: proof format constants
NB-PrasadKatkar Apr 20, 2022
20a9741
Merge branch 'main' of https://github.com/NB-PrasadKatkar/aries-frame…
NB-PrasadKatkar Apr 20, 2022
3a49595
Merge branch 'main' of https://github.com/NB-PrasadKatkar/aries-frame…
NB-PrasadKatkar Apr 20, 2022
9d152be
Merge branch 'main' of https://github.com/NB-PrasadKatkar/aries-frame…
NB-PrasadKatkar Apr 23, 2022
fb398f6
Merge branch 'main' of https://github.com/NB-PrasadKatkar/aries-frame…
NB-PrasadKatkar May 2, 2022
04c15a8
fix: few review comments fixed
NB-PrasadKatkar May 2, 2022
11566c2
refac: find request payload updated
NB-PrasadKatkar May 2, 2022
0b2ea5f
fix: eslint fixes
NB-PrasadKatkar May 2, 2022
6c68720
Merge branch 'main' of https://github.com/NB-PrasadKatkar/aries-frame…
NB-PrasadKatkar May 3, 2022
7c51e2e
test: added test for Problem report from Module.
NB-PrasadKatkar May 4, 2022
a61811f
Merge branch 'main' of https://github.com/NB-PrasadKatkar/aries-frame…
NB-PrasadKatkar May 4, 2022
14a98fa
refac: removed TBD comment
NB-PrasadKatkar May 4, 2022
9d301af
fix: service name updation comments resolved
NB-PrasadKatkar May 5, 2022
cfb8dca
fix: service name updation comments resolved
NB-PrasadKatkar May 5, 2022
7cb29de
fix: eslint fixes
NB-PrasadKatkar May 5, 2022
0c0feed
fix: some review comments on based on protocol version
NB-PrasadKatkar May 5, 2022
6ba43f2
fix: few comments related to tests
NB-PrasadKatkar May 6, 2022
f43f8c8
fix: created single file for problem report reason and renamed attchI…
NB-PrasadKatkar May 6, 2022
39514ba
Merge branch 'main' of https://github.com/NB-PrasadKatkar/aries-frame…
NB-PrasadKatkar May 7, 2022
b6cc5d1
fix: removed duplicate referent method
NB-PrasadKatkar May 8, 2022
b7f0548
fix: remove uuid and used indy wallet for nonce generation
NB-PrasadKatkar May 8, 2022
d04598e
Update packages/core/src/modules/proofs/ProofService.ts
TimoGlastra May 9, 2022
7a6fb59
Update packages/core/src/modules/proofs/__tests__/V1ProofService.test.ts
TimoGlastra May 9, 2022
8bba6dd
Merge branch 'main' of https://github.com/NB-PrasadKatkar/aries-frame…
NB-PrasadKatkar May 10, 2022
cad0d1f
Merge branch 'feat/present-proof-v2' of https://github.com/NB-PrasadK…
NB-PrasadKatkar May 10, 2022
6e40192
Merge branch 'main' of https://github.com/NB-PrasadKatkar/aries-frame…
NB-PrasadKatkar May 10, 2022
c59d670
Merge branch 'main' of https://github.com/NB-PrasadKatkar/aries-frame…
NB-PrasadKatkar May 10, 2022
cf500e9
Merge branch 'main' of https://github.com/NB-PrasadKatkar/aries-frame…
NB-PrasadKatkar May 12, 2022
9b116a9
Merge branch 'main' of https://github.com/NB-PrasadKatkar/aries-frame…
NB-PrasadKatkar May 18, 2022
c8617e4
fix: eslint fixes
NB-PrasadKatkar May 18, 2022
cfde215
Merge branch 'main' of https://github.com/NB-PrasadKatkar/aries-frame…
NB-PrasadKatkar May 18, 2022
de30117
refac: validate attachment before processing the messages.
NB-PrasadKatkar May 19, 2022
61797ff
Merge branch 'main' of https://github.com/NB-PrasadKatkar/aries-frame…
NB-PrasadKatkar May 19, 2022
0166af3
tests: presentation exchange unit test
NB-PrasadKatkar May 19, 2022
f0e02eb
Merge pull request #666 from NB-PrasadKatkar/feat/present-proof-v2
TimoGlastra May 19, 2022
aa45ec6
Merge remote-tracking branch 'upstream/main' into feat/ppv2
TimoGlastra May 30, 2022
379cb18
chore: update with main (#876)
TimoGlastra Jun 17, 2022
c0d071b
Merge remote-tracking branch 'upstream/main' into feat/ppv2
TimoGlastra Jun 17, 2022
df1c18f
feat: present proof v2 indy (#805)
NB-PrasadKatkar Jul 5, 2022
00d8954
Merge remote-tracking branch 'upstream/0.3.0-pre' into refactor/gener…
TimoGlastra Jul 6, 2022
828a3e6
temp
TimoGlastra Jul 6, 2022
81d6bb8
temp
TimoGlastra Jul 14, 2022
5b10382
Local test commit
NB-MikeRichardson Jul 27, 2022
9989800
fix errors in helpers.ts
NB-MikeRichardson Jul 29, 2022
dbb7b1d
Refactor PPV2 to use new stuff from 0.3.0-pre
NB-MikeRichardson Aug 2, 2022
0c4d967
Merge branch 'hyperledger-0.3.0-pre' into feat/mjrppv2
NB-MikeRichardson Aug 2, 2022
468489c
Merge branch 'feat/mjrppv2' of https://github.com/NB-MikeRichardson/a…
NB-MikeRichardson Aug 2, 2022
7f5ab3e
Remove unused import
NB-MikeRichardson Aug 2, 2022
a4dd68d
Fix V1 PPV2 tests
NB-MikeRichardson Aug 4, 2022
69bab5a
Further fixes for v1 and v2 service tests
NB-MikeRichardson Aug 5, 2022
cd029db
e2e v1 and v2 indy proof request test fixes
NB-MikeRichardson Aug 5, 2022
a3401ea
Fix v1 auto accept proof tests
NB-MikeRichardson Aug 5, 2022
608bb9c
Fix v1 auto accept proof tests
NB-MikeRichardson Aug 5, 2022
19eaae7
Fix lint errors/warnings
NB-MikeRichardson Aug 8, 2022
3fa1d14
Fix lint errors/warnings
NB-MikeRichardson Aug 8, 2022
7ca93b7
Merge with TimoGlastro branch refactor/generalize-proofs
NB-MikeRichardson Aug 8, 2022
97b4970
Merge branch 'TimoGlastra-refactor/generalize-proofs' into refactor/m…
NB-MikeRichardson Aug 8, 2022
3404884
Fix v1 out of band connectionless auto accept tests
NB-MikeRichardson Aug 9, 2022
efa0f77
Remove revocationNotificationService from ProofsAPI constructor
NB-MikeRichardson Aug 15, 2022
566e8e8
Remove ProofsConfig object from modules/api (credentials specific)
NB-MikeRichardson Aug 15, 2022
b941c58
Tidy up ProofFormatService interfaces
NB-MikeRichardson Aug 15, 2022
29795ec
Tidy up ProofFormatService interfaces
NB-MikeRichardson Aug 15, 2022
905e964
fix lint warnings
NB-MikeRichardson Aug 15, 2022
aa45795
Merge branch '0.3.0-pre' into refactor/mjrppv2
NB-MikeRichardson Aug 15, 2022
91f9a91
fix lint warnings
NB-MikeRichardson Aug 15, 2022
e379c9e
Put Config back into ProofsModule
NB-MikeRichardson Aug 15, 2022
2be36f4
Fix lint errors
NB-MikeRichardson Aug 15, 2022
cf83e1c
fix(proofs): typing issues
TimoGlastra Aug 17, 2022
034e35c
fix: remove rev notification service from proofs
TimoGlastra Aug 17, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions demo/src/Alice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,17 @@ export class Alice extends BaseAgent {
}

public async acceptProofRequest(proofRecord: ProofRecord) {
const retrievedCredentials = await this.agent.proofs.getRequestedCredentialsForProofRequest(proofRecord.id, {
filterByPresentationPreview: true,
const requestedCredentials = await this.agent.proofs.autoSelectCredentialsForProofRequest({
proofRecordId: proofRecord.id,
config: {
filterByPresentationPreview: true,
},
})

await this.agent.proofs.acceptRequest({
proofRecordId: proofRecord.id,
proofFormats: { indy: requestedCredentials.indy },
})
const requestedCredentials = this.agent.proofs.autoSelectCredentialsForProofRequest(retrievedCredentials)
await this.agent.proofs.acceptRequest(proofRecord.id, requestedCredentials)
console.log(greenText('\nProof request accepted!\n'))
}

Expand Down
22 changes: 19 additions & 3 deletions demo/src/Faber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import type { ConnectionRecord } from '@aries-framework/core'
import type { CredDef, Schema } from 'indy-sdk'
import type BottomBar from 'inquirer/lib/ui/bottom-bar'

import { V1CredentialPreview, AttributeFilter, ProofAttributeInfo, utils } from '@aries-framework/core'
import {
AttributeFilter,
ProofAttributeInfo,
ProofProtocolVersion,
utils,
V1CredentialPreview,
} from '@aries-framework/core'
import { ui } from 'inquirer'

import { BaseAgent } from './BaseAgent'
Expand Down Expand Up @@ -137,8 +143,18 @@ export class Faber extends BaseAgent {
const connectionRecord = await this.getConnectionRecord()
const proofAttribute = await this.newProofAttribute()
await this.printProofFlow(greenText('\nRequesting proof...\n', false))
await this.agent.proofs.requestProof(connectionRecord.id, {
requestedAttributes: proofAttribute,

await this.agent.proofs.requestProof({
protocolVersion: ProofProtocolVersion.V1,
connectionId: connectionRecord.id,
proofFormats: {
indy: {
name: 'proof-request',
version: '1.0',
nonce: '1298236324864',
requestedAttributes: proofAttribute,
},
},
})
this.ui.updateBottomBar(
`\nProof request sent!\n\nGo to the Alice agent to accept the proof request\n\n${Color.Reset}`
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/agent/AgentConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { DID_COMM_TRANSPORT_QUEUE } from '../constants'
import { AriesFrameworkError } from '../error'
import { ConsoleLogger, LogLevel } from '../logger'
import { AutoAcceptCredential } from '../modules/credentials/models/CredentialAutoAcceptType'
import { AutoAcceptProof } from '../modules/proofs/ProofAutoAcceptType'
import { AutoAcceptProof } from '../modules/proofs/models/ProofAutoAcceptType'
import { DidCommMimeType } from '../types'

export class AgentConfig {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/agent/BaseAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export abstract class BaseAgent {
// We set the modules in the constructor because that allows to set them as read-only
this.connections = this.dependencyManager.resolve(ConnectionsApi)
this.credentials = this.dependencyManager.resolve(CredentialsApi) as CredentialsApi
this.proofs = this.dependencyManager.resolve(ProofsApi)
this.proofs = this.dependencyManager.resolve(ProofsApi) as ProofsApi
this.mediator = this.dependencyManager.resolve(MediatorApi)
this.mediationRecipient = this.dependencyManager.resolve(RecipientApi)
this.basicMessages = this.dependencyManager.resolve(BasicMessagesApi)
Expand Down
10 changes: 7 additions & 3 deletions packages/core/src/agent/__tests__/Agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import { CredentialRepository } from '../../modules/credentials'
import { CredentialsApi } from '../../modules/credentials/CredentialsApi'
import { IndyLedgerService } from '../../modules/ledger'
import { LedgerApi } from '../../modules/ledger/LedgerApi'
import { ProofRepository, ProofService } from '../../modules/proofs'
import { ProofRepository } from '../../modules/proofs'
import { ProofsApi } from '../../modules/proofs/ProofsApi'
import { V1ProofService } from '../../modules/proofs/protocol/v1'
import { V2ProofService } from '../../modules/proofs/protocol/v2'
import {
MediatorApi,
RecipientApi,
Expand Down Expand Up @@ -115,8 +117,9 @@ describe('Agent', () => {
expect(container.resolve(ConnectionRepository)).toBeInstanceOf(ConnectionRepository)
expect(container.resolve(TrustPingService)).toBeInstanceOf(TrustPingService)

expect(container.resolve(V1ProofService)).toBeInstanceOf(V1ProofService)
expect(container.resolve(V2ProofService)).toBeInstanceOf(V2ProofService)
expect(container.resolve(ProofsApi)).toBeInstanceOf(ProofsApi)
expect(container.resolve(ProofService)).toBeInstanceOf(ProofService)
expect(container.resolve(ProofRepository)).toBeInstanceOf(ProofRepository)

expect(container.resolve(CredentialsApi)).toBeInstanceOf(CredentialsApi)
Expand Down Expand Up @@ -157,8 +160,9 @@ describe('Agent', () => {
expect(container.resolve(ConnectionRepository)).toBe(container.resolve(ConnectionRepository))
expect(container.resolve(TrustPingService)).toBe(container.resolve(TrustPingService))

expect(container.resolve(V1ProofService)).toBe(container.resolve(V1ProofService))
expect(container.resolve(V2ProofService)).toBe(container.resolve(V2ProofService))
expect(container.resolve(ProofsApi)).toBe(container.resolve(ProofsApi))
expect(container.resolve(ProofService)).toBe(container.resolve(ProofService))
expect(container.resolve(ProofRepository)).toBe(container.resolve(ProofRepository))

expect(container.resolve(CredentialsApi)).toBe(container.resolve(CredentialsApi))
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/decorators/ack/AckDecorator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { JsonTransformer } from '../../utils/JsonTransformer'
import { MessageValidator } from '../../utils/MessageValidator'
import { Compose } from '../../utils/mixins'

import { AckValues } from './AckDecorator'
import { AckDecorated } from './AckDecoratorExtension'

describe('Decorators | AckDecoratorExtension', () => {
Expand All @@ -15,7 +16,7 @@ describe('Decorators | AckDecoratorExtension', () => {

test('transforms AckDecorator class to JSON', () => {
const message = new TestMessage()
message.setPleaseAck()
message.setPleaseAck([AckValues.Receipt])
expect(message.toJSON()).toEqual({
'@id': undefined,
'@type': undefined,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import type { AgentContext } from '../../../agent'
import type { EventEmitter } from '../../../agent/EventEmitter'
import type { CredentialRepository } from '../repository'
import type { CredentialFormat } from './CredentialFormat'
import type {
FormatCreateProposalOptions,
Expand All @@ -23,14 +21,6 @@ import { Attachment, AttachmentData } from '../../../decorators/attachment/Attac
import { JsonEncoder } from '../../../utils/JsonEncoder'

export abstract class CredentialFormatService<CF extends CredentialFormat = CredentialFormat> {
protected credentialRepository: CredentialRepository
protected eventEmitter: EventEmitter

public constructor(credentialRepository: CredentialRepository, eventEmitter: EventEmitter) {
this.credentialRepository = credentialRepository
this.eventEmitter = eventEmitter
}

abstract readonly formatKey: CF['formatKey']
abstract readonly credentialRecordType: CF['credentialRecordType']

Expand Down Expand Up @@ -86,7 +76,6 @@ export abstract class CredentialFormatService<CF extends CredentialFormat = Cred
*
* @param data The data to include in the attach object
* @param id the attach id from the formats component of the message
* @returns attachment to the credential proposal
*/
protected getFormatData(data: unknown, id: string): Attachment {
const attachment = new Attachment({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import type {
import type { IndyCredentialFormat } from './IndyCredentialFormat'
import type * as Indy from 'indy-sdk'

import { EventEmitter } from '../../../../agent/EventEmitter'
import { InjectionSymbols } from '../../../../constants'
import { AriesFrameworkError } from '../../../../error'
import { Logger } from '../../../../logger'
Expand All @@ -38,7 +37,6 @@ import { CredentialProblemReportError, CredentialProblemReportReason } from '../
import { CredentialFormatSpec } from '../../models/CredentialFormatSpec'
import { CredentialPreviewAttribute } from '../../models/CredentialPreviewAttribute'
import { CredentialMetadataKeys } from '../../repository/CredentialMetadataTypes'
import { CredentialRepository } from '../../repository/CredentialRepository'
import { CredentialFormatService } from '../CredentialFormatService'

import { IndyCredentialUtils } from './IndyCredentialUtils'
Expand All @@ -59,16 +57,14 @@ export class IndyCredentialFormatService extends CredentialFormatService<IndyCre
private logger: Logger

public constructor(
credentialRepository: CredentialRepository,
eventEmitter: EventEmitter,
indyIssuerService: IndyIssuerService,
indyLedgerService: IndyLedgerService,
indyHolderService: IndyHolderService,
connectionService: ConnectionService,
didResolver: DidResolverService,
@inject(InjectionSymbols.Logger) logger: Logger
) {
super(credentialRepository, eventEmitter)
super()
this.indyIssuerService = indyIssuerService
this.indyLedgerService = indyLedgerService
this.indyHolderService = indyHolderService
Expand Down Expand Up @@ -130,14 +126,10 @@ export class IndyCredentialFormatService extends CredentialFormatService<IndyCre
}

public async processProposal(agentContext: AgentContext, { attachment }: FormatProcessOptions): Promise<void> {
const credProposalJson = attachment.getDataAsJson()
const proposalJson = attachment.getDataAsJson()

if (!credProposalJson) {
throw new AriesFrameworkError('Missing indy credential proposal data payload')
}

const credProposal = JsonTransformer.fromJSON(credProposalJson, IndyCredPropose)
MessageValidator.validateSync(credProposal)
// fromJSON also validates
JsonTransformer.fromJSON(proposalJson, IndyCredPropose)
}

public async acceptProposal(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { AgentContext } from '../../../agent'
import type { RequestedCredentials } from '../../proofs'
import type { RequestedCredentials } from '../../proofs/formats/indy/models/RequestedCredentials'
import type * as Indy from 'indy-sdk'

import { AgentDependencies } from '../../../agent/AgentDependencies'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AgentContext } from '../../../agent'
import type { IndyRevocationInterval } from '../../credentials'
import type { RequestedCredentials } from '../../proofs'
import type { RequestedCredentials } from '../../proofs/formats/indy/models/RequestedCredentials'
import type { default as Indy } from 'indy-sdk'

import { AgentDependencies } from '../../../agent/AgentDependencies'
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/modules/proofs/ProofEvents.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { BaseEvent } from '../../agent/Events'
import type { ProofState } from './ProofState'
import type { ProofState } from './models/ProofState'
import type { ProofRecord } from './repository'

export enum ProofEventTypes {
Expand Down
42 changes: 25 additions & 17 deletions packages/core/src/modules/proofs/ProofResponseCoordinator.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import type { AgentContext } from '../../agent/context'
import type { AgentContext } from '../../agent/context/AgentContext'
import type { ProofRecord } from './repository'

import { injectable } from '../../plugins'

import { AutoAcceptProof } from './ProofAutoAcceptType'
import { ProofsModuleConfig } from './ProofsModuleConfig'
import { ProofService } from './ProofService'
import { AutoAcceptProof } from './models/ProofAutoAcceptType'

/**
* This class handles all the automation with all the messages in the present proof protocol
* Every function returns `true` if it should automate the flow and `false` if not
*/
@injectable()
export class ProofResponseCoordinator {
private proofsModuleConfig: ProofsModuleConfig
private proofService: ProofService

public constructor(proofsModuleConfig: ProofsModuleConfig) {
this.proofsModuleConfig = proofsModuleConfig
public constructor(proofService: ProofService) {
this.proofService = proofService
}

/**
* Returns the proof auto accept config based on priority:
* - The record config takes first priority
Expand All @@ -36,12 +37,17 @@ export class ProofResponseCoordinator {
public shouldAutoRespondToProposal(agentContext: AgentContext, proofRecord: ProofRecord) {
const autoAccept = ProofResponseCoordinator.composeAutoAccept(
proofRecord.autoAcceptProof,
this.proofsModuleConfig.autoAcceptProofs
agentContext.config.autoAcceptProofs
)

if (autoAccept === AutoAcceptProof.Always) {
return true
}

if (autoAccept === AutoAcceptProof.ContentApproved) {
return this.proofService.shouldAutoRespondToProposal(agentContext, proofRecord)
}

return false
}

Expand All @@ -51,16 +57,17 @@ export class ProofResponseCoordinator {
public shouldAutoRespondToRequest(agentContext: AgentContext, proofRecord: ProofRecord) {
const autoAccept = ProofResponseCoordinator.composeAutoAccept(
proofRecord.autoAcceptProof,
this.proofsModuleConfig.autoAcceptProofs
agentContext.config.autoAcceptProofs
)

if (
autoAccept === AutoAcceptProof.Always ||
(autoAccept === AutoAcceptProof.ContentApproved && proofRecord.proposalMessage)
) {
if (autoAccept === AutoAcceptProof.Always) {
return true
}

if (autoAccept === AutoAcceptProof.ContentApproved) {
return this.proofService.shouldAutoRespondToRequest(agentContext, proofRecord)
}

return false
}

Expand All @@ -70,16 +77,17 @@ export class ProofResponseCoordinator {
public shouldAutoRespondToPresentation(agentContext: AgentContext, proofRecord: ProofRecord) {
const autoAccept = ProofResponseCoordinator.composeAutoAccept(
proofRecord.autoAcceptProof,
this.proofsModuleConfig.autoAcceptProofs
agentContext.config.autoAcceptProofs
)

if (
autoAccept === AutoAcceptProof.Always ||
(autoAccept === AutoAcceptProof.ContentApproved && proofRecord.requestMessage)
) {
if (autoAccept === AutoAcceptProof.Always) {
return true
}

if (autoAccept === AutoAcceptProof.ContentApproved) {
return this.proofService.shouldAutoRespondToPresentation(agentContext, proofRecord)
}

return false
}
}
Loading