Package Exports
- zencf
- zencf/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (zencf) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
🚀 zencf
Klien API untuk Cloudflare Bypass Bypass Cloudflare WAF & Turnstile tanpa browser headless.
zencf adalah klien ringan
Gunakan modul ini untuk mengatasi tantangan Cloudflare (seperti WAF dan Turnstile) tanpa menjalankan browser headless sendiri.
💾 Instalasi
# Menggunakan npm
npm install zencf
# Atau menggunakan yarn
yarn add zencf
📋 Penggunaan
Modul ini mendukung CommonJS (require) dan ES Modules (import).
🧱 CommonJS Example
const { zencf } = require('zencf');
async function getSession() {
try {
const session = await zencf.wafSession('[https://example.com/protected](https://example.com/protected)', 'host:port');
console.log('Cookies:', session.cookies);
console.log('User-Agent:', session.headers['User-Agent']);
} catch (error) {
console.error('Gagal mendapatkan WAF Session:', error.message);
}
}
getSession();
📦 ES Modules Example (Static Import)
import { zencf } from 'zencf';
(async () => {
try {
const result = await zencf.turnstileMin('[https://forms.com/login](https://forms.com/login)', '0x4AAAAAAAT-yE...');
console.log('Token Turnstile:', result.token);
} catch (error) {
console.error('Gagal:', error.message);
}
})();
⚙️ ES Modules Example (Dynamic Import — Disarankan untuk Skrip Asinkron)
const zencfPromise = import('zencf');
async function runDynamicScraper() {
const zencfModule = await zencfPromise;
const zencf = zencfModule.zencf || (zencfModule.default && zencfModule.default.zencf);
try {
const result = await zencf.turnstileMin('[https://forms.com/login](https://forms.com/login)', '0x4AAAAAAAT-yE...');
console.log('Token Dynamic Import:', result.token);
} catch (error) {
console.error('Gagal menjalankan dynamic import:', error.message);
}
}
runDynamicScraper();
🧭 API Reference
Semua fungsi bersifat async dan akan melempar Error jika terjadi kegagalan.
1️⃣ zencf.wafSession(url, proxy?)
Mengambil cookies dan headers untuk melewati Cloudflare WAF,
sehingga request HTTP berikutnya dapat berjalan tanpa challenge.
| Parameter | Tipe | Diperlukan | Deskripsi |
|---|---|---|---|
| url | string | ✅ Ya | URL yang dilindungi WAF |
| proxy | string | ❌ Tidak | Alamat proxy opsional (user:pass@host:port) |
Contoh:
const { zencf } = require('zencf');
async function getSession() {
const session = await zencf.wafSession('[https://example.com/protected](https://example.com/protected)', 'host:port');
console.log('Cookies:', session.cookies);
console.log('Headers:', session.headers);
}
getSession();
2️⃣ zencf.turnstileMin(url, siteKey, proxy?)
Menyelesaikan challenge Cloudflare Turnstile dengan mode minimal (cepat).
Mengembalikan token yang dapat diverifikasi di server Anda.
| Parameter | Tipe | Diperlukan | Deskripsi |
|---|---|---|---|
| url | string | ✅ Ya | URL halaman dengan widget Turnstile |
| siteKey | string | ✅ Ya | Site Key Turnstile |
| proxy | string | ❌ Tidak | Proxy opsional |
Contoh:
const { zencf } = require('zencf');
async function solveTurnstile() {
const result = await zencf.turnstileMin(
'[https://forms.com/login](https://forms.com/login)',
'0x4AAAAAAAT-yE...', // Site Key
'host:port'
);
console.log('Token Turnstile Min:', result.token);
}
solveTurnstile();
3️⃣ zencf.turnstileMax(url, proxy?)
Mode maksimum (simulasi interaksi pengguna alami).
Lebih andal pada halaman yang memiliki proteksi ketat.
| Parameter | Tipe | Diperlukan | Deskripsi |
|---|---|---|---|
| url | string | ✅ Ya | URL target Turnstile |
| proxy | string | ❌ Tidak | Proxy opsional |
4️⃣ zencf.source(url, proxy?)
Mengambil HTML yang sudah di-render oleh JavaScript dari suatu halaman.
Cocok untuk situs SPA (Single Page Application) atau konten dinamis.
| Parameter | Tipe | Diperlukan | Deskripsi |
|---|---|---|---|
| url | string | ✅ Ya | URL target |
| proxy | string | ❌ Tidak | Proxy opsional |
Contoh:
const { zencf } = require('zencf');
async function getSource() {
const result = await zencf.source('[https://spa-website.com/](https://spa-website.com/)');
console.log('HTML Source:', result.source.substring(0, 200) + '...');
}
getSource();
⚠️ Penanganan Error
Semua fungsi akan melempar Error jika:
* Permintaan gagal di tingkat jaringan (misal: koneksi putus, DNS gagal)
* API mengembalikan status 4xx atau 5xx
* Parameter wajib hilang atau challenge gagal diselesaikan
Gunakan try...catch:
try {
const token = await zencf.turnstileMin(url, siteKey, proxy);
console.log('Token:', token);
} catch (err) {
console.error('zencf error:', err.message);
}
🔒 Catatan Keamanan
* Token Turnstile harus diverifikasi di server-side.
* Hindari menampilkan atau menyimpan token sensitif di log produksi.
* Gunakan proxy secara bijak dan hanya dari sumber tepercaya.
🧠 Tips
* Gunakan turnstileMin untuk kecepatan.
* Gunakan turnstileMax jika challenge sulit dilewati.
* wafSession() cocok untuk scraping awal sebelum request utama.
* source() ideal untuk situs SPA atau konten JS-rendered.
📜 Lisensi
Lisensi mengikuti ketentuan dalam package.json atau repositori resmi proyek ini.