Skip to content

Commit

Permalink
Merge pull request #1326 from WalletConnect/cocoapods-fix
Browse files Browse the repository at this point in the history
Cocoapods fix
  • Loading branch information
llbartekll authored Mar 19, 2024
2 parents 4bf498e + 185f34f commit ad6cf95
Show file tree
Hide file tree
Showing 22 changed files with 39 additions and 43 deletions.
6 changes: 3 additions & 3 deletions Sources/Auth/AuthClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ public class AuthClient: AuthClientProtocol {
private let appRespondSubscriber: AppRespondSubscriber
private let walletRequestSubscriber: WalletRequestSubscriber
private let walletRespondService: WalletRespondService
private let pendingRequestsProvider: PendingRequestsProvider
private let pendingRequestsProvider: Auth_PendingRequestsProvider

init(appRequestService: AppRequestService,
appRespondSubscriber: AppRespondSubscriber,
walletRequestSubscriber: WalletRequestSubscriber,
walletRespondService: WalletRespondService,
pendingRequestsProvider: PendingRequestsProvider,
pendingRequestsProvider: Auth_PendingRequestsProvider,
logger: ConsoleLogging,
socketConnectionStatusPublisher: AnyPublisher<SocketConnectionStatus, Never>,
pairingRegisterer: PairingRegisterer
Expand Down Expand Up @@ -102,7 +102,7 @@ public class AuthClient: AuthClientProtocol {
}

@available(*, deprecated, message: "Use SignClient or Web3Wallet for message formatting.")
public func formatMessage(payload: AuthPayload, address: String) throws -> String {
public func formatMessage(payload: AuthPayloadStruct, address: String) throws -> String {
return try SIWEFromCacaoPayloadFormatter().formatMessage(from: payload.cacaoPayload(address: address))
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/Auth/AuthClientFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ public struct AuthClientFactory {
let messageVerifierFactory = MessageVerifierFactory(crypto: crypto)
let signatureVerifier = messageVerifierFactory.create(projectId: projectId)
let appRespondSubscriber = AppRespondSubscriber(networkingInteractor: networkingClient, logger: logger, rpcHistory: history, signatureVerifier: signatureVerifier, pairingRegisterer: pairingRegisterer, messageFormatter: messageFormatter)
let walletErrorResponder = WalletErrorResponder(networkingInteractor: networkingClient, logger: logger, kms: kms, rpcHistory: history)
let walletErrorResponder = Auth_WalletErrorResponder(networkingInteractor: networkingClient, logger: logger, kms: kms, rpcHistory: history)
let walletRequestSubscriber = WalletRequestSubscriber(networkingInteractor: networkingClient, logger: logger, kms: kms, walletErrorResponder: walletErrorResponder, pairingRegisterer: pairingRegisterer, verifyClient: verifyClient, verifyContextStore: verifyContextStore)
let walletRespondService = WalletRespondService(networkingInteractor: networkingClient, logger: logger, kms: kms, rpcHistory: history, verifyContextStore: verifyContextStore, walletErrorResponder: walletErrorResponder, pairingRegisterer: pairingRegisterer)
let pendingRequestsProvider = PendingRequestsProvider(rpcHistory: history, verifyContextStore: verifyContextStore)
let pendingRequestsProvider = Auth_PendingRequestsProvider(rpcHistory: history, verifyContextStore: verifyContextStore)

return AuthClient(
appRequestService: appRequestService,
Expand Down
2 changes: 1 addition & 1 deletion Sources/Auth/AuthClientProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Combine
public protocol AuthClientProtocol {
var authRequestPublisher: AnyPublisher<(request: AuthRequest, context: VerifyContext?), Never> { get }

func formatMessage(payload: AuthPayload, address: String) throws -> String
func formatMessage(payload: AuthPayloadStruct, address: String) throws -> String
func respond(requestId: RPCID, signature: CacaoSignature, from account: Account) async throws
func reject(requestId: RPCID) async throws
func getPendingRequests() throws -> [(AuthRequest, VerifyContext?)]
Expand Down
4 changes: 2 additions & 2 deletions Sources/Auth/AuthDecryptionService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class AuthDecryptionService {
public func decryptAuthRequest(topic: String, ciphertext: String) throws -> AuthRequest {
let (rpcRequest, _, _): (RPCRequest, String?, Data) = try serializer.deserialize(topic: topic, encodedEnvelope: ciphertext)
setPairingMetadata(rpcRequest: rpcRequest, topic: topic)
if let params = try rpcRequest.params?.get(AuthRequestParams.self),
if let params = try rpcRequest.params?.get(Auth_RequestParams.self),
let id = rpcRequest.id {
let authRequest = AuthRequest(id: id, topic: topic, payload: params.payloadParams, requester: params.requester.metadata)
return authRequest
Expand All @@ -37,7 +37,7 @@ public class AuthDecryptionService {
private func setPairingMetadata(rpcRequest: RPCRequest, topic: String) {
guard var pairing = pairingStorage.getPairing(forTopic: topic),
pairing.peerMetadata == nil,
let peerMetadata = try? rpcRequest.params?.get(AuthRequestParams.self).requester.metadata
let peerMetadata = try? rpcRequest.params?.get(Auth_RequestParams.self).requester.metadata
else { return }

pairing.updatePeerMetadata(peerMetadata)
Expand Down
6 changes: 3 additions & 3 deletions Sources/Auth/Services/App/AppRequestService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ actor AppRequestService {
func request(params: RequestParams, topic: String) async throws {
let pubKey = try kms.createX25519KeyPair()
let responseTopic = pubKey.rawRepresentation.sha256().toHexString()
let requester = AuthRequestParams.Requester(publicKey: pubKey.hexRepresentation, metadata: appMetadata)
let payload = AuthPayload(requestParams: params, iat: iatProvader.iat)
let params = AuthRequestParams(requester: requester, payloadParams: payload)
let requester = Auth_RequestParams.Requester(publicKey: pubKey.hexRepresentation, metadata: appMetadata)
let payload = AuthPayloadStruct(requestParams: params, iat: iatProvader.iat)
let params = Auth_RequestParams(requester: requester, payloadParams: payload)
let request = RPCRequest(method: "wc_authRequest", params: params)
try kms.setPublicKey(publicKey: pubKey, for: responseTopic)
logger.debug("AppRequestService: Subscribibg for response topic: \(responseTopic)")
Expand Down
4 changes: 2 additions & 2 deletions Sources/Auth/Services/App/AppRespondSubscriber.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ class AppRespondSubscriber {

private func subscribeForResponse() {
networkingInteractor.responseErrorSubscription(on: AuthRequestProtocolMethod())
.sink { [unowned self] (payload: ResponseSubscriptionErrorPayload<AuthRequestParams>) in
.sink { [unowned self] (payload: ResponseSubscriptionErrorPayload<Auth_RequestParams>) in
guard let error = AuthErrors(code: payload.error.code) else { return }
onResponse?(payload.id, .failure(error))
}.store(in: &publishers)

networkingInteractor.responseSubscription(on: AuthRequestProtocolMethod())
.sink { [unowned self] (payload: ResponseSubscriptionPayload<AuthRequestParams, Cacao>) in
.sink { [unowned self] (payload: ResponseSubscriptionPayload<Auth_RequestParams, Cacao>) in

pairingRegisterer.activate(pairingTopic: payload.topic, peerMetadata: nil)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

class PendingRequestsProvider {
class Auth_PendingRequestsProvider {
private let rpcHistory: RPCHistory
private let verifyContextStore: CodableStore<VerifyContext>

Expand All @@ -16,7 +16,7 @@ class PendingRequestsProvider {
let pendingRequests: [AuthRequest] = rpcHistory.getPending()
.filter {$0.request.method == "wc_authRequest"}
.compactMap {
guard let params = try? $0.request.params?.get(AuthRequestParams.self) else { return nil }
guard let params = try? $0.request.params?.get(Auth_RequestParams.self) else { return nil }
return AuthRequest(id: $0.request.id!, topic: $0.topic, payload: params.payloadParams, requester: params.requester.metadata)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

actor WalletErrorResponder {
actor Auth_WalletErrorResponder {
enum Errors: Error {
case recordForIdNotFound
case malformedAuthRequestParams
Expand Down Expand Up @@ -31,17 +31,17 @@ actor WalletErrorResponder {
try await networkingInteractor.respondError(topic: topic, requestId: requestId, protocolMethod: AuthRequestProtocolMethod(), reason: error, envelopeType: envelopeType)
}

private func getAuthRequestParams(requestId: RPCID) throws -> AuthRequestParams {
private func getAuthRequestParams(requestId: RPCID) throws -> Auth_RequestParams {
guard let request = rpcHistory.get(recordId: requestId)?.request
else { throw Errors.recordForIdNotFound }

guard let authRequestParams = try request.params?.get(AuthRequestParams.self)
guard let authRequestParams = try request.params?.get(Auth_RequestParams.self)
else { throw Errors.malformedAuthRequestParams }

return authRequestParams
}

private func generateAgreementKeys(requestParams: AuthRequestParams) throws -> (topic: String, keys: AgreementKeys) {
private func generateAgreementKeys(requestParams: Auth_RequestParams) throws -> (topic: String, keys: AgreementKeys) {
let peerPubKey = try AgreementPublicKey(hex: requestParams.requester.publicKey)
let topic = peerPubKey.rawRepresentation.sha256().toHexString()
let selfPubKey = try kms.createX25519KeyPair()
Expand Down
6 changes: 3 additions & 3 deletions Sources/Auth/Services/Wallet/WalletRequestSubscriber.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class WalletRequestSubscriber {
private let logger: ConsoleLogging
private let kms: KeyManagementServiceProtocol
private var publishers = [AnyCancellable]()
private let walletErrorResponder: WalletErrorResponder
private let walletErrorResponder: Auth_WalletErrorResponder
private let pairingRegisterer: PairingRegisterer
private let verifyClient: VerifyClientProtocol
private let verifyContextStore: CodableStore<VerifyContext>
Expand All @@ -17,7 +17,7 @@ class WalletRequestSubscriber {
networkingInteractor: NetworkInteracting,
logger: ConsoleLogging,
kms: KeyManagementServiceProtocol,
walletErrorResponder: WalletErrorResponder,
walletErrorResponder: Auth_WalletErrorResponder,
pairingRegisterer: PairingRegisterer,
verifyClient: VerifyClientProtocol,
verifyContextStore: CodableStore<VerifyContext>
Expand All @@ -34,7 +34,7 @@ class WalletRequestSubscriber {

private func subscribeForRequest() {
pairingRegisterer.register(method: AuthRequestProtocolMethod())
.sink { [unowned self] (payload: RequestSubscriptionPayload<AuthRequestParams>) in
.sink { [unowned self] (payload: RequestSubscriptionPayload<Auth_RequestParams>) in
logger.debug("WalletRequestSubscriber: Received request")

pairingRegisterer.setReceived(pairingTopic: payload.topic)
Expand Down
10 changes: 5 additions & 5 deletions Sources/Auth/Services/Wallet/WalletRespondService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ actor WalletRespondService {
private let rpcHistory: RPCHistory
private let verifyContextStore: CodableStore<VerifyContext>
private let logger: ConsoleLogging
private let walletErrorResponder: WalletErrorResponder
private let walletErrorResponder: Auth_WalletErrorResponder
private let pairingRegisterer: PairingRegisterer

init(
Expand All @@ -19,7 +19,7 @@ actor WalletRespondService {
kms: KeyManagementService,
rpcHistory: RPCHistory,
verifyContextStore: CodableStore<VerifyContext>,
walletErrorResponder: WalletErrorResponder,
walletErrorResponder: Auth_WalletErrorResponder,
pairingRegisterer: PairingRegisterer
) {
self.networkingInteractor = networkingInteractor
Expand Down Expand Up @@ -57,17 +57,17 @@ actor WalletRespondService {
verifyContextStore.delete(forKey: requestId.string)
}

private func getAuthRequestParams(requestId: RPCID) throws -> AuthRequestParams {
private func getAuthRequestParams(requestId: RPCID) throws -> Auth_RequestParams {
guard let request = rpcHistory.get(recordId: requestId)?.request
else { throw Errors.recordForIdNotFound }

guard let authRequestParams = try request.params?.get(AuthRequestParams.self)
guard let authRequestParams = try request.params?.get(Auth_RequestParams.self)
else { throw Errors.malformedAuthRequestParams }

return authRequestParams
}

private func generateAgreementKeys(requestParams: AuthRequestParams) throws -> (topic: String, keys: AgreementKeys) {
private func generateAgreementKeys(requestParams: Auth_RequestParams) throws -> (topic: String, keys: AgreementKeys) {
let peerPubKey = try AgreementPublicKey(hex: requestParams.requester.publicKey)
let topic = peerPubKey.rawRepresentation.sha256().toHexString()
let selfPubKey = try kms.createX25519KeyPair()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

public struct AuthPayload: Codable, Equatable {
public struct AuthPayloadStruct: Codable, Equatable {
public let domain: String
public let aud: String
public let version: String
Expand Down Expand Up @@ -51,7 +51,7 @@ public struct AuthPayload: Codable, Equatable {
}
}

private extension AuthPayload {
private extension AuthPayloadStruct {

enum Errors: Error {
case invalidChainID
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

public struct RespondParams: Equatable {
public struct AuthRespondParams: Equatable {
let id: RPCID
let signature: CacaoSignature

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import Foundation

/// wc_authRequest RPC method request param
struct AuthRequestParams: Codable, Equatable {
struct Auth_RequestParams: Codable, Equatable {
let requester: Requester
let payloadParams: AuthPayload
let payloadParams: AuthPayloadStruct
}

extension AuthRequestParams {
extension Auth_RequestParams {
struct Requester: Codable, Equatable {
let publicKey: String
let metadata: AppMetadata
Expand Down
2 changes: 1 addition & 1 deletion Sources/Auth/Types/Public/AuthRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import Foundation
public struct AuthRequest: Equatable, Codable {
public let id: RPCID
public let topic: String
public let payload: AuthPayload
public let payload: AuthPayloadStruct
public let requester: AppMetadata
}
6 changes: 2 additions & 4 deletions Sources/WalletConnectSign/Auth/Services/CacaosBuilder.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@

import Foundation
import WalletConnectUtils

struct CacaosBuilder {
public static func makeCacao(authPayload: AuthPayload, signature: WalletConnectUtils.CacaoSignature, account: WalletConnectUtils.Account) throws -> Cacao {
public static func makeCacao(authPayload: AuthPayload, signature: CacaoSignature, account: Account) throws -> Cacao {
let cacaoPayload = try CacaoPayloadBuilder.makeCacaoPayload(authPayload: authPayload, account: account)
let header = CacaoHeader(t: "eip4361")
return Cacao(h: header, p: cacaoPayload, s: signature)
Expand All @@ -12,7 +10,7 @@ struct CacaosBuilder {
}

struct CacaoPayloadBuilder {
public static func makeCacaoPayload(authPayload: AuthPayload, account: WalletConnectUtils.Account) throws -> CacaoPayload {
public static func makeCacaoPayload(authPayload: AuthPayload, account: Account) throws -> CacaoPayload {
var mergedRecap: RecapUrn?
var resources: [String]? = nil

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//

import Foundation

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Foundation


struct SignRecapBuilder {

enum BuilderError: Error {
Expand Down
2 changes: 1 addition & 1 deletion Sources/WalletConnectSign/Sign/SignClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ public final class SignClient: SignClientProtocol {
return try SIWEFromCacaoPayloadFormatter().formatMessage(from: cacaoPayload)
}

public func buildSignedAuthObject(authPayload: AuthPayload, signature: WalletConnectUtils.CacaoSignature, account: Account) throws -> AuthObject {
public func buildSignedAuthObject(authPayload: AuthPayload, signature: CacaoSignature, account: Account) throws -> AuthObject {
try CacaosBuilder.makeCacao(authPayload: authPayload, signature: signature, account: account)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/WalletConnectSign/Sign/SignClientProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public protocol SignClientProtocol {
func cleanup() async throws

func getPendingRequests(topic: String?) -> [(request: Request, context: VerifyContext?)]
func getPendingAuthRequests() throws -> [(WalletConnectSign.AuthenticationRequest, VerifyContext?)]
func getPendingAuthRequests() throws -> [(AuthenticationRequest, VerifyContext?)]
func getPendingProposals(topic: String?) -> [(proposal: Session.Proposal, context: VerifyContext?)]
}

2 changes: 1 addition & 1 deletion Sources/Web3Wallet/Web3WalletClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public class Web3WalletClient {
signClient.getSessions()
}

public func formatAuthMessage(payload: WalletConnectSign.AuthPayload, account: Account) throws -> String {
public func formatAuthMessage(payload: AuthPayload, account: Account) throws -> String {
try signClient.formatAuthMessage(payload: payload, account: account)
}

Expand Down

0 comments on commit ad6cf95

Please sign in to comment.