Skip to content

Commit ff2fcaa

Browse files
Added a typed initializer to AuthenticatorData
1 parent 4db01ce commit ff2fcaa

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

Sources/WebAuthn/Ceremonies/Shared/AuthenticatorData.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,23 @@ public struct AuthenticatorData: Equatable, Sendable {
2525
/// For attestation signatures this value will be set. For assertion signatures not.
2626
let attestedData: AttestedCredentialData?
2727
let extData: [UInt8]?
28+
29+
init(
30+
relyingPartyIDHash: SHA256Digest,
31+
flags: AuthenticatorFlags,
32+
counter: UInt32,
33+
attestedData: AttestedCredentialData? = nil,
34+
extData: [UInt8]? = nil
35+
) {
36+
self.relyingPartyIDHash = Array(relyingPartyIDHash)
37+
var flags = flags
38+
flags.attestedCredentialData = attestedData != nil
39+
flags.extensionDataIncluded = extData != nil
40+
self.flags = flags
41+
self.counter = counter
42+
self.attestedData = attestedData
43+
self.extData = extData
44+
}
2845
}
2946

3047
extension AuthenticatorData {

Sources/WebAuthn/Ceremonies/Shared/AuthenticatorFlags.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ public struct AuthenticatorFlags: Equatable, Sendable {
3333
case extensionDataIncluded = 7
3434
}
3535

36-
let userPresent: Bool
37-
let userVerified: Bool
38-
let isBackupEligible: Bool
39-
let isCurrentlyBackedUp: Bool
40-
let attestedCredentialData: Bool
41-
let extensionDataIncluded: Bool
36+
var userPresent: Bool
37+
var userVerified: Bool
38+
var isBackupEligible: Bool
39+
var isCurrentlyBackedUp: Bool
40+
var attestedCredentialData: Bool
41+
var extensionDataIncluded: Bool
4242

4343
var deviceType: VerifiedAuthentication.CredentialDeviceType {
4444
isBackupEligible ? .multiDevice : .singleDevice

0 commit comments

Comments
 (0)