fold

inline fun <T, R> PasskeyResult<T>.fold(onSuccess: (T) -> R, onFailure: (PasskeyError) -> R): R

Returns onSuccess of the value or onFailure of the error; exactly one of them runs. The usual way to turn a result into your own type:

passkeys.signIn(options).fold(
onSuccess = { AuthResult.SignedIn(api.finishSignIn(it.json)) },
onFailure = { if (it.isUserCancellation) AuthResult.Idle else AuthResult.Error(it) },
)