@openclaw/msteams 2026.5.2 → 2026.5.3-beta.2

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 (197) hide show
  1. package/dist/api.js +3 -0
  2. package/dist/channel-D7hdreTh.js +984 -0
  3. package/dist/channel-config-api.js +2 -0
  4. package/dist/channel-plugin-api.js +2 -0
  5. package/dist/channel.runtime-BC1ruIfN.js +573 -0
  6. package/dist/config-schema-B8QezH6t.js +15 -0
  7. package/dist/contract-api.js +2 -0
  8. package/dist/graph-users-9uQJepqr.js +1354 -0
  9. package/dist/index.js +22 -0
  10. package/dist/oauth-BWJyilR1.js +114 -0
  11. package/dist/oauth.token-xxpoLWy5.js +115 -0
  12. package/dist/policy-DTnU2GR7.js +142 -0
  13. package/dist/probe-D_H8yFps.js +2194 -0
  14. package/dist/resolve-allowlist-D41JSziq.js +219 -0
  15. package/dist/runtime-api-DV1iVMn1.js +28 -0
  16. package/dist/runtime-api.js +2 -0
  17. package/dist/secret-contract-BuoEXmPS.js +35 -0
  18. package/dist/secret-contract-api.js +2 -0
  19. package/dist/setup-entry.js +15 -0
  20. package/dist/setup-plugin-api.js +64 -0
  21. package/dist/setup-surface-BLkFQYIQ.js +313 -0
  22. package/dist/src-CFp1QpFd.js +4064 -0
  23. package/dist/test-api.js +2 -0
  24. package/package.json +14 -6
  25. package/api.ts +0 -3
  26. package/channel-config-api.ts +0 -1
  27. package/channel-plugin-api.ts +0 -2
  28. package/config-api.ts +0 -4
  29. package/contract-api.ts +0 -4
  30. package/index.ts +0 -20
  31. package/runtime-api.ts +0 -73
  32. package/secret-contract-api.ts +0 -5
  33. package/setup-entry.ts +0 -13
  34. package/setup-plugin-api.ts +0 -3
  35. package/src/ai-entity.ts +0 -7
  36. package/src/approval-auth.ts +0 -44
  37. package/src/attachments/bot-framework.test.ts +0 -461
  38. package/src/attachments/bot-framework.ts +0 -362
  39. package/src/attachments/download.ts +0 -311
  40. package/src/attachments/graph.test.ts +0 -416
  41. package/src/attachments/graph.ts +0 -484
  42. package/src/attachments/html.ts +0 -122
  43. package/src/attachments/payload.ts +0 -14
  44. package/src/attachments/remote-media.test.ts +0 -137
  45. package/src/attachments/remote-media.ts +0 -112
  46. package/src/attachments/shared.test.ts +0 -530
  47. package/src/attachments/shared.ts +0 -626
  48. package/src/attachments/types.ts +0 -47
  49. package/src/attachments.graph.test.ts +0 -342
  50. package/src/attachments.helpers.test.ts +0 -246
  51. package/src/attachments.test-helpers.ts +0 -17
  52. package/src/attachments.test.ts +0 -687
  53. package/src/attachments.ts +0 -18
  54. package/src/block-streaming-config.test.ts +0 -61
  55. package/src/channel-api.ts +0 -1
  56. package/src/channel.actions.test.ts +0 -742
  57. package/src/channel.directory.test.ts +0 -200
  58. package/src/channel.runtime.ts +0 -56
  59. package/src/channel.setup.ts +0 -77
  60. package/src/channel.test.ts +0 -128
  61. package/src/channel.ts +0 -1136
  62. package/src/config-schema.ts +0 -6
  63. package/src/config-ui-hints.ts +0 -12
  64. package/src/conversation-store-fs.test.ts +0 -74
  65. package/src/conversation-store-fs.ts +0 -149
  66. package/src/conversation-store-helpers.test.ts +0 -202
  67. package/src/conversation-store-helpers.ts +0 -105
  68. package/src/conversation-store-memory.ts +0 -51
  69. package/src/conversation-store.shared.test.ts +0 -225
  70. package/src/conversation-store.ts +0 -71
  71. package/src/directory-live.test.ts +0 -156
  72. package/src/directory-live.ts +0 -111
  73. package/src/doctor.ts +0 -27
  74. package/src/errors.test.ts +0 -133
  75. package/src/errors.ts +0 -246
  76. package/src/feedback-reflection-prompt.ts +0 -117
  77. package/src/feedback-reflection-store.ts +0 -114
  78. package/src/feedback-reflection.test.ts +0 -237
  79. package/src/feedback-reflection.ts +0 -283
  80. package/src/file-consent-helpers.test.ts +0 -326
  81. package/src/file-consent-helpers.ts +0 -126
  82. package/src/file-consent-invoke.ts +0 -150
  83. package/src/file-consent.test.ts +0 -363
  84. package/src/file-consent.ts +0 -287
  85. package/src/graph-chat.ts +0 -55
  86. package/src/graph-group-management.test.ts +0 -318
  87. package/src/graph-group-management.ts +0 -168
  88. package/src/graph-members.test.ts +0 -89
  89. package/src/graph-members.ts +0 -48
  90. package/src/graph-messages.actions.test.ts +0 -243
  91. package/src/graph-messages.read.test.ts +0 -391
  92. package/src/graph-messages.search.test.ts +0 -213
  93. package/src/graph-messages.test-helpers.ts +0 -50
  94. package/src/graph-messages.ts +0 -534
  95. package/src/graph-teams.test.ts +0 -215
  96. package/src/graph-teams.ts +0 -114
  97. package/src/graph-thread.test.ts +0 -246
  98. package/src/graph-thread.ts +0 -146
  99. package/src/graph-upload.test.ts +0 -258
  100. package/src/graph-upload.ts +0 -531
  101. package/src/graph-users.ts +0 -29
  102. package/src/graph.test.ts +0 -516
  103. package/src/graph.ts +0 -293
  104. package/src/inbound.test.ts +0 -221
  105. package/src/inbound.ts +0 -148
  106. package/src/index.ts +0 -4
  107. package/src/media-helpers.test.ts +0 -202
  108. package/src/media-helpers.ts +0 -105
  109. package/src/mentions.test.ts +0 -244
  110. package/src/mentions.ts +0 -114
  111. package/src/messenger.test.ts +0 -865
  112. package/src/messenger.ts +0 -605
  113. package/src/monitor-handler/access.ts +0 -125
  114. package/src/monitor-handler/inbound-media.test.ts +0 -289
  115. package/src/monitor-handler/inbound-media.ts +0 -180
  116. package/src/monitor-handler/message-handler-mock-support.test-support.ts +0 -28
  117. package/src/monitor-handler/message-handler.authz.test.ts +0 -669
  118. package/src/monitor-handler/message-handler.dm-media.test.ts +0 -54
  119. package/src/monitor-handler/message-handler.test-support.ts +0 -100
  120. package/src/monitor-handler/message-handler.thread-parent.test.ts +0 -223
  121. package/src/monitor-handler/message-handler.thread-session.test.ts +0 -77
  122. package/src/monitor-handler/message-handler.ts +0 -1000
  123. package/src/monitor-handler/reaction-handler.test.ts +0 -267
  124. package/src/monitor-handler/reaction-handler.ts +0 -210
  125. package/src/monitor-handler/thread-session.ts +0 -17
  126. package/src/monitor-handler.adaptive-card.test.ts +0 -162
  127. package/src/monitor-handler.feedback-authz.test.ts +0 -314
  128. package/src/monitor-handler.file-consent.test.ts +0 -423
  129. package/src/monitor-handler.sso.test.ts +0 -563
  130. package/src/monitor-handler.test-helpers.ts +0 -180
  131. package/src/monitor-handler.ts +0 -534
  132. package/src/monitor-handler.types.ts +0 -27
  133. package/src/monitor-types.ts +0 -6
  134. package/src/monitor.lifecycle.test.ts +0 -278
  135. package/src/monitor.test.ts +0 -119
  136. package/src/monitor.ts +0 -442
  137. package/src/oauth.flow.ts +0 -77
  138. package/src/oauth.shared.ts +0 -37
  139. package/src/oauth.test.ts +0 -305
  140. package/src/oauth.token.ts +0 -158
  141. package/src/oauth.ts +0 -130
  142. package/src/outbound.test.ts +0 -130
  143. package/src/outbound.ts +0 -71
  144. package/src/pending-uploads-fs.test.ts +0 -246
  145. package/src/pending-uploads-fs.ts +0 -235
  146. package/src/pending-uploads.test.ts +0 -173
  147. package/src/pending-uploads.ts +0 -121
  148. package/src/policy.test.ts +0 -240
  149. package/src/policy.ts +0 -262
  150. package/src/polls-store-memory.ts +0 -32
  151. package/src/polls.test.ts +0 -160
  152. package/src/polls.ts +0 -323
  153. package/src/presentation.ts +0 -68
  154. package/src/probe.test.ts +0 -77
  155. package/src/probe.ts +0 -132
  156. package/src/reply-dispatcher.test.ts +0 -437
  157. package/src/reply-dispatcher.ts +0 -346
  158. package/src/reply-stream-controller.test.ts +0 -235
  159. package/src/reply-stream-controller.ts +0 -147
  160. package/src/resolve-allowlist.test.ts +0 -250
  161. package/src/resolve-allowlist.ts +0 -309
  162. package/src/revoked-context.ts +0 -17
  163. package/src/runtime.ts +0 -9
  164. package/src/sdk-types.ts +0 -59
  165. package/src/sdk.test.ts +0 -666
  166. package/src/sdk.ts +0 -884
  167. package/src/secret-contract.ts +0 -49
  168. package/src/secret-input.ts +0 -7
  169. package/src/send-context.ts +0 -231
  170. package/src/send.test.ts +0 -493
  171. package/src/send.ts +0 -637
  172. package/src/sent-message-cache.test.ts +0 -15
  173. package/src/sent-message-cache.ts +0 -56
  174. package/src/session-route.ts +0 -40
  175. package/src/setup-core.ts +0 -160
  176. package/src/setup-surface.test.ts +0 -202
  177. package/src/setup-surface.ts +0 -320
  178. package/src/sso-token-store.test.ts +0 -72
  179. package/src/sso-token-store.ts +0 -166
  180. package/src/sso.ts +0 -300
  181. package/src/storage.ts +0 -25
  182. package/src/store-fs.ts +0 -44
  183. package/src/streaming-message.test.ts +0 -262
  184. package/src/streaming-message.ts +0 -297
  185. package/src/test-runtime.ts +0 -16
  186. package/src/thread-parent-context.test.ts +0 -224
  187. package/src/thread-parent-context.ts +0 -159
  188. package/src/token-response.ts +0 -11
  189. package/src/token.test.ts +0 -259
  190. package/src/token.ts +0 -195
  191. package/src/user-agent.test.ts +0 -86
  192. package/src/user-agent.ts +0 -53
  193. package/src/webhook-timeouts.ts +0 -27
  194. package/src/welcome-card.test.ts +0 -81
  195. package/src/welcome-card.ts +0 -57
  196. package/test-api.ts +0 -1
  197. package/tsconfig.json +0 -16
@@ -1,173 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
2
- import {
3
- clearPendingUploads,
4
- getPendingUpload,
5
- getPendingUploadCount,
6
- removePendingUpload,
7
- setPendingUploadActivityId,
8
- storePendingUpload,
9
- } from "./pending-uploads.js";
10
-
11
- describe("pending-uploads", () => {
12
- beforeEach(() => {
13
- vi.useFakeTimers();
14
- clearPendingUploads();
15
- });
16
-
17
- afterEach(() => {
18
- clearPendingUploads();
19
- vi.useRealTimers();
20
- });
21
-
22
- describe("storePendingUpload", () => {
23
- it("stores and retrieves a pending upload", () => {
24
- const id = storePendingUpload({
25
- buffer: Buffer.from("data"),
26
- filename: "file.txt",
27
- contentType: "text/plain",
28
- conversationId: "conv-1",
29
- });
30
-
31
- const upload = getPendingUpload(id);
32
- expect(upload).toBeDefined();
33
- expect(upload?.filename).toBe("file.txt");
34
- expect(upload?.conversationId).toBe("conv-1");
35
- });
36
-
37
- it("stores consentCardActivityId when provided", () => {
38
- const id = storePendingUpload({
39
- buffer: Buffer.from("data"),
40
- filename: "file.txt",
41
- conversationId: "conv-1",
42
- consentCardActivityId: "activity-abc",
43
- });
44
-
45
- const upload = getPendingUpload(id);
46
- expect(upload?.consentCardActivityId).toBe("activity-abc");
47
- });
48
-
49
- it("stores without consentCardActivityId when not provided", () => {
50
- const id = storePendingUpload({
51
- buffer: Buffer.from("data"),
52
- filename: "file.txt",
53
- conversationId: "conv-1",
54
- });
55
-
56
- const upload = getPendingUpload(id);
57
- expect(upload?.consentCardActivityId).toBeUndefined();
58
- });
59
-
60
- it("auto-removes entry after TTL expires", () => {
61
- const id = storePendingUpload({
62
- buffer: Buffer.from("data"),
63
- filename: "file.txt",
64
- conversationId: "conv-1",
65
- });
66
-
67
- expect(getPendingUpload(id)).toBeDefined();
68
- vi.advanceTimersByTime(5 * 60 * 1000 + 1);
69
- // After TTL the in-memory check also gates access
70
- expect(getPendingUpload(id)).toBeUndefined();
71
- });
72
- });
73
-
74
- describe("removePendingUpload", () => {
75
- it("removes the entry immediately", () => {
76
- const id = storePendingUpload({
77
- buffer: Buffer.from("data"),
78
- filename: "file.txt",
79
- conversationId: "conv-1",
80
- });
81
-
82
- removePendingUpload(id);
83
- expect(getPendingUpload(id)).toBeUndefined();
84
- });
85
-
86
- it("clears the TTL timer so it does not fire after explicit removal", () => {
87
- const id = storePendingUpload({
88
- buffer: Buffer.from("data"),
89
- filename: "file.txt",
90
- conversationId: "conv-1",
91
- });
92
-
93
- expect(getPendingUploadCount()).toBe(1);
94
- removePendingUpload(id);
95
- expect(getPendingUploadCount()).toBe(0);
96
-
97
- // Advance past TTL — timer should have been cleared and count stays 0
98
- vi.advanceTimersByTime(5 * 60 * 1000 + 1);
99
- expect(getPendingUploadCount()).toBe(0);
100
- });
101
-
102
- it("is a no-op for undefined id", () => {
103
- storePendingUpload({
104
- buffer: Buffer.from("data"),
105
- filename: "file.txt",
106
- conversationId: "conv-1",
107
- });
108
-
109
- expect(() => removePendingUpload(undefined)).not.toThrow();
110
- expect(getPendingUploadCount()).toBe(1);
111
- });
112
-
113
- it("is a no-op for unknown id", () => {
114
- expect(() => removePendingUpload("non-existent-id")).not.toThrow();
115
- });
116
- });
117
-
118
- describe("clearPendingUploads", () => {
119
- it("removes all entries and cancels timers", () => {
120
- storePendingUpload({ buffer: Buffer.from("a"), filename: "a.txt", conversationId: "c1" });
121
- storePendingUpload({ buffer: Buffer.from("b"), filename: "b.txt", conversationId: "c2" });
122
- expect(getPendingUploadCount()).toBe(2);
123
-
124
- clearPendingUploads();
125
- expect(getPendingUploadCount()).toBe(0);
126
-
127
- // TTL timers should have been cleared — no side-effects after advance
128
- vi.advanceTimersByTime(5 * 60 * 1000 + 1);
129
- expect(getPendingUploadCount()).toBe(0);
130
- });
131
- });
132
-
133
- describe("setPendingUploadActivityId", () => {
134
- it("sets the consentCardActivityId on an existing upload", () => {
135
- const id = storePendingUpload({
136
- buffer: Buffer.from("data"),
137
- filename: "file.txt",
138
- conversationId: "conv-1",
139
- });
140
-
141
- expect(getPendingUpload(id)?.consentCardActivityId).toBeUndefined();
142
-
143
- setPendingUploadActivityId(id, "activity-xyz");
144
- expect(getPendingUpload(id)?.consentCardActivityId).toBe("activity-xyz");
145
- });
146
-
147
- it("is a no-op for unknown upload id", () => {
148
- expect(() => setPendingUploadActivityId("non-existent", "activity-xyz")).not.toThrow();
149
- });
150
- });
151
-
152
- describe("getPendingUpload", () => {
153
- it("returns undefined for undefined id", () => {
154
- expect(getPendingUpload(undefined)).toBeUndefined();
155
- });
156
-
157
- it("returns undefined for unknown id", () => {
158
- expect(getPendingUpload("no-such-id")).toBeUndefined();
159
- });
160
-
161
- it("returns undefined when entry is past TTL but timer has not yet fired", () => {
162
- const id = storePendingUpload({
163
- buffer: Buffer.from("data"),
164
- filename: "file.txt",
165
- conversationId: "conv-1",
166
- });
167
-
168
- // Manually advance time without firing timers to simulate stale entry
169
- vi.setSystemTime(Date.now() + 5 * 60 * 1000 + 1);
170
- expect(getPendingUpload(id)).toBeUndefined();
171
- });
172
- });
173
- });
@@ -1,121 +0,0 @@
1
- /**
2
- * In-memory storage for files awaiting user consent in the FileConsentCard flow.
3
- *
4
- * When sending large files (>=4MB) in personal chats, Teams requires user consent
5
- * before upload. This module stores the file data temporarily until the user
6
- * accepts or declines, or until the TTL expires.
7
- */
8
-
9
- import crypto from "node:crypto";
10
-
11
- export interface PendingUpload {
12
- id: string;
13
- buffer: Buffer;
14
- filename: string;
15
- contentType?: string;
16
- conversationId: string;
17
- /** Activity ID of the original FileConsentCard, used to replace it after upload */
18
- consentCardActivityId?: string;
19
- createdAt: number;
20
- }
21
-
22
- const pendingUploads = new Map<string, PendingUpload>();
23
- /** Timer handles keyed by upload ID, cleared on explicit removal to prevent ghost cleanup */
24
- const pendingUploadTimers = new Map<string, ReturnType<typeof setTimeout>>();
25
-
26
- /** TTL for pending uploads: 5 minutes */
27
- const PENDING_UPLOAD_TTL_MS = 5 * 60 * 1000;
28
-
29
- /**
30
- * Store a file pending user consent.
31
- * Returns the upload ID to include in the FileConsentCard context.
32
- */
33
- export function storePendingUpload(upload: Omit<PendingUpload, "id" | "createdAt">): string {
34
- const id = crypto.randomUUID();
35
- const entry: PendingUpload = {
36
- ...upload,
37
- id,
38
- createdAt: Date.now(),
39
- };
40
- pendingUploads.set(id, entry);
41
-
42
- // Auto-cleanup after TTL; timer ref stored so removePendingUpload can cancel it
43
- const timer = setTimeout(() => {
44
- pendingUploads.delete(id);
45
- pendingUploadTimers.delete(id);
46
- }, PENDING_UPLOAD_TTL_MS);
47
- pendingUploadTimers.set(id, timer);
48
-
49
- return id;
50
- }
51
-
52
- /**
53
- * Retrieve a pending upload by ID.
54
- * Returns undefined if not found or expired.
55
- */
56
- export function getPendingUpload(id?: string): PendingUpload | undefined {
57
- if (!id) {
58
- return undefined;
59
- }
60
- const entry = pendingUploads.get(id);
61
- if (!entry) {
62
- return undefined;
63
- }
64
-
65
- // Check if expired (in case timeout hasn't fired yet)
66
- if (Date.now() - entry.createdAt > PENDING_UPLOAD_TTL_MS) {
67
- pendingUploads.delete(id);
68
- const timer = pendingUploadTimers.get(id);
69
- if (timer !== undefined) {
70
- clearTimeout(timer);
71
- pendingUploadTimers.delete(id);
72
- }
73
- return undefined;
74
- }
75
-
76
- return entry;
77
- }
78
-
79
- /**
80
- * Remove a pending upload (after successful upload or user decline).
81
- * Also clears the TTL timer to prevent ghost Map deletions.
82
- */
83
- export function removePendingUpload(id?: string): void {
84
- if (id) {
85
- pendingUploads.delete(id);
86
- const timer = pendingUploadTimers.get(id);
87
- if (timer !== undefined) {
88
- clearTimeout(timer);
89
- pendingUploadTimers.delete(id);
90
- }
91
- }
92
- }
93
-
94
- /**
95
- * Set the consent card activity ID on an existing pending upload.
96
- * Called after the FileConsentCard is sent and we know its activity ID.
97
- */
98
- export function setPendingUploadActivityId(uploadId: string, activityId: string): void {
99
- const entry = pendingUploads.get(uploadId);
100
- if (entry) {
101
- entry.consentCardActivityId = activityId;
102
- }
103
- }
104
-
105
- /**
106
- * Get the count of pending uploads (for monitoring/debugging).
107
- */
108
- export function getPendingUploadCount(): number {
109
- return pendingUploads.size;
110
- }
111
-
112
- /**
113
- * Clear all pending uploads (for testing).
114
- */
115
- export function clearPendingUploads(): void {
116
- for (const timer of pendingUploadTimers.values()) {
117
- clearTimeout(timer);
118
- }
119
- pendingUploadTimers.clear();
120
- pendingUploads.clear();
121
- }
@@ -1,240 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import type { MSTeamsConfig } from "../runtime-api.js";
3
- import {
4
- isMSTeamsGroupAllowed,
5
- resolveMSTeamsReplyPolicy,
6
- resolveMSTeamsRouteConfig,
7
- } from "./policy.js";
8
-
9
- function resolveNamedTeamRouteConfig(allowNameMatching = false) {
10
- const cfg: MSTeamsConfig = {
11
- teams: {
12
- "My Team": {
13
- requireMention: true,
14
- channels: {
15
- "General Chat": { requireMention: false },
16
- },
17
- },
18
- },
19
- };
20
-
21
- return resolveMSTeamsRouteConfig({
22
- cfg,
23
- teamName: "My Team",
24
- channelName: "General Chat",
25
- conversationId: "ignored",
26
- allowNameMatching,
27
- });
28
- }
29
-
30
- describe("msteams policy", () => {
31
- describe("resolveMSTeamsRouteConfig", () => {
32
- it("returns team and channel config when present", () => {
33
- const cfg: MSTeamsConfig = {
34
- teams: {
35
- team123: {
36
- requireMention: false,
37
- channels: {
38
- chan456: { requireMention: true },
39
- },
40
- },
41
- },
42
- };
43
-
44
- const res = resolveMSTeamsRouteConfig({
45
- cfg,
46
- teamId: "team123",
47
- conversationId: "chan456",
48
- });
49
-
50
- if (!res.teamConfig || !res.channelConfig) {
51
- throw new Error("expected matched team and channel config");
52
- }
53
- expect(res.teamConfig.requireMention).toBe(false);
54
- expect(res.channelConfig.requireMention).toBe(true);
55
- expect(res.allowlistConfigured).toBe(true);
56
- expect(res.allowed).toBe(true);
57
- expect(res.channelMatchKey).toBe("chan456");
58
- expect(res.channelMatchSource).toBe("direct");
59
- });
60
-
61
- it("returns undefined configs when teamId is missing", () => {
62
- const cfg: MSTeamsConfig = {
63
- teams: { team123: { requireMention: false } },
64
- };
65
-
66
- const res = resolveMSTeamsRouteConfig({
67
- cfg,
68
- teamId: undefined,
69
- conversationId: "chan",
70
- });
71
- expect(res.teamConfig).toBeUndefined();
72
- expect(res.channelConfig).toBeUndefined();
73
- expect(res.allowlistConfigured).toBe(true);
74
- expect(res.allowed).toBe(false);
75
- });
76
-
77
- it("blocks team and channel name matches by default", () => {
78
- const res = resolveNamedTeamRouteConfig();
79
-
80
- expect(res.teamConfig).toBeUndefined();
81
- expect(res.channelConfig).toBeUndefined();
82
- expect(res.allowed).toBe(false);
83
- });
84
-
85
- it("matches team and channel by name when dangerous name matching is enabled", () => {
86
- const res = resolveNamedTeamRouteConfig(true);
87
-
88
- if (!res.teamConfig || !res.channelConfig) {
89
- throw new Error("expected matched named team and channel config");
90
- }
91
- expect(res.teamConfig.requireMention).toBe(true);
92
- expect(res.channelConfig.requireMention).toBe(false);
93
- expect(res.allowed).toBe(true);
94
- });
95
- });
96
-
97
- describe("resolveMSTeamsReplyPolicy", () => {
98
- it("forces thread replies for direct messages", () => {
99
- const policy = resolveMSTeamsReplyPolicy({
100
- isDirectMessage: true,
101
- globalConfig: { replyStyle: "top-level", requireMention: false },
102
- });
103
- expect(policy).toEqual({ requireMention: false, replyStyle: "thread" });
104
- });
105
-
106
- it("defaults to requireMention=true and replyStyle=thread", () => {
107
- const policy = resolveMSTeamsReplyPolicy({
108
- isDirectMessage: false,
109
- globalConfig: {},
110
- });
111
- expect(policy).toEqual({ requireMention: true, replyStyle: "thread" });
112
- });
113
-
114
- it("defaults replyStyle to top-level when requireMention=false", () => {
115
- const policy = resolveMSTeamsReplyPolicy({
116
- isDirectMessage: false,
117
- globalConfig: { requireMention: false },
118
- });
119
- expect(policy).toEqual({
120
- requireMention: false,
121
- replyStyle: "top-level",
122
- });
123
- });
124
-
125
- it("prefers channel overrides over team and global defaults", () => {
126
- const policy = resolveMSTeamsReplyPolicy({
127
- isDirectMessage: false,
128
- globalConfig: { requireMention: true },
129
- teamConfig: { requireMention: true },
130
- channelConfig: { requireMention: false },
131
- });
132
-
133
- // requireMention from channel -> false, and replyStyle defaults from requireMention -> top-level
134
- expect(policy).toEqual({
135
- requireMention: false,
136
- replyStyle: "top-level",
137
- });
138
- });
139
-
140
- it("inherits team mention settings when channel config is missing", () => {
141
- const policy = resolveMSTeamsReplyPolicy({
142
- isDirectMessage: false,
143
- globalConfig: { requireMention: true },
144
- teamConfig: { requireMention: false },
145
- });
146
- expect(policy).toEqual({
147
- requireMention: false,
148
- replyStyle: "top-level",
149
- });
150
- });
151
-
152
- it("uses explicit replyStyle even when requireMention defaults would differ", () => {
153
- const policy = resolveMSTeamsReplyPolicy({
154
- isDirectMessage: false,
155
- globalConfig: { requireMention: false, replyStyle: "thread" },
156
- });
157
- expect(policy).toEqual({ requireMention: false, replyStyle: "thread" });
158
- });
159
- });
160
-
161
- describe("isMSTeamsGroupAllowed", () => {
162
- it("allows when policy is open", () => {
163
- expect(
164
- isMSTeamsGroupAllowed({
165
- groupPolicy: "open",
166
- allowFrom: [],
167
- senderId: "user-id",
168
- senderName: "User",
169
- }),
170
- ).toBe(true);
171
- });
172
-
173
- it("blocks when policy is disabled", () => {
174
- expect(
175
- isMSTeamsGroupAllowed({
176
- groupPolicy: "disabled",
177
- allowFrom: ["user-id"],
178
- senderId: "user-id",
179
- senderName: "User",
180
- }),
181
- ).toBe(false);
182
- });
183
-
184
- it("blocks allowlist when empty", () => {
185
- expect(
186
- isMSTeamsGroupAllowed({
187
- groupPolicy: "allowlist",
188
- allowFrom: [],
189
- senderId: "user-id",
190
- senderName: "User",
191
- }),
192
- ).toBe(false);
193
- });
194
-
195
- it("allows allowlist when sender matches", () => {
196
- expect(
197
- isMSTeamsGroupAllowed({
198
- groupPolicy: "allowlist",
199
- allowFrom: ["User-Id"],
200
- senderId: "user-id",
201
- senderName: "User",
202
- }),
203
- ).toBe(true);
204
- });
205
-
206
- it("blocks sender-name allowlist matches by default", () => {
207
- expect(
208
- isMSTeamsGroupAllowed({
209
- groupPolicy: "allowlist",
210
- allowFrom: ["user"],
211
- senderId: "other",
212
- senderName: "User",
213
- }),
214
- ).toBe(false);
215
- });
216
-
217
- it("allows sender-name allowlist matches when explicitly enabled", () => {
218
- expect(
219
- isMSTeamsGroupAllowed({
220
- groupPolicy: "allowlist",
221
- allowFrom: ["user"],
222
- senderId: "other",
223
- senderName: "User",
224
- allowNameMatching: true,
225
- }),
226
- ).toBe(true);
227
- });
228
-
229
- it("allows allowlist wildcard", () => {
230
- expect(
231
- isMSTeamsGroupAllowed({
232
- groupPolicy: "allowlist",
233
- allowFrom: ["*"],
234
- senderId: "other",
235
- senderName: "User",
236
- }),
237
- ).toBe(true);
238
- });
239
- });
240
- });