mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Cleanup
PiperOrigin-RevId: 879854458
This commit is contained in:
committed by
Copybara-Service
parent
14ad036bf2
commit
0cc01b476c
@@ -332,7 +332,6 @@ cc_library(
|
||||
"//connections/implementation/flags:connections_flags",
|
||||
"//internal/base",
|
||||
"//internal/flags:nearby_flags",
|
||||
"//internal/platform/implementation:account_manager",
|
||||
"//internal/platform/implementation:comm",
|
||||
"//internal/platform/implementation:platform",
|
||||
"//internal/platform/implementation:wifi_utils",
|
||||
|
||||
@@ -17,69 +17,6 @@ load("@rules_cc//cc:cc_test.bzl", "cc_test")
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
cc_library(
|
||||
name = "auth_status",
|
||||
hdrs = ["auth_status.h"],
|
||||
visibility = [
|
||||
"//internal/auth:__pkg__",
|
||||
"//internal/platform/implementation:__subpackages__",
|
||||
"//location/nearby/cpp/sharing/clients/cpp:__subpackages__",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "account_info",
|
||||
hdrs = ["account_info.h"],
|
||||
visibility = [
|
||||
"//internal/auth:__pkg__",
|
||||
"//internal/platform/implementation:__subpackages__",
|
||||
"//location/nearby/cpp/sharing/clients/cpp:__subpackages__",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "account_manager",
|
||||
hdrs = ["account_manager.h"],
|
||||
visibility = [
|
||||
"//internal/account:__pkg__",
|
||||
"//internal/platform:__pkg__",
|
||||
"//internal/platform/implementation:__subpackages__",
|
||||
"//internal/test:__subpackages__",
|
||||
"//location/nearby/cpp/sharing/clients/cpp:__subpackages__",
|
||||
"//location/nearby/sharing/lib:__subpackages__",
|
||||
"//location/nearby/sharing/sdk/quick_share_server:__pkg__",
|
||||
"//sharing:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
":account_info",
|
||||
":signin_attempt",
|
||||
"@com_google_absl//absl/functional:any_invocable",
|
||||
"@com_google_absl//absl/status",
|
||||
"@com_google_absl//absl/status:statusor",
|
||||
"@com_google_absl//absl/strings:string_view",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "signin_attempt",
|
||||
hdrs = ["signin_attempt.h"],
|
||||
visibility = [
|
||||
"//internal/account:__pkg__",
|
||||
"//internal/auth:__pkg__",
|
||||
"//internal/platform/implementation:__subpackages__",
|
||||
"//internal/test:__subpackages__",
|
||||
"//location/nearby/cpp/sharing/clients/cpp:__subpackages__",
|
||||
"//location/nearby/sharing/sdk/quick_share_server:__pkg__",
|
||||
"//sharing:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
":account_info",
|
||||
":auth_status",
|
||||
"@com_google_absl//absl/functional:any_invocable",
|
||||
"@com_google_absl//absl/strings:string_view",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "types",
|
||||
hdrs = [
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
// Copyright 2024 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_INTERNAL_PLATFORM_IMPLEMENTATION_ACCOUNT_INFO_H_
|
||||
#define THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_ACCOUNT_INFO_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace nearby {
|
||||
|
||||
// Describes a Nearby account. The account class will have more properties
|
||||
// and methods in the future based on the new feature added.
|
||||
struct AccountInfo {
|
||||
std::string id; // The unique identify of the account.
|
||||
std::string display_name;
|
||||
std::string family_name;
|
||||
std::string given_name;
|
||||
std::string picture_url;
|
||||
std::string email;
|
||||
};
|
||||
|
||||
} // namespace nearby
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_ACCOUNT_INFO_H_
|
||||
@@ -1,89 +0,0 @@
|
||||
// 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 PLATFORM_API_ACCOUNT_MANAGER_H_
|
||||
#define PLATFORM_API_ACCOUNT_MANAGER_H_
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/status/statusor.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "internal/platform/implementation/account_info.h"
|
||||
#include "internal/platform/implementation/signin_attempt.h"
|
||||
|
||||
namespace nearby {
|
||||
|
||||
// AccountManager manages the accounts are used to access Nearby backend.
|
||||
// In current design, AccountManager only support one active account.
|
||||
class AccountManager {
|
||||
public:
|
||||
using Account = AccountInfo;
|
||||
|
||||
// Observes the activity of the account manager.
|
||||
class Observer {
|
||||
public:
|
||||
virtual ~Observer() = default;
|
||||
|
||||
virtual void OnLoginSucceeded(absl::string_view account_id) = 0;
|
||||
// |credential_error| is true if the logout is due to critical auth error.
|
||||
virtual void OnLogoutSucceeded(absl::string_view account_id,
|
||||
bool credential_error) = 0;
|
||||
};
|
||||
|
||||
virtual ~AccountManager() = default;
|
||||
|
||||
// Gets current active account. If no login user, return std::nullopt.
|
||||
virtual std::optional<Account> GetCurrentAccount() = 0;
|
||||
|
||||
// Initializes the login process for a Google account from an oauth client.
|
||||
// |client_id| GCP client_id of the client
|
||||
// |client_secret| GCP client_secret of the client
|
||||
// Returns a SigninAttempt object that can be used to complete the login
|
||||
// process.
|
||||
virtual std::unique_ptr<SigninAttempt> Login(
|
||||
absl::string_view client_id, absl::string_view client_secret) = 0;
|
||||
|
||||
// Logs out current active account. |logout_callback| is called when logout is
|
||||
// completed.
|
||||
virtual void Logout(
|
||||
absl::AnyInvocable<void(absl::Status)> logout_callback) = 0;
|
||||
|
||||
// Gets access token for the active account.
|
||||
// |callback| is called with the access token or error status.
|
||||
//
|
||||
// Returns false if callback is null.
|
||||
virtual bool GetAccessToken(
|
||||
absl::AnyInvocable<void(absl::StatusOr<std::string>)> callback) = 0;
|
||||
|
||||
// Returns a pair containing the client id and client secret used in the most
|
||||
// recent Login request.
|
||||
// If no current user is logged in, returns empty string for both.
|
||||
virtual std::pair<std::string, std::string> GetOAuthClientCredential() = 0;
|
||||
|
||||
virtual void AddObserver(Observer* observer) = 0;
|
||||
virtual void RemoveObserver(Observer* observer) = 0;
|
||||
|
||||
virtual void SaveAccountPrefs(absl::string_view user_id,
|
||||
absl::string_view client_id,
|
||||
absl::string_view client_secret) = 0;
|
||||
};
|
||||
|
||||
} // namespace nearby
|
||||
|
||||
#endif // PLATFORM_API_ACCOUNT_MANAGER_H_
|
||||
@@ -1,88 +0,0 @@
|
||||
// Copyright 2024 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_INTERNAL_PLATFORM_IMPLEMENTATION_AUTH_STATUS_H_
|
||||
#define THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_AUTH_STATUS_H_
|
||||
|
||||
namespace nearby {
|
||||
|
||||
enum AuthStatus {
|
||||
AUTH_STATUS_UNSPECIFIED = 0,
|
||||
// Request completed successfully, the results should be in the correct order
|
||||
// up to the given count.
|
||||
SUCCESS = 1,
|
||||
|
||||
// Request encountered a generic error.
|
||||
GENERIC_ERROR = 2,
|
||||
|
||||
// Request as specified is not supported.
|
||||
UNSUPPORTED = 3,
|
||||
|
||||
// Request failed and should be retried soon.
|
||||
TEMPORARILY_UNAVAILABLE = 4,
|
||||
|
||||
// Request failed due to an unavailable resource.
|
||||
UNAVAILABLE_RESOURCE = 5,
|
||||
|
||||
// The request failed due to an invalid argument.
|
||||
INVALID_ARGUMENT = 6,
|
||||
|
||||
// In case the status could not be retrieved.
|
||||
UNKNOWN_STATUS = 7,
|
||||
|
||||
// Currently used as a way to signal an ETag mismatch.
|
||||
PRECONDITION_FAILED = 8,
|
||||
|
||||
// Exclusively used to report when user did not consent to required scopes.
|
||||
// Do NOT use this for another other scenarios.
|
||||
PERMISSION_DENIED = 9,
|
||||
|
||||
// The resource exists, but the requested attribute of it does not.
|
||||
MISSING_ATTRIBUTE = 10,
|
||||
|
||||
// The method was interrupted and the caller should exit the current unit of
|
||||
// work immediately.
|
||||
INTERRUPTED = 11,
|
||||
|
||||
// User signed in with an unexpected account.
|
||||
SIGNED_IN_WITH_WRONG_ACCOUNT = 12,
|
||||
|
||||
// Used when data cannot be parsed properly.
|
||||
PARSE_ERROR = 13,
|
||||
|
||||
// Used to report that the local HTTP server for receiving the authorization
|
||||
// code cannot be created.
|
||||
CANT_CREATE_AUTH_SERVER = 14,
|
||||
|
||||
// Used to report that the system browser for authenticating the user cannot
|
||||
// be open.
|
||||
CANT_OPEN_BROWSER_FOR_AUTH = 15,
|
||||
|
||||
// Used to report that the authorization code cannot be received.
|
||||
CANT_RECEIVE_AUTH_CODE = 16,
|
||||
|
||||
// Used to report that the account is blocked (e.g. CAA).
|
||||
ACCOUNT_BLOCKED = 17,
|
||||
|
||||
// Receiving the authorization code failed because it took longer than the
|
||||
// timeout.
|
||||
AUTH_CODE_TIMEOUT_EXCEEDED = 18,
|
||||
|
||||
// Used to report when user presses the cancel button during login process.
|
||||
USER_CANCELED = 19,
|
||||
};
|
||||
|
||||
} // namespace nearby
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_AUTH_STATUS_H_
|
||||
@@ -1,48 +0,0 @@
|
||||
// Copyright 2024 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_INTERNAL_PLATFORM_IMPLEMENTATION_SIGNIN_ATTEMPT_H_
|
||||
#define THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_SIGNIN_ATTEMPT_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "internal/platform/implementation/account_info.h"
|
||||
#include "internal/platform/implementation/auth_status.h"
|
||||
|
||||
namespace nearby {
|
||||
|
||||
class SigninAttempt {
|
||||
public:
|
||||
SigninAttempt() = default;
|
||||
virtual ~SigninAttempt() = default;
|
||||
|
||||
// Starts a new sign-in attempt.
|
||||
// `callback` is called with the status of the request, client_id,
|
||||
// client_secret, and account_info if the request is successful. Returns the
|
||||
// auth url if the request is successful.
|
||||
virtual std::string Start(
|
||||
absl::AnyInvocable<void(AuthStatus, absl::string_view, absl::string_view,
|
||||
const AccountInfo&)>
|
||||
callback) = 0;
|
||||
|
||||
// Tears down the machinery set up to request auth tokens, including the HTTP
|
||||
// server.
|
||||
virtual void Close() = 0;
|
||||
};
|
||||
|
||||
} // namespace nearby
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_SIGNIN_ATTEMPT_H_
|
||||
@@ -35,7 +35,6 @@
|
||||
#include "internal/account/account_manager_impl.h"
|
||||
#include "internal/platform/byte_array.h"
|
||||
#include "internal/platform/count_down_latch.h"
|
||||
#include "internal/platform/implementation/account_manager.h"
|
||||
#include "internal/platform/implementation/webrtc.h"
|
||||
#include "internal/platform/logging.h"
|
||||
#include "internal/proto/messaging.grpc.pb.h"
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "location/nearby/sharing/lib/account/account_manager.h"
|
||||
#include "absl/base/thread_annotations.h"
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
@@ -30,7 +31,6 @@
|
||||
#include "third_party/grpc/include/grpcpp/support/client_callback.h"
|
||||
#include "third_party/grpc/include/grpcpp/support/status.h"
|
||||
#include "internal/platform/byte_array.h"
|
||||
#include "internal/platform/implementation/account_manager.h"
|
||||
#include "internal/platform/implementation/webrtc.h"
|
||||
#include "internal/proto/messaging.grpc.pb.h"
|
||||
|
||||
@@ -94,7 +94,7 @@ class TachyonExpressSignalingMessenger : public api::WebRtcSignalingMessenger {
|
||||
std::unique_ptr<google::internal::communications::instantmessaging::v1::grpc::
|
||||
Messaging::StubInterface>
|
||||
messaging_stub_;
|
||||
AccountManager* const account_manager_;
|
||||
nearby::sharing::AccountManager* const account_manager_;
|
||||
std::shared_ptr<ReceiveMessagesReader> reader_ = nullptr;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user