@openclaw/msteams 2026.2.21 → 2026.2.22
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/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/attachments/download.ts +67 -68
- package/src/attachments/graph.ts +29 -28
- package/src/attachments/remote-media.ts +42 -0
- package/src/attachments/shared.test.ts +279 -0
- package/src/attachments/shared.ts +113 -0
- package/src/attachments.test.ts +126 -18
- package/src/channel.ts +8 -2
- package/src/directory-live.ts +2 -20
- package/src/graph-users.test.ts +66 -0
- package/src/graph-users.ts +29 -0
- package/src/graph.ts +1 -12
- package/src/messenger.ts +10 -21
- package/src/monitor-handler/message-handler.ts +7 -5
- package/src/probe.ts +1 -12
- package/src/resolve-allowlist.ts +2 -20
- package/src/token-response.test.ts +23 -0
- package/src/token-response.ts +11 -0
package/src/resolve-allowlist.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
+
import { searchGraphUsers } from "./graph-users.js";
|
|
1
2
|
import {
|
|
2
|
-
escapeOData,
|
|
3
|
-
fetchGraphJson,
|
|
4
|
-
type GraphResponse,
|
|
5
|
-
type GraphUser,
|
|
6
3
|
listChannelsForTeam,
|
|
7
4
|
listTeamsByName,
|
|
8
5
|
normalizeQuery,
|
|
@@ -182,22 +179,7 @@ export async function resolveMSTeamsUserAllowlist(params: {
|
|
|
182
179
|
results.push({ input, resolved: true, id: query });
|
|
183
180
|
continue;
|
|
184
181
|
}
|
|
185
|
-
|
|
186
|
-
if (query.includes("@")) {
|
|
187
|
-
const escaped = escapeOData(query);
|
|
188
|
-
const filter = `(mail eq '${escaped}' or userPrincipalName eq '${escaped}')`;
|
|
189
|
-
const path = `/users?$filter=${encodeURIComponent(filter)}&$select=id,displayName,mail,userPrincipalName`;
|
|
190
|
-
const res = await fetchGraphJson<GraphResponse<GraphUser>>({ token, path });
|
|
191
|
-
users = res.value ?? [];
|
|
192
|
-
} else {
|
|
193
|
-
const path = `/users?$search=${encodeURIComponent(`"displayName:${query}"`)}&$select=id,displayName,mail,userPrincipalName&$top=10`;
|
|
194
|
-
const res = await fetchGraphJson<GraphResponse<GraphUser>>({
|
|
195
|
-
token,
|
|
196
|
-
path,
|
|
197
|
-
headers: { ConsistencyLevel: "eventual" },
|
|
198
|
-
});
|
|
199
|
-
users = res.value ?? [];
|
|
200
|
-
}
|
|
182
|
+
const users = await searchGraphUsers({ token, query, top: 10 });
|
|
201
183
|
const match = users[0];
|
|
202
184
|
if (!match?.id) {
|
|
203
185
|
results.push({ input, resolved: false });
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { readAccessToken } from "./token-response.js";
|
|
3
|
+
|
|
4
|
+
describe("readAccessToken", () => {
|
|
5
|
+
it("returns raw string token values", () => {
|
|
6
|
+
expect(readAccessToken("abc")).toBe("abc");
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("returns accessToken from object value", () => {
|
|
10
|
+
expect(readAccessToken({ accessToken: "access-token" })).toBe("access-token");
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("returns token fallback from object value", () => {
|
|
14
|
+
expect(readAccessToken({ token: "fallback-token" })).toBe("fallback-token");
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("returns null for unsupported values", () => {
|
|
18
|
+
expect(readAccessToken({ accessToken: 123 })).toBeNull();
|
|
19
|
+
expect(readAccessToken({ token: false })).toBeNull();
|
|
20
|
+
expect(readAccessToken(null)).toBeNull();
|
|
21
|
+
expect(readAccessToken(undefined)).toBeNull();
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function readAccessToken(value: unknown): string | null {
|
|
2
|
+
if (typeof value === "string") {
|
|
3
|
+
return value;
|
|
4
|
+
}
|
|
5
|
+
if (value && typeof value === "object") {
|
|
6
|
+
const token =
|
|
7
|
+
(value as { accessToken?: unknown }).accessToken ?? (value as { token?: unknown }).token;
|
|
8
|
+
return typeof token === "string" ? token : null;
|
|
9
|
+
}
|
|
10
|
+
return null;
|
|
11
|
+
}
|