From 61dd7d3b266c5675cc7f5b824d5c46190babe2b5 Mon Sep 17 00:00:00 2001 From: ieow Date: Fri, 6 Oct 2023 10:13:41 +0800 Subject: [PATCH 1/3] fix: set client Id and call allowHost --- Sources/TorusUtils/TorusUtils.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Sources/TorusUtils/TorusUtils.swift b/Sources/TorusUtils/TorusUtils.swift index aa29bdae..0bc02bf2 100644 --- a/Sources/TorusUtils/TorusUtils.swift +++ b/Sources/TorusUtils/TorusUtils.swift @@ -72,7 +72,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: "VerifierId") + allowHostRequest.addValue(self.clientId, forHTTPHeaderField: "ClientId") + allowHostRequest.addValue(network.name, forHTTPHeaderField: "Network") + + 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 (self.isLegacyNetwork()) { let result = try await legacyRetrieveShares(torusNodePubs: torusNodePubs, indexes: indexes, endpoints: endpoints, verifier: verifier, verifierId: verifierParams.verifier_id, idToken: idToken, extraParams: extraParams) return result From 6868015f891453876ba908eb1ae654a9dde3b0b9 Mon Sep 17 00:00:00 2001 From: metalurgical <97008724+metalurgical@users.noreply.github.com> Date: Wed, 1 Nov 2023 13:23:13 +0200 Subject: [PATCH 2/3] fix: header field capitalization --- Sources/TorusUtils/TorusUtils.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Sources/TorusUtils/TorusUtils.swift b/Sources/TorusUtils/TorusUtils.swift index f892188f..243f2f7b 100644 --- a/Sources/TorusUtils/TorusUtils.swift +++ b/Sources/TorusUtils/TorusUtils.swift @@ -66,12 +66,12 @@ open class TorusUtils: AbstractTorusUtils { 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: "VerifierId") - allowHostRequest.addValue(self.clientId, forHTTPHeaderField: "ClientId") - allowHostRequest.addValue(network.name, forHTTPHeaderField: "Network") + 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") do { _ = try await session.data(for: allowHostRequest) From eb5461720fce2ea54e936ca930b949aebf194ad1 Mon Sep 17 00:00:00 2001 From: metalurgical <97008724+metalurgical@users.noreply.github.com> Date: Wed, 1 Nov 2023 20:38:33 +0200 Subject: [PATCH 3/3] review comment --- Package.resolved | 2 +- Sources/TorusUtils/TorusUtils.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Package.resolved b/Package.resolved index 283fc734..79bfbfb3 100644 --- a/Package.resolved +++ b/Package.resolved @@ -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" } }, diff --git a/Sources/TorusUtils/TorusUtils.swift b/Sources/TorusUtils/TorusUtils.swift index 243f2f7b..5fa7a6a2 100644 --- a/Sources/TorusUtils/TorusUtils.swift +++ b/Sources/TorusUtils/TorusUtils.swift @@ -72,7 +72,7 @@ open class TorusUtils: AbstractTorusUtils { 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 {