diff --git a/Sources/Auth/AuthClient.swift b/Sources/Auth/AuthClient.swift index 8efd60dad..d9551bdde 100644 --- a/Sources/Auth/AuthClient.swift +++ b/Sources/Auth/AuthClient.swift @@ -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, pairingRegisterer: PairingRegisterer @@ -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)) } diff --git a/Sources/Auth/AuthClientFactory.swift b/Sources/Auth/AuthClientFactory.swift index ae73f8d7e..59b902602 100644 --- a/Sources/Auth/AuthClientFactory.swift +++ b/Sources/Auth/AuthClientFactory.swift @@ -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, diff --git a/Sources/Auth/AuthClientProtocol.swift b/Sources/Auth/AuthClientProtocol.swift index 23d5cd55c..d74cdbb7f 100644 --- a/Sources/Auth/AuthClientProtocol.swift +++ b/Sources/Auth/AuthClientProtocol.swift @@ -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?)] diff --git a/Sources/Auth/AuthDecryptionService.swift b/Sources/Auth/AuthDecryptionService.swift index 9c2c55d61..11e9a2fbd 100644 --- a/Sources/Auth/AuthDecryptionService.swift +++ b/Sources/Auth/AuthDecryptionService.swift @@ -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 @@ -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) diff --git a/Sources/Auth/Services/App/AppRequestService.swift b/Sources/Auth/Services/App/AppRequestService.swift index afc45eac9..325c515b5 100644 --- a/Sources/Auth/Services/App/AppRequestService.swift +++ b/Sources/Auth/Services/App/AppRequestService.swift @@ -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)") diff --git a/Sources/Auth/Services/App/AppRespondSubscriber.swift b/Sources/Auth/Services/App/AppRespondSubscriber.swift index fe1d07287..e7036bf5e 100644 --- a/Sources/Auth/Services/App/AppRespondSubscriber.swift +++ b/Sources/Auth/Services/App/AppRespondSubscriber.swift @@ -29,13 +29,13 @@ class AppRespondSubscriber { private func subscribeForResponse() { networkingInteractor.responseErrorSubscription(on: AuthRequestProtocolMethod()) - .sink { [unowned self] (payload: ResponseSubscriptionErrorPayload) in + .sink { [unowned self] (payload: ResponseSubscriptionErrorPayload) 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) in + .sink { [unowned self] (payload: ResponseSubscriptionPayload) in pairingRegisterer.activate(pairingTopic: payload.topic, peerMetadata: nil) diff --git a/Sources/Auth/Services/Wallet/PendingRequestsProvider.swift b/Sources/Auth/Services/Wallet/Auth_PendingRequestsProvider.swift similarity index 91% rename from Sources/Auth/Services/Wallet/PendingRequestsProvider.swift rename to Sources/Auth/Services/Wallet/Auth_PendingRequestsProvider.swift index c824760b9..f646835e4 100644 --- a/Sources/Auth/Services/Wallet/PendingRequestsProvider.swift +++ b/Sources/Auth/Services/Wallet/Auth_PendingRequestsProvider.swift @@ -1,6 +1,6 @@ import Foundation -class PendingRequestsProvider { +class Auth_PendingRequestsProvider { private let rpcHistory: RPCHistory private let verifyContextStore: CodableStore @@ -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) } diff --git a/Sources/Auth/Services/Wallet/WalletErrorResponder.swift b/Sources/Auth/Services/Wallet/Auth_WalletErrorResponder.swift similarity index 90% rename from Sources/Auth/Services/Wallet/WalletErrorResponder.swift rename to Sources/Auth/Services/Wallet/Auth_WalletErrorResponder.swift index f6047f016..895f41d9d 100644 --- a/Sources/Auth/Services/Wallet/WalletErrorResponder.swift +++ b/Sources/Auth/Services/Wallet/Auth_WalletErrorResponder.swift @@ -1,6 +1,6 @@ import Foundation -actor WalletErrorResponder { +actor Auth_WalletErrorResponder { enum Errors: Error { case recordForIdNotFound case malformedAuthRequestParams @@ -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() diff --git a/Sources/Auth/Services/Wallet/WalletRequestSubscriber.swift b/Sources/Auth/Services/Wallet/WalletRequestSubscriber.swift index 95d71799e..7270871d7 100644 --- a/Sources/Auth/Services/Wallet/WalletRequestSubscriber.swift +++ b/Sources/Auth/Services/Wallet/WalletRequestSubscriber.swift @@ -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 @@ -17,7 +17,7 @@ class WalletRequestSubscriber { networkingInteractor: NetworkInteracting, logger: ConsoleLogging, kms: KeyManagementServiceProtocol, - walletErrorResponder: WalletErrorResponder, + walletErrorResponder: Auth_WalletErrorResponder, pairingRegisterer: PairingRegisterer, verifyClient: VerifyClientProtocol, verifyContextStore: CodableStore @@ -34,7 +34,7 @@ class WalletRequestSubscriber { private func subscribeForRequest() { pairingRegisterer.register(method: AuthRequestProtocolMethod()) - .sink { [unowned self] (payload: RequestSubscriptionPayload) in + .sink { [unowned self] (payload: RequestSubscriptionPayload) in logger.debug("WalletRequestSubscriber: Received request") pairingRegisterer.setReceived(pairingTopic: payload.topic) diff --git a/Sources/Auth/Services/Wallet/WalletRespondService.swift b/Sources/Auth/Services/Wallet/WalletRespondService.swift index 3735ce663..529ef2a79 100644 --- a/Sources/Auth/Services/Wallet/WalletRespondService.swift +++ b/Sources/Auth/Services/Wallet/WalletRespondService.swift @@ -10,7 +10,7 @@ actor WalletRespondService { private let rpcHistory: RPCHistory private let verifyContextStore: CodableStore private let logger: ConsoleLogging - private let walletErrorResponder: WalletErrorResponder + private let walletErrorResponder: Auth_WalletErrorResponder private let pairingRegisterer: PairingRegisterer init( @@ -19,7 +19,7 @@ actor WalletRespondService { kms: KeyManagementService, rpcHistory: RPCHistory, verifyContextStore: CodableStore, - walletErrorResponder: WalletErrorResponder, + walletErrorResponder: Auth_WalletErrorResponder, pairingRegisterer: PairingRegisterer ) { self.networkingInteractor = networkingInteractor @@ -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() diff --git a/Sources/Auth/Types/AuthPayload.swift b/Sources/Auth/Types/AuthPayloadStruct.swift similarity index 94% rename from Sources/Auth/Types/AuthPayload.swift rename to Sources/Auth/Types/AuthPayloadStruct.swift index 33ba49756..b7a1494c4 100644 --- a/Sources/Auth/Types/AuthPayload.swift +++ b/Sources/Auth/Types/AuthPayloadStruct.swift @@ -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 @@ -51,7 +51,7 @@ public struct AuthPayload: Codable, Equatable { } } -private extension AuthPayload { +private extension AuthPayloadStruct { enum Errors: Error { case invalidChainID diff --git a/Sources/Auth/Types/RespondParams.swift b/Sources/Auth/Types/AuthRespondParams.swift similarity index 81% rename from Sources/Auth/Types/RespondParams.swift rename to Sources/Auth/Types/AuthRespondParams.swift index f7c4a4af8..fce3414eb 100644 --- a/Sources/Auth/Types/RespondParams.swift +++ b/Sources/Auth/Types/AuthRespondParams.swift @@ -1,6 +1,6 @@ import Foundation -public struct RespondParams: Equatable { +public struct AuthRespondParams: Equatable { let id: RPCID let signature: CacaoSignature diff --git a/Sources/Auth/Types/Errors/AuthError.swift b/Sources/Auth/Types/Errors/AuthErrors.swift similarity index 100% rename from Sources/Auth/Types/Errors/AuthError.swift rename to Sources/Auth/Types/Errors/AuthErrors.swift diff --git a/Sources/Auth/Types/ProtocolRPCParams/AuthRequestParams.swift b/Sources/Auth/Types/ProtocolRPCParams/Auth_RequestParams.swift similarity index 63% rename from Sources/Auth/Types/ProtocolRPCParams/AuthRequestParams.swift rename to Sources/Auth/Types/ProtocolRPCParams/Auth_RequestParams.swift index 427b29303..4a72728ed 100644 --- a/Sources/Auth/Types/ProtocolRPCParams/AuthRequestParams.swift +++ b/Sources/Auth/Types/ProtocolRPCParams/Auth_RequestParams.swift @@ -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 diff --git a/Sources/Auth/Types/Public/AuthRequest.swift b/Sources/Auth/Types/Public/AuthRequest.swift index e796d75cf..63e553cc5 100644 --- a/Sources/Auth/Types/Public/AuthRequest.swift +++ b/Sources/Auth/Types/Public/AuthRequest.swift @@ -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 } diff --git a/Sources/WalletConnectRelay/PackageConfig.json b/Sources/WalletConnectRelay/PackageConfig.json index 8c3caff7b..617b2b368 100644 --- a/Sources/WalletConnectRelay/PackageConfig.json +++ b/Sources/WalletConnectRelay/PackageConfig.json @@ -1 +1 @@ -{"version": "1.17.0"} +{"version": "1.18.0"} diff --git a/Sources/WalletConnectSign/Auth/Services/CacaosBuilder.swift b/Sources/WalletConnectSign/Auth/Services/CacaosBuilder.swift index 572eba175..02889c9a1 100644 --- a/Sources/WalletConnectSign/Auth/Services/CacaosBuilder.swift +++ b/Sources/WalletConnectSign/Auth/Services/CacaosBuilder.swift @@ -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) @@ -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 diff --git a/Sources/WalletConnectSign/Auth/Services/ProposalNamespaceBuilder.swift b/Sources/WalletConnectSign/Auth/Services/ProposalNamespaceBuilder.swift index 5a3faa1fc..b18f5c297 100644 --- a/Sources/WalletConnectSign/Auth/Services/ProposalNamespaceBuilder.swift +++ b/Sources/WalletConnectSign/Auth/Services/ProposalNamespaceBuilder.swift @@ -1,4 +1,3 @@ -// import Foundation diff --git a/Sources/WalletConnectSign/Auth/Services/SignRecapBuilder.swift b/Sources/WalletConnectSign/Auth/Services/SignRecapBuilder.swift index 6ce80bb80..fc008a98d 100644 --- a/Sources/WalletConnectSign/Auth/Services/SignRecapBuilder.swift +++ b/Sources/WalletConnectSign/Auth/Services/SignRecapBuilder.swift @@ -1,6 +1,5 @@ import Foundation - struct SignRecapBuilder { enum BuilderError: Error { diff --git a/Sources/WalletConnectSign/Auth/AuthProtocolMethod.swift b/Sources/WalletConnectSign/Auth/SessionAuthenticatedProtocolMethod.swift similarity index 100% rename from Sources/WalletConnectSign/Auth/AuthProtocolMethod.swift rename to Sources/WalletConnectSign/Auth/SessionAuthenticatedProtocolMethod.swift diff --git a/Sources/WalletConnectSign/Sign/SignClient.swift b/Sources/WalletConnectSign/Sign/SignClient.swift index 64ed1a1f7..9bc4c4db5 100644 --- a/Sources/WalletConnectSign/Sign/SignClient.swift +++ b/Sources/WalletConnectSign/Sign/SignClient.swift @@ -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) } diff --git a/Sources/WalletConnectSign/Sign/SignClientProtocol.swift b/Sources/WalletConnectSign/Sign/SignClientProtocol.swift index 1947e298c..4cb030cd4 100644 --- a/Sources/WalletConnectSign/Sign/SignClientProtocol.swift +++ b/Sources/WalletConnectSign/Sign/SignClientProtocol.swift @@ -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?)] } diff --git a/Sources/Web3Wallet/Web3WalletClient.swift b/Sources/Web3Wallet/Web3WalletClient.swift index bde5bc345..5cc7b864f 100644 --- a/Sources/Web3Wallet/Web3WalletClient.swift +++ b/Sources/Web3Wallet/Web3WalletClient.swift @@ -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) }