Skip to content

Commit 601fd6a

Browse files
Guilherme Souzagrdsdev
authored andcommitted
remove deprecated code
1 parent d27dee5 commit 601fd6a

40 files changed

+1033
-5456
lines changed

Sources/Auth/AuthError.swift

Lines changed: 0 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -118,129 +118,6 @@ extension ErrorCode {
118118
}
119119

120120
public enum AuthError: LocalizedError, Equatable {
121-
@available(
122-
*,
123-
deprecated,
124-
message:
125-
"Error used to be thrown when no exp claim was found in JWT during setSession(accessToken:refreshToken:) method."
126-
)
127-
case missingExpClaim
128-
129-
@available(
130-
*,
131-
deprecated,
132-
message:
133-
"Error used to be thrown when provided JWT wasn't valid during setSession(accessToken:refreshToken:) method."
134-
)
135-
case malformedJWT
136-
137-
@available(*, deprecated, renamed: "sessionMissing")
138-
public static var sessionNotFound: AuthError { .sessionMissing }
139-
140-
/// Error thrown during PKCE flow.
141-
@available(
142-
*,
143-
deprecated,
144-
renamed: "pkceGrantCodeExchange",
145-
message: "Error was grouped in `pkceGrantCodeExchange`, please use it instead of `pkce`."
146-
)
147-
public static func pkce(_ reason: PKCEFailureReason) -> AuthError {
148-
switch reason {
149-
case .codeVerifierNotFound:
150-
.pkceGrantCodeExchange(message: "A code verifier wasn't found in PKCE flow.")
151-
case .invalidPKCEFlowURL:
152-
.pkceGrantCodeExchange(message: "Not a valid PKCE flow url.")
153-
}
154-
}
155-
156-
@available(*, deprecated, message: "Use `pkceGrantCodeExchange` instead.")
157-
public enum PKCEFailureReason: Sendable {
158-
/// Code verifier not found in the URL.
159-
case codeVerifierNotFound
160-
161-
/// Not a valid PKCE flow URL.
162-
case invalidPKCEFlowURL
163-
}
164-
165-
@available(*, deprecated, renamed: "implicitGrantRedirect")
166-
public static var invalidImplicitGrantFlowURL: AuthError {
167-
.implicitGrantRedirect(message: "Not a valid implicit grant flow url.")
168-
}
169-
170-
@available(
171-
*,
172-
deprecated,
173-
message:
174-
"This error is never thrown, if you depend on it, you can remove the logic as it never happens."
175-
)
176-
case missingURL
177-
178-
@available(
179-
*,
180-
deprecated,
181-
message:
182-
"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."
183-
)
184-
case invalidRedirectScheme
185-
186-
@available(
187-
*,
188-
deprecated,
189-
renamed: "api(message:errorCode:underlyingData:underlyingResponse:)"
190-
)
191-
public static func api(_ error: APIError) -> AuthError {
192-
let message = error.msg ?? error.error ?? error.errorDescription ?? "Unexpected API error."
193-
if let weakPassword = error.weakPassword {
194-
return .weakPassword(message: message, reasons: weakPassword.reasons)
195-
}
196-
197-
return .api(
198-
message: message,
199-
errorCode: .unknown,
200-
underlyingData: (try? AuthClient.Configuration.jsonEncoder.encode(error)) ?? Data(),
201-
underlyingResponse: HTTPURLResponse(
202-
url: defaultAuthURL,
203-
statusCode: error.code ?? 500,
204-
httpVersion: nil,
205-
headerFields: nil
206-
)!
207-
)
208-
}
209-
210-
/// An error returned by the API.
211-
@available(
212-
*,
213-
deprecated,
214-
renamed: "api(message:errorCode:underlyingData:underlyingResponse:)"
215-
)
216-
public struct APIError: Error, Codable, Sendable, Equatable {
217-
/// A basic message describing the problem with the request. Usually missing if
218-
/// ``AuthError/APIError/error`` is present.
219-
public var msg: String?
220-
221-
/// The HTTP status code. Usually missing if ``AuthError/APIError/error`` is present.
222-
public var code: Int?
223-
224-
/// Certain responses will contain this property with the provided values.
225-
///
226-
/// Usually one of these:
227-
/// - `invalid_request`
228-
/// - `unauthorized_client`
229-
/// - `access_denied`
230-
/// - `server_error`
231-
/// - `temporarily_unavailable`
232-
/// - `unsupported_otp_type`
233-
public var error: String?
234-
235-
/// Certain responses that have an ``AuthError/APIError/error`` property may have this property
236-
/// which describes the error.
237-
public var errorDescription: String?
238-
239-
/// Only returned when signing up if the password used is too weak. Inspect the
240-
/// ``WeakPassword/reasons`` and ``AuthError/APIError/msg`` property to identify the causes.
241-
public var weakPassword: WeakPassword?
242-
}
243-
244121
/// Error thrown when a session is required to proceed, but none was found, either thrown by the client, or returned by the server.
245122
case sessionMissing
246123

@@ -270,11 +147,6 @@ public enum AuthError: LocalizedError, Equatable {
270147
let .pkceGrantCodeExchange(message, _, _),
271148
let .implicitGrantRedirect(message):
272149
message
273-
// Deprecated cases
274-
case .missingExpClaim: "Missing expiration claim in the access token."
275-
case .malformedJWT: "A malformed JWT received."
276-
case .invalidRedirectScheme: "Invalid redirect scheme."
277-
case .missingURL: "Missing URL."
278150
}
279151
}
280152

@@ -284,8 +156,6 @@ public enum AuthError: LocalizedError, Equatable {
284156
case .weakPassword: .weakPassword
285157
case let .api(_, errorCode, _, _): errorCode
286158
case .pkceGrantCodeExchange, .implicitGrantRedirect: .unknown
287-
// Deprecated cases
288-
case .missingExpClaim, .malformedJWT, .invalidRedirectScheme, .missingURL: .unknown
289159
}
290160
}
291161

Sources/Auth/AuthStateChangeListener.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ public protocol AuthStateChangeListenerRegistration: Sendable {
1717
func remove()
1818
}
1919

20-
extension ObservationToken: AuthStateChangeListenerRegistration {}
20+
extension ObservationToken: AuthStateChangeListenerRegistration {
21+
public func remove() {
22+
cancel()
23+
}
24+
}
2125

2226
public typealias AuthStateChangeListener = @Sendable (
2327
_ event: AuthChangeEvent,

Sources/Auth/Deprecated.swift

Lines changed: 0 additions & 131 deletions
This file was deleted.

Sources/Auth/Types.swift

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,12 @@ public enum AuthChangeEvent: String, Sendable {
1515
case mfaChallengeVerified = "MFA_CHALLENGE_VERIFIED"
1616
}
1717

18-
@available(
19-
*,
20-
deprecated,
21-
message: "Access to UserCredentials will be removed on the next major release."
22-
)
23-
public struct UserCredentials: Codable, Hashable, Sendable {
24-
public var email: String?
25-
public var password: String?
26-
public var phone: String?
27-
public var refreshToken: String?
28-
public var gotrueMetaSecurity: AuthMetaSecurity?
29-
30-
public init(
31-
email: String? = nil,
32-
password: String? = nil,
33-
phone: String? = nil,
34-
refreshToken: String? = nil,
35-
gotrueMetaSecurity: AuthMetaSecurity? = nil
36-
) {
37-
self.email = email
38-
self.password = password
39-
self.phone = phone
40-
self.refreshToken = refreshToken
41-
self.gotrueMetaSecurity = gotrueMetaSecurity
42-
}
18+
struct UserCredentials: Codable, Hashable, Sendable {
19+
var email: String?
20+
var password: String?
21+
var phone: String?
22+
var refreshToken: String?
23+
var gotrueMetaSecurity: AuthMetaSecurity?
4324
}
4425

4526
struct SignUpRequest: Codable, Hashable, Sendable {
@@ -479,9 +460,6 @@ public struct UserAttributes: Codable, Hashable, Sendable {
479460
/// Note: Call ``AuthClient/reauthenticate()`` to obtain the nonce first.
480461
public var nonce: String?
481462

482-
/// An email change token.
483-
@available(*, deprecated, message: "This is an old field, stop relying on it.")
484-
public var emailChangeToken: String?
485463
/// A custom data object to store the user's metadata. This maps to the `auth.users.user_metadata`
486464
/// column. The `data` should be a JSON object that includes user-specific info, such as their
487465
/// first and last name.
@@ -495,14 +473,12 @@ public struct UserAttributes: Codable, Hashable, Sendable {
495473
phone: String? = nil,
496474
password: String? = nil,
497475
nonce: String? = nil,
498-
emailChangeToken: String? = nil,
499476
data: [String: AnyJSON]? = nil
500477
) {
501478
self.email = email
502479
self.phone = phone
503480
self.password = password
504481
self.nonce = nonce
505-
self.emailChangeToken = emailChangeToken
506482
self.data = data
507483
}
508484
}

Sources/Helpers/EventEmitter.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ public final class ObservationToken: @unchecked Sendable, Hashable {
2323
self.onCancel = onCancel
2424
}
2525

26-
@available(*, deprecated, renamed: "cancel")
27-
public func remove() {
28-
cancel()
29-
}
30-
3126
public func cancel() {
3227
_isCancelled.withValue { isCancelled in
3328
guard !isCancelled else { return }

0 commit comments

Comments
 (0)