Merge branch 'main' into dev

This commit is contained in:
Owen
2025-08-10 10:16:47 -07:00
43 changed files with 898 additions and 346 deletions

View File

@@ -222,7 +222,7 @@ export async function listAccessTokens(
(resource) => resource.resourceId
);
let countQuery: any = db
const countQuery: any = db
.select({ count: count() })
.from(resources)
.where(inArray(resources.resourceId, accessibleResourceIds));

View File

@@ -48,7 +48,7 @@ export async function getAllRelays(
}
// Fetch exit node
let [exitNode] = await db.select().from(exitNodes).where(eq(exitNodes.publicKey, publicKey));
const [exitNode] = await db.select().from(exitNodes).where(eq(exitNodes.publicKey, publicKey));
if (!exitNode) {
return next(createHttpError(HttpCode.NOT_FOUND, "Exit node not found"));
}
@@ -63,7 +63,7 @@ export async function getAllRelays(
}
// Initialize mappings object for multi-peer support
let mappings: { [key: string]: ProxyMapping } = {};
const mappings: { [key: string]: ProxyMapping } = {};
// Process each site
for (const site of sitesRes) {

View File

@@ -112,7 +112,7 @@ export async function getConfig(
)
);
let peers = await Promise.all(
const peers = await Promise.all(
sitesRes.map(async (site) => {
if (site.type === "wireguard") {
return {

View File

@@ -68,7 +68,7 @@ export async function createOidcIdp(
);
}
let {
const {
clientId,
clientSecret,
authUrl,

View File

@@ -85,7 +85,7 @@ export async function updateOidcIdp(
}
const { idpId } = parsedParams.data;
let {
const {
clientId,
clientSecret,
authUrl,

View File

@@ -238,7 +238,7 @@ export async function validateOidcCallback(
const defaultRoleMapping = existingIdp.idp.defaultRoleMapping;
const defaultOrgMapping = existingIdp.idp.defaultOrgMapping;
let userOrgInfo: { orgId: string; roleId: number }[] = [];
const userOrgInfo: { orgId: string; roleId: number }[] = [];
for (const org of allOrgs) {
const [idpOrgRes] = await db
.select()
@@ -314,7 +314,7 @@ export async function validateOidcCallback(
let existingUserId = existingUser?.userId;
let orgUserCounts: { orgId: string; userCount: number }[] = [];
const orgUserCounts: { orgId: string; userCount: number }[] = [];
// sync the user with the orgs and roles
await db.transaction(async (trx) => {

View File

@@ -55,7 +55,7 @@ export const handleNewtPingRequestMessage: MessageHandler = async (context) => {
);
if (currentConnections.count >= maxConnections) {
return null
return null;
}
weight =

View File

@@ -37,7 +37,7 @@ export const startOfflineChecker = (): void => {
}, OFFLINE_CHECK_INTERVAL);
logger.info("Started offline checker interval");
}
};
/**
* Stops the background interval that checks for offline clients
@@ -48,7 +48,7 @@ export const stopOfflineChecker = (): void => {
offlineCheckerInterval = null;
logger.info("Stopped offline checker interval");
}
}
};
/**
* Handles ping messages from clients and responds with pong

View File

@@ -102,7 +102,7 @@ export const handleOlmRegisterMessage: MessageHandler = async (context) => {
.where(eq(clientSites.clientId, client.clientId));
// Prepare an array to store site configurations
let siteConfigurations = [];
const siteConfigurations = [];
logger.debug(`Found ${sitesData.length} sites for client ${client.clientId}`);
if (sitesData.length === 0) {

View File

@@ -35,7 +35,7 @@ const listResourceRulesSchema = z.object({
});
function queryResourceRules(resourceId: number) {
let baseQuery = db
const baseQuery = db
.select({
ruleId: resourceRules.ruleId,
resourceId: resourceRules.resourceId,
@@ -117,7 +117,7 @@ export async function listResourceRules(
const baseQuery = queryResourceRules(resourceId);
let countQuery = db
const countQuery = db
.select({ count: sql<number>`cast(count(*) as integer)` })
.from(resourceRules)
.where(eq(resourceRules.resourceId, resourceId));

View File

@@ -231,7 +231,7 @@ export async function listResources(
(resource) => resource.resourceId
);
let countQuery: any = db
const countQuery: any = db
.select({ count: count() })
.from(resources)
.where(inArray(resources.resourceId, accessibleResourceIds));

View File

@@ -100,7 +100,7 @@ export async function listRoles(
const { orgId } = parsedParams.data;
let countQuery: any = db
const countQuery: any = db
.select({ count: sql<number>`cast(count(*) as integer)` })
.from(roles)
.where(eq(roles.orgId, orgId));

View File

@@ -176,7 +176,7 @@ export async function listSites(
const accessibleSiteIds = accessibleSites.map((site) => site.siteId);
const baseQuery = querySites(orgId, accessibleSiteIds);
let countQuery = db
const countQuery = db
.select({ count: count() })
.from(sites)
.where(

View File

@@ -86,7 +86,7 @@ export async function pickSiteDefaults(
.where(eq(sites.exitNodeId, exitNode.exitNodeId));
// TODO: we need to lock this subnet for some time so someone else does not take it
let subnets = sitesQuery.map((site) => site.subnet).filter((subnet) => subnet !== null);
const subnets = sitesQuery.map((site) => site.subnet).filter((subnet) => subnet !== null);
// exclude the exit node address by replacing after the / with a site block size
subnets.push(
exitNode.address.replace(

View File

@@ -2,7 +2,7 @@ import { db } from "@server/db";
import { resources, targets } from "@server/db";
import { eq } from "drizzle-orm";
let currentBannedPorts: number[] = [];
const currentBannedPorts: number[] = [];
export async function pickPort(siteId: number): Promise<{
internalPort: number;
@@ -15,8 +15,8 @@ export async function pickPort(siteId: number): Promise<{
// TODO: is this all inefficient?
// Fetch targets for all resources of this site
let targetIps: string[] = [];
let targetInternalPorts: number[] = [];
const targetIps: string[] = [];
const targetInternalPorts: number[] = [];
await Promise.all(
resourcesRes.map(async (resource) => {
const targetsRes = await db

View File

@@ -35,7 +35,7 @@ const listTargetsSchema = z.object({
});
function queryTargets(resourceId: number) {
let baseQuery = db
const baseQuery = db
.select({
targetId: targets.targetId,
ip: targets.ip,
@@ -99,7 +99,7 @@ export async function listTargets(
const baseQuery = queryTargets(resourceId);
let countQuery = db
const countQuery = db
.select({ count: sql<number>`cast(count(*) as integer)` })
.from(targets)
.where(eq(targets.resourceId, resourceId));

View File

@@ -62,7 +62,7 @@ const wss: WebSocketServer = new WebSocketServer({ noServer: true });
const NODE_ID = uuidv4();
// Client tracking map (local to this node)
let connectedClients: Map<string, AuthenticatedWebSocket[]> = new Map();
const connectedClients: Map<string, AuthenticatedWebSocket[]> = new Map();
// Helper to get map key
const getClientMapKey = (clientId: string) => clientId;