npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

deepfake-sdk-js

v1.0.4

Published

JavaScript SDK for Deepfake Detection API

Readme

Deepfake Detection SDK

A powerful JavaScript SDK designed for seamless integration with the Deepfake Detection backend. This SDK enables developers to consume backend APIs with ease, including authentication, deepfake file analysis, liveness detection, ID verification, content provenance, analytics, and feedback handling — all with automatic token management and secure request handling.

Table of Contents

Overview

This SDK provides a developer-friendly wrapper around the Deepfake Detection Backend REST API. It enables:

Authentication: Register,Verify OTP,Resend OTP,Login,Refresh Token,Logout,ForgotPassword,Verify Email

Deepfake Detection: File and URL analysis for images, videos, audio, and text

Liveness Detection: Verifying real-time human presence

ID Verification: Matching face ID documents with live images

Content Provenance: Metadata verification and write operations

Analytics: Media usage analytics and activity stats

Feedback Submission: ML model improvement through user input

It handles:

Automatic token refresh

Error formatting

File uploads

Authorization headers

Secure cookie management

Tech Stack

Core Technologies

Language: JavaScript (ES Modules)

Build System: Rollup (ESM, CJS, UMD bundles)

HTTP Requests: Fetch API

Compatibility:

Browsers (React, Vue, Next.js)

Node.js (v18+)

Optional TypeScript Support

Type definitions (index.d.ts) included

Features

Authentication

Registration with OTP

Login with access & refresh tokens

Auto token refresh

Secure logout

ML & Detection Services

File Uploads: image, video, audio, text

URL Analysis

ID Verification

Liveness Detection

Provenance Metadata

User & Analytics

Get/update user profile

View activity analytics

View liveness/ID verification analytics

Paginated request history

Developer Tools

Zero external dependencies

Clean unified error handling

Auto retries for expired tokens

Works in both frontend and backend

SDK Structure


deepfake-sdk/
├── dist/                         # Compiled SDK bundles (CJS, ESM, UMD)
├── src/
│   ├── http.js                   # Base HTTP client
│   ├── auth.js                   # Authentication logic
│   ├── ml.js                     # ML & detection services
│   ├── user.js                   # User profile
│   ├── analytics.js              # Analytics module
│   └── feedback.js               # Feedback module
├── package.json
├── README.md
└── .npmignore

Installation

NPM

npm install deepfake-sdk-js

Yarn

yarn add deepfake-sdk-js

CDN (UMD)

<script src="https://cdn.jsdelivr.net/npm/deepfake-sdk-js/dist/index.js"></script>
<script>
  const sdk = new DeepfakeSDK({
    baseURL: "https://api.example.com/api/v1",
    apiKey: "YOUR_SECRET_KEY"
  });
</script>

Initialization

import DeepfakeSDK from "deepfake-sdk-js";

const sdk = new DeepfakeSDK({
  baseURL: "https://your-api-domain.com/api/v1",
  apiKey: "YOUR_SECRET_API_KEY"
});

✔ Automatically attaches access tokens ✔ Auto-refreshes tokens ✔ Works with HttpOnly refresh cookies

Usage Examples

Upload a file for deepfake detection

const file = document.querySelector("#fileInput").files[0];

const result = await sdk.ml.uploadFile(file);
console.log(result);

Analyze using a URL

await sdk.ml.analyzeUrl("https://example.com/media.mp4");

Authentication Methods

Register

await sdk.auth.register({
  name: "John",
  email: "[email protected]",
  password: "Password123",
  phone: "+918888888888"
});

Verify OTP

await sdk.auth.verifyOtp(registrationId, "123456");

Login

await sdk.auth.login("[email protected]", "Password123");

Resend OTP

await sdk.auth.resendOtp(regId);

Refresh Token

await sdk.auth.refresh();

Logout

await sdk.auth.logout();

Forgot Password

await sdk.auth.forgotPassword("[email protected]");

Verify Email

await sdk.auth.verifyEmail(token);

ML & Detection Methods

Upload File (Image/Video/Audio/Text)

await sdk.ml.uploadFile(file);

URL-Based Analysis

await sdk.ml.analyzeUrl("https://example.com/demo.mp4");

ID Verification

await sdk.ml.idVerification(sourceImage, targetImage);

Liveness Detection

await sdk.ml.livenessDetection({
  lastFrame: base64string,
  isLive: true,
  confidence: 0.98
});

Provenance Metadata

await sdk.ml.provenance(file, {
  creator_name: "John",
  title: "Document",
  include_exif: "true"
});

Face Enrollment

await sdk.ml.faceEnroll(file, { userId: "123" });

Face Search

await sdk.ml.faceSearch(file);

Get Face Enrollment List

await sdk.ml.getFaceEnrollment();

User Profile Methods

Get Profile

await sdk.user.getProfile();

Update Profile

await sdk.user.updateProfile({ name: "New Name" });

Analytics Methods

Summary Analytics

await sdk.analytics.summary();

Liveness Analytics

await sdk.analytics.liveness();

ID Verification Analytics

await sdk.analytics.idVerification();

User History (Paginated)

await sdk.analytics.history(1, 20);

Paginated History

await sdk.analytics.history(1, 20);

Get Record by Table + ID (NEW)

await sdk.analytics.getRecordById(3, "uuid123");

Dashboard Data (NEW)

await sdk.analytics.getDashboardData();

Feedback Methods

Submit Feedback

await sdk.feedback.submit({
  mlFileId: "uuid",
  feedback: true,
  source: "web"
});

Get All Feedback

Fetch entire feedback list.

const allFeedback = await sdk.feedback.getAll();
console.log(allFeedback);

Get Feedback for ML File by ID

Fetch ML feedback by ML file ID.

const data = await sdk.feedback.byML("mlFileId123");
console.log(data);

Get Feedback for a URL Analysis by ID

const feedback = await sdk.feedback.byURL("urlId456");
console.log(feedback);

Error Handling

All errors follow a standardized format:

try {
  await sdk.ml.uploadFile(file);
} catch (error) {
  console.error(error.statusCode);
  console.error(error.message);
  console.error(error.details);
}

Security Notes

To ensure secure operation:

Always use HTTPS

Backend must enable:

cors({
  origin: ["https://your-frontend.com"],
  credentials: true
});

Refresh token must remain HttpOnly

Do NOT store access or refresh tokens in localStorage

Publishing Guide

Step 1: Build SDK

npm run build

Step 2: Version Update

npm version patch

Step 3: Publish to npm

npm publish --access public

Step 4: Install in Client

npm install deepfake-sdk-js