Skip to content

Commit

Permalink
Fix SwiftLint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
conradev committed Sep 8, 2024
1 parent fa1ef6f commit 3fbb520
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .github/actions/build-for-testing/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ runs:
Apple/DerivedData
key: ${{ runner.os }}-${{ inputs.scheme }}-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-${{ inputs.scheme }}-${{ hashFiles('**/Package.resolved') }}
${{ runner.os }}-${{ inputs.scheme }}-
${{ runner.os }}-
- name: Build
shell: bash
working-directory: Apple
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/build-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ jobs:
- x86_64-unknown-linux-gnu
targets:
- aarch64-unknown-linux-gnu
- os: macos-12
- os: macos-13
platform: macOS (Intel)
xcode: /Applications/Xcode_15.2.app
test-targets:
- x86_64-apple-darwin
targets:
- x86_64-apple-ios
- os: macos-14
platform: macOS
xcode: /Applications/Xcode_16.0.app
test-targets:
- aarch64-apple-darwin
targets:
Expand All @@ -42,7 +44,7 @@ jobs:
- aarch64-pc-windows-msvc
runs-on: ${{ matrix.os }}
env:
DEVELOPER_DIR: /Applications/Xcode_16.0.app/Contents/Developer
DEVELOPER_DIR: ${{ matrix.xcode }}/Contents/Developer
CARGO_INCREMENTAL: 0
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
RUST_BACKTRACE: short
Expand Down
3 changes: 2 additions & 1 deletion Apple/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import AppKit
import SwiftUI

@MainActor @main
@main
@MainActor
class AppDelegate: NSObject, NSApplicationDelegate {
private let quitItem: NSMenuItem = {
let quitItem = NSMenuItem(
Expand Down
1 change: 0 additions & 1 deletion Apple/App/BurrowView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ struct BurrowView: View {
}

private func addWireGuardNetwork() {

}

private func authenticateWithSlack() async throws {
Expand Down
46 changes: 25 additions & 21 deletions Apple/App/OAuth2.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import AuthenticationServices
import SwiftUI
import Foundation
import SwiftUI

enum OAuth2 {
enum Error: Swift.Error {
Expand Down Expand Up @@ -35,7 +35,7 @@ enum OAuth2 {
}
}

public init(
init(
authorizationEndpoint: URL,
tokenEndpoint: URL,
redirectURI: URL,
Expand Down Expand Up @@ -125,7 +125,11 @@ enum OAuth2 {
var refreshToken: String?

var credential: Credential {
.init(accessToken: accessToken, refreshToken: refreshToken, expirationDate: expiresIn.map { Date.init(timeIntervalSinceNow: $0) })
.init(
accessToken: accessToken,
refreshToken: refreshToken,
expirationDate: expiresIn.map { Date(timeIntervalSinceNow: $0) }
)
}
}

Expand Down Expand Up @@ -203,7 +207,24 @@ enum OAuth2 {
}

extension WebAuthenticationSession {
func start(url: URL, redirectURI: URL) async throws -> URL {
#if canImport(BrowserEngineKit)
@available(iOS 17.4, macOS 14.4, tvOS 17.4, watchOS 10.4, *)
fileprivate static func callback(for redirectURI: URL) throws -> ASWebAuthenticationSession.Callback {
switch redirectURI.scheme {
case "https":
guard let host = redirectURI.host else { throw OAuth2.Error.invalidRedirectURI }
return .https(host: host, path: redirectURI.path)
case "http":
throw OAuth2.Error.invalidRedirectURI
case .some(let scheme):
return .customScheme(scheme)
case .none:
throw OAuth2.Error.invalidRedirectURI
}
}
#endif

fileprivate func start(url: URL, redirectURI: URL) async throws -> URL {
#if canImport(BrowserEngineKit)
if #available(iOS 17.4, macOS 14.4, tvOS 17.4, watchOS 10.4, *) {
return try await authenticate(
Expand Down Expand Up @@ -231,23 +252,6 @@ extension WebAuthenticationSession {
return url
}
}

#if canImport(BrowserEngineKit)
@available(iOS 17.4, macOS 14.4, tvOS 17.4, watchOS 10.4, *)
fileprivate static func callback(for redirectURI: URL) throws -> ASWebAuthenticationSession.Callback {
switch redirectURI.scheme {
case "https":
guard let host = redirectURI.host else { throw OAuth2.Error.invalidRedirectURI }
return .https(host: host, path: redirectURI.path)
case "http":
throw OAuth2.Error.invalidRedirectURI
case .some(let scheme):
return .customScheme(scheme)
case .none:
throw OAuth2.Error.invalidRedirectURI
}
}
#endif
}

extension View {
Expand Down

0 comments on commit 3fbb520

Please sign in to comment.