31
31
import com .yubico .webauthn .StartAssertionOptions ;
32
32
import com .yubico .webauthn .extension .appid .AppId ;
33
33
import java .util .HashSet ;
34
+ import java .util .Map ;
34
35
import java .util .Optional ;
35
36
import java .util .Set ;
36
37
import lombok .Builder ;
@@ -55,15 +56,18 @@ public class AssertionExtensionInputs implements ExtensionInputs {
55
56
56
57
private final AppId appid ;
57
58
private final Extensions .LargeBlob .LargeBlobAuthenticationInput largeBlob ;
59
+ private final Extensions .Prf .PrfAuthenticationInput prf ;
58
60
private final Boolean uvm ;
59
61
60
62
@ JsonCreator
61
63
private AssertionExtensionInputs (
62
64
@ JsonProperty ("appid" ) AppId appid ,
63
65
@ JsonProperty ("largeBlob" ) Extensions .LargeBlob .LargeBlobAuthenticationInput largeBlob ,
66
+ @ JsonProperty ("prf" ) Extensions .Prf .PrfAuthenticationInput prf ,
64
67
@ JsonProperty ("uvm" ) Boolean uvm ) {
65
68
this .appid = appid ;
66
69
this .largeBlob = largeBlob ;
70
+ this .prf = prf ;
67
71
this .uvm = (uvm != null && uvm ) ? true : null ;
68
72
}
69
73
@@ -78,6 +82,7 @@ public AssertionExtensionInputs merge(AssertionExtensionInputs other) {
78
82
return new AssertionExtensionInputs (
79
83
this .appid != null ? this .appid : other .appid ,
80
84
this .largeBlob != null ? this .largeBlob : other .largeBlob ,
85
+ this .prf != null ? this .prf : other .prf ,
81
86
this .uvm != null ? this .uvm : other .uvm );
82
87
}
83
88
@@ -95,6 +100,9 @@ public Set<String> getExtensionIds() {
95
100
if (largeBlob != null ) {
96
101
ids .add (Extensions .LargeBlob .EXTENSION_ID );
97
102
}
103
+ if (prf != null ) {
104
+ ids .add (Extensions .Prf .EXTENSION_ID );
105
+ }
98
106
if (getUvm ()) {
99
107
ids .add (Extensions .Uvm .EXTENSION_ID );
100
108
}
@@ -172,6 +180,37 @@ public AssertionExtensionInputsBuilder largeBlob(
172
180
return this ;
173
181
}
174
182
183
+ /**
184
+ * Enable the Pseudo-random function extension (<code>prf</code>).
185
+ *
186
+ * <p>This extension allows a Relying Party to evaluate outputs from a pseudo-random function
187
+ * (PRF) associated with a credential.
188
+ *
189
+ * <p>Use the {@link com.yubico.webauthn.data.Extensions.Prf.PrfAuthenticationInput} factory
190
+ * functions to construct the argument:
191
+ *
192
+ * <ul>
193
+ * <li>Use {@link Extensions.Prf.PrfAuthenticationInput#eval(Extensions.Prf.PrfValues)} to use
194
+ * the same PRF input for all credentials.
195
+ * <li>Use {@link Extensions.Prf.PrfAuthenticationInput#evalByCredential(Map)} to use
196
+ * different PRF inputs for different credentials.
197
+ * <li>Use {@link Extensions.Prf.PrfAuthenticationInput#evalByCredentialWithFallback(Map,
198
+ * Extensions.Prf.PrfValues)} to use different PRF inputs for different credentials, but
199
+ * with a "fallback" input for credentials without their own input.
200
+ * </ul>
201
+ *
202
+ * @see Extensions.Prf.PrfAuthenticationInput#eval(Extensions.Prf.PrfValues)
203
+ * @see Extensions.Prf.PrfAuthenticationInput#evalByCredential(Map)
204
+ * @see Extensions.Prf.PrfAuthenticationInput#evalByCredentialWithFallback(Map,
205
+ * Extensions.Prf.PrfValues)
206
+ * @see <a href="https://www.w3.org/TR/2025/WD-webauthn-3-20250127/#prf-extension">§10.1.4.
207
+ * Pseudo-random function extension (prf)</a>
208
+ */
209
+ public AssertionExtensionInputsBuilder prf (Extensions .Prf .PrfAuthenticationInput prf ) {
210
+ this .prf = prf ;
211
+ return this ;
212
+ }
213
+
175
214
/**
176
215
* Enable the User Verification Method Extension (<code>uvm</code>).
177
216
*
@@ -233,6 +272,31 @@ private Extensions.LargeBlob.LargeBlobAuthenticationInput getLargeBlobJson() {
233
272
: null ;
234
273
}
235
274
275
+ /**
276
+ * The input to the Pseudo-random function extension (<code>prf</code>), if any.
277
+ *
278
+ * <p>This extension allows a Relying Party to evaluate outputs from a pseudo-random function
279
+ * (PRF) associated with a credential.
280
+ *
281
+ * @see Extensions.Prf.PrfAuthenticationInput#eval(Extensions.Prf.PrfValues)
282
+ * @see Extensions.Prf.PrfAuthenticationInput#evalByCredential(Map)
283
+ * @see Extensions.Prf.PrfAuthenticationInput#evalByCredentialWithFallback(Map,
284
+ * Extensions.Prf.PrfValues)
285
+ * @see <a href="https://www.w3.org/TR/2025/WD-webauthn-3-20250127/#prf-extension">§10.1.4.
286
+ * Pseudo-random function extension (prf)</a>
287
+ */
288
+ public Optional <Extensions .Prf .PrfAuthenticationInput > getPrf () {
289
+ return Optional .ofNullable (prf );
290
+ }
291
+
292
+ /** For JSON serialization, to omit false and null values. */
293
+ @ JsonProperty ("prf" )
294
+ private Extensions .Prf .PrfAuthenticationInput getPrfJson () {
295
+ return prf != null && (prf .getEval ().isPresent () || prf .getEvalByCredential ().isPresent ())
296
+ ? prf
297
+ : null ;
298
+ }
299
+
236
300
/**
237
301
* @return <code>true</code> if the User Verification Method Extension (<code>uvm</code>) is
238
302
* enabled, <code>false</code> otherwise.
0 commit comments