feat: Migrate to moxlib 0.2.0
This commit is contained in:
@@ -1,23 +1,17 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
enum CipherAlgorithm {
|
||||
aes128GcmNoPadding,
|
||||
aes256GcmNoPadding,
|
||||
aes256CbcPkcs7,
|
||||
}
|
||||
aes128GcmNoPadding(0),
|
||||
aes256GcmNoPadding(1),
|
||||
aes256CbcPkcs7(2);
|
||||
|
||||
extension CipherAlgorithmToIntExtension on CipherAlgorithm {
|
||||
int toInt() {
|
||||
switch (this) {
|
||||
case CipherAlgorithm.aes128GcmNoPadding: return 0;
|
||||
case CipherAlgorithm.aes256GcmNoPadding: return 1;
|
||||
case CipherAlgorithm.aes256CbcPkcs7: return 2;
|
||||
}
|
||||
}
|
||||
const CipherAlgorithm(this.value);
|
||||
|
||||
/// The "id" of the algorithm choice.
|
||||
final int value;
|
||||
}
|
||||
|
||||
class CryptographyResult {
|
||||
|
||||
const CryptographyResult(this.plaintextHash, this.ciphertextHash);
|
||||
final Uint8List plaintextHash;
|
||||
final Uint8List ciphertextHash;
|
||||
@@ -30,14 +24,28 @@ abstract class CryptographyImplementation {
|
||||
/// Note that this function runs off-thread as to not block the UI thread.
|
||||
///
|
||||
/// Resolves to true if the encryption was successful. Resolves to fale on failure.
|
||||
Future<CryptographyResult?> encryptFile(String sourcePath, String destPath, Uint8List key, Uint8List iv, CipherAlgorithm algorithm, String hashSpec);
|
||||
Future<CryptographyResult?> encryptFile(
|
||||
String sourcePath,
|
||||
String destPath,
|
||||
Uint8List key,
|
||||
Uint8List iv,
|
||||
CipherAlgorithm algorithm,
|
||||
String hashSpec,
|
||||
);
|
||||
|
||||
/// Decrypt the file at [sourcePath] using [algorithm] and write the result back to
|
||||
/// [destPath]. [hashSpec] is the name of the Hash function to use, i.e. "SHA-256".
|
||||
/// Note that this function runs off-thread as to not block the UI thread.
|
||||
///
|
||||
///
|
||||
/// Resolves to true if the encryption was successful. Resolves to fale on failure.
|
||||
Future<CryptographyResult?> decryptFile(String sourcePath, String destPath, Uint8List key, Uint8List iv, CipherAlgorithm algorithm, String hashSpec);
|
||||
Future<CryptographyResult?> decryptFile(
|
||||
String sourcePath,
|
||||
String destPath,
|
||||
Uint8List key,
|
||||
Uint8List iv,
|
||||
CipherAlgorithm algorithm,
|
||||
String hashSpec,
|
||||
);
|
||||
|
||||
/// Hashes the file at [path] using the Hash function with name [hashSpec].
|
||||
/// Note that this function runs off-thread as to not block the UI thread.
|
||||
|
||||
@@ -3,12 +3,26 @@ import 'package:moxplatform_platform_interface/src/crypto.dart';
|
||||
|
||||
class StubCryptographyImplementation extends CryptographyImplementation {
|
||||
@override
|
||||
Future<CryptographyResult?> encryptFile(String sourcePath, String destPath, Uint8List key, Uint8List iv, CipherAlgorithm algorithm, String hashSpec) async {
|
||||
Future<CryptographyResult?> encryptFile(
|
||||
String sourcePath,
|
||||
String destPath,
|
||||
Uint8List key,
|
||||
Uint8List iv,
|
||||
CipherAlgorithm algorithm,
|
||||
String hashSpec,
|
||||
) async {
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<CryptographyResult?> decryptFile(String sourcePath, String destPath, Uint8List key, Uint8List iv, CipherAlgorithm algorithm, String hashSpec) async {
|
||||
Future<CryptographyResult?> decryptFile(
|
||||
String sourcePath,
|
||||
String destPath,
|
||||
Uint8List key,
|
||||
Uint8List iv,
|
||||
CipherAlgorithm algorithm,
|
||||
String hashSpec,
|
||||
) async {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ abstract class MoxplatformInterface extends PlatformInterface {
|
||||
MoxplatformInterface() : super(token: _token);
|
||||
|
||||
static final Object _token = Object();
|
||||
|
||||
|
||||
static IsolateHandler handler = StubIsolateHandler();
|
||||
static MediaScannerImplementation media = StubMediaScannerImplementation();
|
||||
static CryptographyImplementation crypto = StubCryptographyImplementation();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'package:moxlib/awaitabledatasender.dart';
|
||||
import 'package:moxlib/moxlib.dart';
|
||||
|
||||
/// A class abstracting the interaction between the UI isolate and the background
|
||||
/// service, which is either a regular isolate or an Android foreground service.
|
||||
@@ -18,7 +18,7 @@ abstract class IsolateHandler {
|
||||
Future<void> attach(
|
||||
Future<void> Function(Map<String, dynamic>? data) handleIsolateEvent,
|
||||
);
|
||||
|
||||
|
||||
/// Return true if the background service is running. False if it's not.
|
||||
Future<bool> isRunning();
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'package:moxlib/awaitabledatasender.dart';
|
||||
import 'package:moxlib/moxlib.dart';
|
||||
import 'package:moxplatform_platform_interface/src/isolate.dart';
|
||||
|
||||
class StubDataSender extends AwaitableDataSender {
|
||||
@@ -19,7 +19,7 @@ class StubIsolateHandler extends IsolateHandler {
|
||||
// ignore: avoid_print
|
||||
print('STUB ATTACHED!!!!!!');
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Future<void> start(
|
||||
Future<void> Function() entrypoint,
|
||||
|
||||
@@ -5,7 +5,7 @@ abstract class BackgroundService {
|
||||
void setNotification(String title, String body);
|
||||
|
||||
/// Send data from the background service to the UI.
|
||||
void sendEvent(BackgroundEvent event, { String? id });
|
||||
void sendEvent(BackgroundEvent event, {String? id});
|
||||
|
||||
/// Called before [entrypoint]. Sets up whatever it needs to set up.
|
||||
/// [handleEvent] is a function that is called whenever the service receives
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
name: moxplatform_platform_interface
|
||||
description: A common platform interface for the my_plugin plugin.
|
||||
version: 0.1.15
|
||||
version: 0.1.16
|
||||
homepage: https://codeberg.org/moxxy/moxplatform
|
||||
publish_to: https://git.polynom.me/api/packages/Moxxy/pub
|
||||
|
||||
environment:
|
||||
sdk: ">=2.16.0 <3.0.0"
|
||||
sdk: ">=2.17.0 <3.0.0"
|
||||
flutter: ">=2.10.0"
|
||||
|
||||
dependencies:
|
||||
@@ -14,14 +14,14 @@ dependencies:
|
||||
|
||||
moxlib:
|
||||
hosted: https://git.polynom.me/api/packages/Moxxy/pub
|
||||
version: ^0.1.4
|
||||
version: ^0.2.0
|
||||
moxplatform:
|
||||
hosted: https://git.polynom.me/api/packages/Moxxy/pub
|
||||
version: ^0.1.15
|
||||
version: ^0.1.16
|
||||
|
||||
plugin_platform_interface: ^2.1.2
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
very_good_analysis: ^2.4.0
|
||||
very_good_analysis: ^3.0.1
|
||||
|
||||
Reference in New Issue
Block a user