Skip to content

Commit

Permalink
Merge pull request #1135 from WalletConnect/develop
Browse files Browse the repository at this point in the history
1.8.4
  • Loading branch information
flypaper0 authored Sep 22, 2023
2 parents 192ff62 + b6ba4b9 commit 13446a8
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
12 changes: 10 additions & 2 deletions Example/WalletApp/ApplicationLayer/ConfigurationService.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Foundation
import UIKit
import WalletConnectNetworking
import WalletConnectNotify
import Web3Wallet
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ struct ListingViewModel: Identifiable {
}

var imageUrl: URL? {
return listing.image_url.md
return listing.image_url?.md
}

var title: String {
return listing.name
}

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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct NotificationsView: View {
}
}
.task {
try! await presenter.fetch()
try? await presenter.fetch()
}
}

Expand Down
33 changes: 14 additions & 19 deletions Sources/WalletConnectJWT/JWT.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@ import Foundation

struct JWT<JWTClaims: JWTEncodable>: 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 {
Expand All @@ -19,19 +27,6 @@ struct JWT<JWTClaims: JWTEncodable>: 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
}
}
6 changes: 2 additions & 4 deletions Sources/WalletConnectJWT/JWTDecodable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion Sources/WalletConnectRelay/PackageConfig.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version": "1.8.3"}
{"version": "1.8.4"}
8 changes: 3 additions & 5 deletions Tests/RelayerTests/AuthTests/JWTTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 13446a8

Please sign in to comment.