feat(mobile): add U2F support for Android devices (#2311)

* feat(mobile): add U2F support for Android devices

* chore: fix specs
This commit is contained in:
Karol Sójko
2023-04-17 14:57:41 +02:00
committed by GitHub
parent c0c9a4ff91
commit 725f55fca7
23 changed files with 449 additions and 86 deletions

View File

@@ -22,6 +22,7 @@ import {
AppStateStatus,
ColorSchemeName,
Linking,
NativeModules,
PermissionsAndroid,
Platform,
StatusBar,
@@ -71,6 +72,26 @@ export class MobileDevice implements MobileDeviceInterface {
private colorSchemeService?: ColorSchemeObserverService,
) {}
async authenticateWithU2F(authenticationOptionsJSONString: string): Promise<Record<string, unknown> | null> {
const { Fido2ApiModule } = NativeModules
if (!Fido2ApiModule) {
this.consoleLog('Fido2ApiModule is not available')
return null
}
try {
const response = await Fido2ApiModule.promptForU2FAuthentication(authenticationOptionsJSONString)
return response
} catch (error) {
this.consoleLog(`Fido2ApiModule.authenticateWithU2F error: ${(error as Error).message}`)
return null
}
}
purchaseSubscriptionIAP(plan: AppleIAPProductId): Promise<AppleIAPReceipt | undefined> {
return PurchaseManager.getInstance().purchase(plan)
}