Skip to content

Commit 30f46ad

Browse files
committed
Fix indentation, add contributors, address warnings, bump version
1 parent 7fe7a16 commit 30f46ad

File tree

9 files changed

+56
-39
lines changed

9 files changed

+56
-39
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ Changelog
44
Version numbering represents the Swift version, plus a running number representing updates, fixes and new features at the same time.
55
You can also refer to commit logs to get details on what was implemented, fixed and improved.
66

7+
#### 5.3.2
8+
9+
- Fix tvOS build.
10+
[m4p](https://github.com/m4p)
11+
[#372](https://github.com/p2/OAuth2/pull/372)
12+
- Fix `ASWebAuthenticationSession` for SwiftUI.
13+
[longinius](https://github.com/longinius)
14+
[#361](https://github.com/p2/OAuth2/pull/361)
15+
716
#### 5.3.1
817

918
- Fix `ASWebAuthenticationSession` implementation even more.

CONTRIBUTORS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ Contributors
33

44
Contributors to the codebase, in reverse chronological order:
55

6+
- Martin Pittenauer, @m4p
7+
- Lars, @longinius
68
- Christian Gossain, @cgossain
79
- James Addyman, @james-rantmedia
810
- Foti Dim, @fotidim

Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>5.1.0</string>
18+
<string>$(MARKETING_VERSION)</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

OAuth2.xcodeproj/project.pbxproj

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -826,9 +826,10 @@
826826
INFOPLIST_FILE = "$(SRCROOT)/Info.plist";
827827
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
828828
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
829+
MARKETING_VERSION = 5.3.2;
829830
MTL_ENABLE_DEBUG_INFO = YES;
830831
OTHER_SWIFT_FLAGS = "-DNO_KEYCHAIN_IMPORT -DNO_MODULE_IMPORT";
831-
PRODUCT_BUNDLE_IDENTIFIER = "org.chip.${PRODUCT_NAME:rfc1034identifier}";
832+
PRODUCT_BUNDLE_IDENTIFIER = com.github.p2.OAuth2;
832833
PRODUCT_NAME = OAuth2;
833834
SDKROOT = appletvos;
834835
SKIP_INSTALL = YES;
@@ -853,9 +854,10 @@
853854
INFOPLIST_FILE = "$(SRCROOT)/Info.plist";
854855
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
855856
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
857+
MARKETING_VERSION = 5.3.2;
856858
MTL_ENABLE_DEBUG_INFO = NO;
857859
OTHER_SWIFT_FLAGS = "-DNO_KEYCHAIN_IMPORT -DNO_MODULE_IMPORT";
858-
PRODUCT_BUNDLE_IDENTIFIER = "org.chip.${PRODUCT_NAME:rfc1034identifier}";
860+
PRODUCT_BUNDLE_IDENTIFIER = com.github.p2.OAuth2;
859861
PRODUCT_NAME = OAuth2;
860862
SDKROOT = appletvos;
861863
SKIP_INSTALL = YES;
@@ -995,6 +997,7 @@
995997
INFOPLIST_FILE = "$(SRCROOT)/Info.plist";
996998
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
997999
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
1000+
MARKETING_VERSION = 5.3.2;
9981001
OTHER_SWIFT_FLAGS = "-DNO_KEYCHAIN_IMPORT -DNO_MODULE_IMPORT";
9991002
PRODUCT_BUNDLE_IDENTIFIER = "com.github.p2.${PRODUCT_NAME:rfc1034identifier}";
10001003
PRODUCT_NAME = OAuth2;
@@ -1017,6 +1020,7 @@
10171020
INFOPLIST_FILE = "$(SRCROOT)/Info.plist";
10181021
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
10191022
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
1023+
MARKETING_VERSION = 5.3.2;
10201024
OTHER_SWIFT_FLAGS = "-DNO_KEYCHAIN_IMPORT -DNO_MODULE_IMPORT";
10211025
PRODUCT_BUNDLE_IDENTIFIER = "com.github.p2.${PRODUCT_NAME:rfc1034identifier}";
10221026
PRODUCT_NAME = OAuth2;
@@ -1039,6 +1043,7 @@
10391043
INFOPLIST_FILE = "$(SRCROOT)/Info.plist";
10401044
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
10411045
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
1046+
MARKETING_VERSION = 5.3.2;
10421047
OTHER_SWIFT_FLAGS = "-DNO_KEYCHAIN_IMPORT -DNO_MODULE_IMPORT";
10431048
PRODUCT_BUNDLE_IDENTIFIER = "com.github.p2.${PRODUCT_NAME:rfc1034identifier}";
10441049
PRODUCT_NAME = OAuth2;
@@ -1062,6 +1067,7 @@
10621067
INFOPLIST_FILE = "$(SRCROOT)/Info.plist";
10631068
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
10641069
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
1070+
MARKETING_VERSION = 5.3.2;
10651071
OTHER_SWIFT_FLAGS = "-DNO_KEYCHAIN_IMPORT -DNO_MODULE_IMPORT";
10661072
PRODUCT_BUNDLE_IDENTIFIER = "com.github.p2.${PRODUCT_NAME:rfc1034identifier}";
10671073
PRODUCT_NAME = OAuth2;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

Sources/iOS/OAuth2Authorizer+iOS.swift

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ open class OAuth2Authorizer: OAuth2AuthorizerUI {
4242

4343
/// Used to store the authentication session.
4444
private var authenticationSession: AnyObject?
45-
45+
4646
/// Used to store the ASWebAuthenticationPresentationContextProvider
4747
private var webAuthenticationPresentationContextProvider: AnyObject?
48-
48+
4949
public init(oauth2: OAuth2Base) {
5050
self.oauth2 = oauth2
5151
}
@@ -137,7 +137,7 @@ open class OAuth2Authorizer: OAuth2AuthorizerUI {
137137
*/
138138
@available(iOS 11.0, *)
139139
@discardableResult
140-
public func authenticationSessionEmbedded(at url: URL, withRedirect redirect: String, prefersEphemeralWebBrowserSession prefersEphemeralWebBrowserSession: Bool = false) -> Bool {
140+
public func authenticationSessionEmbedded(at url: URL, withRedirect redirect: String, prefersEphemeralWebBrowserSession: Bool = false) -> Bool {
141141
guard let redirectURL = URL(string: redirect) else {
142142
oauth2.logger?.warn("OAuth2", msg: "Unable to parse redirect URL ”(redirect)“")
143143
return false
@@ -166,26 +166,21 @@ open class OAuth2Authorizer: OAuth2AuthorizerUI {
166166
self.authenticationSession = nil
167167
self.webAuthenticationPresentationContextProvider = nil
168168
}
169-
170-
#if targetEnvironment(macCatalyst)
169+
170+
#if targetEnvironment(macCatalyst)
171171
authenticationSession = ASWebAuthenticationSession(url: url, callbackURLScheme: redirectURL.scheme, completionHandler: completionHandler)
172172
return (authenticationSession as! ASWebAuthenticationSession).start()
173-
#else
174-
if #available(iOS 12, *) {
175-
authenticationSession = ASWebAuthenticationSession(url: url, callbackURLScheme: redirectURL.scheme, completionHandler: completionHandler)
176-
if #available(iOS 13.0, *) {
177-
webAuthenticationPresentationContextProvider = OAuth2ASWebAuthenticationPresentationContextProvider(authorizer: self)
178-
if let session = authenticationSession as? ASWebAuthenticationSession {
179-
session.presentationContextProvider = webAuthenticationPresentationContextProvider as! OAuth2ASWebAuthenticationPresentationContextProvider
180-
session.prefersEphemeralWebBrowserSession = prefersEphemeralWebBrowserSession
181-
}
173+
#else
174+
authenticationSession = ASWebAuthenticationSession(url: url, callbackURLScheme: redirectURL.scheme, completionHandler: completionHandler)
175+
if #available(iOS 13.0, *) {
176+
webAuthenticationPresentationContextProvider = OAuth2ASWebAuthenticationPresentationContextProvider(authorizer: self)
177+
if let session = authenticationSession as? ASWebAuthenticationSession {
178+
session.presentationContextProvider = webAuthenticationPresentationContextProvider as! OAuth2ASWebAuthenticationPresentationContextProvider
179+
session.prefersEphemeralWebBrowserSession = prefersEphemeralWebBrowserSession
182180
}
183-
return (authenticationSession as! ASWebAuthenticationSession).start()
184-
} else {
185-
authenticationSession = SFAuthenticationSession(url: url, callbackURLScheme: redirect, completionHandler: completionHandler)
186-
return (authenticationSession as! SFAuthenticationSession).start()
187181
}
188-
#endif
182+
return (authenticationSession as! ASWebAuthenticationSession).start()
183+
#endif
189184
}
190185

191186

@@ -320,23 +315,23 @@ class OAuth2SFViewControllerDelegate: NSObject, SFSafariViewControllerDelegate {
320315

321316
@available(iOS 13.0, *)
322317
class OAuth2ASWebAuthenticationPresentationContextProvider: NSObject, ASWebAuthenticationPresentationContextProviding {
323-
318+
324319
private let authorizer: OAuth2Authorizer
325-
320+
326321
init(authorizer: OAuth2Authorizer) {
327322
self.authorizer = authorizer
328323
}
329-
324+
330325
public func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
331-
if let context = authorizer.oauth2.authConfig.authorizeContext as? ASPresentationAnchor {
332-
return context
333-
}
334-
335-
if let context = authorizer.oauth2.authConfig.authorizeContext as? UIViewController {
336-
return context.view.window!
337-
}
338-
339-
fatalError("Invalid authConfig.authorizeContext, must be an ASPresentationAnchor but is \(String(describing: authorizer.oauth2.authConfig.authorizeContext))")
326+
if let context = authorizer.oauth2.authConfig.authorizeContext as? ASPresentationAnchor {
327+
return context
328+
}
329+
330+
if let context = authorizer.oauth2.authConfig.authorizeContext as? UIViewController {
331+
return context.view.window!
332+
}
333+
334+
fatalError("Invalid authConfig.authorizeContext, must be an ASPresentationAnchor but is \(String(describing: authorizer.oauth2.authConfig.authorizeContext))")
340335
}
341336
}
342337

Sources/tvOS/OAuth2Authorizer+tvOS.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,11 @@ public final class OAuth2Authorizer: OAuth2AuthorizerUI {
3030
/// The OAuth2 instance this authorizer belongs to.
3131
public unowned let oauth2: OAuth2Base
3232

33-
3433
public init(oauth2: OAuth2Base) {
3534
self.oauth2 = oauth2
3635
}
3736

38-
3937
// no webview or webbrowser available on tvOS
40-
4138
public func openAuthorizeURLInBrowser(_ url: URL) throws {
4239
throw OAuth2Error.generic("Not implemented")
4340
}

generate-docs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
bundle exec jazzy \
77
-o "docs" \
88
--min-acl "internal" \
9-
--module-version "5.3.1"
9+
--module-version "5.3.2"
1010

1111
mkdir docs/assets 2>/dev/null
1212
cp assets/* docs/assets/

p2.OAuth2.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
Pod::Spec.new do |s|
99
s.name = 'p2.OAuth2'
10-
s.version = '5.3.1'
10+
s.version = '5.3.2'
1111
s.summary = 'OAuth2 framework for macOS, iOS and tvOS, written in Swift.'
1212
s.description = <<-DESC
1313
OAuth2 frameworks for macOS, iOS and tvOS written in Swift.

0 commit comments

Comments
 (0)