25 changed files with 692 additions and 0 deletions
			
			
		@ -0,0 +1,32 @@ | 
				
			|||||||
 | 
					# Miscellaneous | 
				
			||||||
 | 
					*.class | 
				
			||||||
 | 
					*.log | 
				
			||||||
 | 
					*.pyc | 
				
			||||||
 | 
					*.swp | 
				
			||||||
 | 
					.DS_Store | 
				
			||||||
 | 
					.atom/ | 
				
			||||||
 | 
					.buildlog/ | 
				
			||||||
 | 
					.history | 
				
			||||||
 | 
					.svn/ | 
				
			||||||
 | 
					migrate_working_dir/ | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# IntelliJ related | 
				
			||||||
 | 
					*.iml | 
				
			||||||
 | 
					*.ipr | 
				
			||||||
 | 
					*.iws | 
				
			||||||
 | 
					.idea/ | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# The .vscode folder contains launch configuration and tasks you configure in | 
				
			||||||
 | 
					# VS Code which you may wish to be included in version control, so this line | 
				
			||||||
 | 
					# is commented out by default. | 
				
			||||||
 | 
					#.vscode/ | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Flutter/Dart/Pub related | 
				
			||||||
 | 
					# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. | 
				
			||||||
 | 
					/pubspec.lock | 
				
			||||||
 | 
					**/doc/api/ | 
				
			||||||
 | 
					.dart_tool/ | 
				
			||||||
 | 
					.packages | 
				
			||||||
 | 
					build/ | 
				
			||||||
 | 
					.metadata | 
				
			||||||
 | 
					run.sh | 
				
			||||||
@ -0,0 +1,46 @@ | 
				
			|||||||
 | 
					# flutter_secure_storage_aurora | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					The Aurora implementation of [`flutter_secure_storage`][https://pub.dev/packages/flutter_secure_storage]. | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Usage | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					This package is not an _endorsed_ implementation of `flutter_secure_storage`.  | 
				
			||||||
 | 
					Therefore, you have to include `flutter_secure_storage_aurora` alongside `flutter_secure_storage` as dependencies in your `pubspec.yaml` file. | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					**pubspec.yaml** | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```yaml | 
				
			||||||
 | 
					dependencies: | 
				
			||||||
 | 
					  flutter_secure_storage: ^8.0.0 | 
				
			||||||
 | 
					  flutter_secure_storage_aurora: | 
				
			||||||
 | 
					    path: # path to folder with plugin | 
				
			||||||
 | 
					``` | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					***.dart** | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```dart | 
				
			||||||
 | 
					import 'package:flutter_secure_storage/flutter_secure_storage.dart'; | 
				
			||||||
 | 
					import 'package:flutter_secure_storage_aurora/flutter_secure_storage_aurora.dart'; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// https://pub.dev/packages/encrypt | 
				
			||||||
 | 
					// Encrypter(AES(key)) | 
				
			||||||
 | 
					// secure-random --length 16 --base 16 | 
				
			||||||
 | 
					FlutterSecureStorageAurora.setSecret('5872747ed1ceda363808efb8b2b18b20'); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					final storage = const FlutterSecureStorage(); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const key = 'my_key'; | 
				
			||||||
 | 
					const data = 'Something secret'; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Write value | 
				
			||||||
 | 
					await storage.write(key: key, value: data); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Read value | 
				
			||||||
 | 
					String? value = await storage.read(key: key); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Read all values | 
				
			||||||
 | 
					Map<String, String> allValues = await storage.readAll(); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Delete all | 
				
			||||||
 | 
					await storage.deleteAll(); | 
				
			||||||
 | 
					``` | 
				
			||||||
@ -0,0 +1 @@ | 
				
			|||||||
 | 
					include: package:flutter_lints/flutter.yaml | 
				
			||||||
| 
		 After Width: | Height: | Size: 84 KiB  | 
@ -0,0 +1,45 @@ | 
				
			|||||||
 | 
					# Miscellaneous | 
				
			||||||
 | 
					*.class | 
				
			||||||
 | 
					*.log | 
				
			||||||
 | 
					*.pyc | 
				
			||||||
 | 
					*.swp | 
				
			||||||
 | 
					.DS_Store | 
				
			||||||
 | 
					.atom/ | 
				
			||||||
 | 
					.buildlog/ | 
				
			||||||
 | 
					.history | 
				
			||||||
 | 
					.svn/ | 
				
			||||||
 | 
					migrate_working_dir/ | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# IntelliJ related | 
				
			||||||
 | 
					*.iml | 
				
			||||||
 | 
					*.ipr | 
				
			||||||
 | 
					*.iws | 
				
			||||||
 | 
					.idea/ | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# The .vscode folder contains launch configuration and tasks you configure in | 
				
			||||||
 | 
					# VS Code which you may wish to be included in version control, so this line | 
				
			||||||
 | 
					# is commented out by default. | 
				
			||||||
 | 
					#.vscode/ | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Flutter/Dart/Pub related | 
				
			||||||
 | 
					**/doc/api/ | 
				
			||||||
 | 
					**/ios/Flutter/.last_build_id | 
				
			||||||
 | 
					.dart_tool/ | 
				
			||||||
 | 
					.flutter-plugins | 
				
			||||||
 | 
					.flutter-plugins-dependencies | 
				
			||||||
 | 
					.packages | 
				
			||||||
 | 
					.pub-cache/ | 
				
			||||||
 | 
					.pub/ | 
				
			||||||
 | 
					/build/ | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Symbolication related | 
				
			||||||
 | 
					app.*.symbols | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Obfuscation related | 
				
			||||||
 | 
					app.*.map.json | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Android Studio will place build artifacts here | 
				
			||||||
 | 
					/android/app/debug | 
				
			||||||
 | 
					/android/app/profile | 
				
			||||||
 | 
					/android/app/release | 
				
			||||||
 | 
					pubspec.lock | 
				
			||||||
@ -0,0 +1,21 @@ | 
				
			|||||||
 | 
					# flutter_secure_storage_aurora_example | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Demonstrates how to use the flutter_secure_storage_aurora plugin. | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Build | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```shell | 
				
			||||||
 | 
					# Add an alias if it doesn't already exist | 
				
			||||||
 | 
					alias flutter-aurora=$HOME/.local/opt/flutter-sdk/bin/flutter | 
				
			||||||
 | 
					# Get dependencies | 
				
			||||||
 | 
					flutter-aurora pub get | 
				
			||||||
 | 
					# Run build | 
				
			||||||
 | 
					flutter-aurora build aurora --release # [--release|--debug|--profile] | 
				
			||||||
 | 
					``` | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					You can collect, sign, run an example on the device with a script located in the `script/build_example.sh` | 
				
			||||||
 | 
					More information in `build_example.sh`. | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### Preview example | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
@ -0,0 +1 @@ | 
				
			|||||||
 | 
					include: package:flutter_lints/flutter.yaml | 
				
			||||||
@ -0,0 +1 @@ | 
				
			|||||||
 | 
					flutter/ephemeral | 
				
			||||||
@ -0,0 +1,47 @@ | 
				
			|||||||
 | 
					cmake_minimum_required(VERSION 3.10) | 
				
			||||||
 | 
					project(com.example.flutter_secure_storage_aurora_example LANGUAGES CXX) | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					include(GNUInstallDirs) | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					set(BINARY_NAME ${CMAKE_PROJECT_NAME}) | 
				
			||||||
 | 
					set(FLUTTER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/flutter) | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					set(CMAKE_CXX_STANDARD 17) | 
				
			||||||
 | 
					set(CMAKE_CXX_STANDARD_REQUIRED ON) | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					set(CMAKE_CXX_FLAGS "-Wall -Wextra") | 
				
			||||||
 | 
					set(CMAKE_CXX_FLAGS_RELEASE "-O3") | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					set(CMAKE_SKIP_RPATH OFF) | 
				
			||||||
 | 
					set(CMAKE_INSTALL_RPATH "\$ORIGIN/../share/${BINARY_NAME}/lib") | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					find_package(PkgConfig REQUIRED) | 
				
			||||||
 | 
					pkg_check_modules(FlutterEmbedder REQUIRED IMPORTED_TARGET flutter-embedder) | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					add_executable(${BINARY_NAME} main.cpp ${FLUTTER_DIR}/generated_plugin_registrant.cpp) | 
				
			||||||
 | 
					target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::FlutterEmbedder) | 
				
			||||||
 | 
					target_include_directories(${BINARY_NAME} PRIVATE ${FLUTTER_DIR}) | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					include(flutter/generated_plugins.cmake) | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					set(PACKAGE_INSTALL_DIR    ${CMAKE_INSTALL_DATADIR}/${BINARY_NAME}) | 
				
			||||||
 | 
					set(DESKTOP_INSTALL_DIR    ${CMAKE_INSTALL_DATADIR}/applications) | 
				
			||||||
 | 
					set(ICONS_INSTALL_ROOT_DIR ${CMAKE_INSTALL_DATADIR}/icons/hicolor) | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					add_custom_command(TARGET ${BINARY_NAME} POST_BUILD | 
				
			||||||
 | 
					                   COMMAND ${CMAKE_COMMAND} -E copy | 
				
			||||||
 | 
					                   ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libflutter-embedder.so | 
				
			||||||
 | 
					                   ${PROJECT_BINARY_DIR}/bundle/lib/libflutter-embedder.so) | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					install(FILES     ${PROJECT_BINARY_DIR}/bundle/icudtl.dat     DESTINATION ${PACKAGE_INSTALL_DIR}) | 
				
			||||||
 | 
					install(DIRECTORY ${PROJECT_BINARY_DIR}/bundle/flutter_assets DESTINATION ${PACKAGE_INSTALL_DIR}) | 
				
			||||||
 | 
					install(DIRECTORY ${PROJECT_BINARY_DIR}/bundle/lib            DESTINATION ${PACKAGE_INSTALL_DIR}) | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) | 
				
			||||||
 | 
					install(FILES desktop/${BINARY_NAME}.desktop DESTINATION ${DESKTOP_INSTALL_DIR}) | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					foreach(ICONS_SIZE 86x86 108x108 128x128 172x172) | 
				
			||||||
 | 
					    install(FILES icons/${ICONS_SIZE}.png | 
				
			||||||
 | 
					            RENAME ${BINARY_NAME}.png | 
				
			||||||
 | 
					            DESTINATION ${ICONS_INSTALL_ROOT_DIR}/${ICONS_SIZE}/apps/) | 
				
			||||||
 | 
					endforeach(ICONS_SIZE) | 
				
			||||||
@ -0,0 +1,12 @@ | 
				
			|||||||
 | 
					[Desktop Entry] | 
				
			||||||
 | 
					Type=Application | 
				
			||||||
 | 
					Name=flutter_secure_storage_aurora_example | 
				
			||||||
 | 
					Comment=Demonstrates how to use the flutter_secure_storage_aurora plugin. | 
				
			||||||
 | 
					Icon=com.example.flutter_secure_storage_aurora_example | 
				
			||||||
 | 
					Exec=/usr/bin/com.example.flutter_secure_storage_aurora_example | 
				
			||||||
 | 
					X-Nemo-Application-Type=silica-qt5 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[X-Application] | 
				
			||||||
 | 
					Permissions= | 
				
			||||||
 | 
					OrganizationName=com.example | 
				
			||||||
 | 
					ApplicationName=flutter_secure_storage_aurora_example | 
				
			||||||
@ -0,0 +1,16 @@ | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					//  Generated file. Do not edit.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// clang-format off
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <flutter/application.h> | 
				
			||||||
 | 
					#include <path_provider_aurora/path_provider_aurora_plugin.h> | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "generated_plugin_registrant.h" | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void RegisterPlugins() { | 
				
			||||||
 | 
					    Application::RegisterPlugins({ | 
				
			||||||
 | 
					        std::make_shared<PathProviderAuroraPlugin>(), | 
				
			||||||
 | 
					    }); | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,12 @@ | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					//  Generated file. Do not edit.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// clang-format off
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef GENERATED_PLUGIN_REGISTRANT | 
				
			||||||
 | 
					#define GENERATED_PLUGIN_REGISTRANT | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void RegisterPlugins(); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif /* GENERATED_PLUGIN_REGISTRANT */ | 
				
			||||||
@ -0,0 +1,32 @@ | 
				
			|||||||
 | 
					# | 
				
			||||||
 | 
					# Generated file, do not edit. | 
				
			||||||
 | 
					# | 
				
			||||||
 | 
					set(ROOT_PROJECT_BINARY_DIR "${PROJECT_BINARY_DIR}") | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function(add_library TARGET) | 
				
			||||||
 | 
					    _add_library(${TARGET} ${ARGN}) | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if(NOT "${TARGET}" MATCHES "^PkgConfig::.*") | 
				
			||||||
 | 
					      add_custom_command(TARGET ${TARGET} POST_BUILD | 
				
			||||||
 | 
					                        COMMAND ${CMAKE_COMMAND} -E copy | 
				
			||||||
 | 
					                        "$<TARGET_FILE:${TARGET}>" | 
				
			||||||
 | 
					                        "${ROOT_PROJECT_BINARY_DIR}/bundle/lib/$<TARGET_FILE_NAME:${TARGET}>") | 
				
			||||||
 | 
					    endif(NOT "${TARGET}" MATCHES "^PkgConfig::.*") | 
				
			||||||
 | 
					endfunction() | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					list(APPEND FLUTTER_PLATFORM_PLUGIN_LIST | 
				
			||||||
 | 
					    path_provider_aurora | 
				
			||||||
 | 
					) | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					list(APPEND FLUTTER_FFI_PLUGIN_LIST | 
				
			||||||
 | 
					    xdga_directories | 
				
			||||||
 | 
					) | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					foreach(PLUGIN ${FLUTTER_PLATFORM_PLUGIN_LIST}) | 
				
			||||||
 | 
					    add_subdirectory(flutter/ephemeral/.plugin_symlinks/${PLUGIN}/aurora plugins/${PLUGIN}) | 
				
			||||||
 | 
					    target_link_libraries(${BINARY_NAME} PRIVATE ${PLUGIN}_platform_plugin) | 
				
			||||||
 | 
					endforeach(PLUGIN) | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					foreach(FFI_PLUGIN ${FLUTTER_FFI_PLUGIN_LIST}) | 
				
			||||||
 | 
					    add_subdirectory(flutter/ephemeral/.plugin_symlinks/${FFI_PLUGIN}/aurora plugins/${FFI_PLUGIN}) | 
				
			||||||
 | 
					endforeach(FFI_PLUGIN) | 
				
			||||||
| 
		 After Width: | Height: | Size: 9.7 KiB  | 
| 
		 After Width: | Height: | Size: 13 KiB  | 
| 
		 After Width: | Height: | Size: 23 KiB  | 
| 
		 After Width: | Height: | Size: 6.5 KiB  | 
@ -0,0 +1,10 @@ | 
				
			|||||||
 | 
					#include <flutter/application.h> | 
				
			||||||
 | 
					#include "generated_plugin_registrant.h" | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int main(int argc, char *argv[]) { | 
				
			||||||
 | 
					    Application::Initialize(argc, argv); | 
				
			||||||
 | 
					    Application::SetPixelRatio(1.8); | 
				
			||||||
 | 
					    RegisterPlugins(); | 
				
			||||||
 | 
					    Application::Launch(); | 
				
			||||||
 | 
					    return 0; | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,31 @@ | 
				
			|||||||
 | 
					%global __provides_exclude_from ^%{_datadir}/%{name}/lib/.*$ | 
				
			||||||
 | 
					%global __requires_exclude ^lib(dconf|flutter-embedder|maliit-glib|appmanifest-.+|.+_platform_plugin)\\.so.*$ | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Name: com.example.flutter_secure_storage_aurora_example | 
				
			||||||
 | 
					Summary: Demonstrates how to use the flutter_secure_storage_aurora plugin. | 
				
			||||||
 | 
					Version: 0.1.0 | 
				
			||||||
 | 
					Release: 1 | 
				
			||||||
 | 
					License: Proprietary | 
				
			||||||
 | 
					Source0: %{name}-%{version}.tar.zst | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					BuildRequires: cmake | 
				
			||||||
 | 
					BuildRequires: pkgconfig(flutter-embedder) | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					%description | 
				
			||||||
 | 
					%{summary}. | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					%prep | 
				
			||||||
 | 
					%autosetup | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					%build | 
				
			||||||
 | 
					%cmake -DCMAKE_BUILD_TYPE=%{_flutter_build_type} | 
				
			||||||
 | 
					%make_build | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					%install | 
				
			||||||
 | 
					%make_install | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					%files | 
				
			||||||
 | 
					%{_bindir}/%{name} | 
				
			||||||
 | 
					%{_datadir}/%{name}/* | 
				
			||||||
 | 
					%{_datadir}/applications/%{name}.desktop | 
				
			||||||
 | 
					%{_datadir}/icons/hicolor/*/apps/%{name}.png | 
				
			||||||
@ -0,0 +1,152 @@ | 
				
			|||||||
 | 
					import 'package:flutter/material.dart'; | 
				
			||||||
 | 
					import 'dart:async'; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import 'package:flutter_secure_storage/flutter_secure_storage.dart'; | 
				
			||||||
 | 
					import 'package:flutter_secure_storage_aurora/flutter_secure_storage_aurora.dart'; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void main() { | 
				
			||||||
 | 
					  runApp(const MyApp()); | 
				
			||||||
 | 
					} | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class MyApp extends StatefulWidget { | 
				
			||||||
 | 
					  const MyApp({super.key}); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @override | 
				
			||||||
 | 
					  State<MyApp> createState() => _MyAppState(); | 
				
			||||||
 | 
					} | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class _MyAppState extends State<MyApp> { | 
				
			||||||
 | 
					  final _flutterSecureStorage = const FlutterSecureStorage(); | 
				
			||||||
 | 
					  String? _error; | 
				
			||||||
 | 
					  String? _data; | 
				
			||||||
 | 
					  String? _all; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @override | 
				
			||||||
 | 
					  void initState() { | 
				
			||||||
 | 
					    super.initState(); | 
				
			||||||
 | 
					    initPlatformState(); | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Future<void> initPlatformState() async { | 
				
			||||||
 | 
					    try { | 
				
			||||||
 | 
					      // https://pub.dev/packages/encrypt | 
				
			||||||
 | 
					      // Encrypter(AES(key)) | 
				
			||||||
 | 
					      // secure-random --length 16 --base 16 | 
				
			||||||
 | 
					      FlutterSecureStorageAurora.setSecret('5872747ed1ceda363808efb8b2b18b20'); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      const key = 'my_key'; | 
				
			||||||
 | 
					      const data = 'Something secret'; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      // Write value | 
				
			||||||
 | 
					      await _flutterSecureStorage.write(key: key, value: data); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      // Read value | 
				
			||||||
 | 
					      String? value = await _flutterSecureStorage.read(key: key); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      // Read all values | 
				
			||||||
 | 
					      Map<String, String> allValues = await _flutterSecureStorage.readAll(); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      setState(() { | 
				
			||||||
 | 
					        _data = value; | 
				
			||||||
 | 
					        _all = allValues.toString(); | 
				
			||||||
 | 
					      }); | 
				
			||||||
 | 
					    } on Exception catch (e) { | 
				
			||||||
 | 
					      setState(() { | 
				
			||||||
 | 
					        _error = e.toString(); | 
				
			||||||
 | 
					      }); | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @override | 
				
			||||||
 | 
					  Widget build(BuildContext context) { | 
				
			||||||
 | 
					    const textStyleWhite = TextStyle(fontSize: 18, color: Colors.white); | 
				
			||||||
 | 
					    const textStyleTitle = TextStyle(fontSize: 20, color: Colors.black); | 
				
			||||||
 | 
					    const textStylePath = TextStyle(fontSize: 18, color: Colors.black54); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const spaceMedium = SizedBox(height: 20); | 
				
			||||||
 | 
					    const spaceSmall = SizedBox(height: 10); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return MaterialApp( | 
				
			||||||
 | 
					      home: Scaffold( | 
				
			||||||
 | 
					        appBar: AppBar( | 
				
			||||||
 | 
					          title: const Text('Example flutter_secure_storage'), | 
				
			||||||
 | 
					        ), | 
				
			||||||
 | 
					        body: Stack( | 
				
			||||||
 | 
					          children: [ | 
				
			||||||
 | 
					            // Error message | 
				
			||||||
 | 
					            Visibility( | 
				
			||||||
 | 
					              visible: _error != null, | 
				
			||||||
 | 
					              child: Center( | 
				
			||||||
 | 
					                child: Padding( | 
				
			||||||
 | 
					                  padding: const EdgeInsets.all(16), | 
				
			||||||
 | 
					                  child: Container( | 
				
			||||||
 | 
					                    padding: const EdgeInsets.all(20), | 
				
			||||||
 | 
					                    decoration: const BoxDecoration( | 
				
			||||||
 | 
					                      color: Colors.redAccent, | 
				
			||||||
 | 
					                      borderRadius: BorderRadius.all(Radius.circular(10.0)), | 
				
			||||||
 | 
					                    ), | 
				
			||||||
 | 
					                    child: Text( | 
				
			||||||
 | 
					                      _error ?? '', | 
				
			||||||
 | 
					                      style: textStyleWhite, | 
				
			||||||
 | 
					                    ), | 
				
			||||||
 | 
					                  ), | 
				
			||||||
 | 
					                ), | 
				
			||||||
 | 
					              ), | 
				
			||||||
 | 
					            ), | 
				
			||||||
 | 
					            // List directories path | 
				
			||||||
 | 
					            Visibility( | 
				
			||||||
 | 
					              visible: _error == null, | 
				
			||||||
 | 
					              child: SingleChildScrollView( | 
				
			||||||
 | 
					                child: Padding( | 
				
			||||||
 | 
					                  padding: const EdgeInsets.all(16), | 
				
			||||||
 | 
					                  child: Center( | 
				
			||||||
 | 
					                    child: Column( | 
				
			||||||
 | 
					                      children: [ | 
				
			||||||
 | 
					                        // Info | 
				
			||||||
 | 
					                        Container( | 
				
			||||||
 | 
					                          padding: const EdgeInsets.all(20), | 
				
			||||||
 | 
					                          decoration: const BoxDecoration( | 
				
			||||||
 | 
					                            color: Colors.green, | 
				
			||||||
 | 
					                            borderRadius: | 
				
			||||||
 | 
					                                BorderRadius.all(Radius.circular(10.0)), | 
				
			||||||
 | 
					                          ), | 
				
			||||||
 | 
					                          child: const Text( | 
				
			||||||
 | 
					                            'Demo application demonstration implementation of flutter_secure_storage', | 
				
			||||||
 | 
					                            style: textStyleWhite, | 
				
			||||||
 | 
					                            textAlign: TextAlign.center, | 
				
			||||||
 | 
					                          ), | 
				
			||||||
 | 
					                        ), | 
				
			||||||
 | 
					                        const SizedBox(height: 30), | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        const Text( | 
				
			||||||
 | 
					                          'After write/read secret data', | 
				
			||||||
 | 
					                          style: textStyleTitle, | 
				
			||||||
 | 
					                        ), | 
				
			||||||
 | 
					                        spaceSmall, | 
				
			||||||
 | 
					                        Text( | 
				
			||||||
 | 
					                          _data.toString(), | 
				
			||||||
 | 
					                          style: textStylePath, | 
				
			||||||
 | 
					                        ), | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        spaceMedium, | 
				
			||||||
 | 
					                        const Text( | 
				
			||||||
 | 
					                          'All data', | 
				
			||||||
 | 
					                          style: textStyleTitle, | 
				
			||||||
 | 
					                        ), | 
				
			||||||
 | 
					                        spaceSmall, | 
				
			||||||
 | 
					                        Text( | 
				
			||||||
 | 
					                          _all.toString(), | 
				
			||||||
 | 
					                          style: textStylePath, | 
				
			||||||
 | 
					                        ), | 
				
			||||||
 | 
					                      ], | 
				
			||||||
 | 
					                    ), | 
				
			||||||
 | 
					                  ), | 
				
			||||||
 | 
					                ), | 
				
			||||||
 | 
					              ), | 
				
			||||||
 | 
					            ), | 
				
			||||||
 | 
					          ], | 
				
			||||||
 | 
					        ), | 
				
			||||||
 | 
					      ), | 
				
			||||||
 | 
					    ); | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,23 @@ | 
				
			|||||||
 | 
					name: flutter_secure_storage_aurora_example | 
				
			||||||
 | 
					description: Demonstrates how to use the flutter_secure_storage_aurora plugin. | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					publish_to: 'none' | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					environment: | 
				
			||||||
 | 
					  sdk: '>=2.18.6 <3.0.0' | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					dependencies: | 
				
			||||||
 | 
					  flutter: | 
				
			||||||
 | 
					    sdk: flutter | 
				
			||||||
 | 
					  flutter_secure_storage: ^8.0.0 | 
				
			||||||
 | 
					  flutter_secure_storage_aurora: | 
				
			||||||
 | 
					    path: ../ | 
				
			||||||
 | 
					  cupertino_icons: ^1.0.2 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					dev_dependencies: | 
				
			||||||
 | 
					  flutter_test: | 
				
			||||||
 | 
					    sdk: flutter | 
				
			||||||
 | 
					  flutter_lints: ^2.0.0 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					flutter: | 
				
			||||||
 | 
					  uses-material-design: true | 
				
			||||||
@ -0,0 +1,75 @@ | 
				
			|||||||
 | 
					import 'package:flutter_secure_storage_platform_interface/flutter_secure_storage_platform_interface.dart'; | 
				
			||||||
 | 
					import 'package:flutter/foundation.dart'; | 
				
			||||||
 | 
					import 'package:path_provider_aurora/path_provider_aurora.dart'; | 
				
			||||||
 | 
					import 'null_secret_exception.dart'; | 
				
			||||||
 | 
					import 'flutter_secure_storage_aurora_api.dart'; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class FlutterSecureStorageAurora extends FlutterSecureStoragePlatform { | 
				
			||||||
 | 
					  static FlutterSecureStorageAuroraApi? _api; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /// Before use, you need to specify the encryption key | 
				
			||||||
 | 
					  /// https://pub.dev/packages/encrypt | 
				
			||||||
 | 
					  /// Encrypter(AES(key)) | 
				
			||||||
 | 
					  /// secure-random --length 16 --base 16 | 
				
			||||||
 | 
					  static void setSecret(String secret) { | 
				
			||||||
 | 
					    _api = FlutterSecureStorageAuroraApi( | 
				
			||||||
 | 
					      secret, | 
				
			||||||
 | 
					      '.flutter_secure_storage.json', | 
				
			||||||
 | 
					    ); | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  static void registerWith() async { | 
				
			||||||
 | 
					    if (TargetPlatform.aurora == defaultTargetPlatform) { | 
				
			||||||
 | 
					      PathProviderAurora.registerWith(); | 
				
			||||||
 | 
					      FlutterSecureStoragePlatform.instance = FlutterSecureStorageAurora(); | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  static FlutterSecureStorageAuroraApi _getAPI() { | 
				
			||||||
 | 
					    if (_api == null) { | 
				
			||||||
 | 
					      throw NullSecretException(); | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					    return _api!; | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @override | 
				
			||||||
 | 
					  Future<bool> containsKey({ | 
				
			||||||
 | 
					    required String key, | 
				
			||||||
 | 
					    required Map<String, String> options, | 
				
			||||||
 | 
					  }) async => | 
				
			||||||
 | 
					      _getAPI().containsKey(key); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @override | 
				
			||||||
 | 
					  Future<void> delete({ | 
				
			||||||
 | 
					    required String key, | 
				
			||||||
 | 
					    required Map<String, String> options, | 
				
			||||||
 | 
					  }) async => | 
				
			||||||
 | 
					      _getAPI().remove(key); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @override | 
				
			||||||
 | 
					  Future<void> deleteAll({ | 
				
			||||||
 | 
					    required Map<String, String> options, | 
				
			||||||
 | 
					  }) async => | 
				
			||||||
 | 
					      _getAPI().clear(); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @override | 
				
			||||||
 | 
					  Future<String?> read({ | 
				
			||||||
 | 
					    required String key, | 
				
			||||||
 | 
					    required Map<String, String> options, | 
				
			||||||
 | 
					  }) async => | 
				
			||||||
 | 
					      await _getAPI().getData(key); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @override | 
				
			||||||
 | 
					  Future<Map<String, String>> readAll({ | 
				
			||||||
 | 
					    required Map<String, String> options, | 
				
			||||||
 | 
					  }) async => | 
				
			||||||
 | 
					      (await _getAPI().getAll()).cast(); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @override | 
				
			||||||
 | 
					  Future<void> write({ | 
				
			||||||
 | 
					    required String key, | 
				
			||||||
 | 
					    required String value, | 
				
			||||||
 | 
					    required Map<String, String> options, | 
				
			||||||
 | 
					  }) async => | 
				
			||||||
 | 
					      _getAPI().setData(key, value); | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,99 @@ | 
				
			|||||||
 | 
					import 'dart:convert'; | 
				
			||||||
 | 
					import 'dart:io'; | 
				
			||||||
 | 
					import 'package:path/path.dart' as p; | 
				
			||||||
 | 
					import 'package:path_provider/path_provider.dart'; | 
				
			||||||
 | 
					import 'package:encrypt/encrypt.dart' as encrypt; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class FlutterSecureStorageAuroraApi { | 
				
			||||||
 | 
					  final JsonDecoder decoder = const JsonDecoder(); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  final String _secret; | 
				
			||||||
 | 
					  final String _fileName; | 
				
			||||||
 | 
					  Map<String, dynamic>? _data; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  FlutterSecureStorageAuroraApi(this._secret, this._fileName); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /// Get value | 
				
			||||||
 | 
					  Future<dynamic> getData(String key) async { | 
				
			||||||
 | 
					    final map = await _read(); | 
				
			||||||
 | 
					    return map[key]; | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /// Get all data | 
				
			||||||
 | 
					  Future<Map<String, dynamic>> getAll() async { | 
				
			||||||
 | 
					    return await _read(); | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /// Check has value | 
				
			||||||
 | 
					  Future<bool> containsKey(String key) async { | 
				
			||||||
 | 
					    final map = await _read(); | 
				
			||||||
 | 
					    return map.containsKey(key); | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /// Add value and save data | 
				
			||||||
 | 
					  Future<bool> setData(String key, dynamic value) async { | 
				
			||||||
 | 
					    final map = await _read(); | 
				
			||||||
 | 
					    map[key] = value; | 
				
			||||||
 | 
					    await _save(map); | 
				
			||||||
 | 
					    return true; | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /// Remove one value | 
				
			||||||
 | 
					  Future<bool> remove(String key) async { | 
				
			||||||
 | 
					    final map = await _read(); | 
				
			||||||
 | 
					    if (map.containsKey(key)) { | 
				
			||||||
 | 
					      map.remove(key); | 
				
			||||||
 | 
					      await _save(map); | 
				
			||||||
 | 
					      return true; | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					    return false; | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /// Clear all data - remove file | 
				
			||||||
 | 
					  Future<bool> clear() async { | 
				
			||||||
 | 
					    final file = await _getFile(); | 
				
			||||||
 | 
					    await file.delete(); | 
				
			||||||
 | 
					    _data = null; | 
				
			||||||
 | 
					    return true; | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /// Get file with data | 
				
			||||||
 | 
					  Future<File> _getFile() async { | 
				
			||||||
 | 
					    return File(p.join( | 
				
			||||||
 | 
					      (await getTemporaryDirectory()).path, | 
				
			||||||
 | 
					      _fileName, | 
				
			||||||
 | 
					    )).create(recursive: true); | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /// Read file or get from cache | 
				
			||||||
 | 
					  Future<Map<String, dynamic>> _read() async { | 
				
			||||||
 | 
					    if (_data == null) { | 
				
			||||||
 | 
					      final file = await _getFile(); | 
				
			||||||
 | 
					      final read = await file.readAsString(); | 
				
			||||||
 | 
					      final value = read.isEmpty ? '' : _decrypt(read); | 
				
			||||||
 | 
					      _data = value.isEmpty ? {} : decoder.convert(value); | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					    return Future.value(_data); | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /// Save data to file | 
				
			||||||
 | 
					  Future<void> _save(Map<String, dynamic> data) async { | 
				
			||||||
 | 
					    final file = await _getFile(); | 
				
			||||||
 | 
					    final value = json.encode(data); | 
				
			||||||
 | 
					    await file.writeAsString(_encrypt(value)); | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /// Encrypt data in file | 
				
			||||||
 | 
					  String _encrypt(String value) { | 
				
			||||||
 | 
					    final key = encrypt.Key.fromUtf8(_secret); | 
				
			||||||
 | 
					    final iv = encrypt.IV.fromLength(16); | 
				
			||||||
 | 
					    return encrypt.Encrypter(encrypt.AES(key)).encrypt(value, iv: iv).base64; | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /// Decrypt data in file | 
				
			||||||
 | 
					  String _decrypt(String value) { | 
				
			||||||
 | 
					    final key = encrypt.Key.fromUtf8(_secret); | 
				
			||||||
 | 
					    final iv = encrypt.IV.fromLength(16); | 
				
			||||||
 | 
					    return encrypt.Encrypter(encrypt.AES(key)).decrypt64(value, iv: iv); | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,6 @@ | 
				
			|||||||
 | 
					class NullSecretException implements Exception { | 
				
			||||||
 | 
					  @override | 
				
			||||||
 | 
					  String toString() { | 
				
			||||||
 | 
					    return 'NullSecretException: Oops! Before use, you need to specify the encryption key'; | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,30 @@ | 
				
			|||||||
 | 
					name: flutter_secure_storage_aurora | 
				
			||||||
 | 
					description: The Aurora OS implementation of flutter_secure_storage. | 
				
			||||||
 | 
					version: 0.0.1 | 
				
			||||||
 | 
					homepage: | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					environment: | 
				
			||||||
 | 
					  sdk: '>=2.18.6 <3.0.0' | 
				
			||||||
 | 
					  flutter: ">=2.5.0" | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					dependencies: | 
				
			||||||
 | 
					  flutter: | 
				
			||||||
 | 
					    sdk: flutter | 
				
			||||||
 | 
					  encrypt: ^5.0.1 | 
				
			||||||
 | 
					  plugin_platform_interface: ^2.0.2 | 
				
			||||||
 | 
					  flutter_secure_storage_platform_interface: ^1.0.1 | 
				
			||||||
 | 
					  path: ^1.8.2 | 
				
			||||||
 | 
					  path_provider: ^2.0.14 | 
				
			||||||
 | 
					  path_provider_aurora: | 
				
			||||||
 | 
					    path: ../../path_provider/path_provider_aurora | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					dev_dependencies: | 
				
			||||||
 | 
					  flutter_test: | 
				
			||||||
 | 
					    sdk: flutter | 
				
			||||||
 | 
					  flutter_lints: ^2.0.0 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					flutter: | 
				
			||||||
 | 
					  plugin: | 
				
			||||||
 | 
					    platforms: | 
				
			||||||
 | 
					      aurora: | 
				
			||||||
 | 
					        dartPluginClass: FlutterSecureStorageAurora | 
				
			||||||
					Loading…
					
					
				
		Reference in new issue