diff --git a/README.md b/README.md index 2e45d7f2d..192250ba4 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,8 @@ await Parse().initialize( ``` If you want to use secure storage or use the Flutter web/desktop SDK, please change to the below instance of CoreStorage as it has no dependencies on Flutter. + +**The `CoreStoreSembastImp` does not encrypt the data!** (Web is not safe anyway. Encrypt fields manually as needed.) ```dart await Parse().initialize( diff --git a/lib/parse_server_sdk_dart.dart b/lib/parse_server_sdk_dart.dart index 1da9ae8ae..c5da87525 100644 --- a/lib/parse_server_sdk_dart.dart +++ b/lib/parse_server_sdk_dart.dart @@ -14,6 +14,7 @@ import 'package:parse_server_sdk/src/network/parse_websocket.dart' import 'package:path/path.dart' as path; import 'package:sembast/sembast.dart'; import 'package:sembast/sembast_io.dart'; +import 'package:sembast_web/sembast_web.dart'; import 'package:uuid/uuid.dart'; import 'package:web_socket_channel/web_socket_channel.dart'; import 'package:xxtea/xxtea.dart'; diff --git a/lib/src/storage/core_store_sem_impl.dart b/lib/src/storage/core_store_sem_impl.dart index bf60602bd..466fc24ec 100644 --- a/lib/src/storage/core_store_sem_impl.dart +++ b/lib/src/storage/core_store_sem_impl.dart @@ -9,9 +9,16 @@ class CoreStoreSembastImp implements CoreStore { static Future getInstance(String dbPath, {DatabaseFactory factory, String password = 'flutter_sdk'}) async { if (_instance == null) { - factory ??= databaseFactoryIo; - final SembastCodec codec = getXXTeaSembastCodec(password: password); - final Database db = await factory.openDatabase(dbPath, codec: codec); + factory ??= !parseIsWeb ? databaseFactoryIo : databaseFactoryWeb; + assert(() { + if (parseIsWeb) { + print( + 'Warning: CoreStoreSembastImp of the Parse_Server_SDK does not encrypt the database on WEB.'); + } + return true; + }()); + final Database db = await factory.openDatabase(dbPath, + codec: !parseIsWeb ? getXXTeaSembastCodec(password: password) : null); _instance = CoreStoreSembastImp._internal(db, StoreRef.main()); } diff --git a/pubspec.yaml b/pubspec.yaml index 50a5bfed7..415a1cee1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,6 +17,7 @@ dependencies: #Database sembast: ^2.4.7+6 + sembast_web: '>=1.0.0' xxtea: ^2.0.3 shared_preferences: ^0.5.10 # only used in the flutter part