All files / src global.ts

100% Statements 5/5
100% Branches 2/2
100% Functions 1/1
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47                        1x 1x 1x 1x 1x                                                            
import * as FingerprintJS from '@fingerprintjs/fingerprintjs-pro'
import { ICache } from './cache'
 
export type VisitorData<TExtended extends boolean = false> = TExtended extends false
  ? FingerprintJS.GetResult
  : FingerprintJS.ExtendedGetResult
 
export type FpjsSpaResponse<T> = T & {
  // Indicates whether the response was retrieved from cache.
  cacheHit: boolean
}
 
export enum CacheLocation {
  Memory = 'memory',
  LocalStorage = 'localstorage',
  SessionStorage = 'sessionstorage',
  NoCache = 'nocache',
}
 
export interface FpjsClientOptions {
  /**
   * Options for the FingerprintJS JS Agent load() method.
   */
  loadOptions: FingerprintJS.LoadOptions
 
  /**
   * Defines which built-in cache mechanism the client should use.
   */
  cacheLocation?: CacheLocation
 
  /**
   * Custom cache implementation. Takes precedence over the `cacheLocation` property.
   */
  cache?: ICache
 
  /**
   * Duration in seconds for which data is stored in cache. Cannot exceed 86_400 (24h) because caching data
   * for longer than 24 hours can negatively affect identification accuracy.
   */
  cacheTimeInSeconds?: number
 
  /**
   * Custom prefix for localStorage and sessionStorage cache keys. Will be ignored if `cache` is provided.
   */
  cachePrefix?: string
}