@@ -72,7 +72,10 @@ interface DeviceAuthenticator {
7272 * @param kid Generated kid from the Preference
7373 * @param userId userId received from server
7474 * @param challenge challenge received from server
75- * @param customClaims A map of custom claims to be added to the jws payload
75+ * @param expiration token expiration time
76+ * @param attestation Attestation type to decide whether to include certificate chain in the JWS header
77+ *
78+ * @return the signed JWT as String
7679 */
7780 fun sign (context : Context ,
7881 keyPair : KeyPair ,
@@ -89,7 +92,7 @@ interface DeviceAuthenticator {
8992 if (attestation !is Attestation .None ) {
9093 builder.x509CertChain(getCertificateChain(userId))
9194 }
92- val jwk = builder.build();
95+ val jwk = builder.build()
9396 val signedJWT = SignedJWT (JWSHeader .Builder (parse(getAlgorithm()))
9497 .keyID(kid).jwk(jwk).build(),
9598 JWTClaimsSet .Builder ().subject(userId)
@@ -210,7 +213,16 @@ interface DeviceAuthenticator {
210213
211214}
212215
213- fun DeviceAuthenticator.initialize (userId : String , prompt : Prompt ): DeviceAuthenticator {
216+ /* *
217+ * Initialize the DeviceAuthenticator with userId, authentication validity duration and prompt
218+ * @param userId The user ID for which the keys will be generated.
219+ * @param authenticationValidityDuration The duration (in seconds) for which the generated key remains valid
220+ * for user authentication. Passed to the underlying crypto key during key generation. Defaults to 5 seconds.
221+ * @param prompt The Prompt to modify the title, subtitle, description
222+ *
223+ * @return The initialized DeviceAuthenticator instance.
224+ */
225+ fun DeviceAuthenticator.initialize (userId : String , authenticationValidityDuration : Int , prompt : Prompt ): DeviceAuthenticator {
214226
215227 // Inject objects
216228 if (this is BiometricAuthenticator ) {
@@ -219,15 +231,23 @@ fun DeviceAuthenticator.initialize(userId: String, prompt: Prompt): DeviceAuthen
219231 prompt.description,
220232 deviceBindAuthenticationType = this .type()))
221233 }
222- initialize(userId)
234+ initialize(userId, authenticationValidityDuration )
223235 this .prompt(prompt)
224236 return this
225237}
226238
227- fun DeviceAuthenticator.initialize (userId : String ): DeviceAuthenticator {
239+ /* *
240+ * Initialize the DeviceAuthenticator with userId and authentication validity duration
241+ * @param userId The user ID for which the keys will be generated.
242+ * @param authenticationValidityDuration The duration (in seconds) for which the generated key remains valid
243+ * for user authentication. Passed to the underlying crypto key during key generation. Defaults to 5 seconds.
244+ *
245+ * @return The initialized DeviceAuthenticator instance.
246+ */
247+ fun DeviceAuthenticator.initialize (userId : String , authenticationValidityDuration : Int = 5): DeviceAuthenticator {
228248 // Inject objects
229249 if (this is CryptoAware ) {
230- this .setKey(CryptoKey (userId))
250+ this .setKey(CryptoKey (userId, authenticationValidityDuration ))
231251 }
232252 return this
233253}
0 commit comments