Skip to content

Commit

Permalink
Update CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ptoffy committed Sep 23, 2024
1 parent 3f7b65b commit cebdea8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
uses: vapor/ci/.github/workflows/run-unit-tests.yml@main
with:
with_api_check: ${{ github.event_name == 'pull_request' }}
extra_flags: -Xswiftc -warnings-as-errors
warnings_as_errors: true
secrets: inherit

ios-tests:
Expand Down
6 changes: 3 additions & 3 deletions Sources/JWTKit/Claims/LocaleClaim.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#if compiler(<6.0) && !canImport(Darwin)
@preconcurrency import Foundation
@preconcurrency import Foundation
#else
import Foundation
import Foundation
#endif

public struct LocaleClaim: JWTClaim, Equatable, ExpressibleByStringLiteral {
Expand All @@ -26,6 +26,6 @@ public struct LocaleClaim: JWTClaim, Equatable, ExpressibleByStringLiteral {
/// See `Encodable`.
public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
try container.encode(self.value.identifier)
try container.encode(value.identifier)
}
}
24 changes: 12 additions & 12 deletions Sources/JWTKit/Utilities/CustomizedJSONCoders.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,41 @@ public protocol JWTJSONEncoder: Sendable {
}

#if compiler(<6.0) && !canImport(Darwin)
extension JSONDecoder: JWTJSONDecoder, @unchecked Sendable {}
extension JSONEncoder: JWTJSONEncoder, @unchecked Sendable {}
extension JSONDecoder: JWTJSONDecoder, @unchecked Sendable {}
extension JSONEncoder: JWTJSONEncoder, @unchecked Sendable {}
#else
extension JSONDecoder: JWTJSONDecoder {}
extension JSONEncoder: JWTJSONEncoder {}
extension JSONDecoder: JWTJSONDecoder {}
extension JSONEncoder: JWTJSONEncoder {}
#endif

public extension JSONDecoder.DateDecodingStrategy {
static var integerSecondsSince1970: Self {
extension JSONDecoder.DateDecodingStrategy {
public static var integerSecondsSince1970: Self {
.custom { decoder in
let container = try decoder.singleValueContainer()
return try Date(timeIntervalSince1970: Double(container.decode(Int.self)))
}
}
}

public extension JSONEncoder.DateEncodingStrategy {
static var integerSecondsSince1970: Self {
extension JSONEncoder.DateEncodingStrategy {
public static var integerSecondsSince1970: Self {
.custom { date, encoder in
var container = encoder.singleValueContainer()
try container.encode(Int(date.timeIntervalSince1970.rounded(.towardZero)))
}
}
}

public extension JWTJSONEncoder where Self == JSONEncoder {
static var defaultForJWT: any JWTJSONEncoder {
extension JWTJSONEncoder where Self == JSONEncoder {
public static var defaultForJWT: any JWTJSONEncoder {
let encoder = JSONEncoder()
encoder.dateEncodingStrategy = .secondsSince1970
return encoder
}
}

public extension JWTJSONDecoder where Self == JSONDecoder {
static var defaultForJWT: any JWTJSONDecoder {
extension JWTJSONDecoder where Self == JSONDecoder {
public static var defaultForJWT: any JWTJSONDecoder {
let decoder = JSONDecoder()
decoder.dateDecodingStrategy = .secondsSince1970
return decoder
Expand Down

0 comments on commit cebdea8

Please sign in to comment.