Skip to content

Commit

Permalink
Remove deprecated metods (#543)
Browse files Browse the repository at this point in the history
  • Loading branch information
Widcket committed Nov 12, 2021
1 parent 5be2582 commit 812eb34
Show file tree
Hide file tree
Showing 26 changed files with 80 additions and 1,812 deletions.
9 changes: 2 additions & 7 deletions App/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import UIKit
import Auth0

typealias A0ApplicationLaunchOptionsKey = UIApplication.LaunchOptionsKey

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [A0ApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
return true
}

func application(_ app: UIApplication, open url: URL, options: [A0URLOptionsKey : Any]) -> Bool {
return Auth0.resumeAuth(url)
}

}

8 changes: 2 additions & 6 deletions Auth0.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ web_auth_files = [
'Auth0/Array+Encode.swift',
'Auth0/ASCallbackTransaction.swift',
'Auth0/ASTransaction.swift',
'Auth0/AuthProvider.swift',
'Auth0/AuthSession.swift',
'Auth0/AuthTransaction.swift',
'Auth0/Auth0WebAuth.swift',
Expand All @@ -22,7 +21,6 @@ web_auth_files = [
'Auth0/JWK+RSA.swift',
'Auth0/JWT+Header.swift',
'Auth0/JWTAlgorithm.swift',
'Auth0/NativeAuth.swift',
'Auth0/NSURLComponents+OAuth2.swift',
'Auth0/OAuth2Grant.swift',
'Auth0/TransactionStore.swift',
Expand All @@ -31,13 +29,11 @@ web_auth_files = [
]

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

macos_files = [
'Auth0/DesktopWebAuth.swift',
'Auth0/NSApplication+Shared.swift'
'Auth0/DesktopWebAuth.swift'
]

excluded_files = [
Expand Down
62 changes: 0 additions & 62 deletions Auth0.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

95 changes: 1 addition & 94 deletions Auth0/Auth0Authentication.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// swiftlint:disable file_length

import Foundation

// swiftlint:disable:next type_body_length
struct Auth0Authentication: Authentication {

let clientId: String
Expand All @@ -27,28 +24,6 @@ struct Auth0Authentication: Authentication {
return login(username: username, otp: otp, realm: "sms", audience: audience, scope: scope)
}

// swiftlint:disable:next function_parameter_count
func login(usernameOrEmail username: String, password: String, multifactorCode: String?, connection: String, scope: String, parameters: [String: Any]) -> Request<Credentials, AuthenticationError> {
let resourceOwner = URL(string: "/oauth/ro", relativeTo: self.url)!
var payload: [String: Any] = [
"username": username,
"password": password,
"connection": connection,
"grant_type": "password",
"scope": scope,
"client_id": self.clientId
]
payload["mfa_code"] = multifactorCode
parameters.forEach { key, value in payload[key] = value }
return Request(session: session,
url: resourceOwner,
method: "POST",
handle: authenticationObject,
payload: payload,
logger: self.logger,
telemetry: self.telemetry)
}

func login(usernameOrEmail username: String, password: String, realm: String, audience: String?, scope: String) -> Request<Credentials, AuthenticationError> {
let resourceOwner = URL(string: "/oauth/token", relativeTo: self.url)!
var payload: [String: Any] = [
Expand Down Expand Up @@ -192,7 +167,7 @@ struct Auth0Authentication: Authentication {
parameters: parameters)
}

func login(facebookSessionAccessToken sessionAccessToken: String, profile: [String: Any], audience: String?, scope: String) -> Request<Credentials, AuthenticationError> {
func login(facebookSessionAccessToken sessionAccessToken: String, profile: [String: Any], audience: String?, scope: String) -> Request<Credentials, AuthenticationError> {
var parameters: [String: String] = [:]
if let jsonData = try? JSONSerialization.data(withJSONObject: profile, options: []),
let json = String(data: jsonData, encoding: .utf8) {
Expand Down Expand Up @@ -246,13 +221,6 @@ struct Auth0Authentication: Authentication {
telemetry: self.telemetry)
}

// swiftlint:disable:next function_parameter_count
func signUp(email: String, username: String? = nil, password: String, connection: String, userMetadata: [String: Any]?, scope: String, parameters: [String: Any]) -> ConcatRequest<DatabaseUser, Credentials, AuthenticationError> {
let first = createUser(email: email, username: username, password: password, connection: connection, userMetadata: userMetadata)
let second = login(usernameOrEmail: email, password: password, connection: connection, scope: scope, parameters: parameters)
return ConcatRequest(first: first, second: second)
}

func startPasswordless(email: String, type: PasswordlessType, connection: String, parameters: [String: Any]) -> Request<Void, AuthenticationError> {
var payload: [String: Any] = [
"email": email,
Expand Down Expand Up @@ -291,29 +259,6 @@ struct Auth0Authentication: Authentication {
telemetry: self.telemetry)
}

func tokenInfo(token: String) -> Request<Profile, AuthenticationError> {
let payload: [String: Any] = ["id_token": token]
let tokenInfo = URL(string: "/tokeninfo", relativeTo: self.url)!
return Request(session: session,
url: tokenInfo,
method: "POST",
handle: authenticationObject,
payload: payload,
logger: self.logger,
telemetry: self.telemetry)
}

func userInfo(token: String) -> Request<Profile, AuthenticationError> {
let userInfo = URL(string: "/userinfo", relativeTo: self.url)!
return Request(session: session,
url: userInfo,
method: "GET",
handle: authenticationObject,
headers: ["Authorization": "Bearer \(token)"],
logger: self.logger,
telemetry: self.telemetry)
}

func userInfo(withAccessToken accessToken: String) -> Request<UserInfo, AuthenticationError> {
let userInfo = URL(string: "/userinfo", relativeTo: self.url)!
return Request(session: session,
Expand All @@ -325,24 +270,6 @@ struct Auth0Authentication: Authentication {
telemetry: self.telemetry)
}

func loginSocial(token: String, connection: String, scope: String, parameters: [String: Any]) -> Request<Credentials, AuthenticationError> {
var payload: [String: Any] = [
"access_token": token,
"connection": connection,
"scope": scope,
"client_id": self.clientId
]
parameters.forEach { key, value in payload[key] = value }
let accessToken = URL(string: "/oauth/access_token", relativeTo: self.url)!
return Request(session: session,
url: accessToken,
method: "POST",
handle: authenticationObject,
payload: payload,
logger: self.logger,
telemetry: self.telemetry)
}

func tokenExchange() -> Request<Credentials, AuthenticationError> {
let payload: [String: Any] = [
"client_id": self.clientId
Expand All @@ -366,10 +293,6 @@ struct Auth0Authentication: Authentication {
])
}

func tokenExchange(withAppleAuthorizationCode authCode: String, scope: String?, audience: String?, fullName: PersonNameComponents?) -> Request<Credentials, AuthenticationError> {
return self.login(appleAuthorizationCode: authCode, fullName: fullName, audience: audience, scope: scope ?? defaultScope)
}

func renew(withRefreshToken refreshToken: String, scope: String? = nil) -> Request<Credentials, AuthenticationError> {
var payload: [String: Any] = [
"refresh_token": refreshToken,
Expand Down Expand Up @@ -402,22 +325,6 @@ struct Auth0Authentication: Authentication {
telemetry: self.telemetry)
}

func delegation(withParameters parameters: [String: Any]) -> Request<[String: Any], AuthenticationError> {
var payload: [String: Any] = [
"client_id": self.clientId,
"grant_type": "urn:ietf:params:oauth:grant-type:jwt-bearer"
]
parameters.forEach { payload[$0] = $1 }
let delegation = URL(string: "/delegation", relativeTo: self.url)!
return Request(session: session,
url: delegation,
method: "POST",
handle: plainJson,
payload: payload,
logger: self.logger,
telemetry: self.telemetry)
}

func jwks() -> Request<JWKS, AuthenticationError> {
let jwks = URL(string: "/.well-known/jwks.json", relativeTo: self.url)!
return Request(session: session,
Expand Down
8 changes: 1 addition & 7 deletions Auth0/Auth0WebAuth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ final class Auth0WebAuth: WebAuth {
let storage: TransactionStore
var telemetry: Telemetry
var logger: Logger?
var universalLink = false
var ephemeralSession = false

#if os(macOS)
Expand All @@ -30,7 +29,7 @@ final class Auth0WebAuth: WebAuth {
lazy var redirectURL: URL? = {
guard let bundleIdentifier = Bundle.main.bundleIdentifier else { return nil }
var components = URLComponents(url: self.url, resolvingAgainstBaseURL: true)
components?.scheme = self.universalLink ? "https" : bundleIdentifier
components?.scheme = bundleIdentifier
return components?.url?
.appendingPathComponent(self.platform)
.appendingPathComponent(bundleIdentifier)
Expand All @@ -48,11 +47,6 @@ final class Auth0WebAuth: WebAuth {
self.issuer = "\(url.absoluteString)/"
}

func useUniversalLink() -> Self {
self.universalLink = true
return self
}

func connection(_ connection: String) -> Self {
self.parameters["connection"] = connection
return self
Expand Down
36 changes: 0 additions & 36 deletions Auth0/AuthProvider.swift

This file was deleted.

Loading

0 comments on commit 812eb34

Please sign in to comment.