From ae755dc43e510af083e71bac13f5c1f491755e15 Mon Sep 17 00:00:00 2001 From: Fil Maj Date: Fri, 19 Apr 2024 12:32:21 +0000 Subject: [PATCH] web-api(fix): oauth.v2.exchange method requires a token parameter (#1779) --- packages/web-api/src/types/request/oauth.ts | 5 ++++- .../test/types/methods/oauth.test-d.ts | 20 +++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/packages/web-api/src/types/request/oauth.ts b/packages/web-api/src/types/request/oauth.ts index d5af94784..5acaed690 100644 --- a/packages/web-api/src/types/request/oauth.ts +++ b/packages/web-api/src/types/request/oauth.ts @@ -8,4 +8,7 @@ export interface OAuthAccessArguments extends OAuthCredentials { // https://api.slack.com/methods/oauth.v2.access export interface OAuthV2AccessArguments extends OAuthCredentials, OAuthGrantRefresh {} // https://api.slack.com/methods/oauth.v2.exchange -export interface OAuthV2ExchangeArguments extends Pick {} +export interface OAuthV2ExchangeArguments extends Pick { + /** @description The legacy xoxb or xoxp token being migrated. */ + token: string; +} diff --git a/packages/web-api/test/types/methods/oauth.test-d.ts b/packages/web-api/test/types/methods/oauth.test-d.ts index 1e1ec23b8..3056677dd 100644 --- a/packages/web-api/test/types/methods/oauth.test-d.ts +++ b/packages/web-api/test/types/methods/oauth.test-d.ts @@ -41,12 +41,28 @@ expectAssignable>([{ expectError(web.oauth.v2.exchange()); // lacking argument expectError(web.oauth.v2.exchange({})); // empty argument expectError(web.oauth.v2.exchange({ - client_id: 'C1234', // missing client_secret + client_id: 'C1234', // missing client_secret, token })); expectError(web.oauth.v2.exchange({ - client_secret: '1234.567', // missing `client_id` + client_secret: '1234.567', // missing `client_id`, token +})); +expectError(web.oauth.v2.exchange({ + token: 'xoxp-blah', // missing `client_id`, client_secret +})); +expectError(web.oauth.v2.exchange({ + client_id: 'C1234', + client_secret: '1234.567', // missing token +})); +expectError(web.oauth.v2.exchange({ + client_id: 'C1234', + token: 'xoxb-blah', // missing client_secret +})); +expectError(web.oauth.v2.exchange({ + client_secret: '1234.567', + token: 'xoxb-blah', // missing client_id })); // -- happy path expectAssignable>([{ + token: 'xoxb-blah', ...creds, }]);