Skip to content
Closed
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
30 changes: 23 additions & 7 deletions Examples/Examples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1510;
LastUpgradeCheck = 1510;
LastUpgradeCheck = 2600;
TargetAttributes = {
793895C52954ABFF0044F2B8 = {
CreatedOnToolsVersion = 14.1;
Expand Down Expand Up @@ -625,6 +625,7 @@
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = ELTTE7K8TT;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
Expand Down Expand Up @@ -654,6 +655,7 @@
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
STRING_CATALOG_GENERATE_SYMBOLS = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand Down Expand Up @@ -699,6 +701,7 @@
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = ELTTE7K8TT;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
Expand All @@ -721,6 +724,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
STRING_CATALOG_GENERATE_SYMBOLS = YES;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor;
SWIFT_OPTIMIZATION_LEVEL = "-O";
Expand All @@ -737,9 +741,11 @@
CODE_SIGN_ENTITLEMENTS = Examples/Examples.entitlements;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"Examples/Preview Content\"";
DEVELOPMENT_TEAM = ELTTE7K8TT;
ENABLE_APP_SANDBOX = YES;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_OUTGOING_NETWORK_CONNECTIONS = YES;
ENABLE_PREVIEWS = YES;
ENABLE_USER_SELECTED_FILES = readonly;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Examples/Info.plist;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
Expand All @@ -763,9 +769,11 @@
CODE_SIGN_ENTITLEMENTS = Examples/Examples.entitlements;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"Examples/Preview Content\"";
DEVELOPMENT_TEAM = ELTTE7K8TT;
ENABLE_APP_SANDBOX = YES;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_OUTGOING_NETWORK_CONNECTIONS = YES;
ENABLE_PREVIEWS = YES;
ENABLE_USER_SELECTED_FILES = readonly;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Examples/Info.plist;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
Expand All @@ -790,9 +798,11 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"SlackClone/Preview Content\"";
DEVELOPMENT_TEAM = ELTTE7K8TT;
ENABLE_APP_SANDBOX = YES;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_OUTGOING_NETWORK_CONNECTIONS = YES;
ENABLE_PREVIEWS = YES;
ENABLE_USER_SELECTED_FILES = readonly;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = SlackClone/Info.plist;
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;
Expand Down Expand Up @@ -830,9 +840,11 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"SlackClone/Preview Content\"";
DEVELOPMENT_TEAM = ELTTE7K8TT;
ENABLE_APP_SANDBOX = YES;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_OUTGOING_NETWORK_CONNECTIONS = YES;
ENABLE_PREVIEWS = YES;
ENABLE_USER_SELECTED_FILES = readonly;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = SlackClone/Info.plist;
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;
Expand Down Expand Up @@ -870,9 +882,11 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"UserManagement/Preview Content\"";
DEVELOPMENT_TEAM = ELTTE7K8TT;
ENABLE_APP_SANDBOX = YES;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_OUTGOING_NETWORK_CONNECTIONS = YES;
ENABLE_PREVIEWS = YES;
ENABLE_USER_SELECTED_FILES = readonly;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = UserManagement/Info.plist;
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;
Expand Down Expand Up @@ -910,9 +924,11 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"UserManagement/Preview Content\"";
DEVELOPMENT_TEAM = ELTTE7K8TT;
ENABLE_APP_SANDBOX = YES;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_OUTGOING_NETWORK_CONNECTIONS = YES;
ENABLE_PREVIEWS = YES;
ENABLE_USER_SELECTED_FILES = readonly;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = UserManagement/Info.plist;
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1510"
LastUpgradeVersion = "2600"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1520"
LastUpgradeVersion = "2600"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1510"
LastUpgradeVersion = "2600"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
6 changes: 0 additions & 6 deletions Examples/Examples/Examples.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
<array>
<string>Default</string>
</array>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>keychain-access-groups</key>
<array/>
</dict>
Expand Down
9 changes: 1 addition & 8 deletions Examples/SlackClone/SlackClone.entitlements
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
<?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>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
<dict/>
</plist>
9 changes: 1 addition & 8 deletions Examples/UserManagement/UserManagement.entitlements
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
<?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>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
<dict/>
</plist>
9 changes: 9 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ let package = Package(
"Functions",
"Mocker",
"TestHelpers",
],
exclude: [
"__Snapshots__"
]
),
.testTarget(
Expand Down Expand Up @@ -123,6 +126,9 @@ let package = Package(
"Mocker",
"PostgREST",
"TestHelpers",
],
exclude: [
"__Snapshots__"
]
),
.target(
Expand Down Expand Up @@ -160,6 +166,9 @@ let package = Package(
"TestHelpers",
"Storage",
],
exclude: [
"__Snapshots__"
],
resources: [
.copy("sadcat.jpg"),
.process("Fixtures"),
Expand Down
129 changes: 0 additions & 129 deletions Sources/Auth/AuthError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,128 +118,6 @@ extension ErrorCode {
}

public enum AuthError: LocalizedError, Equatable {
@available(
*,
deprecated,
message:
"Error used to be thrown when no exp claim was found in JWT during setSession(accessToken:refreshToken:) method."
)
case missingExpClaim

@available(
*,
deprecated,
message:
"Error used to be thrown when provided JWT wasn't valid during setSession(accessToken:refreshToken:) method."
)
case malformedJWT

@available(*, deprecated, renamed: "sessionMissing")
public static var sessionNotFound: AuthError { .sessionMissing }

/// Error thrown during PKCE flow.
@available(
*,
deprecated,
renamed: "pkceGrantCodeExchange",
message: "Error was grouped in `pkceGrantCodeExchange`, please use it instead of `pkce`."
)
public static func pkce(_ reason: PKCEFailureReason) -> AuthError {
switch reason {
case .codeVerifierNotFound:
.pkceGrantCodeExchange(message: "A code verifier wasn't found in PKCE flow.")
case .invalidPKCEFlowURL:
.pkceGrantCodeExchange(message: "Not a valid PKCE flow url.")
}
}

@available(*, deprecated, message: "Use `pkceGrantCodeExchange` instead.")
public enum PKCEFailureReason: Sendable {
/// Code verifier not found in the URL.
case codeVerifierNotFound

/// Not a valid PKCE flow URL.
case invalidPKCEFlowURL
}

@available(*, deprecated, renamed: "implicitGrantRedirect")
public static var invalidImplicitGrantFlowURL: AuthError {
.implicitGrantRedirect(message: "Not a valid implicit grant flow url.")
}

@available(
*,
deprecated,
message:
"This error is never thrown, if you depend on it, you can remove the logic as it never happens."
)
case missingURL

@available(
*,
deprecated,
message:
"Error used to be thrown on methods which required a valid redirect scheme, such as signInWithOAuth. This is now considered a programming error an a assertion is triggered in case redirect scheme isn't provided."
)
case invalidRedirectScheme

@available(
*,
deprecated,
renamed: "api(message:errorCode:underlyingData:underlyingResponse:)"
)
public static func api(_ error: APIError) -> AuthError {
let message = error.msg ?? error.error ?? error.errorDescription ?? "Unexpected API error."
if let weakPassword = error.weakPassword {
return .weakPassword(message: message, reasons: weakPassword.reasons)
}

return .api(
message: message,
errorCode: .unknown,
underlyingData: (try? AuthClient.Configuration.jsonEncoder.encode(error)) ?? Data(),
underlyingResponse: HTTPURLResponse(
url: defaultAuthURL,
statusCode: error.code ?? 500,
httpVersion: nil,
headerFields: nil
)!
)
}

/// An error returned by the API.
@available(
*,
deprecated,
renamed: "api(message:errorCode:underlyingData:underlyingResponse:)"
)
public struct APIError: Error, Codable, Sendable, Equatable {
/// A basic message describing the problem with the request. Usually missing if
/// ``AuthError/APIError/error`` is present.
public var msg: String?

/// The HTTP status code. Usually missing if ``AuthError/APIError/error`` is present.
public var code: Int?

/// Certain responses will contain this property with the provided values.
///
/// Usually one of these:
/// - `invalid_request`
/// - `unauthorized_client`
/// - `access_denied`
/// - `server_error`
/// - `temporarily_unavailable`
/// - `unsupported_otp_type`
public var error: String?

/// Certain responses that have an ``AuthError/APIError/error`` property may have this property
/// which describes the error.
public var errorDescription: String?

/// Only returned when signing up if the password used is too weak. Inspect the
/// ``WeakPassword/reasons`` and ``AuthError/APIError/msg`` property to identify the causes.
public var weakPassword: WeakPassword?
}

/// Error thrown when a session is required to proceed, but none was found, either thrown by the client, or returned by the server.
case sessionMissing
Expand Down Expand Up @@ -274,11 +152,6 @@ public enum AuthError: LocalizedError, Equatable {
let .implicitGrantRedirect(message),
let .jwtVerificationFailed(message):
message
// Deprecated cases
case .missingExpClaim: "Missing expiration claim in the access token."
case .malformedJWT: "A malformed JWT received."
case .invalidRedirectScheme: "Invalid redirect scheme."
case .missingURL: "Missing URL."
}
}

Expand All @@ -289,8 +162,6 @@ public enum AuthError: LocalizedError, Equatable {
case let .api(_, errorCode, _, _): errorCode
case .pkceGrantCodeExchange, .implicitGrantRedirect: .unknown
case .jwtVerificationFailed: .invalidJWT
// Deprecated cases
case .missingExpClaim, .malformedJWT, .invalidRedirectScheme, .missingURL: .unknown
}
}

Expand Down
7 changes: 5 additions & 2 deletions Sources/Auth/AuthStateChangeListener.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import ConcurrencyExtras
import Foundation


/// A listener that can be removed by calling ``AuthStateChangeListenerRegistration/remove()``.
///
/// - Note: Listener is automatically removed on deinit.
Expand All @@ -17,7 +16,11 @@ public protocol AuthStateChangeListenerRegistration: Sendable {
func remove()
}

extension ObservationToken: AuthStateChangeListenerRegistration {}
extension ObservationToken: AuthStateChangeListenerRegistration {
public func remove() {
cancel()
}
}

public typealias AuthStateChangeListener = @Sendable (
_ event: AuthChangeEvent,
Expand Down
Loading
Loading