hw-fingerprint
Advanced tools
Comparing version 3.0.1 to 3.1.1
# Changelog | ||
## v3.1.1 | ||
- v3.1.0 was published with extraneous files, this release corrects it | ||
## v3.1.0 | ||
- Updates `systeminformation` to version 5.21.8 | ||
- Adds a `FINGERPRINTING_PARAMETERS` constant export that holds `Object.keys(FINGERPRINTING_INFO)` | ||
- Adds better type definitions with JSDoc | ||
- Updates README.md | ||
## v3.0.1 | ||
@@ -4,0 +15,0 @@ |
@@ -0,3 +1,4 @@ | ||
import { Buffer } from 'node:buffer' | ||
import { createHash } from 'node:crypto' | ||
import { EOL, endianness } from 'node:os' | ||
import { createHash } from 'node:crypto' | ||
import { | ||
@@ -15,3 +16,32 @@ system, | ||
/** | ||
* Available system parameters for fingerprint calculation. | ||
* @typedef {Object} FingerprintingInfo An object that holds all the system information | ||
* used for fingerprinting | ||
* | ||
* @property {string} EOL - OS-defined end-of-line (typically LF or CR+LF) | ||
* @property {string} endianness - CPU and/or OS-defined multibyte integer endianness | ||
* @property {string} manufacturer - Computer manufacturer | ||
* @property {string} model - CPU model | ||
* @property {string} serial - CPU serial | ||
* @property {string} uuid - CPU UUID | ||
* @property {string} vendor - Bios vendor | ||
* @property {string} biosVersion - Bios version | ||
* @property {string} releaseDate - Bios release date | ||
* @property {string} boardManufacturer Board manufacturer | ||
* @property {string} boardModel Board model | ||
* @property {string} boardSerial Board serial | ||
* @property {string} cpuManufacturer CPU manufacturer | ||
* @property {string} brand CPU brand | ||
* @property {string} speedMax CPU speed max | ||
* @property {number} cores CPU cores | ||
* @property {number} physicalCores CPU physical cores | ||
* @property {string} socket CPU socket type | ||
* @property {number} memTotal Total system memory | ||
* @property {string} platform OS type | ||
* @property {string} arch OS architecture | ||
* @property {string[]} hdds List of HDDs concatenated model and serial | ||
*/ | ||
/** | ||
* @constant FINGERPRINTING_INFO Available system parameters for fingerprint calculation | ||
* @type FingerprintingInfo | ||
*/ | ||
@@ -68,2 +98,9 @@ export const FINGERPRINTING_INFO = await (async function() { | ||
/** | ||
* @constant FINGERPRINTING_PARAMETERS A list of string that names available parameters | ||
* to be considered during fingerprinting | ||
* @type {string[]} | ||
*/ | ||
export const FINGERPRINTING_PARAMETERS = keys(FINGERPRINTING_INFO) | ||
/** | ||
* Calculates the fingerprint for given system parameters, ordered as 'FINGERPRINTING_INFO` properties | ||
@@ -82,11 +119,14 @@ * @param {string[]} parameters System parameters to use for fingerprinting calculation | ||
/** | ||
* Calculates the 512-bit fingerprint using this system's parameters. | ||
* Additional customisation of which parameters are accounted for are available through the `options` parameter. | ||
* @param {object} options An object that controls which system parameters should be used for fingerprint calculation | ||
* @param {string[]} options.only An inclusive property list; if provided, only properties listed here are used for calculation | ||
* @param {string[]} options.except An exclusive property list; if provided, all available properties not listed here are used for calculation | ||
* @returns {Buffer} The 512-bit fingerprint as a `Buffer` | ||
* Calculates the 512-bit fingerprint using this system's parameters. | ||
* Additional customisation of which parameters are accounted for are available through the `options` parameter. | ||
* @param {object} [options={}] An object that controls which system parameters should be used for | ||
* fingerprint calculation | ||
* @param {string[]} [options.only=FINGERPRINTING_PARAMETERS] An inclusive property list; if provided, | ||
* only properties listed here are used for calculation | ||
* @param {string[]} [options.except=[]] An exclusive property list; if provided, all available properties | ||
* not listed here are used for calculation | ||
* @returns {Buffer} The 512-bit fingerprint as a `Buffer` | ||
*/ | ||
export function getFingerprint({ only = keys(FINGERPRINTING_INFO), except = [] } = {}) { | ||
const parameters = keys(FINGERPRINTING_INFO) | ||
export function getFingerprint({ only = FINGERPRINTING_PARAMETERS, except = [] } = {}) { | ||
const parameters = FINGERPRINTING_PARAMETERS | ||
.filter(key => only.includes(key) && !except.includes(key)) | ||
@@ -102,4 +142,4 @@ const cacheKey = parameters.join('') | ||
* Gets the available system parameters to be used in fingerprinting calculation. | ||
* This parameters can be used in conjuction with the `getFingerprint()` function to customise fingerprint generation. | ||
* @returns An object containing all the available fingerprinting parameters | ||
* This parameters can be used in conjunction with the `getFingerprint()` function to customise fingerprint generation. | ||
* @returns {FingerprintingInfo} An object containing all the available fingerprinting parameters | ||
*/ | ||
@@ -106,0 +146,0 @@ export function getFingerprintingInfo() { |
{ | ||
"name": "hw-fingerprint", | ||
"version": "3.0.1", | ||
"version": "3.1.1", | ||
"license": "MIT", | ||
@@ -18,4 +18,4 @@ "description": "Hardware-based fingerprint for Node and Electron", | ||
"dependencies": { | ||
"systeminformation": "^5.9.9" | ||
"systeminformation": "^5.21.8" | ||
} | ||
} |
@@ -7,5 +7,8 @@ # hw-fingerprint | ||
This library provides a `getFingerprint()` function that produces a 512-bit signature based on the host machine's hardware information, suitable for use in Electron or Node client apps that require authentication against a server. This signature is immutable as long as the underlying system is not changed, even across resets. | ||
This library provides a `getFingerprint()` function that produces a 512-bit signature based on the host machine's | ||
hardware information, suitable for use in Electron or Node client apps that require authentication against a server. | ||
This signature is immutable as long as the underlying system is not changed, even across resets. | ||
It uses information provided by [Node's OS module](https://nodejs.org/api/os.html) and [systeminformation](https://github.com/sebhildebrandt/systeminformation) library and has no other dependencies. | ||
It uses information provided by [Node's OS module](https://nodejs.org/api/os.html) and [systeminformation](https://github.com/sebhildebrandt/systeminformation) library and has no other | ||
dependencies. | ||
@@ -26,3 +29,4 @@ | ||
The library exports a constant `FINGERPRINTING_INFO`. This is an object that contains the raw information available for fingerprinting. | ||
The library exports a constant `FINGERPRINTING_INFO`. This is an object that contains the raw information available | ||
for fingerprinting. | ||
@@ -32,3 +36,4 @@ | ||
`getFingerprint()` returns a [Node Buffer](https://nodejs.org/api/buffer.html) containing the 512-bit fingerprint. The returned buffer is internally cached, so the actual implementation gets called just once. | ||
`getFingerprint()` returns a [Node Buffer](https://nodejs.org/api/buffer.html) containing the 512-bit fingerprint. The returned buffer is internally | ||
cached, so the actual implementation gets called just once. | ||
@@ -54,14 +59,32 @@ ```js | ||
```js | ||
[ 'EOL', 'endianness', 'manufacturer', 'model', 'serial', 'uuid', 'vendor', 'biosVersion', 'releaseDate', 'boardManufacturer', 'boardModel', 'boardSerial', 'cpuManufacturer', 'brand', 'speedMax', 'cores', 'physicalCores', 'socket', 'memTotal', 'platform', 'arch', 'hdds' ] | ||
[ | ||
'EOL', 'endianness', 'manufacturer', 'model', | ||
'serial', 'uuid', 'vendor', 'biosVersion', | ||
'releaseDate', 'boardManufacturer', 'boardModel', 'boardSerial', | ||
'cpuManufacturer', 'brand', 'speedMax', 'cores', | ||
'physicalCores', 'socket', 'memTotal', 'platform', | ||
'arch', 'hdds' | ||
] | ||
``` | ||
Each combination of parameters will generate a different fingerprint. As long as the same set of parameters is always used, the fingerprint will always be the same. | ||
Nonetheless, fingerprints are always cached internally. | ||
This same list can be retrieved through the `FINGERPRINTING_PARAMETERS` constant export: | ||
```js | ||
import { FINGERPRINTING_PARAMETERS } from 'hw-fingerprint' | ||
``` | ||
Each combination of parameters will generate a different fingerprint. As long as the same set of parameters is always | ||
used, the fingerprint will always be the same, even if the order in which they are provided changes. | ||
Every fingerprint generated gets cached internally, so calling `getFingerprint()` repeatedly with the same parameters | ||
is very cheap. | ||
## Upgrade v2.x -> v3.x | ||
Back at v2.x, `getFingerprint()` was asynchronous, because the fingerprinting information depended on asynchronous functions. | ||
Back at v2.x, `getFingerprint()` was asynchronous, because the fingerprinting information depended on asynchronous | ||
functions. | ||
v3.x addresses this by raising the Node.js to a version that supports top-level `await`. This makes the `FINGERPRINTING_INFO` readily available in top-level and allows for synchronous fingerprinting. | ||
Despite this, the `getFingerprint()` function signature is backwards compatible and the `getFingerprintingInfo()` function is still available. | ||
v3.x addresses this by raising the Node.js to a version that supports top-level `await`. This makes the | ||
`FINGERPRINTING_INFO` readily available in top-level and allows for synchronous fingerprinting. Despite this, the | ||
`getFingerprint()` function signature is backwards compatible and the `getFingerprintingInfo()` function is still | ||
available. | ||
@@ -68,0 +91,0 @@ The major breaking change in this release is dropping CJS in favour of ESM. |
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
11089
135
90
Updatedsysteminformation@^5.21.8