From a0fddf45590ee1b7af2c472fcd94526706d209fd Mon Sep 17 00:00:00 2001 From: coodos Date: Sat, 14 Mar 2026 15:30:28 +0530 Subject: [PATCH] chore: change env vars --- .../src/lib/server/auth/allowlist.ts | 4 ++-- .../src/lib/server/auth/token.ts | 4 ++-- .../control-panel/src/lib/services/loki.ts | 8 ++++---- .../src/lib/services/notificationService.ts | 19 ++++++++++--------- .../src/lib/services/registry.ts | 4 ++-- .../src/routes/api/auth/offer/+server.ts | 4 ++-- .../src/routes/api/evaults/+server.ts | 6 +++--- .../src/routes/api/references/+server.ts | 6 +++--- 8 files changed, 28 insertions(+), 27 deletions(-) diff --git a/infrastructure/control-panel/src/lib/server/auth/allowlist.ts b/infrastructure/control-panel/src/lib/server/auth/allowlist.ts index da0b3a288..2d7564024 100644 --- a/infrastructure/control-panel/src/lib/server/auth/allowlist.ts +++ b/infrastructure/control-panel/src/lib/server/auth/allowlist.ts @@ -1,4 +1,4 @@ -import { env } from '$env/dynamic/private'; +import { CONTROL_PANEL_ADMIN_ENAMES_FILE } from '$env/static/private'; import { readFile, stat } from 'node:fs/promises'; import { resolve } from 'node:path'; @@ -19,7 +19,7 @@ export function normalizeEName(value: string): string { } function getAllowlistPath(): string { - const configuredPath = env.CONTROL_PANEL_ADMIN_ENAMES_FILE?.trim(); + const configuredPath = CONTROL_PANEL_ADMIN_ENAMES_FILE?.trim(); return resolve(process.cwd(), configuredPath || DEFAULT_ALLOWLIST_PATH); } diff --git a/infrastructure/control-panel/src/lib/server/auth/token.ts b/infrastructure/control-panel/src/lib/server/auth/token.ts index 1e12d3160..9eac4c131 100644 --- a/infrastructure/control-panel/src/lib/server/auth/token.ts +++ b/infrastructure/control-panel/src/lib/server/auth/token.ts @@ -1,4 +1,4 @@ -import { env } from '$env/dynamic/private'; +import { CONTROL_PANEL_JWT_SECRET } from '$env/static/private'; import { jwtVerify, SignJWT } from 'jose'; export const AUTH_COOKIE_NAME = 'control_panel_auth'; @@ -9,7 +9,7 @@ type AuthTokenPayload = { }; function getJwtSecret(): Uint8Array { - const secret = env.CONTROL_PANEL_JWT_SECRET || 'control-panel-dev-secret-change-me'; + const secret = CONTROL_PANEL_JWT_SECRET || 'control-panel-dev-secret-change-me'; return new TextEncoder().encode(secret); } diff --git a/infrastructure/control-panel/src/lib/services/loki.ts b/infrastructure/control-panel/src/lib/services/loki.ts index 78144489a..d58b8997c 100644 --- a/infrastructure/control-panel/src/lib/services/loki.ts +++ b/infrastructure/control-panel/src/lib/services/loki.ts @@ -1,4 +1,4 @@ -import { env } from '$env/dynamic/private'; +import { LOKI_PASSWORD, LOKI_URL, LOKI_USERNAME } from '$env/static/private'; export interface LogEntry { timestamp: string; @@ -34,9 +34,9 @@ export class LokiService { private processedLogIds = new Set(); // Track processed logs to prevent duplicates constructor() { - this.baseUrl = env.LOKI_URL || 'http://localhost:3100'; - this.username = env.LOKI_USERNAME || 'admin'; - this.password = env.LOKI_PASSWORD || 'admin'; + this.baseUrl = LOKI_URL || 'http://localhost:3100'; + this.username = LOKI_USERNAME || 'admin'; + this.password = LOKI_PASSWORD || 'admin'; } private getAuthHeaders() { diff --git a/infrastructure/control-panel/src/lib/services/notificationService.ts b/infrastructure/control-panel/src/lib/services/notificationService.ts index 8c9c2dc1e..7ee0f9ac5 100644 --- a/infrastructure/control-panel/src/lib/services/notificationService.ts +++ b/infrastructure/control-panel/src/lib/services/notificationService.ts @@ -1,4 +1,9 @@ -import { env } from '$env/dynamic/private'; +import { + NOTIFICATION_TRIGGER_PORT, + NOTIFICATION_TRIGGER_URL, + PROVISIONER_URL, + PUBLIC_PROVISIONER_URL +} from '$env/static/private'; export interface NotificationPayload { title: string; @@ -22,9 +27,9 @@ export interface SendResult { } function getBaseUrl(): string { - const url = env.NOTIFICATION_TRIGGER_URL; + const url = NOTIFICATION_TRIGGER_URL; if (url) return url; - const port = env.NOTIFICATION_TRIGGER_PORT || '3998'; + const port = NOTIFICATION_TRIGGER_PORT || '3998'; return `http://localhost:${port}`; } @@ -49,9 +54,7 @@ export async function sendNotification(request: SendNotificationRequest): Promis } export async function getDevicesWithTokens(): Promise<{ token: string; eName: string }[]> { - const { env } = await import('$env/dynamic/private'); - const provisionerUrl = - env.PUBLIC_PROVISIONER_URL || env.PROVISIONER_URL || 'http://localhost:3001'; + const provisionerUrl = PUBLIC_PROVISIONER_URL || PROVISIONER_URL || 'http://localhost:3001'; try { const response = await fetch(`${provisionerUrl}/api/devices/list`, { signal: AbortSignal.timeout(10000) @@ -68,9 +71,7 @@ export async function getDevicesWithTokens(): Promise<{ token: string; eName: st export async function getDevicesByEName( eName: string ): Promise<{ token: string; eName: string }[]> { - const { env } = await import('$env/dynamic/private'); - const provisionerUrl = - env.PUBLIC_PROVISIONER_URL || env.PROVISIONER_URL || 'http://localhost:3001'; + const provisionerUrl = PUBLIC_PROVISIONER_URL || PROVISIONER_URL || 'http://localhost:3001'; try { const response = await fetch( `${provisionerUrl}/api/devices/by-ename/${encodeURIComponent(eName)}`, diff --git a/infrastructure/control-panel/src/lib/services/registry.ts b/infrastructure/control-panel/src/lib/services/registry.ts index 94516c68c..68ebc428d 100644 --- a/infrastructure/control-panel/src/lib/services/registry.ts +++ b/infrastructure/control-panel/src/lib/services/registry.ts @@ -1,4 +1,4 @@ -import { env } from '$env/dynamic/public'; +import { PUBLIC_REGISTRY_URL } from '$env/static/public'; export interface Platform { name: string; @@ -19,7 +19,7 @@ export class RegistryService { private baseUrl: string; constructor() { - this.baseUrl = env.PUBLIC_REGISTRY_URL || 'https://registry.w3ds.metastate.foundation'; + this.baseUrl = PUBLIC_REGISTRY_URL || 'https://registry.w3ds.metastate.foundation'; } async getEVaults(): Promise { diff --git a/infrastructure/control-panel/src/routes/api/auth/offer/+server.ts b/infrastructure/control-panel/src/routes/api/auth/offer/+server.ts index 5cf4ec6f6..3fd97bd8b 100644 --- a/infrastructure/control-panel/src/routes/api/auth/offer/+server.ts +++ b/infrastructure/control-panel/src/routes/api/auth/offer/+server.ts @@ -1,10 +1,10 @@ -import { env } from '$env/dynamic/public'; +import { PUBLIC_CONTROL_PANEL_URL } from '$env/static/public'; import { json, type RequestHandler } from '@sveltejs/kit'; import { createAuthSession } from '$lib/server/auth/sessions'; export const GET: RequestHandler = async ({ url }) => { const sessionId = createAuthSession(); - const baseUrl = env.PUBLIC_CONTROL_PANEL_URL || url.origin; + const baseUrl = PUBLIC_CONTROL_PANEL_URL || url.origin; const redirect = new URL('/api/auth', baseUrl).toString(); const platform = 'control-panel'; const uri = `w3ds://auth?redirect=${encodeURIComponent(redirect)}&session=${encodeURIComponent(sessionId)}&platform=${encodeURIComponent(platform)}`; diff --git a/infrastructure/control-panel/src/routes/api/evaults/+server.ts b/infrastructure/control-panel/src/routes/api/evaults/+server.ts index b7d864498..3dea2f0bd 100644 --- a/infrastructure/control-panel/src/routes/api/evaults/+server.ts +++ b/infrastructure/control-panel/src/routes/api/evaults/+server.ts @@ -1,6 +1,6 @@ import { json } from '@sveltejs/kit'; import type { RequestHandler } from '@sveltejs/kit'; -import { env } from '$env/dynamic/public'; +import { PUBLIC_CONTROL_PANEL_URL, PUBLIC_REGISTRY_URL } from '$env/static/public'; import { registryService, type RegistryVault } from '$lib/services/registry'; const USER_ONTOLOGY_ID = '550e8400-e29b-41d4-a716-446655440000'; @@ -143,7 +143,7 @@ async function resolveVaultIdentity( } async function requestPlatformToken(platform: string): Promise { - const registryUrl = env.PUBLIC_REGISTRY_URL || 'https://registry.staging.metastate.foundation'; + const registryUrl = PUBLIC_REGISTRY_URL || 'https://registry.staging.metastate.foundation'; const response = await fetch(new URL('/platforms/certification', registryUrl).toString(), { method: 'POST', headers: { @@ -167,7 +167,7 @@ async function requestPlatformToken(platform: string): Promise { export const GET: RequestHandler = async ({ url }) => { try { - const platform = env.PUBLIC_CONTROL_PANEL_URL || url.origin; + const platform = PUBLIC_CONTROL_PANEL_URL || url.origin; let token: string | undefined; try { token = await requestPlatformToken(platform); diff --git a/infrastructure/control-panel/src/routes/api/references/+server.ts b/infrastructure/control-panel/src/routes/api/references/+server.ts index 7f6d550ad..93245a208 100644 --- a/infrastructure/control-panel/src/routes/api/references/+server.ts +++ b/infrastructure/control-panel/src/routes/api/references/+server.ts @@ -1,15 +1,15 @@ import { json } from '@sveltejs/kit'; import type { RequestHandler } from '@sveltejs/kit'; -import { env } from '$env/dynamic/private'; +import { EREPUTATION_BASE_URL, VISUALIZER_API_KEY } from '$env/static/private'; export const GET: RequestHandler = async () => { - const baseUrl = env.EREPUTATION_BASE_URL || 'http://localhost:8765'; + const baseUrl = EREPUTATION_BASE_URL || 'http://localhost:8765'; try { const controller = new AbortController(); const timeout = setTimeout(() => controller.abort(), 5000); const response = await fetch(`${baseUrl}/api/references/all`, { - headers: env.VISUALIZER_API_KEY ? { 'x-visualizer-key': env.VISUALIZER_API_KEY } : {}, + headers: VISUALIZER_API_KEY ? { 'x-visualizer-key': VISUALIZER_API_KEY } : {}, signal: controller.signal }); clearTimeout(timeout);