Skip to content

Commit 43609e1

Browse files
author
“prongbang”
committed
Throw PlatformException code and message for iOS
1 parent 295ceeb commit 43609e1

6 files changed

Lines changed: 46 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.0.3
2+
3+
* Throw PlatformException code and message for iOS
4+
15
## 1.0.2
26

37
* Config min dart sdk to 2.12.0

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Generate key pair and signing (NIST P-256 EC key pair using ECDSA) using Local A
1111
It is really easy to use! You should ensure that you add the `local_auth_signature` as a dependency in your flutter project.
1212

1313
```yaml
14-
local_auth_signature: "^1.0.2"
14+
local_auth_signature: "^1.0.3"
1515
```
1616
1717
## Usage

example/ios/Podfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ PODS:
22
- Flutter (1.0.0)
33
- local_auth_signature (1.0.0):
44
- Flutter
5-
- SignatureBiometricSwift (~> 1.0.5)
6-
- SignatureBiometricSwift (1.0.5)
5+
- SignatureBiometricSwift (~> 1.0.6)
6+
- SignatureBiometricSwift (1.0.6)
77

88
DEPENDENCIES:
99
- Flutter (from `Flutter`)
@@ -21,8 +21,8 @@ EXTERNAL SOURCES:
2121

2222
SPEC CHECKSUMS:
2323
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
24-
local_auth_signature: a1c61420f1f67f11071b8bc19ccf3666672e4283
25-
SignatureBiometricSwift: 954d1d2625c4ce7f69a8d6792a0a82e7017faf64
24+
local_auth_signature: 733566170b5fee75709761f770801671c91daf9f
25+
SignatureBiometricSwift: 7447bcee210b0ace2d28ea9e564638ebe6de6bd6
2626

2727
PODFILE CHECKSUM: 7368163408c647b7eb699d0d788ba6718e18fb8d
2828

ios/Classes/SwiftLocalAuthSignaturePlugin.swift

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class SwiftLocalAuthSignaturePlugin: NSObject, FlutterPlugin {
5151
let keyConfig = KeyConfig(name: key)
5252
let signatureBiometricManager = LocalSignatureBiometricManager.newInstance(keyConfig: keyConfig)
5353
signatureBiometricManager.createKeyPair(reason: reason) { value in
54-
if value.status == "success" {
54+
if value.status == SignatureBiometricStatus.success {
5555
result(value.publicKey)
5656
} else {
5757
result(
@@ -79,11 +79,31 @@ public class SwiftLocalAuthSignaturePlugin: NSObject, FlutterPlugin {
7979

8080
let keyConfig = KeyConfig(name: key)
8181
let signatureBiometricManager = LocalSignatureBiometricManager.newInstance(keyConfig: keyConfig)
82-
signatureBiometricManager.sign(payload: payload) { signature in
83-
result(signature)
82+
signatureBiometricManager.sign(payload: payload) { value in
83+
if value.status == SignatureBiometricStatus.success {
84+
result(value.signature)
85+
} else {
86+
result(
87+
FlutterError(
88+
code: value.status,
89+
message: "Error is \(value.status)",
90+
details: nil
91+
)
92+
)
93+
}
8494
}
8595
break
8696
case SwiftLocalAuthSignatureMethod.Verify:
97+
guard let reason = args[SwiftLocalAuthSignatureArgs.Reason] else {
98+
result(
99+
FlutterError(
100+
code: SwiftLocalAuthSignatureError.ReasonIsNull,
101+
message: "Reason is null",
102+
details: nil
103+
)
104+
)
105+
return
106+
}
87107
guard let payload = args[SwiftLocalAuthSignatureArgs.Payload] else {
88108
result(
89109
FlutterError(
@@ -107,8 +127,18 @@ public class SwiftLocalAuthSignaturePlugin: NSObject, FlutterPlugin {
107127

108128
let keyConfig = KeyConfig(name: key)
109129
let signatureBiometricManager = LocalSignatureBiometricManager.newInstance(keyConfig: keyConfig)
110-
signatureBiometricManager.verify(payload: payload, signature: signature) { verified in
111-
result(verified)
130+
signatureBiometricManager.verify(reason: reason, payload: payload, signature: signature) { value in
131+
if value.status == SignatureBiometricStatus.success {
132+
result(value.verified)
133+
} else {
134+
result(
135+
FlutterError(
136+
code: value.status,
137+
message: "Error is \(value.status)",
138+
details: nil
139+
)
140+
)
141+
}
112142
}
113143
break
114144
default:

ios/local_auth_signature.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Generate key pair and signing using Local Authentication for Android and iOS.
1616
s.source = { :path => '.' }
1717
s.source_files = 'Classes/**/*'
1818
s.dependency 'Flutter'
19-
s.dependency 'SignatureBiometricSwift', '~> 1.0.5'
19+
s.dependency 'SignatureBiometricSwift', '~> 1.0.6'
2020
s.platform = :ios, '11.0'
2121
s.swift_version = ["4.0", "4.1", "4.2", "5.0", "5.1", "5.2", "5.3", "5.4", "5.5"]
2222
end

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: local_auth_signature
22
description: Generate key pair and signing (NIST P-256 EC key pair using ECDSA) using Local Authentication for Android and iOS.
3-
version: 1.0.2
3+
version: 1.0.3
44
homepage: https://github.com/prongbang/local_auth_signature
55

66
environment:

0 commit comments

Comments
 (0)