Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A way to detect Biometry type for Android/iOS devices #1159

Open
FarjadGov14 opened this issue Jun 10, 2024 · 1 comment
Open

A way to detect Biometry type for Android/iOS devices #1159

FarjadGov14 opened this issue Jun 10, 2024 · 1 comment

Comments

@FarjadGov14
Copy link
Contributor

FarjadGov14 commented Jun 10, 2024

Description of feature / user story

A great feature to add would be to detect biometry type for Android/iOS devices, by using this below library
react-native-biometrics

If we can create a service or a utility in bifold to detect Biometry type we can guide the users accordingly, a utility function that can be used in a context provider and used by wallets to enhance User experience.

A Sample code that we could use below:

import Biometry, { BiometryType } from 'react-native-biometrics'

export interface IsSensorAvailableResult {
  available: boolean
  biometryType?: BiometryType
  error?: string
}

export interface SimplePromptResult {
  success: boolean
  error?: string
}

export function serviceGetBiometryDescription(biometryType: BiometryType | undefined): string {
  switch (biometryType) {
    case Biometry.TouchID:
      return Biometry.TouchID
    case Biometry.FaceID:
      return Biometry.FaceID
    case 'Biometrics':
      return 'Biometrics'
    default:
      throw new Error('We do not support this type of biometry')
  }
}

export function serviceAuthenticateWithBiometrics(promptMessage: string): Promise<SimplePromptResult> {
  return Biometry.simplePrompt({
    promptMessage: promptMessage,
  })
}

export function serviceGetEnrolledBiometry(): Promise<IsSensorAvailableResult> {
  return Biometry.isSensorAvailable()
}

export async function biometryType(): Promise<BiometryType | undefined> {
  let biometryType: BiometryType | undefined
  await Biometry.isSensorAvailable().then((resultObject) => {
    biometryType = resultObject.biometryType
  })
  return biometryType
}

This can be used across different wallets as a utility service.

Acceptance Criteria

A Hook for biometryType that can detect the device type and it can be used by other wallets as a custom hook.

Wireframes or relevant image assets / links

@timbl-ont
Copy link
Contributor

@jleach This can be closed. In a previous discussion it was pointed out that react-native-keychain which is already in the wallet can be used to get the Biometry type.

A utility function could be useful, but currently there no longer any plans to submit a PR for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants