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. โ
โ 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
authsecure_js/
โ
โโโ package.json
โโโ src/
โโโ authsecure.js
โโโ main.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 -vCreate a folder and set up the project:
mkdir authsecure_js && cd authsecure_js
npm init -y
npm install axiosEdit 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"
}
}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}`);
}
}
}
}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();
}
});
})();npm startConnecting...
โ
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
| 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 |
MIT License ยฉ 2025 โ Created with โค๏ธ by Lufy