Skip to content

Commit

Permalink
update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
metalurgical committed Nov 21, 2024
1 parent e9dc224 commit 7f8f4b0
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 74 deletions.
63 changes: 18 additions & 45 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/tkey/curvelib.swift",
"state" : {
"revision" : "9f88bd5e56d1df443a908f7a7e81ae4f4d9170ea",
"version" : "1.0.1"
"revision" : "432bf1abe7ff505fc2ac9fcf697341ff5b2dc6d0",
"version" : "2.0.0"
}
},
{
"identity" : "customauth-swift-sdk",
"kind" : "remoteSourceControl",
"location" : "https://github.com/torusresearch/customauth-swift-sdk",
"state" : {
"branch" : "features_update",
"revision" : "72a83f30942b1f87cbed7eac5b1c5a164e91d1d4"
"revision" : "b3d0079bb1683d9daba95c349a072e60c8390328",
"version" : "11.0.1"
}
},
{
"identity" : "fetch-node-details-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/torusresearch/fetch-node-details-swift.git",
"state" : {
"revision" : "4bd96c33ba8d02d9e27190c5c7cedf09cfdfd656",
"version" : "6.0.3"
"revision" : "52fb5efaa94e0fe3775913ab00964bcb51601c2a",
"version" : "8.0.0"
}
},
{
Expand All @@ -50,53 +50,26 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/auth0/JWTDecode.swift.git",
"state" : {
"revision" : "58af7278797871e460d79496621b3e5366b865b2",
"version" : "3.1.0"
}
},
{
"identity" : "keychain-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/evgenyneu/keychain-swift.git",
"state" : {
"revision" : "d108a1fa6189e661f91560548ef48651ed8d93b9",
"version" : "20.0.0"
}
},
{
"identity" : "session-manager-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Web3Auth/session-manager-swift.git",
"state" : {
"revision" : "20cc7bff065d7fe53164d17e7714a3f17d4cea2a",
"version" : "4.0.2"
}
},
{
"identity" : "single-factor-auth-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Web3Auth/single-factor-auth-swift",
"state" : {
"branch" : "7.0.0",
"revision" : "d9a8fd7885e37e74e61010f8fb240cbbafd1e577"
"revision" : "1e153ef009969543191970c66b7c60163c0b4a65",
"version" : "3.2.0"
}
},
{
"identity" : "socket.io-client-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/socketio/socket.io-client-swift",
"state" : {
"revision" : "175da8b5156f6b132436f0676cc84c2f6a766b6e",
"version" : "16.1.0"
"revision" : "42da871d9369f290d6ec4930636c40672143905b",
"version" : "16.1.1"
}
},
{
"identity" : "starscream",
"kind" : "remoteSourceControl",
"location" : "https://github.com/daltoniam/Starscream",
"state" : {
"revision" : "ac6c0fc9da221873e01bd1a0d4818498a71eef33",
"version" : "4.0.6"
"revision" : "c6bfd1af48efcc9a9ad203665db12375ba6b145a",
"version" : "4.0.8"
}
},
{
Expand All @@ -113,26 +86,26 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/tkey/tkey-mpc-swift",
"state" : {
"branch" : "update_features",
"revision" : "00ed189447df83681092aabd5c64e65671ccd0d1"
"branch" : "encapsulate_torusnetwork",
"revision" : "73158e73e109e59ec7e7a9f9fdd9c70759a04d7b"
}
},
{
"identity" : "torus-utils-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/torusresearch/torus-utils-swift.git",
"state" : {
"revision" : "303dc2cf41db7c10f769855edad0e717ced2d554",
"version" : "9.0.0"
"revision" : "baa822fc67bdb208ed1a2dc5b3c10485cfca15df",
"version" : "10.0.0"
}
},
{
"identity" : "tss-client-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/torusresearch/tss-client-swift.git",
"state" : {
"revision" : "40246d5e3ff1d2c97d41846576f7a81d58858981",
"version" : "4.0.0"
"revision" : "4eadb32baed827d5e0600ee4f5c099259c45631c",
"version" : "5.0.0"
}
}
],
Expand Down
10 changes: 4 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/vapor/jwt-kit.git", from: "4.0.0"),
.package(url: "https://github.com/torusresearch/tss-client-swift.git", from: "4.0.0"),
.package(url: "https://github.com/tkey/tkey-mpc-swift", branch : "update_features" ),
.package(url: "https://github.com/torusresearch/customauth-swift-sdk", branch : "features_update"),
.package(url: "https://github.com/Web3Auth/single-factor-auth-swift", branch :"7.0.0"),
.package(url: "https://github.com/auth0/JWTDecode.swift", from: "3.1.0")
.package(url: "https://github.com/torusresearch/tss-client-swift.git", from: "5.0.0"),
.package(url: "https://github.com/tkey/tkey-mpc-swift", branch : "encapsulate_torusnetwork" ), // 4.0.0
.package(url: "https://github.com/torusresearch/customauth-swift-sdk", from: "11.0.1"),
.package(url: "https://github.com/auth0/JWTDecode.swift", from: "3.2.0")
],

targets: [
Expand All @@ -28,7 +27,6 @@ let package = Package(
name: "mpc-core-kit-swift",
dependencies: [
.product(name: "CustomAuth", package: "customauth-swift-sdk"),
.product(name: "SingleFactorAuth", package: "single-factor-auth-swift"),
.product(name: "tkey", package: "tkey-mpc-swift" ),
.product(name: "tssClientSwift", package: "tss-client-swift" ),
.product(name: "JWTDecode", package: "JWTDecode.swift")
Expand Down
3 changes: 3 additions & 0 deletions Sources/mpc-core-kit-swift/CoreKitError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public enum CoreKitError: Error {
case invalidStore
case noTssTags
case invalidDeviceFactorKey
case invalidTssPubKey
case runtime(_ msg: String)

public var errorDescription: String {
Expand Down Expand Up @@ -91,6 +92,8 @@ public enum CoreKitError: Error {
return "Device factor key not found"
case .runtime(msg: let msg):
return msg
case .invalidTssPubKey:
return "Invalid tss public key"
}
}
}
2 changes: 1 addition & 1 deletion Sources/mpc-core-kit-swift/DeviceFactorStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class DeviceFactorStorage: IFactorStorage {

public func setFactor(metadataPubKey: String, factorKey: String) async throws {
guard let factorKeyData = Data(hexString: factorKey) else {
throw "invalid factorKey"
throw CoreKitError.invalidFactorKey
}
try await storage.set(key: metadataPubKey, payload: factorKeyData)
}
Expand Down
1 change: 0 additions & 1 deletion Sources/mpc-core-kit-swift/Helper.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import BigInt
import FetchNodeDetails
import Foundation
import SingleFactorAuth

#if canImport(tkey)
import tkey
Expand Down
1 change: 0 additions & 1 deletion Sources/mpc-core-kit-swift/Interface.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Foundation
import SingleFactorAuth

#if canImport(tkey)
import tkey
Expand Down
16 changes: 8 additions & 8 deletions Sources/mpc-core-kit-swift/MpcCoreKitSwift.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import CustomAuth
import FetchNodeDetails
import Foundation
import SingleFactorAuth
import TorusUtils

#if canImport(tkey)
Expand All @@ -21,7 +20,7 @@ public class MpcCoreKit {
internal var tssPubKey: String?

internal var userInfo: [String:Any]
internal var option: Web3AuthOptions
internal var option: CoreKitWeb3AuthOptions
// internal var state: CoreKitstate


Expand Down Expand Up @@ -49,7 +48,7 @@ public class MpcCoreKit {
private let customAuth: CustomAuth


public init(options: Web3AuthOptions) throws {
public init(options: CoreKitWeb3AuthOptions) throws {
if options.web3AuthClientId.isEmpty {
throw CoreKitError.invalidInput
}
Expand Down Expand Up @@ -111,9 +110,10 @@ public class MpcCoreKit {
return mnemonic
}


public func loginWithJwt(verifier: String, verifierId: String, idToken: String) async throws -> MpcKeyDetails {
let singleFactor = try SingleFactorAuth(singleFactorAuthArgs: SingleFactorAuthArgs(web3AuthClientId: option.web3AuthClientId, network: option.web3AuthNetwork))
let torusKey = try await singleFactor.getTorusKey(loginParams: LoginParams(verifier: verifier, verifierId: verifierId, idToken: idToken))

let torusKey = try await customAuth.getTorusKey(verifier: verifier, verifier_id: verifierId, verifierParams: VerifierParams(verifier_id: verifierId), idToken: idToken)

let result = try await login(keyDetails: torusKey, verifier: verifier, verifierId: verifierId)

Expand Down Expand Up @@ -183,7 +183,7 @@ public class MpcCoreKit {

self.nodeDetails = nodeDetails

tssEndpoints = nodeDetails.torusNodeTSSEndpoints
tssEndpoints = nodeDetails.getTorusNodeTSSEndpoints()

guard let postboxkey = self.oAuthKey else {
throw CoreKitError.invalidPostboxKey
Expand All @@ -201,7 +201,7 @@ public class MpcCoreKit {
authSigs = sigs

guard let metadataEndpoint = metadataHostUrl else {
throw "Invalid metadata url endpoint"
throw CoreKitError.invalidInput
}

// initialize tkey
Expand Down Expand Up @@ -360,7 +360,7 @@ public class MpcCoreKit {
let allFactorPubs = try await self.getAllFactorPubs()
let factorPub = try SecretKey(hex: factorKey).toPublic().serialize(compressed: true)
if (!allFactorPubs.contains(factorPub)) {
throw "Invalid factor \(factorKey)"
throw CoreKitError.invalidFactorKey
}

// input factor
Expand Down
8 changes: 4 additions & 4 deletions Sources/mpc-core-kit-swift/Tss.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ import tssClientSwift

extension MpcCoreKit {
public func getTssPubKey() throws -> Data {
guard let thresholdKey = tkey else {
guard tkey != nil else {
throw CoreKitError.invalidTKey
}

guard let tssPubKey = self.tssPubKey else {
throw "invalid Tss Pub Key"
throw CoreKitError.invalidTssPubKey
}

guard let res = Data(hexString: tssPubKey) else {
throw "invalid Tss Pub Key"
throw CoreKitError.invalidTssPubKey
}
return res
}
Expand All @@ -40,7 +40,7 @@ extension MpcCoreKit {
}

if factorKey == nil {
throw "Invalid factor Key"
throw CoreKitError.invalidFactorKey
}

let selectedTag = try TssModule.get_tss_tag(threshold_key: tkey)
Expand Down
4 changes: 2 additions & 2 deletions Sources/mpc-core-kit-swift/core/Web3AuthOptions.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation
import SingleFactorAuth
import FetchNodeDetails

public class Web3AuthOptions {
public class CoreKitWeb3AuthOptions {
public let web3AuthClientId: String
public let manualSync: Bool
public let web3AuthNetwork: Web3AuthNetwork
Expand Down
11 changes: 5 additions & 6 deletions Tests/mpc-kit-swiftTests/mpc_kit_swiftTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import curveSecp256k1
import JWTKit
import FetchNodeDetails
import mpc_core_kit_swift
import SingleFactorAuth
import XCTest

// JWT payload structure.
Expand Down Expand Up @@ -91,7 +90,7 @@ func mockLogin2(email: String) throws -> String {

final class mpc_kit_swiftTests: XCTestCase {
func resetMPC(email: String, verifier: String, clientId: String) async throws {
let coreKitInstance = try MpcCoreKit(options: Web3AuthOptions(web3AuthClientId: clientId, manualSync: true, web3AuthNetwork: .sapphire(.SAPPHIRE_DEVNET), localStorage: MemoryStorage(), disableHashFactor: false))
let coreKitInstance = try MpcCoreKit(options: CoreKitWeb3AuthOptions(web3AuthClientId: clientId, manualSync: true, web3AuthNetwork: .SAPPHIRE_DEVNET, localStorage: MemoryStorage(), disableHashFactor: false))
let data = try mockLogin2(email: email)
let token = data

Expand All @@ -109,14 +108,14 @@ final class mpc_kit_swiftTests: XCTestCase {

let memoryStorage = MemoryStorage()

let coreKitInstance = try MpcCoreKit(options: Web3AuthOptions(web3AuthClientId: clientId, manualSync: true, web3AuthNetwork: .sapphire(.SAPPHIRE_DEVNET), localStorage: memoryStorage, disableHashFactor: false))
let coreKitInstance = try MpcCoreKit(options: CoreKitWeb3AuthOptions(web3AuthClientId: clientId, manualSync: true, web3AuthNetwork: .SAPPHIRE_DEVNET, localStorage: memoryStorage, disableHashFactor: false))

let data = try mockLogin2(email: email)
let token = data

let _ = try await coreKitInstance.loginWithJwt(verifier: verifier, verifierId: email, idToken: token)
let hash = try keccak256(data: Data(hexString: "010203040506")!)
let signatures = try coreKitInstance.tssSign(message: hash)
_ = try coreKitInstance.tssSign(message: hash)

let newFactor = try await coreKitInstance.createFactor(tssShareIndex: .device, factorKey: nil, factorDescription: .DeviceShare, additionalMetadata: ["my": "mymy"])

Expand All @@ -132,7 +131,7 @@ final class mpc_kit_swiftTests: XCTestCase {
// reset Account
try await resetMPC(email: email, verifier: verifier, clientId: clientId)
let memoryStorage = MemoryStorage()
let coreKitInstance = try MpcCoreKit(options: Web3AuthOptions(web3AuthClientId: clientId, manualSync: false, web3AuthNetwork: .sapphire(.SAPPHIRE_DEVNET), localStorage: memoryStorage, disableHashFactor: false))
let coreKitInstance = try MpcCoreKit(options: CoreKitWeb3AuthOptions(web3AuthClientId: clientId, manualSync: false, web3AuthNetwork: .SAPPHIRE_DEVNET, localStorage: memoryStorage, disableHashFactor: false))
let data = try mockLogin2(email: email)
let token = data

Expand All @@ -141,7 +140,7 @@ final class mpc_kit_swiftTests: XCTestCase {
let recoveryFactor = try await coreKitInstance.enableMFAWithRecoveryFactor()

let memoryStorage2 = MemoryStorage()
let coreKitInstance2 = try MpcCoreKit(options: Web3AuthOptions(web3AuthClientId: clientId, manualSync: false, web3AuthNetwork: .sapphire(.SAPPHIRE_DEVNET), localStorage: memoryStorage2, disableHashFactor: false))
let coreKitInstance2 = try MpcCoreKit(options: CoreKitWeb3AuthOptions(web3AuthClientId: clientId, manualSync: false, web3AuthNetwork: .SAPPHIRE_DEVNET, localStorage: memoryStorage2, disableHashFactor: false))
let data2 = try mockLogin2(email: email)
let token2 = data2

Expand Down

0 comments on commit 7f8f4b0

Please sign in to comment.