From 8fead5c2dd0bccad14be81b97779fefe91a614a9 Mon Sep 17 00:00:00 2001 From: Suet-Fei Li Date: Mon, 9 Dec 2024 14:57:54 -0800 Subject: [PATCH] move identity protos. PiperOrigin-RevId: 704428031 --- .github/workflows/validate.yaml | 2 +- proto/identity/BUILD | 44 +++++++ proto/identity/resources.proto | 110 ++++++++++++++++++ proto/identity/rpcs.proto | 72 ++++++++++++ sharing/certificates/BUILD | 8 +- .../nearby_share_certificate_manager_impl.cc | 4 +- ...rby_share_certificate_manager_impl_test.cc | 4 +- sharing/internal/api/BUILD | 2 +- sharing/internal/api/sharing_rpc_client.h | 2 +- sharing/local_device_data/BUILD | 8 +- ...by_share_local_device_data_manager_impl.cc | 4 +- ...are_local_device_data_manager_impl_test.cc | 4 +- 12 files changed, 245 insertions(+), 19 deletions(-) create mode 100644 proto/identity/BUILD create mode 100644 proto/identity/resources.proto create mode 100644 proto/identity/rpcs.proto diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index 60285ac5a8..b5c643b477 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -50,7 +50,7 @@ jobs: - name: Build Presence run: CC=clang-15 CXX=clang-15++ bazel build --copt='-DGITHUB_BUILD' //presence - name: Build Sharing - run: CC=clang-15 CXX=clang-15++ bazel build --verbose_failures --copt='-DGITHUB_BUILD' //sharing/proto/... //sharing/analytics + run: CC=clang-15 CXX=clang-15++ bazel build --verbose_failures --copt='-DGITHUB_BUILD' //sharing:nearby_sharing_service //sharing/certificates //sharing/contacts //sharing/local_device_data //sharing/proto/... //sharing/internal/public:nearby_context //sharing/common:all //sharing/scheduling //sharing/fast_initiation:nearby_fast_initiation //sharing/analytics build-rust-linux: name: Build Rust on Linux diff --git a/proto/identity/BUILD b/proto/identity/BUILD new file mode 100644 index 0000000000..be07f4e951 --- /dev/null +++ b/proto/identity/BUILD @@ -0,0 +1,44 @@ +# Copyright 2020 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. + +load("@com_google_protobuf//bazel:cc_proto_library.bzl", "cc_proto_library") +load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library") + +package(default_visibility = ["//visibility:public"]) + +proto_library( + name = "resources_proto", + srcs = ["resources.proto"], + deps = [ + "//sharing/proto:share_proto", + ], +) + +cc_proto_library( + name = "resources_cc_proto", + deps = [":resources_proto"], +) + +proto_library( + name = "rpcs_proto", + srcs = ["rpcs.proto"], + deps = [ + ":resources_proto", + ], +) + +cc_proto_library( + name = "rpcs_cc_proto", + deps = [":rpcs_proto"], +) diff --git a/proto/identity/resources.proto b/proto/identity/resources.proto new file mode 100644 index 0000000000..8c283f5695 --- /dev/null +++ b/proto/identity/resources.proto @@ -0,0 +1,110 @@ +// Copyright 2021 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. + +// DO NOT EDIT DIRECTLY. +// This file is a third_party mirror of +// google/nearby/identity/v1/resources.proto. + +syntax = "proto3"; + +package google.nearby.identity.v1; + +import "sharing/proto/timestamp.proto"; + +option java_package = "com.google.nearby.identity.v1"; +option java_outer_classname = "ResourcesProto"; +option java_multiple_files = true; +option optimize_for = LITE_RUNTIME; + +// This message represents an SharedCredential generated by Google Nearby client +// for a device participating in the Nearby Ecosystem. The "data" field in this +// proto is transparent to the Nearby SDK clients as well as the Nearby backend +// service. +message SharedCredential { + // Data type of the "data" field. + enum DataType { + // Undefined or unset. + DATA_TYPE_UNSPECIFIED = 0; + // For Nearby Share. + DATA_TYPE_PUBLIC_CERTIFICATE = 1; + // For Nearby Presence. + DATA_TYPE_SHARED_CREDENTIAL = 2; + } + + // The unique identifier for the SharedCredential. + int64 id = 1; + + // Set it to DATE_TYPE_NEARBY_PUBLIC_CERTIFICATE for Nearby Share and + // DATA_TYPE_NEARBY_SHARED_CREDENTIAL for Nearby Presence. + DataType data_type = 2; + + // Serialized proto based on data_type that indicates the proto type, e.g. + // DATA_TYPE_PUBLIC_CERTIFICATE for proto message PublicCertificate. The + // server will store and distribute them to contacts and requesters, but it + // doesn't interprete the data itself. + bytes data = 3; + + // The expiration timestamp. The SharedCredential is excluded from the + // QuerySharedCredentials RPC response if it is expired. + .nearby.sharing.proto.Timestamp expiration_time = 5; +} + +// The SharedCredentials for a specific visibility. +message PerVisibilitySharedCredentials { + // The visility of the SharedCredential. + enum Visibility { + // Undefined or unset. + VISIBILITY_UNSPECIFIED = 0; + // Visible to requester's devices only + VISIBILITY_SELF = 1; + // Visible to requester's contacts. This also implies VISIBILITY_SELF. + VISIBILITY_CONTACTS = 2; + } + // The visibility of the SharedCredentials. + Visibility visibility = 1; + // All the SharedCredentials for the visibility. + repeated SharedCredential shared_credentials = 2; +} + +// Device represents the device meta information and its SharedCredentials +// for discovery. +message Device { + // The device id, unique per gaia user. + string name = 1; + // The display_name. + string display_name = 2; + + // What contact and how they should be used in distribute the + // SharedCredentials. + enum Contact { + // Unknown or unset. It will be treated as an error. + CONTACT_UNSPECIFIED = 0; + // For the requester only. + CONTACT_SELF = 1; + // The Google contact, the best effort for the freshness. + CONTACT_GOOGLE_CONTACT = 2; + // The latest Google contacts in the Google backend. + CONTACT_GOOGLE_CONTACT_LATEST = 3; + } + // For CONTACT_GOOGLE_CONTACT/CONTACT_GOOGLE_CONTACT_LATEST, the service will + // allow requester's Google contacts to download (Query) SharedCredentials + // from the Nearby service. + Contact contact = 3; + + // All the SharedCredentials including VISIBILITY_SELF and VISIBILITY_CONTACT. + // When per_visibility_shared_credentials for VISIBILITY_CONTACT and the + // contact is not CONTACT_SELF, the server will make those to be accessible to + // (downloaded by) the requester's contacts. + repeated PerVisibilitySharedCredentials per_visibility_shared_credentials = 4; +} diff --git a/proto/identity/rpcs.proto b/proto/identity/rpcs.proto new file mode 100644 index 0000000000..3a53576da1 --- /dev/null +++ b/proto/identity/rpcs.proto @@ -0,0 +1,72 @@ +// Copyright 2021 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. + +// DO NOT EDIT DIRECTLY. +// This file is a third_party mirror of +// google/nearby/identity/v1/rpcs.proto. + +syntax = "proto3"; + +package google.nearby.identity.v1; + +import "proto/identity/resources.proto"; + +option java_package = "com.google.nearby.identity.v1"; +option java_outer_classname = "RpcsProto"; +option java_multiple_files = true; +option optimize_for = LITE_RUNTIME; + +// Publish the Device's SharedCredentials, its meta-info and contacts info +// that the backend uses to distribute the SharedCredentials. +message PublishDeviceRequest { + // The Device with both metadata and SharedCredentials. + Device device = 1; +} +// The response message for PublishDevic RPC. +message PublishDeviceResponse { + // The enum used to indicate the contact update result. + enum ContactUpdate { + // The contact is not updated. + CONTACT_UPDATE_UNSPECIFIED = 0; + // The contact is updated. + CONTACT_UPDATE_ADDED = 1; + // The contact is removed. + CONTACT_UPDATE_REMOVED = 2; + } + // The contact update result. + repeated ContactUpdate contact_updates = 1; +} + +// Query all the SharedCredentials. +message QuerySharedCredentialsRequest { + // The Device to query with format: devices/{device}. The device is the + // requester's current device-id. The device-id is used to filter out the + // SharedCredentials from the current device as the device has all of them. + string name = 1; + // the page size for the streaming request. + int32 page_size = 2; + // the continue token. + string page_token = 3; +} + +// The message containing all the SharedCredentials the requester can access, +// i.e. those devices using the SharedCredentials in advertising are visible to +// the requester. +message QuerySharedCredentialsResponse { + // All the unexpired SharedCredentials that other devices has shared with the + // requester + repeated SharedCredential shared_credentials = 1; + // next page token. + string next_page_token = 2; +} diff --git a/sharing/certificates/BUILD b/sharing/certificates/BUILD index 334431086d..89ef66cde5 100644 --- a/sharing/certificates/BUILD +++ b/sharing/certificates/BUILD @@ -44,8 +44,8 @@ cc_library( "//internal/flags:nearby_flags", "//internal/platform:types", "//internal/platform/implementation:account_manager", - "//proto/identity/v1:resources_cc_proto", - "//proto/identity/v1:rpcs_cc_proto", + "//proto/identity:resources_cc_proto", + "//proto/identity:rpcs_cc_proto", "//sharing/common", "//sharing/common:enum", "//sharing/contacts", @@ -122,8 +122,8 @@ cc_test( "//internal/platform/implementation:account_manager", "//internal/platform/implementation/g3", # fixdeps: keep "//internal/test", - "//proto/identity/v1:resources_cc_proto", - "//proto/identity/v1:rpcs_cc_proto", + "//proto/identity:resources_cc_proto", + "//proto/identity:rpcs_cc_proto", "//sharing/common", "//sharing/common:enum", "//sharing/contacts:test_support", diff --git a/sharing/certificates/nearby_share_certificate_manager_impl.cc b/sharing/certificates/nearby_share_certificate_manager_impl.cc index a7b9ccde37..02baa07586 100644 --- a/sharing/certificates/nearby_share_certificate_manager_impl.cc +++ b/sharing/certificates/nearby_share_certificate_manager_impl.cc @@ -41,8 +41,8 @@ #include "absl/types/span.h" #include "internal/flags/nearby_flags.h" #include "internal/platform/implementation/account_manager.h" -#include "proto/identity/v1/resources.pb.h" -#include "proto/identity/v1/rpcs.pb.h" +#include "proto/identity/resources.pb.h" +#include "proto/identity/rpcs.pb.h" #include "sharing/certificates/common.h" #include "sharing/certificates/constants.h" #include "sharing/certificates/nearby_share_certificate_manager.h" diff --git a/sharing/certificates/nearby_share_certificate_manager_impl_test.cc b/sharing/certificates/nearby_share_certificate_manager_impl_test.cc index 326fb20092..ae80d78bad 100644 --- a/sharing/certificates/nearby_share_certificate_manager_impl_test.cc +++ b/sharing/certificates/nearby_share_certificate_manager_impl_test.cc @@ -38,8 +38,8 @@ #include "internal/flags/nearby_flags.h" #include "internal/platform/implementation/account_manager.h" #include "internal/test/fake_account_manager.h" -#include "proto/identity/v1/resources.pb.h" -#include "proto/identity/v1/rpcs.pb.h" +#include "proto/identity/resources.pb.h" +#include "proto/identity/rpcs.pb.h" #include "sharing/certificates/constants.h" #include "sharing/certificates/fake_nearby_share_certificate_storage.h" #include "sharing/certificates/nearby_share_certificate_manager.h" diff --git a/sharing/internal/api/BUILD b/sharing/internal/api/BUILD index 9c79d487d4..78313a9e83 100644 --- a/sharing/internal/api/BUILD +++ b/sharing/internal/api/BUILD @@ -40,7 +40,7 @@ cc_library( deps = [ "//internal/platform:types", "//internal/platform/implementation:account_manager", - "//proto/identity/v1:rpcs_cc_proto", + "//proto/identity:rpcs_cc_proto", "//sharing/analytics", "//sharing/proto:share_cc_proto", "@com_google_absl//absl/functional:any_invocable", diff --git a/sharing/internal/api/sharing_rpc_client.h b/sharing/internal/api/sharing_rpc_client.h index 026f301c1d..dad2a44e9a 100644 --- a/sharing/internal/api/sharing_rpc_client.h +++ b/sharing/internal/api/sharing_rpc_client.h @@ -19,7 +19,7 @@ #include "absl/functional/any_invocable.h" #include "absl/status/statusor.h" -#include "proto/identity/v1/rpcs.pb.h" +#include "proto/identity/rpcs.pb.h" #include "sharing/internal/api/sharing_rpc_notifier.h" #include "sharing/proto/certificate_rpc.pb.h" #include "sharing/proto/contact_rpc.pb.h" diff --git a/sharing/local_device_data/BUILD b/sharing/local_device_data/BUILD index c599a20333..6f1f6ecb21 100644 --- a/sharing/local_device_data/BUILD +++ b/sharing/local_device_data/BUILD @@ -30,8 +30,8 @@ cc_library( "//internal/platform:types", "//internal/platform/implementation:account_manager", "//internal/platform/implementation:types", - "//proto/identity/v1:resources_cc_proto", - "//proto/identity/v1:rpcs_cc_proto", + "//proto/identity:resources_cc_proto", + "//proto/identity:rpcs_cc_proto", "//sharing/common", "//sharing/common:enum", "//sharing/internal/api:platform", @@ -80,8 +80,8 @@ cc_test( "//internal/platform/implementation:account_manager", "//internal/platform/implementation/g3", # fixdeps: keep "//internal/test", - "//proto/identity/v1:resources_cc_proto", - "//proto/identity/v1:rpcs_cc_proto", + "//proto/identity:resources_cc_proto", + "//proto/identity:rpcs_cc_proto", "//sharing/common", "//sharing/common:enum", "//sharing/internal/api:mock_sharing_platform", diff --git a/sharing/local_device_data/nearby_share_local_device_data_manager_impl.cc b/sharing/local_device_data/nearby_share_local_device_data_manager_impl.cc index 894a75a5b1..25c1f4fde1 100644 --- a/sharing/local_device_data/nearby_share_local_device_data_manager_impl.cc +++ b/sharing/local_device_data/nearby_share_local_device_data_manager_impl.cc @@ -35,8 +35,8 @@ #include "internal/platform/device_info.h" #include "internal/platform/implementation/account_manager.h" #include "internal/platform/implementation/device_info.h" -#include "proto/identity/v1/resources.pb.h" -#include "proto/identity/v1/rpcs.pb.h" +#include "proto/identity/resources.pb.h" +#include "proto/identity/rpcs.pb.h" #include "sharing/common/nearby_share_enums.h" #include "sharing/common/nearby_share_prefs.h" #include "sharing/internal/api/preference_manager.h" diff --git a/sharing/local_device_data/nearby_share_local_device_data_manager_impl_test.cc b/sharing/local_device_data/nearby_share_local_device_data_manager_impl_test.cc index c20d1b1659..d84fb7fbd7 100644 --- a/sharing/local_device_data/nearby_share_local_device_data_manager_impl_test.cc +++ b/sharing/local_device_data/nearby_share_local_device_data_manager_impl_test.cc @@ -34,8 +34,8 @@ #include "internal/test/fake_account_manager.h" #include "internal/test/fake_device_info.h" #include "internal/test/fake_task_runner.h" -#include "proto/identity/v1/resources.pb.h" -#include "proto/identity/v1/rpcs.pb.h" +#include "proto/identity/resources.pb.h" +#include "proto/identity/rpcs.pb.h" #include "sharing/common/nearby_share_enums.h" #include "sharing/common/nearby_share_prefs.h" #include "sharing/internal/api/fake_nearby_share_client.h"