Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Starscream as dependency, use Apple's URLSession-based websockets instead #124

Merged
merged 14 commits into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
github "krzyzanowskim/CryptoSwift" ~> 1.4.0
github "daltoniam/Starscream" ~> 4.0.4
9 changes: 4 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
// swift-tools-version:5.0
// swift-tools-version:5.5
import PackageDescription

let package = Package(
name: "WalletConnectSwift",
platforms: [
.macOS(.v10_14), .iOS(.v11),
.macOS(.v10_14), .iOS(.v13),
],
products: [
.library(
name: "WalletConnectSwift",
targets: ["WalletConnectSwift"])
],
dependencies: [
.package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", .upToNextMinor(from: "1.4.0")),
.package(url: "https://github.com/daltoniam/Starscream.git", .upToNextMinor(from: "4.0.4"))
.package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", .upToNextMinor(from: "1.4.0"))
],
targets: [
.target(
name: "WalletConnectSwift",
dependencies: ["CryptoSwift", "Starscream"],
dependencies: ["CryptoSwift"],
path: "Sources"),
.testTarget(name: "WalletConnectSwiftTests", dependencies: ["WalletConnectSwift"], path: "Tests"),
],
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,12 @@ Please open `ExampleApps/ExampleApps.xcodeproj`

## Prerequisites

- iOS 11.0 or macOS 10.14
- iOS 13.0 or macOS 10.14
- Swift 5

## WalletConnectSwift dependencies

- CryptoSwift - for cryptography operations
- Starscream - for WebSocket operations prior to iOS 13

## Swift Package Manager

Expand All @@ -152,7 +151,7 @@ In your `Package.swift`:

In your `Podfile`:

platform :ios, '11.0'
platform :ios, '13.0'
use_frameworks!

target 'MyApp' do
Expand All @@ -169,7 +168,7 @@ Run `carthage update` to build the framework and drag the WalletConnectSwift.fra

# Acknowledgments

We'd like to thank [Trust Wallet](https://github.com/trustwallet/wallet-connect-swift) team for inspiration in imlpementing this library.
We'd like to thank [Trust Wallet](https://github.com/trustwallet/wallet-connect-swift) team for inspiration in implementing this library.

# Contributors

Expand Down
2 changes: 1 addition & 1 deletion Sources/Internal/AES_256_CBC_HMAC_SHA256_Codec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class AES_256_CBC_HMAC_SHA256_Codec: Codec {
}

private func authenticationCode(key: Data, data: Data) throws -> Data {
let algo = HMAC(key: key.bytes, variant: .sha256)
let algo = HMAC(key: key.bytes, variant: .sha2(.sha256))
let digest = try algo.authenticate(data.bytes)
return Data(digest)
}
Expand Down
14 changes: 8 additions & 6 deletions Sources/Internal/Communicator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,16 @@ class Communicator {

func addOrUpdate(_ session: Session) {
dispatchPrecondition(condition: .notOnQueue(queue))
queue.sync { [unowned self] in
self.sessions[session.url] = session
queue.sync { [weak self] in
self?.sessions[session.url] = session
}
}

func all() -> [Session] {
var result: [Session] = []
dispatchPrecondition(condition: .notOnQueue(queue))
queue.sync { [unowned self] in
queue.sync { [weak self] in
guard let self = self else { return }
result = Array(self.sessions.values)
}
return result
Expand All @@ -126,16 +127,17 @@ class Communicator {
func find(url: WCURL) -> Session? {
var result: Session?
dispatchPrecondition(condition: .notOnQueue(queue))
queue.sync { [unowned self] in
queue.sync { [weak self] in
guard let self = self else { return }
result = self.sessions[url]
}
return result
}

func remove(url: WCURL) {
dispatchPrecondition(condition: .notOnQueue(queue))
queue.sync { [unowned self] in
_ = self.sessions.removeValue(forKey: url)
queue.sync { [weak self] in
_ = self?.sessions.removeValue(forKey: url)
}
}
}
Expand Down
Loading