Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(fdc): Add GMP header #13358

Merged
merged 75 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
84d7598
First pass at dataconnect
maneesht May 23, 2024
a960d33
Got mutations to work
maneesht May 28, 2024
257c90c
Finished WIP
maneesht Jun 25, 2024
2b0c7ab
Used generated SDK
maneesht Jul 11, 2024
b5c3611
Merge branch 'master' into mtewani/fdc
maneesht Jul 11, 2024
8e8e737
Removed unrelated chagnes
maneesht Jul 11, 2024
806989b
Cleanup
maneesht Jul 11, 2024
8978090
Updated deps
maneesht Jul 11, 2024
fa7829e
Addressed comments
maneesht Jul 16, 2024
d7bb86c
Removed prints
maneesht Jul 16, 2024
8983df1
Removed unnecessary protos
maneesht Jul 23, 2024
1297684
Removed user class
maneesht Jul 23, 2024
2774a0d
Removed unnecessary class
maneesht Jul 23, 2024
3058024
Removed unnecessary deps
maneesht Jul 29, 2024
f5b35ea
Added back config files
maneesht Jul 29, 2024
8df3922
Fixed formatting
maneesht Jul 29, 2024
c7868f6
added index.html
maneesht Jul 29, 2024
9149814
Added license files
maneesht Jul 29, 2024
34d53aa
Fixed formatting
maneesht Jul 29, 2024
8bc79ad
Fixed linting issues
maneesht Jul 30, 2024
fb97874
Fixed formatting
maneesht Jul 30, 2024
7b421c9
Added protobuf as dependency
maneesht Jul 30, 2024
37ab782
Added license
maneesht Jul 31, 2024
d5521e8
Ignored example dir for secret checking
maneesht Jul 31, 2024
bb54564
Added changelog and readme
maneesht Jul 31, 2024
16855c8
Updated package version
maneesht Jul 31, 2024
bf9f8b9
Implemented app check
maneesht Aug 7, 2024
6a643f1
Removed key
maneesht Aug 7, 2024
723b069
Revert "Removed key"
maneesht Aug 7, 2024
6a69cab
Removed key again
maneesht Aug 7, 2024
afe32c2
Added error catching implementation (#13163)
maneesht Aug 7, 2024
fde352f
feat(dataconnect): Added error handling (#13175)
maneesht Aug 12, 2024
6d756f4
Miscellaneous cleanup
maneesht Aug 12, 2024
2e3d56e
Removed macros experiment
maneesht Aug 12, 2024
b053313
Removed .then statements
maneesht Aug 12, 2024
ec3a45d
Removed debug prints
maneesht Aug 12, 2024
2fec20e
Addressed first pass of comments
maneesht Aug 13, 2024
e3d19f0
Added movie_insert gql file
maneesht Aug 13, 2024
d5dc189
Added comments
maneesht Aug 13, 2024
b33ab6c
Renamed package
maneesht Aug 13, 2024
b0ceb73
Another package rename
maneesht Aug 13, 2024
422bd80
Removed common package
maneesht Aug 14, 2024
7d0826a
Added missing files
maneesht Aug 14, 2024
466fa23
Updated readme
maneesht Aug 14, 2024
359088a
Revert "Removed common package"
maneesht Aug 14, 2024
281c399
Various improvements
maneesht Aug 22, 2024
05ab14e
Merge branch 'mtewani/implement-app-check' into mtewani/fdc
maneesht Aug 22, 2024
31694c0
Made changes per api proposal
maneesht Aug 23, 2024
61562f3
Fixed initialization issues with generated SDK
maneesht Aug 23, 2024
945a9cf
Made changes according to api council review
maneesht Aug 28, 2024
6847801
Addressed Comments.
maneesht Sep 3, 2024
d7e933f
Merge remote-tracking branch 'origin/main' into mtewani/fdc
maneesht Sep 3, 2024
a6a5585
Added missing license header to files
maneesht Sep 3, 2024
f9ac9a4
/s/query/operation
maneesht Sep 3, 2024
46b7f73
API Council Changes
maneesht Sep 3, 2024
47f98bc
Included list movies changes
maneesht Sep 3, 2024
b3817a9
API council updates
maneesht Sep 5, 2024
bdd9535
Addressed comments
maneesht Sep 5, 2024
636f740
Removed print
maneesht Sep 5, 2024
89232c6
Added license header
maneesht Sep 5, 2024
74e40a9
Removed files that should be gitignored
maneesht Sep 5, 2024
abb4354
Removed requirement on firebase_options
maneesht Sep 6, 2024
d22ea34
Added missing line
maneesht Sep 6, 2024
6dde572
Removed windows and linux folders, updated changelog and gitignore
maneesht Sep 6, 2024
ce3caeb
Updated version of firebase_data_connect
maneesht Sep 7, 2024
800ee6a
Implemented gmpid
maneesht Sep 18, 2024
2614210
Merge remote-tracking branch 'origin/main' into mtewani/implement-gmpid
maneesht Sep 18, 2024
bca91b2
Made changes
maneesht Sep 18, 2024
a0de73d
Made more changes
maneesht Sep 18, 2024
51a7327
Replaced null with emptySerializer
maneesht Sep 18, 2024
0ec73f4
Trigger Build
maneesht Sep 18, 2024
34eb062
Fixed errors
maneesht Sep 18, 2024
bc1d6ff
Merge branch 'main' into mtewani/implement-gmpid
maneesht Sep 24, 2024
d68ecd7
Addressed comment
maneesht Sep 24, 2024
37bf50a
Addressed jsonEncode comment
maneesht Sep 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@
<data android:mimeType="text/plain" />
</intent>
</queries>
</manifest>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
"port": 9099
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class TransportOptions {
/// Interface for transports connecting to the DataConnect backend.
abstract class DataConnectTransport {
/// Constructor.
DataConnectTransport(this.transportOptions, this.options);
DataConnectTransport(this.transportOptions, this.options, this.appId);

/// Transport options.
TransportOptions transportOptions;
Expand All @@ -44,17 +44,20 @@ abstract class DataConnectTransport {
/// FirebaseAppCheck to use to get app check token.
FirebaseAppCheck? appCheck;

/// Application ID
String appId;

/// Invokes corresponding query endpoint.
Future<Data> invokeQuery<Data, Variables>(
String queryName,
Deserializer<Data> deserializer,
Serializer<Variables>? serializer,
Serializer<Variables> serializer,
Variables? vars);

/// Invokes corresponding mutation endpoint.
Future<Data> invokeMutation<Data, Variables>(
String queryName,
Deserializer<Data> deserializer,
Serializer<Variables>? serializer,
Serializer<Variables> serializer,
Variables? vars);
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class FirebaseDataConnect extends FirebasePluginPlatform {
void checkTransport() {
transportOptions ??=
TransportOptions('firebasedataconnect.googleapis.com', null, true);
transport = getTransport(transportOptions!, options, auth, appCheck);
transport = getTransport(
transportOptions!, options, app.options.appId, auth, appCheck);
}

/// Returns a [QueryRef] object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ part of firebase_data_connect_grpc;
/// Transport used for Android/iOS. Uses a GRPC transport instead of REST.
class GRPCTransport implements DataConnectTransport {
/// GRPCTransport creates a new channel
GRPCTransport(this.transportOptions, this.options, this.auth, this.appCheck) {
GRPCTransport(
this.transportOptions,
this.options,
this.appId,
this.auth,
this.appCheck,
) {
bool isSecure =
transportOptions.isSecure == null || transportOptions.isSecure == true;
channel = ClientChannel(transportOptions.host,
Expand Down Expand Up @@ -46,6 +52,10 @@ class GRPCTransport implements DataConnectTransport {
@override
DataConnectOptions options;

/// Application ID
@override
String appId;

Future<Map<String, String>> getMetadata() async {
String? authToken;
try {
Expand All @@ -70,6 +80,7 @@ class GRPCTransport implements DataConnectTransport {
if (appCheckToken != null) {
metadata['X-Firebase-AppCheck'] = appCheckToken;
}
metadata['x-firebase-gmpid'] = appId;
return metadata;
}

Expand Down Expand Up @@ -134,6 +145,7 @@ class GRPCTransport implements DataConnectTransport {
DataConnectTransport getTransport(
TransportOptions transportOptions,
DataConnectOptions options,
String appId,
FirebaseAuth? auth,
FirebaseAppCheck? appCheck) =>
GRPCTransport(transportOptions, options, auth, appCheck);
GRPCTransport(transportOptions, options, appId, auth, appCheck);
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ part of firebase_data_connect_rest;
/// RestTransport makes requests out to the REST endpoints of the configured backend.
class RestTransport implements DataConnectTransport {
/// Initializes necessary protocol and port.
RestTransport(this.transportOptions, this.options, this.auth, this.appCheck) {
RestTransport(this.transportOptions, this.options, this.appId, this.auth,
this.appCheck) {
String protocol = 'http';
if (transportOptions.isSecure == null ||
transportOptions.isSecure == true) {
Expand Down Expand Up @@ -48,6 +49,10 @@ class RestTransport implements DataConnectTransport {
@override
DataConnectOptions options;

/// Firebase application ID.
@override
String appId;

/// Invokes the current operation, whether its a query or mutation.
Future<Data> invokeOperation<Data, Variables>(
String queryName,
Expand Down Expand Up @@ -82,6 +87,7 @@ class RestTransport implements DataConnectTransport {
if (appCheckToken != null) {
headers['X-Firebase-AppCheck'] = appCheckToken;
}
headers['x-firebase-gmpid'] = appId;

Map<String, dynamic> body = {
'name':
Expand Down Expand Up @@ -148,6 +154,7 @@ class RestTransport implements DataConnectTransport {
DataConnectTransport getTransport(
TransportOptions transportOptions,
DataConnectOptions options,
String appId,
FirebaseAuth? auth,
FirebaseAppCheck? appCheck) =>
RestTransport(transportOptions, options, auth, appCheck);
RestTransport(transportOptions, options, appId, auth, appCheck);
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ part of firebase_data_connect_transport;
/// Default TransportStub to satisfy compilation of the library.
class TransportStub implements DataConnectTransport {
/// Constructor.
TransportStub(this.transportOptions, this.options, this.auth, this.appCheck);
TransportStub(
this.transportOptions,
this.options,
this.appId,
this.auth,
this.appCheck,
);

/// FirebaseAuth
@override
Expand All @@ -25,6 +31,9 @@ class TransportStub implements DataConnectTransport {
@override
TransportOptions transportOptions;

@override
String appId;

/// Stub for invoking a mutation.
@override
Future<Data> invokeMutation<Data, Variables>(
Expand All @@ -49,8 +58,10 @@ class TransportStub implements DataConnectTransport {
}

DataConnectTransport getTransport(
TransportOptions transportOptions,
DataConnectOptions options,
FirebaseAuth? auth,
FirebaseAppCheck? appCheck) =>
TransportStub(transportOptions, options, auth, appCheck);
TransportOptions transportOptions,
DataConnectOptions options,
String appId,
FirebaseAuth? auth,
FirebaseAppCheck? appCheck,
) =>
TransportStub(transportOptions, options, appId, auth, appCheck);
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ void main() {
transport = TestDataConnectTransport(
transportOptions,
dataConnectOptions,
'testAppId',
auth: mockFirebaseAuth,
appCheck: mockFirebaseAppCheck,
);
Expand All @@ -79,17 +80,17 @@ void main() {
test('should handle invokeQuery with proper deserializer', () async {
final queryName = 'testQuery';
final deserializer = (json) => json;
final result =
await transport.invokeQuery(queryName, deserializer, null, null);
final result = await transport.invokeQuery(
queryName, deserializer, emptySerializer, null);

expect(result, isNotNull);
});

test('should handle invokeMutation with proper deserializer', () async {
final queryName = 'testMutation';
final deserializer = (json) => json;
final result =
await transport.invokeMutation(queryName, deserializer, null, null);
final result = await transport.invokeMutation(
queryName, deserializer, emptySerializer, null);

expect(result, isNotNull);
});
Expand All @@ -98,10 +99,10 @@ void main() {

// Test class extending DataConnectTransport for testing purposes
class TestDataConnectTransport extends DataConnectTransport {
TestDataConnectTransport(
TransportOptions transportOptions, DataConnectOptions options,
TestDataConnectTransport(TransportOptions transportOptions,
DataConnectOptions options, String appId,
{FirebaseAuth? auth, FirebaseAppCheck? appCheck})
: super(transportOptions, options) {
: super(transportOptions, options, appId) {
this.auth = auth;
this.appCheck = appCheck;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ void main() {
'testConnector',
'testService',
),
'testAppId',
mockAuth,
mockAppCheck,
);
Expand All @@ -64,6 +65,7 @@ void main() {
'testConnector',
'testService',
),
'testAppId',
mockAuth,
mockAppCheck,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void main() {
final transportStub = TransportStub(
mockTransportOptions,
mockDataConnectOptions,
'mockAppId',
mockAuth,
mockAppCheck,
);
Expand All @@ -50,6 +51,7 @@ void main() {
final transportStub = TransportStub(
mockTransportOptions,
mockDataConnectOptions,
'mockAppId',
mockAuth,
mockAppCheck,
);
Expand All @@ -69,6 +71,7 @@ void main() {
final transportStub = TransportStub(
mockTransportOptions,
mockDataConnectOptions,
'mockAppId',
mockAuth,
mockAppCheck,
);
Expand Down
Loading