### API Response Example Source: https://github.com/fazpass/seamless-documentation/blob/main/README.md This is an example of the response structure you can expect after calling an API. ```JSON "status":true, "code":200 "data":{ "meta":"" } ``` -------------------------------- ### Request Notification Permission Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Web.md This example demonstrates how to ask the user for notification permissions. It checks for browser support, existing permissions, and handles user responses. Notifications should be spawned in response to a user gesture. ```html ``` -------------------------------- ### FazpassSettingsBuilder Class and Usage Examples Source: https://github.com/fazpass/seamless-documentation/blob/main/README.ReactNative.md A builder class for creating FazpassSettings. Use methods to enable/disable sensitive data and set biometric levels. Examples show builder construction and settings copying. ```typescript /** * A builder to create {@link FazpassSettings} object. * * To enable specific sensitive data collection, call `enableSelectedSensitiveData` method * and specify which data you want to collect. Otherwise call `disableSelectedSensitiveData` method * and specify which data you don't want to collect. To set biometric level to high, call `setBiometricLevelToHigh`. Otherwise call * `setBiometricLevelToLow`. To create {@link FazpassSettings} object with this builder configuration, use {@link FazpassSettings.fromBuilder()} method. * ```typescript * // create builder * const builder: FazpassSettingsBuilder = FazpassSettingsBuilder() * .enableSelectedSensitiveData([SensitiveData.location]) * .setBiometricLevelToHigh(); * * // construct FazpassSettings with the builder * const settings: FazpassSettings = FazpassSettings.fromBuilder(builder); * ``` * * You can also copy settings from {@link FazpassSettings} by using the secondary constructor. * ```typescript * const builder: FazpassSettingsBuilder = * FazpassSettingsBuilder(settings); * ``` */ export class FazpassSettingsBuilder { #sensitiveData: SensitiveData[]; #isBiometricLevelHigh: boolean; get sensitiveData() { return this.#sensitiveData.map((v) => v); } get isBiometricLevelHigh() { return this.#isBiometricLevelHigh; } constructor(settings?: FazpassSettings) { this.#sensitiveData = settings ? [...settings.sensitiveData] : []; this.#isBiometricLevelHigh = settings?.isBiometricLevelHigh ?? false; } enableSelectedSensitiveData(sensitiveData: SensitiveData[]): this { for (const data in sensitiveData) { const key = data as keyof typeof SensitiveData; if (this.#sensitiveData.includes(SensitiveData[key])) { continue; } else { this.#sensitiveData.push(SensitiveData[key]); } } return this; } disableSelectedSensitiveData(sensitiveData: SensitiveData[]): this { for (const data in sensitiveData) { const key = data as keyof typeof SensitiveData; const willRemoveIndex = this.#sensitiveData.indexOf(SensitiveData[key], 0); if (willRemoveIndex > -1) { this.#sensitiveData.splice(willRemoveIndex, 1); } else { continue; } } return this; } setBiometricLevelToHigh(): this { this.#isBiometricLevelHigh = true; return this; } setBiometricLevelToLow(): this { this.#isBiometricLevelHigh = false; return this; } } ``` -------------------------------- ### Native iOS/Android Fazpass Implementation Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Flutter.md Example of native code (Swift/Kotlin) handling Flutter method calls for Fazpass functionalities. This includes setting settings, getting cross-device data, and managing event streams. ```swift result(settings?.toString()) case "setSettings": let args = call.arguments as! Dictionary var settings: FazpassSettings? if (args["settings"] is String) { settings = FazpassSettings.fromString(args["settings"] as! String) } Fazpass.shared.setSettings(accountIndex: args["accountIndex"] as! Int, settings: settings) result(nil) case "getCrossDeviceDataFromNotification": let request = Fazpass.shared.getCrossDeviceDataFromNotification(userInfo: nil) result(request?.toDict()) default: result(FlutterMethodNotImplemented) } } class CrossDeviceEventHandler: NSObject, FlutterStreamHandler { private let stream = Fazpass.shared.getCrossDeviceDataStreamInstance() func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError? { stream.listen { request in events(request.toDict()) } return nil } func onCancel(withArguments arguments: Any?) -> FlutterError? { stream.close() return nil } } } ``` -------------------------------- ### Add ios-trusted-device-v2 using Cocoapods Source: https://github.com/fazpass/seamless-documentation/blob/main/README.iOS.md Add the ios-trusted-device-v2 SDK as a dependency in your Podfile when using Cocoapods for installation. ```ruby pod 'ios-trusted-device-v2', :git => 'https://github.com/fazpass-sdk/ios-trusted-device-v2.git' ``` -------------------------------- ### Flutter MethodChannel and EventChannel Setup Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Flutter.md Defines the MethodChannel and EventChannel for communication between Flutter and native code. Used for invoking native methods and listening to native events. ```dart class Fazpass { static const _CHANNEL = 'com.fazpass.trusted-device'; static const _CD_CHANNEL = 'com.fazpass.trusted-device-cd'; static const instance = Fazpass(); const Fazpass(); final methodChannel = const MethodChannel(_CHANNEL); final eventChannel = const EventChannel(_CD_CHANNEL); Future generateMeta({int accountIndex=-1}) async { String meta = ''; try { meta = await methodChannel.invokeMethod('generateMeta', accountIndex) ?? ''; } on PlatformException catch (e) { switch (e.code) { case 'fazpass-BiometricNoneEnrolledError': throw BiometricNoneEnrolledError(e); case 'fazpass-BiometricAuthFailedError': throw BiometricAuthFailedError(e); case 'fazpass-BiometricUnavailableError': throw BiometricUnavailableError(e); case 'fazpass-BiometricUnsupportedError': throw BiometricUnsupportedError(e); case 'fazpass-PublicKeyNotExistException': throw PublicKeyNotExistException(e); case 'fazpass-UninitializedException': throw UninitializedException(e); case 'fazpass-BiometricSecurityUpdateRequiredError': throw BiometricSecurityUpdateRequiredError(e); case 'fazpass-EncryptionException': default: throw EncryptionException(e); } } return meta; } Future generateNewSecretKey() async { return methodChannel.invokeMethod('generateNewSecretKey'); } Future getSettings(int accountIndex) async { final settingsString = await methodChannel.invokeMethod('getSettings', accountIndex); if (settingsString is String) { return FazpassSettings.fromString(settingsString); } return null; } Future setSettings(int accountIndex, FazpassSettings? settings) async { return await methodChannel.invokeMethod('setSettings', {"accountIndex": accountIndex, "settings": settings?.toString()}); } Stream getCrossDeviceDataStreamInstance() { return eventChannel.receiveBroadcastStream().map((event) => CrossDeviceData.fromData(event)); } Future getCrossDeviceDataFromNotification() async { final data = await methodChannel.invokeMethod('getCrossDeviceDataFromNotification'); return data == null ? null : CrossDeviceData.fromData(data); } Future> getAppSignatures() async { if (Platform.isAndroid) { final signatures = await methodChannel.invokeListMethod('getAppSignatures'); return signatures ?? []; } return []; } } ``` -------------------------------- ### Listen to Cross Device Notification Stream (Foreground) Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Android.V2.md Get the stream instance and start listening for incoming cross-device notifications when the application is in the foreground. You can also stop listening to the stream. ```kotlin // get the stream instance val crossDeviceStream = fazpass.getCrossDeviceDataStreamInstance(this) // start listening to the stream crossDeviceStream.listen { data -> // called everytime there is an incoming cross device notification print(data) if (data.status == "request") { val notificationId = data.notificationId!! print(notificationId) } else if (data.status == "validate") { val action = data.action!! print(action) } } // stop listening to the stream crossDeviceStream.close() ``` -------------------------------- ### Implement FazpassMethodCallHandler Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Flutter.md Handle various method calls from Flutter, such as generating meta, secrets, retrieving settings, and getting app signatures. This class also initializes the Fazpass SDK with a new public key. ```kotlin import android.app.Activity import androidx.fragment.app.FragmentActivity import io.flutter.plugin.common.MethodCall import io.flutter.plugin.common.MethodChannel import com.fazpass.Fazpass import com.fazpass.FazpassSettings class FazpassMethodCallHandler( private val activity: FragmentActivity, private val fazpass: Fazpass ): MethodChannel.MethodCallHandler { init { fazpass.init(activity, "new-public-key.pub") } override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) { when (call.method) { "generateMeta" -> { val accountIndex = call.arguments as Int fazpass.generateMeta(activity, accountIndex) { meta, error -> if (error == null) { result.success(meta) return@generateMeta } result.error( "fazpass-${error.name}", error.exception.message, null ) } } "generateNewSecretKey" -> { try { fazpass.generateNewSecretKey(activity) result.success(null) } catch (e: Exception) { result.error("fazpass-Error", e.message, null) } } "getSettings" -> { val accountIndex = call.arguments as Int val settings = fazpass.getSettings(accountIndex) result.success(settings?.toString()) } "setSettings" -> { val args = call.arguments as Map<*, ?> val accountIndex = args["accountIndex"] as Int val settingsString = args["settings"] as String? val settings = if (settingsString != null) FazpassSettings.fromString(settingsString) else null fazpass.setSettings(activity, accountIndex, settings) result.success(null) } "getCrossDeviceDataFromNotification" -> { val request = fazpass.getCrossDeviceDataFromNotification(activity.intent) result.success(request?.toMap()) } "getAppSignatures" -> { val appSignatures = fazpass.getAppSignatures(activity) result.success(appSignatures) } else -> result.notImplemented() } } } ``` -------------------------------- ### Get Fazpass Instance and App Signatures Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Android.V2.md Retrieve the Fazpass SDK instance and log your application's signatures. This is typically done in your main activity to obtain the signature required for Fazpass merchant registration. ```kotlin // get fazpass instance val fazpass = FazpassFactory.getInstance() Log.i("APPSGN", fazpass.getAppSignatures(this).toString()) ``` -------------------------------- ### Retrieve Cross Device Data (Foreground State) Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Flutter.md When the application is in the foreground, get the stream instance using `getCrossDeviceDataStreamInstance()` and listen to the stream to receive incoming cross-device notifications. ```APIDOC ## getCrossDeviceDataStreamInstance() ### Description Provides a stream to listen for incoming cross-device notifications when the application is in the foreground. ### Method `getCrossDeviceDataStreamInstance()` ### Parameters None ### Response - **crossDeviceStream** (Stream) - A stream that emits `CrossDeviceData` objects. ### Usage ```dart // get the stream instance Stream crossDeviceStream = Fazpass.instance.getCrossDeviceDataStreamInstance(); // start listening to the stream StreamSubscription crossDeviceSubs = crossDeviceStream.listen((CrossDeviceData data) { // called everytime there is an incoming cross device notification print(data); if (data.status == "request") { String notificationId = data.notificationId!; print(notificationId); } else if (data.status == "validate") { String action = data.action!; print(action); } }); // stop listening to the stream crossDeviceSubs.cancel(); ``` ``` -------------------------------- ### Listen for Cross Device Data Stream (Foreground) Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Flutter.md Get the stream instance and listen for incoming cross-device notifications when the application is in the foreground. Remember to cancel the subscription when no longer needed. ```dart // get the stream instance Stream crossDeviceStream = Fazpass.instance.getCrossDeviceDataStreamInstance(); // start listening to the stream StreamSubscription crossDeviceSubs = crossDeviceStream.listen((CrossDeviceData data) { // called everytime there is an incoming cross device notification print(data); if (data.status == "request") { String notificationId = data.notificationId!; print(notificationId); } else if (data.status == "validate") { String action = data.action!; print(action); } }); // stop listening to the stream crossDeviceSubs.cancel(); ``` -------------------------------- ### Handle Cross Device Request Stream Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Web.md Retrieve the cross-device request stream instance and start listening for incoming requests. Ensure the Fazpass service worker is set up. To stop listening, call the returned function. ```javascript // get the stream instance and start listening to the stream let requestStream = fazpass.getCrossDeviceRequestStreamInstance( (request) => { console.log(request) } ) // stop listening to the stream requestStream() ``` -------------------------------- ### Initialize Fazpass SDK with Served File Paths Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Web.md Initialize the Fazpass SDK using the actual URLs where your public key and service worker files are served. This is the practical application of the initialization step. ```javascript // public key is served at https://www.yourdomain.com/files/public-key.txt // fazpass service worker is served at https://www.yourdomain.com/sw/my-service-worker.js fazpass.init( '/files/public-key.txt', '/sw/fazpass-service-worker.js' ) ``` -------------------------------- ### Initialize Fazpass SDK Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Web.md Initialize the Fazpass SDK with your public key and service worker file paths. Ensure these paths are correctly configured to point to your served files. ```javascript fazpass.init( 'YOUR_PUBLIC_KEY_FILE', 'YOUR_SERVICE_WORKER_FILE' ) ``` -------------------------------- ### Initialize Fazpass SDK Source: https://github.com/fazpass/seamless-documentation/blob/main/README.iOS.md Call this method in your app delegate's `didFinishLaunchingWithOptions` to initialize the Fazpass SDK. Ensure you replace placeholder values with your actual public key asset name and FCM App ID. ```swift func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { // Initialize fazpass Fazpass.shared.`init`( publicAssetName: "YOUR_PUBLIC_KEY_ASSET_NAME", application: application, fcmAppId: "YOUR_FCM_APP_ID" ) return true } ``` -------------------------------- ### Initialize Fazpass SDK Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Android.V2.md Initialize the Fazpass SDK with your public key asset name. This must be called before generating meta information. ```kotlin // get fazpass instance val fazpass = FazpassFactory.getInstance() fazpass.init(this, "YOUR_PUBLIC_KEY_ASSET_NAME") ``` -------------------------------- ### FazpassPlugin Initialization Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Flutter.md This snippet shows the registration of the FazpassPlugin and the initialization of the Fazpass SDK with necessary parameters. ```APIDOC ## FazpassPlugin.register ### Description Registers the FazpassPlugin with the Flutter registrar and sets up the method and event channels. It also initializes the Fazpass SDK with the provided public asset name, application instance, and FCM App ID. ### Method Signature `public static func register(with registrar: FlutterPluginRegistrar)` ### Parameters - `registrar` (FlutterPluginRegistrar) - The registrar for the plugin. ### Initialization Details - `publicAssetName`: "new-public-key.pub" - `application`: `UIApplication.shared` - `fcmAppId`: "fcm-app-id" ``` -------------------------------- ### Get Cross Device Data (Background) Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Flutter.md Call this method to retrieve cross-device notification data when the application is in the background. ```dart CrossDeviceData data = await Fazpass.instance.getCrossDeviceDataFromNotification(); ``` -------------------------------- ### Retrieve Background Notification Data Source: https://github.com/fazpass/seamless-documentation/blob/main/README.iOS.md Call `getCrossDeviceDataFromNotification()` in your app delegate's `didReceiveRemoteNotification` method to get data when the app is in the background. ```swift func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : any]) async -> UIBackgroundFetchResult { let data = Fazpass.shared.getCrossDeviceDataFromNotification(userInfo: userInfo) return UIBackgroundFetchResult.newData } ``` -------------------------------- ### Add Jitpack Repo (Plugin Syntax) Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Android.V2.md Configure the Jitpack repository in your settings.gradle file when using plugin syntax. ```gradle pluginManagement { repositories { // Another repo... } } dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { // Another repo... maven { url 'https://jitpack.io' credentials { username fazpassAuthToken } } } } ``` -------------------------------- ### Validate Endpoint Request Body Source: https://github.com/fazpass/seamless-documentation/blob/main/README.md Validate a user and device to get a security score and confidence level using this JSON payload. ```JSON "fazpass_id":"fazpass_id", "meta":"encrypted", "merchant_app_id":"com.tokopedia.tkpd", "challenge":"id" ``` -------------------------------- ### getSettings Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Flutter.md Retrieves the settings for a given account index. Returns null if settings are not found. ```APIDOC ## getSettings ### Description Retrieves the settings for a given account index. Returns null if settings are not found. ### Method Future ### Parameters #### Path Parameters - **accountIndex** (int) - Required - The index of the account for which to retrieve settings. ### Response #### Success Response - **FazpassSettings?** - The retrieved settings object, or null if not found. #### Errors None explicitly documented for this method. ``` -------------------------------- ### Retrieve Foreground Notification Data Source: https://github.com/fazpass/seamless-documentation/blob/main/README.iOS.md Get the stream instance using `getCrossDeviceDataStreamInstance()`, then listen for incoming notifications. Call `close()` to stop listening. ```swift // get the stream instance let crossDeviceStream = Fazpass.shared.getCrossDeviceDataStreamInstance() // start listening to the stream crossDeviceStream.listen { data in // called everytime there is an incoming cross device notification print(data) } // stop listening to the stream crossDeviceStream.close() ``` -------------------------------- ### getSettings Method Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Flutter.md Handles the 'getSettings' method call to retrieve settings for a specific account index. ```APIDOC ## FazpassPlugin.handle(call:result:) - getSettings ### Description This method handles the `getSettings` call from Flutter. It takes an `accountIndex` as an argument and retrieves the settings associated with that account using `Fazpass.shared.getSettings`. ### Method Signature `public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult)` ### Method `getSettings` ### Parameters #### Method Arguments - `accountIndex` (Int) - The index of the account for which to retrieve settings. ``` -------------------------------- ### Initialize Fazpass SDK Source: https://github.com/fazpass/seamless-documentation/blob/main/README.ReactNative.md Initialize the Fazpass SDK with your asset names and FCM App ID. This must be called before generating meta. ```javascript Fazpass.instance.init( androidAssetName: 'AndroidAssetName.pub', iosAssetName: 'iosAssetName', iosFcmAppId: 'iosFcmAppId' ); ``` -------------------------------- ### CrossDeviceModule Methods Source: https://github.com/fazpass/seamless-documentation/blob/main/README.ReactNative.md Methods for managing and listening to cross-device data streams. ```APIDOC ## `addListener` ### Description Adds a listener for cross-device data events. This method sets up a stream to receive data when events occur. ### Method `addListener(eventName: String)` ### Parameters - **eventName** (String) - The name of the event to listen for. This name will be used when emitting events to JavaScript. ## `removeListeners` ### Description Removes listeners for cross-device data events. If all listeners are removed, the stream is closed. ### Method `removeListeners(count: Int)` ### Parameters - **count** (Int) - The number of listeners to remove. ``` -------------------------------- ### Retrieve Cross Device Data When App is in Background Source: https://github.com/fazpass/seamless-documentation/blob/main/README.ReactNative.md Call this method to get cross-device data when the application is in the background and a notification is received. Ensure the Fazpass SDK is initialized. ```javascript let data = await Fazpass.instance.getCrossDeviceDataFromNotification(); ``` -------------------------------- ### Add Jitpack Repo (Buildscript) Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Android.V2.md Include the Jitpack repository in your root-level build.gradle file if using buildscript syntax. ```gradle buildscript { //... } allprojects { repositories { // Another repo... maven { url 'https://jitpack.io' credentials { username fazpassAuthToken } } } } ``` -------------------------------- ### Get App Signatures for Android Source: https://github.com/fazpass/seamless-documentation/blob/main/README.ReactNative.md Retrieve your application signatures by calling this method in your main screen's useEffect. Query logcat for 'APPSGN' to find the signature value. ```javascript Fazpass.instance.getAppSignatures().then((value) => print("APPSGN: $value")); ``` -------------------------------- ### Add Jitpack Auth Token Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Android.V2.md Configure your project's gradle.properties file with the Jitpack authentication token. ```properties # Project-wide Gradle settings. # ... # Add this at the bottom fazpassAuthToken={{AUTH_TOKEN}} ``` -------------------------------- ### Enroll User and Device Source: https://github.com/fazpass/seamless-documentation/blob/main/README.md Registers a user and their device as an authenticated user. ```APIDOC ## POST /v2/trusted-device/enroll ### Description Registers user and device as an authenticated user. ### Method POST ### Endpoint https://api.fazpass.com/v2/trusted-device/enroll ### Parameters #### Request Body - **pic_id** (string) - Required - User identifier. - **meta** (string) - Required - Encrypted metadata. - **merchant_app_id** (string) - Required - Identifier for the merchant's application. - **challenge** (string) - Required - Challenge identifier. ``` -------------------------------- ### Retrieve Cross Device Data from Notification (Background) Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Android.V2.md Call this method to get cross-device notification data when the application is in the background. Ensure the parameter is set with the intent used to launch the app. ```kotlin // IMPORTANT: Make sure you filled the parameter with the first activity's intent since app launch val data = fazpass.getCrossDeviceDataFromNotification(this@MainActivity.intent) ``` -------------------------------- ### getSettings Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Web.md Retrieves the saved preferences for data collection for a specific account. ```APIDOC ## getSettings ### Description Retrieves the saved preferences for data collection for a specific account. ### Method Signature `fazpass.getSettings(accountIndex: number)` ### Parameters #### Path Parameters - **accountIndex** (number) - Required - The index of the account to retrieve settings for. ### Request Example ```javascript let accountIndex = 0 let savedSettings = fazpass.getSettings(accountIndex) console.log(savedSettings) ``` ### Response #### Success Response (200) - **settings** (object) - The saved data collection preferences for the specified account. #### Response Example ```json { "location": true } ``` ``` -------------------------------- ### TrustedDeviceV2 Module Methods Source: https://github.com/fazpass/seamless-documentation/blob/main/README.ReactNative.md Methods for interacting with trusted device functionalities, such as generating metadata and managing application settings. ```APIDOC ## `generateMeta` ### Description Generates metadata for a given account index. Requires an active Android Activity. ### Method `generateMeta(accountIndex: Double, promise: Promise)` ### Parameters - **accountIndex** (Double) - The index of the account for which to generate metadata. - **promise** (Promise) - A Promise that resolves with the generated metadata or rejects with an error. ## `generateNewSecretKey` ### Description Generates a new secret key for the application. ### Method `generateNewSecretKey(promise: Promise)` ### Parameters - **promise** (Promise) - A Promise that resolves when the secret key is generated. ## `setSettings` ### Description Sets the Fazpass settings for a given account index. ### Method `setSettings(accountIndex: Double, settingsString: String?, promise: Promise)` ### Parameters - **accountIndex** (Double) - The index of the account to set settings for. - **settingsString** (String?) - A string representation of the settings to apply. Can be null. - **promise** (Promise) - A Promise that resolves when settings are applied. ## `getSettings` ### Description Retrieves the Fazpass settings for a given account index. ### Method `getSettings(accountIndex: Double, promise: Promise)` ### Parameters - **accountIndex** (Double) - The index of the account to retrieve settings for. - **promise** (Promise) - A Promise that resolves with the settings string or null if not found. ## `getCrossDeviceDataFromNotification` ### Description Retrieves cross-device data from the current activity's intent. Requires an active Android Activity. ### Method `getCrossDeviceDataFromNotification(promise: Promise)` ### Parameters - **promise** (Promise) - A Promise that resolves with the cross-device data map or null. ## `getAppSignatures` ### Description Retrieves the application signatures. Requires an active Android Activity. ### Method `getAppSignatures(promise: Promise)` ### Parameters - **promise** (Promise) - A Promise that resolves with an array of application signatures. ``` -------------------------------- ### setSettings Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Flutter.md Sets the settings for a given account index. This is an asynchronous operation. ```APIDOC ## setSettings ### Description Sets the settings for a given account index. This is an asynchronous operation. ### Method Future ### Parameters #### Path Parameters - **accountIndex** (int) - Required - The index of the account for which to set settings. - **settings** (FazpassSettings?) - Optional - The settings object to apply. Can be null. ### Response #### Success Response - void #### Errors None explicitly documented for this method. ``` -------------------------------- ### CrossDeviceDataStream Class for React Native Source: https://github.com/fazpass/seamless-documentation/blob/main/README.ReactNative.md Manages listening for incoming cross-device requests via native events. Instantiate this class with a native module and use `listen` to start receiving data, calling `close` to stop. ```typescript import { NativeEventEmitter, type EmitterSubscription } from 'react-native'; import CrossDeviceData from './cross-device-data'; /** * An instance acquired from {@link Fazpass.getCrossDeviceDataStreamInstance()} to start listening for * incoming cross device request notification. * * call `listen` method to start listening, and call `close` to stop. */ export default class CrossDeviceDataStream { private static eventType = 'com.fazpass.trusted-device-cd'; #emitter: NativeEventEmitter; #listener: EmitterSubscription | undefined; constructor(module: any) { this.#emitter = new NativeEventEmitter(module); } listen(callback: (request: CrossDeviceData) => void) { if (this.#listener !== undefined) { this.close(); } this.#listener = this.#emitter.addListener(CrossDeviceDataStream.eventType, (event) => { const data = new CrossDeviceData(event); callback(data); }); } close() { this.#listener?.remove(); this.#listener = undefined; } } ``` -------------------------------- ### Set and Manage Account Settings for Fazpass Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Web.md Use `setSettings()` to configure data collection preferences for specific accounts, identified by an index. Retrieve settings with `getSettings()` and delete them by calling `setSettings()` with only the account index. ```javascript // index of an account let accountIndex = 0 // create preferences let settings = { location: true } // save preferences fazpass.setSettings(accountIndex, settings) // apply saved preferences by using the same account index fazpass.generateMeta(accountIndex) .then((meta) => { console.log(meta) }) // get saved preferences let savedSettings = fazpass.getSettings(accountIndex) // delete saved preferences fazpass.setSettings(accountIndex) ``` -------------------------------- ### Generate Meta with Local Authentication Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Flutter.md Call `generateMeta()` to launch local authentication (biometric/password) and generate meta upon success. Catches `FazpassException` for various error scenarios. ```dart String meta = ''; try { meta = await Fazpass.instance.generateMeta(); } on FazpassException catch (e) { switch (e) { case BiometricNoneEnrolledError(): // TODO break; case BiometricAuthFailedError(): // TODO break; case BiometricUnavailableError(): // TODO break; case BiometricUnsupportedError(): // TODO break; case EncryptionException(): // TODO break; case PublicKeyNotExistException(): // TODO break; case UninitializedException(): // TODO break; case BiometricSecurityUpdateRequiredError(): // TODO break; } } ``` -------------------------------- ### Set and Manage Data Collection Preferences Source: https://github.com/fazpass/seamless-documentation/blob/main/README.ReactNative.md Use `setSettings` to configure data collection preferences for a specific account index. Pass `null` to delete saved preferences. The `generateMeta` method uses the account index to retrieve these settings. ```javascript let accountIndex = 0; let builder = new FazpassSettingsBuilder() .enableSelectedSensitiveData([SensitiveData.location]) .setBiometricLevelToHigh(); let settings = FazpassSettings.fromBuilder(builder) await Fazpass.instance.setSettings(accountIndex, settings); let meta = await Fazpass.instance.generateMeta(accountIndex); await Fazpass.instance.setSettings(accountIndex, null); ``` -------------------------------- ### Generate Meta with Local Authentication Source: https://github.com/fazpass/seamless-documentation/blob/main/README.ReactNative.md Call `generateMeta()` to initiate local authentication (biometric or password) and generate meta upon success. Catches `BiometricAuthFailedError` on failure. ```javascript try { let meta = await Fazpass.instance.generateMeta(); } catch (e) { // on error... } ``` -------------------------------- ### getSettings Source: https://github.com/fazpass/seamless-documentation/blob/main/README.ReactNative.md Retrieves the data collection rules previously set using the `setSettings` method. It returns the stored `FazpassSettings` object for a given `accountIndex`, or null if no settings are found for that index. ```APIDOC ## getSettings(accountIndex: number) ### Description Retrieves the rules that has been set in `setSettings()` method. Retrieves a stored `FazpassSettings` object based on the `accountIndex` parameter. Returns null if there is no stored settings for this `accountIndex`. ### Method `getSettings` ### Parameters #### Path Parameters - `accountIndex` (number) - Required - The index of the account for which to retrieve settings. ### Returns - `Promise`: A promise that resolves to the stored `FazpassSettings` object, or undefined if no settings are found. ``` -------------------------------- ### Implement FazpassPackage Class Source: https://github.com/fazpass/seamless-documentation/blob/main/README.ReactNative.md Create the FazpassPackage class to initialize the Fazpass SDK and provide necessary modules to your React Native application. This class implements the ReactPackage interface. ```kotlin class FazpassPackage: ReactPackage { private val fazpass = FazpassFactory.getInstance() override fun createNativeModules(context: ReactApplicationContext): MutableList { fazpass.init(context.applicationContext, YOUR-PUBLIC-KEY.pub) return listOf(FazpassModule(context, fazpass), CrossDeviceModule(context, fazpass)).toMutableList() } override fun createViewManagers(p0: ReactApplicationContext): MutableList>> = mutableListOf() } ``` -------------------------------- ### setSettings Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Web.md Sets preferences for data collection for a specific account. ```APIDOC ## setSettings ### Description Sets preferences for data collection for a specific account. This allows for different settings per account. ### Method Signature `fazpass.setSettings(accountIndex: number, settings: object)` ### Parameters #### Path Parameters - **accountIndex** (number) - Required - The index of the account to set preferences for. - **settings** (object) - Required - An object containing the data collection preferences. Example: `{ location: true }`. ### Request Example ```javascript let accountIndex = 0 let settings = { location: true } fazpass.setSettings(accountIndex, settings) ``` ### Response This method does not return a value upon success. ``` -------------------------------- ### Implement FazpassPlugin for Flutter Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Flutter.md Create the FazpassPlugin class to handle method calls and event streams for the Fazpass SDK. Ensure the SDK is initialized with your public key. ```kotlin import androidx.fragment.app.FragmentActivity import io.flutter.embedding.engine.plugins.FlutterPlugin import io.flutter.plugin.common.EventChannel import io.flutter.plugin.common.MethodChannel import com.fazpass.FazpassFactory import com.fazpass.FazpassMethodCallHandler import com.fazpass.FazpassCDStreamHandler class FazpassPlugin( private val activity: FragmentActivity ): FlutterPlugin { private val fazpass = FazpassFactory.getInstance() private val callHandler = FazpassMethodCallHandler(activity, fazpass) private val cdStreamHandler = FazpassCDStreamHandler(activity, fazpass) private lateinit var channel: MethodChannel private lateinit var cdChannel: EventChannel companion object { private const val CHANNEL = "com.fazpass.trusted-device" private const val CD_CHANNEL = "com.fazpass.trusted-device-cd" } override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) { channel = MethodChannel(binding.binaryMessenger, CHANNEL) channel.setMethodCallHandler(callHandler) cdChannel = EventChannel(binding.binaryMessenger, CD_CHANNEL) cdChannel.setStreamHandler(cdStreamHandler) fazpass.init(activity, YOUR-PUBLIC-KEY.pub) } override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) { channel.setMethodCallHandler(null) cdStreamHandler.onCancel(null) cdChannel.setStreamHandler(null) } } ``` -------------------------------- ### Load Fazpass SDK Script Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Web.md Include the Fazpass SDK script in your HTML to enable its functionality. The `onload` event handler can be used to access the Fazpass instance after the script has loaded. ```html ``` -------------------------------- ### Generate Meta with Biometric Authentication Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Android.V2.md Generate meta information by calling the `generateMeta` method. This method can optionally trigger biometric authentication. Ensure you use `FragmentActivity` or `AppCompatActivity` as the context. Handle various exceptions that may occur during the process. ```kotlin import androidx.fragment.app.FragmentActivity // OR import androidx.appcompat.app.AppCompatActivity class Activity : FragmentActivity() { // OR class Activity : AppCompatActivity() { // your activity fields & methods... fun generateMeta() { fazpass.generateMeta( this@Activity, accountIndex = -1, biometricAuth = false, // set to true if you want to popup biometric biometricMessage = "Biometric required" // customize your popup biometric message here ) } } ``` ```kotlin ) { meta, exception -> when (exception) { is BiometricAuthError -> TODO() is BiometricUnavailableError -> TODO() is BiometricNoneEnrolledError -> TODO() is BiometricSecurityUpdateRequiredError -> TODO() is BiometricUnsupportedError -> TODO() is EncryptionException -> TODO() is PublicKeyNotExistException -> TODO() is UninitializedException -> TODO() null -> { print(meta) } } } ``` -------------------------------- ### generateMeta Method Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Flutter.md Handles the 'generateMeta' method call to generate meta information for a given account index. It includes error handling for various Fazpass-specific errors. ```APIDOC ## FazpassPlugin.handle(call:result:) - generateMeta ### Description This method handles the `generateMeta` call from Flutter. It takes an `accountIndex` as an argument and attempts to generate meta information using `Fazpass.shared.generateMeta`. It returns the generated meta data on success or a `FlutterError` for various failure conditions. ### Method Signature `public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult)` ### Method `generateMeta` ### Parameters #### Method Arguments - `accountIndex` (Int) - The index of the account for which to generate meta. ### Response - Success: Returns the generated meta data. - Error: Returns a `FlutterError` with a specific code and message for issues like: - `fazpassE-biometricNoneEnrolled`: No biometry or device passcode enrolled. - `fazpassE-biometricAuthFailed`: Biometry authentication failed. - `fazpassE-biometricUnavailable`: Biometry is not available on the device. - `fazpassE-biometricUnsupported`: Biometry UI display is forbidden. - `fazpassE-encryptionError`: Encryption failed due to an incorrect public key. - `fazpassE-publicKeyNotExist`: The specified public key asset does not exist. - `fazpassE-uninitialized`: Fazpass SDK has not been initialized. ``` -------------------------------- ### Set and Manage Fazpass Settings Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Flutter.md Configure data collection preferences for a specific account, generate meta with these settings, or clear saved preferences. Use account index 0 for single-account applications. ```dart int accountIndex = 0; FazpassSettings settings = FazpassSettingsBuilder() .enableSelectedSensitiveData([SensitiveData.location]) .setBiometricLevelToHigh() .build(); await Fazpass.instance.setSettings(accountIndex, settings); String meta = await Fazpass.instance.generateMeta(accountIndex: accountIndex); await Fazpass.instance.setSettings(accountIndex, null); ``` -------------------------------- ### Generate Meta Information with Fazpass Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Web.md Call `generateMeta()` to generate meta information. Handles synchronous and asynchronous operations, including specific error types like `UninitializedError`, `PublicKeyNotExistError`, and `EncryptionError`. ```javascript fazpass.generateMeta() .then((meta) => { console.log(meta) }) .catch((err) => { if (err instanceof fazpass.UninitializedError) { console.error("UninitializedError: "+err.message) } if (err instanceof fazpass.PublicKeyNotExistError) { console.error("PublicKeyNotExistError: "+err.message) } if (err instanceof fazpass.EncryptionError) { console.error("EncryptionError: "+err.message) } }) ``` ```javascript try { let meta = await fazpass.generateMeta() console.log(meta) } catch (err) { // handle on error... } ``` -------------------------------- ### Set Fazpass Preferences for Data Collection Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Android.V2.md Use `setSettings()` to configure preferences for data collection per account. Preferences include enabling specific sensitive data and setting biometric authentication levels. Call `generateMeta()` to apply these settings. Pass `null` to `setSettings()` to delete preferences. ```kotlin val accountIndex = 0 val settings = FazpassSettings.Builder() .enableSelectedSensitiveData(SensitiveData.location) .setBiometricLevelToHigh() .build() fazpass.setSettings(accountIndex, settings) val meta = fazpass.generateMeta(this, accountIndex) { meta, exception -> print(meta) } fazpass.setSettings(accountIndex, null) ``` -------------------------------- ### Set Data Collection Preferences Source: https://github.com/fazpass/seamless-documentation/blob/main/README.iOS.md Use this snippet to configure specific settings for data collection for a given account index. This includes enabling sensitive data like location and setting the biometric authentication level. Preferences are applied when calling `generateMeta` and can be cleared by setting settings to nil. ```swift let accountIndex = 0 let settings: FazpassSettings = FazpassSettingsBuilder() .enableSelectedSensitiveData(sensitiveData: SensitiveData.location) .setBiometricLevelToHigh() .build() Fazpass.shared.setSettings(accountIndex, settings) Fazpass.shared.generateMeta(accountIndex: accountIndex) { meta, error in print(meta) } Fazpass.shared.setSettings(accountIndex, nil) ``` -------------------------------- ### App Theme Inheritance for AppCompat Compatibility Source: https://github.com/fazpass/seamless-documentation/blob/main/README.Android.V2.md Ensure your app's theme inherits from an AppCompat theme to prevent conflicts with local authentication dialogs. This is crucial for compatibility on devices experiencing style-related crashes. ```xml