Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@biopassid/face-sdk-react-native
Advanced tools
Key Features • Customizations • Quick Start Guide • Prerequisites • Installation • How to use • LicenseKey • FaceConfig • Something else • Changelog • Support
Increase the security of your applications without harming your user experience.
All customization available:
Enable or disable components:
Change all colors:
Check out our official documentation for more in depth information on BioPass ID.
Android | iOS | |
---|---|---|
Support | SDK 24+ | iOS 14+ |
- A device with a camera
- License key
- Internet connection is required to verify the license
npm install @biopassid/face-sdk-react-native
Change the minimum Android sdk version to 24 (or higher) in your android/app/build.gradle
file.
minSdkVersion 24
Requires iOS 14.0 or higher.
Add to the ios/Info.plist
:
Privacy - Camera Usage Description
and a usage description.If editing Info.plist
as text, add:
<key>NSCameraUsageDescription</key>
<string>Your camera usage description</string>
Then go into your project's ios folder and run pod install.
# Go into ios folder
$ cd ios
# Install dependencies
$ pod install
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyCollectedDataTypes</key>
<array>
<dict>
<key>NSPrivacyCollectedDataType</key>
<string>NSPrivacyCollectedDataTypeOtherUserContent</string>
<key>NSPrivacyCollectedDataTypeLinked</key>
<false/>
<key>NSPrivacyCollectedDataTypeTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypePurposes</key>
<array>
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
</array>
</dict>
<dict>
<key>NSPrivacyCollectedDataType</key>
<string>NSPrivacyCollectedDataTypeDeviceID</string>
<key>NSPrivacyCollectedDataTypeLinked</key>
<false/>
<key>NSPrivacyCollectedDataTypeTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypePurposes</key>
<array>
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
</array>
</dict>
</array>
<key>NSPrivacyTracking</key>
<false/>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>CA92.1</string>
</array>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
</dict>
</array>
</dict>
</plist>
To call Face in your React Native project is as easy as follow:
import React from "react";
import { StyleSheet, View, Button } from "react-native";
import { useFace } from "@biopassid/face-sdk-react-native";
export default function App() {
const { takeFace } = useFace();
async function onPress() {
await takeFace({
config: { licenseKey: "your-license-key" },
onFaceCapture: (image: string) => {
console.log("Image: ", image.substring(0, 20));
},
});
}
return (
<View style={styles.container}>
<Button onPress={onPress} title="Capture Face" />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: "center",
justifyContent: "center",
backgroundColor: '#FFFFFF',
},
});
For this example we used the Enroll from the Multibiometrics plan.
Here, you will need an API key to be able to make requests to the BioPass ID API. To get your API key contact us through our website BioPass ID.
import React from "react";
import { StyleSheet, View, Button } from "react-native";
import { useFace } from "@biopassid/face-sdk-react-native";
export default function App() {
const { takeFace } = useFace();
function onFaceCapture(image: string) {
// Create headers passing your api key
const headers = {
"Content-Type": "application/json",
"Ocp-Apim-Subscription-Key": "your-api-key",
};
// Create json body
const body = JSON.stringify({
Person: {
CustomID: "your-customID",
Face: [{"Face-1": image}],
},
});
// Execute request to BioPass ID API
const response = await fetch(
"https://api.biopassid.com/multibiometrics/enroll",
{
method: "POST",
headers,
body,
},
);
const data = await response.json();
// Handle API response
console.log("Response status: ", response.status);
console.log("Response body: ", data);
}
async function onPress() {
await takeFace({
config: { licenseKey: "your-license-key" },
onFaceCapture,
});
}
return (
<View style={styles.container}>
<Button onPress={onPress} title="Capture Face" />
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: "center",
justifyContent: "center",
backgroundColor: "#FFFFFF",
},
});
To use Face you need a license key. To set the license key needed is simple as setting another attribute. Simply doing:
const config: FaceConfig = {
licenseKey: "your-license-key",
};
You can pass a function callback to receive the captured image. Images are returned in Base64 string format. You can write you own callback following this example:
function onFaceCapture(image: string) {
console.log("Image: ", image.substring(0, 20));
}
async function onPress() {
await takeFace({
config: { licenseKey: "your-license-key" },
onFaceCapture,
});
}
You can use continuous capture to capture multiple frames at once. In addition, you can set a maximum number of frames to be captured using maxNumberFrames. As well as the capture time with timeToCapture. Use continuous capture is as simple as setting another attribute. Simply by doing:
const config: FaceConfig = {
licenseKey: "your-license-key",
continuousCapture: {
enabled: true,
timeToCapture: 1000, // capture every frame per second, time in millisecond
maxNumberFrames: 40,
},
};
With Face SDK you can use face detection to do face detection and automatic capture. Below you can see the options that are available for this functionality.
For automatic capture to work, autoCapture needs to be enabled. By default, autoCapture is already enabled. If autoCapture is disabled, automatic capture will be disabled and the responsibility for capturing will be the user's responsibility through a button. For continuous capture, autoCapture will be ignored and automatic capture will always occur. To set autoCapture is simple as setting another attribute. Simply doing:
const config: FaceConfig = {
licenseKey: "your-license-key",
faceDetection: { enabled: true, autoCapture: true },
};
TimeToCapture is a time in milliseconds that is triggered before the capture. To use timeToCapture, autoCapture needs to be on and a time in milliseconds needs to be passed to timeToCapture. By default, timeToCapture value is 3000ms. If timeToCapture is equal to zero, the capture will be instantaneous. To set timeToCapture is simple as setting another attribute. Simply doing:
const config: FaceConfig = {
licenseKey: "your-license-key",
faceDetection: {
enabled: true,
autoCapture: true,
timeToCapture: 3000, // time in millisecond
},
};
You can use maxFaceDetectionTime to set a maximum time in milliseconds that face detection will be active. If after this time the SDK is unable to identify a face, face detection will be disabled and a capture button will be displayed, thus passing the capture responsibility to the user. The time will only start counting after a first detection attempt. By default, the value of maxFaceDetectionTime is 40000 ms. This functionality only affects single capture mode. Setting maxFaceDetectionTime is as simple as setting another attribute. Simply by doing:
const config: FaceConfig = {
licenseKey: 'your-license-key',
faceDetection: {
enabled: true,
maxFaceDetectionTime: 40000, // time in millisecond
},
};
Minimum trust score for a detection to be considered valid. Must be a number between 0 and 1, which 0.1 would be a lower face detection trust level and 0.9 would be a higher trust level. Default: 0.7. Simply by doing:
const config: FaceConfig = {
licenseKey: 'your-license-key',
faceDetection: {
enabled: true,
scoreThreshold: 0.7,
},
};
You can also use pre-build configurations on your application, so you can automatically start using multiples services and features that better suit your application. You can instantiate each one and use it's default properties, or if you prefer you can change every config available. Here are the types that are supported right now:
Name | Type |
---|---|
licenseKey | string |
resolutionPreset | FaceResolutionPreset |
lensDirection | FaceCameraLensDirection |
imageFormat | FaceImageFormat |
flashEnabled | boolean |
fontFamily | string |
continuousCapture | FaceContinuousCaptureOptions |
faceDetection | FaceDetectionOptions |
mask | FaceMaskOptions |
titleText | FaceTextOptions |
loadingText | FaceTextOptions |
helpText | FaceTextOptions |
feedbackText | FaceFeedbackTextOptions |
backButton | FaceButtonOptions |
flashButton | FaceFlashButtonOptions |
switchCameraButton | FaceButtonOptions |
captureButton | FaceButtonOptions |
Default configs:
const defaultConfig: FaceConfig = {
licenseKey: "",
resolutionPreset: FaceResolutionPreset.MEDIUM,
lensDirection: FaceCameraLensDirection.FRONT,
imageFormat: FaceImageFormat.JPEG,
flashEnabled: false,
fontFamily: "facesdk_opensans_bold",
continuousCapture: {
enabled: false,
timeToCapture: 1000,
maxNumberFrames: 40,
},
faceDetection: {
enabled: true,
autoCapture: true,
multipleFacesEnabled: false,
timeToCapture: 3000,
maxFaceDetectionTime: 40000,
scoreThreshold: 0.7,
},
mask: {
enabled: true,
type: FaceMaskFormat.FACE,
backgroundColor: "#CC000000",
frameColor: "#FFFFFF",
frameEnabledColor: "#16AC81",
frameErrorColor: "#E25353",
},
titleText: {
enabled: true,
content: "Capturando Face",
textColor: "#FFFFFF",
textSize: 20,
},
loadingText: {
enabled: true,
content: "Processando...",
textColor: "#FFFFFF",
textSize: 14,
},
helpText: {
enabled: true,
content: "Encaixe seu rosto no formato abaixo",
textColor: "#FFFFFF",
textSize: 14,
},
feedbackText: {
enabled: true,
messages: {
noFaceDetectedMessage: "Nenhuma face detectada",
multipleFacesDetectedMessage: "Múltiplas faces detectadas",
detectedFaceIsCenteredMessage: "Mantenha o celular parado",
detectedFaceIsTooCloseMessage: "Afaste o rosto da câmera",
detectedFaceIsTooFarMessage: "Aproxime o rosto da câmera",
detectedFaceIsOnTheLeftMessage: "Mova o celular para a direita",
detectedFaceIsOnTheRightMessage: "Mova o celular para a esquerda",
detectedFaceIsTooUpMessage: "Mova o celular para baixo",
detectedFaceIsTooDownMessage: "Mova o celular para cima",
},
textColor: "#FFFFFF",
textSize: 14,
},
backButton: {
enabled: true,
backgroundColor: "#00000000",
buttonPadding: 0,
buttonSize: { width: 56, height: 56 },
iconOptions: {
enabled: true,
iconFile: "facesdk_ic_close",
iconColor: "#FFFFFF",
iconSize: { width: 32, height: 32 },
},
labelOptions: {
enabled: false,
content: "Voltar",
textColor: "#FFFFFF",
textSize: 14,
},
},
flashButton: {
enabled: false,
backgroundColor: "#FFFFFF",
buttonPadding: 0,
buttonSize: { width: 56, height: 56 },
flashOnIconOptions: {
enabled: true,
iconFile: "facesdk_ic_flash_on",
iconColor: "#FFCC01",
iconSize: { width: 32, height: 32 },
},
flashOnLabelOptions: {
enabled: false,
content: "Flash On",
textColor: "#323232",
textSize: 14,
},
flashOffIconOptions: {
enabled: true,
iconFile: "facesdk_ic_flash_off",
iconColor: "#323232",
iconSize: { width: 32, height: 32 },
},
flashOffLabelOptions: {
enabled: false,
content: "Flash Off",
textColor: "#323232",
textSize: 14,
},
},
switchCameraButton: {
enabled: true,
backgroundColor: "#FFFFFF",
buttonPadding: 0,
buttonSize: { width: 56, height: 56 },
iconOptions: {
enabled: true,
iconFile: "facesdk_ic_switch_camera",
iconColor: "#323232",
iconSize: { width: 32, height: 32 },
},
labelOptions: {
enabled: false,
content: "Trocar Câmera",
textColor: "#323232",
textSize: 14,
},
},
captureButton: {
enabled: true,
backgroundColor: "#FFFFFF",
buttonPadding: 0,
buttonSize: { width: 56, height: 56 },
iconOptions: {
enabled: true,
iconFile: "facesdk_ic_capture",
iconColor: "#323232",
iconSize: { width: 32, height: 32 },
},
labelOptions: {
enabled: false,
content: "Capturar",
textColor: "#323232",
textSize: 14,
},
},
};
Name | Type |
---|---|
enabled | boolean |
timeToCapture | number // time in milliseconds |
maxNumberFrames | number |
Name | Type |
---|---|
enabled | boolean |
autoCapture | boolean |
multipleFacesEnabled | boolean |
timeToCapture | number // time in milliseconds |
maxFaceDetectionTime | number // time in milliseconds |
scoreThreshold | number |
Name | Type |
---|---|
enabled | boolean |
type | FaceMaskFormat |
backgroundColor | string |
frameColor | string |
frameEnabledColor | string |
frameErrorColor | string |
Name | Type |
---|---|
enabled | boolean |
messages | FaceFeedbackTextMessages |
textColor | string |
textSize | number |
Name | Type |
---|---|
noFaceDetectedMessage | string |
multipleFacesDetectedMessage | string |
detectedFaceIsCenteredMessage | string |
detectedFaceIsTooCloseMessage | string |
detectedFaceIsTooFarMessage | string |
detectedFaceIsOnTheLeftMessage | string |
detectedFaceIsOnTheRightMessage | string |
detectedFaceIsTooUpMessage | string |
detectedFaceIsTooDownMessage | string |
Name | Type |
---|---|
enabled | boolean |
backgroundColor | string |
buttonPadding | number |
buttonSize | FaceSize |
flashOnIconOptions | FaceIconOptions |
flashOnLabelOptions | FaceTextOptions |
flashOffIconOptions | FaceIconOptions |
flashOffLabelOptions | FaceTextOptions |
Name | Type |
---|---|
enabled | boolean |
backgroundColor | string |
buttonPadding | number |
buttonSize | FaceSize |
iconOptions | FaceIconOptions |
labelOptions | FaceTextOptions |
Name | Type |
---|---|
enabled | boolean |
iconFile | string |
iconColor | string |
iconSize | FaceSize |
Name | Type |
---|---|
enabled | boolean |
content | string |
textColor | string |
textSize | number |
Name |
---|
FaceCameraLensDirection.FRONT |
FaceCameraLensDirection.BACK |
Name |
---|
FaceImageFormat.JPEG |
FaceImageFormat.PNG |
Name |
---|
FaceScreenShape.FACE |
FaceScreenShape.SQUARE |
FaceScreenShape.ELLIPSE |
Name | Resolution |
---|---|
FaceResolutionPreset.LOW | 240p (352x288 on iOS, 320x240 on Android) |
FaceResolutionPreset.MEDIUM | 480p (640x480 on iOS, 720x480 on Android) |
FaceResolutionPreset.HIGH | 720p (1280x720) |
FaceResolutionPreset.VERYHIGH | 1080p (1920x1080) |
FaceResolutionPreset.ULTRAHIGH | 2160p (3840x2160) |
FaceResolutionPreset.MAX | The highest resolution available |
You can use the default font family or set one of your own. To set a font, create a folder font under res directory in your android/app/src/main/res
. Download the font which ever you want and paste it inside font folder. All font file names must be only: lowercase a-z, 0-9, or underscore. The structure should be some thing like below.
To add the font files to your Xcode project:
Then, add the "Fonts provided by application" key to your app’s Info.plist file. For the key’s value, provide an array of strings containing the relative paths to any added font files.
In the following example, the font file is inside the fonts directory, so you use fonts/roboto_mono_bold_italic.ttf as the string value in the Info.plist file.
Finally, just set the font passing the name of the font file when instantiating FaceConfig in your React Native app.
const config: FaceConfig = {
licenseKey: "your-license-key",
fontFamily: "roboto_mono_bold_italic",
};
You can use the default icons or define one of your own. To set a icon, download the icon which ever you want and paste it inside drawable folder in your android/app/src/main/res
. All icon file names must be only: lowercase a-z, 0-9, or underscore. The structure should be some thing like below.
To add icon files to your Xcode project:
Finally, just set the icon passing the name of the icon file when instantiating FaceConfig in your React Native app.
const config: FaceConfig = {
licenseKey: "your-license-key",
// Changing back button icon
backButton: { iconOptions: { iconFile: "ic_baseline_camera" } },
// Changing switch camera button icon
switchCameraButton: { iconOptions: { iconFile: "ic_baseline_camera" } },
// Changing capture button icon
captureButton: { iconOptions: { iconFile: "ic_baseline_camera" } },
// Changing flash button icon
flashButton: {
flashOnIconOptions: { iconFile: 'ic_baseline_camera' },
flashOffIconOptions: { iconFile: 'ic_baseline_camera' },
},
};
Do you like the Face SDK and would you like to know about our other products? We have solutions for fingerprint detection and digital signature capture.
FAQs
BioPass ID Face React Native module.
The npm package @biopassid/face-sdk-react-native receives a total of 460 weekly downloads. As such, @biopassid/face-sdk-react-native popularity was classified as not popular.
We found that @biopassid/face-sdk-react-native demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.