diff --git a/Sources/TorusUtils/Helpers/NodeUtils.swift b/Sources/TorusUtils/Helpers/NodeUtils.swift index a10d0609..fd40d937 100644 --- a/Sources/TorusUtils/Helpers/NodeUtils.swift +++ b/Sources/TorusUtils/Helpers/NodeUtils.swift @@ -14,7 +14,7 @@ public class NodeUtils { verifierId: String, extendedVerifierId: String? = nil) async throws -> KeyLookupResult { let threshold = Int(trunc(Double((endpoints.count / 2) + 1))) - + let params = GetOrSetKeyParams(distributed_metadata: true, verifier: verifier, verifier_id: verifierId, extended_verifier_id: extendedVerifierId, one_key_flow: true, fetch_node_index: true, client_time: String(Int(floor(Date().timeIntervalSince1970 / 1000)))) let jsonRPCRequest = JRPCRequest( method: JRPC_METHODS.GET_OR_SET_KEY, @@ -115,8 +115,8 @@ public class NodeUtils { apiKey: String = "torus-default", extraParams: [String: Codable] = [:] ) async throws -> TorusKey { - let minThresholdRequired = Int(trunc(Double((endpoints.count / 2) + 1))) - + let threshold = Int(trunc(Double((endpoints.count / 2) + 1))) + var allowHostRequest = try MetadataUtils.makeUrlRequest(url: allowHost, httpMethod: .get) allowHostRequest.addValue(apiKey, forHTTPHeaderField: "x-api-key") allowHostRequest.addValue(verifier, forHTTPHeaderField: "origin") @@ -131,7 +131,7 @@ public class NodeUtils { let errorData = try JSONDecoder().decode(AllowRejected.self, from: allowHostResult.0) throw TorusUtilError.gatingError("code: \(errorData.code), error: \(errorData.error)") } - + let sessionAuthKey = SecretKey() let sessionAuthKeySerialized = try sessionAuthKey.serialize().addLeading0sForLength64() let pubKey = try sessionAuthKey.toPublic().serialize(compressed: false) @@ -197,19 +197,18 @@ public class NodeUtils { let shareRequestResults: [JRPCResponse?] = try await withThrowingTaskGroup(of: JRPCResponse?.self, returning: [JRPCResponse?].self) { group -> [JRPCResponse?] in let isImport = isImportShareReq // Local copy for parellel code - for i in 0 ..< endpoints.count { if !nodeSigs.indices.contains(i) { continue } - + group.addTask { let sessionExpiry: Int? = extraParams["session_token_exp_second"] as? Int - + if isImport { do { let importShare = importedShares![i] - + let shareRequestItem = ShareRequestParams.ShareRequestItem( verifieridentifier: verifier, verifier_id: verifierParams.verifier_id, @@ -231,7 +230,7 @@ public class NodeUtils { ) let params = ShareRequestParams(encrypted: "yes", item: [shareRequestItem], client_time: String(Int(floor(Date().timeIntervalSince1970 / 1000)))) - + let jsonRPCRequest = JRPCRequest( method: JRPC_METHODS.IMPORT_SHARE, params: params @@ -284,19 +283,20 @@ public class NodeUtils { } } } - + var collected = [JRPCResponse?]() for try await value in group { collected.append(value) } + return collected } - + let shareResponses: [ShareRequestResult] = shareRequestResults.filter({ $0?.result != nil }).map({ $0!.result! }) - - let pubkeys = shareResponses.filter({$0.keys.count > 0}).map { $0.keys[0].publicKey } - let thresholdPublicKey = try thresholdSame(arr: pubkeys, threshold: minThresholdRequired) + let pubkeys = shareResponses.filter({ $0.keys.count > 0 }).map { $0.keys[0].publicKey } + + let thresholdPublicKey = try thresholdSame(arr: pubkeys, threshold: threshold) if thresholdPublicKey == nil { throw TorusUtilError.retrieveOrImportShareError @@ -317,7 +317,7 @@ public class NodeUtils { throw TorusUtilError.runtime("invalid metadata result from nodes, nonce metadata is empty") } - let thresholdReqCount = (importedShares != nil && importedShares!.count > 0) ? endpoints.count : minThresholdRequired + let thresholdReqCount = (importedShares != nil && importedShares!.count > 0) ? endpoints.count : threshold // Invert comparision to return error early if !(shareResponses.count >= thresholdReqCount && thresholdPublicKey != nil && (thresholdNonceData != nil || verifierParams.extended_verifier_id != nil || TorusUtils.isLegacyNetworkRouteMap(network: network))) { @@ -376,16 +376,16 @@ public class NodeUtils { shares.append(nil) } } - + let validSigs = sessionTokenSigs.filter({ $0 != nil }).map({ $0! }) - if verifierParams.extended_verifier_id == nil && validSigs.count < minThresholdRequired { + if verifierParams.extended_verifier_id == nil && validSigs.count < threshold { throw TorusUtilError.retrieveOrImportShareError } let validTokens = sessionTokens.filter({ $0 != nil }).map({ $0! }) - if verifierParams.extended_verifier_id == nil && validTokens.count < minThresholdRequired { + if verifierParams.extended_verifier_id == nil && validTokens.count < threshold { throw TorusUtilError.runtime("Insufficient number of signatures from nodes") } @@ -404,7 +404,7 @@ public class NodeUtils { } } let elements = Array(0 ..< decryptedShares.count) - let allCombis = kCombinations(elements: elements.slice, k: minThresholdRequired) + let allCombis = kCombinations(elements: elements.slice, k: threshold) var privateKey: String? @@ -431,7 +431,7 @@ public class NodeUtils { throw TorusUtilError.privateKeyDeriveFailed } - let thresholdIsNewKey = try thresholdSame(arr: isNewKeys, threshold: minThresholdRequired) + let thresholdIsNewKey = try thresholdSame(arr: isNewKeys, threshold: threshold) let serverOffsetTimes = serverTimeOffsets.map({ Int($0) ?? 0 }) diff --git a/Sources/TorusUtils/TorusUtils.swift b/Sources/TorusUtils/TorusUtils.swift index b34662fc..ea00ab61 100644 --- a/Sources/TorusUtils/TorusUtils.swift +++ b/Sources/TorusUtils/TorusUtils.swift @@ -110,7 +110,7 @@ public class TorusUtils { newPrivateKey: String ) async throws -> TorusKey { let nodePubs = TorusNodePubModelToINodePub(nodes: nodePubKeys) - + let threshold = Int(trunc(Double((endpoints.count / 2) + 1))) let degree = threshold - 1 @@ -143,7 +143,7 @@ public class TorusUtils { var jsonShares: [Data] = [] for i in 0 ..< nodeIndexes.count { - let share: Share? = shares[nodeIndexes[i].serialize().addLeading0sForLength64().hexString] + let share: Share? = shares[nodeIndexes[i].serialize().hexString.addLeading0sForLength64()] if share == nil { throw TorusUtilError.runtime("Missing node pub key for node index") } @@ -163,7 +163,7 @@ public class TorusUtils { pubKeyY: pubKeyY, encryptedShare: encParamsMetadata.ciphertext!, encryptedShareMetadata: encParamsMetadata, - nodeIndex: Int(shares[nodeIndexes[i].magnitude.serialize().addLeading0sForLength64().hexString]!.shareIndex.magnitude.serialize().addLeading0sForLength64().hexString)!, + nodeIndex: Int(shares[nodeIndexes[i].magnitude.serialize().hexString.addLeading0sForLength64()]!.shareIndex.magnitude.serialize().hexString.addLeading0sForLength64())!, keyType: "secp256k1", nonceData: nonceData.hexString, nonceSignature: nonceParams.signature) diff --git a/Tests/TorusUtilsTests/AquaTest.swift b/Tests/TorusUtilsTests/AquaTest.swift index 0aec4a54..f4f13cd5 100644 --- a/Tests/TorusUtilsTests/AquaTest.swift +++ b/Tests/TorusUtilsTests/AquaTest.swift @@ -21,7 +21,7 @@ class AquaTest: XCTestCase { let verifier: String = "tkey-google-aqua" let verifierID: String = TORUS_TEST_EMAIL let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - let val = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + let val = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertEqual(val.finalKeyData!.evmAddress, "0xDfA967285AC699A70DA340F60d00DB19A272639d") XCTAssertLessThan(val.metadata!.serverTimeOffset, 20) @@ -43,7 +43,7 @@ class AquaTest: XCTestCase { var verifier: String = "tkey-google-aqua" var verifierID: String = TORUS_TEST_EMAIL let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - let result1 = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + let result1 = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertLessThan(result1.metadata!.serverTimeOffset, 20) XCTAssertEqual(result1.oAuthKeyData!.evmAddress, "0xDfA967285AC699A70DA340F60d00DB19A272639d") @@ -62,7 +62,7 @@ class AquaTest: XCTestCase { // 1/1 user verifier = "tkey-google-aqua" verifierID = "somev2user@gmail.com" - let result2 = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + let result2 = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertLessThan(result2.metadata!.serverTimeOffset, 20) @@ -82,7 +82,7 @@ class AquaTest: XCTestCase { // 2/n user verifierID = "caspertorus@gmail.com" - let result3 = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + let result3 = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertLessThan(result2.metadata!.serverTimeOffset, 20) @@ -105,7 +105,7 @@ class AquaTest: XCTestCase { let verifier: String = "tkey-google-aqua" let verifierID: String = fakeEmail let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - let data = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + let data = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) //note: duplicated checks on next two lines in javascript XCTAssertNotNil(data.finalKeyData?.evmAddress) XCTAssertNotNil(data.oAuthKeyData?.evmAddress) diff --git a/Tests/TorusUtilsTests/Celeste.swift b/Tests/TorusUtilsTests/Celeste.swift index cdb62ab4..134331f3 100644 --- a/Tests/TorusUtilsTests/Celeste.swift +++ b/Tests/TorusUtilsTests/Celeste.swift @@ -21,7 +21,7 @@ class CelesteTest: XCTestCase { let verifier = "tkey-google-celeste" let verifierID = TORUS_TEST_EMAIL let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - let val = try await torus.getPublicAddress(endpoints: nodeDetails.torusNodeEndpoints, torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + let val = try await torus.getPublicAddress(endpoints: nodeDetails.torusNodeEndpoints, verifier: verifier, verifierId: verifierID) XCTAssertEqual(val.finalKeyData!.evmAddress, "0xC3115b9d6FaB99739b23DA9dfcBA47A4Ec4Cd113") XCTAssertLessThan(val.metadata!.serverTimeOffset, 20) @@ -43,7 +43,7 @@ class CelesteTest: XCTestCase { var verifier: String = "tkey-google-celeste" var verifierID: String = TORUS_TEST_EMAIL let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - var val = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + var val = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertEqual(val.finalKeyData!.evmAddress, "0xC3115b9d6FaB99739b23DA9dfcBA47A4Ec4Cd113") XCTAssertLessThan(val.metadata!.serverTimeOffset, 20) @@ -60,7 +60,7 @@ class CelesteTest: XCTestCase { verifier = "tkey-google-celeste" verifierID = "somev2user@gmail.com" - val = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + val = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertEqual(val.finalKeyData!.evmAddress, "0x8d69CE354DA39413f205FdC8680dE1F3FBBb36e2") XCTAssertLessThan(val.metadata!.serverTimeOffset, 20) @@ -82,7 +82,7 @@ class CelesteTest: XCTestCase { verifier = "tkey-google-celeste" verifierID = "caspertorus@gmail.com" - val = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + val = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertEqual(val.finalKeyData!.evmAddress, "0x8108c29976C458e76f797AD55A3715Ce80a3fe78") XCTAssertLessThan(val.metadata!.serverTimeOffset, 20) @@ -106,7 +106,7 @@ class CelesteTest: XCTestCase { let verifier: String = "tkey-google-celeste" let verifierID: String = fakeEmail let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - let data = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + let data = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertNotEqual(data.finalKeyData?.evmAddress, "") XCTAssertNotEqual(data.oAuthKeyData?.evmAddress, "") XCTAssertEqual(data.metadata?.typeOfUser, .v1) diff --git a/Tests/TorusUtilsTests/CyanTest.swift b/Tests/TorusUtilsTests/CyanTest.swift index 4e0b0c8b..695b89f3 100644 --- a/Tests/TorusUtilsTests/CyanTest.swift +++ b/Tests/TorusUtilsTests/CyanTest.swift @@ -21,7 +21,7 @@ class CyanTest: XCTestCase { let verifier: String = "tkey-google-cyan" let verifierID: String = TORUS_TEST_EMAIL let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - let val = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + let val = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertEqual(val.finalKeyData!.evmAddress, "0xA3767911A84bE6907f26C572bc89426dDdDB2825") XCTAssertLessThan(val.metadata!.serverTimeOffset, 20) @@ -43,7 +43,7 @@ class CyanTest: XCTestCase { var verifier: String = "tkey-google-cyan" var verifierID: String = TORUS_TEST_EMAIL let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - var data = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + var data = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertEqual(data.finalKeyData!.evmAddress, "0x3507F0d192a44E436B8a6C32a37d57D022861b1a") XCTAssertLessThan(data.metadata!.serverTimeOffset, 20) @@ -63,7 +63,7 @@ class CyanTest: XCTestCase { verifier = "tkey-google-cyan" verifierID = "somev2user@gmail.com" - data = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + data = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertEqual(data.finalKeyData!.evmAddress, "0x8EA83Ace86EB414747F2b23f03C38A34E0217814") XCTAssertLessThan(data.metadata!.serverTimeOffset, 20) @@ -83,7 +83,7 @@ class CyanTest: XCTestCase { verifier = "tkey-google-cyan" verifierID = "caspertorus@gmail.com" - data = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + data = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertEqual(data.finalKeyData!.evmAddress, "0xCC1f953f6972a9e3d685d260399D6B85E2117561") XCTAssertLessThan(data.metadata!.serverTimeOffset, 20) @@ -107,7 +107,7 @@ class CyanTest: XCTestCase { let verifier: String = "tkey-google-cyan" let verifierID: String = fakeEmail let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - let data = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + let data = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertNotEqual(data.finalKeyData?.evmAddress, "") XCTAssertNotEqual(data.oAuthKeyData?.evmAddress, "") XCTAssertEqual(data.metadata?.typeOfUser, .v1) diff --git a/Tests/TorusUtilsTests/MainnetTest.swift b/Tests/TorusUtilsTests/MainnetTest.swift index 9dba3fd9..2eb21f5f 100644 --- a/Tests/TorusUtilsTests/MainnetTest.swift +++ b/Tests/TorusUtilsTests/MainnetTest.swift @@ -28,7 +28,7 @@ class MainnetTests: XCTestCase { let verifier = "google" let verifierID = TORUS_TEST_EMAIL let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - let val = try await torus.getPublicAddress(endpoints: nodeDetails.torusNodeEndpoints, torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + let val = try await torus.getPublicAddress(endpoints: nodeDetails.torusNodeEndpoints, verifier: verifier, verifierId: verifierID) XCTAssertEqual(val.finalKeyData!.evmAddress, "0x0C44AFBb5395a9e8d28DF18e1326aa0F16b9572A") XCTAssertLessThan(val.metadata!.serverTimeOffset, 20) @@ -50,7 +50,7 @@ class MainnetTests: XCTestCase { var verifier: String = "google" var verifierID: String = TORUS_TEST_EMAIL let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - var val = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + var val = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertEqual(val.finalKeyData!.evmAddress, "0xb2e1c3119f8D8E73de7eaF7A535FB39A3Ae98C5E") XCTAssertLessThan(val.metadata!.serverTimeOffset, 20) @@ -70,7 +70,7 @@ class MainnetTests: XCTestCase { verifier = "tkey-google" verifierID = "somev2user@gmail.com" - val = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + val = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertEqual(val.finalKeyData!.evmAddress, "0xFf669A15bFFcf32D3C5B40bE9E5d409d60D43526") XCTAssertLessThan(val.metadata!.serverTimeOffset, 20) @@ -90,7 +90,7 @@ class MainnetTests: XCTestCase { verifier = "tkey-google" verifierID = "caspertorus@gmail.com" - val = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + val = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertEqual(val.finalKeyData!.evmAddress, "0x40A4A04fDa1f29a3667152C8830112FBd6A77BDD") XCTAssertLessThan(val.metadata!.serverTimeOffset, 20) @@ -114,7 +114,7 @@ class MainnetTests: XCTestCase { let verifier: String = "google" let verifierID: String = fakeEmail let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - let data = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + let data = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertNotEqual(data.finalKeyData?.evmAddress, "") XCTAssertNotEqual(data.oAuthKeyData?.evmAddress, "") XCTAssertEqual(data.metadata?.typeOfUser, .v1) diff --git a/Tests/TorusUtilsTests/SapphireDevnetTest.swift b/Tests/TorusUtilsTests/SapphireDevnetTest.swift index faffa8ce..87884839 100644 --- a/Tests/TorusUtilsTests/SapphireDevnetTest.swift +++ b/Tests/TorusUtilsTests/SapphireDevnetTest.swift @@ -29,7 +29,7 @@ final class SapphireDevnetTest: XCTestCase { let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - let val = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + let val = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertEqual(val.oAuthKeyData!.evmAddress, "0x137B3607958562D03Eb3C6086392D1eFa01aA6aa") XCTAssertEqual(val.oAuthKeyData!.X, "118a674da0c68f16a1123de9611ba655f4db1e336fe1b2d746028d65d22a3c6b") @@ -72,7 +72,7 @@ final class SapphireDevnetTest: XCTestCase { let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - let data = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + let data = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertNotEqual(data.finalKeyData?.evmAddress, "") XCTAssertNotEqual(data.oAuthKeyData?.evmAddress, "") @@ -90,7 +90,7 @@ final class SapphireDevnetTest: XCTestCase { let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - let data = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeSSSEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID, extendedVerifierId: tssVerifierID) + let data = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeSSSEndpoints(), verifier: verifier, verifierId: verifierID, extendedVerifierId: tssVerifierID) XCTAssertNotEqual(data.finalKeyData?.evmAddress, "") XCTAssertNotEqual(data.oAuthKeyData?.evmAddress, "") @@ -108,7 +108,7 @@ final class SapphireDevnetTest: XCTestCase { let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - let val = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeSSSEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID, extendedVerifierId: tssVerifierID) + let val = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeSSSEndpoints(), verifier: verifier, verifierId: verifierID, extendedVerifierId: tssVerifierID) XCTAssertLessThan(val.metadata!.serverTimeOffset, 20) @@ -152,7 +152,7 @@ final class SapphireDevnetTest: XCTestCase { let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - let val = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeSSSEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + let val = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeSSSEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertLessThan(val.metadata!.serverTimeOffset, 20) @@ -177,7 +177,7 @@ final class SapphireDevnetTest: XCTestCase { let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - let val = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeSSSEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + let val = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeSSSEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertLessThan(val.metadata!.serverTimeOffset, 20) diff --git a/Tests/TorusUtilsTests/SapphireMainnetTests.swift b/Tests/TorusUtilsTests/SapphireMainnetTests.swift index 656afbc5..994d2dfd 100644 --- a/Tests/TorusUtilsTests/SapphireMainnetTests.swift +++ b/Tests/TorusUtilsTests/SapphireMainnetTests.swift @@ -33,7 +33,7 @@ class SapphireMainnetTests: XCTestCase { let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - let val = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + let val = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertEqual(val.oAuthKeyData!.evmAddress, "0xb1a49C6E50a1fC961259a8c388EAf5953FA5152b") XCTAssertEqual(val.oAuthKeyData!.X, "a9f5a463aefb16e90f4cbb9de4a5b6b7f6c6a3831cefa0f20cccb9e7c7b01c20") @@ -76,7 +76,7 @@ class SapphireMainnetTests: XCTestCase { let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - let data = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + let data = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertNotEqual(data.finalKeyData?.evmAddress, "") XCTAssertNotEqual(data.oAuthKeyData?.evmAddress, "") @@ -94,7 +94,7 @@ class SapphireMainnetTests: XCTestCase { let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - let data = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeSSSEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID, extendedVerifierId: tssVerifierID) + let data = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeSSSEndpoints(), verifier: verifier, verifierId: verifierID, extendedVerifierId: tssVerifierID) XCTAssertNotEqual(data.finalKeyData?.evmAddress, "") XCTAssertNotEqual(data.oAuthKeyData?.evmAddress, "") @@ -112,7 +112,7 @@ class SapphireMainnetTests: XCTestCase { let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - let val = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeSSSEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID, extendedVerifierId: tssVerifierID) + let val = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeSSSEndpoints(), verifier: verifier, verifierId: verifierID, extendedVerifierId: tssVerifierID) XCTAssertLessThan(val.metadata!.serverTimeOffset, 20) @@ -156,7 +156,7 @@ class SapphireMainnetTests: XCTestCase { let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - let val = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeSSSEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + let val = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeSSSEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertLessThan(val.metadata!.serverTimeOffset, 20) @@ -181,7 +181,7 @@ class SapphireMainnetTests: XCTestCase { let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - let val = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeSSSEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + let val = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeSSSEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertLessThan(val.metadata!.serverTimeOffset, 20) diff --git a/Tests/TorusUtilsTests/TestnetTest.swift b/Tests/TorusUtilsTests/TestnetTest.swift index f1407e0b..8492b452 100644 --- a/Tests/TorusUtilsTests/TestnetTest.swift +++ b/Tests/TorusUtilsTests/TestnetTest.swift @@ -21,7 +21,7 @@ class TestnetTest: XCTestCase { let verifier = "google-lrc" let verifierID = TORUS_TEST_EMAIL let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - let val = try await torus.getPublicAddress(endpoints: nodeDetails.torusNodeEndpoints, torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + let val = try await torus.getPublicAddress(endpoints: nodeDetails.torusNodeEndpoints, verifier: verifier, verifierId: verifierID) XCTAssertEqual(val.finalKeyData!.evmAddress, "0x9bcBAde70546c0796c00323CD1b97fa0a425A506") XCTAssertLessThan(val.metadata!.serverTimeOffset, 20) @@ -43,7 +43,7 @@ class TestnetTest: XCTestCase { var verifier: String = "google-lrc" var verifierID: String = TORUS_TEST_EMAIL let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - var val = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + var val = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertEqual(val.finalKeyData!.evmAddress, "0xf5804f608C233b9cdA5952E46EB86C9037fd6842") XCTAssertLessThan(val.metadata!.serverTimeOffset, 20) @@ -61,7 +61,7 @@ class TestnetTest: XCTestCase { verifier = "tkey-google-lrc" verifierID = "somev2user@gmail.com" - val = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + val = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertEqual(val.finalKeyData!.evmAddress, "0xE91200d82029603d73d6E307DbCbd9A7D0129d8D") XCTAssertLessThan(val.metadata!.serverTimeOffset, 20) @@ -81,7 +81,7 @@ class TestnetTest: XCTestCase { verifier = "tkey-google-lrc" verifierID = "caspertorus@gmail.com" - val = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + val = try await torus.getUserTypeAndAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertEqual(val.finalKeyData!.evmAddress, "0x1016DA7c47A04C76036637Ea02AcF1d29c64a456") XCTAssertLessThan(val.metadata!.serverTimeOffset, 20) @@ -105,7 +105,7 @@ class TestnetTest: XCTestCase { let verifier: String = "google-lrc" let verifierID: String = fakeEmail let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - let data = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + let data = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertNotEqual(data.finalKeyData?.evmAddress, "") XCTAssertNotEqual(data.oAuthKeyData?.evmAddress, "") XCTAssertEqual(data.metadata?.typeOfUser, .v1) diff --git a/Tests/TorusUtilsTests/oneKeyTest.swift b/Tests/TorusUtilsTests/oneKeyTest.swift index 18ed46a5..3a395cf2 100644 --- a/Tests/TorusUtilsTests/oneKeyTest.swift +++ b/Tests/TorusUtilsTests/oneKeyTest.swift @@ -21,7 +21,7 @@ class OneKeyTest: XCTestCase { let verifier = "google-lrc" let verifierID = "himanshu@tor.us" let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - let data = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + let data = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertLessThan(data.metadata!.serverTimeOffset, 20) XCTAssertEqual(data.finalKeyData?.evmAddress, "0x930abEDDCa6F9807EaE77A3aCc5c78f20B168Fd1") @@ -104,7 +104,7 @@ class OneKeyTest: XCTestCase { let verifier: String = TORUS_TEST_VERIFIER let verifierID: String = fakeEmail let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - let data = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), torusNodePubs: nodeDetails.getTorusNodePub(), verifier: verifier, verifierId: verifierID) + let data = try await torus.getPublicAddress(endpoints: nodeDetails.getTorusNodeEndpoints(), verifier: verifier, verifierId: verifierID) XCTAssertEqual(data.metadata?.typeOfUser, .v2) XCTAssertEqual(data.metadata?.upgraded, false)