Skip to content

Commit c0ee495

Browse files
committed
feat(auth): remove deprecated code (#838)
1 parent af48c14 commit c0ee495

File tree

6 files changed

+12
-316
lines changed

6 files changed

+12
-316
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

@@ -274,11 +151,6 @@ public enum AuthError: LocalizedError, Equatable {
274151
let .implicitGrantRedirect(message),
275152
let .jwtVerificationFailed(message):
276153
message
277-
// Deprecated cases
278-
case .missingExpClaim: "Missing expiration claim in the access token."
279-
case .malformedJWT: "A malformed JWT received."
280-
case .invalidRedirectScheme: "Invalid redirect scheme."
281-
case .missingURL: "Missing URL."
282154
}
283155
}
284156

@@ -289,8 +161,6 @@ public enum AuthError: LocalizedError, Equatable {
289161
case let .api(_, errorCode, _, _): errorCode
290162
case .pkceGrantCodeExchange, .implicitGrantRedirect: .unknown
291163
case .jwtVerificationFailed: .invalidJWT
292-
// Deprecated cases
293-
case .missingExpClaim, .malformedJWT, .invalidRedirectScheme, .missingURL: .unknown
294164
}
295165
}
296166

Sources/Auth/Deprecated.swift

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

Sources/Auth/Types.swift

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,12 @@ public enum AuthChangeEvent: String, Sendable {
1111
case mfaChallengeVerified = "MFA_CHALLENGE_VERIFIED"
1212
}
1313

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

4122
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
}

0 commit comments

Comments
 (0)