Giter VIP home page Giter VIP logo

jooy2 / machini Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 105 KB

Get hardware specs, Machine ID(Device ID/UUID) information, and more for your current device. It's designed to be fast and lightweight so you can get just the information you need.

Home Page: https://www.npmjs.com/package/machini

License: MIT License

TypeScript 100.00%
hardware-information machine-id machineid nodejs system-information utility uuid

machini's Introduction

machini

license Programming Language Usage Commit Count npm downloads npm latest package minified size github repo size Followers Stars

machini is a utility to get hardware information about system devices.

  • Lightweight and Fast!
  • It doesn't use any additional modules - it utilizes pure Node.js APIs.
  • You don't need system privileges to get the value.
  • Friendly to modern Node.js development and TypeScript.
  • Cross-platform (Windows, macOS, Unix/Linux) support.

Installation

Note

machini is a module that runs on the Node.js runtime and is not available in a typical web environment (client). Since it utilizes the runtime of Node.js to get device information, it defeats the purpose of getting the end user's device information. To get the client's device ID, consider a solution like UUID (randomUUID in crypto).

machini requires Node.js 18.x or higher, and the repository is serviced through NPM.

machini is ESM-only. You must use import instead of require to load the module. There are workarounds available for CommonJS, but we recommend using ESM based on recent JavaScript trends.

After configuring the node environment, you can simply run the following command.

# via npm
$ npm install machini

# via yarn
$ yarn add machini

# via pnpm
$ pnpm install machini

Using named import (Multiple utilities in a single require) - Recommend

import { machineId } from 'machini';

async function main() {
	console.log(await machineId());
}

Using whole class (multiple utilities simultaneously with one object)

import Machini from 'machini';

async function main() {
	console.log(await Machini.machineId());
}

Methods

machineId (Promise<string>)

Gets the unique UUID of the current device. Throws an error if the value is not retrieved. Returns a Promise object, so use await or .then() to wait for the operation to complete and get the correct value.

The UUID may change when the system is reinstalled or as the virtual machine's environment changes. On some systems, this value can also be modified by the system administrator (but this is rarely utilized as the system may become unstable after modification).

This method returns the same value for every user on the system.

console.log(await machineId()); // a642d9e1-6063-4da7-8ea8-2298f989d01d

sid (Promise<string>)

Gets the Security Identifier (SID) value for the current user on the device. Throws an error if the value is not obtained.

The SID value is only supported on Windows and macOS. Other OSes throw an error.

Also, the SID value used on macOS is a value created for the directory service. If you don't trust this value, use the machineId method instead.

This value can be changed by the user.

console.log(await sid()); // S-1-5-21-406418252-5582013529-1321253100-2001

Contribute

You can report issues on GitHub Issue Tracker. You can also request a pull to fix bugs and add frequently used features.

License

Copyright © 2024 Jooy2 <[email protected]> Released under the MIT license.

machini's People

Contributors

jooy2 avatar

Stargazers

 avatar

Watchers

 avatar

machini's Issues

Import Error

How to use this library in NextJS project?

I got error below when trying to use it:

import { machineId } from 'machini';

export default function Home() {
  useEffect(() => {

    const getMachini = async () => {
      const machini = await machineId();
      console.log("machini", machini);
    };

    getMachini();
  }, []);
Import trace for requested module:
./app/page.tsx
 GET / 500 in 2143ms
 ⨯ ./node_modules/machini/dist/index.js:1:58
Module not found: Can't resolve 'child_process'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.