-
Notifications
You must be signed in to change notification settings - Fork 180
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
#379 auth core types #381
Merged
Merged
#379 auth core types #381
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6f12109
Add auth target
llbartekll 2670728
Add AuthTests scheme
llbartekll 9e34bdc
add core auth services
llbartekll 1e90445
savepoint
llbartekll a8e25a4
Move WalletConnectURI to utlis package
llbartekll 1f48b60
Update basic auth methods
llbartekll 0ac81dc
Add Request Params
llbartekll 11107d8
Add AuthPayloadParams
llbartekll 24a0232
Add Cacao
llbartekll 5795f02
Add respond params
llbartekll File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 0 additions & 1 deletion
1
Example/Showcase/Classes/PresentationLayer/Import/ImportInteractor.swift
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
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,8 @@ | ||
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,16 @@ | ||
import Foundation | ||
|
||
struct AuthPayloadParams { | ||
let type: String | ||
let chainId: String | ||
let domain: String | ||
let aud: String | ||
let version: String | ||
let nonce: String | ||
let iat: String | ||
let nbf: String? | ||
let exp: String? | ||
let statement: String? | ||
let requestId: String? | ||
let resources: String? | ||
} |
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 | ||
|
||
struct CacaoHeader { | ||
let t: String | ||
} |
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,15 @@ | ||
import Foundation | ||
|
||
struct CacaoPayload { | ||
let iss: String | ||
let domain: String | ||
let aud: String | ||
let version: String | ||
let nonce: String | ||
let iat: String | ||
let nbf: String | ||
let exp: String | ||
let statement: String | ||
let requestId: String | ||
let resources: String | ||
} |
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 CacaoSignature { | ||
let t: String | ||
let s: String | ||
let m: String | ||
} |
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,13 @@ | ||
import Foundation | ||
|
||
struct RequestParams { | ||
let domain: String | ||
let chainId: String | ||
let nonce: String | ||
let aud: String | ||
let nbf: String? | ||
let exp: String? | ||
let statement: String? | ||
let requestId: String? | ||
let resources: String? | ||
} |
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 | ||
|
||
struct RespondParams { | ||
let topic: String | ||
let signature: CacaoSignature | ||
} |
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
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,6 @@ | ||
import Foundation | ||
|
||
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)" | ||
} | ||
import Foundation | ||
import WalletConnectUtils | ||
|
||
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 { | ||
|
||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still defend the approach of using readable names and declaring the abbreviated coding keys 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That’s according to cacao specs :-)