@@ -15,6 +15,11 @@ 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+ )
1823public struct UserCredentials : Codable , Hashable , Sendable {
1924 public var email : String ?
2025 public var password : String ?
@@ -104,21 +109,13 @@ public struct Session: Codable, Hashable, Sendable {
104109 self . user = user
105110 }
106111
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+ }
122119}
123120
124121public struct User : Codable , Hashable , Identifiable , Sendable {
@@ -513,7 +510,7 @@ public struct Factor: Identifiable, Codable, Hashable, Sendable {
513510 public let friendlyName : String ?
514511
515512 /// 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
517514
518515 /// Factor's status.
519516 public let status : FactorStatus
@@ -718,8 +715,7 @@ public struct ResendMobileResponse: Decodable, Hashable, Sendable {
718715}
719716
720717public 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`.
723719 public let reasons : [ String ]
724720}
725721
0 commit comments