-
Notifications
You must be signed in to change notification settings - Fork 204
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
fix(oob): check service is string instance #814
fix(oob): check service is string instance #814
Conversation
Signed-off-by: Timo Glastra <timo@animo.id>
@@ -103,7 +103,7 @@ export class OutOfBandInvitation extends AgentMessage { | |||
// TODO: this only takes into account inline didcomm services, won't work for public dids | |||
public getRecipientKeys(): Key[] { | |||
return this.services | |||
.filter((s): s is OutOfBandDidCommService => typeof s !== 'string') | |||
.filter((s): s is OutOfBandDidCommService => typeof s !== 'string' && !(s instanceof String)) | |||
.map((s) => s.recipientKeys) |
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.
Just a comment. The error mentioned in #812 actually came from the ...curr
, because the previous map returns [undefined]
in case of public did is used in the invitation.
So I'd suggest to modify the second mapping something like this:
.map((s) => s.recipientKeys) | |
.map((s) => s.recipientKeys || []) |
or
.reduce((acc, curr = []) => [...acc, ...curr], [])
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.
Hmm the filter method should filter out all non-string values, so it shouldn't be possible there is a type undefined in the array. It think by adding this to the filter it won't have the undefined anymore.
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.
s.recipientKeys
was undefined. The json parser converts the string did into some weird object (maybe it was indeed String
sorry for confusion).
Codecov Report
@@ Coverage Diff @@
## main #814 +/- ##
==========================================
+ Coverage 86.53% 87.70% +1.17%
==========================================
Files 475 438 -37
Lines 12615 10823 -1792
Branches 2298 1892 -406
==========================================
- Hits 10916 9492 -1424
+ Misses 1594 1269 -325
+ Partials 105 62 -43
Continue to review full report at Codecov.
|
Signed-off-by: Timo Glastra timo@animo.id
Adds a check whether the service is instanceof String as mentioned in #812. this is needed due to the class-validator logic sadly.