Skip to content

Commit c61cb4f

Browse files
authored
fix: misc slack fixes (#73)
1 parent 133ab2e commit c61cb4f

File tree

8 files changed

+26
-18
lines changed

8 files changed

+26
-18
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vesselapi/integrations",
3-
"version": "0.0.53",
3+
"version": "0.0.54",
44
"description": "Vessel integrations",
55
"main": "dist/index.js",
66
"module": "dist/index.mjs",

src/platforms/slack/actions/conversations/list.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// import { outreachUrl } from '@/platforms/outreach/actions/validators';
21
import { client } from '@/platforms/slack/client';
32
import { action } from '@/sdk';
43
import { z } from 'zod';

src/platforms/slack/client.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,11 @@ export const client = {
3030
...(cursor ? { cursor } : {}),
3131
limit: `${DEFAULT_PAGE_SIZE}`,
3232
},
33-
schema: z.intersection(
34-
custom.object({
33+
schema: custom
34+
.object({
3535
members: z.array(slackUser),
36-
}),
37-
slackPaginated,
38-
),
36+
})
37+
.extend(slackPaginated.shape),
3938
})),
4039
},
4140
conversations: {
@@ -46,12 +45,11 @@ export const client = {
4645
...(cursor ? { cursor } : {}),
4746
limit: `${DEFAULT_PAGE_SIZE}`,
4847
},
49-
schema: z.intersection(
50-
custom.object({
48+
schema: custom
49+
.object({
5150
channels: z.array(slackConversation),
52-
}),
53-
slackPaginated,
54-
),
51+
})
52+
.extend(slackPaginated.shape),
5553
})),
5654
},
5755
messages: {

src/platforms/slack/icon.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
export const icon = 'tbd';
1+
export const icon =
2+
'data:text/html;base64,PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ImVuIj4KICA8aGVhZD4KICAgIDxtZXRhIGNoYXJzZXQ9InV0Zi04Ij4KICAgIDxtZXRhIG5hbWU9InZpZXdwb3J0IiBjb250ZW50PSJ3aWR0aD1kZXZpY2Utd2lkdGgsaW5pdGlhbC1zY2FsZT0xIj4KICAgIDxtZXRhIG5hbWU9InJvYm90cyIgY29udGVudD0ibm9pbmRleCxub2ZvbGxvdyI+CgogICAgPHRpdGxlPkZvcmJpZGRlbjwvdGl0bGU+CiAgICA8bGluayByZWw9InN0eWxlc2hlZXQiIHR5cGU9InRleHQvY3NzIiBocmVmPSIvY3NzL2JsYW5rLmNzcyI+CiAgPC9oZWFkPgoKICA8Ym9keT4KICAgIDxoMT5Gb3JiaWRkZW48L2gxPgogICAgPHA+U29ycnksIHlvdSBkb24ndCBoYXZlIHBlcm1pc3Npb24gdG8gYWNjZXNzIHRoaXMgcmVzb3VyY2UgZnJvbSBoZXJlLjwvcD4KICA8L2JvZHk+CjwvaHRtbD4K';

src/platforms/slack/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,22 @@ import listUsers from '@/platforms/slack/actions/users/list';
55
import { client } from '@/platforms/slack/client';
66
import * as constants from '@/platforms/slack/constants';
77
import { icon } from '@/platforms/slack/icon';
8+
import { slackExpiredAuth } from '@/platforms/slack/schemas';
89
import { auth, platform } from '@/sdk';
910

1011
export * as types from '@/platforms/slack/schemas';
1112

1213
export default platform('slack', {
1314
auth: auth.oauth2({
14-
authUrl: 'https://slack.com/oauth/authorize',
15-
tokenUrl: 'https://slack.com/api/oauth.access',
15+
authUrl: 'https://slack.com/oauth/v2/authorize',
16+
tokenUrl: 'https://slack.com/api/oauth.v2.access',
1617
oauthBodyFormat: 'form',
17-
scopeSeparator: ' ',
18+
scopeSeparator: ',',
1819
default: true,
20+
isRetryable: async ({ response }) => {
21+
const zodResult = slackExpiredAuth.safeParse(await response.json());
22+
return zodResult.success;
23+
},
1924
}),
2025
display: {
2126
name: 'Slack',

src/platforms/slack/schemas.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ export const slackPaginated = custom.object({
77
}),
88
});
99

10+
export const slackExpiredAuth = custom.object({
11+
ok: z.literal(false),
12+
error: z.literal('token_expired'),
13+
});
14+
1015
export const slackUser = custom.object({
1116
id: z.string(),
1217
name: z.string(),

src/sdk/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const auth = {
6363
}?${toQueryString(query)}`;
6464
}),
6565
isRetryable:
66-
options.isRetryable ?? (({ response }) => response.status === 401),
66+
options.isRetryable ?? (async ({ response }) => response.status === 401),
6767
}),
6868
apiToken: <T extends Record<string, string> = Record<string, string>>(
6969
options: {

src/sdk/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export type RetryableCheckFunction = ({
6161
response,
6262
}: {
6363
response: Response;
64-
}) => boolean;
64+
}) => Promise<boolean>;
6565

6666
export type StandardAuthConfig<
6767
TAnswers extends Record<string, string> = Record<string, string>,

0 commit comments

Comments
 (0)