@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.
Files changed (177) hide show
  1. package/klaw.plugin.json +726 -2
  2. package/package.json +16 -4
  3. package/api.ts +0 -3
  4. package/channel-config-api.ts +0 -1
  5. package/channel-plugin-api.ts +0 -2
  6. package/config-api.ts +0 -4
  7. package/contract-api.ts +0 -4
  8. package/index.ts +0 -20
  9. package/runtime-api.ts +0 -66
  10. package/secret-contract-api.ts +0 -5
  11. package/setup-entry.ts +0 -13
  12. package/setup-plugin-api.ts +0 -3
  13. package/src/ai-entity.ts +0 -7
  14. package/src/approval-auth.ts +0 -44
  15. package/src/attachments/bot-framework.test.ts +0 -506
  16. package/src/attachments/bot-framework.ts +0 -348
  17. package/src/attachments/download.ts +0 -328
  18. package/src/attachments/graph.test.ts +0 -441
  19. package/src/attachments/graph.ts +0 -489
  20. package/src/attachments/html.ts +0 -122
  21. package/src/attachments/payload.ts +0 -14
  22. package/src/attachments/remote-media.test.ts +0 -187
  23. package/src/attachments/remote-media.ts +0 -86
  24. package/src/attachments/shared.test.ts +0 -547
  25. package/src/attachments/shared.ts +0 -655
  26. package/src/attachments/types.ts +0 -47
  27. package/src/attachments.graph.test.ts +0 -414
  28. package/src/attachments.helpers.test.ts +0 -245
  29. package/src/attachments.test-helpers.ts +0 -17
  30. package/src/attachments.test.ts +0 -754
  31. package/src/attachments.ts +0 -18
  32. package/src/block-streaming-config.test.ts +0 -61
  33. package/src/channel-api.ts +0 -1
  34. package/src/channel.actions.test.ts +0 -797
  35. package/src/channel.directory.test.ts +0 -176
  36. package/src/channel.message-adapter.test.ts +0 -227
  37. package/src/channel.runtime.ts +0 -56
  38. package/src/channel.setup.ts +0 -77
  39. package/src/channel.test.ts +0 -136
  40. package/src/channel.ts +0 -1176
  41. package/src/config-schema.ts +0 -6
  42. package/src/config-ui-hints.ts +0 -40
  43. package/src/conversation-store-fs.test.ts +0 -81
  44. package/src/conversation-store-fs.ts +0 -149
  45. package/src/conversation-store-helpers.test.ts +0 -202
  46. package/src/conversation-store-helpers.ts +0 -105
  47. package/src/conversation-store-memory.ts +0 -51
  48. package/src/conversation-store.shared.test.ts +0 -260
  49. package/src/conversation-store.ts +0 -71
  50. package/src/directory-live.test.ts +0 -156
  51. package/src/directory-live.ts +0 -111
  52. package/src/doctor.ts +0 -27
  53. package/src/errors.test.ts +0 -154
  54. package/src/errors.ts +0 -270
  55. package/src/feedback-reflection-prompt.ts +0 -117
  56. package/src/feedback-reflection-store.ts +0 -113
  57. package/src/feedback-reflection.test.ts +0 -237
  58. package/src/feedback-reflection.ts +0 -268
  59. package/src/file-consent-helpers.test.ts +0 -328
  60. package/src/file-consent-helpers.ts +0 -115
  61. package/src/file-consent-invoke.ts +0 -150
  62. package/src/file-consent.test.ts +0 -378
  63. package/src/file-consent.ts +0 -223
  64. package/src/graph-chat.ts +0 -36
  65. package/src/graph-group-management.test.ts +0 -332
  66. package/src/graph-group-management.ts +0 -168
  67. package/src/graph-members.test.ts +0 -89
  68. package/src/graph-members.ts +0 -48
  69. package/src/graph-messages.actions.test.ts +0 -253
  70. package/src/graph-messages.read.test.ts +0 -391
  71. package/src/graph-messages.search.test.ts +0 -227
  72. package/src/graph-messages.test-helpers.ts +0 -50
  73. package/src/graph-messages.ts +0 -534
  74. package/src/graph-teams.test.ts +0 -222
  75. package/src/graph-teams.ts +0 -114
  76. package/src/graph-thread.test.ts +0 -252
  77. package/src/graph-thread.ts +0 -146
  78. package/src/graph-upload.test.ts +0 -253
  79. package/src/graph-upload.ts +0 -531
  80. package/src/graph-users.ts +0 -29
  81. package/src/graph.test.ts +0 -540
  82. package/src/graph.ts +0 -308
  83. package/src/inbound.test.ts +0 -221
  84. package/src/inbound.ts +0 -148
  85. package/src/index.ts +0 -4
  86. package/src/media-helpers.test.ts +0 -220
  87. package/src/media-helpers.ts +0 -105
  88. package/src/mentions.test.ts +0 -254
  89. package/src/mentions.ts +0 -114
  90. package/src/messenger.test.ts +0 -961
  91. package/src/messenger.ts +0 -608
  92. package/src/monitor-handler/access.ts +0 -136
  93. package/src/monitor-handler/inbound-media.test.ts +0 -314
  94. package/src/monitor-handler/inbound-media.ts +0 -180
  95. package/src/monitor-handler/message-handler-mock-support.test-support.ts +0 -28
  96. package/src/monitor-handler/message-handler.authz.test.ts +0 -739
  97. package/src/monitor-handler/message-handler.dm-media.test.ts +0 -54
  98. package/src/monitor-handler/message-handler.test-support.ts +0 -99
  99. package/src/monitor-handler/message-handler.thread-parent.test.ts +0 -225
  100. package/src/monitor-handler/message-handler.thread-session.test.ts +0 -132
  101. package/src/monitor-handler/message-handler.ts +0 -1003
  102. package/src/monitor-handler/reaction-handler.test.ts +0 -325
  103. package/src/monitor-handler/reaction-handler.ts +0 -122
  104. package/src/monitor-handler/thread-session.ts +0 -30
  105. package/src/monitor-handler.adaptive-card.test.ts +0 -158
  106. package/src/monitor-handler.feedback-authz.test.ts +0 -357
  107. package/src/monitor-handler.file-consent.test.ts +0 -443
  108. package/src/monitor-handler.sso.test.ts +0 -576
  109. package/src/monitor-handler.test-helpers.ts +0 -181
  110. package/src/monitor-handler.ts +0 -538
  111. package/src/monitor-handler.types.ts +0 -27
  112. package/src/monitor-types.ts +0 -6
  113. package/src/monitor.lifecycle.test.ts +0 -457
  114. package/src/monitor.test.ts +0 -119
  115. package/src/monitor.ts +0 -476
  116. package/src/oauth.flow.ts +0 -77
  117. package/src/oauth.shared.ts +0 -37
  118. package/src/oauth.test.ts +0 -350
  119. package/src/oauth.token.ts +0 -162
  120. package/src/oauth.ts +0 -130
  121. package/src/outbound.test.ts +0 -400
  122. package/src/outbound.ts +0 -198
  123. package/src/pending-uploads-fs.test.ts +0 -261
  124. package/src/pending-uploads-fs.ts +0 -235
  125. package/src/pending-uploads.test.ts +0 -186
  126. package/src/pending-uploads.ts +0 -121
  127. package/src/policy.test.ts +0 -156
  128. package/src/policy.ts +0 -245
  129. package/src/polls-store-memory.ts +0 -32
  130. package/src/polls.test.ts +0 -169
  131. package/src/polls.ts +0 -312
  132. package/src/presentation.ts +0 -93
  133. package/src/probe.test.ts +0 -79
  134. package/src/probe.ts +0 -132
  135. package/src/reply-dispatcher.test.ts +0 -543
  136. package/src/reply-dispatcher.ts +0 -523
  137. package/src/reply-stream-controller.test.ts +0 -424
  138. package/src/reply-stream-controller.ts +0 -334
  139. package/src/resolve-allowlist.test.ts +0 -253
  140. package/src/resolve-allowlist.ts +0 -309
  141. package/src/revoked-context.ts +0 -17
  142. package/src/runtime.ts +0 -12
  143. package/src/sdk-types.ts +0 -59
  144. package/src/sdk.test.ts +0 -727
  145. package/src/sdk.ts +0 -916
  146. package/src/secret-contract.ts +0 -49
  147. package/src/secret-input.ts +0 -7
  148. package/src/send-context.test.ts +0 -93
  149. package/src/send-context.ts +0 -269
  150. package/src/send.test.ts +0 -588
  151. package/src/send.ts +0 -697
  152. package/src/sent-message-cache.test.ts +0 -106
  153. package/src/sent-message-cache.ts +0 -174
  154. package/src/session-route.ts +0 -40
  155. package/src/setup-core.ts +0 -162
  156. package/src/setup-surface.test.ts +0 -175
  157. package/src/setup-surface.ts +0 -319
  158. package/src/sso-token-store.test.ts +0 -74
  159. package/src/sso-token-store.ts +0 -166
  160. package/src/sso.ts +0 -300
  161. package/src/storage.ts +0 -25
  162. package/src/store-fs.ts +0 -42
  163. package/src/streaming-message.test.ts +0 -323
  164. package/src/streaming-message.ts +0 -327
  165. package/src/test-runtime.ts +0 -16
  166. package/src/thread-parent-context.test.ts +0 -224
  167. package/src/thread-parent-context.ts +0 -159
  168. package/src/token-response.ts +0 -11
  169. package/src/token.test.ts +0 -268
  170. package/src/token.ts +0 -194
  171. package/src/user-agent.test.ts +0 -121
  172. package/src/user-agent.ts +0 -53
  173. package/src/webhook-timeouts.ts +0 -27
  174. package/src/welcome-card.test.ts +0 -104
  175. package/src/welcome-card.ts +0 -57
  176. package/test-api.ts +0 -1
  177. package/tsconfig.json +0 -16
@@ -1,187 +0,0 @@
1
- import { beforeEach, describe, expect, it, vi } from "vitest";
2
-
3
- // Mock the runtime so we can assert whether the strict-dispatcher path
4
- // (`saveRemoteMedia`) was invoked versus the new direct-fetch path added
5
- // for issue #63396 (Node 24+ / undici v7 compat).
6
- const runtimeSaveRemoteMediaMock = vi.fn(
7
- async (
8
- _params: unknown,
9
- ): Promise<{
10
- id: string;
11
- path: string;
12
- size: number;
13
- contentType?: string;
14
- fileName?: string;
15
- }> => ({
16
- id: "saved",
17
- path: "/tmp/saved.png",
18
- size: 42,
19
- contentType: "image/png",
20
- }),
21
- );
22
- const runtimeDetectMimeMock = vi.fn(async () => "image/png");
23
- const runtimeSaveMediaBufferMock = vi.fn(async (_buf: Buffer, contentType?: string) => ({
24
- id: "saved",
25
- path: "/tmp/saved.png",
26
- size: 42,
27
- contentType: contentType ?? "image/png",
28
- }));
29
- const saveResponseMediaMock = vi.hoisted(() =>
30
- vi.fn(async (response: Response, options: { maxBytes?: number }) => {
31
- if (!response.ok) {
32
- const statusText = response.statusText ? ` ${response.statusText}` : "";
33
- throw new Error(`HTTP ${response.status}${statusText}`);
34
- }
35
- const contentLength = Number(response.headers.get("content-length"));
36
- if (Number.isFinite(contentLength) && options.maxBytes && contentLength > options.maxBytes) {
37
- throw new Error(`content length ${contentLength} exceeds maxBytes ${options.maxBytes}`);
38
- }
39
- return {
40
- id: "saved",
41
- path: "/tmp/saved.png",
42
- size: 42,
43
- contentType: response.headers.get("content-type") ?? "image/png",
44
- };
45
- }),
46
- );
47
-
48
- vi.mock("klaw/plugin-sdk/media-runtime", async () => ({
49
- saveResponseMedia: saveResponseMediaMock,
50
- }));
51
-
52
- vi.mock("../runtime.js", () => ({
53
- getMSTeamsRuntime: () => ({
54
- media: { detectMime: runtimeDetectMimeMock },
55
- channel: {
56
- media: {
57
- saveRemoteMedia: runtimeSaveRemoteMediaMock,
58
- saveMediaBuffer: runtimeSaveMediaBufferMock,
59
- },
60
- },
61
- }),
62
- }));
63
-
64
- import { downloadAndStoreMSTeamsRemoteMedia } from "./remote-media.js";
65
-
66
- const PNG_BYTES = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
67
-
68
- function jsonResponse(body: BodyInit, init?: ResponseInit): Response {
69
- return new Response(body, init);
70
- }
71
-
72
- function requireFirstFetchUrl(mock: ReturnType<typeof vi.fn>): unknown {
73
- const [call] = mock.mock.calls;
74
- if (!call) {
75
- throw new Error("expected direct fetch call");
76
- }
77
- return call[0];
78
- }
79
-
80
- describe("downloadAndStoreMSTeamsRemoteMedia", () => {
81
- beforeEach(() => {
82
- runtimeSaveRemoteMediaMock.mockClear();
83
- saveResponseMediaMock.mockClear();
84
- runtimeDetectMimeMock.mockClear();
85
- runtimeSaveMediaBufferMock.mockClear();
86
- });
87
-
88
- describe("useDirectFetch: true (Node 24+ / undici v7 path for issue #63396)", () => {
89
- it("bypasses readRemoteMediaBuffer and calls the supplied fetchImpl directly", async () => {
90
- // `fetchImpl` here simulates the "pre-validated hostname" contract from
91
- // `safeFetchWithPolicy`: the caller has already enforced the allowlist,
92
- // so the strict SSRF dispatcher is not needed.
93
- const fetchImpl = vi.fn(async (_input: RequestInfo | URL, _init?: RequestInit) =>
94
- jsonResponse(PNG_BYTES, { status: 200, headers: { "content-type": "image/png" } }),
95
- );
96
-
97
- const result = await downloadAndStoreMSTeamsRemoteMedia({
98
- url: "https://graph.microsoft.com/v1.0/shares/abc/driveItem/content",
99
- filePathHint: "file.png",
100
- maxBytes: 1024,
101
- useDirectFetch: true,
102
- fetchImpl,
103
- });
104
-
105
- expect(fetchImpl).toHaveBeenCalledTimes(1);
106
- const calledUrl = requireFirstFetchUrl(fetchImpl);
107
- expect(calledUrl).toBe("https://graph.microsoft.com/v1.0/shares/abc/driveItem/content");
108
- expect(runtimeSaveRemoteMediaMock).not.toHaveBeenCalled();
109
- expect(result.path).toBe("/tmp/saved.png");
110
- });
111
-
112
- it("surfaces HTTP errors as exceptions (no silent drop)", async () => {
113
- const fetchImpl = vi.fn(async () => jsonResponse("nope", { status: 403 }));
114
-
115
- await expect(
116
- downloadAndStoreMSTeamsRemoteMedia({
117
- url: "https://graph.microsoft.com/v1.0/shares/abc/driveItem/content",
118
- filePathHint: "file.png",
119
- maxBytes: 1024,
120
- useDirectFetch: true,
121
- fetchImpl,
122
- }),
123
- ).rejects.toThrow(/HTTP 403/);
124
- expect(runtimeSaveRemoteMediaMock).not.toHaveBeenCalled();
125
- });
126
-
127
- it("rejects a response whose Content-Length exceeds maxBytes", async () => {
128
- const fetchImpl = vi.fn(async () =>
129
- jsonResponse(PNG_BYTES, {
130
- status: 200,
131
- headers: { "content-length": "999999" },
132
- }),
133
- );
134
-
135
- await expect(
136
- downloadAndStoreMSTeamsRemoteMedia({
137
- url: "https://graph.microsoft.com/v1.0/shares/abc/driveItem/content",
138
- filePathHint: "file.png",
139
- maxBytes: 1024,
140
- useDirectFetch: true,
141
- fetchImpl,
142
- }),
143
- ).rejects.toThrow(/exceeds maxBytes/);
144
- expect(runtimeSaveRemoteMediaMock).not.toHaveBeenCalled();
145
- });
146
-
147
- it("falls back to the runtime saveRemoteMedia path when useDirectFetch is omitted", async () => {
148
- // Non-SharePoint caller, no pre-validated fetchImpl: make sure the strict
149
- // SSRF dispatcher path is still used.
150
- runtimeSaveRemoteMediaMock.mockResolvedValueOnce({
151
- id: "saved",
152
- path: "/tmp/saved.png",
153
- size: 42,
154
- contentType: "image/png",
155
- fileName: "file.png",
156
- });
157
-
158
- await downloadAndStoreMSTeamsRemoteMedia({
159
- url: "https://tenant.sharepoint.com/file.png",
160
- filePathHint: "file.png",
161
- maxBytes: 1024,
162
- });
163
-
164
- expect(runtimeSaveRemoteMediaMock).toHaveBeenCalledTimes(1);
165
- });
166
-
167
- it("does not use the direct path when useDirectFetch is true but fetchImpl is missing", async () => {
168
- runtimeSaveRemoteMediaMock.mockResolvedValueOnce({
169
- id: "saved",
170
- path: "/tmp/saved.png",
171
- size: 42,
172
- contentType: "image/png",
173
- });
174
-
175
- await downloadAndStoreMSTeamsRemoteMedia({
176
- url: "https://graph.microsoft.com/v1.0/shares/abc/driveItem/content",
177
- filePathHint: "file.png",
178
- maxBytes: 1024,
179
- useDirectFetch: true,
180
- });
181
-
182
- // Without a fetchImpl to delegate to, we must fall back to the runtime
183
- // path rather than crashing.
184
- expect(runtimeSaveRemoteMediaMock).toHaveBeenCalledTimes(1);
185
- });
186
- });
187
- });
@@ -1,86 +0,0 @@
1
- import { saveResponseMedia, type SavedRemoteMedia } from "klaw/plugin-sdk/media-runtime";
2
- import type { SsrFPolicy } from "../../runtime-api.js";
3
- import { getMSTeamsRuntime } from "../runtime.js";
4
- import { inferPlaceholder } from "./shared.js";
5
- import type { MSTeamsInboundMedia } from "./types.js";
6
-
7
- type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
8
-
9
- /**
10
- * Direct fetch path used when the caller's `fetchImpl` has already validated
11
- * the URL against a hostname allowlist (for example `safeFetchWithPolicy`).
12
- *
13
- * Bypasses the strict SSRF dispatcher on `readRemoteMediaBuffer` because:
14
- * 1. The pinned undici dispatcher used by `readRemoteMediaBuffer` is incompatible
15
- * with Node 24+'s built-in undici v7 (fails with "invalid onRequestStart
16
- * method"), which silently breaks SharePoint/OneDrive downloads. See
17
- * issue #63396.
18
- * 2. SSRF protection is already enforced by the caller's `fetchImpl`
19
- * (`safeFetch` validates every redirect hop against the hostname
20
- * allowlist before following).
21
- */
22
- async function saveRemoteMediaDirect(params: {
23
- url: string;
24
- filePathHint: string;
25
- fetchImpl: FetchLike;
26
- maxBytes: number;
27
- contentTypeHint?: string;
28
- originalFilename?: string;
29
- }): Promise<SavedRemoteMedia> {
30
- const response = await params.fetchImpl(params.url, { redirect: "follow" });
31
- return await saveResponseMedia(response, {
32
- sourceUrl: params.url,
33
- filePathHint: params.filePathHint,
34
- maxBytes: params.maxBytes,
35
- fallbackContentType: params.contentTypeHint,
36
- originalFilename: params.originalFilename,
37
- });
38
- }
39
-
40
- export async function downloadAndStoreMSTeamsRemoteMedia(params: {
41
- url: string;
42
- filePathHint: string;
43
- maxBytes: number;
44
- fetchImpl?: FetchLike;
45
- ssrfPolicy?: SsrFPolicy;
46
- contentTypeHint?: string;
47
- placeholder?: string;
48
- preserveFilenames?: boolean;
49
- /**
50
- * Opt into a direct fetch path that bypasses `readRemoteMediaBuffer`'s strict
51
- * SSRF dispatcher. Required for SharePoint/OneDrive downloads on Node 24+
52
- * (see issue #63396). Only safe when the supplied `fetchImpl` has already
53
- * validated the URL against a hostname allowlist.
54
- */
55
- useDirectFetch?: boolean;
56
- }): Promise<MSTeamsInboundMedia> {
57
- const originalFilename = params.preserveFilenames ? params.filePathHint : undefined;
58
- let saved: SavedRemoteMedia;
59
- if (params.useDirectFetch && params.fetchImpl) {
60
- saved = await saveRemoteMediaDirect({
61
- url: params.url,
62
- filePathHint: params.filePathHint,
63
- fetchImpl: params.fetchImpl,
64
- maxBytes: params.maxBytes,
65
- contentTypeHint: params.contentTypeHint,
66
- originalFilename,
67
- });
68
- } else {
69
- saved = await getMSTeamsRuntime().channel.media.saveRemoteMedia({
70
- url: params.url,
71
- fetchImpl: params.fetchImpl,
72
- filePathHint: params.filePathHint,
73
- maxBytes: params.maxBytes,
74
- ssrfPolicy: params.ssrfPolicy,
75
- fallbackContentType: params.contentTypeHint,
76
- originalFilename,
77
- });
78
- }
79
- return {
80
- path: saved.path,
81
- contentType: saved.contentType,
82
- placeholder:
83
- params.placeholder ??
84
- inferPlaceholder({ contentType: saved.contentType, fileName: params.filePathHint }),
85
- };
86
- }