diff --git a/Package.swift b/Package.swift index 884f257..566dbe4 100644 --- a/Package.swift +++ b/Package.swift @@ -6,7 +6,7 @@ import PackageDescription let package = Package( name: "MagicExtensions", platforms: [ - .iOS(.v10), + .iOS(.v13), .macOS(.v10_12) ], products: [ @@ -17,6 +17,9 @@ let package = Package( .library( name: "MagicExt-OIDC", targets: ["MagicExt-OIDC"]), + .library( + name: "MagicExt-GDKMS", + targets: ["MagicExt-GDKMS"]), ], dependencies: [ .package(url: "https://github.com/magiclabs/magic-ios.git", from:"4.0.0"), @@ -34,11 +37,16 @@ let package = Package( dependencies: [ .product(name: "MagicSDK", package: "magic-ios"), ]), + .target( + name: "MagicExt-GDKMS", + dependencies: [ + .product(name: "MagicSDK", package: "magic-ios"), + ]), .testTarget( name: "MagicExt-OAuthTests", dependencies: ["MagicExt-OAuth"]), .testTarget( name: "MagicExt-OIDCTests", - dependencies: ["MagicExt-OIDC"]), + dependencies: ["MagicExt-OIDC"]) ] ) diff --git a/Sources/MagicExt-GDKMS/Core/GDKMSExtension.swift b/Sources/MagicExt-GDKMS/Core/GDKMSExtension.swift new file mode 100644 index 0000000..ecd6108 --- /dev/null +++ b/Sources/MagicExt-GDKMS/Core/GDKMSExtension.swift @@ -0,0 +1,31 @@ +// +// OIDCExtension.swift +// MagicSDK +// +// Created by Jerry Liu on 10/16/22. +// + +import Foundation +import MagicSDK_Web3 +import MagicSDK + +public class GDKMSExtension: BaseModule { + + public func encryptWithPrivateKey (_ message:String, response: @escaping Web3ResponseCompletion ) { + let request = RPCRequest<[String]>(method: GDKMSMethod.magic_auth_encrypt_v1.rawValue, params: [message]) + self.provider.send(request: request, response: response) + } + + public func decryptWithPrivateKey (_ cipherText: String, response: @escaping Web3ResponseCompletion ) { + let request = RPCRequest<[String]>(method: GDKMSMethod.magic_auth_decrypt_v1.rawValue, params: [cipherText]) + self.provider.send(request: request, response: response) + } +} + +extension Magic { + + public var gdkms: GDKMSExtension { + print("\(self.MA_EXTENSION_ONLY_MSG)") + return GDKMSExtension(rpcProvider: self.rpcProvider) + } +} diff --git a/Sources/MagicExt-GDKMS/Types/GDKMSMEthod.swift b/Sources/MagicExt-GDKMS/Types/GDKMSMEthod.swift new file mode 100644 index 0000000..916f27a --- /dev/null +++ b/Sources/MagicExt-GDKMS/Types/GDKMSMEthod.swift @@ -0,0 +1,12 @@ +// +// OIDCMethod.swift +// +// +// Created by Jerry Liu on 05/24/23. +// + +import Foundation +internal enum GDKMSMethod: String, CaseIterable { + case magic_auth_encrypt_v1 + case magic_auth_decrypt_v1 +}