@@ -47,43 +47,64 @@ public struct Session: Codable, Hashable, Sendable {
4747 /// The oauth provider token. If present, this can be used to make external API requests to the
4848 /// oauth provider used.
4949 public var providerToken : String ?
50+
5051 /// The oauth provider refresh token. If present, this can be used to refresh the provider_token
5152 /// via the oauth provider's API. Not all oauth providers return a provider refresh token. If the
5253 /// provider_refresh_token is missing, please refer to the oauth provider's documentation for
5354 /// information on how to obtain the provider refresh token.
5455 public var providerRefreshToken : String ?
55- /// The access token jwt. It is recommended to set the JWT_EXPIRY to a shorter expiry value.
56+
57+ /// A valid JWT that will expire in ``Session/expiresIn`` seconds.
58+ /// It is recommended to set the `JWT_EXPIRY` to a shorter expiry value.
5659 public var accessToken : String
60+
61+ /// What type of token this is. Only `bearer` returned, may change in the future.
5762 public var tokenType : String
58- /// The number of seconds until the token expires (since it was issued). Returned when a login is
59- /// confirmed.
60- public var expiresIn : Double
61- /// A one-time used refresh token that never expires.
63+
64+ /// Number of seconds after which the ``Session/accessToken`` should be renewed by using the
65+ /// refresh token with the `refresh_token` grant type.
66+ public var expiresIn : TimeInterval
67+
68+ /// UNIX timestamp after which the ``Session/accessToken`` should be renewed by using the refresh
69+ /// token with the `refresh_token` grant type.
70+ public var expiresAt : TimeInterval ?
71+
72+ /// An opaque string that can be used once to obtain a new access and refresh token.
6273 public var refreshToken : String
74+
75+ /// Only returned on the `/token?grant_type=password` endpoint. When present, it indicates that
76+ /// the password used is weak. Inspect the ``WeakPassword/reasons`` property to identify why.
77+ public var weakPassword : WeakPassword ?
78+
6379 public var user : User
6480
6581 public init (
6682 providerToken: String ? = nil ,
6783 providerRefreshToken: String ? = nil ,
6884 accessToken: String ,
6985 tokenType: String ,
70- expiresIn: Double ,
86+ expiresIn: TimeInterval ,
87+ expiresAt: TimeInterval ? ,
7188 refreshToken: String ,
89+ weakPassword: WeakPassword ? = nil ,
7290 user: User
7391 ) {
7492 self . providerToken = providerToken
7593 self . providerRefreshToken = providerRefreshToken
7694 self . accessToken = accessToken
7795 self . tokenType = tokenType
7896 self . expiresIn = expiresIn
97+ self . expiresAt = expiresAt
7998 self . refreshToken = refreshToken
99+ self . weakPassword = weakPassword
80100 self . user = user
81101 }
82102
83103 static let empty = Session (
84104 accessToken: " " ,
85105 tokenType: " " ,
86106 expiresIn: 0 ,
107+ expiresAt: nil ,
87108 refreshToken: " " ,
88109 user: User (
89110 id: UUID ( ) ,
@@ -618,3 +639,9 @@ public struct ResendMobileResponse: Decodable, Hashable, Sendable {
618639 self . messageId = messageId
619640 }
620641}
642+
643+ public struct WeakPassword : Codable , Hashable , Sendable {
644+ /// List of reasons the password is too weak, could be any of `length`, `characters`, or
645+ /// `pwned`.
646+ public let reasons : [ String ]
647+ }
0 commit comments