From 1d6a8738ab984875e1117ad205eccd2871040a4e Mon Sep 17 00:00:00 2001 From: William Bergamin Date: Thu, 15 Oct 2026 15:20:48 -0400 Subject: [PATCH 1/2] feat: add AuthProviderBlock to @slack/types Co-Authored-By: Claude --- .changeset/add-auth-provider-block.md | 5 ++ packages/types/src/block-kit/blocks.ts | 67 ++++++++++++++++++++++++++ packages/types/test/blocks.test-d.ts | 56 +++++++++++++++++++++ 3 files changed, 128 insertions(+) create mode 100644 .changeset/add-auth-provider-block.md diff --git a/.changeset/add-auth-provider-block.md b/.changeset/add-auth-provider-block.md new file mode 100644 index 000000000..ab7517292 --- /dev/null +++ b/.changeset/add-auth-provider-block.md @@ -0,0 +1,5 @@ +--- +"@slack/types": minor +--- + +feat(types): add [`AuthProviderBlock`](https://docs.slack.dev/reference/block-kit/blocks/auth-provider-block) block interface diff --git a/packages/types/src/block-kit/blocks.ts b/packages/types/src/block-kit/blocks.ts index aa9d44d76..60dea175d 100644 --- a/packages/types/src/block-kit/blocks.ts +++ b/packages/types/src/block-kit/blocks.ts @@ -57,6 +57,7 @@ export interface Block { export type KnownBlock = | ActionsBlock | AlertBlock + | AuthProviderBlock | CardBlock | CarouselBlock | ContainerBlock @@ -134,6 +135,72 @@ export interface AlertBlock extends Block { level?: 'default' | 'info' | 'warning' | 'error' | 'success'; } +/** + * @description Displays authentication provider information, including its icon, name, and connection state. + * @see {@link https://docs.slack.dev/reference/block-kit/blocks/auth-provider-block Auth provider block reference}. + */ +export interface AuthProviderBlock extends Block { + /** + * @description The type of block. For an auth provider block, `type` is always `auth_provider`. + */ + type: 'auth_provider'; + /** + * @description Unique identifier for this provider within the app. Included in interaction payloads and used to + * derive the connect button `action_id` (`auth_provider_connect_`). Maximum length for this field is 150 + * characters. + */ + value: string; + /** + * @description Human-readable name of the provider in the form of a {@link PlainTextElement}. + * Maximum length for the text in this field is 75 characters. + */ + name: PlainTextElement; + /** + * @description Whether this provider is currently connected or disconnected. Slack records this state for the user, + * so an omitted value would be indistinguishable from an explicit `false` and silently mark the user disconnected. + */ + is_connected: boolean; + /** + * @description Brief description of what this connection enables in the form of a {@link PlainTextElement}. + * Maximum length for the text in this field is 150 characters. + */ + description?: PlainTextElement; + /** + * @description URL for the provider icon image. Must be an HTTPS URL. Falls back to the app's avatar when absent. + * Maximum length for this field is 3000 characters. + */ + icon_url?: string; + /** + * @description OAuth redirect URL opened when the user clicks Connect. Must be an HTTPS URL on a host listed in the + * app manifest's `features.user_connections.auth_hosts`. + */ + auth_url?: string; + /** + * @description URL opened when the user clicks Disconnect. Must be an HTTPS URL on a host listed in the app + * manifest's `features.user_connections.auth_hosts`. Maximum length for this field is 3000 characters. + */ + disconnect_url?: string; + /** + * @description Display name of the connected account in the form of a {@link PlainTextElement}, shown when + * `is_connected` is `true`. + */ + connected_identity?: PlainTextElement; + /** + * @description Additional context about the connection in the form of a {@link PlainTextElement}, e.g. the org or + * workspace name. + */ + connected_context?: PlainTextElement; + /** + * @description An {@link Overflow} element shown when connected, e.g. with Disconnect or Re-authenticate options. + */ + accessory?: Overflow; + /** + * @description An array of {@link KnownBlock} objects rendered by clients that don't recognize `auth_provider`, + * spliced into the parent blocks array. + */ + fallback?: KnownBlock[]; +} + /** * @description Displays content in a card. At least one of `hero_image`, `title`, `actions`, or `body` must be provided. * @see {@link https://docs.slack.dev/reference/block-kit/blocks/card-block Card block reference}. diff --git a/packages/types/test/blocks.test-d.ts b/packages/types/test/blocks.test-d.ts index 59de4897d..26e2525c8 100644 --- a/packages/types/test/blocks.test-d.ts +++ b/packages/types/test/blocks.test-d.ts @@ -1,6 +1,7 @@ import { expectAssignable, expectError } from 'tsd'; import type { AlertBlock, + AuthProviderBlock, CardBlock, CarouselBlock, ContainerBlock, @@ -50,6 +51,61 @@ expectAssignable({ level: 'error', }); +// AuthProviderBlock +// -- sad path +expectError({}); // missing type, value, name, and is_connected +expectError({ + type: 'auth_provider', + value: 'lumon', + name: { type: 'plain_text', text: 'Lumon' }, +}); // missing required is_connected +expectError({ + type: 'auth_provider', + value: 'lumon', + name: { type: 'mrkdwn', text: 'Lumon' }, + is_connected: false, +}); // name must be plain_text +expectError({ + type: 'auth_provider', + value: 'lumon', + name: { type: 'plain_text', text: 'Lumon' }, + is_connected: true, + accessory: { type: 'button', text: { type: 'plain_text', text: 'Disconnect' }, action_id: 'disconnect' }, +}); // accessory must be an overflow menu +// -- happy path +expectAssignable({ + type: 'auth_provider', + value: 'lumon', + name: { type: 'plain_text', text: 'Lumon' }, + is_connected: false, + auth_url: 'https://lumon.example.com/oauth', +}); +expectAssignable({ + type: 'auth_provider', + block_id: 'lumon_connection', + value: 'lumon', + name: { type: 'plain_text', text: 'Lumon' }, + is_connected: true, + description: { type: 'plain_text', text: 'Sync your refinement progress' }, + icon_url: 'https://lumon.example.com/icon.png', + auth_url: 'https://lumon.example.com/oauth', + disconnect_url: 'https://lumon.example.com/disconnect', + connected_identity: { type: 'plain_text', text: 'mark.s@lumon.example.com' }, + connected_context: { type: 'plain_text', text: 'Macrodata Refinement' }, + accessory: { + type: 'overflow', + action_id: 'lumon_menu', + options: [{ text: { type: 'plain_text', text: 'Disconnect' }, value: 'disconnect' }], + }, + fallback: [{ type: 'section', text: { type: 'mrkdwn', text: 'Connected to *Lumon*' } }], +}); +expectAssignable({ + type: 'auth_provider', + value: 'lumon', + name: { type: 'plain_text', text: 'Lumon' }, + is_connected: false, +}); + // CarouselBlock // -- sad path expectError({}); // missing type and elements From 2d7ac5d57d312eee0cf9ecdcb550266574cfbe14 Mon Sep 17 00:00:00 2001 From: William Bergamin Date: Thu, 15 Oct 2026 15:36:56 -0400 Subject: [PATCH 2/2] docs(types): add missing AuthProviderBlock length limits and simplify is_connected Co-Authored-By: Claude --- packages/types/src/block-kit/blocks.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/types/src/block-kit/blocks.ts b/packages/types/src/block-kit/blocks.ts index 60dea175d..9237fbbea 100644 --- a/packages/types/src/block-kit/blocks.ts +++ b/packages/types/src/block-kit/blocks.ts @@ -156,8 +156,7 @@ export interface AuthProviderBlock extends Block { */ name: PlainTextElement; /** - * @description Whether this provider is currently connected or disconnected. Slack records this state for the user, - * so an omitted value would be indistinguishable from an explicit `false` and silently mark the user disconnected. + * @description Whether this provider is currently connected. Slack records this state for the user. */ is_connected: boolean; /** @@ -172,7 +171,7 @@ export interface AuthProviderBlock extends Block { icon_url?: string; /** * @description OAuth redirect URL opened when the user clicks Connect. Must be an HTTPS URL on a host listed in the - * app manifest's `features.user_connections.auth_hosts`. + * app manifest's `features.user_connections.auth_hosts`. Maximum length for this field is 3000 characters. */ auth_url?: string; /** @@ -182,21 +181,21 @@ export interface AuthProviderBlock extends Block { disconnect_url?: string; /** * @description Display name of the connected account in the form of a {@link PlainTextElement}, shown when - * `is_connected` is `true`. + * `is_connected` is `true`. Maximum length for the text in this field is 75 characters. */ connected_identity?: PlainTextElement; /** * @description Additional context about the connection in the form of a {@link PlainTextElement}, e.g. the org or - * workspace name. + * workspace name. Maximum length for the text in this field is 75 characters. */ connected_context?: PlainTextElement; /** - * @description An {@link Overflow} element shown when connected, e.g. with Disconnect or Re-authenticate options. + * @description An {@link Overflow} menu shown when connected, e.g. Disconnect or Re-authenticate. */ accessory?: Overflow; /** - * @description An array of {@link KnownBlock} objects rendered by clients that don't recognize `auth_provider`, - * spliced into the parent blocks array. + * @description An array of stable {@link KnownBlock} objects rendered by clients that don't recognize + * `auth_provider`, spliced into the parent blocks array. */ fallback?: KnownBlock[]; }