-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(native_storage): Clearing of secure storage on macOS/iOS (#109)
- The `kSecMatchLimit` flag must always be `kSecMatchLimitAll` to return a list, but this was previously not set in release mode. - Adds tests for all platforms to check that the keys to be cleared only include those owned by native_storage
- Loading branch information
Showing
21 changed files
with
300 additions
and
137 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
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
8 changes: 6 additions & 2 deletions
8
packages/native/storage/example/integration_test/storage_test.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
import 'package:integration_test/integration_test.dart'; | ||
import 'package:native_storage/native_storage.dart'; | ||
import 'package:native_storage/src/local/local_storage_platform.vm.dart' | ||
if (dart.library.js_interop) 'package:native_storage/src/local/local_storage_platform.web.dart'; | ||
import 'package:native_storage/src/secure/secure_storage_platform.vm.dart' | ||
if (dart.library.js_interop) 'package:native_storage/src/secure/secure_storage_platform.web.dart'; | ||
|
||
import 'storage_shared.dart'; | ||
|
||
void main() { | ||
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
sharedTests('NativeMemoryStorage', NativeMemoryStorage.new); | ||
sharedTests('NativeSecureStorage', NativeSecureStorage.new); | ||
sharedTests('NativeLocalStorage', NativeLocalStorage.new); | ||
sharedTests('NativeSecureStorage', NativeSecureStoragePlatform.new); | ||
sharedTests('NativeLocalStorage', NativeLocalStoragePlatform.new); | ||
} |
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
60 changes: 6 additions & 54 deletions
60
packages/native/storage/lib/src/local/local_storage.windows.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,24 @@ | ||
import 'package:native_storage/src/local/local_storage_platform.vm.dart'; | ||
import 'package:native_storage/src/native/windows/windows.dart'; | ||
import 'package:native_storage/src/util/functional.dart'; | ||
import 'package:win32_registry/win32_registry.dart'; | ||
|
||
final class LocalStorageWindows extends NativeLocalStoragePlatform { | ||
final class LocalStorageWindows extends NativeLocalStoragePlatform | ||
with NativeStorageWindows { | ||
LocalStorageWindows({ | ||
String? namespace, | ||
super.scope, | ||
}) : _namespace = namespace, | ||
}) : namespaceOverride = namespace, | ||
super.base(); | ||
|
||
final String? _namespace; | ||
|
||
@override | ||
late final String namespace = lazy(() { | ||
if (_namespace != null) { | ||
return _namespace; | ||
} | ||
if (windows.applicationInfo case (:final companyName, :final productName)) { | ||
return '$companyName\\$productName'; | ||
} | ||
return windows.applicationId; | ||
}); | ||
|
||
late final _registry = lazy(() { | ||
final hkcu = Registry.currentUser; | ||
var key = hkcu | ||
.createKey('SOFTWARE\\Classes\\Local Settings\\Software\\$namespace'); | ||
if (scope case final scope?) { | ||
for (final path in scope.split('/')) { | ||
key = key.createKey(path); | ||
} | ||
} | ||
return key; | ||
}); | ||
|
||
@override | ||
String? delete(String key) { | ||
final current = read(key); | ||
if (current == null) { | ||
return null; | ||
} | ||
_registry.deleteValue(key); | ||
return current; | ||
} | ||
final String? namespaceOverride; | ||
|
||
@override | ||
String? read(String key) => _registry.getValueAsString(key); | ||
String? read(String key) => registry.getValueAsString(key); | ||
|
||
@override | ||
String write(String key, String value) { | ||
_registry.createValue(RegistryValue(key, RegistryValueType.string, value)); | ||
registry.createValue(RegistryValue(key, RegistryValueType.string, value)); | ||
return value; | ||
} | ||
|
||
@override | ||
void clear() { | ||
for (final value in List.of(_registry.values)) { | ||
_registry.deleteValue(value.name); | ||
} | ||
for (final subkey in List.of(_registry.subkeyNames)) { | ||
_registry.deleteKey(subkey, recursive: true); | ||
} | ||
} | ||
|
||
@override | ||
void close() { | ||
_registry.close(); | ||
super.close(); | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
packages/native/storage/lib/src/native/android/jni_bindings.ffi.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.