Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
reinkrul committed Jan 3, 2024
1 parent 4655327 commit 1081e94
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions discovery/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,29 @@ func (r *scheduledRegistrationManager) unregister(ctx context.Context, serviceID
if err != nil {
return err
}

// if the DID has an active registration, retract it
presentations, err := r.store.search(serviceID, map[string]string{
"credentialSubject.id": subjectDID.String(),
})
if err != nil {
return errors.Join(ErrRegistrationFailed, err)
}
if len(presentations) == 0 {
// error occurred, or no active registration found
return err
return nil
}
service := r.services[serviceID]
presentation, err := r.buildPresentation(ctx, subjectDID, service, nil, map[string]interface{}{
"retract_jti": presentations[0].ID.String(),
})

if err != nil {
return errors.Join(ErrRegistrationFailed, err)
}
err = r.client.Register(ctx, service.Endpoint, *presentation)
if err != nil {
return errors.Join(ErrRegistrationFailed, err)
}
return nil
}

func (r *scheduledRegistrationManager) registerPresentation(ctx context.Context, subjectDID did.DID, service ServiceDefinition) error {
Expand Down

0 comments on commit 1081e94

Please sign in to comment.