-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[Auth] #367 auth target
- Loading branch information
Showing
17 changed files
with
196 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "1340" | ||
version = "1.3"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES"> | ||
<Testables> | ||
<TestableReference | ||
skipped = "NO"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "AuthTests" | ||
BuildableName = "AuthTests" | ||
BlueprintName = "AuthTests" | ||
ReferencedContainer = "container:"> | ||
</BuildableReference> | ||
</TestableReference> | ||
</Testables> | ||
</TestAction> | ||
<LaunchAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
debugServiceExtension = "internal" | ||
allowLocationSimulation = "YES"> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Foundation | ||
|
||
class AuthClient { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Foundation | ||
|
||
actor AuthRequestService { | ||
|
||
func request(params: RequestParams, topic: String) async throws { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Foundation | ||
|
||
actor CreatePairingService { | ||
|
||
func create() async throws -> WalletConnectURI { | ||
fatalError("not implemented") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Foundation | ||
|
||
actor AuthService { | ||
|
||
func respond(respondParams: RespondParams) async throws { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Foundation | ||
|
||
actor PairService { | ||
|
||
func pair(_ uri: WalletConnectURI) async throws { | ||
fatalError("not implemented") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// | ||
|
||
import Foundation | ||
import WalletConnectUtils | ||
|
||
typealias RelayProtocolOptions = WalletConnectUtils.RelayProtocolOptions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// | ||
|
||
import Foundation | ||
|
||
struct RequestParams { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// | ||
|
||
import Foundation | ||
|
||
struct RespondParams { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// | ||
|
||
import Foundation | ||
import WalletConnectUtils | ||
|
||
typealias WalletConnectURI = WalletConnectUtils.WalletConnectURI |
6 changes: 0 additions & 6 deletions
6
Sources/WalletConnectSign/Types/Common/RelayProtocolOptions.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// | ||
|
||
import Foundation | ||
import WalletConnectUtils | ||
|
||
typealias RelayProtocolOptions = WalletConnectUtils.RelayProtocolOptions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,4 @@ | ||
import Foundation | ||
import WalletConnectUtils | ||
|
||
public struct WalletConnectURI: Equatable { | ||
|
||
let topic: String | ||
let version: String | ||
let symKey: String | ||
let relay: RelayProtocolOptions | ||
|
||
init(topic: String, symKey: String, relay: RelayProtocolOptions) { | ||
self.version = "2" | ||
self.topic = topic | ||
self.symKey = symKey | ||
self.relay = relay | ||
} | ||
|
||
public init?(string: String) { | ||
guard string.hasPrefix("wc:") else { | ||
return nil | ||
} | ||
let urlString = !string.hasPrefix("wc://") ? string.replacingOccurrences(of: "wc:", with: "wc://") : string | ||
guard let components = URLComponents(string: urlString) else { | ||
return nil | ||
} | ||
let query: [String: String]? = components.queryItems?.reduce(into: [:]) { $0[$1.name] = $1.value } | ||
|
||
guard let topic = components.user, | ||
let version = components.host, | ||
let symKey = query?["symKey"], | ||
let relayProtocol = query?["relay-protocol"] | ||
else { return nil } | ||
let relayData = query?["relay-data"] | ||
self.version = version | ||
self.topic = topic | ||
self.symKey = symKey | ||
self.relay = RelayProtocolOptions(protocol: relayProtocol, data: relayData) | ||
} | ||
|
||
public var absoluteString: String { | ||
return "wc:\(topic)@\(version)?symKey=\(symKey)&\(relayQuery)" | ||
} | ||
|
||
private var relayQuery: String { | ||
var query = "relay-protocol=\(relay.protocol)" | ||
if let relayData = relay.data { | ||
query = "\(query)&relay-data=\(relayData)" | ||
} | ||
return query | ||
} | ||
} | ||
typealias WalletConnectURI = WalletConnectUtils.WalletConnectURI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Foundation | ||
|
||
public struct RelayProtocolOptions: Codable, Equatable { | ||
public let `protocol`: String | ||
public let data: String? | ||
|
||
public init(protocol: String, data: String?) { | ||
self.protocol = `protocol` | ||
self.data = data | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import Foundation | ||
|
||
public struct WalletConnectURI: Equatable { | ||
|
||
public let topic: String | ||
public let version: String | ||
public let symKey: String | ||
public let relay: RelayProtocolOptions | ||
|
||
public init(topic: String, symKey: String, relay: RelayProtocolOptions) { | ||
self.version = "2" | ||
self.topic = topic | ||
self.symKey = symKey | ||
self.relay = relay | ||
} | ||
|
||
public init?(string: String) { | ||
guard string.hasPrefix("wc:") else { | ||
return nil | ||
} | ||
let urlString = !string.hasPrefix("wc://") ? string.replacingOccurrences(of: "wc:", with: "wc://") : string | ||
guard let components = URLComponents(string: urlString) else { | ||
return nil | ||
} | ||
let query: [String: String]? = components.queryItems?.reduce(into: [:]) { $0[$1.name] = $1.value } | ||
|
||
guard let topic = components.user, | ||
let version = components.host, | ||
let symKey = query?["symKey"], | ||
let relayProtocol = query?["relay-protocol"] | ||
else { return nil } | ||
let relayData = query?["relay-data"] | ||
self.version = version | ||
self.topic = topic | ||
self.symKey = symKey | ||
self.relay = RelayProtocolOptions(protocol: relayProtocol, data: relayData) | ||
} | ||
|
||
public var absoluteString: String { | ||
return "wc:\(topic)@\(version)?symKey=\(symKey)&\(relayQuery)" | ||
} | ||
|
||
private var relayQuery: String { | ||
var query = "relay-protocol=\(relay.protocol)" | ||
if let relayData = relay.data { | ||
query = "\(query)&relay-data=\(relayData)" | ||
} | ||
return query | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Foundation | ||
import XCTest | ||
|
||
class AuthClientTest: XCTestCase { | ||
|
||
} |