@@ -15,6 +15,11 @@ public enum AuthChangeEvent: String, Sendable {
15
15
case mfaChallengeVerified = " MFA_CHALLENGE_VERIFIED "
16
16
}
17
17
18
+ @available (
19
+ * ,
20
+ deprecated,
21
+ message: " Access to UserCredentials will be removed on the next major release. "
22
+ )
18
23
public struct UserCredentials : Codable , Hashable , Sendable {
19
24
public var email : String ?
20
25
public var password : String ?
@@ -104,21 +109,13 @@ public struct Session: Codable, Hashable, Sendable {
104
109
self . user = user
105
110
}
106
111
107
- static let empty = Session (
108
- accessToken: " " ,
109
- tokenType: " " ,
110
- expiresIn: 0 ,
111
- expiresAt: 0 ,
112
- refreshToken: " " ,
113
- user: User (
114
- id: UUID ( ) ,
115
- appMetadata: [ : ] ,
116
- userMetadata: [ : ] ,
117
- aud: " " ,
118
- createdAt: Date ( ) ,
119
- updatedAt: Date ( )
120
- )
121
- )
112
+ /// Returns `true` if the token is expired or will expire in the next 30 seconds.
113
+ ///
114
+ /// The 30 second buffer is to account for latency issues.
115
+ public var isExpired : Bool {
116
+ let expiresAt = Date ( timeIntervalSince1970: expiresAt)
117
+ return expiresAt. timeIntervalSinceNow < EXPIRY_MARGIN
118
+ }
122
119
}
123
120
124
121
public struct User : Codable , Hashable , Identifiable , Sendable {
@@ -513,7 +510,7 @@ public struct Factor: Identifiable, Codable, Hashable, Sendable {
513
510
public let friendlyName : String ?
514
511
515
512
/// Type of factor. Only `totp` supported with this version but may change in future versions.
516
- public let factorType : String
513
+ public let factorType : FactorType
517
514
518
515
/// Factor's status.
519
516
public let status : FactorStatus
@@ -718,8 +715,7 @@ public struct ResendMobileResponse: Decodable, Hashable, Sendable {
718
715
}
719
716
720
717
public struct WeakPassword : Codable , Hashable , Sendable {
721
- /// List of reasons the password is too weak, could be any of `length`, `characters`, or
722
- /// `pwned`.
718
+ /// List of reasons the password is too weak, could be any of `length`, `characters`, or `pwned`.
723
719
public let reasons : [ String ]
724
720
}
725
721
0 commit comments