-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
12 changed files
with
271 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// 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_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// 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, | ||
|
||
// The operation failed due to insufficient permissions. | ||
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, | ||
}; | ||
|
||
} // namespace nearby | ||
|
||
#endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_AUTH_STATUS_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// 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 "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 and the user_id if the | ||
// request is successful. | ||
// Returns the auth url if the request is successful. | ||
virtual std::string Start( | ||
absl::AnyInvocable<void(AuthStatus, 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_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.