Skip to content
This repository has been archived by the owner on Apr 5, 2023. It is now read-only.

feat: [WACI-Issuance] Support to read credential manifest #574

Merged
merged 1 commit into from
Jan 26, 2022

Conversation

talwinder50
Copy link
Member

@talwinder50 talwinder50 commented Jan 21, 2022

closes #582

Signed-off-by: talwinder50 talwinderkaur50@gmail.com

@codecov
Copy link

codecov bot commented Jan 21, 2022

Codecov Report

Merging #574 (9ff8c67) into main (837ffab) will decrease coverage by 0.06%.
The diff coverage is 86.36%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #574      +/-   ##
==========================================
- Coverage   87.64%   87.58%   -0.07%     
==========================================
  Files          29       29              
  Lines        4201     4220      +19     
==========================================
+ Hits         3682     3696      +14     
- Misses        305      310       +5     
  Partials      214      214              
Impacted Files Coverage Δ
pkg/profile/issuer/profile.go 89.47% <ø> (ø)
pkg/restapi/issuer/operation/operations.go 89.59% <85.00%> (-0.28%) ⬇️
cmd/adapter-rest/startcmd/start.go 82.24% <100.00%> (+0.03%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 837ffab...9ff8c67. Read the comment docs.

@@ -872,6 +872,7 @@ func addIssuerHandlers(parameters *adapterRestParameters, framework *aries.Aries
ExternalURL: parameters.externalURL,
DidDomain: parameters.trustblocDomain,
JSONLDDocumentLoader: ariesCtx.JSONLDDocumentLoader(),
CmOutputDescriptor: cmOutputDescriptor,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should be CMOutputDescriptor for consistency with the naming conventions

@@ -892,7 +892,7 @@ func addIssuerHandlers(parameters *adapterRestParameters, framework *aries.Aries
if err != nil {
return fmt.Errorf("failed to init trustbloc did creator: %w", err)
}
// TODO #572 Pass the output descriptors to issuer
// TODO #575 Persist the manifest output descriptor in database
Copy link
Member

Choose a reason for hiding this comment

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

correction on TODO: it shouldn't be in database since you pass it everytime you start adapter, it should be in some kind of local file. based or in-memory cache.

add that new issue into current epic you are working on.

I don't see any issues in adapter numbered #575

Copy link
Member Author

Choose a reason for hiding this comment

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

updated and fixed the issue # as well

// TODO #572 Pass the output descriptors to issuer
_, err = readCMOutputDescriptorFile(parameters.cmOutputDescriptorsFilePath)

CMOutputDescriptor, err := readCMOutputDescriptorFile(parameters.cmOutputDescriptorsFilePath)
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this local var name start with lower case ?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -45,7 +46,7 @@ type ProfileData struct {
OIDCClientParams *OIDCClientParams `json:"oidcParams,omitempty"`
CredentialScopes []string `json:"credScopes,omitempty"`
LinkedWalletURL string `json:"linkedWallet,omitempty"`
// Todo #issue Add credential manifest issuer object
CredentialManifestIssuer cm.Issuer `json:"issuer,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Can't we use Name from line 36 rather a new variable ?

Copy link
Member

Choose a reason for hiding this comment

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

I was wondering same, profile name & issuer names are same? remember issuer.Name name gets displayed in.wallet UI.

Copy link
Member

Choose a reason for hiding this comment

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

It is - same is displayed in DIDComm CHAPI screens as well during sharing (passed as part of credential.issuer field).

Copy link
Member

Choose a reason for hiding this comment

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

@talwinder50 remove cm.Issuer and use

  • Name - already there
  • IssuerID - put comment as it is going to be used as issuer ID in credential manifests being issued
  • Style - style object from aries credential manifest package, add go comments to explain it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated

Copy link
Member

Choose a reason for hiding this comment

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

@talwinder50 I don't see any updates

@@ -45,7 +46,7 @@ type ProfileData struct {
OIDCClientParams *OIDCClientParams `json:"oidcParams,omitempty"`
CredentialScopes []string `json:"credScopes,omitempty"`
LinkedWalletURL string `json:"linkedWallet,omitempty"`
// Todo #issue Add credential manifest issuer object
CredentialManifestIssuer cm.Issuer `json:"issuer,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

you do schema validation when CredentialManifestIssuer is supplied? Better to fail here rather than failing during transaction later during WACI.

Add some go doc comments about usage and expected format of this field.

Copy link
Collaborator

Choose a reason for hiding this comment

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

From the spec, you'd need to make sure the ID is not empty:

The object MUST contain a id property, and its value MUST be a valid URI string that identifies who the issuer of the credential(s) will be.

My CredentialManifest validation code makes sure that the ID isn't empty, but only if you unmarshal a full CredentialManifest... (which will happen during the transaction, causing a failure)

Copy link
Member Author

Choose a reason for hiding this comment

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

#581 Validation of the manifest will be done as part of this todo. Which i will address in the follow up pr.

@@ -104,6 +104,7 @@ const (

// WACI interaction constants
credentialManifestFormat = "dif/credential-manifest/manifest@v1.0"
credentialManifestVersion = "1.0.0"
Copy link
Member

Choose a reason for hiding this comment

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

0.1.0

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -155,6 +156,7 @@ type Config struct {
ExternalURL string
DidDomain string
JSONLDDocumentLoader ld.DocumentLoader
CmOutputDescriptor map[string][]*cm.OutputDescriptor
Copy link
Member

Choose a reason for hiding this comment

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

this object will be heavy, I would suggest you put a helper struct here which has functions to find and return subset of output descriptors by credential scope. So that you can swap underlying memory store with cache in future with little effort.

Copy link
Member Author

Choose a reason for hiding this comment

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

#580 I will address this optimization in the follow up pr , if its okay with you @sudeshrshetty

// TODO issue#561 Add credential manifest presentation definition
func (o *Operation) readCredentialManifest(profileData *issuer.ProfileData,
txnCredScope string) *cm.CredentialManifest {
for scope, cmDesciptor := range o.cmOutputDescriptor {
Copy link
Member

Choose a reason for hiding this comment

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

loop can be replaced by a single line o.cmOutputDescriptor[txnCredScope]

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@sudeshrshetty
Copy link
Member

I don't see resolution for this comment : #574 (comment)

ID: uuid.NewString(),
Version: credentialManifestVersion,
Issuer: cm.Issuer{
ID: profileData.ID,
Copy link
Member

Choose a reason for hiding this comment

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

you can not use profile ID here, this is not issuer ID

Copy link
Member Author

Choose a reason for hiding this comment

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

@sudeshrshetty In here when we are creating credential the issuer id we are using profile.url

cred.Issuer.ID = profile.URL

Does this implies the issuer adapter is creating credential and thats why using profile URL ? Is this correct ??

Copy link
Member

Choose a reason for hiding this comment

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

this looks wrong, don't use that. Profile ID is some UUID generated to co-relate data in adapter it has nothing to do with actual identity of issuer.

Refer this example for credential manifest: https://identity.foundation/credential-manifest/#credential-manifest---all-features-exercised

For let profile creation option accept issuer ID & Style as input arguments as I mentioned here

Copy link
Member Author

Choose a reason for hiding this comment

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

@sudeshrshetty I have added issuerID and cmstyle in profile data as when New issuer onboards to adapter it need to provide issuer ID and manifest style for that specific profile.

Copy link
Member

Choose a reason for hiding this comment

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

where it is set?

Issuer: cm.Issuer{
ID: profileData.ID,
Name: profileData.Name,
Styles: cm.Styles{},
Copy link
Member

Choose a reason for hiding this comment

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

Style has to be provided by issuer

@talwinder50 talwinder50 force-pushed the issue-561 branch 2 times, most recently from 1b60db5 to 690b8e6 Compare January 26, 2022 14:45
ID: uuid.NewString(),
Version: credentialManifestVersion,
Issuer: cm.Issuer{
ID: profileData.IssuerID,
Copy link
Member

Choose a reason for hiding this comment

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

I don't see anywhere these being set to profile data??
Where is profile creation step which accepts these 2 additional params - IssuerID & CMStyle?

Copy link
Member Author

Choose a reason for hiding this comment

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

IssuerID: data.IssuerID,
Its being set here

Copy link
Member

Choose a reason for hiding this comment

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

@talwinder50 I meant how an issuer can pass it? I don't see these as part of profile creation request

Copy link
Member Author

Choose a reason for hiding this comment

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

@sudeshrshetty It is mentioned here

IssuerID string `json:"issuerID,omitempty"`

@@ -69,7 +69,7 @@
}
}
],
"prc": [
"PermanentResidentCard": [
Copy link
Member

Choose a reason for hiding this comment

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

why is it renamed?

Copy link
Member Author

Choose a reason for hiding this comment

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

local change pushed by mistake

@@ -27,6 +28,8 @@ type ProfileDataRequest struct {
OIDCClientParams *OIDCClientParams `json:"oidcParams,omitempty"`
CredentialScopes []string `json:"scopes,omitempty"`
LinkedWalletURL string `json:"linkedWallet,omitempty"`
IssuerID string `json:"issuerID,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

follow up: please add comments explaining usage of these params so that it can show up in documentation.
(can be done in future PRs)

return &cm.CredentialManifest{
ID: uuid.NewString(),
Issuer: cm.Issuer{
ID: profileData.ID,
Copy link
Member

Choose a reason for hiding this comment

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

you missed here? issuer ID instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

closes trustbloc#561

Signed-off-by: talwinder50 <talwinderkaur50@gmail.com>
@talwinder50 talwinder50 merged commit fe16daf into trustbloc:main Jan 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement read credential logic
4 participants