Skip to content

Commit

Permalink
fix: Zendesk basic support (#240)
Browse files Browse the repository at this point in the history
* zendesk basic support

* bump package version
  • Loading branch information
zkirby authored Jul 19, 2023
1 parent 63a62f3 commit 4718bfc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vesselapi/integrations",
"version": "1.0.29",
"version": "1.0.30",
"description": "Vessel integrations",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down
8 changes: 7 additions & 1 deletion src/platforms/zendesk/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ import { HttpsUrl } from '../../sdk';
import { API_VERSION } from './constants';

const request = makeRequestFactory(async (auth, options) => {
if (auth.type === 'oauth2')
throw new Error('Zendesk Does not support OAuth.');

const { answers } = await auth.getMetadata();
const url =
`https://${answers.subdomain}.zendesk.com/api/${API_VERSION}` as HttpsUrl;
const token = toBase64(`${answers.email}/token:${await auth.getToken()}`);
const token =
auth.type === 'apiKey'
? toBase64(`${answers.email}/token:${await auth.getToken()}`)
: await auth.getToken();

return {
...options,
Expand Down
24 changes: 11 additions & 13 deletions src/platforms/zendesk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,17 @@ export default platform('zendesk', {
],
default: true,
}),
// TODO: Add Basic support. This will require changing the core sdk

// auth.basic({
// questions: [
// { type: 'text', id: 'username', label: 'Username' },
// { type: 'text', id: 'password', label: 'Password' },
// {
// id: 'subdomain',
// type: 'text',
// label: 'What is your account Subdomain?',
// },
// ],
// }),
auth.basic({
questions: [
{ type: 'text', id: 'username', label: 'Username' },
{ type: 'text', id: 'password', label: 'Password' },
{
id: 'subdomain',
type: 'text',
label: 'What is your account Subdomain?',
},
],
}),
],
display: {
name: 'Zendesk',
Expand Down
14 changes: 14 additions & 0 deletions src/sdk/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,12 @@ export type OAuth2AuthConfig<
default: boolean;
authUrl: (options: {
answers: TAnswers;
/** @deprecated */
appMetadata: TOAuth2AppMeta;
}) => HttpsUrl;
tokenUrl: (options: {
answers: TAnswers;
/** @deprecated */
appMetadata: TOAuth2AppMeta;
callbackArgs: TOAuth2CallbackArgs;
}) => HttpsUrl;
Expand Down Expand Up @@ -176,7 +178,19 @@ export type OAuth2AuthConfig<
display: {
markdown: string | ((platform: Platform<{}, any, string>) => string);
};
/**
* Surfaces information we store about the
* OAuth2 app itself.
*
* This was used by msoft teams but is being deprecated in
* favor of a different auth method.
* @deprecated */
appMetadataSchema: z.ZodType<TOAuth2AppMeta>;
/**
* Surfaces information that we got in the query string
* of the callback url that was called by the downstream
* system after the /authorization step.
*/
callbackArgsSchema: z.ZodType<TOAuth2CallbackArgs>;
refreshTokenExpiresAt: () => Date | null;
accessTokenExpiresAt: () => Date | null;
Expand Down

0 comments on commit 4718bfc

Please sign in to comment.