Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

[do not merge]GDKMS #11

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import PackageDescription
let package = Package(
name: "MagicExtensions",
platforms: [
.iOS(.v10),
.iOS(.v13),
.macOS(.v10_12)
],
products: [
Expand All @@ -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"),
Expand All @@ -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"])
]
)
31 changes: 31 additions & 0 deletions Sources/MagicExt-GDKMS/Core/GDKMSExtension.swift
Original file line number Diff line number Diff line change
@@ -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<String> ) {
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<String> ) {
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)
}
}
12 changes: 12 additions & 0 deletions Sources/MagicExt-GDKMS/Types/GDKMSMEthod.swift
Original file line number Diff line number Diff line change
@@ -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
}