diff --git a/Sources/JWSETKit/Entities/JWE/JWE.swift b/Sources/JWSETKit/Entities/JWE/JWE.swift index fbd18fa..157ff8b 100644 --- a/Sources/JWSETKit/Entities/JWE/JWE.swift +++ b/Sources/JWSETKit/Entities/JWE/JWE.swift @@ -214,7 +214,9 @@ public struct JSONWebEncryption: Hashable, Sendable { extension String { public init(jwe: JSONWebEncryption) throws { - self = try String(String(decoding: JSONEncoder.encoder.encode(jwe), as: UTF8.self).dropFirst().dropLast()) + var encoder = JSONEncoder.encoder + encoder.userInfo[.jwsEncodedRepresentation] = JSONWebEncryptionRepresentation.compact + self = try String(String(decoding: encoder.encode(jwe), as: UTF8.self).dropFirst().dropLast()) } } diff --git a/Sources/JWSETKit/Entities/JWS/JWS.swift b/Sources/JWSETKit/Entities/JWS/JWS.swift index 39bd199..1cff41a 100644 --- a/Sources/JWSETKit/Entities/JWS/JWS.swift +++ b/Sources/JWSETKit/Entities/JWS/JWS.swift @@ -157,7 +157,9 @@ public struct JSONWebSignature: Hashable, Sendab extension String { public init(jws: JSONWebSignature) throws { - self = try String(String(decoding: JSONEncoder.encoder.encode(jws), as: UTF8.self).dropFirst().dropLast()) + var encoder = JSONEncoder.encoder + encoder.userInfo[.jwsEncodedRepresentation] = JSONWebSignatureRepresentation.compact + self = try String(String(decoding: encoder.encode(jws), as: UTF8.self).dropFirst().dropLast()) } }