Skip to content
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

Drop platform versions [SDK-2895] #527

Merged
merged 12 commits into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions App/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

import UIKit
import Auth0
#if canImport(AuthenticationServices)
import AuthenticationServices
#endif

class ViewController: UIViewController {

Expand Down
27 changes: 11 additions & 16 deletions Auth0.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ web_auth_files = [
'Auth0/ObjectiveC/A0RSA.m',
'Auth0/ObjectiveC/A0SHA.h',
'Auth0/ObjectiveC/A0SHA.m',
'Auth0/A0SimpleKeychain+RSAPublicKey.swift',
'Auth0/Array+Encode.swift',
'Auth0/ASCallbackTransaction.swift',
'Auth0/ASTransaction.swift',
'Auth0/AuthCancelable.swift',
'Auth0/AuthProvider.swift',
'Auth0/AuthSession.swift',
'Auth0/AuthTransaction.swift',
'Auth0/AuthenticationServicesSession.swift',
'Auth0/AuthenticationServicesSessionCallback.swift',
'Auth0/BaseAuthTransaction.swift',
'Auth0/BaseWebAuth.swift',
'Auth0/Auth0WebAuth.swift',
'Auth0/BaseCallbackTransaction.swift',
'Auth0/BaseTransaction.swift',
'Auth0/BioAuthentication.swift',
'Auth0/ClaimValidators.swift',
'Auth0/IDTokenSignatureValidator.swift',
Expand All @@ -27,19 +27,14 @@ web_auth_files = [
'Auth0/NSURLComponents+OAuth2.swift',
'Auth0/OAuth2Grant.swift',
'Auth0/ResponseType.swift',
'Auth0/SessionCallbackTransaction.swift',
'Auth0/SessionTransaction.swift',
'Auth0/TransactionStore.swift',
'Auth0/WebAuthenticatable.swift',
'Auth0/WebAuth.swift',
'Auth0/WebAuthError.swift',
'Auth0/_ObjectiveWebAuth.swift'
]

ios_files = [
'Auth0/ControllerModalPresenter.swift',
'Auth0/MobileWebAuth.swift',
'Auth0/SafariSession.swift',
'Auth0/SilentSafariViewController.swift',
'Auth0/UIApplication+Shared.swift'
]

Expand All @@ -56,7 +51,7 @@ excluded_files = [

Pod::Spec.new do |s|
s.name = 'Auth0'
s.version = '1.38.0'
s.version = '2.0.0-beta'
s.summary = "Swift toolkit for Auth0 API"
s.description = <<-DESC
Auth0 API toolkit written in Swift for iOS, watchOS, tvOS & macOS apps
Expand All @@ -67,10 +62,10 @@ Pod::Spec.new do |s|
s.source = { :git => 'https://github.com/auth0/Auth0.swift.git', :tag => s.version.to_s }
s.social_media_url = 'https://twitter.com/auth0'

s.ios.deployment_target = '9.0'
s.osx.deployment_target = '10.11'
s.watchos.deployment_target = '2.0'
s.tvos.deployment_target = '9.0'
s.ios.deployment_target = '12.0'
s.osx.deployment_target = '10.15'
s.watchos.deployment_target = '6.2'
s.tvos.deployment_target = '12.0'
s.requires_arc = true

s.ios.source_files = 'Auth0/*.{swift,h,m}', 'Auth0/ObjectiveC/*.{h,m}'
Expand Down
178 changes: 71 additions & 107 deletions Auth0.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

42 changes: 0 additions & 42 deletions Auth0/A0SimpleKeychain+RSAPublicKey.swift

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// AuthenticationServicesSessionCallback.swift
// ASCallbackTransaction.swift
//
// Copyright (c) 2020 Auth0 (http://auth0.com)
//
Expand All @@ -20,11 +20,10 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#if WEB_AUTH_PLATFORM && canImport(AuthenticationServices)
#if WEB_AUTH_PLATFORM
import AuthenticationServices

@available(iOS 12.0, macOS 10.15, *)
final class AuthenticationServicesSessionCallback: SessionCallbackTransaction {
final class ASCallbackTransaction: BaseCallbackTransaction {

init(url: URL, schemeURL: URL, callback: @escaping (Bool) -> Void) {
super.init(callback: callback)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// AuthenticationServicesSession.swift
// ASTransaction.swift
//
// Copyright (c) 2020 Auth0 (http://auth0.com)
//
Expand All @@ -20,11 +20,10 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#if WEB_AUTH_PLATFORM && canImport(AuthenticationServices)
#if WEB_AUTH_PLATFORM
import AuthenticationServices

@available(iOS 12.0, macOS 10.15, *)
final class AuthenticationServicesSession: SessionTransaction {
final class ASTransaction: BaseTransaction {

init(authorizeURL: URL,
redirectURL: URL,
Expand Down Expand Up @@ -66,6 +65,5 @@ final class AuthenticationServicesSession: SessionTransaction {

}

@available(iOS 12.0, macOS 10.15, *)
extension ASWebAuthenticationSession: AuthSession {}
#endif
83 changes: 24 additions & 59 deletions Auth0/BaseWebAuth.swift → Auth0/Auth0WebAuth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@
// THE SOFTWARE.

#if WEB_AUTH_PLATFORM
#if canImport(AuthenticationServices)
import AuthenticationServices
#endif

class BaseWebAuth: WebAuthenticatable {
final class Auth0WebAuth: WebAuth {

let clientId: String
let url: URL
Expand All @@ -35,7 +33,12 @@ class BaseWebAuth: WebAuthenticatable {
var universalLink = false
var ephemeralSession = false

private let platform: String
#if os(macOS)
private let platform = "macos"
#else
private let platform = "ios"
#endif

private(set) var parameters: [String: String] = [:]
private(set) var issuer: String
private(set) var leeway: Int = 60 * 1000 // Default leeway is 60 seconds
Expand All @@ -55,8 +58,10 @@ class BaseWebAuth: WebAuthenticatable {
.appendingPathComponent("callback")
}()

init(platform: String, clientId: String, url: URL, storage: TransactionStore, telemetry: Telemetry) {
self.platform = platform
init(clientId: String,
url: URL,
storage: TransactionStore = TransactionStore.shared,
telemetry: Telemetry = Telemetry()) {
self.clientId = clientId
self.url = url
self.storage = storage
Expand Down Expand Up @@ -176,37 +181,15 @@ class BaseWebAuth: WebAuthenticatable {
state: state,
organization: organization,
invitation: invitation)

// performLogin must handle the callback
if let session = performLogin(authorizeURL: authorizeURL,
redirectURL: redirectURL,
state: state,
handler: handler,
callback: callback) {
logger?.trace(url: authorizeURL, source: String(describing: session.self))
self.storage.store(session)
}
}

func performLogin(authorizeURL: URL,
redirectURL: URL,
state: String?,
handler: OAuth2Grant,
callback: @escaping (Result<Credentials>) -> Void) -> AuthTransaction? {
#if canImport(AuthenticationServices)
if #available(iOS 12.0, macOS 10.15, *) {
return AuthenticationServicesSession(authorizeURL: authorizeURL,
redirectURL: redirectURL,
state: state,
handler: handler,
logger: self.logger,
ephemeralSession: self.ephemeralSession,
callback: callback)
}
#endif
// TODO: On the next major add a new case to WebAuthError
callback(.failure(WebAuthError.unknownError))
return nil
let session = ASTransaction(authorizeURL: authorizeURL,
redirectURL: redirectURL,
state: state,
handler: handler,
logger: self.logger,
ephemeralSession: self.ephemeralSession,
callback: callback)
logger?.trace(url: authorizeURL, source: String(describing: session.self))
self.storage.store(session)
}

func clearSession(federated: Bool, callback: @escaping (Bool) -> Void) {
Expand All @@ -224,28 +207,10 @@ class BaseWebAuth: WebAuthenticatable {
return callback(false)
}

// performLogout must handle the callback
if let session = performLogout(logoutURL: logoutURL,
redirectURL: redirectURL,
federated: federated,
callback: callback) {
self.storage.store(session)
}
}

func performLogout(logoutURL: URL,
redirectURL: URL,
federated: Bool,
callback: @escaping (Bool) -> Void) -> AuthTransaction? {
#if canImport(AuthenticationServices)
if #available(iOS 12.0, macOS 10.15, *) {
return AuthenticationServicesSessionCallback(url: logoutURL,
schemeURL: redirectURL,
callback: callback)
}
#endif
callback(false)
return nil
let session = ASCallbackTransaction(url: logoutURL,
schemeURL: redirectURL,
callback: callback)
self.storage.store(session)
}

func buildAuthorizeURL(withRedirectURL redirectURL: URL,
Expand Down
35 changes: 0 additions & 35 deletions Auth0/AuthCancelable.swift

This file was deleted.

17 changes: 16 additions & 1 deletion Auth0/AuthTransaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
// THE SOFTWARE.

#if WEB_AUTH_PLATFORM
import Foundation

/**
Represents an ongoing Auth transaction with an Identity Provider (Auth0 or a third party).

Expand All @@ -30,10 +32,23 @@ When that happens the OS will call a method in your `AppDelegate` and that is wh

- important: Only one AuthTransaction can be active at a given time for Auth0.swift, if you start a new one before finishing the current one it will be cancelled.
*/
public protocol AuthTransaction: AuthResumable, AuthCancelable {
public protocol AuthTransaction {

/// value of the OAuth 2.0 state parameter. It must be a cryptographically secure random string used to protect the app with request forgery.
var state: String? { get }

/**
Resumes the transaction when the third party application notifies the application using a url with a custom scheme.

- parameter url: the url sent by the third party application that contains the result of the Auth
- returns: if the url was expected and properly formatted otherwise it will return `false`.
*/
func resume(_ url: URL) -> Bool

/**
Terminates the operation and reports back that it was cancelled.
*/
func cancel()

}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
#if WEB_AUTH_PLATFORM
import Foundation

class SessionCallbackTransaction: NSObject, AuthTransaction {
class BaseCallbackTransaction: NSObject, AuthTransaction {

var state: String?
var authSession: AuthSession?
var state: String?
let callback: (Bool) -> Void

init(callback: @escaping (Bool) -> Void) {
Expand All @@ -37,7 +37,7 @@ class SessionCallbackTransaction: NSObject, AuthTransaction {
self.callback(false)
}

func handleUrl(_ url: URL) -> Bool {
func resume(_ url: URL) -> Bool {
self.callback(true)
return true
}
Expand Down
Loading