@fingerprintjs/fingerprintjs-pro-react-native
Version:
Official React Native client for Fingerprint. Best identification solution for React Native.
101 lines • 2.77 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.
*/
import { UnknownError } from "./errors";
import { FpjsClient } from "@fingerprintjs/fingerprintjs-pro-spa";
import { unwrapError } from "./unwrapError";
const packageVersion = "3.14.0";
class FingerprintJsProAgent {
constructor({
apiKey,
region,
endpointUrl,
fallbackEndpointUrls = [],
extendedResponseFormat = false,
requestOptions = {},
scriptUrlPattern,
storageKey,
urlHashing,
remoteControlDetection,
cache,
cachePrefix,
cacheLocation,
cacheTimeInSeconds
}) {
this.requestOptions = {};
this.extendedResponseFormat = false;
const endpoints = [];
if (endpointUrl) {
endpoints.push(endpointUrl);
}
endpoints.push(...fallbackEndpointUrls);
this.client = new FpjsClient({
loadOptions: {
apiKey,
region,
endpoint: endpoints.length > 0 ? endpoints : void 0,
scriptUrlPattern,
storageKey,
urlHashing,
remoteControlDetection,
integrationInfo: [`fingerprint-pro-react-native/${packageVersion}/web`]
},
cache,
cachePrefix,
cacheLocation,
cacheTimeInSeconds
});
this.agentPromise = this.client.init();
this.requestOptions = requestOptions;
this.extendedResponseFormat = extendedResponseFormat;
}
/**
* @inheritDoc
* */
async getVisitorId(tags, linkedId, options) {
var _a;
try {
const timeout = (_a = options == null ? void 0 : options.timeout) != null ? _a : this.requestOptions.timeout;
const agent = await this.agentPromise;
const result = await agent.get({
extendedResult: this.extendedResponseFormat,
tag: tags,
linkedId,
timeout
});
return result.visitorId;
} catch (error) {
if (error instanceof Error) {
throw unwrapError(error);
}
throw new UnknownError(String(error));
}
}
/**
* @inheritDoc
* */
async getVisitorData(tags, linkedId, options) {
var _a;
try {
const timeout = (_a = options == null ? void 0 : options.timeout) != null ? _a : this.requestOptions.timeout;
const agent = await this.agentPromise;
return await agent.get({
tag: tags,
linkedId,
extendedResult: this.extendedResponseFormat,
timeout
});
} catch (error) {
if (error instanceof Error) {
throw unwrapError(error);
} else {
throw new UnknownError(String(error));
}
}
}
}
export {
FingerprintJsProAgent
};
//# sourceMappingURL=FingerprintJsProAgent.web.js.map