Skip to content

Commit

Permalink
update: macos support
Browse files Browse the repository at this point in the history
  • Loading branch information
metalurgical committed Jun 12, 2024
1 parent d66f90c commit 9904196
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 86 deletions.
88 changes: 12 additions & 76 deletions Development.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
@@ -1,79 +1,15 @@
{
"object": {
"pins": [
{
"package": "BigInt",
"repositoryURL": "https://github.com/attaswift/BigInt.git",
"state": {
"branch": null,
"revision": "0ed110f7555c34ff468e72e1686e59721f2b0da6",
"version": "5.3.0"
}
},
{
"package": "curvelib.swift",
"repositoryURL": "https://github.com/tkey/curvelib.swift",
"state": {
"branch": null,
"revision": "9f88bd5e56d1df443a908f7a7e81ae4f4d9170ea",
"version": "1.0.1"
}
},
{
"package": "FetchNodeDetails",
"repositoryURL": "https://github.com/torusresearch/fetch-node-details-swift",
"state": {
"branch": null,
"revision": "22bfadf7491d77a0bc1953af002cadbd61383e7d",
"version": "6.0.2"
}
},
{
"package": "jwt-kit",
"repositoryURL": "https://github.com/vapor/jwt-kit.git",
"state": {
"branch": null,
"revision": "e05513b5aec24f88012b6e3034115b6bc915356a",
"version": "4.13.2"
}
},
{
"package": "JWTDecode",
"repositoryURL": "https://github.com/auth0/JWTDecode.swift.git",
"state": {
"branch": null,
"revision": "58af7278797871e460d79496621b3e5366b865b2",
"version": "3.1.0"
}
},
{
"package": "PromiseKit",
"repositoryURL": "https://github.com/mxcl/PromiseKit",
"state": {
"branch": null,
"revision": "cb70b070cde06837cd10a1febdf6105c1a3bb348",
"version": "8.1.1"
}
},
{
"package": "swift-crypto",
"repositoryURL": "https://github.com/apple/swift-crypto.git",
"state": {
"branch": null,
"revision": "f0525da24dc3c6cbb2b6b338b65042bc91cbc4bb",
"version": "3.3.0"
}
},
{
"package": "TorusUtils",
"repositoryURL": "https://github.com/torusresearch/torus-utils-swift.git",
"state": {
"branch": "feature_updates",
"revision": "c42f8a4209b9278be2bdbef5f63818ee7c3e3730",
"version": null
}
"originHash" : "15db2e52658433a7d473400cc03eb7d9196e5e1ee7c0636fcf9c95b35e7c0bf1",
"pins" : [
{
"identity" : "promisekit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/mxcl/PromiseKit",
"state" : {
"revision" : "cb70b070cde06837cd10a1febdf6105c1a3bb348",
"version" : "8.1.1"
}
]
},
"version": 1
}
],
"version" : 3
}
4 changes: 0 additions & 4 deletions Notice.md

This file was deleted.

10 changes: 5 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// swift-tools-version:5.5
// swift-tools-version:5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "CustomAuth",
platforms: [
.iOS(.v13)
.iOS(.v13), .macOS(.v11)
],
products: [
.library(
Expand All @@ -15,15 +15,15 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/torusresearch/torus-utils-swift.git", branch: "feature_updates"), // TODO: Change to 9.0.0
.package(name: "JWTDecode", url: "https://github.com/auth0/JWTDecode.swift.git", from: "3.1.0"),
.package(url: "https://github.com/auth0/JWTDecode.swift.git", from: "3.1.0"),
.package(url: "https://github.com/tkey/curvelib.swift", from: "1.0.1"),
// NB: jwt-kit may only be a test dependency or it will break cocoapods support
.package(name: "jwt-kit", url: "https://github.com/vapor/jwt-kit.git", from: "4.13.0"),
.package(url: "https://github.com/vapor/jwt-kit.git", from: "4.13.0"),
],
targets: [
.target(
name: "CustomAuth",
dependencies: ["JWTDecode", .product(name: "curveSecp256k1", package: "curvelib.swift"), .product(name: "TorusUtils", package: "torus-utils-swift")]),
dependencies: [.product(name: "JWTDecode", package: "JWTDecode.swift"), .product(name: "curveSecp256k1", package: "curvelib.swift"), .product(name: "TorusUtils", package: "torus-utils-swift")]),
.testTarget(
name: "CustomAuthTests",
dependencies: ["CustomAuth", .product(name: "JWTKit", package: "jwt-kit")])
Expand Down
12 changes: 11 additions & 1 deletion Sources/CustomAuth/Handlers/AuthenticationManager.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import AuthenticationServices
#if os(macOS)
import AppKit
#else
import UIKit
#endif

public class AuthenticationManager: NSObject, ASWebAuthenticationPresentationContextProviding {
public func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
let window = UIApplication.shared.windows.first { $0.isKeyWindow }
var window: ASPresentationAnchor? = nil
#if os(macOS)
window = NSApplication.shared.windows.first { $0.isKeyWindow }
#else
window = UIApplication.shared.windows.first { $0.isKeyWindow }
#endif

return window ?? ASPresentationAnchor()
}

Expand Down

0 comments on commit 9904196

Please sign in to comment.