Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 0 additions & 80 deletions .github/workflows/dart.yml

This file was deleted.

1 change: 0 additions & 1 deletion ios/Classes/BiometricStorageImpl.swift

This file was deleted.

4 changes: 0 additions & 4 deletions ios/Classes/BiometricStoragePlugin.h

This file was deleted.

8 changes: 0 additions & 8 deletions ios/Classes/BiometricStoragePlugin.m

This file was deleted.

7 changes: 5 additions & 2 deletions ios/biometric_storage.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ A new flutter plugin project.
s.license = { :file => '../LICENSE' }
s.author = { 'Your Company' => 'email@example.com' }
s.source = { :path => '.' }
s.source_files = 'Classes/**/*' #, '../macos/Classes/BiometricStorageImpl.swift'
s.public_header_files = 'Classes/**/*.h'
# Sources live under the SwiftPM layout (Sources/<name>/) so SPM and CocoaPods
# share one source tree; see ios/biometric_storage/Package.swift. The plugin is
# now pure Swift (the ObjC registration shim was folded into the Swift class),
# so there are no public ObjC headers to expose.
s.source_files = 'biometric_storage/Sources/biometric_storage/**/*.swift'
s.dependency 'Flutter'
s.platform = :ios, '9.0'

Expand Down
31 changes: 31 additions & 0 deletions ios/biometric_storage/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// swift-tools-version: 5.9
// The Swift Package Manager manifest for the iOS implementation of the
// `biometric_storage` plugin. Mirrors ios/biometric_storage.podspec so the
// plugin builds under both SPM (this file) and CocoaPods (the podspec), which
// share the same sources under Sources/biometric_storage/. The plugin is pure
// Swift (the former ObjC registration shim was folded into the Swift
// BiometricStoragePlugin class) so it forms a single SPM target.
import PackageDescription

let package = Package(
name: "biometric_storage",
platforms: [
.iOS("13.0")
],
products: [
.library(name: "biometric-storage", targets: ["biometric_storage"])
],
dependencies: [
// Flutter exposes the engine (Flutter) to plugin SPM targets via a generated
// FlutterFramework package resolved at build time.
.package(name: "FlutterFramework", path: "../FlutterFramework")
],
targets: [
.target(
name: "biometric_storage",
dependencies: [
.product(name: "FlutterFramework", package: "FlutterFramework")
]
)
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,13 @@ class BiometricStorageFile {
return;
}
query[kSecMatchLimit as String] = kSecMatchLimitOne
query[kSecUseOperationPrompt as String] = promptInfo.accessTitle
query[kSecReturnAttributes as String] = true
query[kSecReturnData as String] = true
query[kSecUseAuthenticationContext as String] = context
let authenticationContext = context
if let accessTitle = promptInfo.accessTitle {
authenticationContext.localizedReason = accessTitle
}
query[kSecUseAuthenticationContext as String] = authenticationContext

var item: CFTypeRef?

Expand Down Expand Up @@ -303,12 +306,13 @@ class BiometricStorageFile {
}

if (initOptions.authenticationRequired) {
query.merge([
kSecUseAuthenticationContext as String: context,
]) { (_, new) in new }
let authenticationContext = context
if let operationPrompt = promptInfo.saveTitle {
query[kSecUseOperationPrompt as String] = operationPrompt
authenticationContext.localizedReason = operationPrompt
}
query.merge([
kSecUseAuthenticationContext as String: authenticationContext,
]) { (_, new) in new }
} else {
hpdebug("No authentication required for \(name)")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import Flutter
//import UIKit

public class SwiftBiometricStoragePlugin: NSObject, FlutterPlugin {
// The registered pluginClass (pubspec `ios: pluginClass: BiometricStoragePlugin`).
// Previously an ObjC shim forwarded to `SwiftBiometricStoragePlugin`; this is now
// a pure Swift plugin so the iOS implementation builds under Swift Package
// Manager (SPM cannot compile a mixed ObjC+Swift target). `@objc(...)` keeps the
// ObjC runtime name stable for the generated plugin registrant.
@objc(BiometricStoragePlugin)
public class BiometricStoragePlugin: NSObject, FlutterPlugin {
private let impl = BiometricStorageImpl(storageError: { (code, message, details) -> Any in
FlutterError(code: code, message: message, details: details)
}, storageMethodNotImplemented: FlutterMethodNotImplemented)

public static func register(with registrar: FlutterPluginRegistrar) {
let channel = FlutterMethodChannel(name: "biometric_storage", binaryMessenger: registrar.messenger())
let instance = SwiftBiometricStoragePlugin()
let instance = BiometricStoragePlugin()
registrar.addMethodCallDelegate(instance, channel: channel)
}

Expand Down
13 changes: 6 additions & 7 deletions lib/src/biometric_storage_win32.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ class Win32BiometricStoragePlugin extends BiometricStorage {
) async {
final namePointer = TEXT(name);
try {
final result = CredDelete(namePointer, CRED_TYPE.CRED_TYPE_GENERIC, 0);
final result = CredDelete(namePointer, CRED_TYPE_GENERIC, 0);
if (result != TRUE) {
final errorCode = GetLastError();
if (errorCode == WIN32_ERROR.ERROR_NOT_FOUND) {
if (errorCode == ERROR_NOT_FOUND) {
_logger.fine('Unable to find credential of name $name');
} else {
_logger.warning('Error ($result): $errorCode');
Expand All @@ -71,10 +71,9 @@ class Win32BiometricStoragePlugin extends BiometricStorage {
final credPointer = calloc<Pointer<CREDENTIAL>>();
final namePointer = TEXT(name);
try {
if (CredRead(namePointer, CRED_TYPE.CRED_TYPE_GENERIC, 0, credPointer) !=
TRUE) {
if (CredRead(namePointer, CRED_TYPE_GENERIC, 0, credPointer) != TRUE) {
final errorCode = GetLastError();
if (errorCode == WIN32_ERROR.ERROR_NOT_FOUND) {
if (errorCode == ERROR_NOT_FOUND) {
_logger.fine('Unable to find credential of name $name');
} else {
_logger.warning('Error: $errorCode ',
Expand Down Expand Up @@ -111,9 +110,9 @@ class Win32BiometricStoragePlugin extends BiometricStorage {
final userNamePointer = TEXT('flutter.biometric_storage');

final credential = calloc<CREDENTIAL>()
..ref.Type = CRED_TYPE.CRED_TYPE_GENERIC
..ref.Type = CRED_TYPE_GENERIC
..ref.TargetName = namePointer
..ref.Persist = CRED_PERSIST.CRED_PERSIST_LOCAL_MACHINE
..ref.Persist = CRED_PERSIST_LOCAL_MACHINE
..ref.UserName = userNamePointer
..ref.CredentialBlob = blob
..ref.CredentialBlobSize = examplePassword.length;
Expand Down
4 changes: 3 additions & 1 deletion macos/biometric_storage.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ A new flutter plugin project.
s.license = { :file => '../LICENSE' }
s.author = { 'Your Company' => 'email@example.com' }
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
# Sources live under the SwiftPM layout (Sources/<name>/) so SPM and CocoaPods
# share one source tree; see macos/biometric_storage/Package.swift.
s.source_files = 'biometric_storage/Sources/biometric_storage/**/*.swift'
s.dependency 'FlutterMacOS'

s.platform = :osx, '10.11'
Expand Down
29 changes: 29 additions & 0 deletions macos/biometric_storage/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// swift-tools-version: 5.9
// The Swift Package Manager manifest for the macOS implementation of the
// `biometric_storage` plugin. Mirrors macos/biometric_storage.podspec so the
// plugin builds under both SPM (this file) and CocoaPods (the podspec), which
// share the same sources under Sources/biometric_storage/.
import PackageDescription

let package = Package(
name: "biometric_storage",
platforms: [
.macOS("10.14")
],
products: [
.library(name: "biometric-storage", targets: ["biometric_storage"])
],
dependencies: [
// Flutter exposes the engine (FlutterMacOS) to plugin SPM targets via a
// generated FlutterFramework package resolved at build time.
.package(name: "FlutterFramework", path: "../FlutterFramework")
],
targets: [
.target(
name: "biometric_storage",
dependencies: [
.product(name: "FlutterFramework", package: "FlutterFramework")
]
)
]
)
Loading