File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
Sources/WebAuthn/Ceremonies/Authentication Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ public struct AuthenticationCredential: Sendable {
35
35
public let type : CredentialType
36
36
}
37
37
38
- extension AuthenticationCredential : Decodable {
38
+ extension AuthenticationCredential : Codable {
39
39
public init ( from decoder: Decoder ) throws {
40
40
let container = try decoder. container ( keyedBy: CodingKeys . self)
41
41
@@ -45,6 +45,16 @@ extension AuthenticationCredential: Decodable {
45
45
authenticatorAttachment = try container. decodeIfPresent ( AuthenticatorAttachment . self, forKey: . authenticatorAttachment)
46
46
type = try container. decode ( CredentialType . self, forKey: . type)
47
47
}
48
+
49
+ public func encode( to encoder: Encoder ) throws {
50
+ var container = encoder. container ( keyedBy: CodingKeys . self)
51
+
52
+ try container. encode ( id, forKey: . id)
53
+ try container. encode ( rawID. base64URLEncodedString ( ) , forKey: . rawID)
54
+ try container. encode ( response, forKey: . response)
55
+ try container. encodeIfPresent ( authenticatorAttachment, forKey: . authenticatorAttachment)
56
+ try container. encode ( type, forKey: . type)
57
+ }
48
58
49
59
private enum CodingKeys : String , CodingKey {
50
60
case id
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ public struct AuthenticatorAssertionResponse: Sendable {
49
49
public let attestationObject : [ UInt8 ] ?
50
50
}
51
51
52
- extension AuthenticatorAssertionResponse : Decodable {
52
+ extension AuthenticatorAssertionResponse : Codable {
53
53
public init ( from decoder: Decoder ) throws {
54
54
let container = try decoder. container ( keyedBy: CodingKeys . self)
55
55
@@ -59,6 +59,16 @@ extension AuthenticatorAssertionResponse: Decodable {
59
59
userHandle = try container. decodeBytesFromURLEncodedBase64IfPresent ( forKey: . userHandle)
60
60
attestationObject = try container. decodeBytesFromURLEncodedBase64IfPresent ( forKey: . attestationObject)
61
61
}
62
+
63
+ public func encode( to encoder: Encoder ) throws {
64
+ var container = encoder. container ( keyedBy: CodingKeys . self)
65
+
66
+ try container. encode ( clientDataJSON. base64URLEncodedString ( ) , forKey: . clientDataJSON)
67
+ try container. encode ( authenticatorData. base64URLEncodedString ( ) , forKey: . authenticatorData)
68
+ try container. encode ( signature. base64URLEncodedString ( ) , forKey: . signature)
69
+ try container. encodeIfPresent ( userHandle? . base64URLEncodedString ( ) , forKey: . userHandle)
70
+ try container. encodeIfPresent ( attestationObject? . base64URLEncodedString ( ) , forKey: . attestationObject)
71
+ }
62
72
63
73
private enum CodingKeys : String , CodingKey {
64
74
case clientDataJSON
You can’t perform that action at this time.
0 commit comments