Merge dev into fix/log-analytics-adjustments

This commit is contained in:
Fred KISSIE
2025-12-10 03:19:14 +01:00
parent 9db2feff77
commit d490cab48c
555 changed files with 9375 additions and 9287 deletions

View File

@@ -24,9 +24,9 @@ export type CreateNewtResponse = {
};
const createNewtSchema = z.strictObject({
newtId: z.string(),
secret: z.string()
});
newtId: z.string(),
secret: z.string()
});
export async function createNewt(
req: Request,
@@ -34,7 +34,6 @@ export async function createNewt(
next: NextFunction
): Promise<any> {
try {
const parsedBody = createNewtSchema.safeParse(req.body);
if (!parsedBody.success) {
return next(
@@ -58,7 +57,7 @@ export async function createNewt(
await db.insert(newts).values({
newtId: newtId,
secretHash,
dateCreated: moment().toISOString(),
dateCreated: moment().toISOString()
});
// give the newt their default permissions:
@@ -75,12 +74,12 @@ export async function createNewt(
data: {
newtId,
secret,
token,
token
},
success: true,
error: false,
message: "Newt created successfully",
status: HttpCode.OK,
status: HttpCode.OK
});
} catch (e) {
if (e instanceof SqliteError && e.code === "SQLITE_CONSTRAINT_UNIQUE") {

View File

@@ -22,6 +22,7 @@ import {
import { verifyPassword } from "@server/auth/password";
import logger from "@server/logger";
import config from "@server/lib/config";
import { APP_VERSION } from "@server/lib/consts";
export const olmGetTokenBodySchema = z.object({
olmId: z.string(),
@@ -205,10 +206,12 @@ export async function getOlmToken(
return response<{
token: string;
exitNodes: { publicKey: string; endpoint: string }[];
serverVersion: string;
}>(res, {
data: {
token: resToken,
exitNodes: exitNodesHpData
exitNodes: exitNodesHpData,
serverVersion: APP_VERSION
},
success: true,
error: false,

View File

@@ -61,9 +61,12 @@ export const startOlmOfflineChecker = (): void => {
// Send a disconnect message to the client if connected
try {
await sendTerminateClient(offlineClient.clientId, offlineClient.olmId); // terminate first
await sendTerminateClient(
offlineClient.clientId,
offlineClient.olmId
); // terminate first
// wait a moment to ensure the message is sent
await new Promise(resolve => setTimeout(resolve, 1000));
await new Promise((resolve) => setTimeout(resolve, 1000));
await disconnectClient(offlineClient.olmId);
} catch (error) {
logger.error(

View File

@@ -113,14 +113,14 @@ export const handleOlmServerPeerAddMessage: MessageHandler = async (
.select()
.from(clientSitesAssociationsCache)
.where(
and(
and(
eq(clientSitesAssociationsCache.clientId, client.clientId),
isNotNull(clientSitesAssociationsCache.endpoint),
eq(clientSitesAssociationsCache.publicKey, client.pubKey) // limit it to the current session its connected with otherwise the endpoint could be stale
)
);
// pick an endpoint
// pick an endpoint
for (const assoc of currentSessionSiteAssociationCaches) {
if (assoc.endpoint) {
endpoint = assoc.endpoint;

View File

@@ -8,4 +8,4 @@ export * from "./listUserOlms";
export * from "./deleteUserOlm";
export * from "./getUserOlm";
export * from "./handleOlmServerPeerAddMessage";
export * from "./handleOlmUnRelayMessage";
export * from "./handleOlmUnRelayMessage";