You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A lightweight JavaScript/TypeScript package for generating hashed fingerprints based on device data. Includes options for customizable device information, IP address integration, and cookie management.
15
+
A lightweight JavaScript/TypeScript package that generates unique hashed fingerprints for devices in both browser and server environments. The library allows customization of what data is included in the fingerprint, with options for saving the hash in cookies, passing headers for server-side use, and providing the user's IP directly.
Generate a hashed fingerprint with all options enabled (default behavior):
44
+
By default, all options are enabled. The library generates a fingerprint hash using all available device data and automatically fetches the user's IP address.
res.status(500).send({ error:'Failed to generate fingerprint' });
156
+
}
157
+
});
158
+
```
159
+
143
160
## TypeScript Support
144
161
The package includes TypeScript type definitions for all options and methods. Here’s a quick example:
145
162
@@ -172,8 +189,74 @@ generateHashedFingerprint()
172
189
});
173
190
```
174
191
192
+
## Options
193
+
194
+
-`saveToCookie`
195
+
- Type: `boolean`
196
+
- Default: `true`
197
+
- Description: Save the generated hash in a cookie.
198
+
199
+
-`cookieExpiryDays`
200
+
- Type: `number`
201
+
- Default: `7`
202
+
- Description: Number of days before the cookie expires.
203
+
204
+
-`useUserAgent`
205
+
- Type: `boolean`
206
+
- Default: `true`
207
+
- Description: Include the browser's user agent string in the fingerprint.
208
+
209
+
-`useLanguage`
210
+
- Type: `boolean`
211
+
- Default: `true`
212
+
- Description: Include the browser's language setting in the fingerprint.
213
+
214
+
-`useScreenResolution`
215
+
- Type: `boolean`
216
+
- Default: `true`
217
+
- Description: Include the screen's resolution and color depth in the fingerprint.
218
+
219
+
-`usePlatform`
220
+
- Type: `boolean`
221
+
- Default: `true`
222
+
- Description: Include platform information (e.g., "Win32", "MacIntel").
223
+
224
+
-`useConcurrency`
225
+
- Type: `boolean`
226
+
- Default: `true`
227
+
- Description: Include the number of logical processors.
228
+
229
+
-`useIP`
230
+
- Type: `boolean`
231
+
- Default: `true`
232
+
- Description: Fetch and include the user's IP address.
233
+
234
+
-`userIP`
235
+
- Type: `string`
236
+
- Default: `null`
237
+
- Description: Provide an IP address manually (overrides API fetch).
238
+
239
+
-`headers`
240
+
- Type: `Record<string, string[]>`
241
+
- Default: `{}`
242
+
- Description: HTTP headers for server-side fingerprinting.
243
+
244
+
-`environment`
245
+
- Type: `'browser' | 'server'`
246
+
- Default: `Auto-detected`
247
+
- Description: Specify the environment explicitly (e.g., `'browser'` or `'server'`).
248
+
175
249
## License
176
250
This package is licensed under the [MIT License](https://opensource.org/license/mit/).
177
251
178
252
## Contributing
179
-
Contributions are welcome! Feel free to submit issues or pull requests.
253
+
- Fork the repository.
254
+
- Create a new branch: git checkout -b feature-name.
255
+
- Commit your changes: git commit -m 'Add feature'.
256
+
- Push to the branch: git push origin feature-name.
257
+
- Submit a pull request.
258
+
259
+
## Support
260
+
If you encounter any issues or have questions, feel free to open an issue on [**Repo Issues**](https://github.com/moumen-soliman/hashed-device-fingerprint-js/issues).
0 commit comments