@@ -34,13 +34,17 @@ private struct TeamPayload: Codable {
34
34
case issuerIdentifier = " iss "
35
35
case expirationTime = " exp "
36
36
case audience = " aud "
37
+ case issuedAtTime = " iat "
37
38
}
38
39
39
40
/// Your issuer identifier from the API Keys page in App Store Connect (Ex: 57246542-96fe-1a63-e053-0824d011072a)
40
41
let issuerIdentifier : String
41
42
42
43
/// The token's expiration time, in Unix epoch time; tokens that expire more than 20 minutes in the future are not valid (Ex: 1528408800)
43
44
let expirationTime : TimeInterval
45
+
46
+ /// The token’s creation time, in UNIX epoch time (Ex: 1528407600)
47
+ let issuedAtTime : TimeInterval
44
48
45
49
/// The required audience which is set to the App Store Connect version.
46
50
let audience : String = " appstoreconnect-v1 "
@@ -52,13 +56,17 @@ private struct IndividualPayload: Codable {
52
56
case subject = " sub "
53
57
case expirationTime = " exp "
54
58
case audience = " aud "
59
+ case issuedAtTime = " iat "
55
60
}
56
61
57
62
/// The subject to pass to the payload when using individual keys
58
63
let subject : String = " user "
59
64
60
65
/// The token's expiration time, in Unix epoch time; tokens that expire more than 20 minutes in the future are not valid (Ex: 1528408800)
61
66
let expirationTime : TimeInterval
67
+
68
+ /// The token’s creation time, in UNIX epoch time (Ex: 1528407600)
69
+ let issuedAtTime : TimeInterval
62
70
63
71
/// The required audience which is set to the App Store Connect version.
64
72
let audience : String = " appstoreconnect-v1 "
@@ -122,12 +130,20 @@ public struct JWT: Codable, JWTCreatable {
122
130
123
131
/// Combine the header and the payload as a digest for signing.
124
132
private func digest( dateProvider: DateProvider ) throws -> String {
125
- let expirationTime = dateProvider ( ) . addingTimeInterval ( expireDuration) . timeIntervalSince1970
133
+ let now = dateProvider ( )
134
+ let expirationTime = now. addingTimeInterval ( expireDuration) . timeIntervalSince1970
126
135
let payload : Codable
127
136
if let issuerIdentifier {
128
- payload = TeamPayload ( issuerIdentifier: issuerIdentifier, expirationTime: expirationTime)
137
+ payload = TeamPayload (
138
+ issuerIdentifier: issuerIdentifier,
139
+ expirationTime: expirationTime,
140
+ issuedAtTime: now. timeIntervalSince1970
141
+ )
129
142
} else {
130
- payload = IndividualPayload ( expirationTime: expirationTime)
143
+ payload = IndividualPayload (
144
+ expirationTime: expirationTime,
145
+ issuedAtTime: now. timeIntervalSince1970
146
+ )
131
147
}
132
148
133
149
let headerString = try JSONEncoder ( ) . encode ( header. self) . base64URLEncoded ( )
0 commit comments