initFpjs static method

Future<void> initFpjs(
  1. MethodCall call
)

Initializes the native FingerprintJS Pro client Throws a FingerprintProError if initialisation fails

Implementation

static Future<void> initFpjs(MethodCall call) async {
  final options = FingerprintJSOptions(
    apiKey: call.arguments['apiToken'],
    integrationInfo: [
      "fingerprint-pro-flutter/${call.arguments['pluginVersion']}/web"
    ],
  );
  if (call.arguments['region'] != null) {
    options.region = call.arguments['region'];
  }
  if (call.arguments['endpoint'] != null) {
    options.endpoint = [
      call.arguments['endpoint'],
      ...(call.arguments['endpointFallbacks'] ?? [])
    ];
  }
  if (call.arguments['scriptUrlPattern'] != null) {
    options.scriptUrlPattern = [
      call.arguments['scriptUrlPattern'],
      ...(call.arguments['scriptUrlPatternFallbacks'] ?? [])
    ];
  }
  try {
    _fpPromise = promiseToFuture(FingerprintJS.load(options));
    _isExtendedResult = call.arguments['extendedResponseFormat'];
    _isInitialized = true;
  } catch (e) {
    if (e is WebException) {
      throw unwrapWebError(e);
    } else {
      throw UnknownError(e.toString());
    }
  }
}