diff --git a/Package.swift b/Package.swift index bdeddae..70932a4 100644 --- a/Package.swift +++ b/Package.swift @@ -17,7 +17,7 @@ let package = Package( dependencies: [ // Dependencies declare other packages that this package depends on. // .package(url: /* package url */, from: "1.0.0"), - .package(name: "TorusUtils", url: "https://github.com/torusresearch/torus-utils-swift" , from: "9.0.0"), + .package(name: "TorusUtils", url: "https://github.com/torusresearch/torus-utils-swift", branch: "encapsulate_torusnetwork"), // dev dependencies only .package(name:"jwt-kit", url: "https://github.com/vapor/jwt-kit.git", from: "4.0.0"), ], diff --git a/Sources/ThresholdKey/Modules/TssModule.swift b/Sources/ThresholdKey/Modules/TssModule.swift index 77a3449..65fa12d 100644 --- a/Sources/ThresholdKey/Modules/TssModule.swift +++ b/Sources/ThresholdKey/Modules/TssModule.swift @@ -540,10 +540,10 @@ public final class TssModule { public static func find_device_share_index(threshold_key: ThresholdKey, factor_key: String) async throws -> String { let result = try await threshold_key.storage_layer_get_metadata(private_key: factor_key) guard let resultData = result.data(using: .utf8) else { - throw "Invalid factor key" + throw RuntimeError("Invalid factor key") } guard let resultJson = try JSONSerialization.jsonObject(with: resultData) as? [String: Any] else { - throw "Invalid factor key" + throw RuntimeError("Invalid factor key") } var deviceShareJson = resultJson; @@ -551,16 +551,16 @@ public final class TssModule { // backward competible if resultJson["deviceShare"] != nil { guard let deviceShare = resultJson["deviceShare"] as? [String: Any] else { - throw "Invalid factor key" + throw RuntimeError("Invalid factor key") } deviceShareJson = deviceShare } guard let shareJson = deviceShareJson["share"] as? [String: Any] else { - throw "Invalid factor key" + throw RuntimeError("Invalid factor key") } guard let shareIndex = shareJson["shareIndex"] as? String else { - throw "Invalid factor key" + throw RuntimeError("Invalid factor key") } return shareIndex } @@ -579,7 +579,7 @@ public final class TssModule { let extendedVerifierId = try threshold_key.get_extended_verifier_id() let split = extendedVerifierId.components(separatedBy: "\u{001c}") - let result = try await torusUtils.getPublicAddress(endpoints: nodeDetails.torusNodeEndpoints, verifier: split[0], verifierId: split[1], extendedVerifierId: "\(split[1])\u{0015}\(tssTag)\u{0016}\(nonce)") + let result = try await torusUtils.getPublicAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: split[0], verifierId: split[1], extendedVerifierId: "\(split[1])\u{0015}\(tssTag)\u{0016}\(nonce)") guard let x = result.finalKeyData?.X, let y = result.finalKeyData?.Y, let nodeIndexes = result.nodesData?.nodeIndexes else { throw RuntimeError("conversion error") diff --git a/Sources/ThresholdKey/ServiceProvider.swift b/Sources/ThresholdKey/ServiceProvider.swift index b77db41..9297c4d 100644 --- a/Sources/ThresholdKey/ServiceProvider.swift +++ b/Sources/ThresholdKey/ServiceProvider.swift @@ -44,7 +44,7 @@ public final class ServiceProvider { let rssEndpoints = try JSONSerialization.data(withJSONObject: nodeDetails.getTorusNodeRSSEndpoints()) let tssEndpoints = try JSONSerialization.data(withJSONObject: nodeDetails.getTorusNodeTSSEndpoints()) - let pub = nodeDetails.torusNodePub + let pub = nodeDetails.getTorusNodePub() let pubkey = try JSONEncoder().encode(pub) sss = try NodeDetails(server_endpoints: String(data: sssEndpoints, encoding: .utf8)!, server_public_keys: String(data: pubkey, encoding: .utf8)!, serverThreshold: 3) diff --git a/Tests/tkeypkgTests/IntegrationTests.swift b/Tests/tkeypkgTests/IntegrationTests.swift index e9176cf..0cdd586 100644 --- a/Tests/tkeypkgTests/IntegrationTests.swift +++ b/Tests/tkeypkgTests/IntegrationTests.swift @@ -13,14 +13,14 @@ final class integrationTests: XCTestCase { let TORUS_TEST_VERIFIER = "torus-test-health" - let nodeManager = NodeDetailManager(network: .sapphire(.SAPPHIRE_DEVNET)) + let nodeManager = NodeDetailManager(network: .SAPPHIRE_DEVNET) let nodeDetail = try await nodeManager.getNodeDetails(verifier: TORUS_TEST_VERIFIER, verifierID: TORUS_TEST_EMAIL) - let options = TorusOptions(clientId: "CLIENT ID", network: .sapphire(.SAPPHIRE_DEVNET), serverTimeOffset: 1000) + let options = TorusOptions(clientId: "CLIENT ID", network: .SAPPHIRE_DEVNET, serverTimeOffset: 1000) let torusUtils = try TorusUtils(params: options) let idToken = try generateIdToken(email: TORUS_TEST_EMAIL) let verifierParams = VerifierParams(verifier_id: TORUS_TEST_EMAIL) - let retrievedShare = try await torusUtils.retrieveShares(endpoints: nodeDetail.torusNodeEndpoints, verifier: TORUS_TEST_VERIFIER, verifierParams: verifierParams, idToken: idToken) + let retrievedShare = try await torusUtils.retrieveShares(endpoints: nodeDetail.getTorusNodeEndpoints(), verifier: TORUS_TEST_VERIFIER, verifierParams: verifierParams, idToken: idToken) let signature_collection = retrievedShare.sessionData.sessionTokenData.map { token in ["data": token!.token, @@ -123,14 +123,14 @@ final class integrationTests: XCTestCase { var threshold: ThresholdKey! var threshold2: ThresholdKey! - let nodeManager = NodeDetailManager(network: .sapphire(.SAPPHIRE_DEVNET)) + let nodeManager = NodeDetailManager(network: .SAPPHIRE_DEVNET) let nodeDetail = try await nodeManager.getNodeDetails(verifier: TORUS_TEST_VERIFIER, verifierID: TORUS_TEST_EMAIL) - let options = TorusOptions(clientId: "CLIENT ID", network: .sapphire(.SAPPHIRE_DEVNET), serverTimeOffset: 1000) + let options = TorusOptions(clientId: "CLIENT ID", network: .SAPPHIRE_DEVNET, serverTimeOffset: 1000) let torusUtils = try TorusUtils(params: options) let idToken = try generateIdToken(email: TORUS_TEST_EMAIL) let verifierParams = VerifierParams(verifier_id: TORUS_TEST_EMAIL) - let retrievedShare = try await torusUtils.retrieveShares(endpoints: nodeDetail.torusNodeSSSEndpoints, verifier: TORUS_TEST_VERIFIER, verifierParams: verifierParams, idToken: idToken) + let retrievedShare = try await torusUtils.retrieveShares(endpoints: nodeDetail.getTorusNodeSSSEndpoints(), verifier: TORUS_TEST_VERIFIER, verifierParams: verifierParams, idToken: idToken) let signature_collection = retrievedShare.sessionData.sessionTokenData.map { token in ["data": token!.token, diff --git a/Tests/tkeypkgTests/tkey_base.swift b/Tests/tkeypkgTests/tkey_base.swift index bb7fb2b..b3ef9b5 100644 --- a/Tests/tkeypkgTests/tkey_base.swift +++ b/Tests/tkeypkgTests/tkey_base.swift @@ -5,7 +5,7 @@ import tkey import TorusUtils class tkey_baseTests: XCTestCase { - let options = TorusOptions(clientId: "CLIENT ID", network: .sapphire(.SAPPHIRE_DEVNET)) + let options = TorusOptions(clientId: "CLIENT ID", network: .SAPPHIRE_DEVNET) var torusUtils: TorusUtils! override func setUp() async throws { diff --git a/tkey-mpc-swift.podspec b/tkey-mpc-swift.podspec index bdb781d..4c63291 100644 --- a/tkey-mpc-swift.podspec +++ b/tkey-mpc-swift.podspec @@ -10,6 +10,6 @@ Pod::Spec.new do |spec| spec.module_name = "tkey" spec.source = { :git => "https://github.com/tkey/tkey-mpc-swift.git", :tag => spec.version } spec.vendored_framework = "Sources/libtkey/libtkey.xcframework" - spec.dependency 'TorusUtils', '~> 9.0.0' + spec.dependency 'TorusUtils', '~> 10.0.0' spec.source_files = "Sources/**/*.{swift,c,h}" end