Skip to content

Commit 0021a75

Browse files
authored
Merge pull request #1327 from WalletConnect/develop
1.18.0
2 parents 32000af + 8114d74 commit 0021a75

23 files changed

+40
-44
lines changed

Sources/Auth/AuthClient.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ public class AuthClient: AuthClientProtocol {
4646
private let appRespondSubscriber: AppRespondSubscriber
4747
private let walletRequestSubscriber: WalletRequestSubscriber
4848
private let walletRespondService: WalletRespondService
49-
private let pendingRequestsProvider: PendingRequestsProvider
49+
private let pendingRequestsProvider: Auth_PendingRequestsProvider
5050

5151
init(appRequestService: AppRequestService,
5252
appRespondSubscriber: AppRespondSubscriber,
5353
walletRequestSubscriber: WalletRequestSubscriber,
5454
walletRespondService: WalletRespondService,
55-
pendingRequestsProvider: PendingRequestsProvider,
55+
pendingRequestsProvider: Auth_PendingRequestsProvider,
5656
logger: ConsoleLogging,
5757
socketConnectionStatusPublisher: AnyPublisher<SocketConnectionStatus, Never>,
5858
pairingRegisterer: PairingRegisterer
@@ -102,7 +102,7 @@ public class AuthClient: AuthClientProtocol {
102102
}
103103

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

Sources/Auth/AuthClientFactory.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ public struct AuthClientFactory {
4949
let messageVerifierFactory = MessageVerifierFactory(crypto: crypto)
5050
let signatureVerifier = messageVerifierFactory.create(projectId: projectId)
5151
let appRespondSubscriber = AppRespondSubscriber(networkingInteractor: networkingClient, logger: logger, rpcHistory: history, signatureVerifier: signatureVerifier, pairingRegisterer: pairingRegisterer, messageFormatter: messageFormatter)
52-
let walletErrorResponder = WalletErrorResponder(networkingInteractor: networkingClient, logger: logger, kms: kms, rpcHistory: history)
52+
let walletErrorResponder = Auth_WalletErrorResponder(networkingInteractor: networkingClient, logger: logger, kms: kms, rpcHistory: history)
5353
let walletRequestSubscriber = WalletRequestSubscriber(networkingInteractor: networkingClient, logger: logger, kms: kms, walletErrorResponder: walletErrorResponder, pairingRegisterer: pairingRegisterer, verifyClient: verifyClient, verifyContextStore: verifyContextStore)
5454
let walletRespondService = WalletRespondService(networkingInteractor: networkingClient, logger: logger, kms: kms, rpcHistory: history, verifyContextStore: verifyContextStore, walletErrorResponder: walletErrorResponder, pairingRegisterer: pairingRegisterer)
55-
let pendingRequestsProvider = PendingRequestsProvider(rpcHistory: history, verifyContextStore: verifyContextStore)
55+
let pendingRequestsProvider = Auth_PendingRequestsProvider(rpcHistory: history, verifyContextStore: verifyContextStore)
5656

5757
return AuthClient(
5858
appRequestService: appRequestService,

Sources/Auth/AuthClientProtocol.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Combine
44
public protocol AuthClientProtocol {
55
var authRequestPublisher: AnyPublisher<(request: AuthRequest, context: VerifyContext?), Never> { get }
66

7-
func formatMessage(payload: AuthPayload, address: String) throws -> String
7+
func formatMessage(payload: AuthPayloadStruct, address: String) throws -> String
88
func respond(requestId: RPCID, signature: CacaoSignature, from account: Account) async throws
99
func reject(requestId: RPCID) async throws
1010
func getPendingRequests() throws -> [(AuthRequest, VerifyContext?)]

Sources/Auth/AuthDecryptionService.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class AuthDecryptionService {
2121
public func decryptAuthRequest(topic: String, ciphertext: String) throws -> AuthRequest {
2222
let (rpcRequest, _, _): (RPCRequest, String?, Data) = try serializer.deserialize(topic: topic, encodedEnvelope: ciphertext)
2323
setPairingMetadata(rpcRequest: rpcRequest, topic: topic)
24-
if let params = try rpcRequest.params?.get(AuthRequestParams.self),
24+
if let params = try rpcRequest.params?.get(Auth_RequestParams.self),
2525
let id = rpcRequest.id {
2626
let authRequest = AuthRequest(id: id, topic: topic, payload: params.payloadParams, requester: params.requester.metadata)
2727
return authRequest
@@ -37,7 +37,7 @@ public class AuthDecryptionService {
3737
private func setPairingMetadata(rpcRequest: RPCRequest, topic: String) {
3838
guard var pairing = pairingStorage.getPairing(forTopic: topic),
3939
pairing.peerMetadata == nil,
40-
let peerMetadata = try? rpcRequest.params?.get(AuthRequestParams.self).requester.metadata
40+
let peerMetadata = try? rpcRequest.params?.get(Auth_RequestParams.self).requester.metadata
4141
else { return }
4242

4343
pairing.updatePeerMetadata(peerMetadata)

Sources/Auth/Services/App/AppRequestService.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ actor AppRequestService {
2222
func request(params: RequestParams, topic: String) async throws {
2323
let pubKey = try kms.createX25519KeyPair()
2424
let responseTopic = pubKey.rawRepresentation.sha256().toHexString()
25-
let requester = AuthRequestParams.Requester(publicKey: pubKey.hexRepresentation, metadata: appMetadata)
26-
let payload = AuthPayload(requestParams: params, iat: iatProvader.iat)
27-
let params = AuthRequestParams(requester: requester, payloadParams: payload)
25+
let requester = Auth_RequestParams.Requester(publicKey: pubKey.hexRepresentation, metadata: appMetadata)
26+
let payload = AuthPayloadStruct(requestParams: params, iat: iatProvader.iat)
27+
let params = Auth_RequestParams(requester: requester, payloadParams: payload)
2828
let request = RPCRequest(method: "wc_authRequest", params: params)
2929
try kms.setPublicKey(publicKey: pubKey, for: responseTopic)
3030
logger.debug("AppRequestService: Subscribibg for response topic: \(responseTopic)")

Sources/Auth/Services/App/AppRespondSubscriber.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ class AppRespondSubscriber {
2929

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

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

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

Sources/Auth/Services/Wallet/PendingRequestsProvider.swift renamed to Sources/Auth/Services/Wallet/Auth_PendingRequestsProvider.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
class PendingRequestsProvider {
3+
class Auth_PendingRequestsProvider {
44
private let rpcHistory: RPCHistory
55
private let verifyContextStore: CodableStore<VerifyContext>
66

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

Sources/Auth/Services/Wallet/WalletErrorResponder.swift renamed to Sources/Auth/Services/Wallet/Auth_WalletErrorResponder.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
actor WalletErrorResponder {
3+
actor Auth_WalletErrorResponder {
44
enum Errors: Error {
55
case recordForIdNotFound
66
case malformedAuthRequestParams
@@ -31,17 +31,17 @@ actor WalletErrorResponder {
3131
try await networkingInteractor.respondError(topic: topic, requestId: requestId, protocolMethod: AuthRequestProtocolMethod(), reason: error, envelopeType: envelopeType)
3232
}
3333

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

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

4141
return authRequestParams
4242
}
4343

44-
private func generateAgreementKeys(requestParams: AuthRequestParams) throws -> (topic: String, keys: AgreementKeys) {
44+
private func generateAgreementKeys(requestParams: Auth_RequestParams) throws -> (topic: String, keys: AgreementKeys) {
4545
let peerPubKey = try AgreementPublicKey(hex: requestParams.requester.publicKey)
4646
let topic = peerPubKey.rawRepresentation.sha256().toHexString()
4747
let selfPubKey = try kms.createX25519KeyPair()

Sources/Auth/Services/Wallet/WalletRequestSubscriber.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class WalletRequestSubscriber {
66
private let logger: ConsoleLogging
77
private let kms: KeyManagementServiceProtocol
88
private var publishers = [AnyCancellable]()
9-
private let walletErrorResponder: WalletErrorResponder
9+
private let walletErrorResponder: Auth_WalletErrorResponder
1010
private let pairingRegisterer: PairingRegisterer
1111
private let verifyClient: VerifyClientProtocol
1212
private let verifyContextStore: CodableStore<VerifyContext>
@@ -17,7 +17,7 @@ class WalletRequestSubscriber {
1717
networkingInteractor: NetworkInteracting,
1818
logger: ConsoleLogging,
1919
kms: KeyManagementServiceProtocol,
20-
walletErrorResponder: WalletErrorResponder,
20+
walletErrorResponder: Auth_WalletErrorResponder,
2121
pairingRegisterer: PairingRegisterer,
2222
verifyClient: VerifyClientProtocol,
2323
verifyContextStore: CodableStore<VerifyContext>
@@ -34,7 +34,7 @@ class WalletRequestSubscriber {
3434

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

4040
pairingRegisterer.setReceived(pairingTopic: payload.topic)

Sources/Auth/Services/Wallet/WalletRespondService.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ actor WalletRespondService {
1010
private let rpcHistory: RPCHistory
1111
private let verifyContextStore: CodableStore<VerifyContext>
1212
private let logger: ConsoleLogging
13-
private let walletErrorResponder: WalletErrorResponder
13+
private let walletErrorResponder: Auth_WalletErrorResponder
1414
private let pairingRegisterer: PairingRegisterer
1515

1616
init(
@@ -19,7 +19,7 @@ actor WalletRespondService {
1919
kms: KeyManagementService,
2020
rpcHistory: RPCHistory,
2121
verifyContextStore: CodableStore<VerifyContext>,
22-
walletErrorResponder: WalletErrorResponder,
22+
walletErrorResponder: Auth_WalletErrorResponder,
2323
pairingRegisterer: PairingRegisterer
2424
) {
2525
self.networkingInteractor = networkingInteractor
@@ -57,17 +57,17 @@ actor WalletRespondService {
5757
verifyContextStore.delete(forKey: requestId.string)
5858
}
5959

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

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

6767
return authRequestParams
6868
}
6969

70-
private func generateAgreementKeys(requestParams: AuthRequestParams) throws -> (topic: String, keys: AgreementKeys) {
70+
private func generateAgreementKeys(requestParams: Auth_RequestParams) throws -> (topic: String, keys: AgreementKeys) {
7171
let peerPubKey = try AgreementPublicKey(hex: requestParams.requester.publicKey)
7272
let topic = peerPubKey.rawRepresentation.sha256().toHexString()
7373
let selfPubKey = try kms.createX25519KeyPair()

Sources/Auth/Types/AuthPayload.swift renamed to Sources/Auth/Types/AuthPayloadStruct.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
public struct AuthPayload: Codable, Equatable {
3+
public struct AuthPayloadStruct: Codable, Equatable {
44
public let domain: String
55
public let aud: String
66
public let version: String
@@ -51,7 +51,7 @@ public struct AuthPayload: Codable, Equatable {
5151
}
5252
}
5353

54-
private extension AuthPayload {
54+
private extension AuthPayloadStruct {
5555

5656
enum Errors: Error {
5757
case invalidChainID

Sources/Auth/Types/RespondParams.swift renamed to Sources/Auth/Types/AuthRespondParams.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
public struct RespondParams: Equatable {
3+
public struct AuthRespondParams: Equatable {
44
let id: RPCID
55
let signature: CacaoSignature
66

Sources/Auth/Types/ProtocolRPCParams/AuthRequestParams.swift renamed to Sources/Auth/Types/ProtocolRPCParams/Auth_RequestParams.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import Foundation
22

33
/// wc_authRequest RPC method request param
4-
struct AuthRequestParams: Codable, Equatable {
4+
struct Auth_RequestParams: Codable, Equatable {
55
let requester: Requester
6-
let payloadParams: AuthPayload
6+
let payloadParams: AuthPayloadStruct
77
}
88

9-
extension AuthRequestParams {
9+
extension Auth_RequestParams {
1010
struct Requester: Codable, Equatable {
1111
let publicKey: String
1212
let metadata: AppMetadata

Sources/Auth/Types/Public/AuthRequest.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import Foundation
33
public struct AuthRequest: Equatable, Codable {
44
public let id: RPCID
55
public let topic: String
6-
public let payload: AuthPayload
6+
public let payload: AuthPayloadStruct
77
public let requester: AppMetadata
88
}
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version": "1.17.0"}
1+
{"version": "1.18.0"}

Sources/WalletConnectSign/Auth/Services/CacaosBuilder.swift

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
21
import Foundation
3-
import WalletConnectUtils
42

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

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

Sources/WalletConnectSign/Auth/Services/ProposalNamespaceBuilder.swift

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//
21

32
import Foundation
43

Sources/WalletConnectSign/Auth/Services/SignRecapBuilder.swift

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Foundation
22

3-
43
struct SignRecapBuilder {
54

65
enum BuilderError: Error {

Sources/WalletConnectSign/Sign/SignClient.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ public final class SignClient: SignClientProtocol {
361361
return try SIWEFromCacaoPayloadFormatter().formatMessage(from: cacaoPayload)
362362
}
363363

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

Sources/WalletConnectSign/Sign/SignClientProtocol.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public protocol SignClientProtocol {
3636
func cleanup() async throws
3737

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

Sources/Web3Wallet/Web3WalletClient.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public class Web3WalletClient {
197197
signClient.getSessions()
198198
}
199199

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

0 commit comments

Comments
 (0)