Skip to content

Commit bf34edc

Browse files
authored
fix: resolve ASC invalid bearer token (#129)
This pull request resolves potential clock drift between ASC and bearer token. Ref: #97 (comment)
1 parent d691e61 commit bf34edc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Sources/XKit/DeveloperServices/OpenAPI/ASCKey.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ public struct ASCKey: Sendable {
1515

1616
actor ASCJWTGenerator {
1717
// the duration for which we generate JWTs.
18-
// ASC allows a maximum of 20 minutes.
19-
private static let ttl: TimeInterval = 60 * 20
18+
// ASC allows a maximum of 20 minutes. We use
19+
// 15 minutes to account for clock drift.
20+
private static let ttl: TimeInterval = 60 * 15
2021

2122
// the minimum remaining ttl for us to consider reusing a previous key.
2223
// that is, we reuse the last JWT if it has at least [threshold] seconds
2324
// left before it expires.
24-
private static let tolerance: TimeInterval = 60
25+
private static let tolerance: TimeInterval = 60 * 2
2526

2627
private static let encoder: JSONEncoder = {
2728
let encoder = JSONEncoder()

0 commit comments

Comments
 (0)