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 oob proof proposal #1370

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Zzocker
Copy link
Contributor

@Zzocker Zzocker commented Mar 7, 2023

No description provided.

@Zzocker Zzocker requested a review from a team as a code owner March 7, 2023 06:53
@codecov-commenter
Copy link

codecov-commenter commented Mar 7, 2023

Codecov Report

Merging #1370 (a822161) into main (a4204ef) will decrease coverage by 1.85%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1370      +/-   ##
==========================================
- Coverage   87.27%   85.43%   -1.85%     
==========================================
  Files         780      780              
  Lines       18706    18717      +11     
  Branches     3210     3216       +6     
==========================================
- Hits        16326    15991     -335     
- Misses       2373     2719     +346     
  Partials        7        7              
Impacted Files Coverage Δ
...oncreds/src/protocols/proofs/v1/V1ProofProtocol.ts 88.82% <100.00%> (+0.13%) ⬆️
packages/core/src/modules/proofs/ProofsApi.ts 84.21% <100.00%> (+0.25%) ⬆️
.../src/modules/proofs/protocol/v2/V2ProofProtocol.ts 93.76% <100.00%> (+0.07%) ⬆️

... and 9 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Contributor

@TimoGlastra TimoGlastra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR @Zzocker!

I'm okay with the changes, but we need to make sure to implement it for all protocol versions and make sure we can also receive connectionless proposals in addition to create them.

could you also add some new tests for this?

@Zzocker
Copy link
Contributor Author

Zzocker commented Mar 7, 2023

Yes, I wanted to add test for the changes but I wasn't sure whether to create a new test file or add in an existing test file.

When verifier receives the proposal message, the proposal handler function will be invoked and proposal will be proceeded, and if auto accept proof is true, verifier will send the proof request. Do we need to have any aditional logic for reciving the proposal message ?

@Zzocker
Copy link
Contributor Author

Zzocker commented Mar 9, 2023

I have added oob proof proposal for both (v1 and v2) versions of the proof request. Also added test cases. @TimoGlastra can you again review this PR?

@Zzocker Zzocker requested a review from TimoGlastra March 9, 2023 14:31
Copy link
Contributor

@TimoGlastra TimoGlastra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grest changes @Zzocker. I have some concerns on the connection between oob and proofs. This is something that needs to be fixes across the framework.

@@ -416,6 +416,12 @@ export class V1ProofProtocol extends BaseProofProtocol implements ProofProtocol<

let proofRecord = await this.findByThreadAndConnectionId(agentContext, proofRequestMessage.threadId, connection?.id)

if (!proofRecord) {
// Proof request not bound to any connection: requests_attach in OOB msg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't mean the proof record is not bound to any connection, and it means if i know the thread id i respond to this exchange even though not involved.

We should update this logic to be fully integrated with the oob module:

  • we look for the oob record
  • if oob is connectionless/now has a connection afterwards we allow the proof record to not have a connection

I'd like to solve this generically for both connectionless/non-connectionless exchanges with attached messages. Is this needed for this PR?

Copy link
Contributor Author

@Zzocker Zzocker Mar 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the wrong code comment, connection-less proof requests will also not be linked to a connection.

  • In case of connection-less proof request both findByThreadAndConnectionId and findByThread will return null proofRecord.
  • In case of oob proof proposal findByThreadAndConnectionId will return null since the connection is not linked to any proofRecord, but findByThread will return proofRecord at ProposalSent state.

For now, can I replace the comment to?

    if (!proofRecord) {
      // Proof request bound to a proofRecord by threadId: proof proposal in OOB msg
      // TODO integrate with oob module 
      proofRecord = await this.findByThreadAndConnectionId(messageContext.agentContext, requestMessage.threadId)
      if (proofRecord) proofRecord.connectionId = connection?.id
    }

@TimoGlastra

})
await faberAgent.oob.receiveInvitation(outOfBandInvitation)
testLogger.test('Faber waits for proof proposal message from Alice')
let faberProofExchangeRecord = await waitForProofExchangeRecord(faberAgent, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use waitForProofExchangeRecordSubject? This method can have timing issues

@@ -38,6 +38,17 @@ export interface ProposeProofOptions<PPs extends ProofProtocol[] = ProofProtocol
parentThreadId?: string
}

/**
* Interface for ProofsApi.createProofProposal. Will create an out of band request.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Interface for ProofsApi.createProofProposal. Will create an out of band request.
* Interface for ProofsApi.createProofProposal. Will create an out of band proposal.

@@ -396,6 +396,12 @@ export class V2ProofProtocol<PFs extends ProofFormatService[] = ProofFormatServi
connection?.id
)

if (!proofRecord) {
// Proof request not bound to any connection: requests_attach in OOB msg
proofRecord = await this.findByThreadAndConnectionId(messageContext.agentContext, requestMessage.threadId)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments here

})
})

test('Alice start with oob proof proposal for Faber with auto-accept enabled and both agents having a mediator', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specific reason you added this test? We have a lot of tests that do almost the same and it's making updates harder.

So if there's a specific reason for this test great, but otherwise we can maybe remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, For the oob proof proposal, we want to test

  • After the proof exchange flow is completed,
    • The holder should have all three proof messages proposalMessage, requestMessage , and presentationMessage
    • proof exchange record should have nonNull connection id.

I will remove the first and last tests and add the above assertion in 2nd test.

Signed-off-by: Pritam Singh <pkspritam16@gmail.com>
Signed-off-by: Pritam Singh <pkspritam16@gmail.com>
Signed-off-by: Pritam Singh <pkspritam16@gmail.com>
Signed-off-by: Pritam Singh <pkspritam16@gmail.com>
@TimoGlastra
Copy link
Contributor

Discussed during WG call. @TimoGlastra will take another look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants