diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3174bdc93..d11425c1c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,4 +35,4 @@ jobs: APPLE_KEY_CONTENT: ${{ secrets.APPLE_KEY_CONTENT }} WALLETAPP_SENTRY_DSN: ${{ secrets.WALLETAPP_SENTRY_DSN }} run: | - make release_all APPLE_ID=${{ secrets.APPLE_ID }} TOKEN=$(echo -n $GH_USER:$GH_TOKEN | base64) PROJECT_ID=${{ secrets.RELEASE_PROJECT_ID }} WALLETAPP_SENTRY_DSN=${{ secrets.WALLETAPP_SENTRY_DSN }} MIXPANEL_TOKEN=${{secrets.MIXPANEL_TOKEN}} + make release_wallet APPLE_ID=${{ secrets.APPLE_ID }} TOKEN=$(echo -n $GH_USER:$GH_TOKEN | base64) PROJECT_ID=${{ secrets.RELEASE_PROJECT_ID }} WALLETAPP_SENTRY_DSN=${{ secrets.WALLETAPP_SENTRY_DSN }} MIXPANEL_TOKEN=${{secrets.MIXPANEL_TOKEN}} diff --git a/Example/WalletApp/ApplicationLayer/ConfigurationService.swift b/Example/WalletApp/ApplicationLayer/ConfigurationService.swift index 49734c329..83200ba56 100644 --- a/Example/WalletApp/ApplicationLayer/ConfigurationService.swift +++ b/Example/WalletApp/ApplicationLayer/ConfigurationService.swift @@ -1,4 +1,4 @@ -import Foundation +import UIKit import WalletConnectNetworking import WalletConnectNotify import Web3Wallet @@ -26,7 +26,15 @@ final class ConfigurationService { Notify.instance.setLogging(level: .debug) - Task { try await Notify.instance.register(account: importAccount.account, domain: "com.walletconnect", onSign: importAccount.onSign) } + Task { + do { + try await Notify.instance.register(account: importAccount.account, domain: "com.walletconnect", onSign: importAccount.onSign) + } catch { + DispatchQueue.main.async { + UIApplication.currentWindow.rootViewController?.showAlert(title: "Register error", error: error) + } + } + } if let clientId = try? Networking.interactor.getClientId() { LoggingService.instance.setUpUser(account: importAccount.account.absoluteString, clientId: clientId) diff --git a/Example/WalletApp/BusinessLayer/ListingsSertice/Listings.swift b/Example/WalletApp/BusinessLayer/ListingsSertice/Listings.swift index 176fc4d83..4ab2673c9 100644 --- a/Example/WalletApp/BusinessLayer/ListingsSertice/Listings.swift +++ b/Example/WalletApp/BusinessLayer/ListingsSertice/Listings.swift @@ -13,8 +13,8 @@ struct Listing: Codable { } let id: String let name: String - let description: String - let homepage: String - let image_url: ImageURL + let description: String? + let homepage: String? + let image_url: ImageURL? let dapp_url: String } diff --git a/Example/WalletApp/Common/Extensions/UIKit/UIViewController.swift b/Example/WalletApp/Common/Extensions/UIKit/UIViewController.swift index c058d9ef6..c9ab837d4 100644 --- a/Example/WalletApp/Common/Extensions/UIKit/UIViewController.swift +++ b/Example/WalletApp/Common/Extensions/UIKit/UIViewController.swift @@ -48,6 +48,12 @@ extension UIViewController { navigationController.navigationBar.prefersLargeTitles = true return navigationController } + + func showAlert(title: String, error: Error) { + let alert = UIAlertController(title: title, message: error.localizedDescription, preferredStyle: .alert) + alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil)) + present(alert, animated: true, completion: nil) + } } extension UIApplication { diff --git a/Example/WalletApp/PresentationLayer/Wallet/Notifications/Models/ListingViewModel.swift b/Example/WalletApp/PresentationLayer/Wallet/Notifications/Models/ListingViewModel.swift index 7ae7ead37..08286926d 100644 --- a/Example/WalletApp/PresentationLayer/Wallet/Notifications/Models/ListingViewModel.swift +++ b/Example/WalletApp/PresentationLayer/Wallet/Notifications/Models/ListingViewModel.swift @@ -9,7 +9,7 @@ struct ListingViewModel: Identifiable { } var imageUrl: URL? { - return listing.image_url.md + return listing.image_url?.md } var title: String { @@ -17,11 +17,11 @@ struct ListingViewModel: Identifiable { } var subtitle: String { - return listing.description + return listing.description ?? "" } var appDomain: String? { - let url = listing.homepage + let url = listing.dapp_url return URL(string: url)?.host } } diff --git a/Example/WalletApp/PresentationLayer/Wallet/Notifications/NotificationsView.swift b/Example/WalletApp/PresentationLayer/Wallet/Notifications/NotificationsView.swift index 1098135dd..7bb2cb404 100644 --- a/Example/WalletApp/PresentationLayer/Wallet/Notifications/NotificationsView.swift +++ b/Example/WalletApp/PresentationLayer/Wallet/Notifications/NotificationsView.swift @@ -42,7 +42,7 @@ struct NotificationsView: View { } } .task { - try! await presenter.fetch() + try? await presenter.fetch() } } diff --git a/Sources/WalletConnectJWT/JWT.swift b/Sources/WalletConnectJWT/JWT.swift index f1eab051c..5e3259440 100644 --- a/Sources/WalletConnectJWT/JWT.swift +++ b/Sources/WalletConnectJWT/JWT.swift @@ -2,13 +2,21 @@ import Foundation struct JWT: Codable, Equatable { - var header: JWTHeader - var claims: JWTClaims - var signature: String? + let header: JWTHeader + let claims: JWTClaims + let signature: String + let string: String - init(header: JWTHeader = JWTHeader(), claims: JWTClaims) { - self.header = header + init(claims: JWTClaims, signer: JWTSigning) throws { + self.header = JWTHeader(alg: signer.alg) self.claims = claims + + let headerString = try header.encode() + let claimsString = try claims.encode() + let signature = try signer.sign(header: headerString, claims: claimsString) + + self.signature = signature + self.string = [headerString, claimsString, signature].joined(separator: ".") } init(string: String) throws { @@ -19,19 +27,6 @@ struct JWT: Codable, Equatable { self.header = try JWTHeader.decode(from: components[0]) self.claims = try JWTClaims.decode(from: components[1]) self.signature = components[2] - } - - mutating func sign(using jwtSigner: JWTSigning) throws { - header.alg = jwtSigner.alg - let headerString = try header.encode() - let claimsString = try claims.encode() - self.signature = try jwtSigner.sign(header: headerString, claims: claimsString) - } - - func encoded() throws -> String { - guard let signature = signature else { throw JWTError.jwtNotSigned } - let headerString = try header.encode() - let claimsString = try claims.encode() - return [headerString, claimsString, signature].joined(separator: ".") + self.string = string } } diff --git a/Sources/WalletConnectJWT/JWTDecodable.swift b/Sources/WalletConnectJWT/JWTDecodable.swift index 2f96ae072..fa9d522f8 100644 --- a/Sources/WalletConnectJWT/JWTDecodable.swift +++ b/Sources/WalletConnectJWT/JWTDecodable.swift @@ -43,10 +43,8 @@ extension JWTClaimsCodable { public func signAndCreateWrapper(keyPair: SigningPrivateKey) throws -> Wrapper { let claims = try encode(iss: keyPair.publicKey.did) - var jwt = JWT(claims: claims) - try jwt.sign(using: EdDSASigner(keyPair)) - let jwtString = try jwt.encoded() - return Wrapper(jwtString: jwtString) + let jwt = try JWT(claims: claims, signer: EdDSASigner(keyPair)) + return Wrapper(jwtString: jwt.string) } public func defaultIat() -> UInt64 { diff --git a/Sources/WalletConnectRelay/PackageConfig.json b/Sources/WalletConnectRelay/PackageConfig.json index ad8897ff9..d4136fe89 100644 --- a/Sources/WalletConnectRelay/PackageConfig.json +++ b/Sources/WalletConnectRelay/PackageConfig.json @@ -1 +1 @@ -{"version": "1.8.3"} +{"version": "1.8.4"} diff --git a/Tests/RelayerTests/AuthTests/JWTTests.swift b/Tests/RelayerTests/AuthTests/JWTTests.swift index 40ad5be31..1d07ff0c7 100644 --- a/Tests/RelayerTests/AuthTests/JWTTests.swift +++ b/Tests/RelayerTests/AuthTests/JWTTests.swift @@ -6,13 +6,11 @@ import XCTest final class JWTTests: XCTestCase { let expectedJWT = "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2NTY5MTAwOTcsImV4cCI6MTY1Njk5NjQ5NywiaXNzIjoiZGlkOmtleTp6Nk1rb2RIWnduZVZSU2h0YUxmOEpLWWt4cERHcDF2R1pucEdtZEJwWDhNMmV4eEgiLCJzdWIiOiJjNDc5ZmU1ZGM0NjRlNzcxZTc4YjE5M2QyMzlhNjViNThkMjc4Y2FkMWMzNGJmYjBiNTcxNmU1YmI1MTQ5MjhlIiwiYXVkIjoid3NzOi8vcmVsYXkud2FsbGV0Y29ubmVjdC5jb20ifQ.0JkxOM-FV21U7Hk-xycargj_qNRaYV2H5HYtE4GzAeVQYiKWj7YySY5AdSqtCgGzX4Gt98XWXn2kSr9rE1qvCA" - func testJWTEncoding() { - var jwt = JWT(claims: RelayAuthPayload.Claims.stub()) + func testJWTEncoding() throws { let signer = EdDSASignerMock() signer.signature = "0JkxOM-FV21U7Hk-xycargj_qNRaYV2H5HYtE4GzAeVQYiKWj7YySY5AdSqtCgGzX4Gt98XWXn2kSr9rE1qvCA" - try! jwt.sign(using: signer) - let encoded = try! jwt.encoded() - XCTAssertEqual(expectedJWT, encoded) + let jwt = try JWT(claims: RelayAuthPayload.Claims.stub(), signer: signer) + XCTAssertEqual(expectedJWT, jwt.string) } func testBase64Encoding() throws {