Skip to content

Authsecure-shop/AuthSecure-javascript-Example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation


โšก AuthSecure JavaScript Example

A full Node.js (JavaScript) example showing how to integrate and secure your application using the AuthSecure API. Includes ready-to-use Init, Login, Register, and License Login features. โœ…


๐Ÿš€ Features

โœ… AuthSecure API Integration (Init / Login / Register / License Login) โœ… Works with Windows, Linux, macOS โœ… Uses HTTPS via Axios โœ… Fetches Windows HWID automatically (via PowerShell) โœ… Clean, modular JavaScript (ESM) structure โœ… No TypeScript setup required


๐Ÿ“ Project Structure

authsecure_js/
โ”‚
โ”œโ”€โ”€ package.json
โ””โ”€โ”€ src/
    โ”œโ”€โ”€ authsecure.js
    โ””โ”€โ”€ main.js

โš™๏ธ Setup Guide

๐Ÿงฑ Step 1 โ€” Install Node.js

If you donโ€™t already have Node.js, download and install it from: ๐Ÿ‘‰ https://nodejs.org/en/download

Then verify installation:

node -v
npm -v

๐Ÿงฐ Step 2 โ€” Initialize Your Project

Create a folder and set up the project:

mkdir authsecure_js && cd authsecure_js
npm init -y
npm install axios

โš™๏ธ Step 3 โ€” Update package.json

Edit your package.json to look like this ๐Ÿ‘‡

{
  "name": "authsecure_js",
  "version": "1.0.0",
  "type": "module",
  "scripts": {
    "start": "node src/main.js"
  },
  "dependencies": {
    "axios": "^1.7.7"
  }
}

๐Ÿ’ป Source Code

๐Ÿงฉ src/authsecure.js

This class handles all AuthSecure API communication ๐Ÿ‘‡

import axios from "axios";
import { execSync } from "child_process";

export class AuthSecure {
  constructor(config) {
    this.name = config.name;
    this.ownerid = config.ownerid;
    this.secret = config.secret;
    this.version = config.version;
    this.sessionid = null;
    this.BASE_URL = "https://authsecure.shop/post/api.php";
  }

  async sendRequest(payload) {
    try {
      const params = new URLSearchParams(payload);
      const response = await axios.post(this.BASE_URL, params);
      return response.data;
    } catch (err) {
      console.error("โŒ HTTP Error:", err.message);
      process.exit(1);
    }
  }

  getHWID() {
    try {
      const output = execSync(
        `powershell -Command "[System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value"`,
        { encoding: "utf8" }
      ).trim();
      return output || "UNKNOWN_HWID";
    } catch {
      return "UNKNOWN_HWID";
    }
  }

  async Init() {
    console.log("Connecting...");
    const resp = await this.sendRequest({
      type: "init",
      name: this.name,
      ownerid: this.ownerid,
      secret: this.secret,
      ver: this.version,
    });

    if (resp.success) {
      this.sessionid = resp.sessionid;
      console.log("โœ… Initialized Successfully!");
    } else {
      console.log("โŒ Init Failed:", resp.message || "Unknown error");
      process.exit(1);
    }
  }

  async Login(username, password) {
    const resp = await this.sendRequest({
      type: "login",
      sessionid: this.sessionid,
      username,
      pass: password,
      hwid: this.getHWID(),
      name: this.name,
      ownerid: this.ownerid,
    });

    if (resp.success) {
      console.log("โœ… Logged in!");
      this.printUserInfo(resp.info);
    } else {
      console.log("โŒ Login Failed:", resp.message || "Unknown error");
    }
  }

  async Register(username, password, license) {
    const resp = await this.sendRequest({
      type: "register",
      sessionid: this.sessionid,
      username,
      pass: password,
      license,
      hwid: this.getHWID(),
      name: this.name,
      ownerid: this.ownerid,
    });

    if (resp.success) {
      console.log("โœ… Registered Successfully!");
      this.printUserInfo(resp.info);
    } else {
      console.log("โŒ Register Failed:", resp.message || "Unknown error");
    }
  }

  async License(license) {
    const resp = await this.sendRequest({
      type: "license",
      sessionid: this.sessionid,
      license,
      hwid: this.getHWID(),
      name: this.name,
      ownerid: this.ownerid,
    });

    if (resp.success) {
      console.log("โœ… License Login Successful!");
      this.printUserInfo(resp.info);
    } else {
      console.log("โŒ License Login Failed:", resp.message || "Unknown error");
    }
  }

  printUserInfo(info) {
    console.log("\n๐Ÿ‘ค User Info:");
    console.log(" Username:", info.username);
    console.log(" HWID:", info.hwid);
    console.log(" IP:", info.ip);
    if (info.subscriptions) {
      console.log(" Subscriptions:");
      for (const sub of info.subscriptions) {
        console.log(`  - ${sub.subscription} | Expires: ${sub.expiry}`);
      }
    }
  }
}

๐Ÿงฉ src/main.js

This file handles user interaction (login/register/license) through the CLI ๐Ÿ‘‡

import readline from "readline";
import { AuthSecure } from "./authsecure.js";

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});

const AuthSecureApp = new AuthSecure({
  name: "XD", // App name
  ownerid: "3ezshCmkXrn", // Account ID
  secret: "7a8bfeb28afcd690812ee5de010a6860", // App secret
  version: "1.0", // App version
});

(async () => {
  await AuthSecureApp.Init();

  console.log("\n[1] Login\n[2] Register\n[3] License Login\n[4] Exit");
  rl.question("Choose option: ", async (choice) => {
    switch (choice) {
      case "1":
        rl.question("Username: ", (username) => {
          rl.question("Password: ", async (password) => {
            await AuthSecureApp.Login(username.trim(), password.trim());
            rl.close();
          });
        });
        break;

      case "2":
        rl.question("Username: ", (username) => {
          rl.question("Password: ", (password) => {
            rl.question("License: ", async (license) => {
              await AuthSecureApp.Register(
                username.trim(),
                password.trim(),
                license.trim()
              );
              rl.close();
            });
          });
        });
        break;

      case "3":
        rl.question("License: ", async (license) => {
          await AuthSecureApp.License(license.trim());
          rl.close();
        });
        break;

      default:
        console.log("Goodbye!");
        rl.close();
    }
  });
})();

๐Ÿงฎ Run the App

npm start

๐Ÿ–ฅ๏ธ Example Output

Connecting...
โœ… Initialized Successfully!

[1] Login
[2] Register
[3] License Login
[4] Exit
Choose option: 1
Username: lufy
Password: 12345
โœ… Logged in!

๐Ÿ‘ค User Info:
 Username: lufy
 HWID: S-1-5-21-3116590451-4259102588-3214189088-1001
 IP: 2a09:bac5:3c0b:1a96::2a6:65
 Subscriptions:
  - default | Expires: 1762788300

๐Ÿง  Highlights

Feature Description
๐Ÿ”’ HTTPS API Secure communication using Axios
๐Ÿ’ป HWID Automatically generated via Windows PowerShell
๐Ÿงฑ JavaScript Clean, easy-to-read structure
๐Ÿ”ง Integration Ready Works in apps, tools, or games

๐Ÿชช License

MIT License ยฉ 2025 โ€” Created with โค๏ธ by Lufy


About

AuthSecure-javascript-Example

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published