| 
1 | 1 | import Foundation  | 
 | 2 | +import Helpers  | 
2 | 3 | 
 
  | 
3 | 4 | #if canImport(FoundationNetworking)  | 
4 | 5 |   import FoundationNetworking  | 
@@ -47,7 +48,8 @@ extension ErrorCode {  | 
47 | 48 |   public static let oauthProviderNotSupported = ErrorCode("oauth_provider_not_supported")  | 
48 | 49 |   public static let unexpectedAudience = ErrorCode("unexpected_audience")  | 
49 | 50 |   public static let singleIdentityNotDeletable = ErrorCode("single_identity_not_deletable")  | 
50 |  | -  public static let emailConflictIdentityNotDeletable = ErrorCode("email_conflict_identity_not_deletable")  | 
 | 51 | +  public static let emailConflictIdentityNotDeletable = ErrorCode(  | 
 | 52 | +    "email_conflict_identity_not_deletable")  | 
51 | 53 |   public static let identityAlreadyExists = ErrorCode("identity_already_exists")  | 
52 | 54 |   public static let emailProviderDisabled = ErrorCode("email_provider_disabled")  | 
53 | 55 |   public static let phoneProviderDisabled = ErrorCode("phone_provider_disabled")  | 
@@ -108,14 +110,16 @@ public enum AuthError: LocalizedError, Equatable {  | 
108 | 110 |   @available(  | 
109 | 111 |     *,  | 
110 | 112 |     deprecated,  | 
111 |  | -    message: "Error used to be thrown when no exp claim was found in JWT during setSession(accessToken:refreshToken:) method."  | 
 | 113 | +    message:  | 
 | 114 | +      "Error used to be thrown when no exp claim was found in JWT during setSession(accessToken:refreshToken:) method."  | 
112 | 115 |   )  | 
113 | 116 |   case missingExpClaim  | 
114 | 117 | 
 
  | 
115 | 118 |   @available(  | 
116 | 119 |     *,  | 
117 | 120 |     deprecated,  | 
118 |  | -    message: "Error used to be thrown when provided JWT wasn't valid during setSession(accessToken:refreshToken:) method."  | 
 | 121 | +    message:  | 
 | 122 | +      "Error used to be thrown when provided JWT wasn't valid during setSession(accessToken:refreshToken:) method."  | 
119 | 123 |   )  | 
120 | 124 |   case malformedJWT  | 
121 | 125 | 
 
  | 
@@ -155,14 +159,16 @@ public enum AuthError: LocalizedError, Equatable {  | 
155 | 159 |   @available(  | 
156 | 160 |     *,  | 
157 | 161 |     deprecated,  | 
158 |  | -    message: "This error is never thrown, if you depend on it, you can remove the logic as it never happens."  | 
 | 162 | +    message:  | 
 | 163 | +      "This error is never thrown, if you depend on it, you can remove the logic as it never happens."  | 
159 | 164 |   )  | 
160 | 165 |   case missingURL  | 
161 | 166 | 
 
  | 
162 | 167 |   @available(  | 
163 | 168 |     *,  | 
164 | 169 |     deprecated,  | 
165 |  | -    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."  | 
 | 170 | +    message:  | 
 | 171 | +      "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."  | 
166 | 172 |   )  | 
167 | 173 |   case invalidRedirectScheme  | 
168 | 174 | 
 
  | 
@@ -249,9 +255,9 @@ public enum AuthError: LocalizedError, Equatable {  | 
249 | 255 |     switch self {  | 
250 | 256 |     case .sessionMissing: "Auth session missing."  | 
251 | 257 |     case let .weakPassword(message, _),  | 
252 |  | -         let .api(message, _, _, _),  | 
253 |  | -         let .pkceGrantCodeExchange(message, _, _),  | 
254 |  | -         let .implicitGrantRedirect(message):  | 
 | 258 | +      let .api(message, _, _, _),  | 
 | 259 | +      let .pkceGrantCodeExchange(message, _, _),  | 
 | 260 | +      let .implicitGrantRedirect(message):  | 
255 | 261 |       message  | 
256 | 262 |     // Deprecated cases  | 
257 | 263 |     case .missingExpClaim: "Missing expiration claim in the access token."  | 
@@ -281,3 +287,13 @@ public enum AuthError: LocalizedError, Equatable {  | 
281 | 287 |     return lhs == rhs  | 
282 | 288 |   }  | 
283 | 289 | }  | 
 | 290 | + | 
 | 291 | +extension AuthError: RetryableError {  | 
 | 292 | +  package var shouldRetry: Bool {  | 
 | 293 | +    switch self {  | 
 | 294 | +    case .api(_, _, _, let response):  | 
 | 295 | +      defaultRetryableHTTPStatusCodes.contains(response.statusCode)  | 
 | 296 | +    default: false  | 
 | 297 | +    }  | 
 | 298 | +  }  | 
 | 299 | +}  | 
0 commit comments