Skip to content

Commit

Permalink
Throw PlatformException code and message for iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
“prongbang” committed Jan 3, 2023
1 parent 295ceeb commit 43609e1
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.3

* Throw PlatformException code and message for iOS

## 1.0.2

* Config min dart sdk to 2.12.0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Generate key pair and signing (NIST P-256 EC key pair using ECDSA) using Local A
It is really easy to use! You should ensure that you add the `local_auth_signature` as a dependency in your flutter project.

```yaml
local_auth_signature: "^1.0.2"
local_auth_signature: "^1.0.3"
```
## Usage
Expand Down
8 changes: 4 additions & 4 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ PODS:
- Flutter (1.0.0)
- local_auth_signature (1.0.0):
- Flutter
- SignatureBiometricSwift (~> 1.0.5)
- SignatureBiometricSwift (1.0.5)
- SignatureBiometricSwift (~> 1.0.6)
- SignatureBiometricSwift (1.0.6)

DEPENDENCIES:
- Flutter (from `Flutter`)
Expand All @@ -21,8 +21,8 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
local_auth_signature: a1c61420f1f67f11071b8bc19ccf3666672e4283
SignatureBiometricSwift: 954d1d2625c4ce7f69a8d6792a0a82e7017faf64
local_auth_signature: 733566170b5fee75709761f770801671c91daf9f
SignatureBiometricSwift: 7447bcee210b0ace2d28ea9e564638ebe6de6bd6

PODFILE CHECKSUM: 7368163408c647b7eb699d0d788ba6718e18fb8d

Expand Down
40 changes: 35 additions & 5 deletions ios/Classes/SwiftLocalAuthSignaturePlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class SwiftLocalAuthSignaturePlugin: NSObject, FlutterPlugin {
let keyConfig = KeyConfig(name: key)
let signatureBiometricManager = LocalSignatureBiometricManager.newInstance(keyConfig: keyConfig)
signatureBiometricManager.createKeyPair(reason: reason) { value in
if value.status == "success" {
if value.status == SignatureBiometricStatus.success {
result(value.publicKey)
} else {
result(
Expand Down Expand Up @@ -79,11 +79,31 @@ public class SwiftLocalAuthSignaturePlugin: NSObject, FlutterPlugin {

let keyConfig = KeyConfig(name: key)
let signatureBiometricManager = LocalSignatureBiometricManager.newInstance(keyConfig: keyConfig)
signatureBiometricManager.sign(payload: payload) { signature in
result(signature)
signatureBiometricManager.sign(payload: payload) { value in
if value.status == SignatureBiometricStatus.success {
result(value.signature)
} else {
result(
FlutterError(
code: value.status,
message: "Error is \(value.status)",
details: nil
)
)
}
}
break
case SwiftLocalAuthSignatureMethod.Verify:
guard let reason = args[SwiftLocalAuthSignatureArgs.Reason] else {
result(
FlutterError(
code: SwiftLocalAuthSignatureError.ReasonIsNull,
message: "Reason is null",
details: nil
)
)
return
}
guard let payload = args[SwiftLocalAuthSignatureArgs.Payload] else {
result(
FlutterError(
Expand All @@ -107,8 +127,18 @@ public class SwiftLocalAuthSignaturePlugin: NSObject, FlutterPlugin {

let keyConfig = KeyConfig(name: key)
let signatureBiometricManager = LocalSignatureBiometricManager.newInstance(keyConfig: keyConfig)
signatureBiometricManager.verify(payload: payload, signature: signature) { verified in
result(verified)
signatureBiometricManager.verify(reason: reason, payload: payload, signature: signature) { value in
if value.status == SignatureBiometricStatus.success {
result(value.verified)
} else {
result(
FlutterError(
code: value.status,
message: "Error is \(value.status)",
details: nil
)
)
}
}
break
default:
Expand Down
2 changes: 1 addition & 1 deletion ios/local_auth_signature.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Generate key pair and signing using Local Authentication for Android and iOS.
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.dependency 'Flutter'
s.dependency 'SignatureBiometricSwift', '~> 1.0.5'
s.dependency 'SignatureBiometricSwift', '~> 1.0.6'
s.platform = :ios, '11.0'
s.swift_version = ["4.0", "4.1", "4.2", "5.0", "5.1", "5.2", "5.3", "5.4", "5.5"]
end
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: local_auth_signature
description: Generate key pair and signing (NIST P-256 EC key pair using ECDSA) using Local Authentication for Android and iOS.
version: 1.0.2
version: 1.0.3
homepage: https://github.com/prongbang/local_auth_signature

environment:
Expand Down

0 comments on commit 43609e1

Please sign in to comment.