diff --git a/Sources/JSONWebToken/Claims/AudienceClaim.swift b/Sources/JSONWebToken/Claims/AudienceClaim.swift index 69978f7..d73e7e1 100644 --- a/Sources/JSONWebToken/Claims/AudienceClaim.swift +++ b/Sources/JSONWebToken/Claims/AudienceClaim.swift @@ -31,7 +31,7 @@ public struct AudienceClaim: JWTRegisteredClaim { /// Initializes an `AudienceClaim` with an array of audience values using a result builder. /// - Parameter claims: A closure that returns an array of `StringClaim` using the result builder. - init(@ArrayClaim.ArrayClaimBuilder claims: () -> [StringClaim]) { + public init(@ArrayClaim.ArrayClaimBuilder claims: () -> [StringClaim]) { self.value = .init(key: "aud", element: .array(claims().map(\.value))) } } diff --git a/Sources/JSONWebToken/JWT+Encryption.swift b/Sources/JSONWebToken/JWT+Encryption.swift index 7abb1a0..64e19cb 100644 --- a/Sources/JSONWebToken/JWT+Encryption.swift +++ b/Sources/JSONWebToken/JWT+Encryption.swift @@ -77,7 +77,7 @@ extension JWT { P: JWERegisteredFieldsHeader, U: JWERegisteredFieldsHeader >( - @JWTClaimsBuilder payload: () -> Claim, + @JWTClaimsBuilder claims: () -> Claim, protectedHeader: P, unprotectedHeader: U? = nil as DefaultJWEHeaderImpl?, senderKey: KeyRepresentable?, @@ -91,7 +91,7 @@ extension JWT { if protectedHeader.type == nil { protectedHeader.type = "JWT" } - let encodedPayload = try JSONEncoder.jwt.encode(payload().value) + let encodedPayload = try JSONEncoder.jwt.encode(claims().value) return JWT( payload: encodedPayload, format: .jwe(try JWE( @@ -243,7 +243,7 @@ extension JWT { NP: JWERegisteredFieldsHeader, NU: JWERegisteredFieldsHeader >( - @JWTClaimsBuilder payload: () -> Claim, + @JWTClaimsBuilder claims: () -> Claim, protectedHeader: P, unprotectedHeader: U? = nil as DefaultJWEHeaderImpl?, senderKey: KeyRepresentable? = nil, @@ -262,7 +262,7 @@ extension JWT { nestedAdditionalAuthenticationData: Data? = nil ) throws -> JWE { let jwt = try encrypt( - payload: payload, + claims: claims, protectedHeader: nestedProtectedHeader, unprotectedHeader: nestedUnprotectedHeader, senderKey: nestedSenderKey, diff --git a/Sources/JSONWebToken/JWT+Signing.swift b/Sources/JSONWebToken/JWT+Signing.swift index 98fe99e..b52f524 100644 --- a/Sources/JSONWebToken/JWT+Signing.swift +++ b/Sources/JSONWebToken/JWT+Signing.swift @@ -69,7 +69,7 @@ extension JWT { /// - Throws: An error if the signing process or encoding fails. /// - Returns: A `JWT` instance in JWS format with the signed claims. public static func signed( - @JWTClaimsBuilder payload: () -> Claim, + @JWTClaimsBuilder claims: () -> Claim, protectedHeader: P, key: Key? ) throws -> JWT { @@ -77,7 +77,7 @@ extension JWT { if protectedHeader.type == nil { protectedHeader.type = "JWT" } - let encodedPayload = try JSONEncoder.jwt.encode(payload().value) + let encodedPayload = try JSONEncoder.jwt.encode(claims().value) return JWT( payload: encodedPayload, format: .jws(try JWS( @@ -145,14 +145,14 @@ extension JWT { P: JWSRegisteredFieldsHeader, NP: JWSRegisteredFieldsHeader >( - @JWTClaimsBuilder payload: () -> Claim, + @JWTClaimsBuilder claims: () -> Claim, protectedHeader: P, key: KeyRepresentable?, nestedProtectedHeader: NP, nestedKey: KeyRepresentable? ) throws -> JWS { let jwt = try signed( - payload: payload, + claims: claims, protectedHeader: nestedProtectedHeader, key: nestedKey )