@fingerprintjs/fingerprintjs-pro-react-native
Version:
Official React Native client for Fingerprint. Best identification solution for React Native.
132 lines • 6.03 kB
JavaScript
/**
FingerprintJS Pro React Native v3.14.0 - Copyright (c) FingerprintJS, Inc, 2026 (https://fingerprint.com)
Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
*/
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var FingerprintJsProAgent_exports = {};
__export(FingerprintJsProAgent_exports, {
FingerprintJsProAgent: () => FingerprintJsProAgent
});
module.exports = __toCommonJS(FingerprintJsProAgent_exports);
var import_react_native = require("react-native");
var import_errors = require("./errors");
var import_unwrapError = require("./unwrapError");
const packageVersion = "3.14.0";
class FingerprintJsProAgent {
constructor({
apiKey,
region,
endpointUrl,
fallbackEndpointUrls = [],
extendedResponseFormat = false,
requestOptions = {},
allowUseOfLocationData = false,
locationTimeoutMillisAndroid = 5e3
}) {
/**
* Initialises FingerprintJS Pro Agent with certain settings
*
* @param params
*/
this.requestOptions = {};
try {
import_react_native.NativeModules.RNFingerprintjsPro.configure(
apiKey,
region,
endpointUrl,
fallbackEndpointUrls,
extendedResponseFormat,
packageVersion,
allowUseOfLocationData,
locationTimeoutMillisAndroid
);
this.requestOptions = requestOptions;
} catch (e) {
console.error("RNFingerprintjsPro configure error: ", e);
}
}
/**
* Returns visitor identifier based on the request options {@link https://dev.fingerprint.com/docs/native-android-integration#get-the-visitor-identifier | more info in the documentation page}
*
* @param tags is a customer-provided value or an object that will be saved together with the analysis event and will be returned back to you in a webhook message or when you search for the visit in the server API. {@link https://dev.fingerprint.com/docs/js-agent#tag | more info in the documentation page}
* @param linkedId is a way of linking current analysis event with a custom identifier. This will allow you to filter visit information when using the Server API {@link https://dev.fingerprint.com/docs/js-agent#linkedid | more info in the documentation page}
* @param options is used to configure requests with different settings
*/
async getVisitorId(tags, linkedId, options) {
var _a;
try {
const timeout = (_a = options == null ? void 0 : options.timeout) != null ? _a : this.requestOptions.timeout;
if (timeout != null) {
return await import_react_native.NativeModules.RNFingerprintjsPro.getVisitorIdWithTimeout(tags, linkedId, timeout);
}
return await import_react_native.NativeModules.RNFingerprintjsPro.getVisitorId(tags, linkedId);
} catch (error) {
if (error instanceof Error) {
throw (0, import_unwrapError.unwrapError)(error);
} else {
throw new import_errors.UnknownError(String(error));
}
}
}
/**
* Returns visitor identification data based on the request options {@link https://dev.fingerprint.com/docs/native-android-integration#get-the-visitor-identifier | more info in the documentation page}
*
* Provide `extendedResponseFormat` option in the {@link constructor} to get response in the {@link https://dev.fingerprint.com/docs/native-android-integration#response-format | extended format}
*
* @param tags is a customer-provided value or an object that will be saved together with the analysis event and will be returned back to you in a webhook message or when you search for the visit in the server API. {@link https://dev.fingerprint.com/docs/js-agent#tag | more info in the documentation page}
* @param linkedId is a way of linking current analysis event with a custom identifier. This will allow you to filter visit information when using the Server API {@link https://dev.fingerprint.com/docs/js-agent#linkedid | more info in the documentation page}
* @param options is used to configure requests with different settings
*/
async getVisitorData(tags, linkedId, options) {
var _a;
try {
const timeout = (_a = options == null ? void 0 : options.timeout) != null ? _a : this.requestOptions.timeout;
let visitorData;
if (timeout != null) {
visitorData = await import_react_native.NativeModules.RNFingerprintjsPro.getVisitorDataWithTimeout(tags, linkedId, timeout);
} else {
visitorData = await import_react_native.NativeModules.RNFingerprintjsPro.getVisitorData(tags, linkedId);
}
const [requestId, confidenceScore, visitorDataJsonString, sealedResult] = visitorData;
const result = {
...JSON.parse(visitorDataJsonString),
requestId,
confidence: {
score: confidenceScore
}
};
if (sealedResult) {
result["sealedResult"] = sealedResult;
}
return result;
} catch (error) {
if (error instanceof Error) {
throw (0, import_unwrapError.unwrapError)(error);
} else {
throw new import_errors.UnknownError(String(error));
}
}
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
FingerprintJsProAgent
});
//# sourceMappingURL=FingerprintJsProAgent.js.map