diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fda11bf..c5245b9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,38 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## 2025-03-11 + +### Changes + +--- + +Packages with breaking changes: + + - There are no breaking changes in this release. + +Packages with other changes: + + - [`powersync_core` - `v1.2.2`](#powersync_core---v122) + - [`powersync_attachments_helper` - `v0.6.18+4`](#powersync_attachments_helper---v06184) + - [`powersync_sqlcipher` - `v0.1.5+2`](#powersync_sqlcipher---v0152) + - [`powersync` - `v1.12.2`](#powersync---v1122) + +Packages with dependency updates only: + +> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project. + + - `powersync_attachments_helper` - `v0.6.18+4` + - `powersync_sqlcipher` - `v0.1.5+2` + - `powersync` - `v1.12.2` + +--- + +#### `powersync_core` - `v1.2.2` + + - Fix handling token invalidation on the web. + + ## 2025-03-06 ### Changes diff --git a/demos/benchmarks/pubspec.yaml b/demos/benchmarks/pubspec.yaml index 96570155..73be158e 100644 --- a/demos/benchmarks/pubspec.yaml +++ b/demos/benchmarks/pubspec.yaml @@ -10,7 +10,7 @@ environment: dependencies: flutter: sdk: flutter - powersync: ^1.12.1 + powersync: ^1.12.2 path_provider: ^2.1.1 path: ^1.8.3 logging: ^1.2.0 diff --git a/demos/django-todolist/pubspec.yaml b/demos/django-todolist/pubspec.yaml index 75ed31f7..01bd857f 100644 --- a/demos/django-todolist/pubspec.yaml +++ b/demos/django-todolist/pubspec.yaml @@ -10,7 +10,7 @@ environment: dependencies: flutter: sdk: flutter - powersync: ^1.12.1 + powersync: ^1.12.2 path_provider: ^2.1.1 path: ^1.8.3 logging: ^1.2.0 diff --git a/demos/firebase-nodejs-todolist/pubspec.yaml b/demos/firebase-nodejs-todolist/pubspec.yaml index 2a9325e7..f19af4a2 100644 --- a/demos/firebase-nodejs-todolist/pubspec.yaml +++ b/demos/firebase-nodejs-todolist/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: flutter: sdk: flutter - powersync: ^1.12.1 + powersync: ^1.12.2 path_provider: ^2.1.1 supabase_flutter: ^2.0.1 path: ^1.8.3 diff --git a/demos/supabase-anonymous-auth/pubspec.yaml b/demos/supabase-anonymous-auth/pubspec.yaml index a20bb223..b661d835 100644 --- a/demos/supabase-anonymous-auth/pubspec.yaml +++ b/demos/supabase-anonymous-auth/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: flutter: sdk: flutter - powersync: ^1.12.1 + powersync: ^1.12.2 path_provider: ^2.1.1 supabase_flutter: ^2.0.2 path: ^1.8.3 diff --git a/demos/supabase-edge-function-auth/pubspec.yaml b/demos/supabase-edge-function-auth/pubspec.yaml index 5a6ee09e..5513952a 100644 --- a/demos/supabase-edge-function-auth/pubspec.yaml +++ b/demos/supabase-edge-function-auth/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: flutter: sdk: flutter - powersync: ^1.12.1 + powersync: ^1.12.2 path_provider: ^2.1.1 supabase_flutter: ^2.0.2 path: ^1.8.3 diff --git a/demos/supabase-simple-chat/pubspec.yaml b/demos/supabase-simple-chat/pubspec.yaml index b620f870..e1777b0f 100644 --- a/demos/supabase-simple-chat/pubspec.yaml +++ b/demos/supabase-simple-chat/pubspec.yaml @@ -37,7 +37,7 @@ dependencies: supabase_flutter: ^2.0.2 timeago: ^3.6.0 - powersync: ^1.12.1 + powersync: ^1.12.2 path_provider: ^2.1.1 path: ^1.8.3 logging: ^1.2.0 diff --git a/demos/supabase-todolist-drift/pubspec.yaml b/demos/supabase-todolist-drift/pubspec.yaml index ff70f81f..8b95168b 100644 --- a/demos/supabase-todolist-drift/pubspec.yaml +++ b/demos/supabase-todolist-drift/pubspec.yaml @@ -9,8 +9,8 @@ environment: dependencies: flutter: sdk: flutter - powersync_attachments_helper: ^0.6.18+3 - powersync: ^1.12.1 + powersync_attachments_helper: ^0.6.18+4 + powersync: ^1.12.2 path_provider: ^2.1.1 supabase_flutter: ^2.0.1 path: ^1.8.3 diff --git a/demos/supabase-todolist-optional-sync/pubspec.yaml b/demos/supabase-todolist-optional-sync/pubspec.yaml index 3f287711..fa007858 100644 --- a/demos/supabase-todolist-optional-sync/pubspec.yaml +++ b/demos/supabase-todolist-optional-sync/pubspec.yaml @@ -10,7 +10,7 @@ environment: dependencies: flutter: sdk: flutter - powersync: ^1.12.1 + powersync: ^1.12.2 path_provider: ^2.1.1 supabase_flutter: ^2.0.1 path: ^1.8.3 diff --git a/demos/supabase-todolist/pubspec.yaml b/demos/supabase-todolist/pubspec.yaml index 126c9308..11487ae5 100644 --- a/demos/supabase-todolist/pubspec.yaml +++ b/demos/supabase-todolist/pubspec.yaml @@ -10,8 +10,8 @@ environment: dependencies: flutter: sdk: flutter - powersync_attachments_helper: ^0.6.18+3 - powersync: ^1.12.1 + powersync_attachments_helper: ^0.6.18+4 + powersync: ^1.12.2 path_provider: ^2.1.1 supabase_flutter: ^2.0.1 path: ^1.8.3 diff --git a/demos/supabase-trello/pubspec.yaml b/demos/supabase-trello/pubspec.yaml index 4aa51b1b..f55dc8b2 100644 --- a/demos/supabase-trello/pubspec.yaml +++ b/demos/supabase-trello/pubspec.yaml @@ -36,7 +36,7 @@ dependencies: random_name_generator: ^1.5.0 flutter_dotenv: ^5.2.1 logging: ^1.3.0 - powersync: ^1.12.1 + powersync: ^1.12.2 sqlite_async: ^0.11.0 path_provider: ^2.1.5 supabase_flutter: ^2.8.3 diff --git a/packages/powersync/CHANGELOG.md b/packages/powersync/CHANGELOG.md index 94ef844c..1a263e26 100644 --- a/packages/powersync/CHANGELOG.md +++ b/packages/powersync/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.12.2 + + - Update a dependency to the latest release. + ## 1.12.1 - Update a dependency to the latest release. diff --git a/packages/powersync/pubspec.yaml b/packages/powersync/pubspec.yaml index 4c576d1f..0c438058 100644 --- a/packages/powersync/pubspec.yaml +++ b/packages/powersync/pubspec.yaml @@ -1,5 +1,5 @@ name: powersync -version: 1.12.1 +version: 1.12.2 homepage: https://powersync.com repository: https://github.com/powersync-ja/powersync.dart description: PowerSync Flutter SDK - sync engine for building local-first apps. @@ -12,7 +12,7 @@ dependencies: sdk: flutter sqlite3_flutter_libs: ^0.5.23 - powersync_core: ^1.2.1 + powersync_core: ^1.2.2 powersync_flutter_libs: ^0.4.7 collection: ^1.17.0 diff --git a/packages/powersync_attachments_helper/CHANGELOG.md b/packages/powersync_attachments_helper/CHANGELOG.md index cf0ac2cc..acca968c 100644 --- a/packages/powersync_attachments_helper/CHANGELOG.md +++ b/packages/powersync_attachments_helper/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.6.18+4 + + - Update a dependency to the latest release. + ## 0.6.18+3 - Update a dependency to the latest release. diff --git a/packages/powersync_attachments_helper/pubspec.yaml b/packages/powersync_attachments_helper/pubspec.yaml index cf93a5b6..5d45f744 100644 --- a/packages/powersync_attachments_helper/pubspec.yaml +++ b/packages/powersync_attachments_helper/pubspec.yaml @@ -1,6 +1,6 @@ name: powersync_attachments_helper description: A helper library for handling attachments when using PowerSync. -version: 0.6.18+3 +version: 0.6.18+4 repository: https://github.com/powersync-ja/powersync.dart homepage: https://www.powersync.com/ environment: @@ -10,7 +10,7 @@ dependencies: flutter: sdk: flutter - powersync_core: ^1.2.1 + powersync_core: ^1.2.2 logging: ^1.2.0 sqlite_async: ^0.11.0 path_provider: ^2.0.13 diff --git a/packages/powersync_core/CHANGELOG.md b/packages/powersync_core/CHANGELOG.md index d3dd2972..1d24232c 100644 --- a/packages/powersync_core/CHANGELOG.md +++ b/packages/powersync_core/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.2.2 + + - Fix handling token invalidation on the web. + ## 1.2.1 - Raise minimum version of core extension to 0.3.11. diff --git a/packages/powersync_core/lib/src/database/web/web_powersync_database.dart b/packages/powersync_core/lib/src/database/web/web_powersync_database.dart index b981319c..a55aa5b4 100644 --- a/packages/powersync_core/lib/src/database/web/web_powersync_database.dart +++ b/packages/powersync_core/lib/src/database/web/web_powersync_database.dart @@ -162,7 +162,7 @@ class PowerSyncDatabaseImpl sync = StreamingSyncImplementation( adapter: storage, credentialsCallback: connector.getCredentialsCached, - invalidCredentialsCallback: connector.fetchCredentials, + invalidCredentialsCallback: connector.prefetchCredentials, uploadCrud: () => connector.uploadData(this), crudUpdateTriggerStream: crudStream, retryDelay: Duration(seconds: 3), diff --git a/packages/powersync_core/lib/src/version.dart b/packages/powersync_core/lib/src/version.dart index 22354920..e21aca16 100644 --- a/packages/powersync_core/lib/src/version.dart +++ b/packages/powersync_core/lib/src/version.dart @@ -1 +1 @@ -const String libraryVersion = '1.2.1'; +const String libraryVersion = '1.2.2'; diff --git a/packages/powersync_core/lib/src/web/sync_controller.dart b/packages/powersync_core/lib/src/web/sync_controller.dart index 334281a1..be930fb4 100644 --- a/packages/powersync_core/lib/src/web/sync_controller.dart +++ b/packages/powersync_core/lib/src/web/sync_controller.dart @@ -48,7 +48,7 @@ class SyncWorkerHandle implements StreamingSync { await connector.uploadData(database); return (JSObject(), null); case SyncWorkerMessageType.invalidCredentialsCallback: - final credentials = await connector.fetchCredentials(); + final credentials = await connector.prefetchCredentials(); return ( credentials != null ? SerializedCredentials.from(credentials) diff --git a/packages/powersync_core/pubspec.yaml b/packages/powersync_core/pubspec.yaml index 07ae1cc1..c8ca15b1 100644 --- a/packages/powersync_core/pubspec.yaml +++ b/packages/powersync_core/pubspec.yaml @@ -1,5 +1,5 @@ name: powersync_core -version: 1.2.1 +version: 1.2.2 homepage: https://powersync.com repository: https://github.com/powersync-ja/powersync.dart description: PowerSync Dart SDK - sync engine for building local-first apps. @@ -13,7 +13,7 @@ dependencies: # but right now we need a minimum of v2.4.6. sqlite3: ^2.4.6 # We implement a database controller, which is an interface of sqlite3_web. - sqlite3_web: ^0.3.0 + sqlite3_web: ^0.3.1 universal_io: ^2.0.0 meta: ^1.0.0 http: ^1.1.0 diff --git a/packages/powersync_core/test/in_memory_sync_test.dart b/packages/powersync_core/test/in_memory_sync_test.dart index 22d2d4e3..359f68e7 100644 --- a/packages/powersync_core/test/in_memory_sync_test.dart +++ b/packages/powersync_core/test/in_memory_sync_test.dart @@ -20,9 +20,11 @@ void main() { late CommonDatabase raw; late PowerSyncDatabase database; late MockSyncService syncService; - late StreamingSyncImplementation syncClient; + late StreamingSync syncClient; + var credentialsCallbackCount = 0; setUp(() async { + credentialsCallbackCount = 0; final (client, server) = inMemoryServer(); syncService = MockSyncService(); server.mount(syncService.router.call); @@ -30,12 +32,14 @@ void main() { factory = await testUtils.testFactory(); (raw, database) = await factory.openInMemoryDatabase(); await database.initialize(); + syncClient = database.connectWithMockService( client, TestConnector(() async { + credentialsCallbackCount++; return PowerSyncCredentials( endpoint: server.url.toString(), - token: 'token not used here', + token: 'token$credentialsCallbackCount', expiresAt: DateTime.now(), ); }), @@ -312,11 +316,27 @@ void main() { }, ); }); + + test('reconnects when token expires', () async { + await waitForConnection(); + expect(credentialsCallbackCount, 1); + // When the sync service says the token has expired + syncService + ..addLine({'token_expires_in': 0}) + ..endCurrentListener(); + + final nextRequest = await syncService.waitForListener; + expect(nextRequest.headers['Authorization'], 'Token token2'); + expect(credentialsCallbackCount, 2); + }); }); } TypeMatcher isSyncStatus( - {Object? downloading, Object? connected, Object? hasSynced}) { + {Object? downloading, + Object? connected, + Object? connecting, + Object? hasSynced}) { var matcher = isA(); if (downloading != null) { matcher = matcher.having((e) => e.downloading, 'downloading', downloading); @@ -324,6 +344,9 @@ TypeMatcher isSyncStatus( if (connected != null) { matcher = matcher.having((e) => e.connected, 'connected', connected); } + if (connecting != null) { + matcher = matcher.having((e) => e.connecting, 'connecting', connecting); + } if (hasSynced != null) { matcher = matcher.having((e) => e.hasSynced, 'hasSynced', hasSynced); } diff --git a/packages/powersync_core/test/server/sync_server/in_memory_sync_server.dart b/packages/powersync_core/test/server/sync_server/in_memory_sync_server.dart index b31dffc2..dd4db237 100644 --- a/packages/powersync_core/test/server/sync_server/in_memory_sync_server.dart +++ b/packages/powersync_core/test/server/sync_server/in_memory_sync_server.dart @@ -6,15 +6,15 @@ import 'package:shelf_router/shelf_router.dart'; final class MockSyncService { // Use a queued stream to make tests easier. - StreamController _controller = StreamController(); - Completer _listener = Completer(); + StreamController _controller = StreamController(); + Completer _listener = Completer(); final router = Router(); MockSyncService() { router ..post('/sync/stream', (Request request) async { - _listener.complete(); + _listener.complete(request); // Respond immediately with a stream return Response.ok(_controller.stream.transform(utf8.encoder), headers: { @@ -33,7 +33,7 @@ final class MockSyncService { }); } - Future get waitForListener => _listener.future; + Future get waitForListener => _listener.future; // Queue events which will be sent to connected clients. void addRawEvent(String data) { @@ -48,6 +48,12 @@ final class MockSyncService { addLine({'token_expires_in': tokenExpiresIn}); } + void endCurrentListener() { + _controller.close(); + _controller = StreamController(); + _listener = Completer(); + } + // Clear events. We rely on a buffered controller here. Create a new controller // in order to clear the buffer. Future clearEvents() async { diff --git a/packages/powersync_sqlcipher/CHANGELOG.md b/packages/powersync_sqlcipher/CHANGELOG.md index f9e9d3b8..949cc89c 100644 --- a/packages/powersync_sqlcipher/CHANGELOG.md +++ b/packages/powersync_sqlcipher/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.5+2 + + - Update a dependency to the latest release. + ## 0.1.5+1 - Update a dependency to the latest release. diff --git a/packages/powersync_sqlcipher/pubspec.yaml b/packages/powersync_sqlcipher/pubspec.yaml index a86f0ed7..44b9af17 100644 --- a/packages/powersync_sqlcipher/pubspec.yaml +++ b/packages/powersync_sqlcipher/pubspec.yaml @@ -1,5 +1,5 @@ name: powersync_sqlcipher -version: 0.1.5+1 +version: 0.1.5+2 homepage: https://powersync.com repository: https://github.com/powersync-ja/powersync.dart description: PowerSync Flutter SDK - sync engine for building local-first apps. @@ -12,7 +12,7 @@ dependencies: flutter: sdk: flutter - powersync_core: ^1.2.1 + powersync_core: ^1.2.2 powersync_flutter_libs: ^0.4.7 sqlcipher_flutter_libs: ^0.6.4 sqlite3_web: ^0.3.0