@kodelyth/synology-chat 2026.5.42 → 2026.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/klaw.plugin.json +22 -1
- package/package.json +18 -2
- package/api.ts +0 -3
- package/channel-plugin-api.ts +0 -1
- package/contract-api.ts +0 -1
- package/index.ts +0 -16
- package/setup-api.ts +0 -1
- package/setup-entry.ts +0 -9
- package/src/accounts.ts +0 -151
- package/src/approval-auth.test.ts +0 -17
- package/src/approval-auth.ts +0 -22
- package/src/channel.integration.test.ts +0 -204
- package/src/channel.test-mocks.ts +0 -176
- package/src/channel.test.ts +0 -693
- package/src/channel.ts +0 -435
- package/src/client.test.ts +0 -399
- package/src/client.ts +0 -326
- package/src/config-schema.ts +0 -11
- package/src/core.test.ts +0 -427
- package/src/gateway-runtime.ts +0 -212
- package/src/inbound-context.ts +0 -10
- package/src/inbound-event.ts +0 -175
- package/src/runtime.ts +0 -8
- package/src/security-audit.test.ts +0 -72
- package/src/security-audit.ts +0 -28
- package/src/security.ts +0 -107
- package/src/session-key.ts +0 -21
- package/src/setup-surface.ts +0 -334
- package/src/test-http-utils.ts +0 -75
- package/src/types.ts +0 -59
- package/src/webhook-handler.test.ts +0 -644
- package/src/webhook-handler.ts +0 -652
- package/tsconfig.json +0 -16
package/src/channel.ts
DELETED
|
@@ -1,435 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Synology Chat Channel Plugin for Klaw.
|
|
3
|
-
*
|
|
4
|
-
* Implements the ChannelPlugin interface following the LINE pattern.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { DEFAULT_ACCOUNT_ID } from "klaw/plugin-sdk/account-id";
|
|
8
|
-
import type { KlawConfig } from "klaw/plugin-sdk/account-resolution";
|
|
9
|
-
import {
|
|
10
|
-
createHybridChannelConfigAdapter,
|
|
11
|
-
createScopedDmSecurityResolver,
|
|
12
|
-
} from "klaw/plugin-sdk/channel-config-helpers";
|
|
13
|
-
import { createChatChannelPlugin, type ChannelPlugin } from "klaw/plugin-sdk/channel-core";
|
|
14
|
-
import { waitUntilAbort } from "klaw/plugin-sdk/channel-lifecycle";
|
|
15
|
-
import {
|
|
16
|
-
createMessageReceiptFromOutboundResults,
|
|
17
|
-
defineChannelMessageAdapter,
|
|
18
|
-
type MessageReceipt,
|
|
19
|
-
type MessageReceiptPartKind,
|
|
20
|
-
} from "klaw/plugin-sdk/channel-message";
|
|
21
|
-
import {
|
|
22
|
-
composeWarningCollectors,
|
|
23
|
-
createConditionalWarningCollector,
|
|
24
|
-
projectAccountConfigWarningCollector,
|
|
25
|
-
projectAccountWarningCollector,
|
|
26
|
-
} from "klaw/plugin-sdk/channel-policy";
|
|
27
|
-
import { createEmptyChannelDirectoryAdapter } from "klaw/plugin-sdk/directory-runtime";
|
|
28
|
-
import { normalizeLowercaseStringOrEmpty } from "klaw/plugin-sdk/string-coerce-runtime";
|
|
29
|
-
import { listAccountIds, resolveAccount } from "./accounts.js";
|
|
30
|
-
import { synologyChatApprovalAuth } from "./approval-auth.js";
|
|
31
|
-
import { sendMessage, sendFileUrl } from "./client.js";
|
|
32
|
-
import { SynologyChatChannelConfigSchema } from "./config-schema.js";
|
|
33
|
-
import {
|
|
34
|
-
collectSynologyGatewayRoutingWarnings,
|
|
35
|
-
registerSynologyWebhookRoute,
|
|
36
|
-
validateSynologyGatewayAccountStartup,
|
|
37
|
-
} from "./gateway-runtime.js";
|
|
38
|
-
import { collectSynologyChatSecurityAuditFindings } from "./security-audit.js";
|
|
39
|
-
import { synologyChatSetupAdapter, synologyChatSetupWizard } from "./setup-surface.js";
|
|
40
|
-
import type { ResolvedSynologyChatAccount } from "./types.js";
|
|
41
|
-
|
|
42
|
-
const CHANNEL_ID = "synology-chat";
|
|
43
|
-
|
|
44
|
-
const resolveSynologyChatDmPolicy = createScopedDmSecurityResolver<ResolvedSynologyChatAccount>({
|
|
45
|
-
channelKey: CHANNEL_ID,
|
|
46
|
-
resolvePolicy: (account) => account.dmPolicy,
|
|
47
|
-
resolveAllowFrom: (account) => account.allowedUserIds,
|
|
48
|
-
policyPathSuffix: "dmPolicy",
|
|
49
|
-
defaultPolicy: "allowlist",
|
|
50
|
-
approveHint: "klaw pairing approve synology-chat <code>",
|
|
51
|
-
normalizeEntry: (raw) => normalizeLowercaseStringOrEmpty(raw),
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
type SynologyChannelGatewayContext = {
|
|
55
|
-
cfg: KlawConfig;
|
|
56
|
-
accountId: string;
|
|
57
|
-
abortSignal: AbortSignal;
|
|
58
|
-
log?: {
|
|
59
|
-
info: (message: string) => void;
|
|
60
|
-
warn: (message: string) => void;
|
|
61
|
-
error: (message: string) => void;
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
type SynologyChannelOutboundContext = {
|
|
65
|
-
cfg: KlawConfig;
|
|
66
|
-
to: string;
|
|
67
|
-
text?: string;
|
|
68
|
-
mediaUrl?: string;
|
|
69
|
-
accountId?: string | null;
|
|
70
|
-
};
|
|
71
|
-
type SynologyChannelSendTextContext = SynologyChannelOutboundContext & { text: string };
|
|
72
|
-
type SynologyChannelSendMediaContext = SynologyChannelOutboundContext & { mediaUrl: string };
|
|
73
|
-
type SynologySecurityWarningContext = {
|
|
74
|
-
cfg: KlawConfig;
|
|
75
|
-
account: ResolvedSynologyChatAccount;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const synologyChatConfigAdapter = createHybridChannelConfigAdapter<ResolvedSynologyChatAccount>({
|
|
79
|
-
sectionKey: CHANNEL_ID,
|
|
80
|
-
listAccountIds,
|
|
81
|
-
resolveAccount,
|
|
82
|
-
defaultAccountId: () => DEFAULT_ACCOUNT_ID,
|
|
83
|
-
clearBaseFields: [
|
|
84
|
-
"token",
|
|
85
|
-
"incomingUrl",
|
|
86
|
-
"nasHost",
|
|
87
|
-
"webhookPath",
|
|
88
|
-
"dangerouslyAllowNameMatching",
|
|
89
|
-
"dangerouslyAllowInheritedWebhookPath",
|
|
90
|
-
"dmPolicy",
|
|
91
|
-
"allowedUserIds",
|
|
92
|
-
"rateLimitPerMinute",
|
|
93
|
-
"botName",
|
|
94
|
-
"allowInsecureSsl",
|
|
95
|
-
],
|
|
96
|
-
resolveAllowFrom: (account) => account.allowedUserIds,
|
|
97
|
-
formatAllowFrom: (allowFrom) =>
|
|
98
|
-
allowFrom.map((entry) => normalizeLowercaseStringOrEmpty(String(entry))).filter(Boolean),
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
const collectSynologyChatSecurityWarnings =
|
|
102
|
-
createConditionalWarningCollector<ResolvedSynologyChatAccount>(
|
|
103
|
-
(account) =>
|
|
104
|
-
!account.token &&
|
|
105
|
-
"- Synology Chat: token is not configured. The webhook will reject all requests.",
|
|
106
|
-
(account) =>
|
|
107
|
-
!account.incomingUrl &&
|
|
108
|
-
"- Synology Chat: incomingUrl is not configured. The bot cannot send replies.",
|
|
109
|
-
(account) =>
|
|
110
|
-
account.allowInsecureSsl &&
|
|
111
|
-
"- Synology Chat: SSL verification is disabled (allowInsecureSsl=true). Only use this for local NAS with self-signed certificates.",
|
|
112
|
-
(account) =>
|
|
113
|
-
account.dangerouslyAllowNameMatching &&
|
|
114
|
-
"- Synology Chat: dangerouslyAllowNameMatching=true re-enables mutable username/nickname recipient matching for replies. Prefer stable numeric user IDs.",
|
|
115
|
-
(account) =>
|
|
116
|
-
account.dangerouslyAllowInheritedWebhookPath &&
|
|
117
|
-
account.webhookPathSource === "inherited-base" &&
|
|
118
|
-
"- Synology Chat: dangerouslyAllowInheritedWebhookPath=true opts a named account into a shared inherited webhook path. Prefer an explicit per-account webhookPath.",
|
|
119
|
-
(account) =>
|
|
120
|
-
account.dmPolicy === "open" &&
|
|
121
|
-
account.allowedUserIds.length === 0 &&
|
|
122
|
-
'- Synology Chat: dmPolicy="open" with empty allowedUserIds blocks all senders. Add allowedUserIds=["*"] for public DMs or set explicit user IDs.',
|
|
123
|
-
(account) =>
|
|
124
|
-
account.dmPolicy === "open" &&
|
|
125
|
-
account.allowedUserIds.includes("*") &&
|
|
126
|
-
'- Synology Chat: dmPolicy="open" allows any user to message the bot. Consider "allowlist" for production use.',
|
|
127
|
-
(account) =>
|
|
128
|
-
account.dmPolicy === "allowlist" &&
|
|
129
|
-
account.allowedUserIds.length === 0 &&
|
|
130
|
-
'- Synology Chat: dmPolicy="allowlist" with empty allowedUserIds blocks all senders. Add users or set dmPolicy="open" with allowedUserIds=["*"].',
|
|
131
|
-
);
|
|
132
|
-
|
|
133
|
-
type SynologyChatOutboundResult = {
|
|
134
|
-
channel: typeof CHANNEL_ID;
|
|
135
|
-
messageId: string;
|
|
136
|
-
chatId: string;
|
|
137
|
-
receipt: MessageReceipt;
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
type SynologyChatPlugin = Omit<
|
|
141
|
-
ChannelPlugin<ResolvedSynologyChatAccount>,
|
|
142
|
-
"pairing" | "security" | "messaging" | "directory" | "outbound" | "gateway" | "agentPrompt"
|
|
143
|
-
> & {
|
|
144
|
-
pairing: {
|
|
145
|
-
idLabel: string;
|
|
146
|
-
normalizeAllowEntry?: (entry: string) => string;
|
|
147
|
-
notifyApproval: (params: { cfg: KlawConfig; id: string }) => Promise<void>;
|
|
148
|
-
};
|
|
149
|
-
security: {
|
|
150
|
-
resolveDmPolicy: (params: { cfg: KlawConfig; account: ResolvedSynologyChatAccount }) => {
|
|
151
|
-
policy: string | null | undefined;
|
|
152
|
-
allowFrom?: Array<string | number>;
|
|
153
|
-
normalizeEntry?: (raw: string) => string;
|
|
154
|
-
} | null;
|
|
155
|
-
collectWarnings: (params: {
|
|
156
|
-
cfg: KlawConfig;
|
|
157
|
-
account: ResolvedSynologyChatAccount;
|
|
158
|
-
}) => string[];
|
|
159
|
-
};
|
|
160
|
-
messaging: {
|
|
161
|
-
targetPrefixes?: readonly string[];
|
|
162
|
-
normalizeTarget: (target: string) => string | undefined;
|
|
163
|
-
targetResolver: {
|
|
164
|
-
looksLikeId: (id: string) => boolean;
|
|
165
|
-
hint: string;
|
|
166
|
-
};
|
|
167
|
-
};
|
|
168
|
-
directory: {
|
|
169
|
-
self?: NonNullable<ChannelPlugin<ResolvedSynologyChatAccount>["directory"]>["self"];
|
|
170
|
-
listPeers?: NonNullable<ChannelPlugin<ResolvedSynologyChatAccount>["directory"]>["listPeers"];
|
|
171
|
-
listGroups?: NonNullable<ChannelPlugin<ResolvedSynologyChatAccount>["directory"]>["listGroups"];
|
|
172
|
-
};
|
|
173
|
-
outbound: {
|
|
174
|
-
deliveryMode: "gateway";
|
|
175
|
-
textChunkLimit: number;
|
|
176
|
-
sendText: (ctx: SynologyChannelSendTextContext) => Promise<SynologyChatOutboundResult>;
|
|
177
|
-
sendMedia: (ctx: SynologyChannelSendMediaContext) => Promise<SynologyChatOutboundResult>;
|
|
178
|
-
};
|
|
179
|
-
message: typeof synologyChatMessageAdapter;
|
|
180
|
-
gateway: {
|
|
181
|
-
startAccount: (ctx: SynologyChannelGatewayContext) => Promise<unknown>;
|
|
182
|
-
stopAccount: (ctx: SynologyChannelGatewayContext) => Promise<void>;
|
|
183
|
-
};
|
|
184
|
-
agentPrompt: {
|
|
185
|
-
messageToolHints: () => string[];
|
|
186
|
-
};
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
const collectSynologyChatRoutingWarnings = projectAccountConfigWarningCollector<
|
|
190
|
-
ResolvedSynologyChatAccount,
|
|
191
|
-
KlawConfig,
|
|
192
|
-
SynologySecurityWarningContext
|
|
193
|
-
>(
|
|
194
|
-
(cfg) => cfg,
|
|
195
|
-
({ account, cfg }) => collectSynologyGatewayRoutingWarnings({ account, cfg }),
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
function resolveOutboundAccount(
|
|
199
|
-
cfg: KlawConfig,
|
|
200
|
-
accountId?: string | null,
|
|
201
|
-
): ResolvedSynologyChatAccount {
|
|
202
|
-
return resolveAccount(cfg ?? {}, accountId);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
function requireIncomingUrl(account: ResolvedSynologyChatAccount): string {
|
|
206
|
-
if (!account.incomingUrl) {
|
|
207
|
-
throw new Error("Synology Chat incoming URL not configured");
|
|
208
|
-
}
|
|
209
|
-
return account.incomingUrl;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
function createSynologyChatSendResult(params: {
|
|
213
|
-
messageId: string;
|
|
214
|
-
chatId: string;
|
|
215
|
-
kind: MessageReceiptPartKind;
|
|
216
|
-
}): SynologyChatOutboundResult {
|
|
217
|
-
return {
|
|
218
|
-
channel: CHANNEL_ID,
|
|
219
|
-
messageId: params.messageId,
|
|
220
|
-
chatId: params.chatId,
|
|
221
|
-
receipt: createMessageReceiptFromOutboundResults({
|
|
222
|
-
results: [
|
|
223
|
-
{
|
|
224
|
-
channel: CHANNEL_ID,
|
|
225
|
-
messageId: params.messageId,
|
|
226
|
-
chatId: params.chatId,
|
|
227
|
-
conversationId: params.chatId,
|
|
228
|
-
},
|
|
229
|
-
],
|
|
230
|
-
threadId: params.chatId,
|
|
231
|
-
kind: params.kind,
|
|
232
|
-
}),
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
async function sendSynologyChatText(
|
|
237
|
-
ctx: SynologyChannelSendTextContext,
|
|
238
|
-
): Promise<SynologyChatOutboundResult> {
|
|
239
|
-
const account = resolveOutboundAccount(ctx.cfg ?? {}, ctx.accountId);
|
|
240
|
-
const incomingUrl = requireIncomingUrl(account);
|
|
241
|
-
const ok = await sendMessage(incomingUrl, ctx.text, ctx.to, account.allowInsecureSsl);
|
|
242
|
-
if (!ok) {
|
|
243
|
-
throw new Error("Failed to send message to Synology Chat");
|
|
244
|
-
}
|
|
245
|
-
return createSynologyChatSendResult({
|
|
246
|
-
messageId: `sc-${Date.now()}`,
|
|
247
|
-
chatId: ctx.to,
|
|
248
|
-
kind: "text",
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
async function sendSynologyChatMedia(
|
|
253
|
-
ctx: SynologyChannelSendMediaContext,
|
|
254
|
-
): Promise<SynologyChatOutboundResult> {
|
|
255
|
-
const account = resolveOutboundAccount(ctx.cfg ?? {}, ctx.accountId);
|
|
256
|
-
const incomingUrl = requireIncomingUrl(account);
|
|
257
|
-
const ok = await sendFileUrl(incomingUrl, ctx.mediaUrl, ctx.to, account.allowInsecureSsl);
|
|
258
|
-
if (!ok) {
|
|
259
|
-
throw new Error("Failed to send media to Synology Chat");
|
|
260
|
-
}
|
|
261
|
-
return createSynologyChatSendResult({
|
|
262
|
-
messageId: `sc-${Date.now()}`,
|
|
263
|
-
chatId: ctx.to,
|
|
264
|
-
kind: "media",
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
export const synologyChatMessageAdapter = defineChannelMessageAdapter({
|
|
269
|
-
id: CHANNEL_ID,
|
|
270
|
-
durableFinal: {
|
|
271
|
-
capabilities: {
|
|
272
|
-
text: true,
|
|
273
|
-
media: true,
|
|
274
|
-
messageSendingHooks: true,
|
|
275
|
-
},
|
|
276
|
-
},
|
|
277
|
-
send: {
|
|
278
|
-
text: async (ctx) => await sendSynologyChatText(ctx),
|
|
279
|
-
media: async (ctx) => await sendSynologyChatMedia(ctx),
|
|
280
|
-
},
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
export function createSynologyChatPlugin(): SynologyChatPlugin {
|
|
284
|
-
return createChatChannelPlugin({
|
|
285
|
-
base: {
|
|
286
|
-
id: CHANNEL_ID,
|
|
287
|
-
meta: {
|
|
288
|
-
id: CHANNEL_ID,
|
|
289
|
-
label: "Synology Chat",
|
|
290
|
-
selectionLabel: "Synology Chat (Webhook)",
|
|
291
|
-
detailLabel: "Synology Chat (Webhook)",
|
|
292
|
-
docsPath: "/channels/synology-chat",
|
|
293
|
-
blurb: "Connect your Synology NAS Chat to Klaw",
|
|
294
|
-
order: 90,
|
|
295
|
-
},
|
|
296
|
-
capabilities: {
|
|
297
|
-
chatTypes: ["direct" as const],
|
|
298
|
-
media: true,
|
|
299
|
-
threads: false,
|
|
300
|
-
reactions: false,
|
|
301
|
-
edit: false,
|
|
302
|
-
unsend: false,
|
|
303
|
-
reply: false,
|
|
304
|
-
effects: false,
|
|
305
|
-
blockStreaming: false,
|
|
306
|
-
},
|
|
307
|
-
reload: { configPrefixes: [`channels.${CHANNEL_ID}`] },
|
|
308
|
-
configSchema: SynologyChatChannelConfigSchema,
|
|
309
|
-
setup: synologyChatSetupAdapter,
|
|
310
|
-
setupWizard: synologyChatSetupWizard,
|
|
311
|
-
config: {
|
|
312
|
-
...synologyChatConfigAdapter,
|
|
313
|
-
},
|
|
314
|
-
approvalCapability: synologyChatApprovalAuth,
|
|
315
|
-
messaging: {
|
|
316
|
-
targetPrefixes: ["synology-chat", "synology_chat", "synology"],
|
|
317
|
-
normalizeTarget: (target: string) => {
|
|
318
|
-
const trimmed = target.trim();
|
|
319
|
-
if (!trimmed) {
|
|
320
|
-
return undefined;
|
|
321
|
-
}
|
|
322
|
-
// Strip common prefixes
|
|
323
|
-
return trimmed.replace(/^synology(?:[-_]?chat)?:/i, "").trim();
|
|
324
|
-
},
|
|
325
|
-
targetResolver: {
|
|
326
|
-
looksLikeId: (id: string) => {
|
|
327
|
-
const trimmed = id?.trim();
|
|
328
|
-
if (!trimmed) {
|
|
329
|
-
return false;
|
|
330
|
-
}
|
|
331
|
-
// Synology Chat user IDs are numeric
|
|
332
|
-
return /^\d+$/.test(trimmed) || /^synology(?:[-_]?chat)?:/i.test(trimmed);
|
|
333
|
-
},
|
|
334
|
-
hint: "<userId>",
|
|
335
|
-
},
|
|
336
|
-
},
|
|
337
|
-
directory: createEmptyChannelDirectoryAdapter(),
|
|
338
|
-
gateway: {
|
|
339
|
-
startAccount: async (ctx: SynologyChannelGatewayContext) => {
|
|
340
|
-
const { cfg, accountId, log, abortSignal } = ctx;
|
|
341
|
-
const account = resolveAccount(cfg, accountId);
|
|
342
|
-
if (!validateSynologyGatewayAccountStartup({ cfg, account, accountId, log }).ok) {
|
|
343
|
-
return waitUntilAbort(abortSignal);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
log?.info?.(
|
|
347
|
-
`Starting Synology Chat channel (account: ${accountId}, path: ${account.webhookPath})`,
|
|
348
|
-
);
|
|
349
|
-
const unregister = registerSynologyWebhookRoute({ account, accountId, log });
|
|
350
|
-
|
|
351
|
-
log?.info?.(`Registered HTTP route: ${account.webhookPath} for Synology Chat`);
|
|
352
|
-
|
|
353
|
-
// Keep alive until abort signal fires.
|
|
354
|
-
// The gateway expects a Promise that stays pending while the channel is running.
|
|
355
|
-
// Resolving immediately triggers a restart loop.
|
|
356
|
-
return waitUntilAbort(abortSignal, () => {
|
|
357
|
-
log?.info?.(`Stopping Synology Chat channel (account: ${accountId})`);
|
|
358
|
-
unregister();
|
|
359
|
-
});
|
|
360
|
-
},
|
|
361
|
-
|
|
362
|
-
stopAccount: async (ctx: SynologyChannelGatewayContext) => {
|
|
363
|
-
ctx.log?.info?.(`Synology Chat account ${ctx.accountId} stopped`);
|
|
364
|
-
},
|
|
365
|
-
},
|
|
366
|
-
agentPrompt: {
|
|
367
|
-
messageToolHints: () => [
|
|
368
|
-
"",
|
|
369
|
-
"### Synology Chat Formatting",
|
|
370
|
-
"Synology Chat supports limited formatting. Use these patterns:",
|
|
371
|
-
"",
|
|
372
|
-
"**Links**: Use `<URL|display text>` to create clickable links.",
|
|
373
|
-
" Example: `<https://example.com|Click here>` renders as a clickable link.",
|
|
374
|
-
"",
|
|
375
|
-
"**File sharing**: Include a publicly accessible URL to share files or images.",
|
|
376
|
-
" The NAS will download and attach the file (max 32 MB).",
|
|
377
|
-
"",
|
|
378
|
-
"**Limitations**:",
|
|
379
|
-
"- No markdown, bold, italic, or code blocks",
|
|
380
|
-
"- No buttons, cards, or interactive elements",
|
|
381
|
-
"- No message editing after send",
|
|
382
|
-
"- Keep messages under 2000 characters for best readability",
|
|
383
|
-
"",
|
|
384
|
-
"**Best practices**:",
|
|
385
|
-
"- Use short, clear responses (Synology Chat has a minimal UI)",
|
|
386
|
-
"- Use line breaks to separate sections",
|
|
387
|
-
"- Use numbered or bulleted lists for clarity",
|
|
388
|
-
"- Wrap URLs with `<URL|label>` for user-friendly links",
|
|
389
|
-
],
|
|
390
|
-
},
|
|
391
|
-
message: synologyChatMessageAdapter,
|
|
392
|
-
},
|
|
393
|
-
pairing: {
|
|
394
|
-
text: {
|
|
395
|
-
idLabel: "synologyChatUserId",
|
|
396
|
-
message: "Klaw: your access has been approved.",
|
|
397
|
-
normalizeAllowEntry: (entry: string) => normalizeLowercaseStringOrEmpty(entry),
|
|
398
|
-
notify: async ({ cfg, id, message }) => {
|
|
399
|
-
const account = resolveAccount(cfg);
|
|
400
|
-
if (!account.incomingUrl) {
|
|
401
|
-
return;
|
|
402
|
-
}
|
|
403
|
-
await sendMessage(account.incomingUrl, message, id, account.allowInsecureSsl);
|
|
404
|
-
},
|
|
405
|
-
},
|
|
406
|
-
},
|
|
407
|
-
security: {
|
|
408
|
-
resolveDmPolicy: resolveSynologyChatDmPolicy,
|
|
409
|
-
collectWarnings: composeWarningCollectors(
|
|
410
|
-
projectAccountWarningCollector<ResolvedSynologyChatAccount, SynologySecurityWarningContext>(
|
|
411
|
-
collectSynologyChatSecurityWarnings,
|
|
412
|
-
),
|
|
413
|
-
collectSynologyChatRoutingWarnings,
|
|
414
|
-
),
|
|
415
|
-
collectAuditFindings: collectSynologyChatSecurityAuditFindings,
|
|
416
|
-
},
|
|
417
|
-
outbound: {
|
|
418
|
-
deliveryMode: "gateway" as const,
|
|
419
|
-
textChunkLimit: 2000,
|
|
420
|
-
|
|
421
|
-
sendText: sendSynologyChatText,
|
|
422
|
-
sendMedia: async (ctx) => {
|
|
423
|
-
if (!ctx.mediaUrl) {
|
|
424
|
-
throw new Error("Synology Chat media send requires mediaUrl");
|
|
425
|
-
}
|
|
426
|
-
return await sendSynologyChatMedia({
|
|
427
|
-
...ctx,
|
|
428
|
-
mediaUrl: ctx.mediaUrl,
|
|
429
|
-
});
|
|
430
|
-
},
|
|
431
|
-
},
|
|
432
|
-
}) as unknown as SynologyChatPlugin;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
export const synologyChatPlugin = createSynologyChatPlugin();
|