Merge branch 'develop' into 'main'
Develop See merge request digiresilience/link/link-stack!10
This commit is contained in:
commit
bfff5db155
35 changed files with 1537 additions and 1055 deletions
|
|
@ -8,8 +8,9 @@ stages:
|
|||
build-all:
|
||||
stage: build
|
||||
variables:
|
||||
TURBO_TOKEN: $TURBO_TOKEN
|
||||
TURBO_TEAM: $TURBO_TEAM
|
||||
TURBO_TOKEN: ${TURBO_TOKEN}
|
||||
TURBO_TEAM: ${TURBO_TEAM}
|
||||
ZAMMAD_URL: ${ZAMMAD_URL}
|
||||
script:
|
||||
- npm install npm@latest -g
|
||||
- npm install -g turbo
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/bridge-frontend",
|
||||
"version": "2.1.1",
|
||||
"version": "2.2.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
|
@ -41,14 +41,14 @@
|
|||
"react-dom": "18.3.1",
|
||||
"react-qr-code": "^2.0.15",
|
||||
"react-timer-hook": "^3.0.7",
|
||||
"sharp": "^0.33.4",
|
||||
"sharp": "^0.33.5",
|
||||
"tss-react": "^4.9.12",
|
||||
"tsx": "^4.17.0",
|
||||
"tsx": "^4.19.0",
|
||||
"@link-stack/ui": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22",
|
||||
"@types/pg": "^8.11.6",
|
||||
"@types/pg": "^8.11.8",
|
||||
"@types/react": "^18",
|
||||
"@types/react-dom": "^18",
|
||||
"@link-stack/eslint-config": "*",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/bridge-migrations",
|
||||
"version": "2.1.1",
|
||||
"version": "2.2.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"migrate:up:all": "tsx migrate.ts up:all",
|
||||
|
|
@ -12,11 +12,11 @@
|
|||
"dotenv": "^16.4.5",
|
||||
"kysely": "0.26.1",
|
||||
"pg": "^8.12.0",
|
||||
"tsx": "^4.17.0"
|
||||
"tsx": "^4.19.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22",
|
||||
"@types/pg": "^8.11.6",
|
||||
"@types/pg": "^8.11.8",
|
||||
"@link-stack/eslint-config": "*",
|
||||
"@link-stack/typescript-config": "*",
|
||||
"typescript": "^5"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/bridge-whatsapp",
|
||||
"version": "2.1.1",
|
||||
"version": "2.2.0",
|
||||
"main": "build/main/index.js",
|
||||
"author": "Darren Clarke <darren@redaranj.com>",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
"@hapi/hapi": "^21.3.10",
|
||||
"@hapipal/schmervice": "^3.0.0",
|
||||
"@hapipal/toys": "^4.0.0",
|
||||
"@whiskeysockets/baileys": "^6.7.5",
|
||||
"@whiskeysockets/baileys": "^6.7.7",
|
||||
"hapi-pino": "^12.1.0",
|
||||
"link-preview-js": "^3.0.5"
|
||||
},
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
"@link-stack/typescript-config": "*",
|
||||
"@types/node": "*",
|
||||
"dotenv-cli": "^7.4.2",
|
||||
"tsx": "^4.17.0",
|
||||
"tsx": "^4.19.0",
|
||||
"typescript": "^5.5.4"
|
||||
},
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
*/1 * * * * fetch-signal-messages ?max=1
|
||||
*/1 * * * * fetch-signal-messages ?max=1&id=fetchSignalMessagesCron {"scheduleTasks": "true"}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/bridge-worker",
|
||||
"version": "2.1.1",
|
||||
"version": "2.2.0",
|
||||
"type": "module",
|
||||
"main": "build/main/index.js",
|
||||
"author": "Darren Clarke <darren@redaranj.com>",
|
||||
|
|
@ -21,19 +21,19 @@
|
|||
"kysely": "^0.27.3",
|
||||
"pg": "^8.12.0",
|
||||
"remeda": "^2.11.0",
|
||||
"twilio": "^5.2.2"
|
||||
"twilio": "^5.2.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.25.2",
|
||||
"@babel/preset-env": "7.25.3",
|
||||
"@babel/preset-env": "7.25.4",
|
||||
"@babel/preset-typescript": "7.24.7",
|
||||
"@types/fluent-ffmpeg": "^2.1.25",
|
||||
"@types/fluent-ffmpeg": "^2.1.26",
|
||||
"dotenv-cli": "^7.4.2",
|
||||
"@link-stack/eslint-config": "*",
|
||||
"prettier": "^3.3.3",
|
||||
"@link-stack/typescript-config": "*",
|
||||
"ts-node": "^10.9.2",
|
||||
"typedoc": "^0.26.5",
|
||||
"typedoc": "^0.26.6",
|
||||
"typescript": "^5.5.4"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,41 +1,138 @@
|
|||
import { db, getWorkerUtils } from "@link-stack/bridge-common";
|
||||
import * as signalApi from "@link-stack/signal-api";
|
||||
const { Configuration, MessagesApi } = signalApi;
|
||||
|
||||
const fetchSignalMessagesTask = async (): Promise<void> => {
|
||||
const worker = await getWorkerUtils();
|
||||
const rows = await db.selectFrom("SignalBot").selectAll().execute();
|
||||
const config = new Configuration({
|
||||
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 messagesClient = new MessagesApi(config);
|
||||
const arrayBuffer = await blob.arrayBuffer();
|
||||
const base64Attachment = Buffer.from(arrayBuffer).toString("base64");
|
||||
|
||||
for (const row of rows) {
|
||||
const { id, phoneNumber: number } = row;
|
||||
const messages = await messagesClient.v1ReceiveNumberGet({ number });
|
||||
const formattedAttachment = {
|
||||
filename: name,
|
||||
mimeType: contentType,
|
||||
attachment: base64Attachment,
|
||||
};
|
||||
|
||||
for (const msg of messages) {
|
||||
const { envelope } = msg as any;
|
||||
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;
|
||||
const message = dataMessage?.message;
|
||||
|
||||
if (!dataMessage) return [];
|
||||
|
||||
const { attachments } = dataMessage;
|
||||
const rawTimestamp = dataMessage?.timestamp;
|
||||
const timestamp = new Date(rawTimestamp);
|
||||
const messageId = `${sourceUuid}-${rawTimestamp}`;
|
||||
const attachment = undefined;
|
||||
const mimeType = undefined;
|
||||
const filename = undefined;
|
||||
if (source !== number && message) {
|
||||
await worker.addJob("signal/receive-signal-message", {
|
||||
|
||||
const formattedAttachments = await fetchAttachments(attachments);
|
||||
const primaryAttachment = formattedAttachments[0] ?? {};
|
||||
const additionalAttachments = formattedAttachments.slice(1);
|
||||
const primaryMessage = {
|
||||
token: id,
|
||||
to: number,
|
||||
to: phoneNumber,
|
||||
from: source,
|
||||
messageId,
|
||||
message,
|
||||
messageId: `${sourceUuid}-${rawTimestamp}`,
|
||||
message: dataMessage?.message,
|
||||
sentAt: timestamp.toISOString(),
|
||||
attachment,
|
||||
filename,
|
||||
mimeType,
|
||||
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();
|
||||
|
||||
if (scheduleTasks === "true") {
|
||||
// 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 rows = await db.selectFrom("SignalBot").selectAll().execute();
|
||||
|
||||
for (const row of rows) {
|
||||
const { id, phoneNumber } = row;
|
||||
const messages = await messagesClient.v1ReceiveNumberGet({
|
||||
number: phoneNumber,
|
||||
});
|
||||
|
||||
for (const message of messages) {
|
||||
const formattedMessages = await processMessage({
|
||||
id,
|
||||
phoneNumber,
|
||||
message,
|
||||
});
|
||||
console.log({ formattedMessages });
|
||||
for (const formattedMessage of formattedMessages) {
|
||||
if (formattedMessage.to !== formattedMessage.from) {
|
||||
await worker.addJob(
|
||||
"signal/receive-signal-message",
|
||||
formattedMessage,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/leafcutter",
|
||||
"version": "2.1.1",
|
||||
"version": "2.2.0",
|
||||
"scripts": {
|
||||
"dev": "next dev -p 3001",
|
||||
"login": "aws sso login --sso-session cdr",
|
||||
|
|
@ -38,17 +38,17 @@
|
|||
"react-iframe": "^1.8.5",
|
||||
"react-markdown": "^9.0.1",
|
||||
"react-polyglot": "^0.7.2",
|
||||
"sharp": "^0.33.4",
|
||||
"sharp": "^0.33.5",
|
||||
"uuid": "^10.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.25.2",
|
||||
"@types/node": "^22.2.0",
|
||||
"@types/react": "18.3.3",
|
||||
"@types/node": "^22.5.2",
|
||||
"@types/react": "18.3.5",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"babel-loader": "^9.1.3",
|
||||
"eslint": "^8.0.0",
|
||||
"eslint-config-next": "^14.2.5",
|
||||
"eslint-config-next": "^14.2.7",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-import": "^2.29.1",
|
||||
"eslint-plugin-jsx-a11y": "^6.9.0",
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ RUN npm ci
|
|||
|
||||
COPY --from=builder ${APP_DIR}/out/full/ .
|
||||
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
|
||||
|
||||
FROM base AS runner
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ export const Sidebar: FC<SidebarProps> = ({
|
|||
|
||||
fetchCounts();
|
||||
|
||||
const interval = setInterval(fetchCounts, 10000);
|
||||
const interval = setInterval(fetchCounts, 30000);
|
||||
|
||||
return () => clearInterval(interval);
|
||||
}, []);
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ export const TicketDetail: FC<TicketDetailProps> = ({ id }) => {
|
|||
|
||||
fetchTicketArticles();
|
||||
|
||||
const interval = setInterval(fetchTicketArticles, 2000);
|
||||
const interval = setInterval(fetchTicketArticles, 5000);
|
||||
|
||||
return () => clearInterval(interval);
|
||||
}, [id]);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import { AdapterDateFns } from "@mui/x-date-pickers-pro/AdapterDateFnsV3";
|
|||
import { LocalizationProvider } from "@mui/x-date-pickers-pro";
|
||||
import { LicenseInfo } from "@mui/x-license";
|
||||
import { locales, LeafcutterProvider } from "@link-stack/leafcutter-ui";
|
||||
import { CSRFProvider } from "./CSRFProvider";
|
||||
import { ZammadLoginProvider } from "./ZammadLoginProvider";
|
||||
|
||||
LicenseInfo.setLicenseKey(
|
||||
"c787ac6613c5f2aa0494c4285fe3e9f2Tz04OTY1NyxFPTE3NDYzNDE0ODkwMDAsUz1wcm8sTE09c3Vic2NyaXB0aW9uLEtWPTI=",
|
||||
|
|
@ -22,7 +22,7 @@ export const MultiProvider: FC<PropsWithChildren> = ({ children }) => {
|
|||
return (
|
||||
<SessionProvider>
|
||||
<CssBaseline />
|
||||
<CSRFProvider>
|
||||
<ZammadLoginProvider>
|
||||
<CookiesProvider>
|
||||
<LocalizationProvider dateAdapter={AdapterDateFns}>
|
||||
<I18n locale={locale} messages={messages[locale]}>
|
||||
|
|
@ -30,7 +30,7 @@ export const MultiProvider: FC<PropsWithChildren> = ({ children }) => {
|
|||
</I18n>
|
||||
</LocalizationProvider>
|
||||
</CookiesProvider>
|
||||
</CSRFProvider>
|
||||
</ZammadLoginProvider>
|
||||
</SessionProvider>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,25 +4,19 @@ import { FC, PropsWithChildren, useEffect } from "react";
|
|||
import { useRouter } from "next/navigation";
|
||||
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 router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
const checkSession = async () => {
|
||||
console.log("Checking session status...");
|
||||
console.log(status);
|
||||
if (status === "authenticated") {
|
||||
const response = await fetch("/api/v1/users/me", {
|
||||
method: "GET",
|
||||
});
|
||||
|
||||
if (response.status !== 200 && !!router) {
|
||||
console.log("redirecting");
|
||||
window.location.href = "/auth/sso";
|
||||
} else {
|
||||
const token = response.headers.get("CSRF-Token");
|
||||
update({ zammadCsrfToken: token });
|
||||
if (response.status !== 200) {
|
||||
window.location.href = "/zammad/auth/sso";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -101,30 +101,19 @@ export const authOptions: NextAuthOptions = {
|
|||
callbacks: {
|
||||
signIn: async ({ user }) => {
|
||||
const roles = (await getUserRoles(user.email)) ?? [];
|
||||
return (
|
||||
roles.includes("admin") ||
|
||||
roles.includes("agent") ||
|
||||
process.env.SETUP_MODE === "true"
|
||||
);
|
||||
return roles.includes("admin") || roles.includes("agent");
|
||||
},
|
||||
session: async ({ session, token }) => {
|
||||
// @ts-ignore
|
||||
session.user.roles = token.roles ?? [];
|
||||
// @ts-ignore
|
||||
session.user.leafcutter = token.leafcutter; // remove
|
||||
// @ts-ignore
|
||||
session.user.zammadCsrfToken = token.zammadCsrfToken;
|
||||
|
||||
return session;
|
||||
},
|
||||
jwt: async ({ token, user, trigger, session }) => {
|
||||
jwt: async ({ token, user }) => {
|
||||
if (user) {
|
||||
token.roles = (await getUserRoles(user.email)) ?? [];
|
||||
}
|
||||
|
||||
if (session && trigger === "update") {
|
||||
token.zammadCsrfToken = session.zammadCsrfToken;
|
||||
}
|
||||
return token;
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { getServerSession } from "app/_lib/authentication";
|
||||
import { redirect } from "next/navigation";
|
||||
import { cookies } from "next/headers";
|
||||
|
||||
const getHeaders = async () => {
|
||||
|
|
@ -8,8 +7,6 @@ const getHeaders = async () => {
|
|||
const headers = {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
// @ts-ignore
|
||||
"X-CSRF-Token": session.user.zammadCsrfToken,
|
||||
"X-Browser-Fingerprint": `${session.expires}`,
|
||||
Cookie: allCookies
|
||||
.map((cookie: any) => `${cookie.name}=${cookie.value}`)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import { AppRouterCacheProvider } from "@mui/material-nextjs/v14-appRouter";
|
|||
import { MultiProvider } from "./_components/MultiProvider";
|
||||
import "./_styles/global.css";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "CDR Link",
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,11 +10,12 @@ const rewriteURL = (
|
|||
const destinationURL = request.url.replace(originBaseURL, destinationBaseURL);
|
||||
console.log(`Rewriting ${request.url} to ${destinationURL}`);
|
||||
const requestHeaders = new Headers(request.headers);
|
||||
requestHeaders.delete("x-forwarded-user");
|
||||
requestHeaders.delete("connection");
|
||||
|
||||
for (const [key, value] of Object.entries(headers)) {
|
||||
requestHeaders.set(key, value as string);
|
||||
}
|
||||
requestHeaders.delete("connection");
|
||||
|
||||
return NextResponse.rewrite(new URL(destinationURL), {
|
||||
request: { headers: requestHeaders },
|
||||
|
|
@ -24,11 +25,9 @@ const rewriteURL = (
|
|||
const checkRewrites = async (request: NextRequestWithAuth) => {
|
||||
const linkBaseURL = process.env.LINK_URL ?? "http://localhost:3000";
|
||||
const zammadURL = process.env.ZAMMAD_URL ?? "http://zammad-nginx:8080";
|
||||
const opensearchDashboardsURL =
|
||||
process.env.OPENSEARCH_DASHBOARDS_URL ?? "http://macmini:5601";
|
||||
|
||||
const zammadPaths = [
|
||||
"/zammad",
|
||||
"/api/v1",
|
||||
"/auth/sso",
|
||||
"/assets",
|
||||
"/mobile",
|
||||
|
|
@ -39,28 +38,50 @@ const checkRewrites = async (request: NextRequestWithAuth) => {
|
|||
const email = token?.email?.toLowerCase() ?? "unknown";
|
||||
let headers = { "x-forwarded-user": email };
|
||||
|
||||
if (request.nextUrl.pathname.startsWith("/dashboards")) {
|
||||
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")) {
|
||||
if (request.nextUrl.pathname.startsWith("/zammad")) {
|
||||
return rewriteURL(request, `${linkBaseURL}/zammad`, zammadURL, headers);
|
||||
} else if (zammadPaths.some((p) => request.nextUrl.pathname.startsWith(p))) {
|
||||
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, {
|
||||
|
|
@ -69,15 +90,11 @@ export default withAuth(checkRewrites, {
|
|||
},
|
||||
callbacks: {
|
||||
authorized: ({ token, req }) => {
|
||||
const path = req.nextUrl.pathname;
|
||||
if (path.startsWith("/api/v1/")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (process.env.SETUP_MODE === "true") {
|
||||
return true;
|
||||
}
|
||||
|
||||
const path = req.nextUrl.pathname;
|
||||
const roles: any = token?.roles ?? [];
|
||||
|
||||
if (path.startsWith("/admin") && !roles.includes("admin")) {
|
||||
|
|
@ -94,7 +111,5 @@ export default withAuth(checkRewrites, {
|
|||
});
|
||||
|
||||
export const config = {
|
||||
matcher: [
|
||||
"/((?!ws|wss|api/signal|api/whatsapp|api/facebook|_next/static|_next/image|favicon.ico).*)",
|
||||
],
|
||||
matcher: ["/((?!ws|wss|api|_next/static|_next/image|favicon.ico).*)"],
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,13 +6,42 @@ const nextConfig = {
|
|||
"@link-stack/ui",
|
||||
"@link-stack/bridge-common",
|
||||
"@link-stack/bridge-ui",
|
||||
"mui-chips-input"
|
||||
"mui-chips-input",
|
||||
],
|
||||
publicRuntimeConfig: {
|
||||
linkURL: process.env.LINK_URL ?? "http://localhost:3000",
|
||||
bridgeURL: process.env.BRIDGE_URL ?? "http://localhost:8002",
|
||||
labelStudioURL: process.env.LABEL_STUDIO_URL ?? "http://localhost:8006",
|
||||
muiLicenseKey: process.env.MUI_LICENSE_KEY ?? "",
|
||||
headers: async () => {
|
||||
return [
|
||||
{
|
||||
source: "/((?!zammad).*)",
|
||||
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`,
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/link",
|
||||
"version": "2.1.1",
|
||||
"version": "2.2.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
"@chatscope/chat-ui-kit-react": "^2.0.3",
|
||||
"@chatscope/chat-ui-kit-styles": "^1.4.0",
|
||||
"@emotion/cache": "^11.13.1",
|
||||
"@emotion/react": "^11.13.0",
|
||||
"@emotion/react": "^11.13.3",
|
||||
"@emotion/server": "^11.11.0",
|
||||
"@emotion/styled": "^11.13.0",
|
||||
"@link-stack/bridge-common": "*",
|
||||
|
|
|
|||
2144
package-lock.json
generated
2144
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,13 +1,13 @@
|
|||
{
|
||||
"name": "@link-stack",
|
||||
"version": "2.1.1",
|
||||
"version": "2.2.0",
|
||||
"description": "Link from the Center for Digital Resilience",
|
||||
"scripts": {
|
||||
"dev": "dotenv -- turbo dev",
|
||||
"build": "dotenv -- turbo build",
|
||||
"migrate": "dotenv -- npm run migrate --workspace=database",
|
||||
"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:check": "ncu && ncu -ws",
|
||||
"upgrade": "ncu -u -x eslint -x kysely && ncu -ws -u -x eslint -x kysely && npm i",
|
||||
|
|
@ -46,7 +46,7 @@
|
|||
"type": "git",
|
||||
"url": "git+https://gitlab.com/digiresilience/link/link-stack.git"
|
||||
},
|
||||
"packageManager": "npm@10.8.2",
|
||||
"packageManager": "npm@10.8.3",
|
||||
"author": "Darren Clarke",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"devDependencies": {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/bridge-common",
|
||||
"version": "2.1.1",
|
||||
"version": "2.2.0",
|
||||
"main": "build/main/index.js",
|
||||
"type": "module",
|
||||
"author": "Darren Clarke <darren@redaranj.com>",
|
||||
|
|
@ -16,11 +16,11 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.25.2",
|
||||
"@babel/preset-env": "7.25.3",
|
||||
"@babel/preset-env": "7.25.4",
|
||||
"@babel/preset-typescript": "7.24.7",
|
||||
"prettier": "^3.3.3",
|
||||
"@link-stack/typescript-config": "*",
|
||||
"tsx": "^4.17.0",
|
||||
"tsx": "^4.19.0",
|
||||
"typescript": "^5.5.4"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/bridge-ui",
|
||||
"version": "2.1.1",
|
||||
"version": "2.2.0",
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.json"
|
||||
},
|
||||
|
|
@ -32,13 +32,13 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.25.2",
|
||||
"@types/node": "^22.2.0",
|
||||
"@types/react": "18.3.3",
|
||||
"@types/node": "^22.5.2",
|
||||
"@types/react": "18.3.5",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"babel-loader": "^9.1.3",
|
||||
"eslint": "^8.0.0",
|
||||
"eslint-config-next": "^14.2.5",
|
||||
"eslint-config-next": "^14.2.7",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-import": "^2.29.1",
|
||||
"eslint-plugin-jsx-a11y": "^6.9.0",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/eslint-config",
|
||||
"version": "2.1.1",
|
||||
"version": "2.2.0",
|
||||
"description": "amigo's eslint config",
|
||||
"author": "Abel Luck <abel@guardianproject.info>",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
|
|
@ -10,14 +10,14 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@rushstack/eslint-patch": "^1.10.4",
|
||||
"@typescript-eslint/eslint-plugin": "^8.1.0",
|
||||
"@typescript-eslint/parser": "^8.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.3.0",
|
||||
"@typescript-eslint/parser": "^8.3.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-config-xo-space": "^0.35.0",
|
||||
"eslint-plugin-cypress": "^3.5.0",
|
||||
"eslint-plugin-eslint-comments": "^3.2.0",
|
||||
"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-unicorn": "55.0.0",
|
||||
"@babel/eslint-parser": "7.25.1"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/jest-config",
|
||||
"version": "2.1.1",
|
||||
"version": "2.2.0",
|
||||
"description": "",
|
||||
"author": "Abel Luck <abel@guardianproject.info>",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/leafcutter-ui",
|
||||
"version": "2.1.1",
|
||||
"version": "2.2.0",
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.json"
|
||||
},
|
||||
|
|
@ -29,12 +29,12 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.25.2",
|
||||
"@types/node": "^22.2.0",
|
||||
"@types/react": "18.3.3",
|
||||
"@types/node": "^22.5.2",
|
||||
"@types/react": "18.3.5",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"babel-loader": "^9.1.3",
|
||||
"eslint": "^8.0.0",
|
||||
"eslint-config-next": "^14.2.5",
|
||||
"eslint-config-next": "^14.2.7",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-import": "^2.29.1",
|
||||
"eslint-plugin-jsx-a11y": "^6.9.0",
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
{
|
||||
"name": "@link-stack/opensearch-common",
|
||||
"version": "2.1.1",
|
||||
"version": "2.2.0",
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@opensearch-project/opensearch": "^2.11.0",
|
||||
"@opensearch-project/opensearch": "^2.12.0",
|
||||
"uuid": "^10.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.25.2",
|
||||
"@types/node": "^22.2.0",
|
||||
"@types/react": "18.3.3",
|
||||
"@types/node": "^22.5.2",
|
||||
"@types/react": "18.3.5",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"babel-loader": "^9.1.3",
|
||||
"@link-stack/typescript-config": "*",
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ export class AttachmentsApi extends runtime.BaseAPI {
|
|||
async v1AttachmentsAttachmentGetRaw(
|
||||
requestParameters: V1AttachmentsAttachmentGetRequest,
|
||||
initOverrides?: RequestInit | runtime.InitOverrideFunction,
|
||||
): Promise<runtime.ApiResponse<string>> {
|
||||
): Promise<runtime.ApiResponse<Blob>> {
|
||||
if (requestParameters["attachment"] == null) {
|
||||
throw new runtime.RequiredError(
|
||||
"attachment",
|
||||
|
|
@ -114,11 +114,7 @@ export class AttachmentsApi extends runtime.BaseAPI {
|
|||
initOverrides,
|
||||
);
|
||||
|
||||
if (this.isJsonMime(response.headers.get("content-type"))) {
|
||||
return new runtime.JSONApiResponse<string>(response);
|
||||
} else {
|
||||
return new runtime.TextApiResponse(response) as any;
|
||||
}
|
||||
return new runtime.BlobApiResponse(response) as any;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -128,7 +124,7 @@ export class AttachmentsApi extends runtime.BaseAPI {
|
|||
async v1AttachmentsAttachmentGet(
|
||||
requestParameters: V1AttachmentsAttachmentGetRequest,
|
||||
initOverrides?: RequestInit | runtime.InitOverrideFunction,
|
||||
): Promise<string> {
|
||||
): Promise<Blob> {
|
||||
const response = await this.v1AttachmentsAttachmentGetRaw(
|
||||
requestParameters,
|
||||
initOverrides,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/signal-api",
|
||||
"version": "2.1.1",
|
||||
"version": "2.2.0",
|
||||
"type": "module",
|
||||
"main": "build/index.js",
|
||||
"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"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@openapitools/openapi-generator-cli": "^2.13.4",
|
||||
"@openapitools/openapi-generator-cli": "^2.13.5",
|
||||
"@link-stack/typescript-config": "*",
|
||||
"@link-stack/eslint-config": "*",
|
||||
"@types/node": "^22",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/typescript-config",
|
||||
"version": "2.1.1",
|
||||
"version": "2.2.0",
|
||||
"description": "Shared TypeScript config",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"author": "Abel Luck <abel@guardianproject.info>",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/ui",
|
||||
"version": "2.1.1",
|
||||
"version": "2.2.0",
|
||||
"description": "",
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.json"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@link-stack/zammad-addon-bridge",
|
||||
"displayName": "Bridge",
|
||||
"version": "2.1.1",
|
||||
"version": "2.2.0",
|
||||
"description": "An addon that adds CDR Bridge channels to Zammad.",
|
||||
"scripts": {
|
||||
"build": "node '../../node_modules/@link-stack/zammad-addon-common/dist/build.js'",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/zammad-addon-common",
|
||||
"version": "2.1.1",
|
||||
"version": "2.2.0",
|
||||
"description": "",
|
||||
"bin": {
|
||||
"zpm-build": "./dist/build.js",
|
||||
|
|
@ -10,9 +10,12 @@
|
|||
"build": "tsc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5",
|
||||
"@types/node": "^22"
|
||||
"@types/node": "^22.5.2",
|
||||
"typescript": "^5"
|
||||
},
|
||||
"author": "",
|
||||
"license": "AGPL-3.0-or-later"
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"glob": "^11.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@link-stack/zammad-addon-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.",
|
||||
"scripts": {
|
||||
"build": "node '../../node_modules/@link-stack/zammad-addon-common/dist/build.js'",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@link-stack/zammad-addon-leafcutter",
|
||||
"displayName": "Leafcutter",
|
||||
"version": "2.1.1",
|
||||
"version": "2.2.0",
|
||||
"description": "Adds a common set of tags for Leafcutter uses.",
|
||||
"scripts": {
|
||||
"build": "node '../../node_modules/@link-stack/zammad-addon-common/dist/build.js'",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue