Skip to content

WIP: Add sembast_web and load correct databaseFactoryWeb #394

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

Closed
wants to merge 1 commit into from
Closed

Conversation

nstrelow
Copy link
Contributor

@nstrelow nstrelow commented Jun 11, 2020

Work in progress: I would appreciate if this is used as a starting point to get sembast working on web.
Feel free to use these changes in your own PR to fix it 🚀

I added the necessary packages sembast_web and included the correct databaseFactory.

I have not really tested this, as we currently do not use Sembast.

Includes web fixes from #395.

sembast_web has certain limitations:

Codec are not supported. Web is not safe anyway. Encrypt fields as needed.

from core_store_sem_impl.dart:

final SembastCodec codec = getXXTeaSembastCodec(password: password);
final Database db = await factory.openDatabase(dbPath, codec: codec);

Fails with error:

Error: Expected a value of type 'Map<String, dynamic>', but got one of type 'String'
    at Object.throw_ [as throw] (http://localhost:53792/dart_sdk.js:4463:11)
    at Object.castError (http://localhost:53792/dart_sdk.js:4434:15)
    at Object.cast [as as] (http://localhost:53792/dart_sdk.js:4750:17)
    at dart.LegacyType.new.as (http://localhost:53792/dart_sdk.js:6274:60)
    at parse_server_sdk._XXTeaCodec.new.encode (http://localhost:53792/dart_sdk.js:43409:11)
    at jdb_factory_idb.JdbDatabaseIdb.new._txnAddEntries (http://localhost:53792/packages/sembast_web/src/jdb_factory_idb.dart.lib.js:355:49)
    at _txnAddEntries.next (<anonymous>)
    at http://localhost:53792/dart_sdk.js:37175:33
    at _RootZone.runUnary (http://localhost:53792/dart_sdk.js:37029:58)
    at _FutureListener.thenAwait.handleValue (http://localhost:53792/dart_sdk.js:32116:29)
    at handleValueCallback (http://localhost:53792/dart_sdk.js:32663:49)
    at Function._propagateToListeners (http://localhost:53792/dart_sdk.js:32701:17)
    at _Future.new.[_complete] (http://localhost:53792/dart_sdk.js:32535:25)
    at _SyncCompleter.new.complete (http://localhost:53792/dart_sdk.js:32043:31)
    at http://localhost:53792/dart_sdk.js:63461:17
    at Object._checkAndCall (http://localhost:53792/dart_sdk.js:4673:16)
    at Object.dcall (http://localhost:53792/dart_sdk.js:4678:17)
    at IDBRequest.<anonymous> (http://localhost:53792/dart_sdk.js:104624:21)Application finished.

@nstrelow
Copy link
Contributor Author

nstrelow commented Jun 12, 2020

We cannot use codec, which is needed for encryption. Would it still make sense to use sembast for it's other advantages?
Then we could simply remove the code/password/encryption part on web and add a disclaimer that sembast_web does not support it.

Or we encrypt/decrypt values before/after accessing sembast via a different encryption method.

@nstrelow
Copy link
Contributor Author

nstrelow commented Sep 4, 2020

Has been completed in #436

@nstrelow nstrelow closed this Sep 4, 2020
@nstrelow nstrelow deleted the sembast_web branch September 4, 2020 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant