@openclaw/slack 2026.9.1-beta.1 → 2026.9.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.
- package/dist/{account-inspect-CN2hBsim.js → account-inspect-C3sePHWa.js} +3 -3
- package/dist/account-inspect-api.js +1 -1
- package/dist/{action-runtime-BoSeX09X.js → action-runtime-DftQWpI4.js} +84 -66
- package/dist/action-runtime.runtime-rHI3UAh4.js +2 -0
- package/dist/{actions-XdQyjG_p.js → actions-CFkvEv1d.js} +198 -54
- package/dist/api.js +14 -14
- package/dist/{approval-handler.runtime-DxXfGX_Z.js → approval-handler.runtime-BeILKdw4.js} +47 -25
- package/dist/{channel-C_vnTgxo.js → channel-CmOuxbOD.js} +76 -133
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel-type-j-2lalcC.js → channel-type-BWt2CRaI.js} +2 -2
- package/dist/{channel.setup-aal8tokM.js → channel.setup-D5z1ReaT.js} +29 -23
- package/dist/{config-schema-CN3XZRX5.js → config-schema-JDx_f9Zb.js} +26 -17
- package/dist/{cursor-pages-eX7p8Wwt.js → cursor-pages-ByFwo-Py.js} +7 -1
- package/dist/{directory-config-DqfQ42OV.js → directory-config-Bmw4ykSy.js} +4 -3
- package/dist/directory-contract-api.js +1 -1
- package/dist/{directory-live-lC6X_Ru-.js → directory-live-BuBPHmju.js} +3 -8
- package/dist/{doctor-contract-BAy7-EUQ.js → doctor-contract-BNjw9bxb.js} +5 -4
- package/dist/doctor-contract-api.js +1 -1
- package/dist/{message-tool-api-CWosHSi5.js → message-tool-api-uNEfQYGY.js} +19 -2
- package/dist/message-tool-api.js +1 -1
- package/dist/{monitor-DrNCGneD.js → monitor-DI07pfJl.js} +3 -3
- package/dist/{outbound-adapter-DkT2vUE9.js → outbound-adapter-B5QyTRpJ.js} +96 -91
- package/dist/{pipeline.runtime-CRRng_Nw.js → pipeline.runtime-BdIwZgm4.js} +596 -920
- package/dist/{policy-BoP6t88v.js → policy-Bh5TOqII.js} +7 -4
- package/dist/{probe-4_aHtVT3.js → probe-Biy--yhL.js} +251 -12
- package/dist/{provider-D4nDgxCh.js → provider-DoaUvAM4.js} +5621 -4944
- package/dist/{relay-source-CEmze11m.js → relay-source-D4uecp68.js} +6 -4
- package/dist/{replies-D9XMM_S0.js → replies-DENuTcPO.js} +21 -16
- package/dist/reply-blocks-PRkhyAN7.js +790 -0
- package/dist/{resolve-channels-DSamDgVs.js → resolve-channels-DQGV2VrE.js} +6 -10
- package/dist/{resolve-users-CIzwbaJR.js → resolve-users-DRGt_Q4I.js} +5 -4
- package/dist/runtime-api.js +10 -10
- package/dist/{scopes-BBrUzpBH.js → scopes-CZzeGdWV.js} +1 -1
- package/dist/{send-DtjEnlLh.js → send-DElUcgIs.js} +32 -24
- package/dist/send-results-eeOu_HYm.js +23 -0
- package/dist/{send.runtime-DQeNKa2J.js → send.runtime-C8D6cKGm.js} +1 -1
- package/dist/{group-policy-CU1tEGpS.js → session-status-BynwcZSO.js} +284 -1013
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{setup-surface-CsBCM4rP.js → setup-surface-B1_gpGBl.js} +5 -5
- package/dist/{shared-D9GeeR9K.js → shared-CNQsWJT7.js} +7 -5
- package/dist/{slash-dispatch.runtime-Chr3YHnT.js → slash-dispatch.runtime-DhsXavSY.js} +2 -2
- package/dist/{target-parsing-BnMD2ZqZ.js → target-parsing-PbxGDbr9.js} +11 -6
- package/dist/{targets-Cx5W_n3W.js → targets-7FexXJ62.js} +1 -1
- package/dist/{thread-ts-DUGhaYKq.js → thread-ts-CukseRVL.js} +5 -1
- package/node_modules/@slack/bolt/node_modules/negotiator/lib/accept.js +54 -0
- package/node_modules/@slack/bolt/node_modules/negotiator/lib/charset.js +10 -34
- package/node_modules/@slack/bolt/node_modules/negotiator/lib/encoding.js +9 -30
- package/node_modules/@slack/bolt/node_modules/negotiator/lib/language.js +15 -36
- package/node_modules/@slack/bolt/node_modules/negotiator/lib/mediaType.js +16 -134
- package/node_modules/@slack/bolt/node_modules/negotiator/node_modules/content-type/LICENSE +22 -0
- package/node_modules/@slack/bolt/node_modules/negotiator/node_modules/content-type/README.md +71 -0
- package/node_modules/@slack/bolt/node_modules/negotiator/node_modules/content-type/dist/index.d.ts +46 -0
- package/node_modules/@slack/bolt/node_modules/negotiator/node_modules/content-type/dist/index.js +176 -0
- package/node_modules/@slack/bolt/node_modules/negotiator/node_modules/content-type/dist/index.js.map +1 -0
- package/node_modules/@slack/bolt/node_modules/negotiator/node_modules/content-type/package.json +52 -0
- package/node_modules/@slack/bolt/node_modules/negotiator/package.json +16 -10
- package/node_modules/typebox/build/format/email.mjs +1 -1
- package/node_modules/typebox/build/format/idna/idn-hostname.mjs +19 -1
- package/node_modules/typebox/build/format/json_pointer.d.mts +2 -2
- package/node_modules/typebox/build/format/json_pointer.mjs +2 -2
- package/node_modules/typebox/build/format/json_pointer_uri_fragment.d.mts +2 -2
- package/node_modules/typebox/build/format/json_pointer_uri_fragment.mjs +2 -2
- package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
- package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
- package/node_modules/typebox/build/system/memory/assign.mjs +2 -1
- package/node_modules/typebox/build/system/memory/create.mjs +3 -4
- package/node_modules/typebox/build/system/memory/discard.mjs +2 -2
- package/node_modules/typebox/build/system/memory/freeze.d.mts +4 -0
- package/node_modules/typebox/build/system/memory/freeze.mjs +6 -0
- package/node_modules/typebox/build/system/memory/update.mjs +3 -2
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/undici/lib/dispatcher/balanced-pool.js +4 -2
- package/node_modules/undici/lib/dispatcher/client-h1.js +12 -4
- package/node_modules/undici/lib/dispatcher/client-h2.js +70 -14
- package/node_modules/undici/lib/dispatcher/client.js +6 -2
- package/node_modules/undici/lib/handler/cache-handler.js +21 -5
- package/node_modules/undici/lib/handler/retry-handler.js +42 -7
- package/node_modules/undici/lib/interceptor/cache.js +20 -1
- package/node_modules/undici/lib/interceptor/decompress.js +146 -14
- package/node_modules/undici/lib/interceptor/dump.js +10 -23
- package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +245 -150
- package/node_modules/undici/lib/web/websocket/connection.js +1 -1
- package/node_modules/undici/lib/web/websocket/permessage-deflate.js +5 -0
- package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +8 -10
- package/node_modules/undici/package.json +1 -1
- package/node_modules/undici/types/interceptors.d.ts +2 -0
- package/openclaw.plugin.json +17 -9
- package/package.json +6 -6
- package/skills/_vendor/slack-skills-plugin.LICENSE +21 -0
- package/skills/_vendor/slack-skills-plugin.json +31 -0
- package/skills/block-kit/SKILL.md +37 -0
- package/skills/block-kit/references/official-block-kit.md +257 -0
- package/skills/block-kit/references/official-common-patterns.md +385 -0
- package/skills/slack/SKILL.md +1 -1
- package/dist/action-runtime.runtime-Dpa16J87.js +0 -2
- package/dist/conversation-binding-route-DFVLUdYF.js +0 -115
- package/dist/slack-client-kind-hSfjXyUM.js +0 -94
- package/node_modules/@slack/bolt/node_modules/negotiator/HISTORY.md +0 -114
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as buildSlackChannelPolicyScope, r as buildSlackChannelIdCandidates } from "./session-status-BynwcZSO.js";
|
|
2
|
+
import { D as resolveSlackUserAllowListForTeam, T as normalizeSlackSlug } from "./probe-Biy--yhL.js";
|
|
2
3
|
import { applyChannelMatchMeta, buildChannelKeyCandidates } from "openclaw/plugin-sdk/channel-targets";
|
|
3
4
|
import { mergePairLoopGuardConfig } from "openclaw/plugin-sdk/pair-loop-guard-runtime";
|
|
4
5
|
//#region extensions/slack/src/monitor/channel-config.ts
|
|
@@ -17,9 +18,10 @@ function resolveSlackChannelConfig(params) {
|
|
|
17
18
|
const keys = channelKeys ?? Object.keys(entries);
|
|
18
19
|
const normalizedName = channelName ? normalizeSlackSlug(channelName) : "";
|
|
19
20
|
const directName = channelName ? channelName.trim() : "";
|
|
21
|
+
const candidates = buildChannelKeyCandidates(...buildSlackChannelIdCandidates(channelId, params.teamId, { allowUnscoped: params.allowUnscoped }), allowNameMatching ? channelName ? `#${directName}` : void 0 : void 0, allowNameMatching ? directName : void 0, allowNameMatching ? normalizedName : void 0);
|
|
20
22
|
const match = buildSlackChannelPolicyScope({
|
|
21
23
|
channels: entries,
|
|
22
|
-
candidates
|
|
24
|
+
candidates
|
|
23
25
|
});
|
|
24
26
|
const { entry: matched, wildcardEntry: fallback } = match;
|
|
25
27
|
const requireMentionDefault = defaultRequireMention ?? true;
|
|
@@ -46,7 +48,7 @@ function resolveSlackChannelConfig(params) {
|
|
|
46
48
|
const skills = firstDefined(resolved.skills, fallback?.skills);
|
|
47
49
|
const systemPrompt = firstDefined(resolved.systemPrompt, fallback?.systemPrompt);
|
|
48
50
|
const presenceEvents = firstDefined(resolved.presenceEvents, fallback?.presenceEvents);
|
|
49
|
-
|
|
51
|
+
const result = {
|
|
50
52
|
allowed,
|
|
51
53
|
requireMention,
|
|
52
54
|
ignoreOtherMentions,
|
|
@@ -57,7 +59,8 @@ function resolveSlackChannelConfig(params) {
|
|
|
57
59
|
skills,
|
|
58
60
|
systemPrompt,
|
|
59
61
|
presenceEvents
|
|
60
|
-
}
|
|
62
|
+
};
|
|
63
|
+
return applyChannelMatchMeta(result, match);
|
|
61
64
|
}
|
|
62
65
|
//#endregion
|
|
63
66
|
//#region extensions/slack/src/monitor/policy.ts
|
|
@@ -1,16 +1,130 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
2
|
import { u as formatSlackBotTokenIdentityWarning } from "./accounts-Dm_H77gH.js";
|
|
3
|
+
import { a as parseSlackTarget } from "./target-parsing-PbxGDbr9.js";
|
|
3
4
|
import { createRequire } from "node:module";
|
|
4
|
-
import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
5
|
+
import { isRecord, normalizeOptionalLowercaseString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
6
|
+
import { sleepWithAbort } from "openclaw/plugin-sdk/runtime-env";
|
|
7
|
+
import { compileAllowlist, resolveCompiledAllowlistMatch } from "openclaw/plugin-sdk/allow-from";
|
|
8
|
+
import { normalizeHyphenSlug, normalizeStringEntries as normalizeStringEntries$1, normalizeStringEntriesLower } from "openclaw/plugin-sdk/string-normalization-runtime";
|
|
5
9
|
import { runChannelProbe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
6
10
|
import { createHash } from "node:crypto";
|
|
7
|
-
import { WebClient } from "@slack/web-api";
|
|
11
|
+
import { WebAPIRateLimitedError, WebClient } from "@slack/web-api";
|
|
8
12
|
import { addActiveManagedProxyTlsOptions, resolveEnvHttpProxyAgentOptions, resolveFetch } from "openclaw/plugin-sdk/fetch-runtime";
|
|
9
13
|
import { isDebugProxyGlobalFetchPatchInstalled } from "openclaw/plugin-sdk/proxy-capture";
|
|
14
|
+
import { parseRetryAfterHeaderSeconds, retryAsync } from "openclaw/plugin-sdk/retry-runtime";
|
|
10
15
|
import { redactSensitiveText } from "openclaw/plugin-sdk/logging-core";
|
|
16
|
+
import { defineStableChannelIngressIdentity } from "openclaw/plugin-sdk/channel-ingress-runtime";
|
|
17
|
+
//#region extensions/slack/src/monitor/allow-list.ts
|
|
18
|
+
const SLACK_SLUG_CACHE_MAX = 512;
|
|
19
|
+
const SLACK_STABLE_USER_ID_RE = /^[ubw][a-z0-9]+$/;
|
|
20
|
+
const slackSlugCache = /* @__PURE__ */ new Map();
|
|
21
|
+
function normalizeSlackSlug(raw) {
|
|
22
|
+
const key = raw ?? "";
|
|
23
|
+
const cached = slackSlugCache.get(key);
|
|
24
|
+
if (cached !== void 0) return cached;
|
|
25
|
+
const normalized = normalizeHyphenSlug(raw);
|
|
26
|
+
slackSlugCache.set(key, normalized);
|
|
27
|
+
if (slackSlugCache.size > SLACK_SLUG_CACHE_MAX) {
|
|
28
|
+
const oldest = slackSlugCache.keys().next();
|
|
29
|
+
if (!oldest.done) slackSlugCache.delete(oldest.value);
|
|
30
|
+
}
|
|
31
|
+
return normalized;
|
|
32
|
+
}
|
|
33
|
+
function normalizeAllowList(list) {
|
|
34
|
+
return normalizeStringEntries$1(list);
|
|
35
|
+
}
|
|
36
|
+
function normalizeAllowListLower(list) {
|
|
37
|
+
return normalizeStringEntriesLower(list);
|
|
38
|
+
}
|
|
39
|
+
function normalizeSlackAllowOwnerEntry(entry) {
|
|
40
|
+
const trimmed = normalizeOptionalLowercaseString(entry);
|
|
41
|
+
if (!trimmed || trimmed === "*") return;
|
|
42
|
+
try {
|
|
43
|
+
const target = parseSlackTarget(trimmed);
|
|
44
|
+
if (target?.kind === "user" && target.teamId) return target.id.toLowerCase();
|
|
45
|
+
} catch {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const withoutPrefix = trimmed.replace(/^(slack:|user:)/, "");
|
|
49
|
+
return SLACK_STABLE_USER_ID_RE.test(withoutPrefix) ? withoutPrefix : void 0;
|
|
50
|
+
}
|
|
51
|
+
function resolveSlackAllowListMatch(params) {
|
|
52
|
+
const compiledAllowList = compileAllowlist(params.allowList);
|
|
53
|
+
const teamId = normalizeOptionalLowercaseString(params.teamId);
|
|
54
|
+
const id = normalizeOptionalLowercaseString(params.id);
|
|
55
|
+
const name = normalizeOptionalLowercaseString(params.name);
|
|
56
|
+
const slug = normalizeSlackSlug(name);
|
|
57
|
+
const scopedCandidates = [{
|
|
58
|
+
value: teamId && id ? `team:${teamId}:user:${id}` : void 0,
|
|
59
|
+
source: "workspace-id"
|
|
60
|
+
}];
|
|
61
|
+
const unscopedCandidates = [
|
|
62
|
+
{
|
|
63
|
+
value: id,
|
|
64
|
+
source: "id"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
value: id ? `slack:${id}` : void 0,
|
|
68
|
+
source: "prefixed-id"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
value: id ? `user:${id}` : void 0,
|
|
72
|
+
source: "prefixed-user"
|
|
73
|
+
},
|
|
74
|
+
...params.allowNameMatching === true ? [
|
|
75
|
+
{
|
|
76
|
+
value: name,
|
|
77
|
+
source: "name"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
value: name ? `slack:${name}` : void 0,
|
|
81
|
+
source: "prefixed-name"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
value: slug,
|
|
85
|
+
source: "slug"
|
|
86
|
+
}
|
|
87
|
+
] : []
|
|
88
|
+
];
|
|
89
|
+
return resolveCompiledAllowlistMatch({
|
|
90
|
+
compiledAllowlist: compiledAllowList,
|
|
91
|
+
candidates: [...scopedCandidates, ...unscopedCandidates]
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function allowListMatches(params) {
|
|
95
|
+
return resolveSlackAllowListMatch(params).allowed;
|
|
96
|
+
}
|
|
97
|
+
function resolveSlackUserAllowed(params) {
|
|
98
|
+
const allowList = normalizeAllowListLower(params.allowList);
|
|
99
|
+
if (allowList.length === 0) return true;
|
|
100
|
+
return allowListMatches({
|
|
101
|
+
allowList,
|
|
102
|
+
teamId: params.teamId,
|
|
103
|
+
id: params.userId,
|
|
104
|
+
name: params.userName,
|
|
105
|
+
allowNameMatching: params.allowNameMatching
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function resolveSlackUserAllowListForTeam(params) {
|
|
109
|
+
const allowList = normalizeAllowListLower(params.allowList);
|
|
110
|
+
const teamId = normalizeOptionalLowercaseString(params.teamId);
|
|
111
|
+
return allowList.flatMap((entry) => {
|
|
112
|
+
if (entry === "*") return [entry];
|
|
113
|
+
if (!entry.startsWith("team:")) return [entry];
|
|
114
|
+
try {
|
|
115
|
+
const target = parseSlackTarget(entry);
|
|
116
|
+
if (target?.kind === "user" && target.teamId?.toLowerCase() === teamId) return [entry];
|
|
117
|
+
return params.preserveUnmatchedScopedEntries ? [entry] : [];
|
|
118
|
+
} catch {
|
|
119
|
+
return params.preserveUnmatchedScopedEntries ? [entry] : [];
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
11
124
|
//#region extensions/slack/src/client-options.ts
|
|
12
125
|
const requireFromSlackSocketMode = (() => {
|
|
13
|
-
|
|
126
|
+
const require = createRequire(import.meta.url);
|
|
127
|
+
return createRequire(require.resolve("@slack/socket-mode/package.json"));
|
|
14
128
|
})();
|
|
15
129
|
function loadSlackUndiciRuntime() {
|
|
16
130
|
return requireFromSlackSocketMode("undici");
|
|
@@ -25,6 +139,11 @@ const SLACK_DEFAULT_RETRY_OPTIONS = {
|
|
|
25
139
|
const SLACK_WRITE_RETRY_OPTIONS = { retries: 0 };
|
|
26
140
|
const SLACK_READ_TIMEOUT_MS = 3e4;
|
|
27
141
|
const SLACK_LOOKUP_RETRY_OPTIONS = { retries: 0 };
|
|
142
|
+
function normalizeSlackFetchInit(init) {
|
|
143
|
+
if (init?.body !== "") return init;
|
|
144
|
+
const { body: _body, ...rest } = init;
|
|
145
|
+
return rest;
|
|
146
|
+
}
|
|
28
147
|
/** Build the dispatcher shared by Slack Web API fetches and Socket Mode. */
|
|
29
148
|
function resolveSlackProxyDispatcher() {
|
|
30
149
|
const options = resolveEnvHttpProxyAgentOptions();
|
|
@@ -37,12 +156,16 @@ function resolveSlackProxyDispatcher() {
|
|
|
37
156
|
}
|
|
38
157
|
}
|
|
39
158
|
function buildSlackFetch(dispatcher) {
|
|
40
|
-
if (!dispatcher || isDebugProxyGlobalFetchPatchInstalled())
|
|
159
|
+
if (!dispatcher || isDebugProxyGlobalFetchPatchInstalled()) {
|
|
160
|
+
const slackFetch = resolveFetch();
|
|
161
|
+
if (!slackFetch) return;
|
|
162
|
+
return ((input, init) => slackFetch(input, normalizeSlackFetchInit(init)));
|
|
163
|
+
}
|
|
41
164
|
const { fetch: slackFetch } = loadSlackUndiciRuntime();
|
|
42
165
|
return ((input, init) => {
|
|
43
166
|
const slackInput = input;
|
|
44
167
|
const slackInit = {
|
|
45
|
-
...init,
|
|
168
|
+
...normalizeSlackFetchInit(init),
|
|
46
169
|
dispatcher
|
|
47
170
|
};
|
|
48
171
|
return slackFetch(slackInput, slackInit);
|
|
@@ -73,6 +196,27 @@ function resolveSlackWriteClientOptions(options = {}, dispatcher = resolveSlackP
|
|
|
73
196
|
const resolved = Object.assign({}, options);
|
|
74
197
|
applySlackApiUrlAndProxyOptions(resolved, dispatcher);
|
|
75
198
|
resolved.retryConfig ??= SLACK_WRITE_RETRY_OPTIONS;
|
|
199
|
+
if (resolved.rejectRateLimitedCalls !== true && resolved.retryConfig.retries === 0) {
|
|
200
|
+
const slackFetch = resolved.fetch ?? buildSlackFetch(dispatcher);
|
|
201
|
+
if (slackFetch) resolved.fetch = (input, init) => retryAsync(async () => {
|
|
202
|
+
init?.signal?.throwIfAborted();
|
|
203
|
+
const response = await slackFetch(input, init);
|
|
204
|
+
if (response.status !== 429) return response;
|
|
205
|
+
const retryAfter = parseRetryAfterHeaderSeconds(response.headers.get("retry-after"));
|
|
206
|
+
response.body?.cancel().catch(() => void 0);
|
|
207
|
+
init?.signal?.throwIfAborted();
|
|
208
|
+
if (retryAfter === void 0 || retryAfter * 1e3 > 2147e6) return response;
|
|
209
|
+
throw new WebAPIRateLimitedError(retryAfter);
|
|
210
|
+
}, {
|
|
211
|
+
attempts: 3,
|
|
212
|
+
minDelayMs: 0,
|
|
213
|
+
maxDelayMs: 0,
|
|
214
|
+
shouldRetry: (error) => error instanceof WebAPIRateLimitedError,
|
|
215
|
+
retryAfterMs: (error) => error instanceof WebAPIRateLimitedError ? error.retryAfter * 1e3 : void 0,
|
|
216
|
+
sleep: (delayMs) => sleepWithAbort(delayMs, init?.signal)
|
|
217
|
+
});
|
|
218
|
+
resolved.rejectRateLimitedCalls = true;
|
|
219
|
+
}
|
|
76
220
|
return resolved;
|
|
77
221
|
}
|
|
78
222
|
function resolveSlackLookupClientOptions(options = {}, dispatcher = resolveSlackProxyDispatcher()) {
|
|
@@ -89,7 +233,7 @@ const SLACK_WRITE_CLIENT_CACHE_MAX = 32;
|
|
|
89
233
|
const SLACK_STARTUP_AUTH_TIMEOUT_MS = 1e4;
|
|
90
234
|
const SLACK_STARTUP_AUTH_RETRY_BUDGET_MS = 35e3;
|
|
91
235
|
const slackWriteClientCache = /* @__PURE__ */ new Map();
|
|
92
|
-
const
|
|
236
|
+
const slackListenerWriteClientCache = /* @__PURE__ */ new WeakMap();
|
|
93
237
|
function createSlackWebClient(token, options = {}) {
|
|
94
238
|
return new WebClient(token, resolveSlackWebClientOptions(options));
|
|
95
239
|
}
|
|
@@ -153,11 +297,11 @@ function getSlackWriteClient(token, options = {}) {
|
|
|
153
297
|
slackWriteClientCache.set(tokenKey, client);
|
|
154
298
|
return client;
|
|
155
299
|
}
|
|
156
|
-
function
|
|
300
|
+
function getSlackListenerWriteClient(params) {
|
|
157
301
|
const token = params.listenerClient.token?.trim();
|
|
158
|
-
const teamId = params.teamId
|
|
159
|
-
if (!token
|
|
160
|
-
const cached =
|
|
302
|
+
const teamId = params.teamId?.trim().toUpperCase();
|
|
303
|
+
if (!token) return;
|
|
304
|
+
const cached = slackListenerWriteClientCache.get(params.listenerClient);
|
|
161
305
|
if (cached) return cached.teamId === teamId ? cached.client : void 0;
|
|
162
306
|
const headers = Object.fromEntries(Object.entries(params.clientOptions?.headers ?? {}).filter(([name]) => name.toLowerCase() !== "authorization"));
|
|
163
307
|
const client = new WebClient(token, resolveSlackWriteClientOptions({
|
|
@@ -168,7 +312,7 @@ function getSlackListenerUploadCompletionClient(params) {
|
|
|
168
312
|
retryConfig: SLACK_WRITE_RETRY_OPTIONS,
|
|
169
313
|
timeout: 0
|
|
170
314
|
}));
|
|
171
|
-
|
|
315
|
+
slackListenerWriteClientCache.set(params.listenerClient, {
|
|
172
316
|
teamId,
|
|
173
317
|
client
|
|
174
318
|
});
|
|
@@ -279,6 +423,101 @@ function formatSlackError(error, fallback = NO_ERROR_DETAIL) {
|
|
|
279
423
|
return safeStringify(error) ?? fallback;
|
|
280
424
|
}
|
|
281
425
|
//#endregion
|
|
426
|
+
//#region extensions/slack/src/monitor/ingress-identity.ts
|
|
427
|
+
const SLACK_USER_NAME_KIND = "plugin:slack-user-name";
|
|
428
|
+
const SLACK_WORKSPACE_USER_ID_KIND = "plugin:slack-workspace-user-id";
|
|
429
|
+
function normalizeSlackUserId(raw) {
|
|
430
|
+
const value = (raw ?? "").trim().toLowerCase();
|
|
431
|
+
if (!value) return "";
|
|
432
|
+
const mention = value.match(/^<@([a-z0-9_]+)>$/i);
|
|
433
|
+
if (mention?.[1]) return mention[1];
|
|
434
|
+
return value.replace(/^(slack:|user:)/, "");
|
|
435
|
+
}
|
|
436
|
+
function isSlackStableUserId(value) {
|
|
437
|
+
return /^[ubw][a-z0-9_]+$/i.test(value);
|
|
438
|
+
}
|
|
439
|
+
function normalizeSlackWorkspaceUserEntry(entry) {
|
|
440
|
+
const normalized = entry.trim().toLowerCase();
|
|
441
|
+
if (!normalized) return null;
|
|
442
|
+
try {
|
|
443
|
+
const target = parseSlackTarget(normalized);
|
|
444
|
+
if (target?.kind === "user" && target.teamId) return target.normalized;
|
|
445
|
+
} catch {
|
|
446
|
+
return null;
|
|
447
|
+
}
|
|
448
|
+
return null;
|
|
449
|
+
}
|
|
450
|
+
function normalizeSlackBareUserEntry(entry) {
|
|
451
|
+
const normalized = entry.trim().toLowerCase();
|
|
452
|
+
if (!normalized || normalizeSlackWorkspaceUserEntry(normalized)) return null;
|
|
453
|
+
const userId = normalizeSlackUserId(normalized);
|
|
454
|
+
return isSlackStableUserId(userId) ? userId : null;
|
|
455
|
+
}
|
|
456
|
+
function normalizeSlackStableEntry(entry) {
|
|
457
|
+
return normalizeSlackBareUserEntry(entry) ?? normalizeSlackWorkspaceUserEntry(entry);
|
|
458
|
+
}
|
|
459
|
+
function normalizeSlackNameEntry(entry) {
|
|
460
|
+
const normalized = entry.trim().toLowerCase();
|
|
461
|
+
if (!normalized || normalizeSlackStableEntry(normalized)) return null;
|
|
462
|
+
return normalized.replace(/^slack:/, "") || null;
|
|
463
|
+
}
|
|
464
|
+
function normalizeSlackNameSubject(value) {
|
|
465
|
+
return value.trim().toLowerCase() || null;
|
|
466
|
+
}
|
|
467
|
+
function normalizeSlackNameSlugEntry(entry) {
|
|
468
|
+
const name = normalizeSlackNameEntry(entry);
|
|
469
|
+
if (!name) return null;
|
|
470
|
+
return normalizeSlackSlug(name) || null;
|
|
471
|
+
}
|
|
472
|
+
const slackIngressIdentity = defineStableChannelIngressIdentity({
|
|
473
|
+
resolveParticipant: (subject) => {
|
|
474
|
+
const qualified = subject.aliases?.workspaceSenderId;
|
|
475
|
+
if (typeof qualified !== "string") return;
|
|
476
|
+
const normalized = normalizeSlackWorkspaceUserEntry(qualified);
|
|
477
|
+
const target = normalized ? parseSlackTarget(normalized) : void 0;
|
|
478
|
+
return target?.teamId ? {
|
|
479
|
+
domain: target.teamId,
|
|
480
|
+
idKind: target.id.startsWith("b") ? "bot-id" : "user-id",
|
|
481
|
+
id: target.id
|
|
482
|
+
} : void 0;
|
|
483
|
+
},
|
|
484
|
+
key: "senderId",
|
|
485
|
+
kind: "stable-id",
|
|
486
|
+
authentication: "asserted",
|
|
487
|
+
normalizeEntry: normalizeSlackBareUserEntry,
|
|
488
|
+
normalizeSubject: normalizeSlackUserId,
|
|
489
|
+
sensitivity: "pii",
|
|
490
|
+
aliases: [{
|
|
491
|
+
key: "workspaceSenderId",
|
|
492
|
+
kind: SLACK_WORKSPACE_USER_ID_KIND,
|
|
493
|
+
authentication: "asserted",
|
|
494
|
+
normalizeEntry: normalizeSlackWorkspaceUserEntry,
|
|
495
|
+
normalizeSubject: normalizeSlackWorkspaceUserEntry,
|
|
496
|
+
sensitivity: "pii"
|
|
497
|
+
}, ...[["senderName", normalizeSlackNameEntry], ["senderNameSlug", normalizeSlackNameSlugEntry]].map(([key, normalizeEntry]) => ({
|
|
498
|
+
key,
|
|
499
|
+
kind: SLACK_USER_NAME_KIND,
|
|
500
|
+
normalizeEntry,
|
|
501
|
+
normalizeSubject: normalizeSlackNameSubject,
|
|
502
|
+
authentication: "mutable",
|
|
503
|
+
sensitivity: "pii"
|
|
504
|
+
}))]
|
|
505
|
+
});
|
|
506
|
+
function createSlackIngressSubject(params) {
|
|
507
|
+
const senderId = normalizeSlackUserId(params.senderId);
|
|
508
|
+
const teamId = normalizeOptionalLowercaseString(params.teamId);
|
|
509
|
+
const senderName = params.senderName?.trim().toLowerCase();
|
|
510
|
+
const senderNameSlug = senderName ? normalizeSlackSlug(senderName) : void 0;
|
|
511
|
+
return {
|
|
512
|
+
stableId: senderId,
|
|
513
|
+
aliases: {
|
|
514
|
+
workspaceSenderId: teamId && senderId ? `team:${teamId}:user:${senderId}` : void 0,
|
|
515
|
+
senderName,
|
|
516
|
+
senderNameSlug
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
//#endregion
|
|
282
521
|
//#region extensions/slack/src/probe.ts
|
|
283
522
|
var probe_exports = /* @__PURE__ */ __exportAll({ probeSlack: () => probeSlack });
|
|
284
523
|
async function probeSlack(token, timeoutMs = 2500, opts) {
|
|
@@ -343,4 +582,4 @@ async function probeSlack(token, timeoutMs = 2500, opts) {
|
|
|
343
582
|
}));
|
|
344
583
|
}
|
|
345
584
|
//#endregion
|
|
346
|
-
export {
|
|
585
|
+
export { normalizeAllowListLower as C, resolveSlackUserAllowListForTeam as D, resolveSlackAllowListMatch as E, resolveSlackUserAllowed as O, normalizeAllowList as S, normalizeSlackSlug as T, resolveSlackLookupClientOptions as _, slackIngressIdentity as a, resolveSlackWriteClientOptions as b, createSlackReadClient as c, createSlackWebClient as d, createSlackWriteClient as f, SLACK_WRITE_RETRY_OPTIONS as g, SLACK_DEFAULT_RETRY_OPTIONS as h, createSlackIngressSubject as i, createSlackStartupAuthClient as l, getSlackWriteClient as m, probe_exports as n, formatSlackError as o, getSlackListenerWriteClient as p, SLACK_USER_NAME_KIND as r, createSlackLookupClient as s, probeSlack as t, createSlackTokenCacheKey as u, resolveSlackProxyDispatcher as v, normalizeSlackAllowOwnerEntry as w, allowListMatches as x, resolveSlackWebClientOptions as y };
|