From d3ba2f7839d5fb723719aa3229396fa5782b7606 Mon Sep 17 00:00:00 2001 From: metalurgical <97008724+metalurgical@users.noreply.github.com> Date: Tue, 14 May 2024 11:27:30 +0200 Subject: [PATCH] Update SapphireDevnetTest.swift --- .../TorusUtilsTests/SapphireDevnetTest.swift | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Tests/TorusUtilsTests/SapphireDevnetTest.swift b/Tests/TorusUtilsTests/SapphireDevnetTest.swift index 2526067a..5c42841d 100644 --- a/Tests/TorusUtilsTests/SapphireDevnetTest.swift +++ b/Tests/TorusUtilsTests/SapphireDevnetTest.swift @@ -23,6 +23,25 @@ final class SapphireDevnetTest: XCTestCase { torus = TorusUtils(params: TorusOptions(clientId: "YOUR_CLIENT_ID", network: .sapphire(.SAPPHIRE_DEVNET))) } + func test_should_be_able_to_aggregate_login() async throws { + let email: String = generateRandomEmail(of: 6) + let jwt = try! generateIdToken(email: email) + let hashedIDToken = try KeyUtils.keccak256Data(jwt) + let verifierParams = VerifierParams(verifier_id: email) + + let nodeDetails = try await fnd.getNodeDetails(verifier: TORUS_TEST_AGGREGATE_VERIFIER, verifierID: email) + let extraParams = [ + "verify_params": [ShareRequestParams.ShareRequestVerifyParams(verifier_id: email, idtoken: jwt)], + "sub_verifier_ids": [TORUS_TEST_VERIFIER], + ] as [String: Codable] + let data = try await torus.retrieveShares(endpoints: nodeDetails.getTorusNodeSSSEndpoints(), indexes: nodeDetails.getTorusIndexes(), verifier: TORUS_TEST_AGGREGATE_VERIFIER, verifierParams: verifierParams, idToken: hashedIDToken, extraParams: extraParams) + + XCTAssertLessThan(data.metadata.serverTimeOffset, 20) + XCTAssertNotNil(data.finalKeyData.privKey) + XCTAssertNotNil(data.oAuthKeyData.evmAddress) + XCTAssertEqual(data.metadata.typeOfUser, .v2) + } + // NB!!! // Note: Some javascript tests are wrong, they should be using .sapphire(.SAPPHIRE_DEVNET) // and not .legacy(.TESTNET)