-
Notifications
You must be signed in to change notification settings - Fork 207
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
refactor: only use ready connection for inbound #360
refactor: only use ready connection for inbound #360
Conversation
Signed-off-by: Timo Glastra <timo@animo.id>
Signed-off-by: Timo Glastra <timo@animo.id>
Signed-off-by: Timo Glastra <timo@animo.id>
Signed-off-by: Timo Glastra <timo@animo.id>
Signed-off-by: Timo Glastra <timo@animo.id>
Signed-off-by: Timo Glastra <timo@animo.id>
Signed-off-by: Timo Glastra <timo@animo.id>
Signed-off-by: Timo Glastra <timo@animo.id>
Codecov Report
@@ Coverage Diff @@
## main #360 +/- ##
=======================================
Coverage 85.65% 85.66%
=======================================
Files 253 254 +1
Lines 5467 5498 +31
Branches 878 884 +6
=======================================
+ Hits 4683 4710 +27
- Misses 783 787 +4
Partials 1 1
Continue to review full report at Codecov.
|
Signed-off-by: Timo Glastra <timo@animo.id>
These are some good additions--and I will give some additional review once you find this is in a good state @TimoGlastra as discussed in the WG call on the 15th, which IIRC may include you splitting this out into additional PRs. |
Signed-off-by: Timo Glastra <timo@animo.id>
Signed-off-by: Timo Glastra <timo@animo.id>
Signed-off-by: Timo Glastra <timo@animo.id>
Signed-off-by: Timo Glastra <timo@animo.id>
@jakubkoci @JamesKEbert @blu3beri I've updated this PR with latest changes. Although there are still a lot of changed files, most of it is adding class-validator decorators. Could you take a look so we can get it merged? :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice! love the addition of a lot more validators.
Just left some minor points, but nothing major.
// We check whether the sender key is the same as the key we have stored in the connection | ||
// otherwise everyone could send messages to our key and we would just accept | ||
// it as if it was send by the key of the connection. | ||
// Throw error if the recipient key (ourKey) does not match the key of the connection record | ||
if (connection && connection.theirKey != null && connection.theirKey != senderKey) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not your line, but why do we check if connection.theirKey
is not null? The last check connection.theirKey != senderKey
should suffice.
Also we should do !==
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't completely suffice, as in this case if connection.theirKey
is null, it will not throw the error. If theirKey is null, and senderKey isn't (it will never be null due to check above) it will throw the error.
if connection.theirKey
is null it means the connection does not have their key yet (we've sent an invitation, but didn't receive a request yet). This check is mostly to check if a connection that already has theirKey matches the key of the message we received
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree on the !==
however
@@ -22,6 +22,7 @@ export class TimingDecorator { | |||
@Expose({ name: 'in_time' }) | |||
@Type(() => Date) | |||
@IsDate() | |||
@IsOptional() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really a comment, but is there a particular order we want to add these decorators?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. I'm not sure if there are sorters for decorators (as the order can matter I think) and doing it manually seems tedious
validateOrReject(JsonTransformer.fromJSON(obj, TransportDecorator)) | ||
const expectValid = (obj: Record<string, unknown>) => expect(validTranport(obj)).resolves.toBeUndefined() | ||
const expectInvalid = (obj: Record<string, unknown>) => expect(validTranport(obj)).rejects.not.toBeNull() | ||
const validTransport = (obj: Record<string, unknown>) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick, but could we make obj
a bit more verbose?
@@ -19,11 +19,13 @@ export class Credential { | |||
@Expose({ name: 'cred_info' }) | |||
@Type(() => IndyCredentialInfo) | |||
@ValidateNested() | |||
@IsInstance(IndyCredentialInfo) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a common pattern of adding the @type
decorator and the @IsInstance
decorator. Is there a way to combine these decorators? Can be in a seperate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be. I'm not sure if it is easy to combine two decorators and make the work like before (as it needs the field data)
@@ -141,7 +142,7 @@ export class ProofsModule { | |||
*/ | |||
public async requestProof( | |||
connectionId: string, | |||
proofRequestOptions: ProofRequestOptions, | |||
proofRequestOptions: RequestProofOptions, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the reorder of words? Shouldn't we also rename the param then? And the line below:
config?: ProofRequestConfig
to config?: RequestProofConfig
or requestProofConfig?: RequestProofConfig
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this is kinda messy. I'll take a look
|
||
import { AgentMessage } from '../../../agent/AgentMessage' | ||
|
||
export enum KeylistUpdateAction { | ||
add = 'add', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Camelcase?
Signed-off-by: Timo Glastra <timo@animo.id>
If no one else is going to review, I'm going to merge this PR |
Signed-off-by: Timo Glastra <timo@animo.id>
Breaking up this PR as discussed. See #396 for first sub-PR
This PR became a bit bigger than anticipated, but one change led to another and so on. However I do think this PR packs some nice improvements.
validation on incoming messages
Fixes #68
Although used a lot, we weren't putting the validation decorators to good use yet (
@IsString
, etc...). I've enabled them and made updates where needed to make them valid. Already found some bugs. I think once we update the AFJ backchannel for AATH we'll probably find some more interop issues with ACA-Py.Only attach connection to inbound message context if sender and receiver match and connection is ready
Fixes #76
We were attaching the connection before it was ready and didn't do all necessary checks to make sure we're actually in the context of this connection. The connection is now only attached if the connection is ready to be used and fully matches with the incoming recipient and sender key.
### Break out indy walletFixes #330It didn't make a lot of sense to me that the indy wallet was handling indy storage and ledger stuff. I think it belongs more in the ledger and storage services. This is also more in line with where we're headed with the shared components librariesRenameLedgerService
toIndyLedgerService
. It's very indy focussed now.move storage related methods toIndyStorageService
move ledger related methods toIndyLedgerService
Better indy message handlingSometimes you would get very cryptic errors such asCommonInvalidParam
without a stack trace or anything that would help you get a sense of what's erroring out. I've wrapped all indy calls with a try catch and added a newIndySdkError
. This will take the indy error as input, but with very nice stack tracing so you know exactly where things went wrong, without losing information from the indy errorAlso fixed a bug where the mediator would terminate on unhandled promise