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(web): upgrade to support v9.8.1 Firebase JS SDK #8235

Merged
merged 31 commits into from Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
29b1f61
feat(firebase_core): upgrade core web to v9 sdk
Ehesp Mar 8, 2022
9988b4c
fix database app usage
Ehesp Mar 8, 2022
faaba41
fix: fix tests
Ehesp Mar 8, 2022
19511a4
fix: formatting
Ehesp Mar 8, 2022
bc72147
Merge branch 'web-v9-sdk' into v9/core
russellwheatley May 16, 2022
53f0733
chore(core): update web firebase version
russellwheatley May 16, 2022
cf8b423
Merge branch 'v9/core' of github.com:FirebaseExtended/flutterfire int…
russellwheatley May 16, 2022
c81c509
Merge branch 'web-v9-sdk' into v9/core
russellwheatley May 23, 2022
35b27f7
feat(core, web): remove trigger after use
russellwheatley Jun 16, 2022
24a7ce1
chore(core, web): update API
russellwheatley Jun 16, 2022
40320cf
chore(core, web): update API
russellwheatley Jun 16, 2022
0cc3c6c
docs(core, web): update inline doc
russellwheatley Jun 16, 2022
6d8ee42
feat(core): add crossOrigin script
russellwheatley Jun 27, 2022
bbaaf16
fix analyzer
russellwheatley Jun 27, 2022
5933eab
fix(core, web): cannot build web apps without this update to database…
russellwheatley Jun 27, 2022
2a0f579
format
russellwheatley Jun 27, 2022
480d6b5
feat(firebase_firestore): upgrade to web v9 sdk (#8690)
russellwheatley Jun 27, 2022
60ea720
feat(functions, web): integrate web v9 SDK (#8922)
russellwheatley Jun 28, 2022
078092c
Merge branch 'web-v9-sdk' into v9/core
russellwheatley Jun 28, 2022
e0bff2f
feat(firebase_analytics): upgrade analytics web to v9 sdk (#8810)
russellwheatley Jun 28, 2022
471eb38
feat(firebase_remote_config): upgrade remote-config web to v9 sdk (#8…
russellwheatley Jun 29, 2022
9a4af59
feat(firebase_storage, web): upgrade storage web to v9 sdk (#8870)
russellwheatley Jun 29, 2022
b298b44
feat(firebase_performance): upgrade performance web to v9 sdk (#8868)
russellwheatley Jun 30, 2022
de987a7
feat(firebase_app_check): upgrade app_check web to v9 sdk. (#8816)
russellwheatley Jun 30, 2022
75d8ad3
refactor(firebase_database): upgrade database to integrate with modul…
russellwheatley Jun 30, 2022
f7bc21b
feat(app-installations): web v9 SDK implementation (#9007)
russellwheatley Jul 4, 2022
41b21ee
Update packages/cloud_firestore/cloud_firestore_platform_interface/li…
russellwheatley Jul 4, 2022
aee9725
Merge branch 'master' into v9/core
russellwheatley Jul 5, 2022
fd7f477
Update packages/cloud_firestore/cloud_firestore_platform_interface/li…
russellwheatley Jul 5, 2022
6e59f23
fix: import foundation
russellwheatley Jul 6, 2022
d3bccf8
fix: rm import
russellwheatley Jul 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -20,6 +20,7 @@ import 'timestamp_e2e.dart';
import 'transaction_e2e.dart';
import 'write_batch_e2e.dart';
import 'load_bundle_e2e.dart';
import 'second_app_e2e.dart';

bool kUseFirestoreEmulator = true;

Expand All @@ -45,6 +46,7 @@ void testsMain() {
runTransactionTests();
runWriteBatchTests();
runLoadBundleTests();
runSecondAppTests();
}

void main() => drive.main(testsMain);
@@ -0,0 +1,74 @@
// File generated by FlutterFire CLI.
// ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
import 'package:flutter/foundation.dart'
show defaultTargetPlatform, kIsWeb, TargetPlatform;

/// Default [FirebaseOptions] for use with your Firebase apps.
///
/// Example:
/// ```dart
/// import 'firebase_options_secondary.dart';
/// // ...
/// await Firebase.initializeApp(
/// options: DefaultFirebaseOptions.currentPlatform,
/// );
/// ```
class DefaultFirebaseOptions {
static FirebaseOptions get currentPlatform {
if (kIsWeb) {
return web;
}
switch (defaultTargetPlatform) {
case TargetPlatform.android:
return android;
case TargetPlatform.iOS:
return ios;
case TargetPlatform.macOS:
return macos;
default:
throw UnsupportedError(
'DefaultFirebaseOptions are not supported for this platform.',
);
}
}

static const FirebaseOptions web = FirebaseOptions(
apiKey: 'AIzaSyAFh7c37C6MyAVwRJylz7EwvzZSECqmcus',
appId: '1:866672724757:web:3a0fad9cba4848ea19f71c',
messagingSenderId: '866672724757',
projectId: 'flutterfire-e2e-tests-2',
authDomain: 'flutterfire-e2e-tests-2.firebaseapp.com',
storageBucket: 'flutterfire-e2e-tests-2.appspot.com',
);

static const FirebaseOptions android = FirebaseOptions(
apiKey: 'AIzaSyAMoRmAcD_NW0DVoO40ThJO1zDF2vDB7Rs',
appId: '1:866672724757:android:d069b410181b65cf19f71c',
messagingSenderId: '866672724757',
projectId: 'flutterfire-e2e-tests-2',
storageBucket: 'flutterfire-e2e-tests-2.appspot.com',
);

static const FirebaseOptions ios = FirebaseOptions(
apiKey: 'AIzaSyDfWh055gUcnS6_Gqd_Jjwy7boVm5_E8oI',
appId: '1:866672724757:ios:142139d84dda4ed419f71c',
messagingSenderId: '866672724757',
projectId: 'flutterfire-e2e-tests-2',
storageBucket: 'flutterfire-e2e-tests-2.appspot.com',
iosClientId:
'866672724757-rncbdu3qrn0j423e1tfk2jg7jdvrhd8i.apps.googleusercontent.com',
iosBundleId: 'io.flutter.plugins.firebase.firestoreExample',
);

static const FirebaseOptions macos = FirebaseOptions(
apiKey: 'AIzaSyDfWh055gUcnS6_Gqd_Jjwy7boVm5_E8oI',
appId: '1:866672724757:ios:3e35357fc677cc5719f71c',
messagingSenderId: '866672724757',
projectId: 'flutterfire-e2e-tests-2',
storageBucket: 'flutterfire-e2e-tests-2.appspot.com',
iosClientId:
'866672724757-fup6o8riklmmc7mbo3b1jolbeadbb84m.apps.googleusercontent.com',
iosBundleId: 'io.flutter.plugins.firebase.firestore.example',
);
}
@@ -0,0 +1,49 @@
// Copyright 2020, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter_test/flutter_test.dart';

import 'firebase_options_secondary.dart';

void runSecondAppTests() {
group('$FirebaseFirestore', () {
late FirebaseFirestore firestore;
late FirebaseFirestore secondFirestoreProject;

setUpAll(() async {
firestore = FirebaseFirestore.instance;
FirebaseApp secondApp = await Firebase.initializeApp(
name: 'secondApp',
options: DefaultFirebaseOptions.currentPlatform,
);
secondFirestoreProject = FirebaseFirestore.instanceFor(
app: secondApp,
);
});

group('Secondary app Firestore instance', () {
test(
'Second Firestore instance should fail due to firestore.rules forbidding data writes',
() async {
// successful write on default app instance
await firestore
.collection('flutter-tests/banned/doc')
.add({'foo': 'bar'});

// permission denied on second app with Firebase that denies database writes
await expectLater(
secondFirestoreProject
.collection('flutter-tests/banned/doc')
.add({'foo': 'bar'}),
throwsA(
isA<FirebaseException>()
.having((e) => e.code, 'code', 'permission-denied'),
),
);
});
});
});
}
Expand Up @@ -3,7 +3,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';

/// Specifies custom configurations for your Cloud Firestore instance.
///
Expand All @@ -16,6 +16,7 @@ class Settings {
this.host,
this.sslEnabled,
this.cacheSizeBytes,
this.ignoreUndefinedProperties = false,
});

/// Constant used to indicate the LRU garbage collection should be disabled.
Expand Down Expand Up @@ -44,13 +45,21 @@ class Settings {
/// and can be set to [Settings.CACHE_SIZE_UNLIMITED] to disable garbage collection.
final int? cacheSizeBytes;

/// Whether to skip nested properties that are set to undefined during object serialization.
russellwheatley marked this conversation as resolved.
Show resolved Hide resolved
///
/// If set to true, these properties are skipped and not written to Firestore. If set to false
/// or omitted, the SDK throws an exception when it encounters properties of type undefined.
/// Web only.
final bool ignoreUndefinedProperties;

/// Returns the settings as a [Map]
Map<String, dynamic> get asMap {
return {
'persistenceEnabled': persistenceEnabled,
'host': host,
'sslEnabled': sslEnabled,
'cacheSizeBytes': cacheSizeBytes
'cacheSizeBytes': cacheSizeBytes,
if (kIsWeb) 'ignoreUndefinedProperties': ignoreUndefinedProperties,
};
}

Expand All @@ -59,12 +68,15 @@ class Settings {
String? host,
bool? sslEnabled,
int? cacheSizeBytes,
bool? ignoreUndefinedProperties,
}) =>
Settings(
persistenceEnabled: persistenceEnabled ?? this.persistenceEnabled,
host: host ?? this.host,
sslEnabled: sslEnabled ?? this.sslEnabled,
cacheSizeBytes: cacheSizeBytes ?? this.cacheSizeBytes,
ignoreUndefinedProperties:
ignoreUndefinedProperties ?? this.ignoreUndefinedProperties,
);

@override
Expand All @@ -74,7 +86,8 @@ class Settings {
other.persistenceEnabled == persistenceEnabled &&
other.host == host &&
other.sslEnabled == sslEnabled &&
other.cacheSizeBytes == cacheSizeBytes;
other.cacheSizeBytes == cacheSizeBytes &&
other.ignoreUndefinedProperties == ignoreUndefinedProperties;

@override
int get hashCode => Object.hash(
Expand All @@ -83,6 +96,7 @@ class Settings {
host,
sslEnabled,
cacheSizeBytes,
ignoreUndefinedProperties,
);

@override
Expand Down
Expand Up @@ -29,10 +29,12 @@ class FirebaseFirestoreWeb extends FirebaseFirestorePlatform {
/// instance of Analytics from the web plugin
firestore_interop.Firestore? _webFirestore;

firestore_interop.Settings? _settings;

/// Lazily initialize [_webFirestore] on first method call
firestore_interop.Firestore get _delegate {
return _webFirestore ??=
firestore_interop.getFirestoreInstance(core_interop.app(app.name));
return _webFirestore ??= firestore_interop.getFirestoreInstance(
core_interop.app(app.name), _settings);
}

/// Called by PluginRegistry to register this plugin for Flutter Web
Expand Down Expand Up @@ -120,7 +122,6 @@ class FirebaseFirestoreWeb extends FirebaseFirestorePlatform {
@override
set settings(Settings settings) {
int? cacheSizeBytes;

if (settings.cacheSizeBytes == null) {
cacheSizeBytes = 40000000;
} else if (settings.cacheSizeBytes == Settings.CACHE_SIZE_UNLIMITED) {
Expand All @@ -131,13 +132,17 @@ class FirebaseFirestoreWeb extends FirebaseFirestorePlatform {
}

if (settings.host != null && settings.sslEnabled != null) {
_delegate.settings(firestore_interop.Settings(
cacheSizeBytes: cacheSizeBytes,
host: settings.host,
ssl: settings.sslEnabled));
_settings = firestore_interop.Settings(
cacheSizeBytes: cacheSizeBytes,
host: settings.host,
ssl: settings.sslEnabled,
ignoreUndefinedProperties: settings.ignoreUndefinedProperties,
);
} else {
_delegate
.settings(firestore_interop.Settings(cacheSizeBytes: cacheSizeBytes));
_settings = firestore_interop.Settings(
cacheSizeBytes: cacheSizeBytes,
ignoreUndefinedProperties: settings.ignoreUndefinedProperties,
);
}
}

Expand Down

This file was deleted.