@openclaw/msteams 2026.7.2-beta.1 → 2026.7.2-beta.3
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/dist/api.cjs +2 -2
- package/dist/{channel-BSyPdpGN.cjs → channel-oNBYNcJT.cjs} +15 -21
- package/dist/channel-plugin-api.cjs +1 -1
- package/dist/{channel.runtime-DQTOzzet.cjs → channel.runtime-Sn3hY2Lu.cjs} +13 -7
- package/dist/delegated-state-DOSCHaAB.cjs +98 -0
- package/dist/directory-contract-api.cjs +1 -1
- package/dist/doctor-contract-api.cjs +86 -7
- package/dist/{messenger-DtS9gqkV.cjs → messenger-Do4oje4J.cjs} +90 -52
- package/dist/{oauth-C5E5powI.cjs → oauth-BUFvYhIw.cjs} +1 -1
- package/dist/{polls-BhoI4VaN.cjs → polls-CWExq2xZ.cjs} +24 -40
- package/dist/{resolve-allowlist-CyQ57MfH.cjs → resolve-allowlist-Dk-1CqBm.cjs} +41 -27
- package/dist/runtime-api.cjs +0 -7
- package/dist/secret-contract-api.cjs +6 -0
- package/dist/setup-plugin-api.cjs +2 -2
- package/dist/{setup-surface-BDTPN3dX.cjs → setup-surface-BcRVoUY8.cjs} +6 -14
- package/dist/{src-CUMz2B6f.cjs → src-BQM9QUTF.cjs} +455 -311
- package/dist/{sso-token-store-CktCz88k.cjs → sso-token-store-OSg229re.cjs} +4 -4
- package/npm-shrinkwrap.json +3 -3
- package/package.json +4 -4
- package/dist/rolldown-runtime-D6vf50IK.cjs +0 -28
package/dist/api.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_channel = require("./channel-
|
|
3
|
-
const require_setup_surface = require("./setup-surface-
|
|
2
|
+
const require_channel = require("./channel-oNBYNcJT.cjs");
|
|
3
|
+
const require_setup_surface = require("./setup-surface-BcRVoUY8.cjs");
|
|
4
4
|
exports.createMSTeamsSetupWizardBase = require_setup_surface.createMSTeamsSetupWizardBase;
|
|
5
5
|
exports.msteamsPlugin = require_channel.msteamsPlugin;
|
|
6
6
|
exports.msteamsSetupAdapter = require_setup_surface.msteamsSetupAdapter;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require("./runtime-api.cjs");
|
|
2
|
-
const require_resolve_allowlist = require("./resolve-allowlist-
|
|
2
|
+
const require_resolve_allowlist = require("./resolve-allowlist-Dk-1CqBm.cjs");
|
|
3
3
|
const require_config_schema = require("./config-schema-BSNLJUta.cjs");
|
|
4
|
-
const require_setup_surface = require("./setup-surface-
|
|
4
|
+
const require_setup_surface = require("./setup-surface-BcRVoUY8.cjs");
|
|
5
5
|
let openclaw_plugin_sdk_account_helpers = require("openclaw/plugin-sdk/account-helpers");
|
|
6
6
|
let openclaw_plugin_sdk_allow_from = require("openclaw/plugin-sdk/allow-from");
|
|
7
7
|
let openclaw_plugin_sdk_channel_config_helpers = require("openclaw/plugin-sdk/channel-config-helpers");
|
|
@@ -55,28 +55,19 @@ const msTeamsApprovalAuth = (0, openclaw_plugin_sdk_approval_auth_runtime.create
|
|
|
55
55
|
}).approvalAuth;
|
|
56
56
|
//#endregion
|
|
57
57
|
//#region extensions/msteams/src/doctor.ts
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return /\s/.test(withoutPrefix) || withoutPrefix.includes("@");
|
|
63
|
-
}
|
|
58
|
+
const isMSTeamsMutableAllowEntry = (0, openclaw_plugin_sdk_channel_policy.buildMutableAllowEntryDetector)({
|
|
59
|
+
prefixes: ["msteams:", "user:"],
|
|
60
|
+
stableIdPattern: /^[^\s@]+$/
|
|
61
|
+
});
|
|
64
62
|
const collectMSTeamsMutableAllowlistWarnings = (0, openclaw_plugin_sdk_channel_policy.createDangerousNameMatchingMutableAllowlistWarningCollector)({
|
|
65
63
|
channel: "msteams",
|
|
66
64
|
detector: isMSTeamsMutableAllowEntry,
|
|
67
|
-
collectLists: (scope) =>
|
|
68
|
-
pathLabel: `${scope.prefix}.allowFrom`,
|
|
69
|
-
list: scope.account.allowFrom
|
|
70
|
-
}, {
|
|
71
|
-
pathLabel: `${scope.prefix}.groupAllowFrom`,
|
|
72
|
-
list: scope.account.groupAllowFrom
|
|
73
|
-
}]
|
|
65
|
+
collectLists: (scope) => (0, openclaw_plugin_sdk_channel_policy.collectStandardAllowlistLists)(scope)
|
|
74
66
|
});
|
|
75
67
|
//#endregion
|
|
76
68
|
//#region extensions/msteams/src/policy.ts
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
const channelScopeKey = (teamKey, channelKey) => `${teamScopeKey(teamKey)}/channel:${encodeScopeSegment(channelKey)}`;
|
|
69
|
+
const teamScopeKey = (teamKey) => (0, openclaw_plugin_sdk_channel_policy.scopeKey)(["team", teamKey]);
|
|
70
|
+
const channelScopeKey = (teamKey, channelKey) => (0, openclaw_plugin_sdk_channel_policy.scopeKey)(["team", teamKey], ["channel", channelKey]);
|
|
80
71
|
function buildMSTeamsToolPolicyTree(teams) {
|
|
81
72
|
const scopes = {};
|
|
82
73
|
for (const [teamKey, team] of Object.entries(teams ?? {})) {
|
|
@@ -288,10 +279,12 @@ function buildMSTeamsPresentationCard(params) {
|
|
|
288
279
|
if (block.type === "buttons") for (const button of block.buttons) {
|
|
289
280
|
const action = (0, openclaw_plugin_sdk_interactive_runtime.resolveMessagePresentationButtonAction)(button);
|
|
290
281
|
if (action?.type === "url" || action?.type === "web-app") {
|
|
282
|
+
const url = (0, openclaw_plugin_sdk_string_coerce_runtime.normalizeOptionalString)(action.url);
|
|
283
|
+
if (!url) continue;
|
|
291
284
|
actions.push({
|
|
292
285
|
type: "Action.OpenUrl",
|
|
293
286
|
title: button.label,
|
|
294
|
-
url
|
|
287
|
+
url
|
|
295
288
|
});
|
|
296
289
|
continue;
|
|
297
290
|
}
|
|
@@ -678,7 +671,7 @@ const collectMSTeamsSecurityWarnings = (0, openclaw_plugin_sdk_channel_policy.cr
|
|
|
678
671
|
resolveGroupPolicy: ({ cfg }) => cfg.channels?.msteams?.groupPolicy,
|
|
679
672
|
collect: ({ groupPolicy }) => groupPolicy === "open" ? ["- MS Teams groups: groupPolicy=\"open\" allows any member to trigger (mention-gated). Set channels.msteams.groupPolicy=\"allowlist\" + channels.msteams.groupAllowFrom to restrict senders."] : []
|
|
680
673
|
});
|
|
681
|
-
const loadMSTeamsChannelRuntime = (0, openclaw_plugin_sdk_lazy_runtime.createLazyRuntimeNamedExport)(() => Promise.resolve().then(() => require("./channel.runtime-
|
|
674
|
+
const loadMSTeamsChannelRuntime = (0, openclaw_plugin_sdk_lazy_runtime.createLazyRuntimeNamedExport)(() => Promise.resolve().then(() => require("./channel.runtime-Sn3hY2Lu.cjs")), "msTeamsChannelRuntime");
|
|
682
675
|
const resolveMSTeamsChannelConfig = (cfg) => ({
|
|
683
676
|
allowFrom: cfg.channels?.msteams?.allowFrom,
|
|
684
677
|
defaultTo: cfg.channels?.msteams?.defaultTo
|
|
@@ -974,6 +967,7 @@ const msteamsPlugin = (0, openclaw_plugin_sdk_channel_core.createChatChannelPlug
|
|
|
974
967
|
setup: require_setup_surface.msteamsSetupAdapter,
|
|
975
968
|
messaging: {
|
|
976
969
|
targetPrefixes: ["msteams", "teams"],
|
|
970
|
+
directTargetStyle: "user-prefixed",
|
|
977
971
|
normalizeTarget: require_resolve_allowlist.normalizeMSTeamsMessagingTarget,
|
|
978
972
|
resolveOutboundSessionRoute: (params) => resolveMSTeamsOutboundSessionRoute(params),
|
|
979
973
|
targetResolver: {
|
|
@@ -1571,7 +1565,7 @@ const msteamsPlugin = (0, openclaw_plugin_sdk_channel_core.createChatChannelPlug
|
|
|
1571
1565
|
})
|
|
1572
1566
|
}),
|
|
1573
1567
|
gateway: { startAccount: async (ctx) => {
|
|
1574
|
-
const { monitorMSTeamsProvider } = await Promise.resolve().then(() => require("./src-
|
|
1568
|
+
const { monitorMSTeamsProvider } = await Promise.resolve().then(() => require("./src-BQM9QUTF.cjs"));
|
|
1575
1569
|
const port = ctx.cfg.channels?.msteams?.webhook?.port ?? 3978;
|
|
1576
1570
|
ctx.setStatus({
|
|
1577
1571
|
accountId: ctx.accountId,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const require_runtime = require("./runtime-gZTAuFux.cjs");
|
|
2
2
|
require("./runtime-api.cjs");
|
|
3
|
-
const require_resolve_allowlist = require("./resolve-allowlist-
|
|
4
|
-
const require_channel = require("./channel-
|
|
5
|
-
const require_setup_surface = require("./setup-surface-
|
|
6
|
-
const require_polls = require("./polls-
|
|
7
|
-
const require_messenger = require("./messenger-
|
|
3
|
+
const require_resolve_allowlist = require("./resolve-allowlist-Dk-1CqBm.cjs");
|
|
4
|
+
const require_channel = require("./channel-oNBYNcJT.cjs");
|
|
5
|
+
const require_setup_surface = require("./setup-surface-BcRVoUY8.cjs");
|
|
6
|
+
const require_polls = require("./polls-CWExq2xZ.cjs");
|
|
7
|
+
const require_messenger = require("./messenger-Do4oje4J.cjs");
|
|
8
8
|
let openclaw_plugin_sdk_channel_outbound = require("openclaw/plugin-sdk/channel-outbound");
|
|
9
9
|
let openclaw_plugin_sdk_string_coerce_runtime = require("openclaw/plugin-sdk/string-coerce-runtime");
|
|
10
10
|
let openclaw_plugin_sdk_reply_payload = require("openclaw/plugin-sdk/reply-payload");
|
|
@@ -1291,10 +1291,16 @@ async function probeMSTeams(cfg) {
|
|
|
1291
1291
|
try {
|
|
1292
1292
|
const { app } = await require_resolve_allowlist.loadMSTeamsSdkWithAuth(creds, require_resolve_allowlist.resolveMSTeamsSdkCloudOptions(cfg));
|
|
1293
1293
|
const tokenProvider = require_resolve_allowlist.createMSTeamsTokenProvider(app);
|
|
1294
|
-
if (!await
|
|
1294
|
+
if (!await require_resolve_allowlist.withMSTeamsRequestDeadline({
|
|
1295
|
+
label: "MS Teams Bot Framework probe token",
|
|
1296
|
+
work: () => tokenProvider.getAccessToken("https://api.botframework.com")
|
|
1297
|
+
})) throw new Error("Failed to acquire bot token");
|
|
1295
1298
|
let graph;
|
|
1296
1299
|
try {
|
|
1297
|
-
const accessToken = require_resolve_allowlist.readAccessToken(await
|
|
1300
|
+
const accessToken = require_resolve_allowlist.readAccessToken(await require_resolve_allowlist.withMSTeamsRequestDeadline({
|
|
1301
|
+
label: "MS Teams Graph probe token",
|
|
1302
|
+
work: () => tokenProvider.getAccessToken("https://graph.microsoft.com")
|
|
1303
|
+
}));
|
|
1298
1304
|
const payload = accessToken ? decodeJwtPayload(accessToken) : null;
|
|
1299
1305
|
graph = {
|
|
1300
1306
|
ok: true,
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
//#endregion
|
|
23
|
+
const require_runtime = require("./runtime-gZTAuFux.cjs");
|
|
24
|
+
//#region extensions/msteams/src/delegated-state.ts
|
|
25
|
+
const MSTEAMS_DELEGATED_TOKEN_LEGACY_FILENAME = "msteams-delegated.json";
|
|
26
|
+
const MSTEAMS_DELEGATED_TOKEN_NAMESPACE = "delegated-token";
|
|
27
|
+
const MSTEAMS_DELEGATED_TOKEN_KEY = "current";
|
|
28
|
+
function openDelegatedTokenStore(env) {
|
|
29
|
+
return require_runtime.getMSTeamsRuntime().state.openSyncKeyedStore({
|
|
30
|
+
namespace: MSTEAMS_DELEGATED_TOKEN_NAMESPACE,
|
|
31
|
+
maxEntries: 1,
|
|
32
|
+
overflowPolicy: "reject-new",
|
|
33
|
+
...env ? { env } : {}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function normalizeMSTeamsDelegatedTokens(value) {
|
|
37
|
+
if (!value || typeof value !== "object") return null;
|
|
38
|
+
const token = value;
|
|
39
|
+
if (typeof token.accessToken !== "string" || !token.accessToken || typeof token.refreshToken !== "string" || !token.refreshToken || typeof token.expiresAt !== "number" || !Number.isFinite(token.expiresAt) || !Array.isArray(token.scopes) || !token.scopes.every((scope) => typeof scope === "string" && scope.length > 0)) return null;
|
|
40
|
+
return {
|
|
41
|
+
accessToken: token.accessToken,
|
|
42
|
+
refreshToken: token.refreshToken,
|
|
43
|
+
expiresAt: token.expiresAt,
|
|
44
|
+
scopes: [...token.scopes],
|
|
45
|
+
...typeof token.userPrincipalName === "string" ? { userPrincipalName: token.userPrincipalName } : {}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function loadMSTeamsDelegatedTokens(env) {
|
|
49
|
+
return normalizeMSTeamsDelegatedTokens(openDelegatedTokenStore(env).lookup("current")) ?? void 0;
|
|
50
|
+
}
|
|
51
|
+
function saveMSTeamsDelegatedTokens(tokens, env) {
|
|
52
|
+
const normalized = normalizeMSTeamsDelegatedTokens(tokens);
|
|
53
|
+
if (!normalized) throw new Error("Invalid Microsoft Teams delegated token payload");
|
|
54
|
+
openDelegatedTokenStore(env).register(MSTEAMS_DELEGATED_TOKEN_KEY, normalized);
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
Object.defineProperty(exports, "MSTEAMS_DELEGATED_TOKEN_KEY", {
|
|
58
|
+
enumerable: true,
|
|
59
|
+
get: function() {
|
|
60
|
+
return MSTEAMS_DELEGATED_TOKEN_KEY;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
Object.defineProperty(exports, "MSTEAMS_DELEGATED_TOKEN_LEGACY_FILENAME", {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
get: function() {
|
|
66
|
+
return MSTEAMS_DELEGATED_TOKEN_LEGACY_FILENAME;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
Object.defineProperty(exports, "MSTEAMS_DELEGATED_TOKEN_NAMESPACE", {
|
|
70
|
+
enumerable: true,
|
|
71
|
+
get: function() {
|
|
72
|
+
return MSTEAMS_DELEGATED_TOKEN_NAMESPACE;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
Object.defineProperty(exports, "__toESM", {
|
|
76
|
+
enumerable: true,
|
|
77
|
+
get: function() {
|
|
78
|
+
return __toESM;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
Object.defineProperty(exports, "loadMSTeamsDelegatedTokens", {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function() {
|
|
84
|
+
return loadMSTeamsDelegatedTokens;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
Object.defineProperty(exports, "normalizeMSTeamsDelegatedTokens", {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function() {
|
|
90
|
+
return normalizeMSTeamsDelegatedTokens;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
Object.defineProperty(exports, "saveMSTeamsDelegatedTokens", {
|
|
94
|
+
enumerable: true,
|
|
95
|
+
get: function() {
|
|
96
|
+
return saveMSTeamsDelegatedTokens;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_resolve_allowlist = require("./resolve-allowlist-
|
|
2
|
+
const require_resolve_allowlist = require("./resolve-allowlist-Dk-1CqBm.cjs");
|
|
3
3
|
let openclaw_plugin_sdk_directory_runtime = require("openclaw/plugin-sdk/directory-runtime");
|
|
4
4
|
const msteamsDirectoryContractPlugin = {
|
|
5
5
|
id: "msteams",
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
const require_polls = require("./polls-
|
|
4
|
-
const require_sso_token_store = require("./sso-token-store-
|
|
2
|
+
const require_delegated_state = require("./delegated-state-DOSCHaAB.cjs");
|
|
3
|
+
const require_polls = require("./polls-CWExq2xZ.cjs");
|
|
4
|
+
const require_sso_token_store = require("./sso-token-store-OSg229re.cjs");
|
|
5
5
|
let openclaw_plugin_sdk_string_coerce_runtime = require("openclaw/plugin-sdk/string-coerce-runtime");
|
|
6
|
-
let node_path = require("node:path");
|
|
7
|
-
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
8
6
|
let node_crypto = require("node:crypto");
|
|
9
|
-
node_crypto =
|
|
7
|
+
node_crypto = require_delegated_state.__toESM(node_crypto, 1);
|
|
10
8
|
let node_fs_promises = require("node:fs/promises");
|
|
11
|
-
node_fs_promises =
|
|
9
|
+
node_fs_promises = require_delegated_state.__toESM(node_fs_promises, 1);
|
|
10
|
+
let node_path = require("node:path");
|
|
11
|
+
node_path = require_delegated_state.__toESM(node_path, 1);
|
|
12
12
|
let openclaw_plugin_sdk_runtime_doctor = require("openclaw/plugin-sdk/runtime-doctor");
|
|
13
13
|
let openclaw_plugin_sdk_session_store_runtime = require("openclaw/plugin-sdk/session-store-runtime");
|
|
14
14
|
//#region extensions/msteams/doctor-contract-api.ts
|
|
@@ -314,6 +314,85 @@ const stateMigrations = [
|
|
|
314
314
|
};
|
|
315
315
|
}
|
|
316
316
|
},
|
|
317
|
+
{
|
|
318
|
+
id: "msteams-delegated-token-json-to-plugin-state",
|
|
319
|
+
label: "Microsoft Teams delegated OAuth token",
|
|
320
|
+
async detectLegacyState(params) {
|
|
321
|
+
const filePath = resolveStateFilePath(params.stateDir, require_delegated_state.MSTEAMS_DELEGATED_TOKEN_LEGACY_FILENAME);
|
|
322
|
+
try {
|
|
323
|
+
return (await node_fs_promises.default.stat(filePath)).isFile() ? { preview: [`- ${MSTEAMS_PLUGIN_ID} delegated OAuth token -> plugin state (${require_delegated_state.MSTEAMS_DELEGATED_TOKEN_NAMESPACE})`] } : null;
|
|
324
|
+
} catch {
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
async migrateLegacyState(params) {
|
|
329
|
+
const changes = [];
|
|
330
|
+
const warnings = [];
|
|
331
|
+
const filePath = resolveStateFilePath(params.stateDir, require_delegated_state.MSTEAMS_DELEGATED_TOKEN_LEGACY_FILENAME);
|
|
332
|
+
let token;
|
|
333
|
+
try {
|
|
334
|
+
token = require_delegated_state.normalizeMSTeamsDelegatedTokens(JSON.parse(await node_fs_promises.default.readFile(filePath, "utf8")));
|
|
335
|
+
} catch (error) {
|
|
336
|
+
if (error.code === "ENOENT") return {
|
|
337
|
+
changes,
|
|
338
|
+
warnings
|
|
339
|
+
};
|
|
340
|
+
warnings.push(`Failed reading ${MSTEAMS_PLUGIN_ID} delegated OAuth token legacy source; left it in place`);
|
|
341
|
+
return {
|
|
342
|
+
changes,
|
|
343
|
+
warnings
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
if (!token) {
|
|
347
|
+
warnings.push(`Invalid ${MSTEAMS_PLUGIN_ID} delegated OAuth token legacy source; left it in place`);
|
|
348
|
+
return {
|
|
349
|
+
changes,
|
|
350
|
+
warnings
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
const store = params.context.openPluginStateKeyedStore({
|
|
354
|
+
namespace: require_delegated_state.MSTEAMS_DELEGATED_TOKEN_NAMESPACE,
|
|
355
|
+
maxEntries: 1,
|
|
356
|
+
overflowPolicy: "reject-new"
|
|
357
|
+
});
|
|
358
|
+
const existing = await store.lookup(require_delegated_state.MSTEAMS_DELEGATED_TOKEN_KEY);
|
|
359
|
+
if (existing && JSON.stringify(existing) !== JSON.stringify(token)) {
|
|
360
|
+
warnings.push(`Kept existing ${MSTEAMS_PLUGIN_ID} delegated OAuth token in plugin state; left differing legacy source in place`);
|
|
361
|
+
return {
|
|
362
|
+
changes,
|
|
363
|
+
warnings
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
if (!existing) try {
|
|
367
|
+
await store.registerIfAbsent(require_delegated_state.MSTEAMS_DELEGATED_TOKEN_KEY, token);
|
|
368
|
+
} catch (error) {
|
|
369
|
+
warnings.push(`Failed importing ${MSTEAMS_PLUGIN_ID} delegated OAuth token: ${String(error)}; left legacy source in place`);
|
|
370
|
+
return {
|
|
371
|
+
changes,
|
|
372
|
+
warnings
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
const persisted = require_delegated_state.normalizeMSTeamsDelegatedTokens(await store.lookup(require_delegated_state.MSTEAMS_DELEGATED_TOKEN_KEY));
|
|
376
|
+
if (!persisted || JSON.stringify(persisted) !== JSON.stringify(token)) {
|
|
377
|
+
warnings.push(`Failed verifying ${MSTEAMS_PLUGIN_ID} delegated OAuth token in plugin state; left legacy source in place`);
|
|
378
|
+
return {
|
|
379
|
+
changes,
|
|
380
|
+
warnings
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
changes.push(`Migrated ${MSTEAMS_PLUGIN_ID} delegated OAuth token -> plugin state`);
|
|
384
|
+
await (0, openclaw_plugin_sdk_runtime_doctor.archiveLegacyStateSource)({
|
|
385
|
+
filePath,
|
|
386
|
+
label: `${MSTEAMS_PLUGIN_ID} delegated OAuth token`,
|
|
387
|
+
changes,
|
|
388
|
+
warnings
|
|
389
|
+
});
|
|
390
|
+
return {
|
|
391
|
+
changes,
|
|
392
|
+
warnings
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
},
|
|
317
396
|
{
|
|
318
397
|
id: "msteams-feedback-learnings-json-to-plugin-state",
|
|
319
398
|
label: "Microsoft Teams feedback learnings",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_delegated_state = require("./delegated-state-DOSCHaAB.cjs");
|
|
2
2
|
const require_runtime = require("./runtime-gZTAuFux.cjs");
|
|
3
3
|
require("./runtime-api.cjs");
|
|
4
|
-
const require_resolve_allowlist = require("./resolve-allowlist-
|
|
5
|
-
const require_setup_surface = require("./setup-surface-
|
|
6
|
-
const require_polls = require("./polls-
|
|
4
|
+
const require_resolve_allowlist = require("./resolve-allowlist-Dk-1CqBm.cjs");
|
|
5
|
+
const require_setup_surface = require("./setup-surface-BcRVoUY8.cjs");
|
|
6
|
+
const require_polls = require("./polls-CWExq2xZ.cjs");
|
|
7
7
|
let openclaw_plugin_sdk_lazy_runtime = require("openclaw/plugin-sdk/lazy-runtime");
|
|
8
8
|
let openclaw_plugin_sdk_string_coerce_runtime = require("openclaw/plugin-sdk/string-coerce-runtime");
|
|
9
9
|
let openclaw_plugin_sdk_reply_payload = require("openclaw/plugin-sdk/reply-payload");
|
|
@@ -11,11 +11,11 @@ let openclaw_plugin_sdk_provider_http = require("openclaw/plugin-sdk/provider-ht
|
|
|
11
11
|
let node_dns_promises = require("node:dns/promises");
|
|
12
12
|
let openclaw_plugin_sdk_ssrf_policy = require("openclaw/plugin-sdk/ssrf-policy");
|
|
13
13
|
let openclaw_plugin_sdk_text_utility_runtime = require("openclaw/plugin-sdk/text-utility-runtime");
|
|
14
|
-
let node_path = require("node:path");
|
|
15
|
-
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
16
14
|
let openclaw_plugin_sdk_html_entity_runtime = require("openclaw/plugin-sdk/html-entity-runtime");
|
|
17
15
|
let node_crypto = require("node:crypto");
|
|
18
|
-
node_crypto =
|
|
16
|
+
node_crypto = require_delegated_state.__toESM(node_crypto, 1);
|
|
17
|
+
let node_path = require("node:path");
|
|
18
|
+
node_path = require_delegated_state.__toESM(node_path, 1);
|
|
19
19
|
let openclaw_plugin_sdk_reply_chunking = require("openclaw/plugin-sdk/reply-chunking");
|
|
20
20
|
let openclaw_plugin_sdk_web_media = require("openclaw/plugin-sdk/web-media");
|
|
21
21
|
let openclaw_plugin_sdk_media_runtime = require("openclaw/plugin-sdk/media-runtime");
|
|
@@ -256,6 +256,7 @@ async function uploadToConsentUrl(params) {
|
|
|
256
256
|
},
|
|
257
257
|
body: new Uint8Array(params.buffer)
|
|
258
258
|
}, params.timeoutMs ?? require_resolve_allowlist.resolveMSTeamsSharePointUploadTimeoutMs(params.buffer.length), fetchFn);
|
|
259
|
+
await res.body?.cancel().catch(() => void 0);
|
|
259
260
|
if (!res.ok) throw new Error(`File upload to consent URL failed: ${res.status} ${res.statusText}`);
|
|
260
261
|
}
|
|
261
262
|
//#endregion
|
|
@@ -270,7 +271,7 @@ const RAW_CHUNK_BYTES = 36 * 1024;
|
|
|
270
271
|
const PENDING_UPLOAD_META_MAX_ENTRIES = 200;
|
|
271
272
|
const PENDING_UPLOAD_META_NAMESPACE = "pending-uploads";
|
|
272
273
|
const PENDING_UPLOAD_CHUNKS_NAMESPACE = "pending-upload-chunks";
|
|
273
|
-
const
|
|
274
|
+
const PENDING_UPLOAD_MUTATION_KEY = "pending-uploads";
|
|
274
275
|
function createMetaStore(options) {
|
|
275
276
|
return require_runtime.getMSTeamsRuntime().state.openKeyedStore({
|
|
276
277
|
namespace: PENDING_UPLOAD_META_NAMESPACE,
|
|
@@ -339,7 +340,7 @@ async function registerUploadRows(record, metaStore, chunkStore, ttlMs, overwrit
|
|
|
339
340
|
}));
|
|
340
341
|
}
|
|
341
342
|
async function withPendingUploadLock(options, run) {
|
|
342
|
-
return await require_polls.withMSTeamsSqliteMutationLock(options,
|
|
343
|
+
return await require_polls.withMSTeamsSqliteMutationLock(options, PENDING_UPLOAD_MUTATION_KEY, run);
|
|
343
344
|
}
|
|
344
345
|
async function readUploadRows(id, metaStore, chunkStore) {
|
|
345
346
|
const meta = await metaStore.lookup(buildMetaKey(id));
|
|
@@ -632,6 +633,15 @@ function requireMSTeamsSharePointSiteId(siteId) {
|
|
|
632
633
|
if (!normalized) throw new Error("channels.msteams.sharePointSiteId is required to send files to group chats or channels");
|
|
633
634
|
return normalized;
|
|
634
635
|
}
|
|
636
|
+
const SHAREPOINT_REQUEST_TIMEOUT_LABEL = "MS Teams SharePoint request";
|
|
637
|
+
const SHAREPOINT_UPLOAD_TIMEOUT_LABEL = "MS Teams SharePoint upload";
|
|
638
|
+
const GRAPH_TOKEN_TIMEOUT_LABEL = "MS Teams Graph token acquisition";
|
|
639
|
+
async function getGraphAccessToken(tokenProvider) {
|
|
640
|
+
return await require_resolve_allowlist.withMSTeamsRequestDeadline({
|
|
641
|
+
label: GRAPH_TOKEN_TIMEOUT_LABEL,
|
|
642
|
+
work: async () => await tokenProvider.getAccessToken(GRAPH_SCOPE)
|
|
643
|
+
});
|
|
644
|
+
}
|
|
635
645
|
/**
|
|
636
646
|
* Upload a file to a SharePoint site.
|
|
637
647
|
* This is used for group chats and channels where /me/drive doesn't work for bots.
|
|
@@ -640,19 +650,26 @@ function requireMSTeamsSharePointSiteId(siteId) {
|
|
|
640
650
|
*/
|
|
641
651
|
async function uploadToSharePoint(params) {
|
|
642
652
|
const fetchFn = params.fetchFn ?? fetch;
|
|
643
|
-
const token = await params.tokenProvider.getAccessToken(GRAPH_SCOPE);
|
|
644
653
|
const uploadPath = `/OpenClawShared/${encodeURIComponent(params.filename)}`;
|
|
645
|
-
const
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
654
|
+
const data = await require_resolve_allowlist.withMSTeamsAbortableRequestTimeout({
|
|
655
|
+
label: SHAREPOINT_UPLOAD_TIMEOUT_LABEL,
|
|
656
|
+
timeoutMs: require_resolve_allowlist.resolveMSTeamsSharePointUploadTimeoutMs(params.buffer.length),
|
|
657
|
+
work: async (signal) => {
|
|
658
|
+
const token = await getGraphAccessToken(params.tokenProvider);
|
|
659
|
+
const res = await fetchFn(`${GRAPH_ROOT}/sites/${params.siteId}/drive/root:${uploadPath}:/content`, {
|
|
660
|
+
method: "PUT",
|
|
661
|
+
headers: {
|
|
662
|
+
"User-Agent": require_resolve_allowlist.buildUserAgent(),
|
|
663
|
+
Authorization: `Bearer ${token}`,
|
|
664
|
+
"Content-Type": params.contentType ?? "application/octet-stream"
|
|
665
|
+
},
|
|
666
|
+
body: new Uint8Array(params.buffer),
|
|
667
|
+
signal
|
|
668
|
+
});
|
|
669
|
+
if (!res.ok) throw await require_resolve_allowlist.createMSTeamsHttpError(res, "SharePoint upload failed");
|
|
670
|
+
return await (0, openclaw_plugin_sdk_provider_http.readProviderJsonResponse)(res, "msteams.graph-upload.uploadSharePointFile");
|
|
671
|
+
}
|
|
653
672
|
});
|
|
654
|
-
if (!res.ok) throw await require_resolve_allowlist.createMSTeamsHttpError(res, "SharePoint upload failed");
|
|
655
|
-
const data = await (0, openclaw_plugin_sdk_provider_http.readProviderJsonResponse)(res, "msteams.graph-upload.uploadSharePointFile");
|
|
656
673
|
if (!data.id || !data.webUrl || !data.name) throw new Error("SharePoint upload response missing required fields");
|
|
657
674
|
return {
|
|
658
675
|
id: data.id,
|
|
@@ -669,13 +686,21 @@ async function uploadToSharePoint(params) {
|
|
|
669
686
|
*/
|
|
670
687
|
async function getDriveItemProperties(params) {
|
|
671
688
|
const fetchFn = params.fetchFn ?? fetch;
|
|
672
|
-
const
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
689
|
+
const data = await require_resolve_allowlist.withMSTeamsAbortableRequestTimeout({
|
|
690
|
+
label: SHAREPOINT_REQUEST_TIMEOUT_LABEL,
|
|
691
|
+
work: async (signal) => {
|
|
692
|
+
const token = await getGraphAccessToken(params.tokenProvider);
|
|
693
|
+
const res = await fetchFn(`${GRAPH_ROOT}/sites/${params.siteId}/drive/items/${params.itemId}?$select=eTag,webDavUrl,name`, {
|
|
694
|
+
headers: {
|
|
695
|
+
"User-Agent": require_resolve_allowlist.buildUserAgent(),
|
|
696
|
+
Authorization: `Bearer ${token}`
|
|
697
|
+
},
|
|
698
|
+
signal
|
|
699
|
+
});
|
|
700
|
+
if (!res.ok) throw await require_resolve_allowlist.createMSTeamsHttpError(res, "Get driveItem properties failed");
|
|
701
|
+
return await (0, openclaw_plugin_sdk_provider_http.readProviderJsonResponse)(res, "msteams.graph-upload.getDriveItemProperties");
|
|
702
|
+
}
|
|
703
|
+
});
|
|
679
704
|
if (!data.eTag || !data.webDavUrl || !data.name) throw new Error("DriveItem response missing required properties (eTag, webDavUrl, or name)");
|
|
680
705
|
return {
|
|
681
706
|
eTag: data.eTag,
|
|
@@ -689,13 +714,21 @@ async function getDriveItemProperties(params) {
|
|
|
689
714
|
*/
|
|
690
715
|
async function getChatMembers(params) {
|
|
691
716
|
const fetchFn = params.fetchFn ?? fetch;
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
717
|
+
return await require_resolve_allowlist.withMSTeamsAbortableRequestTimeout({
|
|
718
|
+
label: SHAREPOINT_REQUEST_TIMEOUT_LABEL,
|
|
719
|
+
work: async (signal) => {
|
|
720
|
+
const token = await getGraphAccessToken(params.tokenProvider);
|
|
721
|
+
const res = await fetchFn(`${GRAPH_ROOT}/chats/${params.chatId}/members`, {
|
|
722
|
+
headers: {
|
|
723
|
+
"User-Agent": require_resolve_allowlist.buildUserAgent(),
|
|
724
|
+
Authorization: `Bearer ${token}`
|
|
725
|
+
},
|
|
726
|
+
signal
|
|
727
|
+
});
|
|
728
|
+
if (!res.ok) throw await require_resolve_allowlist.createMSTeamsHttpError(res, res.status === 403 ? "Get chat members failed; verify Graph chat-member permissions and tenant access policies" : "Get chat members failed");
|
|
729
|
+
return ((await (0, openclaw_plugin_sdk_provider_http.readProviderJsonResponse)(res, "msteams.graph-upload.getChatMembers")).value ?? []).map((member) => ({ aadObjectId: member.userId ?? "" })).filter((member) => member.aadObjectId);
|
|
730
|
+
}
|
|
731
|
+
});
|
|
699
732
|
}
|
|
700
733
|
/**
|
|
701
734
|
* Create a sharing link for a SharePoint drive item.
|
|
@@ -704,7 +737,6 @@ async function getChatMembers(params) {
|
|
|
704
737
|
*/
|
|
705
738
|
async function createSharePointSharingLink(params) {
|
|
706
739
|
const fetchFn = params.fetchFn ?? fetch;
|
|
707
|
-
const token = await params.tokenProvider.getAccessToken(GRAPH_SCOPE);
|
|
708
740
|
const scope = params.scope ?? "organization";
|
|
709
741
|
const apiRoot = scope === "users" ? GRAPH_BETA : GRAPH_ROOT;
|
|
710
742
|
const body = {
|
|
@@ -712,17 +744,24 @@ async function createSharePointSharingLink(params) {
|
|
|
712
744
|
scope: scope === "users" ? "users" : "organization"
|
|
713
745
|
};
|
|
714
746
|
if (scope === "users" && params.recipientObjectIds?.length) body.recipients = params.recipientObjectIds.map((id) => ({ objectId: id }));
|
|
715
|
-
const
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
747
|
+
const data = await require_resolve_allowlist.withMSTeamsAbortableRequestTimeout({
|
|
748
|
+
label: SHAREPOINT_REQUEST_TIMEOUT_LABEL,
|
|
749
|
+
work: async (signal) => {
|
|
750
|
+
const token = await getGraphAccessToken(params.tokenProvider);
|
|
751
|
+
const res = await fetchFn(`${apiRoot}/sites/${params.siteId}/drive/items/${params.itemId}/createLink`, {
|
|
752
|
+
method: "POST",
|
|
753
|
+
headers: {
|
|
754
|
+
"User-Agent": require_resolve_allowlist.buildUserAgent(),
|
|
755
|
+
Authorization: `Bearer ${token}`,
|
|
756
|
+
"Content-Type": "application/json"
|
|
757
|
+
},
|
|
758
|
+
body: JSON.stringify(body),
|
|
759
|
+
signal
|
|
760
|
+
});
|
|
761
|
+
if (!res.ok) throw await require_resolve_allowlist.createMSTeamsHttpError(res, "Create SharePoint sharing link failed");
|
|
762
|
+
return await (0, openclaw_plugin_sdk_provider_http.readProviderJsonResponse)(res, "msteams.graph-upload.createSharePointSharingLink");
|
|
763
|
+
}
|
|
723
764
|
});
|
|
724
|
-
if (!res.ok) throw await require_resolve_allowlist.createMSTeamsHttpError(res, "Create SharePoint sharing link failed");
|
|
725
|
-
const data = await (0, openclaw_plugin_sdk_provider_http.readProviderJsonResponse)(res, "msteams.graph-upload.createSharePointSharingLink");
|
|
726
765
|
if (!data.link?.webUrl) throw new Error("Create SharePoint sharing link response missing webUrl");
|
|
727
766
|
return { webUrl: data.link.webUrl };
|
|
728
767
|
}
|
|
@@ -734,7 +773,7 @@ async function createSharePointSharingLink(params) {
|
|
|
734
773
|
*
|
|
735
774
|
* @param params.siteId - SharePoint site ID
|
|
736
775
|
* @param params.chatId - Optional chat ID for per-user sharing (group chats)
|
|
737
|
-
* @param params.usePerUserSharing - Whether to use per-user sharing (requires beta API +
|
|
776
|
+
* @param params.usePerUserSharing - Whether to use per-user sharing (requires beta API + chat-member read access)
|
|
738
777
|
*/
|
|
739
778
|
async function uploadAndShareSharePoint(params) {
|
|
740
779
|
const uploaded = await uploadToSharePoint({
|
|
@@ -747,17 +786,16 @@ async function uploadAndShareSharePoint(params) {
|
|
|
747
786
|
});
|
|
748
787
|
let scope = "organization";
|
|
749
788
|
let recipientObjectIds;
|
|
750
|
-
if (params.usePerUserSharing && params.chatId)
|
|
789
|
+
if (params.usePerUserSharing && params.chatId) {
|
|
751
790
|
const members = await getChatMembers({
|
|
752
791
|
chatId: params.chatId,
|
|
753
792
|
tokenProvider: params.tokenProvider,
|
|
754
793
|
fetchFn: params.fetchFn
|
|
755
794
|
});
|
|
756
|
-
if (members.length
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
} catch {}
|
|
795
|
+
if (members.length === 0) throw new Error("MS Teams chat member lookup returned no recipients");
|
|
796
|
+
scope = "users";
|
|
797
|
+
recipientObjectIds = members.map((member) => member.aadObjectId);
|
|
798
|
+
}
|
|
761
799
|
const shareLink = await createSharePointSharingLink({
|
|
762
800
|
siteId: params.siteId,
|
|
763
801
|
itemId: uploaded.id,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_resolve_allowlist = require("./resolve-allowlist-
|
|
1
|
+
const require_resolve_allowlist = require("./resolve-allowlist-Dk-1CqBm.cjs");
|
|
2
2
|
let openclaw_plugin_sdk_provider_auth = require("openclaw/plugin-sdk/provider-auth");
|
|
3
3
|
let openclaw_plugin_sdk_provider_auth_runtime = require("openclaw/plugin-sdk/provider-auth-runtime");
|
|
4
4
|
let openclaw_plugin_sdk_runtime_env = require("openclaw/plugin-sdk/runtime-env");
|