@cuylabs/channel-slack 0.5.0 → 0.6.0
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/README.md +25 -136
- package/dist/app-home.d.ts +23 -0
- package/dist/app-home.js +35 -0
- package/dist/artifacts/index.d.ts +135 -0
- package/dist/artifacts/index.js +299 -0
- package/dist/{assistant.d.ts → assistant/index.d.ts} +1 -1
- package/dist/{assistant.js → assistant/index.js} +2 -2
- package/dist/auth/index.d.ts +56 -0
- package/dist/auth/index.js +168 -0
- package/dist/{chunk-IDVDMJ5U.js → chunk-6JSGIVQH.js} +110 -3
- package/dist/chunk-6WHFQUYQ.js +54 -0
- package/dist/{bolt.js → chunk-73QXT7MA.js} +29 -322
- package/dist/{chunk-CMR6B76C.js → chunk-DNVSH7H5.js} +407 -1
- package/dist/chunk-QJYCHWN6.js +76 -0
- package/dist/chunk-S3SWPYXJ.js +81 -0
- package/dist/{chunk-JZG4IETE.js → chunk-X4WBBBYM.js} +0 -52
- package/dist/core.js +5 -3
- package/dist/diagnostics/index.d.ts +71 -0
- package/dist/{diagnostics.js → diagnostics/index.js} +5 -1
- package/dist/entrypoints/index.d.ts +120 -0
- package/dist/entrypoints/index.js +132 -0
- package/dist/{history.d.ts → history/index.d.ts} +2 -2
- package/dist/{history.js → history/index.js} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +28 -15
- package/dist/{policy.d.ts → policy/index.d.ts} +103 -2
- package/dist/{policy.js → policy/index.js} +13 -1
- package/dist/runtime-BNBHOZSQ.d.ts +53 -0
- package/dist/{setup.d.ts → setup/index.d.ts} +30 -3
- package/dist/{setup.js → setup/index.js} +134 -3
- package/dist/transports/http/index.d.ts +68 -0
- package/dist/transports/http/index.js +8 -0
- package/dist/transports/index.d.ts +8 -0
- package/dist/transports/index.js +24 -0
- package/dist/transports/socket/index.d.ts +94 -0
- package/dist/transports/socket/index.js +19 -0
- package/dist/types-B9NfCVrk.d.ts +141 -0
- package/docs/README.md +31 -0
- package/docs/concepts/activity.md +3 -3
- package/docs/concepts/artifacts.md +56 -0
- package/docs/concepts/entrypoints.md +73 -0
- package/docs/concepts/message-policy.md +13 -0
- package/docs/concepts/setup-requirements.md +23 -0
- package/docs/concepts/{bolt-runtime.md → transport-runtime.md} +14 -4
- package/docs/recipes/app-mention-handler.md +5 -0
- package/docs/recipes/generate-slack-manifest.md +16 -0
- package/docs/recipes/publish-artifact.md +45 -0
- package/docs/recipes/slash-command-and-shortcut.md +51 -0
- package/docs/recipes/socket-mode-app.md +1 -1
- package/docs/reference/channel-slack-boundary.md +10 -6
- package/docs/reference/exports.md +7 -2
- package/docs/reference/source-layout.md +35 -0
- package/package.json +63 -39
- package/dist/bolt.d.ts +0 -364
- package/dist/chunk-NE57BLLU.js +0 -0
- package/dist/diagnostics.d.ts +0 -22
- package/dist/shared.d.ts +0 -2
- package/dist/shared.js +0 -43
- /package/dist/{feedback.d.ts → feedback/index.d.ts} +0 -0
- /package/dist/{feedback.js → feedback/index.js} +0 -0
- /package/dist/{targets.d.ts → targets/index.d.ts} +0 -0
- /package/dist/{targets.js → targets/index.js} +0 -0
- /package/dist/{users.d.ts → users/index.d.ts} +0 -0
- /package/dist/{users.js → users/index.js} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { I as InspectSlackConnectionOptions, f as SlackDiagnosticsClient, c as SlackConnectionInspection } from '
|
|
1
|
+
import { I as InspectSlackConnectionOptions, f as SlackDiagnosticsClient, c as SlackConnectionInspection } from '../inspect-BpY5JA0K.js';
|
|
2
2
|
|
|
3
|
-
type SlackSetupFeature = "assistant" | "app-mentions" | "direct-messages" | "channel-messages" | "history" | "interactivity" | "feedback" | "user-profiles" | "user-emails";
|
|
3
|
+
type SlackSetupFeature = "assistant" | "app-mentions" | "direct-messages" | "channel-messages" | "slash-commands" | "shortcuts" | "artifacts" | "canvas-artifacts" | "history" | "interactivity" | "feedback" | "user-profiles" | "user-emails" | "workspace-search";
|
|
4
4
|
type SlackSetupFeaturePreset = "assistant" | "channel-adapter" | "agent-app";
|
|
5
5
|
type SlackSetupTransport = "http" | "socket";
|
|
6
6
|
interface SlackSetupEnvironmentVariable {
|
|
@@ -11,6 +11,8 @@ interface SlackSetupSettingsRequirements {
|
|
|
11
11
|
assistantView: boolean;
|
|
12
12
|
eventSubscriptions: boolean;
|
|
13
13
|
interactivity: boolean;
|
|
14
|
+
slashCommands: boolean;
|
|
15
|
+
shortcuts: boolean;
|
|
14
16
|
socketMode: boolean;
|
|
15
17
|
}
|
|
16
18
|
interface SlackSetupRequirements {
|
|
@@ -43,6 +45,16 @@ interface GetSlackSetupRequirementsOptions {
|
|
|
43
45
|
* is used as-is.
|
|
44
46
|
*/
|
|
45
47
|
features?: readonly SlackSetupFeature[];
|
|
48
|
+
/**
|
|
49
|
+
* Slash commands exposed by the host app. Supplying at least one command
|
|
50
|
+
* automatically enables the `slash-commands` feature.
|
|
51
|
+
*/
|
|
52
|
+
slashCommands?: readonly SlackManifestSlashCommand[];
|
|
53
|
+
/**
|
|
54
|
+
* Global or message shortcuts exposed by the host app. Supplying at least one
|
|
55
|
+
* shortcut automatically enables the `shortcuts` feature.
|
|
56
|
+
*/
|
|
57
|
+
shortcuts?: readonly SlackManifestShortcut[];
|
|
46
58
|
/**
|
|
47
59
|
* Inbound transport used by the direct Slack app.
|
|
48
60
|
*
|
|
@@ -76,6 +88,19 @@ interface SlackManifestSuggestedPrompt {
|
|
|
76
88
|
title: string;
|
|
77
89
|
message: string;
|
|
78
90
|
}
|
|
91
|
+
interface SlackManifestShortcut {
|
|
92
|
+
type: "global" | "message";
|
|
93
|
+
name: string;
|
|
94
|
+
callback_id: string;
|
|
95
|
+
description: string;
|
|
96
|
+
}
|
|
97
|
+
interface SlackManifestSlashCommand {
|
|
98
|
+
command: string;
|
|
99
|
+
description: string;
|
|
100
|
+
should_escape?: boolean;
|
|
101
|
+
url?: string;
|
|
102
|
+
usage_hint?: string;
|
|
103
|
+
}
|
|
79
104
|
interface SlackAppManifest {
|
|
80
105
|
display_information: {
|
|
81
106
|
name: string;
|
|
@@ -92,6 +117,8 @@ interface SlackAppManifest {
|
|
|
92
117
|
assistant_description?: string;
|
|
93
118
|
suggested_prompts?: SlackManifestSuggestedPrompt[];
|
|
94
119
|
};
|
|
120
|
+
shortcuts?: SlackManifestShortcut[];
|
|
121
|
+
slash_commands?: SlackManifestSlashCommand[];
|
|
95
122
|
};
|
|
96
123
|
oauth_config: {
|
|
97
124
|
scopes: {
|
|
@@ -162,4 +189,4 @@ interface SlackAppSetupInspection {
|
|
|
162
189
|
}
|
|
163
190
|
declare function inspectSlackAppSetup(options?: InspectSlackAppSetupOptions): Promise<SlackAppSetupInspection>;
|
|
164
191
|
|
|
165
|
-
export { type CreateSlackAppManifestOptions, type GetSlackSetupRequirementsOptions, type InspectSlackAppSetupOptions, type SlackAppManifest, type SlackAppManifestComparison, type SlackAppManifestComparisonFinding, type SlackAppManifestComparisonFindingSeverity, type SlackAppSetupInspection, SlackDiagnosticsClient, type SlackManifestAppHome, type SlackManifestSuggestedPrompt, type SlackSetupEnvironmentVariable, type SlackSetupFeature, type SlackSetupFeaturePreset, type SlackSetupRequirements, type SlackSetupSettingsRequirements, type SlackSetupTransport, compareSlackAppManifest, createSlackAppManifest, getSlackSetupRequirements, inspectSlackAppSetup, slackSetupFeaturePresets };
|
|
192
|
+
export { type CreateSlackAppManifestOptions, type GetSlackSetupRequirementsOptions, type InspectSlackAppSetupOptions, type SlackAppManifest, type SlackAppManifestComparison, type SlackAppManifestComparisonFinding, type SlackAppManifestComparisonFindingSeverity, type SlackAppSetupInspection, SlackDiagnosticsClient, type SlackManifestAppHome, type SlackManifestShortcut, type SlackManifestSlashCommand, type SlackManifestSuggestedPrompt, type SlackSetupEnvironmentVariable, type SlackSetupFeature, type SlackSetupFeaturePreset, type SlackSetupRequirements, type SlackSetupSettingsRequirements, type SlackSetupTransport, compareSlackAppManifest, createSlackAppManifest, getSlackSetupRequirements, inspectSlackAppSetup, slackSetupFeaturePresets };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
inspectSlackConnection
|
|
3
|
-
} from "
|
|
3
|
+
} from "../chunk-6JSGIVQH.js";
|
|
4
4
|
|
|
5
5
|
// src/setup/requirements.ts
|
|
6
6
|
var DEFAULT_EVENTS_PATH = "/slack/events";
|
|
@@ -27,6 +27,20 @@ var FEATURE_REQUIREMENTS = {
|
|
|
27
27
|
botScopes: ["channels:history", "chat:write", "groups:history"],
|
|
28
28
|
botEvents: ["message.channels", "message.groups"]
|
|
29
29
|
},
|
|
30
|
+
"slash-commands": {
|
|
31
|
+
botScopes: ["commands"],
|
|
32
|
+
interactivity: true
|
|
33
|
+
},
|
|
34
|
+
shortcuts: {
|
|
35
|
+
botScopes: ["commands"],
|
|
36
|
+
interactivity: true
|
|
37
|
+
},
|
|
38
|
+
artifacts: {
|
|
39
|
+
botScopes: ["chat:write", "files:write"]
|
|
40
|
+
},
|
|
41
|
+
"canvas-artifacts": {
|
|
42
|
+
botScopes: ["canvases:write"]
|
|
43
|
+
},
|
|
30
44
|
history: {
|
|
31
45
|
botScopes: [
|
|
32
46
|
"channels:history",
|
|
@@ -49,6 +63,9 @@ var FEATURE_REQUIREMENTS = {
|
|
|
49
63
|
},
|
|
50
64
|
"user-emails": {
|
|
51
65
|
botScopes: ["users:read", "users:read.email"]
|
|
66
|
+
},
|
|
67
|
+
"workspace-search": {
|
|
68
|
+
botScopes: ["search:read.files", "search:read.public", "search:read.users"]
|
|
52
69
|
}
|
|
53
70
|
};
|
|
54
71
|
function getSlackSetupRequirements(options = {}) {
|
|
@@ -63,6 +80,8 @@ function getSlackSetupRequirements(options = {}) {
|
|
|
63
80
|
const botEvents = [];
|
|
64
81
|
let assistantView = false;
|
|
65
82
|
let interactivity = false;
|
|
83
|
+
let slashCommands = false;
|
|
84
|
+
let shortcuts = false;
|
|
66
85
|
for (const feature of features) {
|
|
67
86
|
const requirement = FEATURE_REQUIREMENTS[feature];
|
|
68
87
|
if (!requirement) {
|
|
@@ -73,6 +92,8 @@ function getSlackSetupRequirements(options = {}) {
|
|
|
73
92
|
collect(requirement.botEvents, botEvents);
|
|
74
93
|
assistantView ||= requirement.assistantView === true;
|
|
75
94
|
interactivity ||= requirement.interactivity === true;
|
|
95
|
+
slashCommands ||= feature === "slash-commands";
|
|
96
|
+
shortcuts ||= feature === "shortcuts";
|
|
76
97
|
}
|
|
77
98
|
collect(options.extraBotScopes, botScopes);
|
|
78
99
|
collect(options.extraOptionalBotScopes, optionalBotScopes);
|
|
@@ -91,6 +112,8 @@ function getSlackSetupRequirements(options = {}) {
|
|
|
91
112
|
assistantView,
|
|
92
113
|
eventSubscriptions: normalizedBotEvents.length > 0,
|
|
93
114
|
interactivity,
|
|
115
|
+
slashCommands,
|
|
116
|
+
shortcuts,
|
|
94
117
|
socketMode: transport === "socket"
|
|
95
118
|
};
|
|
96
119
|
const environment = resolveEnvironment({
|
|
@@ -112,9 +135,13 @@ function getSlackSetupRequirements(options = {}) {
|
|
|
112
135
|
};
|
|
113
136
|
}
|
|
114
137
|
function resolveSetupFeatures(options) {
|
|
138
|
+
const inferredFeatures = [
|
|
139
|
+
...options.slashCommands && options.slashCommands.length > 0 ? ["slash-commands"] : [],
|
|
140
|
+
...options.shortcuts && options.shortcuts.length > 0 ? ["shortcuts"] : []
|
|
141
|
+
];
|
|
115
142
|
const preset = options.preset ?? "agent-app";
|
|
116
143
|
if (preset === false) {
|
|
117
|
-
return uniqueFeatures(options.features ?? []);
|
|
144
|
+
return uniqueFeatures([...options.features ?? [], ...inferredFeatures]);
|
|
118
145
|
}
|
|
119
146
|
const presetFeatures = slackSetupFeaturePresets[preset];
|
|
120
147
|
if (!presetFeatures) {
|
|
@@ -122,7 +149,8 @@ function resolveSetupFeatures(options) {
|
|
|
122
149
|
}
|
|
123
150
|
return uniqueFeatures([
|
|
124
151
|
...presetFeatures ?? [],
|
|
125
|
-
...options.features ?? []
|
|
152
|
+
...options.features ?? [],
|
|
153
|
+
...inferredFeatures
|
|
126
154
|
]);
|
|
127
155
|
}
|
|
128
156
|
function resolveEnvironment(context) {
|
|
@@ -226,6 +254,27 @@ function createSlackAppManifest(options) {
|
|
|
226
254
|
...options.suggestedPrompts ? { suggested_prompts: [...options.suggestedPrompts] } : {}
|
|
227
255
|
};
|
|
228
256
|
}
|
|
257
|
+
const slashCommands = normalizeSlashCommands(options.slashCommands ?? []);
|
|
258
|
+
if (requirements.settings.slashCommands) {
|
|
259
|
+
if (slashCommands.length === 0) {
|
|
260
|
+
throw new Error(
|
|
261
|
+
"Slack slash command definitions are required when the `slash-commands` feature is enabled."
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
features.slash_commands = slashCommands.map((command) => ({
|
|
265
|
+
...command,
|
|
266
|
+
...command.url || requirements.transport !== "http" ? {} : requirements.requestUrl ? { url: requirements.requestUrl } : {}
|
|
267
|
+
}));
|
|
268
|
+
}
|
|
269
|
+
const shortcuts = normalizeShortcuts(options.shortcuts ?? []);
|
|
270
|
+
if (requirements.settings.shortcuts) {
|
|
271
|
+
if (shortcuts.length === 0) {
|
|
272
|
+
throw new Error(
|
|
273
|
+
"Slack shortcut definitions are required when the `shortcuts` feature is enabled."
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
features.shortcuts = shortcuts;
|
|
277
|
+
}
|
|
229
278
|
const settings = {
|
|
230
279
|
socket_mode_enabled: requirements.settings.socketMode,
|
|
231
280
|
token_rotation_enabled: options.tokenRotationEnabled ?? false
|
|
@@ -327,6 +376,8 @@ function compareSettings(manifest, requirements, findings) {
|
|
|
327
376
|
const settings = readRecord(manifestRecord?.settings);
|
|
328
377
|
const eventSubscriptions = readRecord(settings?.event_subscriptions);
|
|
329
378
|
const interactivity = readRecord(settings?.interactivity);
|
|
379
|
+
const slashCommands = features?.slash_commands;
|
|
380
|
+
const shortcuts = features?.shortcuts;
|
|
330
381
|
if (requirements.settings.assistantView && !readRecord(features?.assistant_view)) {
|
|
331
382
|
findings.push({
|
|
332
383
|
severity: "error",
|
|
@@ -357,6 +408,26 @@ function compareSettings(manifest, requirements, findings) {
|
|
|
357
408
|
actual: readBoolean(interactivity?.is_enabled) ?? false
|
|
358
409
|
});
|
|
359
410
|
}
|
|
411
|
+
if (requirements.settings.slashCommands && !Array.isArray(slashCommands)) {
|
|
412
|
+
findings.push({
|
|
413
|
+
severity: "error",
|
|
414
|
+
code: "slash-commands-missing",
|
|
415
|
+
message: "Slack manifest must configure slash commands for selected features.",
|
|
416
|
+
path: "features.slash_commands",
|
|
417
|
+
expected: true,
|
|
418
|
+
actual: void 0
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
if (requirements.settings.shortcuts && !Array.isArray(shortcuts)) {
|
|
422
|
+
findings.push({
|
|
423
|
+
severity: "error",
|
|
424
|
+
code: "shortcuts-missing",
|
|
425
|
+
message: "Slack manifest must configure shortcuts for selected features.",
|
|
426
|
+
path: "features.shortcuts",
|
|
427
|
+
expected: true,
|
|
428
|
+
actual: void 0
|
|
429
|
+
});
|
|
430
|
+
}
|
|
360
431
|
if (requirements.settings.socketMode && readBoolean(settings?.socket_mode_enabled) !== true) {
|
|
361
432
|
findings.push({
|
|
362
433
|
severity: "error",
|
|
@@ -387,6 +458,28 @@ function compareSettings(manifest, requirements, findings) {
|
|
|
387
458
|
actual: readString(interactivity?.request_url)
|
|
388
459
|
});
|
|
389
460
|
}
|
|
461
|
+
if (requirements.requestUrl && requirements.transport === "http" && requirements.settings.slashCommands && Array.isArray(slashCommands)) {
|
|
462
|
+
const mismatched = slashCommands.map((command, index) => ({
|
|
463
|
+
index,
|
|
464
|
+
command: readRecord(command)
|
|
465
|
+
})).filter(
|
|
466
|
+
({ command }) => readString(command?.url) !== requirements.requestUrl
|
|
467
|
+
);
|
|
468
|
+
if (mismatched.length > 0) {
|
|
469
|
+
findings.push({
|
|
470
|
+
severity: "error",
|
|
471
|
+
code: "slash-command-url-mismatch",
|
|
472
|
+
message: `Slack manifest slash command URL(s) must be ${requirements.requestUrl}.`,
|
|
473
|
+
path: "features.slash_commands",
|
|
474
|
+
expected: requirements.requestUrl,
|
|
475
|
+
actual: mismatched.map(({ index, command }) => ({
|
|
476
|
+
index,
|
|
477
|
+
command: readString(command?.command),
|
|
478
|
+
url: readString(command?.url)
|
|
479
|
+
}))
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
}
|
|
390
483
|
}
|
|
391
484
|
function trimString2(value) {
|
|
392
485
|
const trimmed = value?.trim();
|
|
@@ -408,6 +501,44 @@ function uniqueSorted2(values) {
|
|
|
408
501
|
}
|
|
409
502
|
return [...unique.values()].sort((a, b) => a.localeCompare(b));
|
|
410
503
|
}
|
|
504
|
+
function normalizeSlashCommands(values) {
|
|
505
|
+
return values.map((command) => {
|
|
506
|
+
const normalized = {
|
|
507
|
+
command: requireTrimmed(command.command, "slash command"),
|
|
508
|
+
description: requireTrimmed(
|
|
509
|
+
command.description,
|
|
510
|
+
`description for ${command.command}`
|
|
511
|
+
),
|
|
512
|
+
...trimString2(command.usage_hint) ? { usage_hint: trimString2(command.usage_hint) } : {},
|
|
513
|
+
...trimString2(command.url) ? { url: trimString2(command.url) } : {},
|
|
514
|
+
...command.should_escape !== void 0 ? { should_escape: command.should_escape } : {}
|
|
515
|
+
};
|
|
516
|
+
if (!normalized.command.startsWith("/")) {
|
|
517
|
+
throw new Error(
|
|
518
|
+
`Slack slash command must start with "/": ${normalized.command}`
|
|
519
|
+
);
|
|
520
|
+
}
|
|
521
|
+
return normalized;
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
function normalizeShortcuts(values) {
|
|
525
|
+
return values.map((shortcut) => ({
|
|
526
|
+
type: shortcut.type,
|
|
527
|
+
name: requireTrimmed(shortcut.name, "shortcut name"),
|
|
528
|
+
callback_id: requireTrimmed(shortcut.callback_id, "shortcut callback_id"),
|
|
529
|
+
description: requireTrimmed(
|
|
530
|
+
shortcut.description,
|
|
531
|
+
`description for ${shortcut.callback_id}`
|
|
532
|
+
)
|
|
533
|
+
}));
|
|
534
|
+
}
|
|
535
|
+
function requireTrimmed(value, label) {
|
|
536
|
+
const trimmed = value.trim();
|
|
537
|
+
if (!trimmed) {
|
|
538
|
+
throw new Error(`Slack ${label} must not be empty.`);
|
|
539
|
+
}
|
|
540
|
+
return trimmed;
|
|
541
|
+
}
|
|
411
542
|
function readRecord(value) {
|
|
412
543
|
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
413
544
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Application } from 'express';
|
|
2
|
+
import { AppOptions, ExpressReceiverOptions, App, ExpressReceiver } from '@slack/bolt';
|
|
3
|
+
import { e as SlackDirectAuthOptions, d as SlackDirectAuthMode } from '../../types-B9NfCVrk.js';
|
|
4
|
+
import 'node:http';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `createSlackBoltApp` — builds a Bolt `App` + `ExpressReceiver` pair from
|
|
8
|
+
* the package's structured `CreateSlackBoltAppOptions`. Supports
|
|
9
|
+
* single-workspace, OAuth, and custom-authorize auth modes.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
interface CreateSlackBoltAppOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Slack signing secret used to verify inbound requests.
|
|
15
|
+
* Defaults to `SLACK_SIGNING_SECRET`.
|
|
16
|
+
*/
|
|
17
|
+
signingSecret?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Exact Slack Events API endpoint path.
|
|
20
|
+
* Defaults to `/slack/events`.
|
|
21
|
+
*/
|
|
22
|
+
path?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Direct-mode auth configuration.
|
|
25
|
+
*
|
|
26
|
+
* - omit for single-workspace token mode
|
|
27
|
+
* - use `{ mode: "oauth", ... }` for Bolt-managed installs
|
|
28
|
+
* - use `{ mode: "authorize", authorize }` for external token resolution
|
|
29
|
+
*/
|
|
30
|
+
auth?: SlackDirectAuthOptions;
|
|
31
|
+
/**
|
|
32
|
+
* Convenience override for single-workspace mode.
|
|
33
|
+
* Defaults to `SLACK_BOT_TOKEN`.
|
|
34
|
+
*/
|
|
35
|
+
botToken?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Pre-existing Express app to mount onto.
|
|
38
|
+
*/
|
|
39
|
+
app?: Application;
|
|
40
|
+
processBeforeResponse?: boolean;
|
|
41
|
+
signatureVerification?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Additional Bolt `App` options passed through after this package sets
|
|
44
|
+
* receiver/auth. Use for logger/clientOptions and other native Bolt config.
|
|
45
|
+
*/
|
|
46
|
+
boltAppOptions?: Partial<Omit<AppOptions, "receiver" | "token" | "authorize" | "botId" | "botUserId">>;
|
|
47
|
+
/**
|
|
48
|
+
* Additional Bolt `ExpressReceiver` options passed through after this
|
|
49
|
+
* package sets signing/auth/endpoints. Use for router, custom properties,
|
|
50
|
+
* and receiver-level error handlers.
|
|
51
|
+
*/
|
|
52
|
+
receiverOptions?: Partial<Omit<ExpressReceiverOptions, "signingSecret" | "endpoints" | "processBeforeResponse" | "signatureVerification" | "app" | "clientId" | "clientSecret" | "stateSecret" | "installationStore" | "redirectUri" | "scopes" | "installerOptions">>;
|
|
53
|
+
}
|
|
54
|
+
interface CreateSlackBoltAppResult {
|
|
55
|
+
/** Bolt `App` used for event registration and outbound Slack calls. */
|
|
56
|
+
boltApp: App;
|
|
57
|
+
/** Bolt `ExpressReceiver` that owns request verification and OAuth routes. */
|
|
58
|
+
receiver: ExpressReceiver;
|
|
59
|
+
/** Express app that should receive `receiver.router`. */
|
|
60
|
+
app: Application;
|
|
61
|
+
/** Resolved direct auth mode. */
|
|
62
|
+
authMode: SlackDirectAuthMode;
|
|
63
|
+
/** Exact normalized events endpoint path. */
|
|
64
|
+
routePath: string;
|
|
65
|
+
}
|
|
66
|
+
declare function createSlackBoltApp(options?: CreateSlackBoltAppOptions): Promise<CreateSlackBoltAppResult>;
|
|
67
|
+
|
|
68
|
+
export { type CreateSlackBoltAppOptions, type CreateSlackBoltAppResult, createSlackBoltApp, createSlackBoltApp as createSlackHttpBoltApp };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { CreateSlackBoltAppOptions, CreateSlackBoltAppResult, createSlackBoltApp, createSlackBoltApp as createSlackHttpBoltApp } from './http/index.js';
|
|
2
|
+
export { CreateSlackSocketBoltAppOptions, CreateSlackSocketBoltAppResult, SlackSocketModePostgresLock, SlackSocketModePostgresLockClient, SlackSocketModePostgresLockOptions, SlackSocketModePostgresLockPool, SlackSocketModeProcessLock, SlackSocketModeProcessLockOptions, acquireSlackSocketModePostgresLock, acquireSlackSocketModeProcessLock, createSlackSocketBoltApp } from './socket/index.js';
|
|
3
|
+
export { S as SlackSocketModeReceiverRuntimeOptions, a as SlackSocketModeRestartGuard, b as SlackSocketModeRuntime, c as SlackSocketModeRuntimeOptions, d as SlackSocketModeRuntimePolicy, e as createSlackSdkLogger, f as createSlackSocketModeRestartGuard, g as createSlackSocketModeRuntime, r as redactSlackSocketModeLogValue } from '../runtime-BNBHOZSQ.js';
|
|
4
|
+
export { LogLevel as SlackSdkLogLevel, Logger as SlackSdkLogger } from '@slack/bolt';
|
|
5
|
+
import 'express';
|
|
6
|
+
import '../types-B9NfCVrk.js';
|
|
7
|
+
import 'node:http';
|
|
8
|
+
import '../logging-Bl3HfcC8.js';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
acquireSlackSocketModePostgresLock,
|
|
3
|
+
acquireSlackSocketModeProcessLock,
|
|
4
|
+
createSlackSdkLogger,
|
|
5
|
+
createSlackSocketBoltApp,
|
|
6
|
+
createSlackSocketModeRestartGuard,
|
|
7
|
+
createSlackSocketModeRuntime,
|
|
8
|
+
redactSlackSocketModeLogValue
|
|
9
|
+
} from "../chunk-73QXT7MA.js";
|
|
10
|
+
import {
|
|
11
|
+
createSlackBoltApp
|
|
12
|
+
} from "../chunk-QJYCHWN6.js";
|
|
13
|
+
import "../chunk-S3SWPYXJ.js";
|
|
14
|
+
export {
|
|
15
|
+
acquireSlackSocketModePostgresLock,
|
|
16
|
+
acquireSlackSocketModeProcessLock,
|
|
17
|
+
createSlackBoltApp,
|
|
18
|
+
createSlackBoltApp as createSlackHttpBoltApp,
|
|
19
|
+
createSlackSdkLogger,
|
|
20
|
+
createSlackSocketBoltApp,
|
|
21
|
+
createSlackSocketModeRestartGuard,
|
|
22
|
+
createSlackSocketModeRuntime,
|
|
23
|
+
redactSlackSocketModeLogValue
|
|
24
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { AppOptions, SocketModeReceiverOptions, App } from '@slack/bolt';
|
|
2
|
+
export { LogLevel as SlackSdkLogLevel, Logger as SlackSdkLogger } from '@slack/bolt';
|
|
3
|
+
import { e as SlackDirectAuthOptions, d as SlackDirectAuthMode } from '../../types-B9NfCVrk.js';
|
|
4
|
+
import { L as Logger } from '../../logging-Bl3HfcC8.js';
|
|
5
|
+
export { S as SlackSocketModeReceiverRuntimeOptions, a as SlackSocketModeRestartGuard, b as SlackSocketModeRuntime, c as SlackSocketModeRuntimeOptions, d as SlackSocketModeRuntimePolicy, e as createSlackSdkLogger, f as createSlackSocketModeRestartGuard, g as createSlackSocketModeRuntime, r as redactSlackSocketModeLogValue } from '../../runtime-BNBHOZSQ.js';
|
|
6
|
+
import 'node:http';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* `createSlackSocketBoltApp` — builds a Socket Mode Bolt `App` from the
|
|
10
|
+
* package's structured auth options. Mirrors `createSlackBoltApp` without
|
|
11
|
+
* owning any assistant/app surface mounting.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
type ControlledSocketBoltAppOption = "receiver" | "socketMode" | "appToken" | "token" | "authorize" | "botId" | "botUserId" | "clientId" | "clientSecret" | "stateSecret" | "redirectUri" | "installationStore" | "scopes" | "installerOptions";
|
|
15
|
+
type ControlledSocketModeReceiverOption = "appToken" | "clientId" | "clientSecret" | "stateSecret" | "redirectUri" | "installationStore" | "scopes" | "installerOptions" | "logger" | "logLevel";
|
|
16
|
+
interface CreateSlackSocketBoltAppOptions {
|
|
17
|
+
/**
|
|
18
|
+
* Slack app-level token (`xapp-...`) with `connections:write` scope.
|
|
19
|
+
* @default process.env.SLACK_APP_TOKEN
|
|
20
|
+
*/
|
|
21
|
+
appToken?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Convenience override for single-workspace mode.
|
|
24
|
+
* @default process.env.SLACK_BOT_TOKEN
|
|
25
|
+
*/
|
|
26
|
+
botToken?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Direct-mode auth configuration.
|
|
29
|
+
*
|
|
30
|
+
* - omit for single-workspace token mode
|
|
31
|
+
* - use `{ mode: "oauth", ... }` for Bolt-managed installs
|
|
32
|
+
* - use `{ mode: "authorize", authorize }` for external token resolution
|
|
33
|
+
*/
|
|
34
|
+
auth?: SlackDirectAuthOptions;
|
|
35
|
+
/**
|
|
36
|
+
* Additional Bolt `App` options passed after this package sets Socket Mode
|
|
37
|
+
* and auth. Use for logger/clientOptions and non-auth native Bolt config.
|
|
38
|
+
*/
|
|
39
|
+
boltAppOptions?: Partial<Omit<AppOptions, ControlledSocketBoltAppOption>>;
|
|
40
|
+
/**
|
|
41
|
+
* Additional native Socket Mode receiver options. Use this for websocket
|
|
42
|
+
* health tuning such as ping timeouts, reconnect behavior, and receiver
|
|
43
|
+
* error handling. Auth/OAuth fields stay controlled by this helper.
|
|
44
|
+
*/
|
|
45
|
+
socketModeReceiverOptions?: Partial<Omit<SocketModeReceiverOptions, ControlledSocketModeReceiverOption>>;
|
|
46
|
+
}
|
|
47
|
+
interface CreateSlackSocketBoltAppResult {
|
|
48
|
+
boltApp: App;
|
|
49
|
+
authMode: SlackDirectAuthMode;
|
|
50
|
+
}
|
|
51
|
+
declare function createSlackSocketBoltApp(options?: CreateSlackSocketBoltAppOptions): Promise<CreateSlackSocketBoltAppResult>;
|
|
52
|
+
|
|
53
|
+
interface SlackSocketModeProcessLockOptions {
|
|
54
|
+
appSlug: string;
|
|
55
|
+
appToken?: string;
|
|
56
|
+
enabled?: boolean;
|
|
57
|
+
lockDir?: string;
|
|
58
|
+
logger?: Logger;
|
|
59
|
+
}
|
|
60
|
+
interface SlackSocketModeProcessLock {
|
|
61
|
+
path: string;
|
|
62
|
+
release(): void;
|
|
63
|
+
}
|
|
64
|
+
declare function acquireSlackSocketModeProcessLock({ appSlug, appToken, enabled, lockDir, logger, }: SlackSocketModeProcessLockOptions): SlackSocketModeProcessLock | undefined;
|
|
65
|
+
|
|
66
|
+
interface SlackSocketModePostgresLockClient {
|
|
67
|
+
query<T = unknown>(sql: string, values?: readonly unknown[]): Promise<{
|
|
68
|
+
rows: T[];
|
|
69
|
+
rowCount?: number | null;
|
|
70
|
+
}>;
|
|
71
|
+
release?: () => void;
|
|
72
|
+
}
|
|
73
|
+
interface SlackSocketModePostgresLockPool {
|
|
74
|
+
connect(): Promise<SlackSocketModePostgresLockClient>;
|
|
75
|
+
end?: () => Promise<void>;
|
|
76
|
+
}
|
|
77
|
+
interface SlackSocketModePostgresLockOptions {
|
|
78
|
+
appSlug: string;
|
|
79
|
+
appToken?: string;
|
|
80
|
+
client?: SlackSocketModePostgresLockClient;
|
|
81
|
+
connectionString?: string;
|
|
82
|
+
enabled?: boolean;
|
|
83
|
+
logger?: Logger;
|
|
84
|
+
namespace?: string;
|
|
85
|
+
pool?: SlackSocketModePostgresLockPool;
|
|
86
|
+
}
|
|
87
|
+
interface SlackSocketModePostgresLock {
|
|
88
|
+
path: string;
|
|
89
|
+
close(): Promise<void>;
|
|
90
|
+
release(): Promise<void>;
|
|
91
|
+
}
|
|
92
|
+
declare function acquireSlackSocketModePostgresLock({ appSlug, appToken, client, connectionString, enabled, logger, namespace, pool, }: SlackSocketModePostgresLockOptions): Promise<SlackSocketModePostgresLock | undefined>;
|
|
93
|
+
|
|
94
|
+
export { type CreateSlackSocketBoltAppOptions, type CreateSlackSocketBoltAppResult, type SlackSocketModePostgresLock, type SlackSocketModePostgresLockClient, type SlackSocketModePostgresLockOptions, type SlackSocketModePostgresLockPool, type SlackSocketModeProcessLock, type SlackSocketModeProcessLockOptions, acquireSlackSocketModePostgresLock, acquireSlackSocketModeProcessLock, createSlackSocketBoltApp };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
acquireSlackSocketModePostgresLock,
|
|
3
|
+
acquireSlackSocketModeProcessLock,
|
|
4
|
+
createSlackSdkLogger,
|
|
5
|
+
createSlackSocketBoltApp,
|
|
6
|
+
createSlackSocketModeRestartGuard,
|
|
7
|
+
createSlackSocketModeRuntime,
|
|
8
|
+
redactSlackSocketModeLogValue
|
|
9
|
+
} from "../../chunk-73QXT7MA.js";
|
|
10
|
+
import "../../chunk-S3SWPYXJ.js";
|
|
11
|
+
export {
|
|
12
|
+
acquireSlackSocketModePostgresLock,
|
|
13
|
+
acquireSlackSocketModeProcessLock,
|
|
14
|
+
createSlackSdkLogger,
|
|
15
|
+
createSlackSocketBoltApp,
|
|
16
|
+
createSlackSocketModeRestartGuard,
|
|
17
|
+
createSlackSocketModeRuntime,
|
|
18
|
+
redactSlackSocketModeLogValue
|
|
19
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* OAuth and installation type declarations for the direct Slack adapter.
|
|
5
|
+
*
|
|
6
|
+
* Pure types — no runtime imports beyond `node:http` request/response.
|
|
7
|
+
* Mirrors the public surface of `@slack/oauth` enough that callers can
|
|
8
|
+
* implement custom installation/state stores without depending on Bolt's
|
|
9
|
+
* internal types.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
type SlackDirectAuthMode = "single-workspace" | "oauth" | "authorize";
|
|
13
|
+
interface SlackOAuthError extends Error {
|
|
14
|
+
code: string;
|
|
15
|
+
}
|
|
16
|
+
interface SlackInstallURLOptions {
|
|
17
|
+
scopes?: string[];
|
|
18
|
+
userScopes?: string[];
|
|
19
|
+
redirectUri?: string;
|
|
20
|
+
metadata?: string;
|
|
21
|
+
teamId?: string;
|
|
22
|
+
}
|
|
23
|
+
interface SlackInstallationQuery {
|
|
24
|
+
teamId: string | undefined;
|
|
25
|
+
enterpriseId: string | undefined;
|
|
26
|
+
userId?: string;
|
|
27
|
+
conversationId?: string;
|
|
28
|
+
isEnterpriseInstall: boolean;
|
|
29
|
+
}
|
|
30
|
+
interface SlackInstallation {
|
|
31
|
+
team?: {
|
|
32
|
+
id: string;
|
|
33
|
+
name?: string;
|
|
34
|
+
} | undefined;
|
|
35
|
+
enterprise?: {
|
|
36
|
+
id: string;
|
|
37
|
+
name?: string;
|
|
38
|
+
} | undefined;
|
|
39
|
+
user: {
|
|
40
|
+
id: string;
|
|
41
|
+
token?: string;
|
|
42
|
+
refreshToken?: string;
|
|
43
|
+
expiresAt?: number;
|
|
44
|
+
scopes?: string[];
|
|
45
|
+
};
|
|
46
|
+
bot?: {
|
|
47
|
+
token: string;
|
|
48
|
+
refreshToken?: string;
|
|
49
|
+
expiresAt?: number;
|
|
50
|
+
scopes: string[];
|
|
51
|
+
id?: string;
|
|
52
|
+
userId?: string;
|
|
53
|
+
};
|
|
54
|
+
incomingWebhook?: {
|
|
55
|
+
url: string;
|
|
56
|
+
channel?: string;
|
|
57
|
+
channelId?: string;
|
|
58
|
+
configurationUrl?: string;
|
|
59
|
+
};
|
|
60
|
+
appId?: string;
|
|
61
|
+
tokenType?: "bot";
|
|
62
|
+
enterpriseUrl?: string;
|
|
63
|
+
isEnterpriseInstall?: boolean;
|
|
64
|
+
authVersion?: "v1" | "v2";
|
|
65
|
+
metadata?: string;
|
|
66
|
+
}
|
|
67
|
+
interface SlackInstallationStore {
|
|
68
|
+
storeInstallation(installation: SlackInstallation, logger?: unknown): Promise<void>;
|
|
69
|
+
fetchInstallation(query: SlackInstallationQuery, logger?: unknown): Promise<SlackInstallation>;
|
|
70
|
+
deleteInstallation?(query: SlackInstallationQuery, logger?: unknown): Promise<void>;
|
|
71
|
+
}
|
|
72
|
+
interface SlackStateStore {
|
|
73
|
+
generateStateParam(installOptions: SlackInstallURLOptions, now: Date): Promise<string>;
|
|
74
|
+
verifyStateParam(now: Date, state: string): Promise<SlackInstallURLOptions>;
|
|
75
|
+
}
|
|
76
|
+
interface SlackOAuthInstallPathOptions {
|
|
77
|
+
beforeRedirection?: (request: IncomingMessage, response: ServerResponse, options?: SlackInstallURLOptions) => Promise<boolean>;
|
|
78
|
+
}
|
|
79
|
+
interface SlackOAuthCallbackOptions {
|
|
80
|
+
beforeInstallation?: (options: SlackInstallURLOptions, request: IncomingMessage, response: ServerResponse) => Promise<boolean>;
|
|
81
|
+
afterInstallation?: (installation: SlackInstallation, options: SlackInstallURLOptions, request: IncomingMessage, response: ServerResponse) => Promise<boolean>;
|
|
82
|
+
success?: (installation: SlackInstallation, options: SlackInstallURLOptions, request: IncomingMessage, response: ServerResponse) => void;
|
|
83
|
+
successAsync?: (installation: SlackInstallation, options: SlackInstallURLOptions, request: IncomingMessage, response: ServerResponse) => Promise<void>;
|
|
84
|
+
failure?: (error: SlackOAuthError, options: SlackInstallURLOptions, request: IncomingMessage, response: ServerResponse) => void;
|
|
85
|
+
failureAsync?: (error: SlackOAuthError, options: SlackInstallURLOptions, request: IncomingMessage, response: ServerResponse) => Promise<void>;
|
|
86
|
+
}
|
|
87
|
+
interface SlackAuthorizeSource {
|
|
88
|
+
teamId: string | undefined;
|
|
89
|
+
enterpriseId: string | undefined;
|
|
90
|
+
userId?: string;
|
|
91
|
+
conversationId?: string;
|
|
92
|
+
isEnterpriseInstall: boolean;
|
|
93
|
+
}
|
|
94
|
+
interface SlackAuthorizeResult {
|
|
95
|
+
botToken?: string;
|
|
96
|
+
userToken?: string;
|
|
97
|
+
botId?: string;
|
|
98
|
+
botUserId?: string;
|
|
99
|
+
userId?: string;
|
|
100
|
+
teamId?: string;
|
|
101
|
+
enterpriseId?: string;
|
|
102
|
+
[key: string]: unknown;
|
|
103
|
+
}
|
|
104
|
+
type SlackAuthorizeFn = (source: SlackAuthorizeSource, body?: unknown) => Promise<SlackAuthorizeResult>;
|
|
105
|
+
interface SlackSingleWorkspaceAuthOptions {
|
|
106
|
+
mode?: "single-workspace";
|
|
107
|
+
botToken?: string;
|
|
108
|
+
botId?: string;
|
|
109
|
+
botUserId?: string;
|
|
110
|
+
}
|
|
111
|
+
interface SlackOAuthAuthOptions {
|
|
112
|
+
mode: "oauth";
|
|
113
|
+
clientId?: string;
|
|
114
|
+
clientSecret?: string;
|
|
115
|
+
stateSecret?: string;
|
|
116
|
+
installationStore: SlackInstallationStore;
|
|
117
|
+
stateStore?: SlackStateStore;
|
|
118
|
+
stateVerification?: boolean;
|
|
119
|
+
legacyStateVerification?: boolean;
|
|
120
|
+
stateCookieName?: string;
|
|
121
|
+
stateCookieExpirationSeconds?: number;
|
|
122
|
+
redirectUri?: string;
|
|
123
|
+
scopes?: string[];
|
|
124
|
+
userScopes?: string[];
|
|
125
|
+
metadata?: string;
|
|
126
|
+
installPath?: string;
|
|
127
|
+
callbackPath?: string;
|
|
128
|
+
renderHtmlForInstallPath?: (url: string) => string;
|
|
129
|
+
installPathOptions?: SlackOAuthInstallPathOptions;
|
|
130
|
+
callbackOptions?: SlackOAuthCallbackOptions;
|
|
131
|
+
directInstall?: boolean;
|
|
132
|
+
authVersion?: "v1" | "v2";
|
|
133
|
+
authorizationUrl?: string;
|
|
134
|
+
}
|
|
135
|
+
interface SlackCustomAuthorizeAuthOptions {
|
|
136
|
+
mode: "authorize";
|
|
137
|
+
authorize: SlackAuthorizeFn;
|
|
138
|
+
}
|
|
139
|
+
type SlackDirectAuthOptions = SlackSingleWorkspaceAuthOptions | SlackOAuthAuthOptions | SlackCustomAuthorizeAuthOptions;
|
|
140
|
+
|
|
141
|
+
export type { SlackAuthorizeFn as S, SlackAuthorizeResult as a, SlackAuthorizeSource as b, SlackCustomAuthorizeAuthOptions as c, SlackDirectAuthMode as d, SlackDirectAuthOptions as e, SlackInstallation as f, SlackInstallationQuery as g, SlackInstallationStore as h, SlackOAuthAuthOptions as i, SlackOAuthCallbackOptions as j, SlackOAuthError as k, SlackOAuthInstallPathOptions as l, SlackSingleWorkspaceAuthOptions as m, SlackStateStore as n };
|