mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
Add definitions for fingerprintjs
This commit is contained in:
@@ -82,6 +82,7 @@ All definitions files include a header with the author and editors, so at some p
|
||||
* [File API: Directories and System](http://www.w3.org/TR/file-system-api/) (by [Kon](http://phyzkit.net/))
|
||||
* [File API: Writer](http://www.w3.org/TR/file-writer-api/) (by [Kon](http://phyzkit.net/))
|
||||
* [Finch](https://github.com/stoodder/finchjs) (by [David Sichau](https://github.com/DavidSichau/))
|
||||
* [fingerprintjs](https://github.com/Valve/fingerprintjs) (by [Shunsuke Ohtani](https://github.com/zaneli))
|
||||
* [Finite State Machine](https://github.com/jakesgordon/javascript-state-machine) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [Firebase](https://www.firebase.com/docs/javascript/firebase) (by [Vincent Bortone](https://github.com/vbortone))
|
||||
* [Firefox](https://developer.mozilla.org/en-US/docs/Web/API) (by [vvakame](https://github.com/vvakame))
|
||||
|
||||
53
fingerprintjs/fingerprint-tests.ts
Normal file
53
fingerprintjs/fingerprint-tests.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
/// <reference path="fingerprint.d.ts"/>
|
||||
|
||||
function test_no_option() {
|
||||
var fingerprint = new Fingerprint().get();
|
||||
}
|
||||
|
||||
function test_set_canvas_enabled() {
|
||||
var fingerprint = new Fingerprint({canvas: true}).get();
|
||||
}
|
||||
|
||||
function test_set_screen_resolution_enabled() {
|
||||
var fingerprint = new Fingerprint({screen_resolution: true}).get();
|
||||
}
|
||||
|
||||
function test_set_ie_activex_enabled() {
|
||||
var fingerprint = new Fingerprint({ie_activex: true}).get();
|
||||
}
|
||||
|
||||
function test_set_hasher_in_option() {
|
||||
var my_hasher = (value: string, seed: number) => { return value.length % seed; };
|
||||
var fingerprint = new Fingerprint({hasher: my_hasher}).get();
|
||||
|
||||
var fingerprint = new Fingerprint({hasher: (value, seed) => { return value.length % seed; }}).get();
|
||||
}
|
||||
|
||||
function test_set_hasher_in_constructor() {
|
||||
var my_hasher = (value: string, seed: number) => { return value.length % seed; };
|
||||
var fingerprint = new Fingerprint(my_hasher).get();
|
||||
|
||||
var fingerprint = new Fingerprint((value, seed) => { return value.length % seed; }).get();
|
||||
}
|
||||
|
||||
function test_call_methods() {
|
||||
var f = new Fingerprint();
|
||||
f.murmurhash3_32_gc("abcde", 123);
|
||||
if (f.hasLocalStorage()) {
|
||||
alert("LocalStorage");
|
||||
}
|
||||
if (f.hasSessionStorage()) {
|
||||
alert("SessionStorage");
|
||||
}
|
||||
if (f.isCanvasSupported()) {
|
||||
alert("CanvasSupported");
|
||||
}
|
||||
if (f.isIE()) {
|
||||
alert("IE");
|
||||
}
|
||||
f.getPluginsString();
|
||||
f.getRegularPluginsString();
|
||||
f.getIEPluginsString();
|
||||
f.getScreenResolution();
|
||||
f.getCanvasFingerprint();
|
||||
}
|
||||
99
fingerprintjs/fingerprint.d.ts
vendored
Normal file
99
fingerprintjs/fingerprint.d.ts
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
// Type definitions for fingerprintjs 0.5.4
|
||||
// Project: https://github.com/Valve/fingerprintjs
|
||||
// Definitions by: Shunsuke Ohtani <https://github.com/zaneli>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module FingerprintJs {
|
||||
|
||||
interface FingerprintStatic {
|
||||
/**
|
||||
* Create Fingerprint object.
|
||||
*/
|
||||
new(hasher: (key: string, seed: number) => number): Fingerprint;
|
||||
new(option: FingerprintOption): Fingerprint;
|
||||
new(): Fingerprint;
|
||||
}
|
||||
|
||||
interface Fingerprint {
|
||||
/**
|
||||
* Generate fingerprint number.
|
||||
*/
|
||||
get(): number;
|
||||
|
||||
/**
|
||||
* Generate fingerprint number using Murmur hashing.
|
||||
* @param key ASCII only
|
||||
* @param seed Positive integer only
|
||||
*/
|
||||
murmurhash3_32_gc(key: string, seed: number): number;
|
||||
|
||||
/**
|
||||
* Check whether or not the browser has local storage.
|
||||
*/
|
||||
hasLocalStorage(): boolean;
|
||||
|
||||
/**
|
||||
* Check whether or not the browser has session storage.
|
||||
*/
|
||||
hasSessionStorage(): boolean;
|
||||
|
||||
/**
|
||||
* Check whether or not the browser supports canvas.
|
||||
*/
|
||||
isCanvasSupported(): boolean;
|
||||
|
||||
/**
|
||||
* Check whether or not the browser is IE.
|
||||
*/
|
||||
isIE(): boolean;
|
||||
|
||||
/**
|
||||
* Get plugins string.
|
||||
*/
|
||||
getPluginsString(): string;
|
||||
|
||||
/**
|
||||
* Get plugins string from navigator plugins.
|
||||
*/
|
||||
getRegularPluginsString(): string;
|
||||
|
||||
/**
|
||||
* Get plugins string from ActiveXObject.
|
||||
*/
|
||||
getIEPluginsString(): string;
|
||||
|
||||
/**
|
||||
* Get screen height and width.
|
||||
*/
|
||||
getScreenResolution(): number[];
|
||||
|
||||
/**
|
||||
* Get canvas data url string.
|
||||
*/
|
||||
getCanvasFingerprint(): string;
|
||||
}
|
||||
|
||||
interface FingerprintOption {
|
||||
/**
|
||||
* If you want to use canvas fingerprinting, set true.
|
||||
*/
|
||||
canvas?: boolean;
|
||||
|
||||
/**
|
||||
* If you want to use the screen resolution in calculating the fingerprint, set true.
|
||||
*/
|
||||
screen_resolution?: boolean;
|
||||
|
||||
/**
|
||||
* If you want to query the IE plugins info to further diversify the fingerprinting process, set true.
|
||||
*/
|
||||
ie_activex?: boolean;
|
||||
|
||||
/**
|
||||
* If you want to use custom hashing function, set function.
|
||||
*/
|
||||
hasher?: (key: string, seed: number) => number;
|
||||
}
|
||||
}
|
||||
|
||||
declare var Fingerprint: FingerprintJs.FingerprintStatic;
|
||||
Reference in New Issue
Block a user