chromium/chromeos/ash/services/nearby/public/mojom/nearby_presence_credential_storage.mojom

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module ash.nearby.presence.mojom;

import "chromeos/ash/services/nearby/public/mojom/nearby_presence.mojom";
import "mojo/public/mojom/base/absl_status.mojom";

// Used by the utility process to fetch from and write to the storage component
// of credentials for Nearby Presence. Implementation lives in
// the browser process.
// TODO(b/287333989): Implement relevant methods.
interface NearbyPresenceCredentialStorage {
  // SaveCredentials saves the provided credentials to the Nearby Presence
  // Credential Storage database. If the credentials were saved successfully,
  // 'status' will be kOk, otherwise, it will be kFailure.
  // TODO(b/300673037): Adjust local_credentials to be an optional vector,
  // as it is unused when 'public_credential_type' is kRemotePublicCredential.
  SaveCredentials(array<LocalCredential> local_credentials,
                  array<SharedCredential> shared_credentials,
                  PublicCredentialType public_credential_type)
      => (mojo_base.mojom.AbslStatusCode status);

  // GetPublicCredentials returns Nearby Presence shared credentials of
  // the specified type (PublicCredentialType) stored in the database. If
  // retrieving the credentials fails, shared_credentials will be null.
  GetPublicCredentials(PublicCredentialType public_credential_type)
      => (mojo_base.mojom.AbslStatusCode status,
          array<SharedCredential>? shared_credentials);

  // GetPrivateCredentials returns Nearby Presence private credentials
  // stored in the database. If retrieving the credentials fails,
  // local_credentials will be null.
  GetPrivateCredentials() => (mojo_base.mojom.AbslStatusCode status,
          array<LocalCredential>? local_credentials);

  // UpdateLocalCredential finds an existing entry in the private database
  // with a 'secret_id' matching that of 'local_credential', and updates it
  // if it exists.
  UpdateLocalCredential(LocalCredential local_credential)
      => (mojo_base.mojom.AbslStatusCode status);
};