Skip to content

Commit e167f0a

Browse files
committed
🐛 [iOS] Fix imports
1 parent 3fe88e3 commit e167f0a

2 files changed

Lines changed: 54 additions & 54 deletions

File tree

ios/Classes/SecureP256Plugin.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#import "SecureP256Plugin.h"
2-
#if __has_include(<p256/p256-Swift.h>)
2+
#if __has_include(<secp256r1/secp256r1-Swift.h>)
33
#import <secp256r1/secp256r1-Swift.h>
44
#else
55
// Support project import fallback if the generated compatibility header
@@ -10,6 +10,6 @@
1010

1111
@implementation SecureP256Plugin
1212
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
13-
[SwiftP256Plugin registerWithRegistrar:registrar];
13+
[SwiftSecureP256Plugin registerWithRegistrar:registrar];
1414
}
1515
@end

ios/Classes/SwiftSecureP256Plugin.swift

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -12,57 +12,57 @@ public class SwiftSecureP256Plugin: NSObject, FlutterPlugin {
1212

1313
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
1414
switch call.method {
15-
case "getPublicKey":
16-
do {
17-
let param = call.arguments as? Dictionary<String, Any>
18-
let tag = param!["tag"] as! String
19-
var password : String? = nil
20-
if let pwd = param!["password"] as? String {
21-
password = pwd
22-
}
23-
24-
let key = try getPublicKey(tag: tag, password: password)!
25-
result(FlutterStandardTypedData(bytes: key))
26-
} catch {
27-
result(FlutterError(code: "getPublicKey", message: error.localizedDescription, details: "\(error)"))
28-
}
29-
case "sign" :
30-
do {
31-
let param = call.arguments as? Dictionary<String, Any>
32-
let tag = param!["tag"] as! String
33-
let message = param!["payload"] as! FlutterStandardTypedData
34-
var password : String? = nil
35-
if let pwd = param!["password"] as? String {
36-
password = pwd
37-
}
38-
39-
let signature = try sign(
40-
tag: tag,
41-
password: password,
42-
message: message.data
43-
)!
44-
result(FlutterStandardTypedData(bytes: signature))
45-
} catch {
46-
result(FlutterError(code: "sign", message: error.localizedDescription, details: "\(error)"))
15+
case "getPublicKey":
16+
do {
17+
let param = call.arguments as? Dictionary<String, Any>
18+
let tag = param!["tag"] as! String
19+
var password : String? = nil
20+
if let pwd = param!["password"] as? String {
21+
password = pwd
4722
}
48-
case "verify" :
49-
do {
50-
let param = call.arguments as? Dictionary<String, Any>
51-
let payload = (param!["payload"] as! FlutterStandardTypedData).data
52-
let publicKey = (param!["publicKey"] as! FlutterStandardTypedData).data
53-
let signature = (param!["signature"] as! FlutterStandardTypedData).data
54-
let verified = try verify(
55-
payload: payload,
56-
publicKey: publicKey,
57-
signature: signature
58-
)
59-
60-
result(verified)
61-
} catch {
62-
result(FlutterError(code: "verify", message: error.localizedDescription, details: "\(error)"))
23+
24+
let key = try getPublicKey(tag: tag, password: password)!
25+
result(FlutterStandardTypedData(bytes: key))
26+
} catch {
27+
result(FlutterError(code: "getPublicKey", message: error.localizedDescription, details: "\(error)"))
28+
}
29+
case "sign" :
30+
do {
31+
let param = call.arguments as? Dictionary<String, Any>
32+
let tag = param!["tag"] as! String
33+
let message = param!["payload"] as! FlutterStandardTypedData
34+
var password : String? = nil
35+
if let pwd = param!["password"] as? String {
36+
password = pwd
6337
}
64-
default:
65-
result(FlutterMethodNotImplemented)
38+
39+
let signature = try sign(
40+
tag: tag,
41+
password: password,
42+
message: message.data
43+
)!
44+
result(FlutterStandardTypedData(bytes: signature))
45+
} catch {
46+
result(FlutterError(code: "sign", message: error.localizedDescription, details: "\(error)"))
47+
}
48+
case "verify" :
49+
do {
50+
let param = call.arguments as? Dictionary<String, Any>
51+
let payload = (param!["payload"] as! FlutterStandardTypedData).data
52+
let publicKey = (param!["publicKey"] as! FlutterStandardTypedData).data
53+
let signature = (param!["signature"] as! FlutterStandardTypedData).data
54+
let verified = try verify(
55+
payload: payload,
56+
publicKey: publicKey,
57+
signature: signature
58+
)
59+
60+
result(verified)
61+
} catch {
62+
result(FlutterError(code: "verify", message: error.localizedDescription, details: "\(error)"))
63+
}
64+
default:
65+
result(FlutterMethodNotImplemented)
6666
}
6767
}
6868

@@ -120,8 +120,8 @@ public class SwiftSecureP256Plugin: NSObject, FlutterPlugin {
120120
}
121121

122122
func getPublicKey(tag: String, password: String?) throws -> Data? {
123-
let secKey : SecKey
124-
let publicKey : SecKey
123+
let secKey: SecKey
124+
let publicKey: SecKey
125125

126126
do {
127127
if isKeyCreated(tag: tag, password: password) {
@@ -143,7 +143,7 @@ public class SwiftSecureP256Plugin: NSObject, FlutterPlugin {
143143
}
144144

145145
func sign(tag: String, password: String?, message: Data) throws -> Data? {
146-
let secKey : SecKey
146+
let secKey: SecKey
147147
do {
148148
secKey = try getSecKey(tag: tag, password: password)!
149149
} catch {

0 commit comments

Comments
 (0)