insta-checker-sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +0 -0
- package/dist/InstaChecker.d.ts +31 -0
- package/dist/InstaChecker.js +162 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Abdoul-rahman/Abdou-da0wew
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
File without changes
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface CheckerOptions {
|
|
2
|
+
timeout?: number;
|
|
3
|
+
concurrency?: number;
|
|
4
|
+
retries?: number;
|
|
5
|
+
cacheTTL?: number;
|
|
6
|
+
enableCache?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface CheckResult {
|
|
9
|
+
available: boolean;
|
|
10
|
+
cached: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface BatchProgressInfo {
|
|
13
|
+
current: number;
|
|
14
|
+
total: number;
|
|
15
|
+
username: string;
|
|
16
|
+
lastResult: boolean | null;
|
|
17
|
+
}
|
|
18
|
+
export interface BatchOptions {
|
|
19
|
+
onProgress?: (info: BatchProgressInfo) => void;
|
|
20
|
+
}
|
|
21
|
+
declare class InstaChecker {
|
|
22
|
+
private config;
|
|
23
|
+
private agent;
|
|
24
|
+
private cache;
|
|
25
|
+
constructor(opts?: CheckerOptions);
|
|
26
|
+
checkUsername(username: string): Promise<CheckResult>;
|
|
27
|
+
private _makeRequest;
|
|
28
|
+
checkBatch(usernames: string[], options?: BatchOptions): Promise<Record<string, boolean | null>>;
|
|
29
|
+
clearCache(): void;
|
|
30
|
+
}
|
|
31
|
+
export default InstaChecker;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const https = __importStar(require("https"));
|
|
37
|
+
class InstaChecker {
|
|
38
|
+
constructor(opts = {}) {
|
|
39
|
+
this.config = {
|
|
40
|
+
timeout: opts.timeout || 5000,
|
|
41
|
+
concurrency: opts.concurrency || 5,
|
|
42
|
+
retries: opts.retries ?? 2,
|
|
43
|
+
cacheTTL: opts.cacheTTL || 300000,
|
|
44
|
+
enableCache: opts.enableCache !== false,
|
|
45
|
+
apiUrl: "https://wp2.hopperhq.com/wp-content/plugins/freetools-api/checker/username",
|
|
46
|
+
};
|
|
47
|
+
this.agent = new https.Agent({
|
|
48
|
+
keepAlive: true,
|
|
49
|
+
keepAliveMsecs: 1000,
|
|
50
|
+
maxSockets: 50,
|
|
51
|
+
maxFreeSockets: 10,
|
|
52
|
+
});
|
|
53
|
+
this.cache = new Map();
|
|
54
|
+
}
|
|
55
|
+
async checkUsername(username) {
|
|
56
|
+
if (!username || typeof username !== "string") {
|
|
57
|
+
throw new Error("Hey, give me a valid username string!");
|
|
58
|
+
}
|
|
59
|
+
const cleanName = username.trim();
|
|
60
|
+
if (this.config.enableCache && this.cache.has(cleanName)) {
|
|
61
|
+
const cached = this.cache.get(cleanName);
|
|
62
|
+
if (Date.now() - cached.timestamp < this.config.cacheTTL) {
|
|
63
|
+
return { available: cached.data, cached: true };
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
this.cache.delete(cleanName);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
let attempt = 0;
|
|
70
|
+
let lastErr;
|
|
71
|
+
while (attempt <= this.config.retries) {
|
|
72
|
+
try {
|
|
73
|
+
const result = await this._makeRequest(cleanName);
|
|
74
|
+
if (this.config.enableCache) {
|
|
75
|
+
this.cache.set(cleanName, { data: result, timestamp: Date.now() });
|
|
76
|
+
}
|
|
77
|
+
return { available: result, cached: false };
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
lastErr = err;
|
|
81
|
+
attempt++;
|
|
82
|
+
await new Promise(r => setTimeout(r, 100 * Math.pow(2, attempt)));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
throw new Error(`Could not check "${cleanName}" after ${attempt} attempts. Last error: ${lastErr?.message}`);
|
|
86
|
+
}
|
|
87
|
+
_makeRequest(username) {
|
|
88
|
+
return new Promise((resolve, reject) => {
|
|
89
|
+
const payload = JSON.stringify({ username, platform: "instagram" });
|
|
90
|
+
const reqOptions = {
|
|
91
|
+
hostname: "wp2.hopperhq.com",
|
|
92
|
+
path: "/wp-content/plugins/freetools-api/checker/username",
|
|
93
|
+
method: "POST",
|
|
94
|
+
agent: this.agent,
|
|
95
|
+
headers: {
|
|
96
|
+
"User-Agent": "Mozilla/5.0 (compatible; Functiolita/1.0; +https://axionforge.com/abdou-da0wew)",
|
|
97
|
+
"Accept": "application/json",
|
|
98
|
+
"Content-Type": "application/json",
|
|
99
|
+
"Content-Length": Buffer.byteLength(payload),
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
const req = https.request(reqOptions, (res) => {
|
|
103
|
+
let body = "";
|
|
104
|
+
res.on("data", (chunk) => body += chunk);
|
|
105
|
+
res.on("end", () => {
|
|
106
|
+
try {
|
|
107
|
+
if (res.statusCode !== 200)
|
|
108
|
+
return reject(new Error(`HTTP ${res.statusCode}`));
|
|
109
|
+
const json = JSON.parse(body);
|
|
110
|
+
resolve(json.result?.available ?? false);
|
|
111
|
+
}
|
|
112
|
+
catch (e) {
|
|
113
|
+
reject(new Error("Failed to parse JSON"));
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
req.on("error", (err) => reject(err));
|
|
118
|
+
req.on("timeout", () => {
|
|
119
|
+
req.destroy();
|
|
120
|
+
reject(new Error("Request timed out"));
|
|
121
|
+
});
|
|
122
|
+
req.setTimeout(this.config.timeout);
|
|
123
|
+
req.write(payload);
|
|
124
|
+
req.end();
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
async checkBatch(usernames, options = {}) {
|
|
128
|
+
if (!Array.isArray(usernames))
|
|
129
|
+
throw new Error("Usernames must be an array");
|
|
130
|
+
const results = {};
|
|
131
|
+
const queue = [...new Set(usernames)];
|
|
132
|
+
let currentIndex = 0;
|
|
133
|
+
let doneCount = 0;
|
|
134
|
+
const total = queue.length;
|
|
135
|
+
const workers = Array.from({ length: this.config.concurrency }, async () => {
|
|
136
|
+
while (currentIndex < queue.length) {
|
|
137
|
+
const index = currentIndex++;
|
|
138
|
+
const name = queue[index];
|
|
139
|
+
if (!name)
|
|
140
|
+
break;
|
|
141
|
+
try {
|
|
142
|
+
const res = await this.checkUsername(name);
|
|
143
|
+
results[name] = res.available;
|
|
144
|
+
}
|
|
145
|
+
catch (err) {
|
|
146
|
+
results[name] = null;
|
|
147
|
+
console.error(`Error checking ${name}: ${err.message}`);
|
|
148
|
+
}
|
|
149
|
+
doneCount++;
|
|
150
|
+
if (options.onProgress) {
|
|
151
|
+
options.onProgress({ current: doneCount, total, username: name, lastResult: results[name] });
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
await Promise.all(workers);
|
|
156
|
+
return results;
|
|
157
|
+
}
|
|
158
|
+
clearCache() {
|
|
159
|
+
this.cache.clear();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
exports.default = InstaChecker;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const InstaChecker_1 = __importDefault(require("./InstaChecker"));
|
|
7
|
+
exports.default = InstaChecker_1.default;
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "insta-checker-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A robust, production-ready Instagram username availability checker written in TypeScript.",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"prepublishOnly": "npm run build",
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"instagram",
|
|
14
|
+
"username",
|
|
15
|
+
"checker",
|
|
16
|
+
"availability",
|
|
17
|
+
"bot",
|
|
18
|
+
"discord",
|
|
19
|
+
"api",
|
|
20
|
+
"typescript"
|
|
21
|
+
],
|
|
22
|
+
"author": "Abdou-da0wew <aabdouaydev911@gmail.com>",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/abdou-da0wew/insta-checker-sdk.git"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^20.0.0",
|
|
30
|
+
"typescript": "^5.0.0"
|
|
31
|
+
},
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=14.0.0"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist/",
|
|
37
|
+
"README.md",
|
|
38
|
+
"LICENSE"
|
|
39
|
+
]
|
|
40
|
+
}
|