From 125697657502899bb25a76dd213ef92a08647aad Mon Sep 17 00:00:00 2001 From: nayara dias Date: Wed, 6 Sep 2023 16:54:29 -0300 Subject: [PATCH] fix: modules exports and imports --- README.md | 26 ++++---- capitual-react-native-capface-sdk.podspec | 2 +- example/src/App.tsx | 2 +- example/types/index.d.ts | 1 + src/index.tsx | 2 +- src/types/index.ts | 72 +++++++++++++++-------- 6 files changed, 65 insertions(+), 40 deletions(-) create mode 100644 example/types/index.d.ts diff --git a/README.md b/README.md index 0cbaec2..3751a75 100644 --- a/README.md +++ b/README.md @@ -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) @@ -133,7 +133,7 @@ export default function App() { style={styles.button} onPress={async () => await init()} > - Init Facetec Module + Init Capface Module Open Photo Match @@ -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 | | ----------------------- | ------------------------------------------ | -------- | ----------- | @@ -201,7 +201,7 @@ 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 | | -------- | -------- | -------- | ----------- | @@ -209,7 +209,7 @@ This method makes a 3D reading of the user's face. But, you must use to **subscr ### `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 | | -------- | -------- | -------- | ----------- | @@ -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 | | ------------------ | -------------------------------------- | -------- | ----------- | @@ -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) | ✅ | ✅ | @@ -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 | | ------------------- | -------- | -------- | @@ -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 | | --------------------------- | -------- | --- | ------- | -------- | ----------------------------------------------------------------------- | @@ -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 | | --------------------------------------------------- | -------- | --- | ------- | -------- | ------------------------------------ | @@ -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. | ❌ | ✅ | @@ -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. |
-## 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. diff --git a/capitual-react-native-capface-sdk.podspec b/capitual-react-native-capface-sdk.podspec index e69e9bc..9c5c20b 100644 --- a/capitual-react-native-capface-sdk.podspec +++ b/capitual-react-native-capface-sdk.podspec @@ -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. diff --git a/example/src/App.tsx b/example/src/App.tsx index 0cc743a..4e0cee7 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -84,7 +84,7 @@ export default function App() { - Init Facetec Module + Init Capface Module Open Photo Match diff --git a/example/types/index.d.ts b/example/types/index.d.ts new file mode 100644 index 0000000..03e78f4 --- /dev/null +++ b/example/types/index.d.ts @@ -0,0 +1 @@ +declare module '@capitual/react-native-capface-sdk'; \ No newline at end of file diff --git a/src/index.tsx b/src/index.tsx index 02bb378..ee563fd 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -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 diff --git a/src/types/index.ts b/src/types/index.ts index a18c549..f321763 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -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 * @@ -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; } /** @@ -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; + handlePhotoIDMatch(data?: Object): Promise; + handleEnrollUser(data?: Object): Promise; + handleAuthenticateUser(data?: Object): Promise; + 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); + }, + } + );