diff --git a/internal/interop/BUILD b/internal/interop/BUILD index a4f9e5f3..20f4a349 100644 --- a/internal/interop/BUILD +++ b/internal/interop/BUILD @@ -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__", + ], +) diff --git a/internal/interop/authentication_status.h b/internal/interop/authentication_status.h new file mode 100644 index 00000000..fc1f9a16 --- /dev/null +++ b/internal/interop/authentication_status.h @@ -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_ diff --git a/internal/interop/device_provider.h b/internal/interop/device_provider.h index 380e5c0c..5e80ffd5 100644 --- a/internal/interop/device_provider.h +++ b/internal/interop/device_provider.h @@ -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. diff --git a/presence/BUILD b/presence/BUILD index 5c1d61a0..aea8593f 100644 --- a/presence/BUILD +++ b/presence/BUILD @@ -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", diff --git a/presence/presence_device_provider.cc b/presence/presence_device_provider.cc index 3b4628e1..d9cedc8e 100644 --- a/presence/presence_device_provider.cc +++ b/presence/presence_device_provider.cc @@ -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" diff --git a/presence/presence_device_provider.h b/presence/presence_device_provider.h index 001f9f2f..9542827d 100644 --- a/presence/presence_device_provider.h +++ b/presence/presence_device_provider.h @@ -19,6 +19,7 @@ #include #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" diff --git a/presence/presence_device_provider_test.cc b/presence/presence_device_provider_test.cc index affe0ac3..6bc178c9 100644 --- a/presence/presence_device_provider_test.cc +++ b/presence/presence_device_provider_test.cc @@ -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" diff --git a/sharing/BUILD b/sharing/BUILD index 676f06b8..79b00f4f 100644 --- a/sharing/BUILD +++ b/sharing/BUILD @@ -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", diff --git a/sharing/nearby_connections_types.h b/sharing/nearby_connections_types.h index c874005d..903cdb8e 100644 --- a/sharing/nearby_connections_types.h +++ b/sharing/nearby_connections_types.h @@ -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.