Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ let package = Package(
targets: ["CustomAuth"])
],
dependencies: [
.package(url: "https://github.com/torusresearch/torus-utils-swift.git", from: "8.0.0"),
.package(url: "https://github.com/torusresearch/torus-utils-swift.git", from: "8.0.2"),
.package(name: "jwt-kit", url: "https://github.com/vapor/jwt-kit.git", from: "4.13.0"),
.package(name: "JWTDecode", url: "https://github.com/auth0/JWTDecode.swift.git", from: "3.1.0")
.package(name: "JWTDecode", url: "https://github.com/auth0/JWTDecode.swift.git", from: "3.1.0"),
.package(url: "https://github.com/tkey/curvelib.swift", from: "1.0.0"),
],
targets: [
.target(
name: "CustomAuth",
dependencies: ["JWTDecode", .product(name: "TorusUtils", package: "torus-utils-swift")]),
dependencies: ["JWTDecode", .product(name: "curveSecp256k1", package: "curvelib.swift"), .product(name: "TorusUtils", package: "torus-utils-swift")]),
.testTarget(
name: "CustomAuthTests",
dependencies: ["CustomAuth", .product(name: "JWTKit", package: "jwt-kit")])
Expand Down
5 changes: 3 additions & 2 deletions Sources/CustomAuth/CustomAuth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation
import OSLog
import TorusUtils
import UIKit
import curveSecp256k1
import CommonSources

// Global variable
Expand Down Expand Up @@ -245,15 +246,15 @@ open class CustomAuth {
/// - Returns: A promise that resolve with a Dictionary that contain at least `privateKey` and `publicAddress` field..
open func getAggregateTorusKey(verifier: String, verifierId: String, idToken: String, subVerifierDetails: SubVerifierDetails, userData: [String: Any] = [:]) async throws -> TorusKey {
let extraParams = ["verifieridentifier": verifier, "verifier_id": verifierId, "sub_verifier_ids": [subVerifierDetails.verifier], "verify_params": [["verifier_id": verifierId, "idtoken": idToken]]] as [String: Codable]
let hashedOnce = idToken.sha3(.keccak256)
let hashedOnce = try keccak256(data: Data(idToken.utf8))

let verifierParams = VerifierParams(verifier_id: verifierId)

do {
let nodeDetails = try await getNodeDetailsFromContract(verifier: verifier, verfierID: verifierId)

// retrieveShares internall checks if network is legacy and calls getPublicAddress if required.
let responseFromRetrieveShares :TorusKey = try await self.torusUtils.retrieveShares(endpoints: nodeDetails.torusNodeEndpoints, torusNodePubs: nodeDetails.torusNodePub, indexes: nodeDetails.torusIndexes, verifier: verifier, verifierParams: verifierParams, idToken: hashedOnce, extraParams: extraParams)
let responseFromRetrieveShares :TorusKey = try await self.torusUtils.retrieveShares(endpoints: nodeDetails.torusNodeEndpoints, torusNodePubs: nodeDetails.torusNodePub, indexes: nodeDetails.torusIndexes, verifier: verifier, verifierParams: verifierParams, idToken: hashedOnce.toHexString(), extraParams: extraParams)

return responseFromRetrieveShares
} catch {
Expand Down
2 changes: 0 additions & 2 deletions Tests/CustomAuthTests/StubURLProtocolTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ public class StubMockTorusUtils: TorusUtils {

open func generatePrivateKeyData() -> Data? {
let ret = Data(base64Encoded: "FBz7bssmbsV6jBWoOJpkVOu14+6/Xgyt1pxTycODG08=")

print("[StubMockTorusUtils] generatePrivateKeyData(): ", ret!.bytes.toBase64())
return ret
}
}
Expand Down