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

fix(oob): check service is string instance #814

Merged
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -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))
berendsliedrecht marked this conversation as resolved.
Show resolved Hide resolved
.map((s) => s.recipientKeys)
Copy link
Contributor

@Iskander508 Iskander508 May 30, 2022

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:

Suggested change
.map((s) => s.recipientKeys)
.map((s) => s.recipientKeys || [])

or

     .reduce((acc, curr = []) => [...acc, ...curr], [])

Copy link
Contributor Author

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.

Copy link
Contributor

@Iskander508 Iskander508 May 30, 2022

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).

.reduce((acc, curr) => [...acc, ...curr], [])
.map((didKey) => DidKey.fromDid(didKey).key)
Expand Down