-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
161 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
import Cocoa | ||
import FlutterMacOS | ||
|
||
@NSApplicationMain | ||
@main | ||
class AppDelegate: FlutterAppDelegate { | ||
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { | ||
return true | ||
} | ||
|
||
override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { | ||
return true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/// Internal options used to customize how PowerSync opens databases on the web. | ||
library; | ||
|
||
export 'src/web/worker_utils.dart' show PowerSyncAdditionalOpenOptions; | ||
export 'package:sqlite_async/sqlite3_web.dart'; | ||
export 'package:sqlite_async/web.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import '../powersync.dart'; | ||
import '../sqlite_async.dart'; | ||
|
||
PowerSyncSQLCipherOpenFactory cipherFactory({ | ||
required String path, | ||
required String key, | ||
required SqliteOptions options, | ||
}) { | ||
throw UnsupportedError('Unsupported platform for powersync_sqlcipher'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import 'package:powersync_core/sqlite_async.dart'; | ||
import 'package:powersync_core/web.dart'; | ||
|
||
import '../powersync.dart'; | ||
|
||
final class _WebEncryptionFactory extends PowerSyncSQLCipherOpenFactory | ||
with WebSqliteOpenFactory { | ||
_WebEncryptionFactory({ | ||
required super.path, | ||
required super.key, | ||
super.sqliteOptions, | ||
}) : super.internal(); | ||
|
||
@override | ||
List<String> pragmaStatements(SqliteOpenOptions options) { | ||
final basePragmaStatements = super.pragmaStatements(options); | ||
return [ | ||
// Set the encryption key as the first statement | ||
"PRAGMA KEY = ${quoteString(key)}", | ||
// Include the default statements afterwards | ||
for (var statement in basePragmaStatements) statement | ||
]; | ||
} | ||
|
||
@override | ||
Future<ConnectToRecommendedResult> connectToWorker( | ||
WebSqlite sqlite, String name) async { | ||
return sqlite.connectToRecommended( | ||
name, | ||
additionalOptions: PowerSyncAdditionalOpenOptions( | ||
useMultipleCiphersVfs: true, | ||
), | ||
); | ||
} | ||
} | ||
|
||
PowerSyncSQLCipherOpenFactory cipherFactory({ | ||
required String path, | ||
required String key, | ||
required SqliteOptions options, | ||
}) { | ||
return _WebEncryptionFactory(path: path, key: key, sqliteOptions: options); | ||
} |