use same naming style of channel methods as oath

This commit is contained in:
Adam Velebil 2024-03-01 10:05:03 +01:00
parent b6054a258b
commit 87c28e3328
No known key found for this signature in database
GPG Key ID: C9B1E4A3CBBD2E10
2 changed files with 23 additions and 23 deletions

View File

@ -115,22 +115,22 @@ class FidoManager(
fidoChannel.setHandler(coroutineScope) { method, args -> fidoChannel.setHandler(coroutineScope) { method, args ->
when (method) { when (method) {
"fido_reset" -> resetHelper.reset() "reset" -> resetHelper.reset()
"fido_reset_cancel" -> resetHelper.cancelReset() "cancelReset" -> resetHelper.cancelReset()
"session_unlock" -> unlock( "unlock" -> unlock(
(args["pin"] as String).toCharArray() (args["pin"] as String).toCharArray()
) )
"session_set_pin" -> setPin( "setPin" -> setPin(
(args["pin"] as String?)?.toCharArray(), (args["pin"] as String?)?.toCharArray(),
(args["new_pin"] as String).toCharArray(), (args["newPin"] as String).toCharArray(),
) )
"credential_delete" -> deleteCredential( "deleteCredential" -> deleteCredential(
args["rp_id"] as String, args["rpId"] as String,
args["credential_id"] as String args["credentialId"] as String
) )
else -> throw NotImplementedError() else -> throw NotImplementedError()
@ -288,8 +288,8 @@ class FidoManager(
JSONObject( JSONObject(
mapOf( mapOf(
"success" to false, "success" to false,
"pin_retries" to pinRetriesResult.count, "pinRetries" to pinRetriesResult.count,
"auth_blocked" to (ctapException.ctapError == CtapException.ERR_PIN_AUTH_BLOCKED) "authBlocked" to (ctapException.ctapError == CtapException.ERR_PIN_AUTH_BLOCKED)
) )
).toString() ).toString()
} else { } else {

View File

@ -72,7 +72,7 @@ class _FidoStateNotifier extends FidoStateNotifier {
}); });
controller.onCancel = () async { controller.onCancel = () async {
await _methods.invokeMethod('fido_reset_cancel'); await _methods.invokeMethod('cancelReset');
if (!controller.isClosed) { if (!controller.isClosed) {
await subscription.cancel(); await subscription.cancel();
} }
@ -80,11 +80,11 @@ class _FidoStateNotifier extends FidoStateNotifier {
controller.onListen = () async { controller.onListen = () async {
try { try {
await _methods.invokeMethod('fido_reset'); await _methods.invokeMethod('reset');
await controller.sink.close(); await controller.sink.close();
ref.invalidateSelf(); ref.invalidateSelf();
} catch (e) { } catch (e) {
_log.debug('Error during fido_reset: \'$e\''); _log.debug('Error during reset: \'$e\'');
controller.sink.addError(e); controller.sink.addError(e);
} }
}; };
@ -96,10 +96,10 @@ class _FidoStateNotifier extends FidoStateNotifier {
Future<PinResult> setPin(String newPin, {String? oldPin}) async { Future<PinResult> setPin(String newPin, {String? oldPin}) async {
try { try {
final response = jsonDecode(await _methods.invokeMethod( final response = jsonDecode(await _methods.invokeMethod(
'session_set_pin', 'setPin',
{ {
'pin': oldPin, 'pin': oldPin,
'new_pin': newPin, 'newPin': newPin,
}, },
)); ));
if (response['success'] == true) { if (response['success'] == true) {
@ -109,8 +109,8 @@ class _FidoStateNotifier extends FidoStateNotifier {
_log.debug('FIDO pin set/change failed'); _log.debug('FIDO pin set/change failed');
return PinResult.failed( return PinResult.failed(
response['pin_retries'], response['pinRetries'],
response['auth_blocked'], response['authBlocked'],
); );
} on PlatformException catch (pe) { } on PlatformException catch (pe) {
var decodedException = pe.decode(); var decodedException = pe.decode();
@ -125,7 +125,7 @@ class _FidoStateNotifier extends FidoStateNotifier {
Future<PinResult> unlock(String pin) async { Future<PinResult> unlock(String pin) async {
try { try {
final response = jsonDecode(await _methods.invokeMethod( final response = jsonDecode(await _methods.invokeMethod(
'session_unlock', 'unlock',
{'pin': pin}, {'pin': pin},
)); ));
@ -136,8 +136,8 @@ class _FidoStateNotifier extends FidoStateNotifier {
_log.debug('FIDO applet unlock failed'); _log.debug('FIDO applet unlock failed');
return PinResult.failed( return PinResult.failed(
response['pin_retries'], response['pinRetries'],
response['auth_blocked'], response['authBlocked'],
); );
} on PlatformException catch (pe) { } on PlatformException catch (pe) {
var decodedException = pe.decode(); var decodedException = pe.decode();
@ -207,10 +207,10 @@ class _FidoCredentialsNotifier extends FidoCredentialsNotifier {
Future<void> deleteCredential(FidoCredential credential) async { Future<void> deleteCredential(FidoCredential credential) async {
try { try {
await _methods.invokeMethod( await _methods.invokeMethod(
'credential_delete', 'deleteCredential',
{ {
'rp_id': credential.rpId, 'rpId': credential.rpId,
'credential_id': credential.credentialId, 'credentialId': credential.credentialId,
}, },
); );
} on PlatformException catch (pe) { } on PlatformException catch (pe) {