Skip to content

Commit 9d35eca

Browse files
Merge pull request #58 from torusresearch/add-usertype-and-nonce
add usertype and nonce
2 parents a894ed8 + 6542dbc commit 9d35eca

File tree

5 files changed

+19
-12
lines changed

5 files changed

+19
-12
lines changed

Package.resolved

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ let package = Package(
1414
targets: ["CustomAuth"])
1515
],
1616
dependencies: [
17-
.package(name: "TorusUtils", url: "https://github.com/torusresearch/torus-utils-swift.git", from: "5.0.0"),
17+
.package(name: "TorusUtils", url: "https://github.com/torusresearch/torus-utils-swift.git", from: "5.1.1"),
1818
.package(name: "jwt-kit", url: "https://github.com/vapor/jwt-kit.git", from: "4.0.0"),
1919
.package(name: "JWTDecode", url: "https://github.com/auth0/JWTDecode.swift.git", from: "3.0.1")
2020
],

Sources/CustomAuth/CustomAuth.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var tsSdkLogType = OSLogType.default
1717
/// Provides integration of an iOS app with Torus CustomAuth.
1818
open class CustomAuth {
1919
let factory: CASDKFactoryProtocol
20-
var torusUtils: AbstractTorusUtils
20+
public var torusUtils: AbstractTorusUtils
2121
let fetchNodeDetails: FetchNodeDetails
2222
var urlSession: URLSession
2323
var enableOneKey: Bool
@@ -192,6 +192,8 @@ open class CustomAuth {
192192
var data = userData
193193
data["privateKey"] = responseFromRetrieveShares.privateKey
194194
data["publicAddress"] = responseFromRetrieveShares.publicAddress
195+
data["nonce"] = responseFromRetrieveShares.nonce
196+
data["typeOfUser"] = responseFromRetrieveShares.typeOfUser
195197
return data
196198
} catch {
197199
os_log("handleSingleLogin: err: %s", log: getTorusLogger(log: CASDKLogger.core, type: .error), type: .error, error.localizedDescription)

Tests/CustomAuthTests/IntegrationTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ final class IntegrationTests: XCTestCase {
3333
let email = "[email protected]"
3434
let jwt = try! generateIdToken(email: email)
3535
do {
36-
let data = try await IntegrationTests.sdk?.getTorusKey(verifier: TORUS_TEST_VERIFIER, verifierId: email, idToken: jwt)
36+
let data = try await IntegrationTests.sdk?.getTorusKey(verifier: TORUS_TEST_VERIFIER, verifierId: email, idToken: jwt)
3737
XCTAssertEqual(data?["publicAddress"] as! String, "0x8AA6C8ddCD868873120aA265Fc63E3a2180375BA")
3838
exp1.fulfill()
3939
} catch {

Tests/CustomAuthTests/MockTorusUtils.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import CustomAuth
22
import FetchNodeDetails
33
import Foundation
4+
import BigInt
45
@testable import TorusUtils
56

67
// Added so the that we can assign values later.
@@ -18,7 +19,7 @@ class MockTorusUtils: AbstractTorusUtils, MockAbstractTorusUtils {
1819
"idToken": idToken,
1920
"extraParams": extraParams
2021
]
21-
return .init(publicKey: retrieveShares_output["publicAddress"] ?? "", privateKey: retrieveShares_output["privateKey"] ?? "")
22+
return .init(publicKey: retrieveShares_output["publicAddress"] ?? "", privateKey: retrieveShares_output["privateKey"] ?? "", nonce: BigUInt(0), typeOfUser: .v1)
2223
}
2324

2425
func getPublicAddress(endpoints: [String], torusNodePubs: [TorusNodePubModel], verifier: String, verifierId: String, isExtended: Bool) async throws -> GetPublicAddressModel {
@@ -63,4 +64,8 @@ class MockTorusUtils: AbstractTorusUtils, MockAbstractTorusUtils {
6364
]
6465
return retrieveShares_output
6566
}
67+
68+
func getPostBoxKey(torusKey: RetrieveSharesResponseModel) -> String {
69+
return ""
70+
}
6671
}

0 commit comments

Comments
 (0)