Skip to content

Commit 91d3c9f

Browse files
authored
chore: change env vars (#919)
1 parent 37ecef2 commit 91d3c9f

8 files changed

Lines changed: 28 additions & 27 deletions

File tree

infrastructure/control-panel/src/lib/server/auth/allowlist.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { env } from '$env/dynamic/private';
1+
import { CONTROL_PANEL_ADMIN_ENAMES_FILE } from '$env/static/private';
22
import { readFile, stat } from 'node:fs/promises';
33
import { resolve } from 'node:path';
44

@@ -19,7 +19,7 @@ export function normalizeEName(value: string): string {
1919
}
2020

2121
function getAllowlistPath(): string {
22-
const configuredPath = env.CONTROL_PANEL_ADMIN_ENAMES_FILE?.trim();
22+
const configuredPath = CONTROL_PANEL_ADMIN_ENAMES_FILE?.trim();
2323
return resolve(process.cwd(), configuredPath || DEFAULT_ALLOWLIST_PATH);
2424
}
2525

infrastructure/control-panel/src/lib/server/auth/token.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { env } from '$env/dynamic/private';
1+
import { CONTROL_PANEL_JWT_SECRET } from '$env/static/private';
22
import { jwtVerify, SignJWT } from 'jose';
33

44
export const AUTH_COOKIE_NAME = 'control_panel_auth';
@@ -9,7 +9,7 @@ type AuthTokenPayload = {
99
};
1010

1111
function getJwtSecret(): Uint8Array {
12-
const secret = env.CONTROL_PANEL_JWT_SECRET || 'control-panel-dev-secret-change-me';
12+
const secret = CONTROL_PANEL_JWT_SECRET || 'control-panel-dev-secret-change-me';
1313
return new TextEncoder().encode(secret);
1414
}
1515

infrastructure/control-panel/src/lib/services/loki.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { env } from '$env/dynamic/private';
1+
import { LOKI_PASSWORD, LOKI_URL, LOKI_USERNAME } from '$env/static/private';
22

33
export interface LogEntry {
44
timestamp: string;
@@ -34,9 +34,9 @@ export class LokiService {
3434
private processedLogIds = new Set<string>(); // Track processed logs to prevent duplicates
3535

3636
constructor() {
37-
this.baseUrl = env.LOKI_URL || 'http://localhost:3100';
38-
this.username = env.LOKI_USERNAME || 'admin';
39-
this.password = env.LOKI_PASSWORD || 'admin';
37+
this.baseUrl = LOKI_URL || 'http://localhost:3100';
38+
this.username = LOKI_USERNAME || 'admin';
39+
this.password = LOKI_PASSWORD || 'admin';
4040
}
4141

4242
private getAuthHeaders() {

infrastructure/control-panel/src/lib/services/notificationService.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { env } from '$env/dynamic/private';
1+
import {
2+
NOTIFICATION_TRIGGER_PORT,
3+
NOTIFICATION_TRIGGER_URL,
4+
PROVISIONER_URL,
5+
PUBLIC_PROVISIONER_URL
6+
} from '$env/static/private';
27

38
export interface NotificationPayload {
49
title: string;
@@ -22,9 +27,9 @@ export interface SendResult {
2227
}
2328

2429
function getBaseUrl(): string {
25-
const url = env.NOTIFICATION_TRIGGER_URL;
30+
const url = NOTIFICATION_TRIGGER_URL;
2631
if (url) return url;
27-
const port = env.NOTIFICATION_TRIGGER_PORT || '3998';
32+
const port = NOTIFICATION_TRIGGER_PORT || '3998';
2833
return `http://localhost:${port}`;
2934
}
3035

@@ -49,9 +54,7 @@ export async function sendNotification(request: SendNotificationRequest): Promis
4954
}
5055

5156
export async function getDevicesWithTokens(): Promise<{ token: string; eName: string }[]> {
52-
const { env } = await import('$env/dynamic/private');
53-
const provisionerUrl =
54-
env.PUBLIC_PROVISIONER_URL || env.PROVISIONER_URL || 'http://localhost:3001';
57+
const provisionerUrl = PUBLIC_PROVISIONER_URL || PROVISIONER_URL || 'http://localhost:3001';
5558
try {
5659
const response = await fetch(`${provisionerUrl}/api/devices/list`, {
5760
signal: AbortSignal.timeout(10000)
@@ -68,9 +71,7 @@ export async function getDevicesWithTokens(): Promise<{ token: string; eName: st
6871
export async function getDevicesByEName(
6972
eName: string
7073
): Promise<{ token: string; eName: string }[]> {
71-
const { env } = await import('$env/dynamic/private');
72-
const provisionerUrl =
73-
env.PUBLIC_PROVISIONER_URL || env.PROVISIONER_URL || 'http://localhost:3001';
74+
const provisionerUrl = PUBLIC_PROVISIONER_URL || PROVISIONER_URL || 'http://localhost:3001';
7475
try {
7576
const response = await fetch(
7677
`${provisionerUrl}/api/devices/by-ename/${encodeURIComponent(eName)}`,

infrastructure/control-panel/src/lib/services/registry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { env } from '$env/dynamic/public';
1+
import { PUBLIC_REGISTRY_URL } from '$env/static/public';
22

33
export interface Platform {
44
name: string;
@@ -19,7 +19,7 @@ export class RegistryService {
1919
private baseUrl: string;
2020

2121
constructor() {
22-
this.baseUrl = env.PUBLIC_REGISTRY_URL || 'https://registry.w3ds.metastate.foundation';
22+
this.baseUrl = PUBLIC_REGISTRY_URL || 'https://registry.w3ds.metastate.foundation';
2323
}
2424

2525
async getEVaults(): Promise<RegistryVault[]> {

infrastructure/control-panel/src/routes/api/auth/offer/+server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { env } from '$env/dynamic/public';
1+
import { PUBLIC_CONTROL_PANEL_URL } from '$env/static/public';
22
import { json, type RequestHandler } from '@sveltejs/kit';
33
import { createAuthSession } from '$lib/server/auth/sessions';
44

55
export const GET: RequestHandler = async ({ url }) => {
66
const sessionId = createAuthSession();
7-
const baseUrl = env.PUBLIC_CONTROL_PANEL_URL || url.origin;
7+
const baseUrl = PUBLIC_CONTROL_PANEL_URL || url.origin;
88
const redirect = new URL('/api/auth', baseUrl).toString();
99
const platform = 'control-panel';
1010
const uri = `w3ds://auth?redirect=${encodeURIComponent(redirect)}&session=${encodeURIComponent(sessionId)}&platform=${encodeURIComponent(platform)}`;

infrastructure/control-panel/src/routes/api/evaults/+server.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { json } from '@sveltejs/kit';
22
import type { RequestHandler } from '@sveltejs/kit';
3-
import { env } from '$env/dynamic/public';
3+
import { PUBLIC_CONTROL_PANEL_URL, PUBLIC_REGISTRY_URL } from '$env/static/public';
44
import { registryService, type RegistryVault } from '$lib/services/registry';
55

66
const USER_ONTOLOGY_ID = '550e8400-e29b-41d4-a716-446655440000';
@@ -143,7 +143,7 @@ async function resolveVaultIdentity(
143143
}
144144

145145
async function requestPlatformToken(platform: string): Promise<string> {
146-
const registryUrl = env.PUBLIC_REGISTRY_URL || 'https://registry.staging.metastate.foundation';
146+
const registryUrl = PUBLIC_REGISTRY_URL || 'https://registry.staging.metastate.foundation';
147147
const response = await fetch(new URL('/platforms/certification', registryUrl).toString(), {
148148
method: 'POST',
149149
headers: {
@@ -167,7 +167,7 @@ async function requestPlatformToken(platform: string): Promise<string> {
167167

168168
export const GET: RequestHandler = async ({ url }) => {
169169
try {
170-
const platform = env.PUBLIC_CONTROL_PANEL_URL || url.origin;
170+
const platform = PUBLIC_CONTROL_PANEL_URL || url.origin;
171171
let token: string | undefined;
172172
try {
173173
token = await requestPlatformToken(platform);

infrastructure/control-panel/src/routes/api/references/+server.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { json } from '@sveltejs/kit';
22
import type { RequestHandler } from '@sveltejs/kit';
3-
import { env } from '$env/dynamic/private';
3+
import { EREPUTATION_BASE_URL, VISUALIZER_API_KEY } from '$env/static/private';
44

55
export const GET: RequestHandler = async () => {
6-
const baseUrl = env.EREPUTATION_BASE_URL || 'http://localhost:8765';
6+
const baseUrl = EREPUTATION_BASE_URL || 'http://localhost:8765';
77

88
try {
99
const controller = new AbortController();
1010
const timeout = setTimeout(() => controller.abort(), 5000);
1111
const response = await fetch(`${baseUrl}/api/references/all`, {
12-
headers: env.VISUALIZER_API_KEY ? { 'x-visualizer-key': env.VISUALIZER_API_KEY } : {},
12+
headers: VISUALIZER_API_KEY ? { 'x-visualizer-key': VISUALIZER_API_KEY } : {},
1313
signal: controller.signal
1414
});
1515
clearTimeout(timeout);

0 commit comments

Comments
 (0)