diff --git a/package.json b/package.json index d687ff18..2c328b3c 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/platforms/zendesk/client.ts b/src/platforms/zendesk/client.ts index 77e2abb8..17a50b8b 100644 --- a/src/platforms/zendesk/client.ts +++ b/src/platforms/zendesk/client.ts @@ -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, diff --git a/src/platforms/zendesk/index.ts b/src/platforms/zendesk/index.ts index bd013c7c..21f71fdb 100644 --- a/src/platforms/zendesk/index.ts +++ b/src/platforms/zendesk/index.ts @@ -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', diff --git a/src/sdk/types.ts b/src/sdk/types.ts index 29369be4..e04f186c 100644 --- a/src/sdk/types.ts +++ b/src/sdk/types.ts @@ -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; @@ -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; + /** + * 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; refreshTokenExpiresAt: () => Date | null; accessTokenExpiresAt: () => Date | null;