Skip to content

Commit

Permalink
Fix indentation, add contributors, address warnings, bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
ossus-lib committed Sep 12, 2021
1 parent 7fe7a16 commit 30f46ad
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 39 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ Changelog
Version numbering represents the Swift version, plus a running number representing updates, fixes and new features at the same time.
You can also refer to commit logs to get details on what was implemented, fixed and improved.

#### 5.3.2

- Fix tvOS build.
[m4p](https://github.com/m4p)
[#372](https://github.com/p2/OAuth2/pull/372)
- Fix `ASWebAuthenticationSession` for SwiftUI.
[longinius](https://github.com/longinius)
[#361](https://github.com/p2/OAuth2/pull/361)

#### 5.3.1

- Fix `ASWebAuthenticationSession` implementation even more.
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Contributors

Contributors to the codebase, in reverse chronological order:

- Martin Pittenauer, @m4p
- Lars, @longinius
- Christian Gossain, @cgossain
- James Addyman, @james-rantmedia
- Foti Dim, @fotidim
Expand Down
2 changes: 1 addition & 1 deletion Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>5.1.0</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
10 changes: 8 additions & 2 deletions OAuth2.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -826,9 +826,10 @@
INFOPLIST_FILE = "$(SRCROOT)/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 5.3.2;
MTL_ENABLE_DEBUG_INFO = YES;
OTHER_SWIFT_FLAGS = "-DNO_KEYCHAIN_IMPORT -DNO_MODULE_IMPORT";
PRODUCT_BUNDLE_IDENTIFIER = "org.chip.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_BUNDLE_IDENTIFIER = com.github.p2.OAuth2;
PRODUCT_NAME = OAuth2;
SDKROOT = appletvos;
SKIP_INSTALL = YES;
Expand All @@ -853,9 +854,10 @@
INFOPLIST_FILE = "$(SRCROOT)/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 5.3.2;
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_SWIFT_FLAGS = "-DNO_KEYCHAIN_IMPORT -DNO_MODULE_IMPORT";
PRODUCT_BUNDLE_IDENTIFIER = "org.chip.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_BUNDLE_IDENTIFIER = com.github.p2.OAuth2;
PRODUCT_NAME = OAuth2;
SDKROOT = appletvos;
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -995,6 +997,7 @@
INFOPLIST_FILE = "$(SRCROOT)/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 5.3.2;
OTHER_SWIFT_FLAGS = "-DNO_KEYCHAIN_IMPORT -DNO_MODULE_IMPORT";
PRODUCT_BUNDLE_IDENTIFIER = "com.github.p2.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = OAuth2;
Expand All @@ -1017,6 +1020,7 @@
INFOPLIST_FILE = "$(SRCROOT)/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 5.3.2;
OTHER_SWIFT_FLAGS = "-DNO_KEYCHAIN_IMPORT -DNO_MODULE_IMPORT";
PRODUCT_BUNDLE_IDENTIFIER = "com.github.p2.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = OAuth2;
Expand All @@ -1039,6 +1043,7 @@
INFOPLIST_FILE = "$(SRCROOT)/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MARKETING_VERSION = 5.3.2;
OTHER_SWIFT_FLAGS = "-DNO_KEYCHAIN_IMPORT -DNO_MODULE_IMPORT";
PRODUCT_BUNDLE_IDENTIFIER = "com.github.p2.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = OAuth2;
Expand All @@ -1062,6 +1067,7 @@
INFOPLIST_FILE = "$(SRCROOT)/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MARKETING_VERSION = 5.3.2;
OTHER_SWIFT_FLAGS = "-DNO_KEYCHAIN_IMPORT -DNO_MODULE_IMPORT";
PRODUCT_BUNDLE_IDENTIFIER = "com.github.p2.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = OAuth2;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
57 changes: 26 additions & 31 deletions Sources/iOS/OAuth2Authorizer+iOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ open class OAuth2Authorizer: OAuth2AuthorizerUI {

/// Used to store the authentication session.
private var authenticationSession: AnyObject?

/// Used to store the ASWebAuthenticationPresentationContextProvider
private var webAuthenticationPresentationContextProvider: AnyObject?

public init(oauth2: OAuth2Base) {
self.oauth2 = oauth2
}
Expand Down Expand Up @@ -137,7 +137,7 @@ open class OAuth2Authorizer: OAuth2AuthorizerUI {
*/
@available(iOS 11.0, *)
@discardableResult
public func authenticationSessionEmbedded(at url: URL, withRedirect redirect: String, prefersEphemeralWebBrowserSession prefersEphemeralWebBrowserSession: Bool = false) -> Bool {
public func authenticationSessionEmbedded(at url: URL, withRedirect redirect: String, prefersEphemeralWebBrowserSession: Bool = false) -> Bool {
guard let redirectURL = URL(string: redirect) else {
oauth2.logger?.warn("OAuth2", msg: "Unable to parse redirect URL ”(redirect)“")
return false
Expand Down Expand Up @@ -166,26 +166,21 @@ open class OAuth2Authorizer: OAuth2AuthorizerUI {
self.authenticationSession = nil
self.webAuthenticationPresentationContextProvider = nil
}

#if targetEnvironment(macCatalyst)
#if targetEnvironment(macCatalyst)
authenticationSession = ASWebAuthenticationSession(url: url, callbackURLScheme: redirectURL.scheme, completionHandler: completionHandler)
return (authenticationSession as! ASWebAuthenticationSession).start()
#else
if #available(iOS 12, *) {
authenticationSession = ASWebAuthenticationSession(url: url, callbackURLScheme: redirectURL.scheme, completionHandler: completionHandler)
if #available(iOS 13.0, *) {
webAuthenticationPresentationContextProvider = OAuth2ASWebAuthenticationPresentationContextProvider(authorizer: self)
if let session = authenticationSession as? ASWebAuthenticationSession {
session.presentationContextProvider = webAuthenticationPresentationContextProvider as! OAuth2ASWebAuthenticationPresentationContextProvider
session.prefersEphemeralWebBrowserSession = prefersEphemeralWebBrowserSession
}
#else
authenticationSession = ASWebAuthenticationSession(url: url, callbackURLScheme: redirectURL.scheme, completionHandler: completionHandler)
if #available(iOS 13.0, *) {
webAuthenticationPresentationContextProvider = OAuth2ASWebAuthenticationPresentationContextProvider(authorizer: self)
if let session = authenticationSession as? ASWebAuthenticationSession {
session.presentationContextProvider = webAuthenticationPresentationContextProvider as! OAuth2ASWebAuthenticationPresentationContextProvider
session.prefersEphemeralWebBrowserSession = prefersEphemeralWebBrowserSession
}
return (authenticationSession as! ASWebAuthenticationSession).start()
} else {
authenticationSession = SFAuthenticationSession(url: url, callbackURLScheme: redirect, completionHandler: completionHandler)
return (authenticationSession as! SFAuthenticationSession).start()
}
#endif
return (authenticationSession as! ASWebAuthenticationSession).start()
#endif
}


Expand Down Expand Up @@ -320,23 +315,23 @@ class OAuth2SFViewControllerDelegate: NSObject, SFSafariViewControllerDelegate {

@available(iOS 13.0, *)
class OAuth2ASWebAuthenticationPresentationContextProvider: NSObject, ASWebAuthenticationPresentationContextProviding {

private let authorizer: OAuth2Authorizer

init(authorizer: OAuth2Authorizer) {
self.authorizer = authorizer
}

public func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
if let context = authorizer.oauth2.authConfig.authorizeContext as? ASPresentationAnchor {
return context
}

if let context = authorizer.oauth2.authConfig.authorizeContext as? UIViewController {
return context.view.window!
}

fatalError("Invalid authConfig.authorizeContext, must be an ASPresentationAnchor but is \(String(describing: authorizer.oauth2.authConfig.authorizeContext))")
if let context = authorizer.oauth2.authConfig.authorizeContext as? ASPresentationAnchor {
return context
}
if let context = authorizer.oauth2.authConfig.authorizeContext as? UIViewController {
return context.view.window!
}
fatalError("Invalid authConfig.authorizeContext, must be an ASPresentationAnchor but is \(String(describing: authorizer.oauth2.authConfig.authorizeContext))")
}
}

Expand Down
3 changes: 0 additions & 3 deletions Sources/tvOS/OAuth2Authorizer+tvOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,11 @@ public final class OAuth2Authorizer: OAuth2AuthorizerUI {
/// The OAuth2 instance this authorizer belongs to.
public unowned let oauth2: OAuth2Base


public init(oauth2: OAuth2Base) {
self.oauth2 = oauth2
}


// no webview or webbrowser available on tvOS

public func openAuthorizeURLInBrowser(_ url: URL) throws {
throw OAuth2Error.generic("Not implemented")
}
Expand Down
2 changes: 1 addition & 1 deletion generate-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
bundle exec jazzy \
-o "docs" \
--min-acl "internal" \
--module-version "5.3.1"
--module-version "5.3.2"

mkdir docs/assets 2>/dev/null
cp assets/* docs/assets/
2 changes: 1 addition & 1 deletion p2.OAuth2.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

Pod::Spec.new do |s|
s.name = 'p2.OAuth2'
s.version = '5.3.1'
s.version = '5.3.2'
s.summary = 'OAuth2 framework for macOS, iOS and tvOS, written in Swift.'
s.description = <<-DESC
OAuth2 frameworks for macOS, iOS and tvOS written in Swift.
Expand Down

0 comments on commit 30f46ad

Please sign in to comment.