[Nearby Presence] Add authentication status to ConnectionInfo

Adds authentication status to `ConnectionInfo`, which will pass the result of the authentication to clients when the connection is complete. See go/cros-nearby-presence-np-nc-authentication for details. This will be used in follow up CL to communicate the authentication status to clients of RequestConnectionV3().

PiperOrigin-RevId: 606789503
This commit is contained in:
Juliet Levesque
2024-02-13 16:49:49 -08:00
committed by Copybara-Service
parent caf34a717f
commit fb1f01717f
9 changed files with 59 additions and 8 deletions
+13
View File
@@ -22,9 +22,22 @@ cc_library(
"//presence:__subpackages__",
],
deps = [
":authentication_status",
":authentication_transport_interface",
"//internal/platform:connection_info",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:variant",
],
)
cc_library(
name = "authentication_status",
hdrs = [
"authentication_status.h",
],
visibility = [
"//connections:__subpackages__",
"//presence:__subpackages__",
"//sharing:__subpackages__",
],
)
+28
View File
@@ -0,0 +1,28 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef THIRD_PARTY_NEARBY_CONNECTIONS_AUTHENTICATION_STATUS_H_
#define THIRD_PARTY_NEARBY_CONNECTIONS_AUTHENTICATION_STATUS_H_
namespace nearby {
enum class AuthenticationStatus {
kUnknown = 0,
kSuccess = 1,
kFailure = 2,
};
} // namespace nearby
#endif // THIRD_PARTY_NEARBY_CONNECTIONS_AUTHENTICATION_STATUS_H_
+1 -6
View File
@@ -15,17 +15,12 @@
#ifndef THIRD_PARTY_NEARBY_CONNECTIONS_DEVICE_PROVIDER_H_
#define THIRD_PARTY_NEARBY_CONNECTIONS_DEVICE_PROVIDER_H_
#include "internal/interop/authentication_status.h"
#include "internal/interop/authentication_transport.h"
#include "internal/interop/device.h"
namespace nearby {
enum class AuthenticationStatus {
kUnknown = 0,
kSuccess = 1,
kFailure = 2,
};
// The base device provider class for use with the Nearby Connections V3 APIs.
// This class currently provides a function to get the local device for whatever
// client implements it.
+2
View File
@@ -31,6 +31,7 @@ cc_library(
],
deps = [
":types",
"//internal/interop:authentication_status",
"//internal/interop:authentication_transport_interface",
"//internal/interop:device",
"//internal/platform:base",
@@ -187,6 +188,7 @@ cc_test(
":presence",
":types",
"//internal/crypto",
"//internal/interop:authentication_status",
"//internal/interop:authentication_transport_interface",
"//internal/interop:device",
"//internal/platform:test_util",
+1 -1
View File
@@ -22,9 +22,9 @@
#include "absl/types/variant.h"
#include "absl/strings/string_view.h"
#include "absl/time/time.h"
#include "internal/interop/authentication_status.h"
#include "internal/interop/authentication_transport.h"
#include "internal/interop/device.h"
#include "internal/interop/device_provider.h"
#include "internal/platform/exception.h"
#include "internal/platform/future.h"
#include "internal/platform/implementation/system_clock.h"
+1
View File
@@ -19,6 +19,7 @@
#include <string>
#include "absl/strings/string_view.h"
#include "internal/interop/authentication_status.h"
#include "internal/interop/authentication_transport.h"
#include "internal/interop/device.h"
#include "internal/interop/device_provider.h"
+1 -1
View File
@@ -28,8 +28,8 @@
#include "absl/strings/string_view.h"
#include "absl/time/time.h"
#include "internal/crypto/ed25519.h"
#include "internal/interop/authentication_status.h"
#include "internal/interop/authentication_transport.h"
#include "internal/interop/device_provider.h"
#include "internal/platform/implementation/credential_callbacks.h"
#include "internal/platform/implementation/system_clock.h"
#include "internal/proto/credential.pb.h"
+2
View File
@@ -5,6 +5,7 @@ cc_library(
hdrs = ["nearby_connections_types.h"],
deps = [
"//internal/crypto_cros",
"//internal/interop:authentication_status",
"//sharing/common:compatible_u8_string",
"@com_google_absl//absl/strings:string_view",
"@com_google_absl//absl/time",
@@ -43,6 +44,7 @@ cc_library(
],
deps = [
"//internal/crypto_cros",
"//internal/interop:authentication_status",
"//internal/network:types",
"//sharing/common",
"//sharing/common:compatible_u8_string",
+10
View File
@@ -27,6 +27,7 @@
#include "absl/strings/string_view.h"
#include "absl/time/time.h"
#include "internal/crypto_cros/random.h"
#include "internal/interop/authentication_status.h"
#include "sharing/common/compatible_u8_string.h"
namespace nearby {
@@ -121,6 +122,15 @@ struct ConnectionInfo {
bool is_incoming_connection;
// Connection status used for analytics
Status connection_layer_status = Status::kUnknown;
// Result of authenticating the device with the DeviceProvider, which is only
// used during `RequestConnectionV3()`. Based on the result, clients should
// do the following:
// - `AuthenticationStatus::kFailure`: disconnect from the remote device
// - `AuthenticationStatus::kUnknown`: prompt the user to confirm the PIN on
// both sides (retaining existing behavior)
// - `AuthenticationStatus::kSuccess`: connect to the device with no further
// prompting
AuthenticationStatus authentication_status = AuthenticationStatus::kUnknown;
};
// Information about an endpoint when it's discovered.