From 219794ef9560115c115bab9f5c44fb196f3ced8f Mon Sep 17 00:00:00 2001 From: ethella Date: Thu, 25 May 2023 09:24:07 -0700 Subject: [PATCH] * Initial submission --- Package.swift | 12 +++++-- .../MagicExt-GDKMS/Core/GDKMSExtension.swift | 31 +++++++++++++++++++ .../MagicExt-GDKMS/Types/GDKMSMEthod.swift | 12 +++++++ 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 Sources/MagicExt-GDKMS/Core/GDKMSExtension.swift create mode 100644 Sources/MagicExt-GDKMS/Types/GDKMSMEthod.swift 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 +}