Skip to content

Commit

Permalink
Merge pull request #70 from torusresearch/feat/allowHost-req
Browse files Browse the repository at this point in the history
fix: set client Id and call allowHost
  • Loading branch information
chaitanyapotti committed Nov 10, 2023
2 parents b7e4eff + eb54617 commit 124bb10
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Sources/TorusUtils/TorusUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,23 @@ open class TorusUtils: AbstractTorusUtils {
idToken: String,
extraParams: [String: Codable] = [:]
) async throws -> TorusKey {
let session = createURLSession()
var allowHostRequest = try makeUrlRequest(url: allowHost, httpMethod: .get)
allowHostRequest.addValue("torus-default", forHTTPHeaderField: "x-api-key")
allowHostRequest.addValue(verifier, forHTTPHeaderField: "origin")
allowHostRequest.addValue(verifier, forHTTPHeaderField: "verifier")
allowHostRequest.addValue(verifierParams.verifier_id, forHTTPHeaderField: "verifier_id")
allowHostRequest.addValue(verifierParams.verifier_id, forHTTPHeaderField: "verifierId")
allowHostRequest.addValue(clientId, forHTTPHeaderField: "clientId")
allowHostRequest.addValue(network.name, forHTTPHeaderField: "network")
allowHostRequest.addValue("true", forHTTPHeaderField: "enable_gating")
do {
_ = try await session.data(for: allowHostRequest)
} catch {
os_log("retrieveShares: signer allow: %@", log: getTorusLogger(log: TorusUtilsLogger.core, type: .error), type: .error, error.localizedDescription)
throw error
}

if isLegacyNetwork() {
let result = try await legacyRetrieveShares(torusNodePubs: torusNodePubs, indexes: indexes, endpoints: endpoints, verifier: verifier, verifierId: verifierParams.verifier_id, idToken: idToken, extraParams: extraParams)
return result
Expand Down

0 comments on commit 124bb10

Please sign in to comment.