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

Add DidComm Discovery Protocol Query/Disclosure message #71

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

Conversation

volodymyr-basiuk
Copy link
Contributor

No description provided.

@volodymyr-basiuk volodymyr-basiuk marked this pull request as ready for review December 23, 2024 12:17
vmidyllic
vmidyllic previously approved these changes Dec 23, 2024
var acceptProfiles []string
for _, p := range r.packers {
profiles := p.GetSupportedProfiles()
acceptProfiles = append(acceptProfiles, profiles...)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it a chance that two packers would have profiles with the same name and we would return duplicate entries?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It shouldn't be that way; otherwise, the first packer that matches the envelope would handle the pack()


const (
// ProtocolVersionV1 is a V1 version of the protocol used in the accept header
ProtocolVersionV1 AcceptProtocolVersion = "iden3comm/v1"
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO V duplicates the Version part. I would rename it either to ProtocolV1 or ProtocolVersion1.

Comment on lines 130 to 146
supportedAlgorithms := p.getSupportedAlgorithms()
algSupported := len(parsedProfile.AcceptAnoncryptAlgorithms) == 0
if !algSupported {
for _, alg := range parsedProfile.AcceptAnoncryptAlgorithms {
for _, supportedAlg := range supportedAlgorithms {
if string(alg) == supportedAlg {
algSupported = true
break
}
}
if algSupported {
break
}
}
}

return algSupported
Copy link
Contributor

Choose a reason for hiding this comment

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

a little less indentation and state variables

Suggested change
supportedAlgorithms := p.getSupportedAlgorithms()
algSupported := len(parsedProfile.AcceptAnoncryptAlgorithms) == 0
if !algSupported {
for _, alg := range parsedProfile.AcceptAnoncryptAlgorithms {
for _, supportedAlg := range supportedAlgorithms {
if string(alg) == supportedAlg {
algSupported = true
break
}
}
if algSupported {
break
}
}
}
return algSupported
if len(parsedProfile.AcceptJwsAlgorithms) == 0 {
return true
}
supportedAlgorithms := p.getSupportedAlgorithms()
for _, alg := range parsedProfile.AcceptJwsAlgorithms {
for _, supportedAlg := range supportedAlgorithms {
if string(alg) == supportedAlg {
return true
}
}
}
return false


// AcceptProfile is a struct that represents the accept header
type AcceptProfile struct {
ProtocolVersion AcceptProtocolVersion
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a little confused about naming. Correct me if I'm wrong.

The AcceptProtocolVersion type denotes the version of the protocol. Maybe it would be better to name this type ProtocolVersion instead of AcceptProtocolVersion. Moreover... as the package name is protocol, better to name this type just Version. Then it could be used in other packages as protocol.Version instead of protocol.ProtocolVersion.

On the other side, the field name ProtocolVersion stands for version that is accepted by this profile. So the field name is good candidate to be named as AcceptedVersion instead of ProtocolVersion.

)

// AcceptJwzAlgorithms is a type of accepted proving algorithms
type AcceptJwzAlgorithms string
Copy link
Contributor

Choose a reason for hiding this comment

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

I have the same confusion here as with the protocol. The type stands for Algorithm name. I don't see the reason to prepend the type name with Accept prefix. In the field name of this type it is OK to name the field AcceptJwsAlgorithms of type []JwsAlgorithms

And the same with AcceptAnoncryptAlgorithms.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to emphasize that this type is used in the Accept header, but you might be right; this algorithm could be a generic one.

utils/accept.go Show resolved Hide resolved
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.

3 participants