-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
186 additions
and
110 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
android/src/main/kotlin/net/archethic/yubikit_android/methods/Connect.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package net.archethic.yubikit_android.methods | ||
|
||
import io.flutter.plugin.common.MethodCall | ||
import io.flutter.plugin.common.MethodChannel | ||
|
||
class Connect : MethodHandler { | ||
override fun handle(call: MethodCall, result: MethodChannel.Result) { | ||
|
||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
android/src/main/kotlin/net/archethic/yubikit_android/methods/MethodHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package net.archethic.yubikit_android.methods | ||
|
||
import androidx.annotation.NonNull | ||
import io.flutter.plugin.common.MethodCall | ||
import io.flutter.plugin.common.MethodChannel | ||
|
||
interface MethodHandler { | ||
fun handle(@NonNull call: MethodCall, @NonNull result: MethodChannel.Result); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,4 +36,4 @@ SPEC CHECKSUMS: | |
|
||
PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3 | ||
|
||
COCOAPODS: 1.11.3 | ||
COCOAPODS: 1.12.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import 'package:yubidart/yubidart.dart'; | ||
|
||
abstract class Connection { | ||
Future<PivProtocol> get pivSession; | ||
|
||
Future<OTPProtocol> get otpSession; | ||
} | ||
|
||
abstract class ConnectionProtocol { | ||
/// Looks at the device capabilities (connectivity mainly) | ||
Future<DeviceCapabilities> get deviceCapabilities; | ||
|
||
Future<Connection> connect({ | ||
Duration timeout = const Duration(minutes: 1), | ||
}); | ||
|
||
Future<void> disconnect(); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export 'general/protocol.dart'; | ||
export 'connection/protocol.dart'; | ||
export 'otp/otp.dart'; | ||
export 'piv/protocol.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
lib/src/infrastructure/protocol/connection/default_connection_protocol.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import 'package:flutter/services.dart'; | ||
import 'package:yubidart/src/domain/model/failure/failure.dart'; | ||
import 'package:yubidart/src/domain/model/general/device_capabilities.dart'; | ||
import 'package:yubidart/src/domain/protocol/connection/protocol.dart'; | ||
import 'package:yubidart/src/domain/protocol/otp/otp.dart'; | ||
import 'package:yubidart/src/domain/protocol/piv/protocol.dart'; | ||
import 'package:yubidart/src/infrastructure/protocol/otp/default_otp_protocol.dart'; | ||
import 'package:yubidart/src/infrastructure/protocol/otp/yubicloud_client.dart'; | ||
import 'package:yubidart/src/infrastructure/protocol/piv/default_piv_protocol.dart'; | ||
|
||
class DefaultConnection implements Connection { | ||
@override | ||
Future<PivProtocol> get pivSession async => DefaultPivProtocol(); | ||
|
||
@override | ||
Future<OTPProtocol> get otpSession async => | ||
DefaultOTPProtocol(yubicloudClient: YubicloudClient()); | ||
} | ||
|
||
class DefaultConnectionProtocol implements ConnectionProtocol { | ||
/// The method channel used to interact with the native platform. | ||
// @foundation.visibleForTesting | ||
final methodChannel = const MethodChannel('net.archethic/yubidart'); | ||
|
||
@override | ||
Future<DeviceCapabilities> get deviceCapabilities => YKFailure.guard( | ||
() async { | ||
final supportsNFCScanning = | ||
await methodChannel.invokeMethod<bool>('supportsNFCScanning'); | ||
final supportsISO7816NFCTags = | ||
await methodChannel.invokeMethod<bool>('supportsISO7816NFCTags'); | ||
final supportsMFIAccessoryKey = | ||
await methodChannel.invokeMethod<bool>('supportsMFIAccessoryKey'); | ||
|
||
if (supportsNFCScanning == null || | ||
supportsISO7816NFCTags == null || | ||
supportsMFIAccessoryKey == null) { | ||
throw YKFailure.other(); | ||
} | ||
|
||
return DeviceCapabilities( | ||
nfc: supportsNFCScanning || supportsISO7816NFCTags, | ||
wired: supportsMFIAccessoryKey, | ||
); | ||
}, | ||
); | ||
|
||
@override | ||
Future<Connection> connect({ | ||
Duration timeout = const Duration(minutes: 1), | ||
}) { | ||
return YKFailure.guard( | ||
() async { | ||
await methodChannel.invokeMethod( | ||
'connect', | ||
); | ||
return DefaultConnection(); | ||
}, | ||
); | ||
} | ||
|
||
@override | ||
Future<void> disconnect() { | ||
return YKFailure.guard( | ||
() async { | ||
await methodChannel.invokeMethod( | ||
'disconnect', | ||
); | ||
}, | ||
); | ||
} | ||
} |
32 changes: 0 additions & 32 deletions
32
lib/src/infrastructure/protocol/general/default_general_protocol.dart
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.