Socket
Book a DemoInstallSign in
Socket

@dilanjer/fingerprint

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dilanjer/fingerprint

Server-side fingerprinting library for framework NestJs

0.0.5
latest
npmnpm
Version published
Maintainers
1
Created
Source

Server-side fingerprinting library for framework NestJs

Features

  • Generate fingerprint for each browser or device
  • Function decorator support
  • Auto set cookie

Installation

npm install --save @dilanjer/fingerprint

or

yarn add @dilanjer/fingerprint

Usage

app.module.ts

import { Module } from "@nestjs/common";
import { FingerprintModule } from "@dilanjer/fingerprint";
import { AppController } from "./app.controller";
import { AppService } from "./app.service";

@Module({
  imports: [
    FingerprintModule.forRoot({
      params: ["headers", "userAgent", "ipAddress", "location"],
      cookieOptions: {
        name: "your_cookie_name", // optional
        httpOnly: true, // optional
      },
    }),
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}

app.controller.ts

import { Controller, Get } from "@nestjs/common";
import { Fingerprint, RealIp } from "@dilanjer/fingerprint";

@Controller()
export class AppController {
  @Get()
  getFingerprint(@Fingerprint() fp: Fingerprint): Fingerprint {
    return fp;
  }

  @Get("my-ip-address")
  getMyIpAddress(@RealIp() ipAddress: string): string {
    return ipAddress;
  }
}

Fingerprint example:

{
  "id": "79c0678d8672fafb932a97a1368d7bf3",
  "headers": {
    "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
    "language": "en-US,en;q=0.9"
  },
  "userAgent": {
    "browser": {
      "name": "Chrome",
      "version": "xxx"
    },
    "device": {
      "model": "Other",
      "type": "0"
    },
    "os": {
      "name": "Windows",
      "version": "10"
    },
    "cpu": {
      "architecture": "xxx"
    }
  },
  "ipAddress": {
    "value": "xxx.xxx.xxx.xxx"
  },
  "location": {
    "city": "San Antonio",
    "country": "US",
    "region": "TX"
  }
}

License

MIT © Dialnjer

FAQs

Package last updated on 05 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.