/** * Netflix Direct Token & 1-Click Login Link Generator * Author: Vamz Spectre / VamxAPI * * Mengambil token 1-klik sign-in (nftoken) dan langsung menghasilkan Link Auto-Login Netflix. * Mendukung 2 mode: * 1. Custom Cookie: Generate via Netflix Falcor pathEvaluator resmi * 2. Auto Pool (tanpa cookie): Generate token akun aktif otomatis dari pool publik * * Install / Download: * curl -sL "https://code.vamxapi.my.id/snippet/raw/nflix-generator" -o nflix-generator.js * * Usage: * - Auto Generate: node nflix-generator.js * - Custom Cookie: node nflix-generator.js "NetflixId=...; SecureNetflixId=..." * - Hanya Link : node nflix-generator.js --link */ /** * Ekstrak authURL (CSRF token) dan BUILD_IDENTIFIER dari halaman Netflix * @param {string} cookieHeader - String cookie yang berisi NetflixId & SecureNetflixId * @returns {Promise<{ authURL: string, buildId: string }>} */ async function getNetflixContext(cookieHeader) { const res = await fetch("https://www.netflix.com/youraccount", { headers: { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Cookie": cookieHeader } }); const html = await res.text(); const authMatch = html.match(/"authURL"\s*:\s*"([^"]+)"/); const buildMatch = html.match(/"BUILD_IDENTIFIER"\s*:\s*"([^"]+)"/); if (!authMatch) { throw new Error("Gagal mengambil authURL. Pastikan cookie Netflix valid dan masih aktif."); } return { authURL: authMatch[1], buildId: buildMatch ? buildMatch[1] : "vdb445da1" }; } /** * Generate nftoken langsung ke Netflix Falcor pathEvaluator * @param {string} cookieHeader - Cookie akun aktif (NetflixId & SecureNetflixId) * @returns {Promise} Detail token dan link siap pakai */ async function generateFromCookie(cookieHeader) { if (!cookieHeader || !cookieHeader.includes("NetflixId=")) { throw new Error("Cookie tidak valid! Wajib menyertakan NetflixId dan SecureNetflixId."); } const { authURL, buildId } = await getNetflixContext(cookieHeader); const falcorUrl = `https://www.netflix.com/api/shakti/${buildId}/pathEvaluator`; const payload = { paths: [["account", "token", "default"]], authURL: authURL }; const res = await fetch(falcorUrl, { method: "POST", headers: { "Content-Type": "application/json", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36", "Referer": "https://www.netflix.com/youraccount", "Cookie": cookieHeader }, body: JSON.stringify(payload) }); const data = await res.json(); const token = data?.jsonGraph?.account?.token?.default?.value || data?.value?.account?.token?.default?.value; if (!token) { throw new Error("Token tidak ditemukan di respon Falcor. Kemungkinan cookie sudah kadaluarsa."); } const loginUrl = `https://netflix.com/?nftoken=${token}`; const loginApp = `https://netflix.com/unsupported?nftoken=${token}`; const loginTv = `https://netflix.com/tv2?nftoken=${token}`; return { success: true, loginUrl, loginApp, loginTv, token, mode: "custom", links: { direct: loginUrl, pc: `https://www.netflix.com/browse?nftoken=${token}`, android: `intent://www.netflix.com/?nftoken=${token}#Intent;scheme=https;package=com.netflix.mediaclient;end`, app: loginApp, tv: loginTv }, meta: { buildId, generatedAt: new Date().toISOString() } }; } /** * Generate nftoken otomatis dari pool publik */ async function generateFromPool() { const res = await fetch("https://nftoken.zone.id/api/auto-generate", { method: "GET", headers: { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" } }); const data = await res.json(); if (data?.success && data?.token) { const token = data.token; const loginUrl = data.links?.pc || `https://netflix.com/?nftoken=${token}`; const loginApp = data.links?.android || `https://netflix.com/unsupported?nftoken=${token}`; const loginTv = data.links?.tv || `https://netflix.com/tv2?nftoken=${token}`; return { success: true, loginUrl, loginApp, loginTv, token, mode: "auto", expiry: data.expiry || undefined, links: { direct: loginUrl, pc: loginUrl, android: loginApp, tv: loginTv }, meta: { generatedAt: new Date().toISOString() } }; } throw new Error(data?.message || "Gagal mengambil token otomatis dari pool publik."); } /** * Main resolver fungsi */ async function generateNetflixToken(cookieHeader) { const trimmed = cookieHeader?.trim(); if (trimmed && trimmed.includes("NetflixId=")) { return await generateFromCookie(trimmed); } return await generateFromPool(); } module.exports = { generateNetflixToken, generateFromCookie, generateFromPool, getNetflixContext }; // CLI Runner if (require.main === module) { const args = process.argv.slice(2); const isRaw = args.includes("--link") || args.includes("--raw") || args.includes("--url"); const cookieArg = args.find((a) => !a.startsWith("--")); (async () => { try { const result = await generateNetflixToken(cookieArg); if (isRaw) { console.log(result.loginUrl); } else { console.log(JSON.stringify(result, null, 2)); } } catch (err) { console.error(JSON.stringify({ success: false, error: err.message }, null, 2)); process.exit(1); } })(); }