@kodelyth/msteams 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 +726 -2
- package/package.json +16 -4
- package/api.ts +0 -3
- package/channel-config-api.ts +0 -1
- package/channel-plugin-api.ts +0 -2
- package/config-api.ts +0 -4
- package/contract-api.ts +0 -4
- package/index.ts +0 -20
- package/runtime-api.ts +0 -66
- package/secret-contract-api.ts +0 -5
- package/setup-entry.ts +0 -13
- package/setup-plugin-api.ts +0 -3
- package/src/ai-entity.ts +0 -7
- package/src/approval-auth.ts +0 -44
- package/src/attachments/bot-framework.test.ts +0 -506
- package/src/attachments/bot-framework.ts +0 -348
- package/src/attachments/download.ts +0 -328
- package/src/attachments/graph.test.ts +0 -441
- package/src/attachments/graph.ts +0 -489
- package/src/attachments/html.ts +0 -122
- package/src/attachments/payload.ts +0 -14
- package/src/attachments/remote-media.test.ts +0 -187
- package/src/attachments/remote-media.ts +0 -86
- package/src/attachments/shared.test.ts +0 -547
- package/src/attachments/shared.ts +0 -655
- package/src/attachments/types.ts +0 -47
- package/src/attachments.graph.test.ts +0 -414
- package/src/attachments.helpers.test.ts +0 -245
- package/src/attachments.test-helpers.ts +0 -17
- package/src/attachments.test.ts +0 -754
- package/src/attachments.ts +0 -18
- package/src/block-streaming-config.test.ts +0 -61
- package/src/channel-api.ts +0 -1
- package/src/channel.actions.test.ts +0 -797
- package/src/channel.directory.test.ts +0 -176
- package/src/channel.message-adapter.test.ts +0 -227
- package/src/channel.runtime.ts +0 -56
- package/src/channel.setup.ts +0 -77
- package/src/channel.test.ts +0 -136
- package/src/channel.ts +0 -1176
- package/src/config-schema.ts +0 -6
- package/src/config-ui-hints.ts +0 -40
- package/src/conversation-store-fs.test.ts +0 -81
- package/src/conversation-store-fs.ts +0 -149
- package/src/conversation-store-helpers.test.ts +0 -202
- package/src/conversation-store-helpers.ts +0 -105
- package/src/conversation-store-memory.ts +0 -51
- package/src/conversation-store.shared.test.ts +0 -260
- package/src/conversation-store.ts +0 -71
- package/src/directory-live.test.ts +0 -156
- package/src/directory-live.ts +0 -111
- package/src/doctor.ts +0 -27
- package/src/errors.test.ts +0 -154
- package/src/errors.ts +0 -270
- package/src/feedback-reflection-prompt.ts +0 -117
- package/src/feedback-reflection-store.ts +0 -113
- package/src/feedback-reflection.test.ts +0 -237
- package/src/feedback-reflection.ts +0 -268
- package/src/file-consent-helpers.test.ts +0 -328
- package/src/file-consent-helpers.ts +0 -115
- package/src/file-consent-invoke.ts +0 -150
- package/src/file-consent.test.ts +0 -378
- package/src/file-consent.ts +0 -223
- package/src/graph-chat.ts +0 -36
- package/src/graph-group-management.test.ts +0 -332
- package/src/graph-group-management.ts +0 -168
- package/src/graph-members.test.ts +0 -89
- package/src/graph-members.ts +0 -48
- package/src/graph-messages.actions.test.ts +0 -253
- package/src/graph-messages.read.test.ts +0 -391
- package/src/graph-messages.search.test.ts +0 -227
- package/src/graph-messages.test-helpers.ts +0 -50
- package/src/graph-messages.ts +0 -534
- package/src/graph-teams.test.ts +0 -222
- package/src/graph-teams.ts +0 -114
- package/src/graph-thread.test.ts +0 -252
- package/src/graph-thread.ts +0 -146
- package/src/graph-upload.test.ts +0 -253
- package/src/graph-upload.ts +0 -531
- package/src/graph-users.ts +0 -29
- package/src/graph.test.ts +0 -540
- package/src/graph.ts +0 -308
- package/src/inbound.test.ts +0 -221
- package/src/inbound.ts +0 -148
- package/src/index.ts +0 -4
- package/src/media-helpers.test.ts +0 -220
- package/src/media-helpers.ts +0 -105
- package/src/mentions.test.ts +0 -254
- package/src/mentions.ts +0 -114
- package/src/messenger.test.ts +0 -961
- package/src/messenger.ts +0 -608
- package/src/monitor-handler/access.ts +0 -136
- package/src/monitor-handler/inbound-media.test.ts +0 -314
- package/src/monitor-handler/inbound-media.ts +0 -180
- package/src/monitor-handler/message-handler-mock-support.test-support.ts +0 -28
- package/src/monitor-handler/message-handler.authz.test.ts +0 -739
- package/src/monitor-handler/message-handler.dm-media.test.ts +0 -54
- package/src/monitor-handler/message-handler.test-support.ts +0 -99
- package/src/monitor-handler/message-handler.thread-parent.test.ts +0 -225
- package/src/monitor-handler/message-handler.thread-session.test.ts +0 -132
- package/src/monitor-handler/message-handler.ts +0 -1003
- package/src/monitor-handler/reaction-handler.test.ts +0 -325
- package/src/monitor-handler/reaction-handler.ts +0 -122
- package/src/monitor-handler/thread-session.ts +0 -30
- package/src/monitor-handler.adaptive-card.test.ts +0 -158
- package/src/monitor-handler.feedback-authz.test.ts +0 -357
- package/src/monitor-handler.file-consent.test.ts +0 -443
- package/src/monitor-handler.sso.test.ts +0 -576
- package/src/monitor-handler.test-helpers.ts +0 -181
- package/src/monitor-handler.ts +0 -538
- package/src/monitor-handler.types.ts +0 -27
- package/src/monitor-types.ts +0 -6
- package/src/monitor.lifecycle.test.ts +0 -457
- package/src/monitor.test.ts +0 -119
- package/src/monitor.ts +0 -476
- package/src/oauth.flow.ts +0 -77
- package/src/oauth.shared.ts +0 -37
- package/src/oauth.test.ts +0 -350
- package/src/oauth.token.ts +0 -162
- package/src/oauth.ts +0 -130
- package/src/outbound.test.ts +0 -400
- package/src/outbound.ts +0 -198
- package/src/pending-uploads-fs.test.ts +0 -261
- package/src/pending-uploads-fs.ts +0 -235
- package/src/pending-uploads.test.ts +0 -186
- package/src/pending-uploads.ts +0 -121
- package/src/policy.test.ts +0 -156
- package/src/policy.ts +0 -245
- package/src/polls-store-memory.ts +0 -32
- package/src/polls.test.ts +0 -169
- package/src/polls.ts +0 -312
- package/src/presentation.ts +0 -93
- package/src/probe.test.ts +0 -79
- package/src/probe.ts +0 -132
- package/src/reply-dispatcher.test.ts +0 -543
- package/src/reply-dispatcher.ts +0 -523
- package/src/reply-stream-controller.test.ts +0 -424
- package/src/reply-stream-controller.ts +0 -334
- package/src/resolve-allowlist.test.ts +0 -253
- package/src/resolve-allowlist.ts +0 -309
- package/src/revoked-context.ts +0 -17
- package/src/runtime.ts +0 -12
- package/src/sdk-types.ts +0 -59
- package/src/sdk.test.ts +0 -727
- package/src/sdk.ts +0 -916
- package/src/secret-contract.ts +0 -49
- package/src/secret-input.ts +0 -7
- package/src/send-context.test.ts +0 -93
- package/src/send-context.ts +0 -269
- package/src/send.test.ts +0 -588
- package/src/send.ts +0 -697
- package/src/sent-message-cache.test.ts +0 -106
- package/src/sent-message-cache.ts +0 -174
- package/src/session-route.ts +0 -40
- package/src/setup-core.ts +0 -162
- package/src/setup-surface.test.ts +0 -175
- package/src/setup-surface.ts +0 -319
- package/src/sso-token-store.test.ts +0 -74
- package/src/sso-token-store.ts +0 -166
- package/src/sso.ts +0 -300
- package/src/storage.ts +0 -25
- package/src/store-fs.ts +0 -42
- package/src/streaming-message.test.ts +0 -323
- package/src/streaming-message.ts +0 -327
- package/src/test-runtime.ts +0 -16
- package/src/thread-parent-context.test.ts +0 -224
- package/src/thread-parent-context.ts +0 -159
- package/src/token-response.ts +0 -11
- package/src/token.test.ts +0 -268
- package/src/token.ts +0 -194
- package/src/user-agent.test.ts +0 -121
- package/src/user-agent.ts +0 -53
- package/src/webhook-timeouts.ts +0 -27
- package/src/welcome-card.test.ts +0 -104
- package/src/welcome-card.ts +0 -57
- package/test-api.ts +0 -1
- package/tsconfig.json +0 -16
package/src/resolve-allowlist.ts
DELETED
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
import { mapAllowlistResolutionInputs } from "klaw/plugin-sdk/allow-from";
|
|
2
|
-
import {
|
|
3
|
-
normalizeLowercaseStringOrEmpty,
|
|
4
|
-
normalizeOptionalLowercaseString,
|
|
5
|
-
} from "klaw/plugin-sdk/string-coerce-runtime";
|
|
6
|
-
import { searchGraphUsers } from "./graph-users.js";
|
|
7
|
-
import {
|
|
8
|
-
listChannelsForTeam,
|
|
9
|
-
listTeamsByName,
|
|
10
|
-
normalizeQuery,
|
|
11
|
-
resolveGraphToken,
|
|
12
|
-
} from "./graph.js";
|
|
13
|
-
|
|
14
|
-
type MSTeamsChannelResolution = {
|
|
15
|
-
input: string;
|
|
16
|
-
resolved: boolean;
|
|
17
|
-
teamId?: string;
|
|
18
|
-
teamName?: string;
|
|
19
|
-
channelId?: string;
|
|
20
|
-
channelName?: string;
|
|
21
|
-
note?: string;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
type MSTeamsUserResolution = {
|
|
25
|
-
input: string;
|
|
26
|
-
resolved: boolean;
|
|
27
|
-
id?: string;
|
|
28
|
-
name?: string;
|
|
29
|
-
note?: string;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
function stripProviderPrefix(raw: string): string {
|
|
33
|
-
return raw.replace(/^(msteams|teams):/i, "");
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function normalizeMSTeamsMessagingTarget(raw: string): string | undefined {
|
|
37
|
-
let trimmed = raw.trim();
|
|
38
|
-
if (!trimmed) {
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
|
-
trimmed = stripProviderPrefix(trimmed).trim();
|
|
42
|
-
if (/^conversation:/i.test(trimmed)) {
|
|
43
|
-
const id = trimmed.slice("conversation:".length).trim();
|
|
44
|
-
return id ? `conversation:${id}` : undefined;
|
|
45
|
-
}
|
|
46
|
-
if (/^user:/i.test(trimmed)) {
|
|
47
|
-
const id = trimmed.slice("user:".length).trim();
|
|
48
|
-
return id ? `user:${id}` : undefined;
|
|
49
|
-
}
|
|
50
|
-
return trimmed || undefined;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export function normalizeMSTeamsUserInput(raw: string): string {
|
|
54
|
-
return stripProviderPrefix(raw)
|
|
55
|
-
.replace(/^(user|conversation):/i, "")
|
|
56
|
-
.trim();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export function parseMSTeamsConversationId(raw: string): string | null {
|
|
60
|
-
const trimmed = stripProviderPrefix(raw).trim();
|
|
61
|
-
if (!/^conversation:/i.test(trimmed)) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
const id = trimmed.slice("conversation:".length).trim();
|
|
65
|
-
return id;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Detect whether a raw target string looks like a Microsoft Teams conversation
|
|
70
|
-
* or user id that cron announce delivery and other explicit-target paths can
|
|
71
|
-
* forward verbatim to the channel adapter.
|
|
72
|
-
*
|
|
73
|
-
* Accepts both prefixed and bare formats:
|
|
74
|
-
* - `conversation:<id>` — explicit conversation prefix
|
|
75
|
-
* - `user:<aad-guid>` — user id (16+ hex chars, UUID-like)
|
|
76
|
-
* - `19:abc@thread.tacv2` / `19:abc@thread.skype` — channel / legacy group
|
|
77
|
-
* - `19:{userId}_{appId}@unq.gbl.spaces` — Graph 1:1 chat thread format
|
|
78
|
-
* - `a:1xxx` — Bot Framework personal (1:1) chat id
|
|
79
|
-
* - `8:orgid:xxx` — Bot Framework org-scoped personal chat id
|
|
80
|
-
* - `29:xxx` — Bot Framework user id
|
|
81
|
-
*
|
|
82
|
-
* Display-name user targets such as `user:John Smith` intentionally return
|
|
83
|
-
* false so that the Graph API directory lookup still runs for them.
|
|
84
|
-
*/
|
|
85
|
-
export function looksLikeMSTeamsTargetId(raw: string): boolean {
|
|
86
|
-
const trimmed = raw.trim();
|
|
87
|
-
if (!trimmed) {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
if (/^conversation:/i.test(trimmed)) {
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
if (/^user:/i.test(trimmed)) {
|
|
94
|
-
// Only treat as an id when the value after `user:` looks like a UUID;
|
|
95
|
-
// display names must fall through to directory lookup.
|
|
96
|
-
const id = trimmed.slice("user:".length).trim();
|
|
97
|
-
return /^[0-9a-fA-F-]{16,}$/.test(id);
|
|
98
|
-
}
|
|
99
|
-
// Bare Bot Framework / Graph conversation id formats.
|
|
100
|
-
// Channel / group ids always start with `19:` and include an `@thread.*`
|
|
101
|
-
// suffix (`@thread.tacv2` or the legacy `@thread.skype`). Personal chat
|
|
102
|
-
// ids come in three shapes: `a:1...` (Bot Framework), `8:orgid:...`
|
|
103
|
-
// (org-scoped Bot Framework), and `19:{userId}_{appId}@unq.gbl.spaces`
|
|
104
|
-
// (Graph API 1:1 chat thread). Bot Framework user ids use `29:...`.
|
|
105
|
-
if (/^19:.+@thread\.(tacv2|skype)$/i.test(trimmed)) {
|
|
106
|
-
return true;
|
|
107
|
-
}
|
|
108
|
-
if (/^19:.+@unq\.gbl\.spaces$/i.test(trimmed)) {
|
|
109
|
-
return true;
|
|
110
|
-
}
|
|
111
|
-
if (/^a:1[A-Za-z0-9_-]+$/i.test(trimmed)) {
|
|
112
|
-
return true;
|
|
113
|
-
}
|
|
114
|
-
if (/^8:orgid:[A-Za-z0-9-]+$/i.test(trimmed)) {
|
|
115
|
-
return true;
|
|
116
|
-
}
|
|
117
|
-
if (/^29:[A-Za-z0-9_-]+$/i.test(trimmed)) {
|
|
118
|
-
return true;
|
|
119
|
-
}
|
|
120
|
-
// Fallback: anything containing @thread is still treated as a conversation
|
|
121
|
-
// id so the current matches for tenant-specific suffixes remain accepted.
|
|
122
|
-
return /@thread\b/i.test(trimmed);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function normalizeMSTeamsTeamKey(raw: string): string | undefined {
|
|
126
|
-
const trimmed = stripProviderPrefix(raw)
|
|
127
|
-
.replace(/^team:/i, "")
|
|
128
|
-
.trim();
|
|
129
|
-
return trimmed || undefined;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function normalizeMSTeamsChannelKey(raw?: string | null): string | undefined {
|
|
133
|
-
const trimmed = raw?.trim().replace(/^#/, "").trim() ?? "";
|
|
134
|
-
return trimmed || undefined;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function normalizeMSTeamsConversationTargetId(raw: string): string {
|
|
138
|
-
const trimmed = stripProviderPrefix(raw).trim();
|
|
139
|
-
return parseMSTeamsConversationId(trimmed) ?? trimmed;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function looksLikeMSTeamsThreadConversationId(raw: string): boolean {
|
|
143
|
-
const normalized = normalizeMSTeamsConversationTargetId(raw);
|
|
144
|
-
return /^19:.+@thread\./i.test(normalized);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export function parseMSTeamsTeamChannelInput(raw: string): { team?: string; channel?: string } {
|
|
148
|
-
const trimmed = stripProviderPrefix(raw).trim();
|
|
149
|
-
if (!trimmed) {
|
|
150
|
-
return {};
|
|
151
|
-
}
|
|
152
|
-
const parts = trimmed.split("/");
|
|
153
|
-
const team = normalizeMSTeamsTeamKey(parts[0] ?? "");
|
|
154
|
-
const channel =
|
|
155
|
-
parts.length > 1 ? normalizeMSTeamsChannelKey(parts.slice(1).join("/")) : undefined;
|
|
156
|
-
return {
|
|
157
|
-
...(team ? { team } : {}),
|
|
158
|
-
...(channel ? { channel } : {}),
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export function parseMSTeamsTeamEntry(
|
|
163
|
-
raw: string,
|
|
164
|
-
): { teamKey: string; channelKey?: string } | null {
|
|
165
|
-
const { team, channel } = parseMSTeamsTeamChannelInput(raw);
|
|
166
|
-
if (!team) {
|
|
167
|
-
return null;
|
|
168
|
-
}
|
|
169
|
-
return {
|
|
170
|
-
teamKey: team,
|
|
171
|
-
...(channel ? { channelKey: channel } : {}),
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
export async function resolveMSTeamsChannelAllowlist(params: {
|
|
176
|
-
cfg: unknown;
|
|
177
|
-
entries: string[];
|
|
178
|
-
}): Promise<MSTeamsChannelResolution[]> {
|
|
179
|
-
let tokenPromise: Promise<string> | undefined;
|
|
180
|
-
const getToken = () => {
|
|
181
|
-
tokenPromise ??= resolveGraphToken(params.cfg);
|
|
182
|
-
return tokenPromise;
|
|
183
|
-
};
|
|
184
|
-
return await mapAllowlistResolutionInputs({
|
|
185
|
-
inputs: params.entries,
|
|
186
|
-
mapInput: async (input): Promise<MSTeamsChannelResolution> => {
|
|
187
|
-
const { team, channel } = parseMSTeamsTeamChannelInput(input);
|
|
188
|
-
if (!team) {
|
|
189
|
-
return { input, resolved: false };
|
|
190
|
-
}
|
|
191
|
-
if (looksLikeMSTeamsThreadConversationId(team)) {
|
|
192
|
-
const teamId = normalizeMSTeamsConversationTargetId(team);
|
|
193
|
-
if (!channel) {
|
|
194
|
-
return { input, resolved: true, teamId, teamName: teamId };
|
|
195
|
-
}
|
|
196
|
-
if (!looksLikeMSTeamsThreadConversationId(channel)) {
|
|
197
|
-
return {
|
|
198
|
-
input,
|
|
199
|
-
resolved: false,
|
|
200
|
-
teamId,
|
|
201
|
-
teamName: teamId,
|
|
202
|
-
note: "channel id required for conversation-id team",
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
const channelId = normalizeMSTeamsConversationTargetId(channel);
|
|
206
|
-
return {
|
|
207
|
-
input,
|
|
208
|
-
resolved: true,
|
|
209
|
-
teamId,
|
|
210
|
-
teamName: teamId,
|
|
211
|
-
channelId,
|
|
212
|
-
channelName: channelId,
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
const token = await getToken();
|
|
216
|
-
const teams = /^[0-9a-fA-F-]{16,}$/.test(team)
|
|
217
|
-
? [{ id: team, displayName: team }]
|
|
218
|
-
: await listTeamsByName(token, team);
|
|
219
|
-
if (teams.length === 0) {
|
|
220
|
-
return { input, resolved: false, note: "team not found" };
|
|
221
|
-
}
|
|
222
|
-
const teamMatch = teams[0];
|
|
223
|
-
const graphTeamId = teamMatch.id?.trim();
|
|
224
|
-
const teamName = teamMatch.displayName?.trim() || team;
|
|
225
|
-
if (!graphTeamId) {
|
|
226
|
-
return { input, resolved: false, note: "team id missing" };
|
|
227
|
-
}
|
|
228
|
-
// Bot Framework sends the General channel's conversation ID as
|
|
229
|
-
// channelData.team.id at runtime, NOT the Graph API group GUID.
|
|
230
|
-
// Fetch channels upfront so we can resolve the correct key format for
|
|
231
|
-
// runtime matching and reuse the list for channel lookups.
|
|
232
|
-
let teamChannels: Awaited<ReturnType<typeof listChannelsForTeam>> = [];
|
|
233
|
-
try {
|
|
234
|
-
teamChannels = await listChannelsForTeam(token, graphTeamId);
|
|
235
|
-
} catch {
|
|
236
|
-
// API failure (rate limit, network error) — fall back to Graph GUID as team key
|
|
237
|
-
}
|
|
238
|
-
const generalChannel = teamChannels.find(
|
|
239
|
-
(ch) => normalizeOptionalLowercaseString(ch.displayName) === "general",
|
|
240
|
-
);
|
|
241
|
-
// Use the General channel's conversation ID as the team key — this
|
|
242
|
-
// matches what Bot Framework sends at runtime. Fall back to the Graph
|
|
243
|
-
// GUID if the General channel isn't found (renamed or deleted).
|
|
244
|
-
const teamId = generalChannel?.id?.trim() || graphTeamId;
|
|
245
|
-
if (!channel) {
|
|
246
|
-
return {
|
|
247
|
-
input,
|
|
248
|
-
resolved: true,
|
|
249
|
-
teamId,
|
|
250
|
-
teamName,
|
|
251
|
-
note: teams.length > 1 ? "multiple teams; chose first" : undefined,
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
// Reuse teamChannels — already fetched above
|
|
255
|
-
const normalizedChannel = normalizeOptionalLowercaseString(channel);
|
|
256
|
-
const channelMatch =
|
|
257
|
-
teamChannels.find((item) => item.id === channel) ??
|
|
258
|
-
teamChannels.find(
|
|
259
|
-
(item) => normalizeOptionalLowercaseString(item.displayName) === normalizedChannel,
|
|
260
|
-
) ??
|
|
261
|
-
teamChannels.find((item) =>
|
|
262
|
-
normalizeLowercaseStringOrEmpty(item.displayName ?? "").includes(normalizedChannel ?? ""),
|
|
263
|
-
);
|
|
264
|
-
if (!channelMatch?.id) {
|
|
265
|
-
return { input, resolved: false, note: "channel not found" };
|
|
266
|
-
}
|
|
267
|
-
return {
|
|
268
|
-
input,
|
|
269
|
-
resolved: true,
|
|
270
|
-
teamId,
|
|
271
|
-
teamName,
|
|
272
|
-
channelId: channelMatch.id,
|
|
273
|
-
channelName: channelMatch.displayName ?? channel,
|
|
274
|
-
note: teamChannels.length > 1 ? "multiple channels; chose first" : undefined,
|
|
275
|
-
};
|
|
276
|
-
},
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
export async function resolveMSTeamsUserAllowlist(params: {
|
|
281
|
-
cfg: unknown;
|
|
282
|
-
entries: string[];
|
|
283
|
-
}): Promise<MSTeamsUserResolution[]> {
|
|
284
|
-
const token = await resolveGraphToken(params.cfg);
|
|
285
|
-
return await mapAllowlistResolutionInputs({
|
|
286
|
-
inputs: params.entries,
|
|
287
|
-
mapInput: async (input): Promise<MSTeamsUserResolution> => {
|
|
288
|
-
const query = normalizeQuery(normalizeMSTeamsUserInput(input));
|
|
289
|
-
if (!query) {
|
|
290
|
-
return { input, resolved: false };
|
|
291
|
-
}
|
|
292
|
-
if (/^[0-9a-fA-F-]{16,}$/.test(query)) {
|
|
293
|
-
return { input, resolved: true, id: query };
|
|
294
|
-
}
|
|
295
|
-
const users = await searchGraphUsers({ token, query, top: 10 });
|
|
296
|
-
const match = users[0];
|
|
297
|
-
if (!match?.id) {
|
|
298
|
-
return { input, resolved: false };
|
|
299
|
-
}
|
|
300
|
-
return {
|
|
301
|
-
input,
|
|
302
|
-
resolved: true,
|
|
303
|
-
id: match.id,
|
|
304
|
-
name: match.displayName ?? undefined,
|
|
305
|
-
note: users.length > 1 ? "multiple matches; chose first" : undefined,
|
|
306
|
-
};
|
|
307
|
-
},
|
|
308
|
-
});
|
|
309
|
-
}
|
package/src/revoked-context.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { isRevokedProxyError } from "./errors.js";
|
|
2
|
-
|
|
3
|
-
export async function withRevokedProxyFallback<T>(params: {
|
|
4
|
-
run: () => Promise<T>;
|
|
5
|
-
onRevoked: () => Promise<T>;
|
|
6
|
-
onRevokedLog?: () => void;
|
|
7
|
-
}): Promise<T> {
|
|
8
|
-
try {
|
|
9
|
-
return await params.run();
|
|
10
|
-
} catch (err) {
|
|
11
|
-
if (!isRevokedProxyError(err)) {
|
|
12
|
-
throw err;
|
|
13
|
-
}
|
|
14
|
-
params.onRevokedLog?.();
|
|
15
|
-
return await params.onRevoked();
|
|
16
|
-
}
|
|
17
|
-
}
|
package/src/runtime.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { createPluginRuntimeStore } from "klaw/plugin-sdk/runtime-store";
|
|
2
|
-
import type { PluginRuntime } from "klaw/plugin-sdk/runtime-store";
|
|
3
|
-
|
|
4
|
-
const {
|
|
5
|
-
setRuntime: setMSTeamsRuntime,
|
|
6
|
-
getRuntime: getMSTeamsRuntime,
|
|
7
|
-
tryGetRuntime: getOptionalMSTeamsRuntime,
|
|
8
|
-
} = createPluginRuntimeStore<PluginRuntime>({
|
|
9
|
-
pluginId: "msteams",
|
|
10
|
-
errorMessage: "MSTeams runtime not initialized",
|
|
11
|
-
});
|
|
12
|
-
export { getMSTeamsRuntime, getOptionalMSTeamsRuntime, setMSTeamsRuntime };
|
package/src/sdk-types.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Minimal public surface we depend on from the Microsoft SDK types.
|
|
3
|
-
*
|
|
4
|
-
* Note: we intentionally avoid coupling to SDK classes with private members
|
|
5
|
-
* (like TurnContext) in our own public signatures. The SDK's TS surface is also
|
|
6
|
-
* stricter than what the runtime accepts (e.g. it allows plain activity-like
|
|
7
|
-
* objects), so we model the minimal structural shape we rely on.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
type MSTeamsActivity = {
|
|
11
|
-
type: string;
|
|
12
|
-
id?: string;
|
|
13
|
-
timestamp?: string;
|
|
14
|
-
localTimestamp?: string;
|
|
15
|
-
channelId?: string;
|
|
16
|
-
from?: { id?: string; name?: string; aadObjectId?: string; role?: string };
|
|
17
|
-
conversation?: {
|
|
18
|
-
id?: string;
|
|
19
|
-
conversationType?: string;
|
|
20
|
-
tenantId?: string;
|
|
21
|
-
name?: string;
|
|
22
|
-
isGroup?: boolean;
|
|
23
|
-
};
|
|
24
|
-
recipient?: { id?: string; name?: string };
|
|
25
|
-
text?: string;
|
|
26
|
-
textFormat?: string;
|
|
27
|
-
locale?: string;
|
|
28
|
-
serviceUrl?: string;
|
|
29
|
-
channelData?: {
|
|
30
|
-
team?: { id?: string; name?: string };
|
|
31
|
-
channel?: { id?: string; name?: string };
|
|
32
|
-
tenant?: { id?: string };
|
|
33
|
-
[key: string]: unknown;
|
|
34
|
-
};
|
|
35
|
-
attachments?: Array<{
|
|
36
|
-
contentType?: string;
|
|
37
|
-
contentUrl?: string;
|
|
38
|
-
content?: unknown;
|
|
39
|
-
name?: string;
|
|
40
|
-
thumbnailUrl?: string;
|
|
41
|
-
}>;
|
|
42
|
-
entities?: Array<Record<string, unknown>>;
|
|
43
|
-
value?: unknown;
|
|
44
|
-
name?: string;
|
|
45
|
-
membersAdded?: Array<{ id?: string; name?: string }>;
|
|
46
|
-
membersRemoved?: Array<{ id?: string; name?: string }>;
|
|
47
|
-
replyToId?: string;
|
|
48
|
-
[key: string]: unknown;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export type MSTeamsTurnContext = {
|
|
52
|
-
activity: MSTeamsActivity;
|
|
53
|
-
sendActivity: (textOrActivity: string | object) => Promise<unknown>;
|
|
54
|
-
sendActivities: (
|
|
55
|
-
activities: Array<{ type: string } & Record<string, unknown>>,
|
|
56
|
-
) => Promise<unknown>;
|
|
57
|
-
updateActivity: (activity: object) => Promise<{ id?: string } | void>;
|
|
58
|
-
deleteActivity: (activityId: string) => Promise<void>;
|
|
59
|
-
};
|