Skip to content

Commit 4718bfc

Browse files
authored
fix: Zendesk basic support (#240)
* zendesk basic support * bump package version
1 parent 63a62f3 commit 4718bfc

File tree

4 files changed

+33
-15
lines changed

4 files changed

+33
-15
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": "1.0.29",
3+
"version": "1.0.30",
44
"description": "Vessel integrations",
55
"main": "dist/index.js",
66
"module": "dist/index.mjs",

src/platforms/zendesk/client.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@ import { HttpsUrl } from '../../sdk';
33
import { API_VERSION } from './constants';
44

55
const request = makeRequestFactory(async (auth, options) => {
6+
if (auth.type === 'oauth2')
7+
throw new Error('Zendesk Does not support OAuth.');
8+
69
const { answers } = await auth.getMetadata();
710
const url =
811
`https://${answers.subdomain}.zendesk.com/api/${API_VERSION}` as HttpsUrl;
9-
const token = toBase64(`${answers.email}/token:${await auth.getToken()}`);
12+
const token =
13+
auth.type === 'apiKey'
14+
? toBase64(`${answers.email}/token:${await auth.getToken()}`)
15+
: await auth.getToken();
1016

1117
return {
1218
...options,

src/platforms/zendesk/index.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,17 @@ export default platform('zendesk', {
2121
],
2222
default: true,
2323
}),
24-
// TODO: Add Basic support. This will require changing the core sdk
25-
26-
// auth.basic({
27-
// questions: [
28-
// { type: 'text', id: 'username', label: 'Username' },
29-
// { type: 'text', id: 'password', label: 'Password' },
30-
// {
31-
// id: 'subdomain',
32-
// type: 'text',
33-
// label: 'What is your account Subdomain?',
34-
// },
35-
// ],
36-
// }),
24+
auth.basic({
25+
questions: [
26+
{ type: 'text', id: 'username', label: 'Username' },
27+
{ type: 'text', id: 'password', label: 'Password' },
28+
{
29+
id: 'subdomain',
30+
type: 'text',
31+
label: 'What is your account Subdomain?',
32+
},
33+
],
34+
}),
3735
],
3836
display: {
3937
name: 'Zendesk',

src/sdk/types.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,12 @@ export type OAuth2AuthConfig<
144144
default: boolean;
145145
authUrl: (options: {
146146
answers: TAnswers;
147+
/** @deprecated */
147148
appMetadata: TOAuth2AppMeta;
148149
}) => HttpsUrl;
149150
tokenUrl: (options: {
150151
answers: TAnswers;
152+
/** @deprecated */
151153
appMetadata: TOAuth2AppMeta;
152154
callbackArgs: TOAuth2CallbackArgs;
153155
}) => HttpsUrl;
@@ -176,7 +178,19 @@ export type OAuth2AuthConfig<
176178
display: {
177179
markdown: string | ((platform: Platform<{}, any, string>) => string);
178180
};
181+
/**
182+
* Surfaces information we store about the
183+
* OAuth2 app itself.
184+
*
185+
* This was used by msoft teams but is being deprecated in
186+
* favor of a different auth method.
187+
* @deprecated */
179188
appMetadataSchema: z.ZodType<TOAuth2AppMeta>;
189+
/**
190+
* Surfaces information that we got in the query string
191+
* of the callback url that was called by the downstream
192+
* system after the /authorization step.
193+
*/
180194
callbackArgsSchema: z.ZodType<TOAuth2CallbackArgs>;
181195
refreshTokenExpiresAt: () => Date | null;
182196
accessTokenExpiresAt: () => Date | null;

0 commit comments

Comments
 (0)