@@ -20,7 +20,7 @@ import Foundation
20
20
/// `Encodable` byte arrays are base64url encoded.
21
21
///
22
22
/// - SeeAlso: https://www.w3.org/TR/webauthn-2/#dictionary-makecredentialoptions
23
- public struct PublicKeyCredentialCreationOptions : Encodable , Sendable {
23
+ public struct PublicKeyCredentialCreationOptions : Sendable {
24
24
/// A byte array randomly generated by the Relying Party. Should be at least 16 bytes long to ensure sufficient
25
25
/// entropy.
26
26
///
@@ -47,6 +47,19 @@ public struct PublicKeyCredentialCreationOptions: Encodable, Sendable {
47
47
/// Sets the Relying Party's preference for attestation conveyance. At the time of writing only `none` is
48
48
/// supported.
49
49
public let attestation : AttestationConveyancePreference
50
+ }
51
+
52
+ extension PublicKeyCredentialCreationOptions : Codable {
53
+ public init ( from decoder: Decoder ) throws {
54
+ let container = try decoder. container ( keyedBy: CodingKeys . self)
55
+
56
+ challenge = try container. decodeBytesFromURLEncodedBase64 ( forKey: . challenge)
57
+ user = try container. decode ( PublicKeyCredentialUserEntity . self, forKey: . user)
58
+ relyingParty = try container. decode ( PublicKeyCredentialRelyingPartyEntity . self, forKey: . relyingParty)
59
+ publicKeyCredentialParameters = try container. decode ( [ PublicKeyCredentialParameters ] . self, forKey: . publicKeyCredentialParameters)
60
+ timeout = try container. decodeIfPresent ( UInt32 . self, forKey: . timeout) . map { . milliseconds( $0) }
61
+ attestation = try container. decode ( AttestationConveyancePreference . self, forKey: . attestation)
62
+ }
50
63
51
64
public func encode( to encoder: Encoder ) throws {
52
65
var container = encoder. container ( keyedBy: CodingKeys . self)
0 commit comments