Skip to content
← Public packages

@kody/slack

Read Slack conversations and safely send messages as the authorizing user through the saved slack OAuth integration.

src/index.ts

52 lines · 1.3 KB · TypeScript
import {
	SLACK_ALLOWED_HOSTS,
	SLACK_API_BASE_URL,
	SLACK_AUTHORIZE_URL,
	SLACK_CALLBACK_URL,
	SLACK_DASHBOARD_URL,
	SLACK_INTEGRATION,
	SLACK_TOKEN_URL,
	SLACK_USER_SCOPES,
	byoConnectUrl,
	connectOauthUrl,
} from './request.ts'

/** Describe the Slack helpers package and the user-token connect URL. */
export default async function slackOverview() {
	return {
		package: '@kody/slack',
		integration: SLACK_INTEGRATION,
		identity: 'user',
		apiBaseUrl: SLACK_API_BASE_URL,
		callbackUrl: SLACK_CALLBACK_URL,
		connectUrl: byoConnectUrl(),
		reconnectUrl: connectOauthUrl(SLACK_INTEGRATION),
		userScopes: [...SLACK_USER_SCOPES],
		requiredHosts: [...SLACK_ALLOWED_HOSTS],
		auth: {
			kind: 'user-token',
			useFor:
				'Create a Slack app with User Token Scopes and connect it. Helpers reject bot tokens.',
			authorizeUrl: SLACK_AUTHORIZE_URL,
			tokenUrl: SLACK_TOKEN_URL,
			flow: 'confidential',
			tokenExchangeStyle: 'form',
			scopeSeparator: ',',
			dashboardUrl: SLACK_DASHBOARD_URL,
			connectUrl: byoConnectUrl(),
		},
		exports: [
			'smoke-test',
			'list-conversations',
			'list-users',
			'get-history',
			'get-replies',
			'send-message',
		],
		safety: {
			sendingRequiresConfirmation: true,
			dryRunAvailable: true,
			botTokensSupported: false,
		},
	}
}