Throw if the clients are passed an undefined apikey or token

This commit is contained in:
Matt Aitken
2023-07-13 15:34:35 +01:00
parent cc26cbeb7b
commit bac8ad1040
6 changed files with 35 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
---
"@trigger.dev/typeform": patch
"@trigger.dev/github": patch
"@trigger.dev/openai": patch
"@trigger.dev/resend": patch
"@trigger.dev/plain": patch
---
Throw if the clients are passed an undefined apikey or token
+4
View File
@@ -92,6 +92,10 @@ export class Github
function createClientFromOptions(
options: GithubIntegrationOptions
): IntegrationClient<Octokit, typeof tasks> {
if (Object.keys(options).includes("token") && !options.token) {
throw new Error(`GitHub integration (${options.id}) token was undefined`);
}
if (options.token) {
const client = new Octokit({
auth: options.token,
+6
View File
@@ -9,6 +9,12 @@ export class OpenAI
client: IntegrationClient<OpenAIApi, typeof tasks>;
constructor(private options: OpenAIIntegrationOptions) {
if (Object.keys(options).includes("apiKey") && !options.apiKey) {
throw new Error(
`OpenAI integration (${options.id}) apiKey was undefined`
);
}
this.client = {
tasks,
usesLocalAuth: true,
+4
View File
@@ -17,6 +17,10 @@ export class Plain implements PlainIntegration {
client: PlainIntegrationClient;
constructor(private options: PlainIntegrationOptions) {
if (Object.keys(options).includes("apiKey") && !options.apiKey) {
throw new Error(`Plain integration (${options.id}) apiKey was undefined`);
}
this.client = {
tasks,
usesLocalAuth: true,
+6
View File
@@ -56,6 +56,12 @@ export class Resend
client: IntegrationClient<ResendClient, typeof tasks>;
constructor(private options: ResendIntegrationOptions) {
if (Object.keys(options).includes("apiKey") && !options.apiKey) {
throw new Error(
`Resend integration (${options.id}) apiKey was undefined`
);
}
this.client = {
tasks,
usesLocalAuth: true,
+6
View File
@@ -34,6 +34,12 @@ export class Typeform implements TypeformIntegration {
client: TypeformIntegrationClient;
constructor(private options: TypeformIntegrationOptions) {
if (Object.keys(options).includes("token") && !options.token) {
throw new Error(
`Typeform integration (${options.id}) token was undefined`
);
}
this.client = {
tasks,
usesLocalAuth: true,