Merge branch 'develop' into 'main'

Develop

See merge request digiresilience/link/link-stack!10
This commit is contained in:
Darren Clarke 2024-09-09 07:28:45 +00:00
commit bfff5db155
35 changed files with 1537 additions and 1055 deletions

View file

@ -8,8 +8,9 @@ stages:
build-all: build-all:
stage: build stage: build
variables: variables:
TURBO_TOKEN: $TURBO_TOKEN TURBO_TOKEN: ${TURBO_TOKEN}
TURBO_TEAM: $TURBO_TEAM TURBO_TEAM: ${TURBO_TEAM}
ZAMMAD_URL: ${ZAMMAD_URL}
script: script:
- npm install npm@latest -g - npm install npm@latest -g
- npm install -g turbo - npm install -g turbo

View file

@ -1,6 +1,6 @@
{ {
"name": "@link-stack/bridge-frontend", "name": "@link-stack/bridge-frontend",
"version": "2.1.1", "version": "2.2.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",
@ -41,14 +41,14 @@
"react-dom": "18.3.1", "react-dom": "18.3.1",
"react-qr-code": "^2.0.15", "react-qr-code": "^2.0.15",
"react-timer-hook": "^3.0.7", "react-timer-hook": "^3.0.7",
"sharp": "^0.33.4", "sharp": "^0.33.5",
"tss-react": "^4.9.12", "tss-react": "^4.9.12",
"tsx": "^4.17.0", "tsx": "^4.19.0",
"@link-stack/ui": "*" "@link-stack/ui": "*"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^22", "@types/node": "^22",
"@types/pg": "^8.11.6", "@types/pg": "^8.11.8",
"@types/react": "^18", "@types/react": "^18",
"@types/react-dom": "^18", "@types/react-dom": "^18",
"@link-stack/eslint-config": "*", "@link-stack/eslint-config": "*",

View file

@ -1,6 +1,6 @@
{ {
"name": "@link-stack/bridge-migrations", "name": "@link-stack/bridge-migrations",
"version": "2.1.1", "version": "2.2.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"migrate:up:all": "tsx migrate.ts up:all", "migrate:up:all": "tsx migrate.ts up:all",
@ -12,11 +12,11 @@
"dotenv": "^16.4.5", "dotenv": "^16.4.5",
"kysely": "0.26.1", "kysely": "0.26.1",
"pg": "^8.12.0", "pg": "^8.12.0",
"tsx": "^4.17.0" "tsx": "^4.19.0"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^22", "@types/node": "^22",
"@types/pg": "^8.11.6", "@types/pg": "^8.11.8",
"@link-stack/eslint-config": "*", "@link-stack/eslint-config": "*",
"@link-stack/typescript-config": "*", "@link-stack/typescript-config": "*",
"typescript": "^5" "typescript": "^5"

View file

@ -1,6 +1,6 @@
{ {
"name": "@link-stack/bridge-whatsapp", "name": "@link-stack/bridge-whatsapp",
"version": "2.1.1", "version": "2.2.0",
"main": "build/main/index.js", "main": "build/main/index.js",
"author": "Darren Clarke <darren@redaranj.com>", "author": "Darren Clarke <darren@redaranj.com>",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
@ -10,7 +10,7 @@
"@hapi/hapi": "^21.3.10", "@hapi/hapi": "^21.3.10",
"@hapipal/schmervice": "^3.0.0", "@hapipal/schmervice": "^3.0.0",
"@hapipal/toys": "^4.0.0", "@hapipal/toys": "^4.0.0",
"@whiskeysockets/baileys": "^6.7.5", "@whiskeysockets/baileys": "^6.7.7",
"hapi-pino": "^12.1.0", "hapi-pino": "^12.1.0",
"link-preview-js": "^3.0.5" "link-preview-js": "^3.0.5"
}, },
@ -20,7 +20,7 @@
"@link-stack/typescript-config": "*", "@link-stack/typescript-config": "*",
"@types/node": "*", "@types/node": "*",
"dotenv-cli": "^7.4.2", "dotenv-cli": "^7.4.2",
"tsx": "^4.17.0", "tsx": "^4.19.0",
"typescript": "^5.5.4" "typescript": "^5.5.4"
}, },
"scripts": { "scripts": {

View file

@ -1 +1 @@
*/1 * * * * fetch-signal-messages ?max=1 */1 * * * * fetch-signal-messages ?max=1&id=fetchSignalMessagesCron {"scheduleTasks": "true"}

View file

@ -1,6 +1,6 @@
{ {
"name": "@link-stack/bridge-worker", "name": "@link-stack/bridge-worker",
"version": "2.1.1", "version": "2.2.0",
"type": "module", "type": "module",
"main": "build/main/index.js", "main": "build/main/index.js",
"author": "Darren Clarke <darren@redaranj.com>", "author": "Darren Clarke <darren@redaranj.com>",
@ -21,19 +21,19 @@
"kysely": "^0.27.3", "kysely": "^0.27.3",
"pg": "^8.12.0", "pg": "^8.12.0",
"remeda": "^2.11.0", "remeda": "^2.11.0",
"twilio": "^5.2.2" "twilio": "^5.2.3"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "7.25.2", "@babel/core": "7.25.2",
"@babel/preset-env": "7.25.3", "@babel/preset-env": "7.25.4",
"@babel/preset-typescript": "7.24.7", "@babel/preset-typescript": "7.24.7",
"@types/fluent-ffmpeg": "^2.1.25", "@types/fluent-ffmpeg": "^2.1.26",
"dotenv-cli": "^7.4.2", "dotenv-cli": "^7.4.2",
"@link-stack/eslint-config": "*", "@link-stack/eslint-config": "*",
"prettier": "^3.3.3", "prettier": "^3.3.3",
"@link-stack/typescript-config": "*", "@link-stack/typescript-config": "*",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"typedoc": "^0.26.5", "typedoc": "^0.26.6",
"typescript": "^5.5.4" "typescript": "^5.5.4"
} }
} }

View file

@ -1,41 +1,138 @@
import { db, getWorkerUtils } from "@link-stack/bridge-common"; import { db, getWorkerUtils } from "@link-stack/bridge-common";
import * as signalApi from "@link-stack/signal-api"; import * as signalApi from "@link-stack/signal-api";
const { Configuration, MessagesApi } = signalApi;
const fetchSignalMessagesTask = async (): Promise<void> => { const { Configuration, MessagesApi, AttachmentsApi } = signalApi;
const config = new Configuration({
basePath: process.env.BRIDGE_SIGNAL_URL,
});
const fetchAttachments = async (attachments: any[] | undefined) => {
const formattedAttachments = [];
if (attachments) {
const attachmentsClient = new AttachmentsApi(config);
for (const att of attachments) {
const { id, contentType, filename: name } = att;
const blob = await attachmentsClient.v1AttachmentsAttachmentGet({
attachment: id,
});
const arrayBuffer = await blob.arrayBuffer();
const base64Attachment = Buffer.from(arrayBuffer).toString("base64");
const formattedAttachment = {
filename: name,
mimeType: contentType,
attachment: base64Attachment,
};
formattedAttachments.push(formattedAttachment);
}
}
return formattedAttachments;
};
type ProcessMessageArgs = {
id: string;
phoneNumber: string;
message: any;
};
const processMessage = async ({
id,
phoneNumber,
message: msg,
}: ProcessMessageArgs): Promise<Record<string, any>[]> => {
const { envelope } = msg;
console.log(envelope);
const { source, sourceUuid, dataMessage } = envelope;
if (!dataMessage) return [];
const { attachments } = dataMessage;
const rawTimestamp = dataMessage?.timestamp;
const timestamp = new Date(rawTimestamp);
const formattedAttachments = await fetchAttachments(attachments);
const primaryAttachment = formattedAttachments[0] ?? {};
const additionalAttachments = formattedAttachments.slice(1);
const primaryMessage = {
token: id,
to: phoneNumber,
from: source,
messageId: `${sourceUuid}-${rawTimestamp}`,
message: dataMessage?.message,
sentAt: timestamp.toISOString(),
attachment: primaryAttachment.attachment,
filename: primaryAttachment.filename,
mimeType: primaryAttachment.mimeType,
};
const formattedMessages = [primaryMessage];
let count = 1;
for (const attachment of additionalAttachments) {
const additionalMessage = {
...primaryMessage,
...attachment,
message: attachment.filename,
messageId: `${sourceUuid}-${count}-${rawTimestamp}`,
};
formattedMessages.push(additionalMessage);
count++;
}
return formattedMessages;
};
interface FetchSignalMessagesTaskOptions {
scheduleTasks: string;
}
const fetchSignalMessagesTask = async ({
scheduleTasks = "false",
}: FetchSignalMessagesTaskOptions): Promise<void> => {
const worker = await getWorkerUtils(); const worker = await getWorkerUtils();
const rows = await db.selectFrom("SignalBot").selectAll().execute();
const config = new Configuration({ if (scheduleTasks === "true") {
basePath: process.env.BRIDGE_SIGNAL_URL, // because cron only has minimum 1 minute resolution
}); for (const offset of [15000, 30000, 45000]) {
await worker.addJob(
"fetch-signal-messages",
{ scheduleTasks: "false" },
{
maxAttempts: 1,
runAt: new Date(Date.now() + offset),
jobKey: `fetchSignalMessages-${offset}`,
},
);
}
}
const messagesClient = new MessagesApi(config); const messagesClient = new MessagesApi(config);
const rows = await db.selectFrom("SignalBot").selectAll().execute();
for (const row of rows) { for (const row of rows) {
const { id, phoneNumber: number } = row; const { id, phoneNumber } = row;
const messages = await messagesClient.v1ReceiveNumberGet({ number }); const messages = await messagesClient.v1ReceiveNumberGet({
number: phoneNumber,
});
for (const msg of messages) { for (const message of messages) {
const { envelope } = msg as any; const formattedMessages = await processMessage({
const { source, sourceUuid, dataMessage } = envelope; id,
const message = dataMessage?.message; phoneNumber,
const rawTimestamp = dataMessage?.timestamp; message,
const timestamp = new Date(rawTimestamp); });
const messageId = `${sourceUuid}-${rawTimestamp}`; console.log({ formattedMessages });
const attachment = undefined; for (const formattedMessage of formattedMessages) {
const mimeType = undefined; if (formattedMessage.to !== formattedMessage.from) {
const filename = undefined; await worker.addJob(
if (source !== number && message) { "signal/receive-signal-message",
await worker.addJob("signal/receive-signal-message", { formattedMessage,
token: id, );
to: number, }
from: source,
messageId,
message,
sentAt: timestamp.toISOString(),
attachment,
filename,
mimeType,
});
} }
} }
} }

View file

@ -1,6 +1,6 @@
{ {
"name": "@link-stack/leafcutter", "name": "@link-stack/leafcutter",
"version": "2.1.1", "version": "2.2.0",
"scripts": { "scripts": {
"dev": "next dev -p 3001", "dev": "next dev -p 3001",
"login": "aws sso login --sso-session cdr", "login": "aws sso login --sso-session cdr",
@ -38,17 +38,17 @@
"react-iframe": "^1.8.5", "react-iframe": "^1.8.5",
"react-markdown": "^9.0.1", "react-markdown": "^9.0.1",
"react-polyglot": "^0.7.2", "react-polyglot": "^0.7.2",
"sharp": "^0.33.4", "sharp": "^0.33.5",
"uuid": "^10.0.0" "uuid": "^10.0.0"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.25.2", "@babel/core": "^7.25.2",
"@types/node": "^22.2.0", "@types/node": "^22.5.2",
"@types/react": "18.3.3", "@types/react": "18.3.5",
"@types/uuid": "^10.0.0", "@types/uuid": "^10.0.0",
"babel-loader": "^9.1.3", "babel-loader": "^9.1.3",
"eslint": "^8.0.0", "eslint": "^8.0.0",
"eslint-config-next": "^14.2.5", "eslint-config-next": "^14.2.7",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1", "eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.9.0", "eslint-plugin-jsx-a11y": "^6.9.0",

View file

@ -18,6 +18,7 @@ RUN npm ci
COPY --from=builder ${APP_DIR}/out/full/ . COPY --from=builder ${APP_DIR}/out/full/ .
RUN npm i -g turbo RUN npm i -g turbo
ENV ZAMMAD_URL http://zammad-nginx:8080
RUN turbo run build --filter=@link-stack/link --filter=@link-stack/bridge-migrations RUN turbo run build --filter=@link-stack/link --filter=@link-stack/bridge-migrations
FROM base AS runner FROM base AS runner

View file

@ -202,7 +202,7 @@ export const Sidebar: FC<SidebarProps> = ({
fetchCounts(); fetchCounts();
const interval = setInterval(fetchCounts, 10000); const interval = setInterval(fetchCounts, 30000);
return () => clearInterval(interval); return () => clearInterval(interval);
}, []); }, []);

View file

@ -47,7 +47,7 @@ export const TicketDetail: FC<TicketDetailProps> = ({ id }) => {
fetchTicketArticles(); fetchTicketArticles();
const interval = setInterval(fetchTicketArticles, 2000); const interval = setInterval(fetchTicketArticles, 5000);
return () => clearInterval(interval); return () => clearInterval(interval);
}, [id]); }, [id]);

View file

@ -9,7 +9,7 @@ import { AdapterDateFns } from "@mui/x-date-pickers-pro/AdapterDateFnsV3";
import { LocalizationProvider } from "@mui/x-date-pickers-pro"; import { LocalizationProvider } from "@mui/x-date-pickers-pro";
import { LicenseInfo } from "@mui/x-license"; import { LicenseInfo } from "@mui/x-license";
import { locales, LeafcutterProvider } from "@link-stack/leafcutter-ui"; import { locales, LeafcutterProvider } from "@link-stack/leafcutter-ui";
import { CSRFProvider } from "./CSRFProvider"; import { ZammadLoginProvider } from "./ZammadLoginProvider";
LicenseInfo.setLicenseKey( LicenseInfo.setLicenseKey(
"c787ac6613c5f2aa0494c4285fe3e9f2Tz04OTY1NyxFPTE3NDYzNDE0ODkwMDAsUz1wcm8sTE09c3Vic2NyaXB0aW9uLEtWPTI=", "c787ac6613c5f2aa0494c4285fe3e9f2Tz04OTY1NyxFPTE3NDYzNDE0ODkwMDAsUz1wcm8sTE09c3Vic2NyaXB0aW9uLEtWPTI=",
@ -22,7 +22,7 @@ export const MultiProvider: FC<PropsWithChildren> = ({ children }) => {
return ( return (
<SessionProvider> <SessionProvider>
<CssBaseline /> <CssBaseline />
<CSRFProvider> <ZammadLoginProvider>
<CookiesProvider> <CookiesProvider>
<LocalizationProvider dateAdapter={AdapterDateFns}> <LocalizationProvider dateAdapter={AdapterDateFns}>
<I18n locale={locale} messages={messages[locale]}> <I18n locale={locale} messages={messages[locale]}>
@ -30,7 +30,7 @@ export const MultiProvider: FC<PropsWithChildren> = ({ children }) => {
</I18n> </I18n>
</LocalizationProvider> </LocalizationProvider>
</CookiesProvider> </CookiesProvider>
</CSRFProvider> </ZammadLoginProvider>
</SessionProvider> </SessionProvider>
); );
}; };

View file

@ -4,25 +4,19 @@ import { FC, PropsWithChildren, useEffect } from "react";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import { useSession } from "next-auth/react"; import { useSession } from "next-auth/react";
export const CSRFProvider: FC<PropsWithChildren> = ({ children }) => { export const ZammadLoginProvider: FC<PropsWithChildren> = ({ children }) => {
const { data: session, status, update } = useSession(); const { data: session, status, update } = useSession();
const router = useRouter(); const router = useRouter();
useEffect(() => { useEffect(() => {
const checkSession = async () => { const checkSession = async () => {
console.log("Checking session status...");
console.log(status);
if (status === "authenticated") { if (status === "authenticated") {
const response = await fetch("/api/v1/users/me", { const response = await fetch("/api/v1/users/me", {
method: "GET", method: "GET",
}); });
if (response.status !== 200 && !!router) { if (response.status !== 200) {
console.log("redirecting"); window.location.href = "/zammad/auth/sso";
window.location.href = "/auth/sso";
} else {
const token = response.headers.get("CSRF-Token");
update({ zammadCsrfToken: token });
} }
} }
}; };

View file

@ -101,30 +101,19 @@ export const authOptions: NextAuthOptions = {
callbacks: { callbacks: {
signIn: async ({ user }) => { signIn: async ({ user }) => {
const roles = (await getUserRoles(user.email)) ?? []; const roles = (await getUserRoles(user.email)) ?? [];
return ( return roles.includes("admin") || roles.includes("agent");
roles.includes("admin") ||
roles.includes("agent") ||
process.env.SETUP_MODE === "true"
);
}, },
session: async ({ session, token }) => { session: async ({ session, token }) => {
// @ts-ignore // @ts-ignore
session.user.roles = token.roles ?? []; session.user.roles = token.roles ?? [];
// @ts-ignore
session.user.leafcutter = token.leafcutter; // remove
// @ts-ignore
session.user.zammadCsrfToken = token.zammadCsrfToken;
return session; return session;
}, },
jwt: async ({ token, user, trigger, session }) => { jwt: async ({ token, user }) => {
if (user) { if (user) {
token.roles = (await getUserRoles(user.email)) ?? []; token.roles = (await getUserRoles(user.email)) ?? [];
} }
if (session && trigger === "update") {
token.zammadCsrfToken = session.zammadCsrfToken;
}
return token; return token;
}, },
}, },

View file

@ -1,5 +1,4 @@
import { getServerSession } from "app/_lib/authentication"; import { getServerSession } from "app/_lib/authentication";
import { redirect } from "next/navigation";
import { cookies } from "next/headers"; import { cookies } from "next/headers";
const getHeaders = async () => { const getHeaders = async () => {
@ -8,8 +7,6 @@ const getHeaders = async () => {
const headers = { const headers = {
"Content-Type": "application/json", "Content-Type": "application/json",
Accept: "application/json", Accept: "application/json",
// @ts-ignore
"X-CSRF-Token": session.user.zammadCsrfToken,
"X-Browser-Fingerprint": `${session.expires}`, "X-Browser-Fingerprint": `${session.expires}`,
Cookie: allCookies Cookie: allCookies
.map((cookie: any) => `${cookie.name}=${cookie.value}`) .map((cookie: any) => `${cookie.name}=${cookie.value}`)

View file

@ -4,6 +4,8 @@ import { AppRouterCacheProvider } from "@mui/material-nextjs/v14-appRouter";
import { MultiProvider } from "./_components/MultiProvider"; import { MultiProvider } from "./_components/MultiProvider";
import "./_styles/global.css"; import "./_styles/global.css";
export const dynamic = "force-dynamic";
export const metadata: Metadata = { export const metadata: Metadata = {
title: "CDR Link", title: "CDR Link",
}; };

View file

@ -10,11 +10,12 @@ const rewriteURL = (
const destinationURL = request.url.replace(originBaseURL, destinationBaseURL); const destinationURL = request.url.replace(originBaseURL, destinationBaseURL);
console.log(`Rewriting ${request.url} to ${destinationURL}`); console.log(`Rewriting ${request.url} to ${destinationURL}`);
const requestHeaders = new Headers(request.headers); const requestHeaders = new Headers(request.headers);
requestHeaders.delete("x-forwarded-user");
requestHeaders.delete("connection");
for (const [key, value] of Object.entries(headers)) { for (const [key, value] of Object.entries(headers)) {
requestHeaders.set(key, value as string); requestHeaders.set(key, value as string);
} }
requestHeaders.delete("connection");
return NextResponse.rewrite(new URL(destinationURL), { return NextResponse.rewrite(new URL(destinationURL), {
request: { headers: requestHeaders }, request: { headers: requestHeaders },
@ -24,11 +25,9 @@ const rewriteURL = (
const checkRewrites = async (request: NextRequestWithAuth) => { const checkRewrites = async (request: NextRequestWithAuth) => {
const linkBaseURL = process.env.LINK_URL ?? "http://localhost:3000"; const linkBaseURL = process.env.LINK_URL ?? "http://localhost:3000";
const zammadURL = process.env.ZAMMAD_URL ?? "http://zammad-nginx:8080"; const zammadURL = process.env.ZAMMAD_URL ?? "http://zammad-nginx:8080";
const opensearchDashboardsURL =
process.env.OPENSEARCH_DASHBOARDS_URL ?? "http://macmini:5601";
const zammadPaths = [ const zammadPaths = [
"/zammad", "/zammad",
"/api/v1",
"/auth/sso", "/auth/sso",
"/assets", "/assets",
"/mobile", "/mobile",
@ -39,28 +38,50 @@ const checkRewrites = async (request: NextRequestWithAuth) => {
const email = token?.email?.toLowerCase() ?? "unknown"; const email = token?.email?.toLowerCase() ?? "unknown";
let headers = { "x-forwarded-user": email }; let headers = { "x-forwarded-user": email };
if (request.nextUrl.pathname.startsWith("/dashboards")) { if (request.nextUrl.pathname.startsWith("/zammad")) {
const roles: string[] = (token?.roles as string[]) ?? [];
const leafcutterRole = roles.includes("admin")
? "leafcutter_admin"
: "leafcutter_user";
headers["x-forwarded-roles"] = leafcutterRole;
// headers["secruitytenant"] = "global";
// headers["x-forwarded-for"] = 'link';
return rewriteURL(
request,
`${linkBaseURL}/dashboards`,
opensearchDashboardsURL,
headers,
);
} else if (request.nextUrl.pathname.startsWith("/zammad")) {
return rewriteURL(request, `${linkBaseURL}/zammad`, zammadURL, headers); return rewriteURL(request, `${linkBaseURL}/zammad`, zammadURL, headers);
} else if (zammadPaths.some((p) => request.nextUrl.pathname.startsWith(p))) { } else if (zammadPaths.some((p) => request.nextUrl.pathname.startsWith(p))) {
return rewriteURL(request, linkBaseURL, zammadURL, headers); return rewriteURL(request, linkBaseURL, zammadURL, headers);
} } else {
const isDev = process.env.NODE_ENV === "development";
const nonce = Buffer.from(crypto.randomUUID()).toString("base64");
const cspHeader = `
default-src 'self';
connect-src 'self';
script-src 'self' 'nonce-${nonce}' 'strict-dynamic' ${isDev ? "'unsafe-eval'" : ""};
style-src 'self' 'unsafe-inline';
img-src 'self' blob: data:;
font-src 'self';
object-src 'none';
base-uri 'self';
form-action 'self';
frame-ancestors 'none';
upgrade-insecure-requests;
`;
const contentSecurityPolicyHeaderValue = cspHeader
.replace(/\s{2,}/g, " ")
.trim();
return NextResponse.next(); const requestHeaders = new Headers(request.headers);
requestHeaders.set("x-nonce", nonce);
requestHeaders.set(
"Content-Security-Policy",
contentSecurityPolicyHeaderValue,
);
const response = NextResponse.next({
request: {
headers: requestHeaders,
},
});
response.headers.set(
"Content-Security-Policy",
contentSecurityPolicyHeaderValue,
);
return response;
}
}; };
export default withAuth(checkRewrites, { export default withAuth(checkRewrites, {
@ -69,15 +90,11 @@ export default withAuth(checkRewrites, {
}, },
callbacks: { callbacks: {
authorized: ({ token, req }) => { authorized: ({ token, req }) => {
const path = req.nextUrl.pathname;
if (path.startsWith("/api/v1/")) {
return true;
}
if (process.env.SETUP_MODE === "true") { if (process.env.SETUP_MODE === "true") {
return true; return true;
} }
const path = req.nextUrl.pathname;
const roles: any = token?.roles ?? []; const roles: any = token?.roles ?? [];
if (path.startsWith("/admin") && !roles.includes("admin")) { if (path.startsWith("/admin") && !roles.includes("admin")) {
@ -94,7 +111,5 @@ export default withAuth(checkRewrites, {
}); });
export const config = { export const config = {
matcher: [ matcher: ["/((?!ws|wss|api|_next/static|_next/image|favicon.ico).*)"],
"/((?!ws|wss|api/signal|api/whatsapp|api/facebook|_next/static|_next/image|favicon.ico).*)",
],
}; };

View file

@ -6,13 +6,42 @@ const nextConfig = {
"@link-stack/ui", "@link-stack/ui",
"@link-stack/bridge-common", "@link-stack/bridge-common",
"@link-stack/bridge-ui", "@link-stack/bridge-ui",
"mui-chips-input" "mui-chips-input",
], ],
publicRuntimeConfig: { headers: async () => {
linkURL: process.env.LINK_URL ?? "http://localhost:3000", return [
bridgeURL: process.env.BRIDGE_URL ?? "http://localhost:8002", {
labelStudioURL: process.env.LABEL_STUDIO_URL ?? "http://localhost:8006", source: "/((?!zammad).*)",
muiLicenseKey: process.env.MUI_LICENSE_KEY ?? "", headers: [
{
key: "Strict-Transport-Security",
value: "max-age=63072000; includeSubDomains; preload",
},
{
key: "X-Frame-Options",
value: "DENY",
},
{
key: "X-Content-Type-Options",
value: "nosniff",
},
],
},
];
},
rewrites: async () => {
return {
beforeFiles: [
{
source: "/api/v1/:path*",
destination: `${process.env.ZAMMAD_URL ?? "http://zammad-nginx:8080"}/api/v1/:path*`,
},
{
source: "/ws",
destination: `${process.env.ZAMMAD_URL ?? "http://zammad-nginx:8080"}/ws`,
},
],
};
}, },
}; };

View file

@ -1,6 +1,6 @@
{ {
"name": "@link-stack/link", "name": "@link-stack/link",
"version": "2.1.1", "version": "2.2.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",
@ -13,7 +13,7 @@
"@chatscope/chat-ui-kit-react": "^2.0.3", "@chatscope/chat-ui-kit-react": "^2.0.3",
"@chatscope/chat-ui-kit-styles": "^1.4.0", "@chatscope/chat-ui-kit-styles": "^1.4.0",
"@emotion/cache": "^11.13.1", "@emotion/cache": "^11.13.1",
"@emotion/react": "^11.13.0", "@emotion/react": "^11.13.3",
"@emotion/server": "^11.11.0", "@emotion/server": "^11.11.0",
"@emotion/styled": "^11.13.0", "@emotion/styled": "^11.13.0",
"@link-stack/bridge-common": "*", "@link-stack/bridge-common": "*",

2144
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,13 +1,13 @@
{ {
"name": "@link-stack", "name": "@link-stack",
"version": "2.1.1", "version": "2.2.0",
"description": "Link from the Center for Digital Resilience", "description": "Link from the Center for Digital Resilience",
"scripts": { "scripts": {
"dev": "dotenv -- turbo dev", "dev": "dotenv -- turbo dev",
"build": "dotenv -- turbo build", "build": "dotenv -- turbo build",
"migrate": "dotenv -- npm run migrate --workspace=database", "migrate": "dotenv -- npm run migrate --workspace=database",
"lint": "dotenv turbo lint", "lint": "dotenv turbo lint",
"update-version": "find . -name 'package.json' -exec sed -i -E 's/\"version\": \"[^\"]+\"/\"version\": \"2.1.1\"/' {} +", "update-version": "find . -name 'package.json' -exec sed -i -E 's/\"version\": \"[^\"]+\"/\"version\": \"2.2.0\"/' {} +",
"upgrade:setup": "npm i -g npm-check-updates", "upgrade:setup": "npm i -g npm-check-updates",
"upgrade:check": "ncu && ncu -ws", "upgrade:check": "ncu && ncu -ws",
"upgrade": "ncu -u -x eslint -x kysely && ncu -ws -u -x eslint -x kysely && npm i", "upgrade": "ncu -u -x eslint -x kysely && ncu -ws -u -x eslint -x kysely && npm i",
@ -46,7 +46,7 @@
"type": "git", "type": "git",
"url": "git+https://gitlab.com/digiresilience/link/link-stack.git" "url": "git+https://gitlab.com/digiresilience/link/link-stack.git"
}, },
"packageManager": "npm@10.8.2", "packageManager": "npm@10.8.3",
"author": "Darren Clarke", "author": "Darren Clarke",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"devDependencies": { "devDependencies": {

View file

@ -1,6 +1,6 @@
{ {
"name": "@link-stack/bridge-common", "name": "@link-stack/bridge-common",
"version": "2.1.1", "version": "2.2.0",
"main": "build/main/index.js", "main": "build/main/index.js",
"type": "module", "type": "module",
"author": "Darren Clarke <darren@redaranj.com>", "author": "Darren Clarke <darren@redaranj.com>",
@ -16,11 +16,11 @@
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "7.25.2", "@babel/core": "7.25.2",
"@babel/preset-env": "7.25.3", "@babel/preset-env": "7.25.4",
"@babel/preset-typescript": "7.24.7", "@babel/preset-typescript": "7.24.7",
"prettier": "^3.3.3", "prettier": "^3.3.3",
"@link-stack/typescript-config": "*", "@link-stack/typescript-config": "*",
"tsx": "^4.17.0", "tsx": "^4.19.0",
"typescript": "^5.5.4" "typescript": "^5.5.4"
} }
} }

View file

@ -1,6 +1,6 @@
{ {
"name": "@link-stack/bridge-ui", "name": "@link-stack/bridge-ui",
"version": "2.1.1", "version": "2.2.0",
"scripts": { "scripts": {
"build": "tsc -p tsconfig.json" "build": "tsc -p tsconfig.json"
}, },
@ -32,13 +32,13 @@
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.25.2", "@babel/core": "^7.25.2",
"@types/node": "^22.2.0", "@types/node": "^22.5.2",
"@types/react": "18.3.3", "@types/react": "18.3.5",
"@types/react-dom": "^18.3.0", "@types/react-dom": "^18.3.0",
"@types/uuid": "^10.0.0", "@types/uuid": "^10.0.0",
"babel-loader": "^9.1.3", "babel-loader": "^9.1.3",
"eslint": "^8.0.0", "eslint": "^8.0.0",
"eslint-config-next": "^14.2.5", "eslint-config-next": "^14.2.7",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1", "eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.9.0", "eslint-plugin-jsx-a11y": "^6.9.0",

View file

@ -1,6 +1,6 @@
{ {
"name": "@link-stack/eslint-config", "name": "@link-stack/eslint-config",
"version": "2.1.1", "version": "2.2.0",
"description": "amigo's eslint config", "description": "amigo's eslint config",
"author": "Abel Luck <abel@guardianproject.info>", "author": "Abel Luck <abel@guardianproject.info>",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
@ -10,14 +10,14 @@
}, },
"dependencies": { "dependencies": {
"@rushstack/eslint-patch": "^1.10.4", "@rushstack/eslint-patch": "^1.10.4",
"@typescript-eslint/eslint-plugin": "^8.1.0", "@typescript-eslint/eslint-plugin": "^8.3.0",
"@typescript-eslint/parser": "^8.1.0", "@typescript-eslint/parser": "^8.3.0",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"eslint-config-xo-space": "^0.35.0", "eslint-config-xo-space": "^0.35.0",
"eslint-plugin-cypress": "^3.5.0", "eslint-plugin-cypress": "^3.5.0",
"eslint-plugin-eslint-comments": "^3.2.0", "eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.29.1", "eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^28.8.0", "eslint-plugin-jest": "^28.8.2",
"eslint-plugin-promise": "^7.1.0", "eslint-plugin-promise": "^7.1.0",
"eslint-plugin-unicorn": "55.0.0", "eslint-plugin-unicorn": "55.0.0",
"@babel/eslint-parser": "7.25.1" "@babel/eslint-parser": "7.25.1"

View file

@ -1,6 +1,6 @@
{ {
"name": "@link-stack/jest-config", "name": "@link-stack/jest-config",
"version": "2.1.1", "version": "2.2.0",
"description": "", "description": "",
"author": "Abel Luck <abel@guardianproject.info>", "author": "Abel Luck <abel@guardianproject.info>",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",

View file

@ -1,6 +1,6 @@
{ {
"name": "@link-stack/leafcutter-ui", "name": "@link-stack/leafcutter-ui",
"version": "2.1.1", "version": "2.2.0",
"scripts": { "scripts": {
"build": "tsc -p tsconfig.json" "build": "tsc -p tsconfig.json"
}, },
@ -29,12 +29,12 @@
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.25.2", "@babel/core": "^7.25.2",
"@types/node": "^22.2.0", "@types/node": "^22.5.2",
"@types/react": "18.3.3", "@types/react": "18.3.5",
"@types/uuid": "^10.0.0", "@types/uuid": "^10.0.0",
"babel-loader": "^9.1.3", "babel-loader": "^9.1.3",
"eslint": "^8.0.0", "eslint": "^8.0.0",
"eslint-config-next": "^14.2.5", "eslint-config-next": "^14.2.7",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1", "eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.9.0", "eslint-plugin-jsx-a11y": "^6.9.0",

View file

@ -1,17 +1,17 @@
{ {
"name": "@link-stack/opensearch-common", "name": "@link-stack/opensearch-common",
"version": "2.1.1", "version": "2.2.0",
"scripts": { "scripts": {
"build": "tsc -p tsconfig.json" "build": "tsc -p tsconfig.json"
}, },
"dependencies": { "dependencies": {
"@opensearch-project/opensearch": "^2.11.0", "@opensearch-project/opensearch": "^2.12.0",
"uuid": "^10.0.0" "uuid": "^10.0.0"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.25.2", "@babel/core": "^7.25.2",
"@types/node": "^22.2.0", "@types/node": "^22.5.2",
"@types/react": "18.3.3", "@types/react": "18.3.5",
"@types/uuid": "^10.0.0", "@types/uuid": "^10.0.0",
"babel-loader": "^9.1.3", "babel-loader": "^9.1.3",
"@link-stack/typescript-config": "*", "@link-stack/typescript-config": "*",

View file

@ -89,7 +89,7 @@ export class AttachmentsApi extends runtime.BaseAPI {
async v1AttachmentsAttachmentGetRaw( async v1AttachmentsAttachmentGetRaw(
requestParameters: V1AttachmentsAttachmentGetRequest, requestParameters: V1AttachmentsAttachmentGetRequest,
initOverrides?: RequestInit | runtime.InitOverrideFunction, initOverrides?: RequestInit | runtime.InitOverrideFunction,
): Promise<runtime.ApiResponse<string>> { ): Promise<runtime.ApiResponse<Blob>> {
if (requestParameters["attachment"] == null) { if (requestParameters["attachment"] == null) {
throw new runtime.RequiredError( throw new runtime.RequiredError(
"attachment", "attachment",
@ -114,11 +114,7 @@ export class AttachmentsApi extends runtime.BaseAPI {
initOverrides, initOverrides,
); );
if (this.isJsonMime(response.headers.get("content-type"))) { return new runtime.BlobApiResponse(response) as any;
return new runtime.JSONApiResponse<string>(response);
} else {
return new runtime.TextApiResponse(response) as any;
}
} }
/** /**
@ -128,7 +124,7 @@ export class AttachmentsApi extends runtime.BaseAPI {
async v1AttachmentsAttachmentGet( async v1AttachmentsAttachmentGet(
requestParameters: V1AttachmentsAttachmentGetRequest, requestParameters: V1AttachmentsAttachmentGetRequest,
initOverrides?: RequestInit | runtime.InitOverrideFunction, initOverrides?: RequestInit | runtime.InitOverrideFunction,
): Promise<string> { ): Promise<Blob> {
const response = await this.v1AttachmentsAttachmentGetRaw( const response = await this.v1AttachmentsAttachmentGetRaw(
requestParameters, requestParameters,
initOverrides, initOverrides,

View file

@ -1,6 +1,6 @@
{ {
"name": "@link-stack/signal-api", "name": "@link-stack/signal-api",
"version": "2.1.1", "version": "2.2.0",
"type": "module", "type": "module",
"main": "build/index.js", "main": "build/index.js",
"exports": { "exports": {
@ -12,7 +12,7 @@
"update-api": "openapi-generator-cli generate -i 'https://bbernhard.github.io/signal-cli-rest-api/src/docs/swagger.json' -g typescript-fetch -o . --skip-validate-spec" "update-api": "openapi-generator-cli generate -i 'https://bbernhard.github.io/signal-cli-rest-api/src/docs/swagger.json' -g typescript-fetch -o . --skip-validate-spec"
}, },
"devDependencies": { "devDependencies": {
"@openapitools/openapi-generator-cli": "^2.13.4", "@openapitools/openapi-generator-cli": "^2.13.5",
"@link-stack/typescript-config": "*", "@link-stack/typescript-config": "*",
"@link-stack/eslint-config": "*", "@link-stack/eslint-config": "*",
"@types/node": "^22", "@types/node": "^22",

View file

@ -1,6 +1,6 @@
{ {
"name": "@link-stack/typescript-config", "name": "@link-stack/typescript-config",
"version": "2.1.1", "version": "2.2.0",
"description": "Shared TypeScript config", "description": "Shared TypeScript config",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"author": "Abel Luck <abel@guardianproject.info>", "author": "Abel Luck <abel@guardianproject.info>",

View file

@ -1,6 +1,6 @@
{ {
"name": "@link-stack/ui", "name": "@link-stack/ui",
"version": "2.1.1", "version": "2.2.0",
"description": "", "description": "",
"scripts": { "scripts": {
"build": "tsc -p tsconfig.json" "build": "tsc -p tsconfig.json"

View file

@ -1,7 +1,7 @@
{ {
"name": "@link-stack/zammad-addon-bridge", "name": "@link-stack/zammad-addon-bridge",
"displayName": "Bridge", "displayName": "Bridge",
"version": "2.1.1", "version": "2.2.0",
"description": "An addon that adds CDR Bridge channels to Zammad.", "description": "An addon that adds CDR Bridge channels to Zammad.",
"scripts": { "scripts": {
"build": "node '../../node_modules/@link-stack/zammad-addon-common/dist/build.js'", "build": "node '../../node_modules/@link-stack/zammad-addon-common/dist/build.js'",

View file

@ -1,6 +1,6 @@
{ {
"name": "@link-stack/zammad-addon-common", "name": "@link-stack/zammad-addon-common",
"version": "2.1.1", "version": "2.2.0",
"description": "", "description": "",
"bin": { "bin": {
"zpm-build": "./dist/build.js", "zpm-build": "./dist/build.js",
@ -10,9 +10,12 @@
"build": "tsc" "build": "tsc"
}, },
"devDependencies": { "devDependencies": {
"typescript": "^5", "@types/node": "^22.5.2",
"@types/node": "^22" "typescript": "^5"
}, },
"author": "", "author": "",
"license": "AGPL-3.0-or-later" "license": "AGPL-3.0-or-later",
"dependencies": {
"glob": "^11.0.0"
}
} }

View file

@ -1,7 +1,7 @@
{ {
"name": "@link-stack/zammad-addon-hardening", "name": "@link-stack/zammad-addon-hardening",
"displayName": "Hardening", "displayName": "Hardening",
"version": "2.1.1", "version": "2.2.0",
"description": "A Zammad addon that hardens a Zammad instance according to CDR's needs.", "description": "A Zammad addon that hardens a Zammad instance according to CDR's needs.",
"scripts": { "scripts": {
"build": "node '../../node_modules/@link-stack/zammad-addon-common/dist/build.js'", "build": "node '../../node_modules/@link-stack/zammad-addon-common/dist/build.js'",

View file

@ -1,7 +1,7 @@
{ {
"name": "@link-stack/zammad-addon-leafcutter", "name": "@link-stack/zammad-addon-leafcutter",
"displayName": "Leafcutter", "displayName": "Leafcutter",
"version": "2.1.1", "version": "2.2.0",
"description": "Adds a common set of tags for Leafcutter uses.", "description": "Adds a common set of tags for Leafcutter uses.",
"scripts": { "scripts": {
"build": "node '../../node_modules/@link-stack/zammad-addon-common/dist/build.js'", "build": "node '../../node_modules/@link-stack/zammad-addon-common/dist/build.js'",