anonymous-user-id
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -5,7 +5,7 @@ 'use strict'; | ||
var blake3 = require('blake3'); | ||
var blakejs = require('blakejs'); | ||
var dateFns = require('date-fns'); | ||
var hash = function hash(input) { | ||
return blake3.hash(input).toString('hex'); | ||
return blakejs.blake2sHex(input); | ||
}; | ||
@@ -12,0 +12,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("blake3"),r=require("date-fns"),t=function(r){return e.hash(r).toString("hex")},n=function(e,r){var n,u,o;return t(e+"|"+(null!=(n=r.domain)?n:"")+"|"+(null!=(u=r.ip)?u:"")+"|"+(null!=(o=r.userAgent)?o:""))};exports.getAnonymousUserId=n,exports.getAnonymousUserIdWithSecret=function(e,u){return n(t(e+"/"+r.formatISO(new Date,{representation:"date"})),u)}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("blakejs"),r=require("date-fns"),t=function(r){return e.blake2sHex(r)},n=function(e,r){var n,u,o;return t(e+"|"+(null!=(n=r.domain)?n:"")+"|"+(null!=(u=r.ip)?u:"")+"|"+(null!=(o=r.userAgent)?o:""))};exports.getAnonymousUserId=n,exports.getAnonymousUserIdWithSecret=function(e,u){return n(t(e+"/"+r.formatISO(new Date,{representation:"date"})),u)}; | ||
//# sourceMappingURL=anonymous-user-id.cjs.production.min.js.map |
@@ -1,6 +0,6 @@ | ||
import { hash as hash$1 } from 'blake3'; | ||
import { blake2sHex } from 'blakejs'; | ||
import { formatISO } from 'date-fns'; | ||
var hash = function hash(input) { | ||
return hash$1(input).toString('hex'); | ||
return blake2sHex(input); | ||
}; | ||
@@ -7,0 +7,0 @@ /** |
{ | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"license": "MIT", | ||
@@ -41,7 +41,7 @@ "main": "dist/index.js", | ||
"path": "dist/anonymous-user-id.cjs.production.min.js", | ||
"limit": "10 KB" | ||
"limit": "30 KB" | ||
}, | ||
{ | ||
"path": "dist/anonymous-user-id.esm.js", | ||
"limit": "10 KB" | ||
"limit": "30 KB" | ||
} | ||
@@ -59,3 +59,3 @@ ], | ||
"dependencies": { | ||
"blake3": "^2.1.4", | ||
"blakejs": "^1.1.0", | ||
"date-fns": "^2.21.1" | ||
@@ -62,0 +62,0 @@ }, |
# anonymous-user-id | ||
![npm](https://img.shields.io/npm/v/anonymous-user-id) | ||
![node-current](https://img.shields.io/node/v/anonymous-user-id) | ||
[![npm](https://img.shields.io/npm/v/anonymous-user-id)](https://www.npmjs.com/package/anonymous-user-id) | ||
[![node-current](https://img.shields.io/node/v/anonymous-user-id)](package.json) | ||
[![CI](https://github.com/omegavesko/anonymous-user-id/actions/workflows/main.yml/badge.svg)](https://github.com/omegavesko/anonymous-user-id/actions/workflows/main.yml) | ||
![GitHub](https://img.shields.io/github/license/omegavesko/anonymous-user-id) | ||
[![GitHub](https://img.shields.io/github/license/omegavesko/anonymous-user-id)](LICENSE) | ||
`anonymous-user-id` is a JavaScript library that allows you to anonymously identify unique users on your website without requiring them to store (and consent to) a tracking cookie. Instead, we generate a unique ID for each user based on information we can pull out of a regular HTTP request, mainly the source IP address and `User-Agent` header. | ||
`anonymous-user-id` is a JavaScript library that allows you to anonymously identify unique users on your website without requiring them to store (and consent to) a tracking cookie. Instead, we generate a unique ID for each user based on information that can be pulled out of a regular HTTP request, mainly the source IP address and `User-Agent` header. | ||
The method we use to do this is heavily inspired by [Plausible Analytics](https://plausible.io/data-policy#how-we-count-unique-users-without-cookies), with [BLAKE3](https://github.com/BLAKE3-team/BLAKE3) as the hash function. | ||
The method we use to do this is heavily inspired by [Plausible Analytics](https://plausible.io/data-policy#how-we-count-unique-users-without-cookies), with [BLAKE2s](https://tools.ietf.org/html/rfc7693) as the hash function. | ||
@@ -40,8 +40,11 @@ ## Supported Algorithms | ||
For each algorithm we support, we export a function you can use to generate an ID with it. | ||
For each algorithm this package supports, it exports a function you can use to generate an ID with it. | ||
- `getAnonymousUserId(salt: string, request: RequestDetails)` - implements `hash(salt + domain + ip + user_agent)` | ||
- `getAnonymousUserId(salt: string, request: RequestDetails)` | ||
- `getAnonymousUserIdWithSecret(secret: string, request: RequestDetails)` - implements `hash(hash(secret + date) + domain + ip + user_agent)` | ||
- implements `hash(salt + domain + ip + user_agent)` | ||
- `getAnonymousUserIdWithSecret(secret: string, request: RequestDetails)` | ||
- implements `hash(hash(secret + date) + domain + ip + user_agent)` | ||
### Example | ||
@@ -48,0 +51,0 @@ |
@@ -1,2 +0,2 @@ | ||
import * as blake3 from 'blake3'; | ||
import { blake2sHex } from 'blakejs'; | ||
import { formatISO } from 'date-fns'; | ||
@@ -10,4 +10,3 @@ | ||
const hash = (input: blake3.HashInput): string => | ||
blake3.hash(input).toString('hex'); | ||
const hash = (input: string): string => blake2sHex(input); | ||
@@ -14,0 +13,0 @@ /** |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
81
20553
161
+ Addedblakejs@^1.1.0
+ Addedblakejs@1.2.1(transitive)
- Removedblake3@^2.1.4
- Removedblake3@2.1.7(transitive)