Skip to content

Commit

Permalink
Update to v6 rc.4
Browse files Browse the repository at this point in the history
  • Loading branch information
reinkrul committed Sep 27, 2024
1 parent 21ee7b1 commit 7751be7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 20 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/labstack/echo/v4 v4.11.4
github.com/lestrrat-go/jwx v1.2.28
github.com/nuts-foundation/go-did v0.14.0
github.com/nuts-foundation/go-nuts-client v0.1.4
github.com/nuts-foundation/go-nuts-client v0.1.6
github.com/oapi-codegen/runtime v1.1.1
github.com/rs/zerolog v1.33.0
github.com/spf13/pflag v1.0.5
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ github.com/nuts-foundation/go-nuts-client v0.1.3 h1:greij2A5o12T3CZisszkDksfokH3
github.com/nuts-foundation/go-nuts-client v0.1.3/go.mod h1:/apCT1jOnplzvbAsP0GvTgMyUA0fPtesUDwi7VGEi5U=
github.com/nuts-foundation/go-nuts-client v0.1.4 h1:UV010QfqMO5GFCHbWBxzMCSxrrK1Rw8f3a1NTsU85yQ=
github.com/nuts-foundation/go-nuts-client v0.1.4/go.mod h1:/apCT1jOnplzvbAsP0GvTgMyUA0fPtesUDwi7VGEi5U=
github.com/nuts-foundation/go-nuts-client v0.1.6 h1:wQcIcu8+1+zU2fp+B6Gds0rccqBOw5gCc0EBPKotIp0=
github.com/nuts-foundation/go-nuts-client v0.1.6/go.mod h1:/apCT1jOnplzvbAsP0GvTgMyUA0fPtesUDwi7VGEi5U=
github.com/oapi-codegen/oapi-codegen/v2 v2.3.0 h1:rICjNsHbPP1LttefanBPnwsSwl09SqhCO7Ee623qR84=
github.com/oapi-codegen/oapi-codegen/v2 v2.3.0/go.mod h1:4k+cJeSq5ntkwlcpQSxLxICCxQzCL772o30PxdibRt4=
github.com/oapi-codegen/runtime v1.1.1 h1:EXLHh0DXIJnWhdRPN2w4MXAzFyE4CskzhNLUmtpMYro=
Expand Down
13 changes: 5 additions & 8 deletions identity/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,9 @@ func (i Service) Get(ctx context.Context, subjectID string) (*IdentityDetails, e
})

// Get WalletCredentials
for _, currentDID := range identity.DIDs {
credentials, err := i.credentialsInWallet(ctx, currentDID)
if err != nil {
return nil, err
}
result.WalletCredentials = append(result.WalletCredentials, credentials...)
result.WalletCredentials, err = i.credentialsInWallet(ctx, subjectID)
if err != nil {
return nil, err
}

return &result, nil
Expand All @@ -119,8 +116,8 @@ func (i Service) getSubject(ctx context.Context, subject string) (*Identity, err
}, nil
}

func (i Service) credentialsInWallet(ctx context.Context, id string) ([]vc.VerifiableCredential, error) {
httpResponse, err := i.VCRClient.GetCredentialsInWallet(ctx, id)
func (i Service) credentialsInWallet(ctx context.Context, subjectID string) ([]vc.VerifiableCredential, error) {
httpResponse, err := i.VCRClient.GetCredentialsInWallet(ctx, subjectID)
response, err := nuts.ParseResponse(err, httpResponse, vcr.ParseGetCredentialsInWalletResponse)
if err != nil {
return nil, err
Expand Down
30 changes: 19 additions & 11 deletions web/src/admin/IssueCredential.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
<select v-on:change="selectSubjectDID" class="inline" style="width: 20%">
<option disabled value="" selected>choose wallet DID</option>
<optgroup v-for="entry in subjects" :key="'subject-' + entry.subject" :label="entry.subject">
<option :value="currentDID" v-for="currentDID in entry.dids" :key="'did-' + currentDID">
<option :value="entry.subject + '/' + currentDID" v-for="currentDID in entry.dids"
:key="'did-' + currentDID">
{{ currentDID }}
</option>
</optgroup>
Expand Down Expand Up @@ -88,6 +89,7 @@ export default {
fetchError: undefined,
credentialType: undefined,
subjectDID: undefined,
holderSubjectID: undefined,
issuerDID: undefined,
subjects: [],
templates: templates,
Expand Down Expand Up @@ -115,9 +117,11 @@ export default {
this.issuerDID = event.target.value
},
selectSubjectDID(event) {
this.subjectDID = event.target.value
// subject is in form of subjectID/did, need to parse it to set both
const parts = event.target.value.split('/')
this.holderSubjectID = parts[0]
this.subjectDID = parts[1]
event.target.value = ""
},
selectCredentialType(type) {
this.template = this.templates[type]
Expand Down Expand Up @@ -145,14 +149,18 @@ export default {
.then(issuedCredential => {
// Load issued VC into wallet
this.issuedCredential = issuedCredential
this.$api.post(`api/proxy/internal/vcr/v2/holder/${this.subjectDID}/vc`, issuedCredential)
.then(() => {
this.$emit('statusUpdate', 'Verifiable Credential issued and loaded into wallet')
})
.catch(reason => {
this.fetchError = "Couldn't load credential into wallet: " + reason
})
// If it's a local wallet, load it into the wallet
if (this.holderSubjectID) {
this.$api.post(`api/proxy/internal/vcr/v2/holder/${this.holderSubjectID}/vc`, issuedCredential)
.then(() => {
this.$emit('statusUpdate', 'Verifiable Credential issued, and loaded into wallet')
})
.catch(reason => {
this.fetchError = "Couldn't load credential into wallet: " + reason
})
} else {
this.$emit('statusUpdate', 'Verifiable Credential issued, NOTE: make sure to copy it to provide it to the holder!')
}
})
.catch(reason => {
this.fetchError = "Couldn't issue credential: " + reason
Expand Down

0 comments on commit 7751be7

Please sign in to comment.