getVisitorData static method

Future<List<Object>> getVisitorData({
  1. Object? tags,
  2. String? linkedId,
  3. int? timeoutMs,
})

Returns the visitor data generated by the native Fingerprint Pro client Support tags Support linkedId Support timeoutMs Throws a FingerprintProError if identification request fails for any reason

Implementation

static Future<List<Object>> getVisitorData(
    {Object? tags, String? linkedId, int? timeoutMs}) async {
  if (!_isInitialized) {
    throw Exception(
        'You need to initialize the FPJS Client first by calling the "initFpjs" method');
  }
  try {
    FingerprintJSAgent fp = await (_fpPromise as Future<FingerprintJSAgent>);
    final getOptions = FingerprintJSGetOptions(
        linkedId: linkedId,
        tag: tags,
        timeout: timeoutMs,
        extendedResult: _isExtendedResult);
    final IdentificationResult result =
        await promiseToFuture(fp.get(getOptions));

    FingerprintJSProResponse typedResult;

    if (_isExtendedResult) {
      typedResult = FingerprintJSProExtendedResponse.fromJsObject(
          result as IdentificationExtendedResult);
    } else {
      typedResult = FingerprintJSProResponse.fromJsObject(result);
    }

    final serializedResult = typedResult.toJson();
    return [
      typedResult.requestId,
      typedResult.confidenceScore.score,
      serializedResult,
      typedResult.sealedResult ?? ''
    ];
  } catch (e) {
    if (e is WebException) {
      throw unwrapWebError(e);
    } else {
      throw UnknownError(e.toString());
    }
  }
}