forked from trustbloc/adapter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [WACI-Issuance] Support to read credential manifest
closes trustbloc#561 Signed-off-by: talwinder50 <[email protected]>
- Loading branch information
1 parent
8c4b652
commit 3919b0f
Showing
6 changed files
with
106 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,6 +104,7 @@ const ( | |
|
||
// WACI interaction constants | ||
credentialManifestFormat = "dif/credential-manifest/[email protected]" | ||
credentialManifestVersion = "1.0.0" | ||
credentialFulfillmentFormat = "dif/credential-manifest/[email protected]" | ||
offerCredentialAttachMediaType = "application/json" | ||
redirectStatusOK = "OK" | ||
|
@@ -155,6 +156,7 @@ type Config struct { | |
ExternalURL string | ||
DidDomain string | ||
JSONLDDocumentLoader ld.DocumentLoader | ||
CmOutputDescriptor map[string][]*cm.OutputDescriptor | ||
} | ||
|
||
// New returns issuer rest instance. | ||
|
@@ -342,6 +344,7 @@ type Operation struct { | |
getOIDCClientFunc func(string, string) (oidcClient, error) | ||
didDomain string | ||
jsonldDocLoader ld.DocumentLoader | ||
cmOutputDescriptor map[string][]*cm.OutputDescriptor | ||
} | ||
|
||
// GetRESTHandlers get all controller API handler available for this service. | ||
|
@@ -1290,8 +1293,13 @@ func (o *Operation) handleProposeCredential(msg service.DIDCommAction) (issuecre | |
} | ||
} | ||
|
||
// get manifest | ||
manifest := o.readCredentialManifest() | ||
txn, err := o.getTxn(userInvMap.TxID) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to get trasaction data: %w", err) | ||
} | ||
|
||
// read credential manifest | ||
manifest := o.readCredentialManifest(profile, txn.CredScope) | ||
|
||
// get unsigned credential | ||
vc, err := o.createCredential(getUserDataURL(profile.URL), userInvMap.TxToken, oauthToken, | ||
|
@@ -1728,12 +1736,24 @@ func (o *Operation) hanlDIDExStateMsg(msg service.StateMsg) error { | |
return nil | ||
} | ||
|
||
// read credential manifest from profile URL endpoints | ||
// TODO for now returning empty manifest, TO BE IMPLEMENTED [issue##561 & issue#563] | ||
func (o *Operation) readCredentialManifest() *cm.CredentialManifest { | ||
return &cm.CredentialManifest{ | ||
ID: uuid.NewString(), | ||
/* | ||
read credential manifest issuer detail from persisted profile data and scope | ||
from the persisted transaction cred scope. | ||
*/ | ||
// 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 { | ||
if scope == txnCredScope { | ||
return &cm.CredentialManifest{ | ||
ID: uuid.NewString(), | ||
Version: credentialManifestVersion, | ||
Issuer: profileData.CredentialManifestIssuer, | ||
OutputDescriptors: cmDesciptor, | ||
} | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func prepareOfferCredentialMessage(manifest *cm.CredentialManifest, fulfillment *verifiable.Presentation) *issuecredsvc.OfferCredentialParams { // nolint:lll | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters