From 041844d8dcd18c6c1735fc7fb3c85e62b62e4749 Mon Sep 17 00:00:00 2001 From: Francis Ilechukwu Date: Thu, 22 Apr 2021 07:12:08 +0100 Subject: [PATCH 1/2] Migrate to Null Safe Version. --- .dart_tool/package_config.json | 56 +++++++++++++++++++ .dart_tool/package_config_subset | 33 +++++++++++ .dart_tool/version | 1 + example/.gitignore | 1 + .../ios/Flutter/flutter_export_environment.sh | 14 +++++ example/lib/main.dart | 4 +- example/pubspec.yaml | 3 + lib/flutter_string_encryption.dart | 20 +++---- pubspec.yaml | 12 ++-- 9 files changed, 126 insertions(+), 18 deletions(-) create mode 100644 .dart_tool/package_config.json create mode 100644 .dart_tool/package_config_subset create mode 100644 .dart_tool/version create mode 100755 example/ios/Flutter/flutter_export_environment.sh diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json new file mode 100644 index 0000000..cc0a2b4 --- /dev/null +++ b/.dart_tool/package_config.json @@ -0,0 +1,56 @@ +{ + "configVersion": 2, + "packages": [ + { + "name": "characters", + "rootUri": "file:///Users/francis/bin/flutter/.pub-cache/hosted/pub.dartlang.org/characters-1.1.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "collection", + "rootUri": "file:///Users/francis/bin/flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.15.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "flutter", + "rootUri": "file:///Users/francis/bin/flutter/packages/flutter", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "meta", + "rootUri": "file:///Users/francis/bin/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "sky_engine", + "rootUri": "file:///Users/francis/bin/flutter/bin/cache/pkg/sky_engine", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "typed_data", + "rootUri": "file:///Users/francis/bin/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.3.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "vector_math", + "rootUri": "file:///Users/francis/bin/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.1.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "flutter_string_encryption", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.12" + } + ], + "generated": "2021-04-22T06:10:46.351698Z", + "generator": "pub", + "generatorVersion": "2.13.0-211.6.beta" +} diff --git a/.dart_tool/package_config_subset b/.dart_tool/package_config_subset new file mode 100644 index 0000000..ee6be63 --- /dev/null +++ b/.dart_tool/package_config_subset @@ -0,0 +1,33 @@ +characters +2.12 +file:///Users/francis/bin/flutter/.pub-cache/hosted/pub.dartlang.org/characters-1.1.0/ +file:///Users/francis/bin/flutter/.pub-cache/hosted/pub.dartlang.org/characters-1.1.0/lib/ +collection +2.12 +file:///Users/francis/bin/flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.15.0/ +file:///Users/francis/bin/flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.15.0/lib/ +meta +2.12 +file:///Users/francis/bin/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0/ +file:///Users/francis/bin/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0/lib/ +typed_data +2.12 +file:///Users/francis/bin/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.3.0/ +file:///Users/francis/bin/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.3.0/lib/ +vector_math +2.12 +file:///Users/francis/bin/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.1.0/ +file:///Users/francis/bin/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.1.0/lib/ +sky_engine +2.12 +file:///Users/francis/bin/flutter/bin/cache/pkg/sky_engine/ +file:///Users/francis/bin/flutter/bin/cache/pkg/sky_engine/lib/ +flutter +2.12 +file:///Users/francis/bin/flutter/packages/flutter/ +file:///Users/francis/bin/flutter/packages/flutter/lib/ +flutter_string_encryption +2.12 +file:///Users/francis/projects/flutter_string_encryption/ +file:///Users/francis/projects/flutter_string_encryption/lib/ +2 diff --git a/.dart_tool/version b/.dart_tool/version new file mode 100644 index 0000000..72d95be --- /dev/null +++ b/.dart_tool/version @@ -0,0 +1 @@ +2.2.0-10.1.pre \ No newline at end of file diff --git a/example/.gitignore b/example/.gitignore index 3b9b8ba..1ff89cb 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -9,3 +9,4 @@ ios/.generated/ packages pubspec.lock .flutter-plugins +.dart_tool/ \ No newline at end of file diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh new file mode 100755 index 0000000..22ca8ba --- /dev/null +++ b/example/ios/Flutter/flutter_export_environment.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# This is a generated file; do not edit or check into version control. +export "FLUTTER_ROOT=/Users/francis/bin/flutter" +export "FLUTTER_APPLICATION_PATH=/Users/francis/projects/flutter_string_encryption/example" +export "COCOAPODS_PARALLEL_CODE_SIGN=true" +export "FLUTTER_TARGET=lib/main.dart" +export "FLUTTER_BUILD_DIR=build" +export "SYMROOT=${SOURCE_ROOT}/../build/ios" +export "FLUTTER_BUILD_NAME=1.0.0" +export "FLUTTER_BUILD_NUMBER=1" +export "DART_OBFUSCATION=false" +export "TRACK_WIDGET_CREATION=false" +export "TREE_SHAKE_ICONS=false" +export "PACKAGE_CONFIG=.packages" diff --git a/example/lib/main.dart b/example/lib/main.dart index 477c084..ea4acf4 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -9,9 +9,9 @@ class MyApp extends StatefulWidget { } class _MyAppState extends State { - String _randomKey = 'Unknown'; + String? _randomKey = 'Unknown'; String _string = "Unknown"; - String _encrypted = "Unknown"; + String? _encrypted = "Unknown"; @override initState() { diff --git a/example/pubspec.yaml b/example/pubspec.yaml index a146ebb..d3291a1 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -16,6 +16,9 @@ dev_dependencies: flutter_string_encryption: path: ../ +environment: + sdk: '>=2.12.0 <3.0.0' + # For information on the generic Dart part of this file, see the # following page: https://www.dartlang.org/tools/pub/pubspec diff --git a/lib/flutter_string_encryption.dart b/lib/flutter_string_encryption.dart index 377609d..46351e0 100644 --- a/lib/flutter_string_encryption.dart +++ b/lib/flutter_string_encryption.dart @@ -5,26 +5,26 @@ import 'package:flutter/services.dart'; /// Interface for the Plugin abstract class StringCryptor { /// Generates a random key to use with [encrypt] and [decrypt] methods - Future generateRandomKey(); + Future generateRandomKey(); /// Gets a key from the given [password] and [salt]. [salt] can be generated /// with [generateSalt] while [password] is usually provided by the user. - Future generateKeyFromPassword(String password, String salt); + Future generateKeyFromPassword(String password, String salt); /// Generates a salt to use with [generateKeyFromPassword] - Future generateSalt(); + Future generateSalt(); /// Encrypts [string] using a [key] generated from [generateRandomKey] or /// [generateKeyFromPassword]. The returned string is a sequence of 3 /// base64-encoded strings (iv, mac and cipherText) and can be transferred and /// stored almost anywhere. - Future encrypt(String string, String key); + Future encrypt(String string, String key); /// Decrypts [data] created with the [encrypt] method using a [key] created /// with [generateRandomKey] or [generateKeyFromPassword] methods. /// In case the [key] is wrong or the [data] has been forged, a /// [MacMismatchException] is thrown - Future decrypt(String data, String key); + Future decrypt(String data, String key); } /// Implementation of [StringCryptor] using platform channels @@ -32,7 +32,7 @@ class PlatformStringCryptor implements StringCryptor { static const MethodChannel _channel = const MethodChannel('flutter_string_encryption'); @override - Future decrypt(String data, String key) async { + Future decrypt(String? data, String? key) async { try { final decrypted = await _channel.invokeMethod("decrypt", { "data": data, @@ -50,20 +50,20 @@ class PlatformStringCryptor implements StringCryptor { } @override - Future encrypt(String string, String key) async => + Future encrypt(String string, String? key) async => await _channel.invokeMethod("encrypt", { "string": string, "key": key, }); @override - Future generateRandomKey() async => await _channel.invokeMethod("generate_random_key"); + Future generateRandomKey() async => await _channel.invokeMethod("generate_random_key"); @override - Future generateSalt() async => await _channel.invokeMethod("generate_salt"); + Future generateSalt() async => await _channel.invokeMethod("generate_salt"); @override - Future generateKeyFromPassword(String password, String salt) async => + Future generateKeyFromPassword(String password, String salt) async => await _channel.invokeMethod("generate_key_from_password", { "password": password, "salt": salt, diff --git a/pubspec.yaml b/pubspec.yaml index bce80d8..4fc5fb0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_string_encryption description: Cross-platform string encryption using common best-practices. -version: 0.3.1 +version: 0.4.1-nullsafety.0 author: Stefano Rodriguez homepage: https://github.com/sroddy/flutter_string_encryption @@ -9,13 +9,13 @@ dependencies: sdk: flutter environment: - sdk: '>=1.24.0 <3.0.0' + sdk: '>=2.12.0 <3.0.0' # For information on the generic Dart part of this file, see the # following page: https://www.dartlang.org/tools/pub/pubspec # The following section is specific to Flutter. -flutter: - plugin: - androidPackage: com.github.sroddy.flutterstringencryption - pluginClass: FlutterStringEncryptionPlugin +# flutter: +# plugin: +# androidPackage: com.github.sroddy.flutterstringencryption +# pluginClass: FlutterStringEncryptionPlugin From af8bf9d1b68c1c67581fe50e76602c65a1fe061f Mon Sep 17 00:00:00 2001 From: Francis Ilechukwu Date: Thu, 22 Apr 2021 14:22:46 +0100 Subject: [PATCH 2/2] Restore plugin dependency. --- .dart_tool/package_config.json | 2 +- example/.flutter-plugins-dependencies | 1 + pubspec.yaml | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 example/.flutter-plugins-dependencies diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json index cc0a2b4..40755ba 100644 --- a/.dart_tool/package_config.json +++ b/.dart_tool/package_config.json @@ -50,7 +50,7 @@ "languageVersion": "2.12" } ], - "generated": "2021-04-22T06:10:46.351698Z", + "generated": "2021-04-22T13:22:10.694041Z", "generator": "pub", "generatorVersion": "2.13.0-211.6.beta" } diff --git a/example/.flutter-plugins-dependencies b/example/.flutter-plugins-dependencies new file mode 100644 index 0000000..e88dffc --- /dev/null +++ b/example/.flutter-plugins-dependencies @@ -0,0 +1 @@ +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_string_encryption","path":"/Users/francis/projects/flutter_string_encryption/","dependencies":[]}],"android":[{"name":"flutter_string_encryption","path":"/Users/francis/projects/flutter_string_encryption/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"flutter_string_encryption","dependencies":[]}],"date_created":"2021-04-22 14:22:12.946538","version":"2.2.0-10.1.pre"} \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index 4fc5fb0..a45da3b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ environment: # following page: https://www.dartlang.org/tools/pub/pubspec # The following section is specific to Flutter. -# flutter: -# plugin: -# androidPackage: com.github.sroddy.flutterstringencryption -# pluginClass: FlutterStringEncryptionPlugin +flutter: + plugin: + androidPackage: com.github.sroddy.flutterstringencryption + pluginClass: FlutterStringEncryptionPlugin