diff --git a/Sources/TorusUtils/Helpers/jsonRPC/Requests/ShareRequestParams.swift b/Sources/TorusUtils/Helpers/jsonRPC/Requests/ShareRequestParams.swift index 39c76c61..ba0e594a 100644 --- a/Sources/TorusUtils/Helpers/jsonRPC/Requests/ShareRequestParams.swift +++ b/Sources/TorusUtils/Helpers/jsonRPC/Requests/ShareRequestParams.swift @@ -1,15 +1,6 @@ import Foundation public struct ShareRequestParams: Codable { - public struct ShareRequestVerifyParams: Codable { - public var verifier_id: String? - public var idtoken: String? - - public init(verifier_id: String?, idtoken: String?) { - self.verifier_id = verifier_id - self.idtoken = idtoken - } - } public struct ShareRequestItem: Codable { public var verifieridentifier: String public var verifier_id: String? @@ -27,7 +18,7 @@ public struct ShareRequestParams: Codable { // [key: string]: unknown; ?? Needs to be strongly typed in javascript public var sub_verifier_ids: [String]? public var session_token_exp_second: Int? - public var verify_params: [ShareRequestParams.ShareRequestVerifyParams?]? + public var verify_params: [VerifyParams?]? } public var encrypted: String = "yes" public var item: [ShareRequestItem] diff --git a/Sources/TorusUtils/VerifierParams.swift b/Sources/TorusUtils/VerifierParams.swift index 1c2057bc..0c8f02c4 100644 --- a/Sources/TorusUtils/VerifierParams.swift +++ b/Sources/TorusUtils/VerifierParams.swift @@ -1,13 +1,23 @@ import Foundation +public struct VerifyParams: Codable { + public var verifier_id: String? + public var idtoken: String? + + public init(verifier_id: String?, idtoken: String?) { + self.verifier_id = verifier_id + self.idtoken = idtoken + } +} + public struct VerifierParams { // [key: string]: unknown; ?? Needs to be strongly typed in javascript public let verifier_id: String public let extended_verifier_id: String? public let sub_verifier_ids: [String]? - public let verify_params: [ShareRequestParams.ShareRequestVerifyParams]? + public let verify_params: [VerifyParams]? - public init(verifier_id: String, extended_verifier_id: String? = nil, sub_verifier_ids: [String]? = nil, verify_params: [ShareRequestParams.ShareRequestVerifyParams]? = nil) { + public init(verifier_id: String, extended_verifier_id: String? = nil, sub_verifier_ids: [String]? = nil, verify_params: [VerifyParams]? = nil) { self.verifier_id = verifier_id self.extended_verifier_id = extended_verifier_id self.sub_verifier_ids = sub_verifier_ids diff --git a/Tests/TorusUtilsTests/AquaTest.swift b/Tests/TorusUtilsTests/AquaTest.swift index f4f13cd5..f0762598 100644 --- a/Tests/TorusUtilsTests/AquaTest.swift +++ b/Tests/TorusUtilsTests/AquaTest.swift @@ -148,7 +148,7 @@ class AquaTest: XCTestCase { let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - let verifierParams = VerifierParams(verifier_id: verifierID, sub_verifier_ids: [TORUS_TEST_VERIFIER], verify_params: [ShareRequestParams.ShareRequestVerifyParams(verifier_id: TORUS_TEST_EMAIL, idtoken: jwt)]) + let verifierParams = VerifierParams(verifier_id: verifierID, sub_verifier_ids: [TORUS_TEST_VERIFIER], verify_params: [VerifyParams(verifier_id: TORUS_TEST_EMAIL, idtoken: jwt)]) let data = try await torus.retrieveShares(endpoints: nodeDetails.getTorusNodeEndpoints(), indexes: nodeDetails.getTorusIndexes(), verifier: verifier, verifierParams: verifierParams, idToken: hashedIDToken) XCTAssertEqual(data.finalKeyData.evmAddress, "0x5b58d8a16fDA79172cd42Dc3068d5CEf26a5C81D") diff --git a/Tests/TorusUtilsTests/Celeste.swift b/Tests/TorusUtilsTests/Celeste.swift index 134331f3..ee163176 100644 --- a/Tests/TorusUtilsTests/Celeste.swift +++ b/Tests/TorusUtilsTests/Celeste.swift @@ -148,7 +148,7 @@ class CelesteTest: XCTestCase { let hashedIDToken = try KeyUtils.keccak256Data(jwt) let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - let verifierParams = VerifierParams(verifier_id: verifierID, sub_verifier_ids: [TORUS_TEST_VERIFIER], verify_params: [ShareRequestParams.ShareRequestVerifyParams(verifier_id: verifierID, idtoken: jwt)]) + let verifierParams = VerifierParams(verifier_id: verifierID, sub_verifier_ids: [TORUS_TEST_VERIFIER], verify_params: [VerifyParams(verifier_id: verifierID, idtoken: jwt)]) let data = try await torus.retrieveShares(endpoints: nodeDetails.torusNodeEndpoints, indexes: nodeDetails.getTorusIndexes(), verifier: verifier, verifierParams: verifierParams, idToken: hashedIDToken) XCTAssertEqual(data.finalKeyData.evmAddress, "0x535Eb1AefFAc6f699A2a1A5846482d7b5b2BD564") diff --git a/Tests/TorusUtilsTests/CyanTest.swift b/Tests/TorusUtilsTests/CyanTest.swift index 695b89f3..7c15da2a 100644 --- a/Tests/TorusUtilsTests/CyanTest.swift +++ b/Tests/TorusUtilsTests/CyanTest.swift @@ -144,7 +144,7 @@ class CyanTest: XCTestCase { let verifier: String = TORUS_TEST_AGGREGATE_VERIFIER let verifierID: String = TORUS_TEST_EMAIL let jwt = try! generateIdToken(email: TORUS_TEST_EMAIL) - let verifierParams = VerifierParams(verifier_id: verifierID, sub_verifier_ids: [TORUS_TEST_VERIFIER], verify_params: [ShareRequestParams.ShareRequestVerifyParams(verifier_id: TORUS_TEST_EMAIL, idtoken: jwt)]) + let verifierParams = VerifierParams(verifier_id: verifierID, sub_verifier_ids: [TORUS_TEST_VERIFIER], verify_params: [VerifyParams(verifier_id: TORUS_TEST_EMAIL, idtoken: jwt)]) let hashedIDToken = try KeyUtils.keccak256Data(jwt) let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) diff --git a/Tests/TorusUtilsTests/MainnetTest.swift b/Tests/TorusUtilsTests/MainnetTest.swift index 2eb21f5f..b83d690f 100644 --- a/Tests/TorusUtilsTests/MainnetTest.swift +++ b/Tests/TorusUtilsTests/MainnetTest.swift @@ -156,7 +156,7 @@ class MainnetTests: XCTestCase { let hashedIDToken = try KeyUtils.keccak256Data(jwt) let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) - let verifierParams = VerifierParams(verifier_id: verifierID, sub_verifier_ids: [TORUS_TEST_VERIFIER], verify_params: [ShareRequestParams.ShareRequestVerifyParams(verifier_id: verifierID, idtoken: jwt)]) + let verifierParams = VerifierParams(verifier_id: verifierID, sub_verifier_ids: [TORUS_TEST_VERIFIER], verify_params: [VerifyParams(verifier_id: verifierID, idtoken: jwt)]) let data = try await torus.retrieveShares(endpoints: nodeDetails.torusNodeEndpoints, indexes: nodeDetails.getTorusIndexes(), verifier: verifier, verifierParams: verifierParams, idToken: hashedIDToken) XCTAssertEqual(data.finalKeyData.evmAddress, "0x621a4d458cFd345dAE831D9E756F10cC40A50381") diff --git a/Tests/TorusUtilsTests/SapphireDevnetTest.swift b/Tests/TorusUtilsTests/SapphireDevnetTest.swift index 87884839..e0015aa6 100644 --- a/Tests/TorusUtilsTests/SapphireDevnetTest.swift +++ b/Tests/TorusUtilsTests/SapphireDevnetTest.swift @@ -258,7 +258,7 @@ final class SapphireDevnetTest: XCTestCase { let email: String = generateRandomEmail(of: 6) let jwt = try! generateIdToken(email: email) let hashedIDToken = try KeyUtils.keccak256Data(jwt) - let verifierParams = VerifierParams(verifier_id: email, sub_verifier_ids: [TORUS_TEST_VERIFIER], verify_params: [ShareRequestParams.ShareRequestVerifyParams(verifier_id: email, idtoken: jwt)]) + let verifierParams = VerifierParams(verifier_id: email, sub_verifier_ids: [TORUS_TEST_VERIFIER], verify_params: [VerifyParams(verifier_id: email, idtoken: jwt)]) let nodeDetails = try await fnd.getNodeDetails(verifier: TORUS_TEST_AGGREGATE_VERIFIER, verifierID: email) let data = try await torus.retrieveShares(endpoints: nodeDetails.getTorusNodeSSSEndpoints(), indexes: nodeDetails.getTorusIndexes(), verifier: TORUS_TEST_AGGREGATE_VERIFIER, verifierParams: verifierParams, idToken: hashedIDToken) diff --git a/Tests/TorusUtilsTests/SapphireMainnetTests.swift b/Tests/TorusUtilsTests/SapphireMainnetTests.swift index 994d2dfd..0225ffe1 100644 --- a/Tests/TorusUtilsTests/SapphireMainnetTests.swift +++ b/Tests/TorusUtilsTests/SapphireMainnetTests.swift @@ -261,7 +261,7 @@ class SapphireMainnetTests: XCTestCase { let email: String = generateRandomEmail(of: 6) let jwt = try! generateIdToken(email: email) let hashedIDToken = try KeyUtils.keccak256Data(jwt) - let verifierParams = VerifierParams(verifier_id: email, sub_verifier_ids: [TORUS_TEST_VERIFIER], verify_params: [ShareRequestParams.ShareRequestVerifyParams(verifier_id: email, idtoken: jwt)]) + let verifierParams = VerifierParams(verifier_id: email, sub_verifier_ids: [TORUS_TEST_VERIFIER], verify_params: [VerifyParams(verifier_id: email, idtoken: jwt)]) let nodeDetails = try await fnd.getNodeDetails(verifier: TORUS_TEST_AGGREGATE_VERIFIER, verifierID: email) diff --git a/Tests/TorusUtilsTests/TestnetTest.swift b/Tests/TorusUtilsTests/TestnetTest.swift index 8492b452..39d18e91 100644 --- a/Tests/TorusUtilsTests/TestnetTest.swift +++ b/Tests/TorusUtilsTests/TestnetTest.swift @@ -149,7 +149,7 @@ class TestnetTest: XCTestCase { let verifierParams = VerifierParams(verifier_id: verifierID, sub_verifier_ids: [TORUS_TEST_VERIFIER], - verify_params: [ShareRequestParams.ShareRequestVerifyParams(verifier_id: verifierID, idtoken: jwt)]) + verify_params: [VerifyParams(verifier_id: verifierID, idtoken: jwt)]) let data = try await torus.retrieveShares(endpoints: nodeDetails.torusNodeEndpoints, indexes: nodeDetails.getTorusIndexes(), verifier: verifier, verifierParams: verifierParams, idToken: hashedIDToken) XCTAssertEqual(data.finalKeyData.evmAddress, "0x938a40E155d118BD31E439A9d92D67bd55317965") diff --git a/Tests/TorusUtilsTests/oneKeyTest.swift b/Tests/TorusUtilsTests/oneKeyTest.swift index 3a395cf2..4a5d7af8 100644 --- a/Tests/TorusUtilsTests/oneKeyTest.swift +++ b/Tests/TorusUtilsTests/oneKeyTest.swift @@ -73,7 +73,7 @@ class OneKeyTest: XCTestCase { let verifier: String = TORUS_TEST_AGGREGATE_VERIFIER let verifierID: String = TORUS_TEST_EMAIL let jwt = try! generateIdToken(email: TORUS_TEST_EMAIL) - let verifierParams = VerifierParams(verifier_id: verifierID, sub_verifier_ids: [TORUS_TEST_VERIFIER], verify_params: [ShareRequestParams.ShareRequestVerifyParams(verifier_id: TORUS_TEST_EMAIL, idtoken: jwt)]) + let verifierParams = VerifierParams(verifier_id: verifierID, sub_verifier_ids: [TORUS_TEST_VERIFIER], verify_params: [VerifyParams(verifier_id: TORUS_TEST_EMAIL, idtoken: jwt)]) let hashedIDToken = try KeyUtils.keccak256Data(jwt) let nodeDetails = try await fnd.getNodeDetails(verifier: verifier, verifierID: verifierID) let data = try await torus.retrieveShares(endpoints: nodeDetails.getTorusNodeEndpoints(), indexes: nodeDetails.getTorusIndexes(), verifier: verifier, verifierParams: verifierParams, idToken: hashedIDToken)