Skip to content

Commit

Permalink
fix: modules exports and imports
Browse files Browse the repository at this point in the history
  • Loading branch information
nayaradias committed Sep 6, 2023
1 parent b43234b commit 1256976
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 40 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Capface sdk adapter to react native. 📱
- [`CapfaceSdk.Errors`](#capfacesdkerrors)
- [Native Events](#native-events)
- [`Event Types`](#event-types)
- [How to add images in FaceTecSDK module?](#how-to-add-images-in-capfacesdk-module)
- [How to add images in CapfaceSDK module?](#how-to-add-images-in-capfacesdk-module)
- [How to add images in Android?](#how-to-add-images-in-android)
- [How to add images in iOS?](#how-to-add-images-in-ios)
- [Example with images added](#example-with-images-added)
Expand Down Expand Up @@ -133,7 +133,7 @@ export default function App() {
style={styles.button}
onPress={async () => await init()}
>
<Text style={styles.text}>Init Facetec Module</Text>
<Text style={styles.text}>Init Capface Module</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.button} onPress={onPressPhotoMatch}>
<Text style={styles.text}>Open Photo Match</Text>
Expand Down Expand Up @@ -192,7 +192,7 @@ const styles = StyleSheet.create({

### `initialize(init: CapfaceSdk.Initialize)`

This is the **principal** method to be called, he must be **called first** to initialize the FaceTec SDK. If he doens't be called the other methods **don't works!**
This is the **principal** method to be called, he must be **called first** to initialize the Capface SDK. If he doens't be called the other methods **don't works!**

| `CapfaceSdk.Initialize` | type | Required | Default |
| ----------------------- | ------------------------------------------ | -------- | ----------- |
Expand All @@ -201,15 +201,15 @@ This is the **principal** method to be called, he must be **called first** to in

### `enroll(data?: Object)`

This method makes a 3D reading of the user's face. But, you must use to **subscribe** user in FaceTec SDK or in your server.
This method makes a 3D reading of the user's face. But, you must use to **subscribe** user in Capface SDK or in your server.

| `Object` | type | Required | Default |
| -------- | -------- | -------- | ----------- |
| `data` | `Object` || `undefined` |

### `authenticate(data?: Object)`

This method makes a 3D reading of the user's face. But, you must use to **authenticate** user in FaceTec SDK or in your server.
This method makes a 3D reading of the user's face. But, you must use to **authenticate** user in Capface SDK or in your server.

| `Object` | type | Required | Default |
| -------- | -------- | -------- | ----------- |
Expand All @@ -233,7 +233,7 @@ This method make to read from face and documents for user, after comparate face

### `setTheme(options?: CapfaceSdk.Theme)`

This method must be used to **set** the **theme** of the FaceTec SDK screen.
This method must be used to **set** the **theme** of the Capface SDK screen.

| `CapfaceSdk.Theme` | type | Required | Default |
| ------------------ | -------------------------------------- | -------- | ----------- |
Expand All @@ -243,7 +243,7 @@ This method must be used to **set** the **theme** of the FaceTec SDK screen.

## Types

| `FacetecSdk` - Types | iOS | Android |
| `CapfaceSdk` - Types | iOS | Android |
| ----------------------------------------------------------------------------------- | --- | ------- |
| [`CapfaceSdk.Params`](#capfacesdkparams) |||
| [`CapfaceSdk.Headers`](#capfacesdkheaders) |||
Expand All @@ -257,7 +257,7 @@ This method must be used to **set** the **theme** of the FaceTec SDK screen.

### `CapfaceSdk.Params`

Here must be passed to initialize the FaceTec SDK! Case the parameters isn't provided the FaceTec SDK goes to be not initialized.
Here must be passed to initialize the Capface SDK! Case the parameters isn't provided the Capface SDK goes to be not initialized.

| `CapfaceSdk.Params` | type | Required |
| ------------------- | -------- | -------- |
Expand Down Expand Up @@ -375,7 +375,7 @@ This interface defines the drawn in the layer's coordinate space.

### `CapfaceSdk.DefaultMessage`

This interface represents the success message and loading data message during to FaceTecSDK flow. It interface is used **more** by processors's [authenticate](#authenticatedata-capfacesdkdata) and [enroll](#enrolldata-capfacesdkdata) processors.
This interface represents the success message and loading data message during to CapfaceSDK flow. It interface is used **more** by processors's [authenticate](#authenticatedata-capfacesdkdata) and [enroll](#enrolldata-capfacesdkdata) processors.

| `CapfaceSdk.DefaultMessage` | type | iOS | Android | Required | Default |
| --------------------------- | -------- | --- | ------- | -------- | ----------------------------------------------------------------------- |
Expand All @@ -384,7 +384,7 @@ This interface represents the success message and loading data message during to

### `CapfaceSdk.DefaultScanMessage`

This interface represents the all scan messages during to FaceTecSDK flow. It interface is used by [photoMatch](#photomatchdata-capfacesdkdata) processors.
This interface represents the all scan messages during to CapfaceSDK flow. It interface is used by [photoMatch](#photomatchdata-capfacesdkdata) processors.

| `CapfaceSdk.DefaultScanMessage` | type | iOS | Android | Required | Default |
| --------------------------------------------------- | -------- | --- | ------- | -------- | ------------------------------------ |
Expand Down Expand Up @@ -427,7 +427,7 @@ This interface represents the all scan messages during to FaceTecSDK flow. It in

| `CapfaceSdk.Errors` | Description | iOS | Android |
| ------------------------------- | ------------------------------------------------------------------------------------ | --- | ------- |
| `FaceTecDoenstInitialized` | When some processors method is runned, but FaceTecSDK **wasn't initialized**. |||
| `FaceTecDoenstInitialized` | When some processors method is runned, but CapfaceSDK **wasn't initialized**. |||
| `FaceTecWasntProcessed` | When the image sent to the processors cannot be processed due to inconsistency. |||
| `HTTPSError` | When exists some network error. |||
| `JSONError` | When exists some problem in getting data in request of **base URL** information. |||
Expand All @@ -450,11 +450,11 @@ This is a list of event types that can be used on `addListener`.

| `eventType` | Return | Description |
| -------------- | --------- | ----------------------------------------------------------------------------------------------------------------- |
| `onCloseModal` | `boolean` | This event listener verify if FaceTec modal biometric is open. Return `true` if modal is open, `false` otherwise. |
| `onCloseModal` | `boolean` | This event listener verify if Capface modal biometric is open. Return `true` if modal is open, `false` otherwise. |

<hr/>

## How to add images in FaceTecSDK module?
## How to add images in CapfaceSDK module?

The `logoImage` and `cancelImage` properties represents your logo and icon of the button cancel. Does not possible to remove them from the module. Default are [Capitual](https://www.capitual.com/) images and `.png` format. In `Android` you can find the image's full name in lower case and in `iOS` the image's full name, but, with a difference of the first letter to be in the upper case.

Expand Down
2 changes: 1 addition & 1 deletion capitual-react-native-capface-sdk.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Pod::Spec.new do |s|
s.dependency "React-Core"

s.ios.resource_bundles = {
'ReactNativeFaceTecSdk' => ['ios/SupportingFiles/*.xcassets']
'ReactNativeCapfaceSdk' => ['ios/SupportingFiles/*.xcassets']
}

# Don't install the dependencies when we run `pod install` in the old architecture.
Expand Down
2 changes: 1 addition & 1 deletion example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default function App() {
<ScrollView style={styles.container}>
<View style={styles.content}>
<TouchableOpacity style={styles.button} onPress={init}>
<Text style={styles.text}>Init Facetec Module</Text>
<Text style={styles.text}>Init Capface Module</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.button} onPress={onPressPhotoMatch}>
<Text style={styles.text}>Open Photo Match</Text>
Expand Down
1 change: 1 addition & 0 deletions example/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module '@capitual/react-native-capface-sdk';
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ReactNativeCapfaceSdk, { CapfaceSdk } from './types';
import { CapfaceSdk, ReactNativeCapfaceSdk } from './types';

/**
* @description This is the **principal** method to be called, he must be
Expand Down
72 changes: 48 additions & 24 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,6 @@ const LINKING_ERROR =
'- You rebuilt the app after installing the package\n' +
'- You are not using Expo Go\n';

const ReactNativeCapfaceSdk = NativeModules.ReactNativeCapfaceSdk
? NativeModules.ReactNativeCapfaceSdk
: new Proxy(
{},
{
get() {
throw new Error(LINKING_ERROR);
},
}
);

/**
* @description Native module CapfaceSDK, it's recommended use it with event
* types.
*
* @example
* import { NativeEventEmitter } from 'react-native';
* import ReactNativeCapfaceSdk from '@capitual/react-native-capface-sdk';
*
* const emitter = new NativeEventEmitter(ReactNativeCapfaceSdk);
* emitter.addListener('onCloseModal', (event: boolean) => console.log('onCloseModal', event));
*/
export default ReactNativeCapfaceSdk;

/**
* @namespace
*
Expand Down Expand Up @@ -768,6 +744,11 @@ export declare namespace CapfaceSdk {
* Available in your Capface account.
*/
productionKey: string;

/**
* @description Option to select production or developement mode for initialize CapfaceSDK.
*/
isDeveloperMode: string;
}

/**
Expand Down Expand Up @@ -822,4 +803,47 @@ export declare namespace CapfaceSdk {
*/
CapfaceScanWasntProcessed = 'CapfaceScanWasntProcessed',
}

/**
* @interface Methods
*
* @description This is the available methods in Capface SDK.
*/
interface Methods {
/**
* @description ....
*/
initializeSdk(
params: Params,
headers?: Headers,
callback?: Function
): Promise<boolean>;
handlePhotoIDMatch(data?: Object): Promise<boolean>;
handleEnrollUser(data?: Object): Promise<boolean>;
handleAuthenticateUser(data?: Object): Promise<boolean>;
handleTheme(options?: Theme): void;
}
}

/**
* @description Native module CapfaceSDK, it's recommended use it with event
* types.
*
* @example
* import { NativeEventEmitter } from 'react-native';
* import ReactNativeCapfaceSdk from '@capitual/react-native-capface-sdk';
*
* const emitter = new NativeEventEmitter(ReactNativeCapfaceSdk);
* emitter.addListener('onCloseModal', (event: boolean) => console.log('onCloseModal', event));
*/
export const ReactNativeCapfaceSdk: CapfaceSdk.Methods =
NativeModules.ReactNativeCapfaceSdk
? NativeModules.ReactNativeCapfaceSdk
: new Proxy(
{},
{
get() {
throw new Error(LINKING_ERROR);
},
}
);

0 comments on commit 1256976

Please sign in to comment.