Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set client Id and call allowHost #70

Merged
merged 5 commits into from
Nov 10, 2023
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
2 changes: 1 addition & 1 deletion Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"repositoryURL": "https://github.com/torusresearch/fetch-node-details-swift.git",
"state": {
"branch": null,
"revision": "4a887d3895d4a07d40aad4b315744db32f3a0d60",
"revision": "d591af500f32ce3c88d04af9bb74d746585acfea",
"version": "5.1.0"
}
},
Expand Down
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")
metalurgical marked this conversation as resolved.
Show resolved Hide resolved
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
Loading