Skip to content

Commit

Permalink
chore: In GetRemote and ListKeyInfo, if useGnokeyMobile then use the …
Browse files Browse the repository at this point in the history
…remote service.

Signed-off-by: Jeff Thompson <[email protected]>
  • Loading branch information
jefft0 committed Aug 8, 2024
1 parent cd1decb commit ca96e9c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions service/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ func (s *gnoNativeService) SetRemote(ctx context.Context, req *connect.Request[a
}

func (s *gnoNativeService) GetRemote(ctx context.Context, req *connect.Request[api_gen.GetRemoteRequest]) (*connect.Response[api_gen.GetRemoteResponse], error) {
if s.useGnokeyMobile {
// Always get the remote from the Gnokey Mobile service
res, err := s.gnokeyMobileClient.GetRemote(context.Background(), req)
if err != nil {
return nil, err
}

return connect.NewResponse(res.Msg), nil
}

return connect.NewResponse(&api_gen.GetRemoteResponse{Remote: s.ClientGetRemote()}), nil
}

Expand Down Expand Up @@ -77,6 +87,16 @@ func ConvertKeyInfo(key crypto_keys.Info) (*api_gen.KeyInfo, error) {
func (s *gnoNativeService) ListKeyInfo(ctx context.Context, req *connect.Request[api_gen.ListKeyInfoRequest]) (*connect.Response[api_gen.ListKeyInfoResponse], error) {
s.logger.Debug("ListKeyInfo called")

if s.useGnokeyMobile {
// Always get the list of keys from the Gnokey Mobile service
res, err := s.gnokeyMobileClient.ListKeyInfo(context.Background(), req)
if err != nil {
return nil, err
}

return connect.NewResponse(res.Msg), nil
}

keys, err := s.ClientListKeyInfo()
if err != nil {
return nil, err
Expand Down

0 comments on commit ca96e9c

Please sign in to comment.