easy-fingerprint
Advanced tools
Comparing version 1.0.2 to 1.1.0
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.generateFingerprint = void 0; | ||
const utils_1 = require("./utils"); | ||
const generateFingerprint = () => __awaiter(void 0, void 0, void 0, function* () { | ||
const fp = yield (0, utils_1.canvasFingerPrint)(); | ||
return Object.assign(Object.assign(Object.assign({}, fp), (0, utils_1.getAgentInfo)()), { visitorId: fp.hash, ip: '' }); | ||
}); | ||
const getRealIpAddress_1 = require("./utils/getRealIpAddress"); | ||
const generateFingerprint = () => { | ||
return new Promise((resolve, reject) => { | ||
(0, utils_1.canvasFingerPrint)() | ||
.then((hash) => { | ||
(0, getRealIpAddress_1.getRealIpAddress)((ip) => resolve(Object.assign(Object.assign({}, (0, utils_1.getAgentInfo)()), { visitorId: hash, ip: ip.ipv4 ? ip.ipv4 : ip.ipv6 }))); | ||
}) | ||
.catch((err) => reject(err)); | ||
}); | ||
}; | ||
exports.generateFingerprint = generateFingerprint; |
@@ -15,1 +15,6 @@ export interface CanvasFingerPrint { | ||
} | ||
export type GetRealIpAddressCallback = (ip: IpAddresses) => void; | ||
export interface IpAddresses { | ||
ipv4: string; | ||
ipv6: string; | ||
} |
@@ -1,2 +0,1 @@ | ||
import { CanvasFingerPrint } from '../types'; | ||
export declare const canvasFingerPrint: () => Promise<CanvasFingerPrint>; | ||
export declare const canvasFingerPrint: () => Promise<string>; |
@@ -43,5 +43,5 @@ "use strict"; | ||
} | ||
resolve(result); | ||
resolve(result.hash); | ||
}); | ||
}; | ||
exports.canvasFingerPrint = canvasFingerPrint; |
{ | ||
"name": "easy-fingerprint", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -31,5 +31,25 @@ # easy-fingerPrint | ||
generateFingerprint().then((fingerprint) => { | ||
console.log('fingerprint', fingerprint); | ||
generateFingerprint().then((fp) => { | ||
console.log('fp', fp); | ||
}); | ||
``` | ||
### API | ||
##### generateFingerprint | ||
| Name | Type | Description | | ||
| -------------- | ------ | ------------------- | | ||
| visitorId | string | 唯一值 | | ||
| browserName | string | 浏览器名称 | | ||
| browserVersion | string | 浏览器版本 | | ||
| device | string | 设备 | | ||
| ip | string | IP地址(ipv4/ipv6) | | ||
| os | string | 系统 | | ||
| osVersion | string | 系统版本 | | ||
| userAgent | string | userAgent原文 | | ||
### Change Log | ||
- 1.1.0: 返回IP地址参数 | ||
- 1.0.0: Initial release |
11350
14
213
55