@@ -47,43 +47,64 @@ public struct Session: Codable, Hashable, Sendable {
47
47
/// The oauth provider token. If present, this can be used to make external API requests to the
48
48
/// oauth provider used.
49
49
public var providerToken : String ?
50
+
50
51
/// The oauth provider refresh token. If present, this can be used to refresh the provider_token
51
52
/// via the oauth provider's API. Not all oauth providers return a provider refresh token. If the
52
53
/// provider_refresh_token is missing, please refer to the oauth provider's documentation for
53
54
/// information on how to obtain the provider refresh token.
54
55
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.
56
59
public var accessToken : String
60
+
61
+ /// What type of token this is. Only `bearer` returned, may change in the future.
57
62
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.
62
73
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
+
63
79
public var user : User
64
80
65
81
public init (
66
82
providerToken: String ? = nil ,
67
83
providerRefreshToken: String ? = nil ,
68
84
accessToken: String ,
69
85
tokenType: String ,
70
- expiresIn: Double ,
86
+ expiresIn: TimeInterval ,
87
+ expiresAt: TimeInterval ? ,
71
88
refreshToken: String ,
89
+ weakPassword: WeakPassword ? = nil ,
72
90
user: User
73
91
) {
74
92
self . providerToken = providerToken
75
93
self . providerRefreshToken = providerRefreshToken
76
94
self . accessToken = accessToken
77
95
self . tokenType = tokenType
78
96
self . expiresIn = expiresIn
97
+ self . expiresAt = expiresAt
79
98
self . refreshToken = refreshToken
99
+ self . weakPassword = weakPassword
80
100
self . user = user
81
101
}
82
102
83
103
static let empty = Session (
84
104
accessToken: " " ,
85
105
tokenType: " " ,
86
106
expiresIn: 0 ,
107
+ expiresAt: nil ,
87
108
refreshToken: " " ,
88
109
user: User (
89
110
id: UUID ( ) ,
@@ -618,3 +639,9 @@ public struct ResendMobileResponse: Decodable, Hashable, Sendable {
618
639
self . messageId = messageId
619
640
}
620
641
}
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