mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 16:27:40 +00:00
fix: use a non-team based api call for validation
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable no-await-in-loop */
|
/* eslint-disable no-await-in-loop */
|
||||||
import { AxiosError, AxiosResponse } from "axios";
|
import { AxiosError } from "axios";
|
||||||
|
|
||||||
import { request } from "@app/lib/config/request";
|
import { request } from "@app/lib/config/request";
|
||||||
import { BadRequestError, InternalServerError } from "@app/lib/errors";
|
import { BadRequestError, InternalServerError } from "@app/lib/errors";
|
||||||
@@ -27,10 +27,8 @@ export const getVercelConnectionListItem = () => {
|
|||||||
export const validateVercelConnectionCredentials = async (config: TVercelConnectionConfig) => {
|
export const validateVercelConnectionCredentials = async (config: TVercelConnectionConfig) => {
|
||||||
const { credentials: inputCredentials } = config;
|
const { credentials: inputCredentials } = config;
|
||||||
|
|
||||||
let response: AxiosResponse<VercelApp[]> | null = null;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
response = await request.get<VercelApp[]>(`${IntegrationUrls.VERCEL_API_URL}/v9/projects`, {
|
await request.get<VercelApp[]>(`${IntegrationUrls.VERCEL_API_URL}/v2/user`, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${inputCredentials.apiToken}`
|
Authorization: `Bearer ${inputCredentials.apiToken}`
|
||||||
}
|
}
|
||||||
@@ -38,17 +36,14 @@ export const validateVercelConnectionCredentials = async (config: TVercelConnect
|
|||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
if (error instanceof AxiosError) {
|
if (error instanceof AxiosError) {
|
||||||
throw new BadRequestError({
|
throw new BadRequestError({
|
||||||
message: `Failed to validate credentials: ${error.message || "Unknown error"}`
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||||
|
message: `Failed to validate credentials: ${
|
||||||
|
error.response?.data ? JSON.stringify(error.response?.data) : error.message || "Unknown error"
|
||||||
|
}`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
throw new BadRequestError({
|
throw new BadRequestError({
|
||||||
message: "Unable to validate connection - verify credentials"
|
message: `Unable to validate connection: ${(error as Error).message || "Verify credentials"}`
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!response?.data) {
|
|
||||||
throw new InternalServerError({
|
|
||||||
message: "Failed to get organizations: Response was empty"
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user