1- //
2- // WebAuthnLoginCredentialCreationOptionsResponse.swift
3- // Bitwarden
4- //
5- // Created by Isaiah Inuwa on 2025-10-03.
6- //
7-
8-
91import Foundation
102import Networking
113
4+ // swiftlint:disable line_length
5+
6+ // MARK: WebAuthnLoginCredentialCreationOptionsResponse
7+
8+ /// Parameters received from the server to initiate a WebAuthn credential creation flow.
129struct WebAuthnLoginCredentialCreationOptionsResponse : JSONResponse , Equatable , Sendable {
1310 /// Options to be provided to the webauthn authenticator.
14- let options : PublicKeyCredentialCreationOptions ;
11+ let options : PublicKeyCredentialCreationOptions
1512
1613 /// Contains an encrypted version of the {@link options}.
1714 /// Used by the server to validate the attestation response of newly created credentials.
18- let token : String ;
15+ let token : String
1916}
2017
18+ // MARK: PublicKeyCredentialCreationOptions
19+
20+ /// WebAuthn [PublicKeyCredentialCreationOptions](https://www.w3.org/TR/webauthn-3/#dictdef-publickeycredentialcreationoptions).
2121struct PublicKeyCredentialCreationOptions : Codable , Equatable , Hashable {
22- // attestation?: AttestationConveyancePreference
23- // let authenticatorSelection: AuthenticatorSelectionCriteria?
22+ /// A base64-encoded challenge that the authenticator signs, along with other data, when producing an attestation
23+ /// object for the newly created credential.
24+ ///
25+ /// ([Link to specification](https://www.w3.org/TR/webauthn-3/#dom-publickeycredentialcreationoptions-challenge))
26+ ///
27+ /// Note that the server sends this challenge as a padded base64 string, not as a unpadded base64url string as is
28+ /// used in most places in the WebAuthn spec.
2429 let challenge : String
30+
31+ /// Credential IDs received from the server which should not appear on the authenticator used to complete the
32+ /// ceremony.
33+ ///
34+ /// ([Link to specification](https://www.w3.org/TR/webauthn-3/#dom-publickeycredentialcreationoptions-excludecredentials))
2535 let excludeCredentials : [ BwPublicKeyCredentialDescriptor ] ?
36+
37+ /// WebAuthn client extension inputs.
38+ ///
39+ /// ([Link to specification](https://www.w3.org/TR/webauthn-3/#dom-publickeycredentialcreationoptions-extensions)).
2640 let extensions : AuthenticationExtensionsClientInputs ?
41+
42+ /// Types of WebAuthn credentials that the server supports.
43+ ///
44+ /// ([Link to specification](https://www.w3.org/TR/webauthn-3/#dom-publickeycredentialcreationoptions-pubkeycredparams))
2745 let pubKeyCredParams : [ BwPublicKeyCredentialParameters ]
28- let rp : BwPublicKeyCredentialRpEntity
46+
47+ /// Relying party information for the request.
48+ ///
49+ /// [Link to specification](https://www.w3.org/TR/webauthn-3/#dom-publickeycredentialcreationoptions-rp).
50+ let rp : BwPublicKeyCredentialRpEntity // swiftlint:disable:this identifier_name
51+
52+ /// Time, in milliseconds, that the server is willing to wait for a response.
53+ ///
54+ /// [Link to specification](https://www.w3.org/TR/webauthn-3/#dom-publickeycredentialcreationoptions-timeout)
2955 let timeout : Int ?
56+
57+ /// Information about the user for whom the credential is being created.
58+ ///
59+ /// [Link to spec](https://www.w3.org/TR/webauthn-3/#dom-publickeycredentialcreationoptions-user).
3060 let user : BwPublicKeyCredentialUserEntity
3161}
3262
63+ // MARK: AuthenticationExtensionsClientInputs
3364
65+ /// Inputs for WebAuthn extensions.
3466struct AuthenticationExtensionsClientInputs : Codable , Equatable , Hashable {
67+ /// Input values for PRF extensions.
68+ ///
69+ /// [Link to specification](https://www.w3.org/TR/webauthn-3/#dom-authenticationextensionsclientinputs-prf)
3570 let prf : AuthenticationExtensionsPRFInputs ?
3671}
3772
73+ // MARK: AuthenticationExtensionsPRFInputs
74+
75+ /// Input values for WebAutn PRF extension.
76+ ///
77+ /// [Link to specification](https://www.w3.org/TR/webauthn-3/#dictdef-authenticationextensionsprfinputs)
3878struct AuthenticationExtensionsPRFInputs : Codable , Equatable , Hashable {
3979 let eval : AuthenticationExtensionsPRFValues ?
4080 let evalByCredential : [ String : AuthenticationExtensionsPRFValues ] ?
4181}
4282
83+ // MARK: AuthenticationExtensionsPRFValues
84+
85+ /// WebAuthn PRF input values.
86+ ///
87+ /// [Link to specification](https://www.w3.org/TR/webauthn-3/#dictdef-authenticationextensionsprfvalues)
4388struct AuthenticationExtensionsPRFValues : Codable , Equatable , Hashable {
4489 let first : String
4590 let second : String ?
4691}
4792
93+ // MARK: BwPublicKeyCredentialDescriptor
94+
95+ /// WebAuthn Credential Descriptor.
96+ ///
97+ /// [Link to specification](https://www.w3.org/TR/webauthn-3/#dictionary-credential-descriptor)
98+ /// Distinct from ``BitwardenSdk.PublicKeyCredentialDescriptor`` for deserialization purposes.
4899struct BwPublicKeyCredentialDescriptor : Codable , Equatable , Hashable {
49100 let type : String
50101 let id : String
51- // let transports: [String]?
52102}
53103
104+ // MARK: BwPublicKeyCredentialParameters
105+
106+ /// WebAuthn parameters for credential generation.
107+ ///
108+ /// [Link to specification](https://www.w3.org/TR/webauthn-3/#dictdef-publickeycredentialparameters)
109+ /// Distinct from ``BitwardenSdk.PublicKeyCredentialParameters`` for serialization purposes.
54110struct BwPublicKeyCredentialParameters : Codable , Equatable , Hashable {
55111 let type : String
56112 let alg : Int
57113}
58114
115+ // MARK: BwPublicKeyCredentialRpEntity
116+
117+ /// WebAuthn relying party information.
118+ ///
119+ /// [Link to specification](https://www.w3.org/TR/webauthn-3/#dictdef-publickeycredentialrpentity)
120+ /// Distinct from ``BitwardenSdk.PublicKeyCredentialRpEntity`` for serialization purposes.
59121struct BwPublicKeyCredentialRpEntity : Codable , Equatable , Hashable {
60122 let id : String
61123 let name : String
62124}
63125
126+ // MARK: BwPublicKeyCredentialUserEntity
127+
128+ /// WebAuthn user account parameters.
129+ ///
130+ /// [Link to specification](https://www.w3.org/TR/webauthn-3/#dictdef-publickeycredentialuserentity)
131+ /// Distinct from ``BitwardenSdk.PublicKeyCredentialUserEntity`` for serialization purposes.
64132struct BwPublicKeyCredentialUserEntity : Codable , Equatable , Hashable {
65133 let id : String
66134 let name : String
67- }
135+ }
136+
137+ // swiftlint:enable line_length
0 commit comments