From 739ca8934ea2a1a2a5576ba67cb6ebb035ca9917 Mon Sep 17 00:00:00 2001 From: vanne Date: Mon, 6 Jul 2026 09:05:42 +0700 Subject: [PATCH] feat: rebrand Netify to BackOne and resolve lookup database bug --- backend/generate_export.js | 18 +++++++++--------- backend/netify.js | 8 ++++---- backend/routes/dashboard.js | 25 +++++++++++++++++++++++++ src/app/(dashboard)/agents/page.tsx | 2 +- src/app/(dashboard)/lookup/page.tsx | 26 +++++++++++++++++--------- src/app/api/[...route]/route.ts | 16 ++++++++++------ src/lib/actions/agents.ts | 27 ++++++++++++++++----------- 7 files changed, 82 insertions(+), 40 deletions(-) diff --git a/backend/generate_export.js b/backend/generate_export.js index f38964c..335f4be 100644 --- a/backend/generate_export.js +++ b/backend/generate_export.js @@ -1,8 +1,8 @@ /** * generate_export.js * - * Mengekspor SELURUH data dari semua tabel SQLite (netify_data.db) - * ke dalam file netify_data_export.txt + * Mengekspor SELURUH data dari semua tabel SQLite (database) + * ke dalam file backone_data_export.txt * * Format output: * - Header metadata (tanggal, versi, jumlah tabel) @@ -14,7 +14,7 @@ const fs = require('fs'); const path = require('path'); const db = require('./database'); -const OUTPUT_FILE = path.join(__dirname, '../netify_data_export.txt'); +const OUTPUT_FILE = path.join(__dirname, '../backone_data_export.txt'); const d = db.getDB(); // ─── Helpers ──────────────────────────────────────────────────────────────── @@ -49,7 +49,7 @@ function sectionHeader(tableName, rowCount, description) { // ─── Table descriptions ────────────────────────────────────────────────────── const TABLE_DESCRIPTIONS = { - bandwidth_apps : 'Bandwidth per aplikasi (YouTube, Facebook, dll) dari Netify DPI', + bandwidth_apps : 'Bandwidth per aplikasi (YouTube, Facebook, dll) dari BackOne DPI', bandwidth_timeline : 'Timeline bandwidth per menit (download/upload historis)', bittorrent_info_hashes: 'Deteksi aktivitas BitTorrent berdasarkan info hash', countries : 'Distribusi traffic berdasarkan negara tujuan', @@ -57,7 +57,7 @@ const TABLE_DESCRIPTIONS = { dhcp_fingerprints : 'Fingerprint DHCP untuk identifikasi tipe device', discovered_os : 'OS yang terdeteksi dari traffic scanning', dns_stats : 'Query DNS teratas dan statistik resolusi domain', - events : 'Event log dari Netify agent (koneksi, peringatan, dll)', + events : 'Event log dari BackOne agent (koneksi, peringatan, dll)', flows : 'Data aliran jaringan per-sesi (src IP, dst IP, aplikasi, domain, bytes)', flow_origins : 'Asal flow: lokal (LAN) atau eksternal (WAN)', flow_types : 'Tipe flow: TCP, UDP, ICMP, dll', @@ -99,13 +99,13 @@ async function main() { // ── File Header ────────────────────────────────────────────────────────── lines.push(separator('═')); - lines.push(' NETIFY DATA EXPORT'); - lines.push(' Seluruh data hasil parsing dari Netify API'); + lines.push(' BACKONE DATA EXPORT'); + lines.push(' Seluruh data hasil parsing dari BackOne API'); lines.push(separator('─')); lines.push(` Export Date: ${exportDate}`); lines.push(` Generated by: generate_export.js`); - lines.push(` Source: netify_data.db (SQLite lokal)`); - lines.push(` API Base: https://informatics.netify.ai`); + lines.push(` Source: database (SQLite lokal)`); + lines.push(` API Base: BackOne API Service`); lines.push(` Format: Per-tabel, data JSON satu record per baris (JSONL)`); lines.push(separator('─')); diff --git a/backend/netify.js b/backend/netify.js index 6bc44f5..f177d9a 100644 --- a/backend/netify.js +++ b/backend/netify.js @@ -3,13 +3,13 @@ const path = require('path'); require('dotenv').config({ path: path.join(__dirname, '..', '.env.local') }); const axios = require('axios'); -const BASE_URL = 'https://informatics.netify.ai/api/v1'; -const JWT_TOKEN = process.env.NETIFY_TOKEN || process.env.NETIFY_JWT_TOKEN; -const SITE_UUID = process.env.NETIFY_SITE_UUID; +const BASE_URL = process.env.BACKONE_INFORMATICS_BASE_URL || process.env.NETIFY_INFORMATICS_BASE_URL || 'https://informatics.netify.ai/api/v1'; +const JWT_TOKEN = process.env.BACKONE_JWT_TOKEN || process.env.NETIFY_TOKEN || process.env.NETIFY_JWT_TOKEN; +const SITE_UUID = process.env.BACKONE_SITE_UUID || process.env.NETIFY_SITE_UUID; const agentMap = {}; function headersSite(useApiKey = false) { - const token = process.env.NETIFY_API_KEY || JWT_TOKEN; + const token = process.env.BACKONE_API_KEY || process.env.NETIFY_API_KEY || JWT_TOKEN; const headers = { 'x-api-key': token, 'Accept': 'application/json' }; if (SITE_UUID) { headers['x-net-site'] = SITE_UUID; diff --git a/backend/routes/dashboard.js b/backend/routes/dashboard.js index 864cc9c..1433405 100644 --- a/backend/routes/dashboard.js +++ b/backend/routes/dashboard.js @@ -4,6 +4,31 @@ const router = express.Router(); const db = require('../database'); const { runPoll } = require('../scheduler'); +// Rebrand Netify values dynamically in dashboard responses using safe JSON string serialization +router.use((req, res, next) => { + const originalJson = res.json; + res.json = function (body) { + if (body) { + try { + const jsonStr = JSON.stringify(body); + const sanitizedStr = jsonStr + .replace(/netify\.unclassified/gi, 'backone.unclassified') + .replace(/netify\.(?!ai)/gi, 'backone.') + .replace(/Netify's/g, "BackOne's") + .replace(/netify's/g, "backone's") + .replace(/Netify(?!(\.ai))/g, 'BackOne') + .replace(/netify(?!(\.ai))/g, 'backone'); + body = JSON.parse(sanitizedStr); + } catch (err) { + console.error('Error rebranding JSON response:', err); + } + } + return originalJson.call(this, body); + }; + next(); +}); + + // GET /api/dashboard/summary — kartu ringkasan (top of page) router.get('/summary', (req, res) => { const isAgent = req.user?.role === 'AGENT_VIEWER'; diff --git a/src/app/(dashboard)/agents/page.tsx b/src/app/(dashboard)/agents/page.tsx index a614b44..95b957e 100644 --- a/src/app/(dashboard)/agents/page.tsx +++ b/src/app/(dashboard)/agents/page.tsx @@ -218,7 +218,7 @@ export default function AgentsPage() {
  • Buka dan login ke portal BackOne Portal.
  • Di menu sebelah kiri, navigasikan ke Settings > API Keys.
  • Buat atau salin kunci tipe Standard API Key.
  • -
  • Buka file .env.local di proyek Anda, lalu ganti nilai NETIFY_API_KEY dengan kunci baru tersebut.
  • +
  • Buka file .env.local di proyek Anda, lalu ganti nilai BACKONE_API_KEY (atau NETIFY_API_KEY) dengan kunci baru tersebut.
  • diff --git a/src/app/(dashboard)/lookup/page.tsx b/src/app/(dashboard)/lookup/page.tsx index 6afaf44..7c0dcc1 100644 --- a/src/app/(dashboard)/lookup/page.tsx +++ b/src/app/(dashboard)/lookup/page.tsx @@ -83,15 +83,23 @@ export default function LookupPage() {
    {app.favicon || app.logo ? ( - {app.label} { - // If image fails, replace with default icon - (e.target as HTMLElement).style.display = 'none'; - }} - /> + <> + {app.label} { + // If image fails, hide it and show the sibling icon + const img = e.target as HTMLElement; + img.style.display = 'none'; + const sibling = img.nextSibling as HTMLElement; + if (sibling) { + sibling.style.display = 'block'; + } + }} + /> + + ) : ( )} diff --git a/src/app/api/[...route]/route.ts b/src/app/api/[...route]/route.ts index 9e70bc9..5ef5dcf 100644 --- a/src/app/api/[...route]/route.ts +++ b/src/app/api/[...route]/route.ts @@ -32,7 +32,7 @@ async function handleProxy(req: NextRequest, { params }: { params: Promise<{ rou const localBase = process.env.NEXT_PUBLIC_API_URL || 'http://127.0.0.1:3001'; destinationUrl = `${localBase}/api/${route}${url.search}`; } else { - const baseUrl = process.env.NETIFY_BASE_URL || 'https://manager.netify.ai/api/v1'; + const baseUrl = process.env.BACKONE_BASE_URL || process.env.NETIFY_BASE_URL || 'https://manager.netify.ai/api/v1'; destinationUrl = `${baseUrl}/${route}${url.search}`; } @@ -41,11 +41,15 @@ async function handleProxy(req: NextRequest, { params }: { params: Promise<{ rou headers.set('Content-Type', 'application/json'); if (routeArray[0] !== 'auth' && routeArray[0] !== 'dashboard') { - if (process.env.NETIFY_JWT_TOKEN && process.env.NETIFY_SITE_UUID) { - headers.set('x-api-key', process.env.NETIFY_JWT_TOKEN); - headers.set('x-net-site', process.env.NETIFY_SITE_UUID); - } else if (process.env.NETIFY_API_KEY) { - headers.set('x-api-key', process.env.NETIFY_API_KEY); + const jwtToken = process.env.BACKONE_JWT_TOKEN || process.env.NETIFY_JWT_TOKEN; + const siteUuid = process.env.BACKONE_SITE_UUID || process.env.NETIFY_SITE_UUID; + const apiKey = process.env.BACKONE_API_KEY || process.env.NETIFY_API_KEY; + + if (jwtToken && siteUuid) { + headers.set('x-api-key', jwtToken); + headers.set('x-net-site', siteUuid); + } else if (apiKey) { + headers.set('x-api-key', apiKey); } } else { // For local auth/dashboard routes, pass along the cookie for authentication diff --git a/src/lib/actions/agents.ts b/src/lib/actions/agents.ts index 2d0d746..a8a3324 100644 --- a/src/lib/actions/agents.ts +++ b/src/lib/actions/agents.ts @@ -2,16 +2,21 @@ import { revalidatePath } from "next/cache"; -const API_URL = process.env.NETIFY_BASE_URL ? `${process.env.NETIFY_BASE_URL}/assets/agents` : "https://manager.netify.ai/api/v1/assets/agents"; +const BASE_URL = process.env.BACKONE_BASE_URL || process.env.NETIFY_BASE_URL; +const API_URL = BASE_URL ? `${BASE_URL}/assets/agents` : "https://manager.netify.ai/api/v1/assets/agents"; + +const getApiKey = () => process.env.BACKONE_API_KEY || process.env.NETIFY_API_KEY; +const getJwtToken = () => process.env.BACKONE_JWT_TOKEN || process.env.NETIFY_JWT_TOKEN; +const getSiteUuid = () => process.env.BACKONE_SITE_UUID || process.env.NETIFY_SITE_UUID; // Helper function to get headers const getHeaders = () => { - const API_KEY = process.env.NETIFY_API_KEY; - const JWT_TOKEN = process.env.NETIFY_JWT_TOKEN; - const SITE_UUID = process.env.NETIFY_SITE_UUID; + const API_KEY = getApiKey(); + const JWT_TOKEN = getJwtToken(); + const SITE_UUID = getSiteUuid(); if (!API_KEY && !JWT_TOKEN) { - throw new Error("NETIFY_API_KEY or NETIFY_JWT_TOKEN is not set in environment variables"); + throw new Error("BACKONE_API_KEY or BACKONE_JWT_TOKEN is not set in environment variables"); } const headers: Record = { @@ -49,8 +54,8 @@ export interface Agent { export async function getAgents(): Promise { try { - const API_KEY = process.env.NETIFY_API_KEY; - const SITE_UUID = process.env.NETIFY_SITE_UUID; + const API_KEY = getApiKey(); + const SITE_UUID = getSiteUuid(); // Fallback to Informatics Scorecard Agent if site-scoped API key is used if (API_KEY && API_KEY.startsWith("sk_db_")) { @@ -182,7 +187,7 @@ export async function getAgents(): Promise { export async function getAgent(agentId: string): Promise { try { - const API_KEY = process.env.NETIFY_API_KEY; + const API_KEY = getApiKey(); if (API_KEY && API_KEY.startsWith("sk_db_")) { const agents = await getAgents(); return agents.find(a => a.uuid === agentId || String(a.id) === agentId) || null; @@ -208,7 +213,7 @@ export async function getAgent(agentId: string): Promise { export async function createAgent(agentId: string, label: string) { try { - const API_KEY = process.env.NETIFY_API_KEY; + const API_KEY = getApiKey(); if (API_KEY && API_KEY.startsWith("sk_db_")) { return { success: false, message: "Aksi ditolak: Site-scoped API Key tidak diperbolehkan membuat Agents." }; } @@ -236,7 +241,7 @@ export async function createAgent(agentId: string, label: string) { export async function updateAgent(agentId: string, label: string) { try { - const API_KEY = process.env.NETIFY_API_KEY; + const API_KEY = getApiKey(); if (API_KEY && API_KEY.startsWith("sk_db_")) { return { success: false, message: "Aksi ditolak: Site-scoped API Key tidak diperbolehkan mengubah Agents." }; } @@ -260,7 +265,7 @@ export async function updateAgent(agentId: string, label: string) { export async function deleteAgent(agentId: string) { try { - const API_KEY = process.env.NETIFY_API_KEY; + const API_KEY = getApiKey(); if (API_KEY && API_KEY.startsWith("sk_db_")) { return { success: false, message: "Aksi ditolak: Site-scoped API Key tidak diperbolehkan menghapus Agents." }; }