Skip to content

Commit

Permalink
Misc
Browse files Browse the repository at this point in the history
  • Loading branch information
rdnt committed Jul 5, 2023
1 parent 76d04bc commit e530080
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
12 changes: 8 additions & 4 deletions src/client/remote/invitations.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ func (r *Remote) DeleteInvitation(id string) (invitation.Invitation, error) {
return inv, nil
}

func (r *Remote) FinalizeInvitation(invitationId string, privateKey []byte, inviteePublicKey []byte, k keystore.Keystore) (invitation.Invitation, error) {
func (r *Remote) FinalizeInvitation(
invitationId string, privateKey []byte, inviteePublicKey []byte, k keystore.Keystore,
) (invitation.Invitation, error) {
// derive shared secret using the user's private key and the invitee's public key
sharedSecret, err := curve25519.X25519(privateKey, inviteePublicKey)
if err != nil {
Expand All @@ -154,9 +156,11 @@ func (r *Remote) FinalizeInvitation(invitationId string, privateKey []byte, invi
return invitation.Invitation{}, errors.WithMessage(err, "failed to encrypt keystore key")
}

res, err := r.client.FinalizeInvitationWithResponse(context.Background(), invitationId, generated.FinalizeInvitationJSONRequestBody{
KeystoreKey: encryptedKeystoreKey,
})
res, err := r.client.FinalizeInvitationWithResponse(context.Background(),
invitationId, generated.FinalizeInvitationJSONRequestBody{
KeystoreKey: encryptedKeystoreKey,
},
)
if err != nil {
return invitation.Invitation{}, errors.Wrap(err, "failed to finalize invitation")
}
Expand Down
15 changes: 7 additions & 8 deletions src/client/remote/keystores.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ func (r *Remote) UpdateKeystore(k keystore.Keystore) (keystore.Keystore, error)
return keystore.Keystore{}, errors.WithMessage(err, "aes256cbc encrypt failed")
}

res, err := r.client.UpdateKeystoreWithResponse(context.Background(), k.RemoteId, generated.UpdateKeystoreRequest{
Name: &k.Name,
Payload: &b,
})
res, err := r.client.UpdateKeystoreWithResponse(context.Background(),
k.RemoteId, generated.UpdateKeystoreRequest{
Name: &k.Name,
Payload: &b,
})
if err != nil {
return keystore.Keystore{}, errors.Wrap(err, "failed to update keystore")
}
Expand All @@ -81,14 +82,12 @@ func (r *Remote) UpdateKeystore(k keystore.Keystore) (keystore.Keystore, error)
return keystore.Keystore{}, errors.New("invalid response")
}

k2, err := KeystoreFromJSON(*res.JSON200, k.Key)
_, err = KeystoreFromJSON(*res.JSON200, k.Key)
if err != nil {
return keystore.Keystore{}, errors.WithMessage(err, "failed to parse keystore")
}

k2.Key = k.Key

return k2, nil
return k, nil
}

func (r *Remote) DeleteKeystore(id string) error {
Expand Down

0 comments on commit e530080

Please sign in to comment.