Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
Fix merge conflicts
Tuan Dangf450be3a00d3
diff --cc backend/src/integrations/apps.tsindex e68f29f56e,39dba64356..4ea342c16a--- a/backend/src/integrations/apps.ts+++ b/backend/src/integrations/apps.ts@@@ -34,6 -32,9 +34,8 @@@ importINTEGRATION_TRAVISCI_API_URL,INTEGRATION_VERCEL,INTEGRATION_VERCEL_API_URL,+ INTEGRATION_CODEFRESH,+ INTEGRATION_CODEFRESH_API_URL-} from "../variables";interface App {@@@ -149,11 -148,11 +151,17 @@@ const getApps = async (accountId: accessId})break;+ case INTEGRATION_BITBUCKET:+ apps = await getAppsBitBucket({+ accessToken,+ workspaceSlug- })++ });++ break;+ case INTEGRATION_CODEFRESH:+ apps = await getAppsCodefresh({+ accessToken,+ });+ break;}return apps;@@@ -704,104 -703,61 +712,134 @@@ const getAppsCheckly = async ({ accessT* @returns {Object[]} apps - Cloudflare Pages projects* @returns {String} apps.name - name of Cloudflare Pages project*/- const getAppsCloudflarePages = async ({- accessToken,- accountId+ const getAppsCloudflarePages = async ({+ accessToken,+ accountId}: {- accessToken: string;- accountId?: string;+ accessToken: string;+ accountId?: string;}) => {- const { data } = await standardRequest.get(- `${INTEGRATION_CLOUDFLARE_PAGES_API_URL}/client/v4/accounts/${accountId}/pages/projects`,- {- headers: {- Authorization: `Bearer ${accessToken}`,- "Accept": "application/json",- },- }- );+ const { data } = await standardRequest.get(+ `${INTEGRATION_CLOUDFLARE_PAGES_API_URL}/client/v4/accounts/${accountId}/pages/projects`,+ {+ headers: {+ Authorization: `Bearer ${accessToken}`,+ "Accept": "application/json",+ },+ }+ );- const apps = data.result.map((a: any) => {- return {- name: a.name,- appId: a.id,- };- });- return apps;+ const apps = data.result.map((a: any) => {+ return {+ name: a.name,+ appId: a.id,+ };+ });+ return apps;}+/**+ * Return list of repositories for the BitBucket integration based on provided BitBucket workspace+ * @param {Object} obj+ * @param {String} obj.accessToken - access token for BitBucket API+ * @param {String} obj.workspaceSlug - Workspace identifier for fetching BitBucket repositories+ * @returns {Object[]} apps - BitBucket repositories+ * @returns {String} apps.name - name of BitBucket repository+ */+const getAppsBitBucket = async ({+ accessToken,+ workspaceSlug,+}: {+ accessToken: string;+ workspaceSlug?: string;+}) => {+ interface RepositoriesResponse {+ size: number;+ page: number;+ pageLen: number;+ next: string;+ previous: string;+ values: Array<Repository>;+ }++ interface Repository {+ type: string;+ uuid: string;+ name: string;+ is_private: boolean;+ created_on: string;+ updated_on: string;+ }++ if (!workspaceSlug) {+ return []+ }-+++ const repositories: Repository[] = [];+ let hasNextPage = true;+ let repositoriesUrl = `${INTEGRATION_BITBUCKET_API_URL}/2.0/repositories/${workspaceSlug}`++ while (hasNextPage) {+ const { data }: { data: RepositoriesResponse } = await standardRequest.get(+ repositoriesUrl,+ {+ headers: {+ Authorization: `Bearer ${accessToken}`,+ "Accept": "application/json",+ },+ }+ );++ if (data?.values.length > 0) {+ data.values.forEach((repository) => {+ repositories.push(repository)+ })+ }++ if (data.next) {+ repositoriesUrl = data.next+ } else {+ hasNextPage = false+ }+ }++ const apps = repositories.map((repository) => {+ return {+ name: repository.name,+ appId: repository.uuid,+ };+ });+ return apps;+}+ /**+ * Return list of projects for Supabase integration+ * @param {Object} obj+ * @param {String} obj.accessToken - access token for Supabase API+ * @returns {Object[]} apps - names of Supabase apps+ * @returns {String} apps.name - name of Supabase app+ */++ const getAppsCodefresh = async ({+ accessToken,+ }: {+ accessToken: string;+ }) => {+ const res = (+ await standardRequest.get(`${INTEGRATION_CODEFRESH_API_URL}/projects`, {+ headers: {+ Authorization: `Bearer ${accessToken}`,+ "Accept-Encoding": "application/json",+ },+ })+ ).data;++ const apps = res.projects.map((a: any) => ({+ name: a.projectName,+ appId: a.id,+ }));++ return apps;++ };export { getApps };diff --cc backend/src/integrations/exchange.tsindex da42a00fc7,12948d4030..dddbb65c64--- a/backend/src/integrations/exchange.ts+++ b/backend/src/integrations/exchange.ts@@@ -142,11 -129,6 +142,12 @@@ const exchangeCode = async (obj = await exchangeCodeGitlab({code,});+ break;+ case INTEGRATION_BITBUCKET:+ obj = await exchangeCodeBitBucket({+ code,- })++ });++ break;}return obj;diff --cc backend/src/integrations/sync.tsindex a1815fe7e7,129b3a63d2..b58a62636c--- a/backend/src/integrations/sync.ts+++ b/backend/src/integrations/sync.ts@@@ -198,20 -226,20 +228,27 @@@ const syncSecrets = async (break;case INTEGRATION_CLOUDFLARE_PAGES:await syncSecretsCloudflarePages({- integration,- secrets,- accessId,- accessToken+ integration,+ secrets,+ accessId,+ accessToken+ });+ break;+ case INTEGRATION_CODEFRESH:+ await syncSecretsCodefresh({+ integration,+ secrets,+ accessToken,});break;- }+ case INTEGRATION_BITBUCKET:+ await syncSecretsBitBucket({+ integration,+ secrets,+ accessToken,+ });+ break;+ }};/**@@@ -662,22 -690,24 +699,22 @@@ const syncSecretsVercel = async (},}))- .data- .envs- .filter((secret: VercelSecret) => {- if (!secret.target.includes(integration.targetEnvironment)) {- // case: secret does not have the same target environment- return false;- }+ .data+ .envs+ .filter((secret: VercelSecret) => {+ if (!secret.target.includes(integration.targetEnvironment)) {+ // case: secret does not have the same target environment+ return false;+ }- if (integration.targetEnvironment === "preview" && integration.path && integration.path !== secret.gitBranch) {- // case: secret on preview environment does not have same target git branch- return false;- }+ if (integration.targetEnvironment === "preview" && integration.path && integration.path !== secret.gitBranch) {+ // case: secret on preview environment does not have same target git branch+ return false;+ }- return true;- });+ return true;+ });- // return secret.target.includes(integration.targetEnvironment);-const res: { [key: string]: VercelSecret } = {};for await (const vercelSecret of vercelSecrets) {@@@ -1945,119 -1975,36 +1982,151 @@@ const syncSecretsCloudflarePages = asyn}/**+ * Sync/push [secrets] to BitBucket repo with name [integration.app]+ * @param {Object} obj+ * @param {IIntegration} obj.integration - integration details+ * @param {IIntegrationAuth} obj.integrationAuth - integration auth details+ * @param {Object} obj.secrets - secrets to push to integration (object where keys are secret keys and values are secret values)+ * @param {String} obj.accessToken - access token for BitBucket integration+ */+const syncSecretsBitBucket = async ({+ integration,+ secrets,+ accessToken,+}: {+ integration: IIntegration;+ secrets: any;+ accessToken: string;+}) => {-+ interface VariablesResponse {+ size: number;+ page: number;+ pageLen: number;+ next: string;+ previous: string;+ values: Array<BitbucketVariable>;+ }++ interface BitbucketVariable {+ type: string;+ uuid: string;+ key: string;+ value: string;+ secured: boolean;+ }++ const res: { [key: string]: BitbucketVariable } = {};++ let hasNextPage = true;+ let variablesUrl = `${INTEGRATION_BITBUCKET_API_URL}/2.0/repositories/${integration.targetEnvironmentId}/${integration.appId}/pipelines_config/variables`++ while (hasNextPage) {+ const { data }: { data: VariablesResponse } = await standardRequest.get(+ variablesUrl,+ {+ headers: {+ Authorization: `Bearer ${accessToken}`,+ "Accept": "application/json",+ },+ }+ );++ if (data?.values.length > 0) {+ data.values.forEach((variable) => {+ res[variable.key] = variable;+ });+ }++ if (data.next) {+ variablesUrl = data.next+ } else {+ hasNextPage = false+ }+ }++ for await (const key of Object.keys(secrets)) {+ if (key in res) {+ // update existing secret+ await standardRequest.put(+ `${variablesUrl}/${res[key].uuid}`,+ {+ key,+ value: secrets[key],+ secured: true+ },+ {+ headers: {+ Authorization: `Bearer ${accessToken}`,+ "Accept": "application/json",+ },+ }+ );+ } else {+ // create new secret+ await standardRequest.post(+ variablesUrl,+ {+ key,+ value: secrets[key],+ secured: true+ },+ {+ headers: {+ Authorization: `Bearer ${accessToken}`,+ "Accept": "application/json",+ },+ }+ );+ }+ }++ for await (const key of Object.keys(res)) {+ if (!(key in secrets)) {+ // delete secret+ await standardRequest.delete(+ `${variablesUrl}/${res[key].uuid}`,+ {+ headers: {+ Authorization: `Bearer ${accessToken}`,+ "Accept": "application/json",+ }+ }+ );+ }+ }+}+++/*+ * Sync/push [secrets] to Codefresh with name [integration.app]+ * @param {Object} obj+ * @param {IIntegration} obj.integration - integration details+ * @param {Object} obj.secrets - secrets to push to integration (object where keys are secret keys and values are secret values)+ * @param {String} obj.accessToken - access token for Codefresh integration+ */+ const syncSecretsCodefresh = async ({+ integration,+ secrets,+ accessToken,+ }: {+ integration: IIntegration;+ secrets: any;+ accessToken: string;+ }) => {+ await standardRequest.patch(+ `${INTEGRATION_CODEFRESH_API_URL}/projects/${integration.appId}`,+ {+ variables: Object.keys(secrets).map((key) => ({+ key,+ value: secrets[key]+ }))+ },+ {+ headers: {+ Authorization: `Bearer ${accessToken}`,+ "Accept": "application/json",+ },+ }+ );+ };+export { syncSecrets };diff --cc backend/src/models/integration.tsindex 2599e3cbcc,75a5d41932..a7b050a2e7--- a/backend/src/models/integration.ts+++ b/backend/src/models/integration.ts@@@ -56,7 -56,7 +57,8 @@@ export interface IIntegration| "checkly"| "hashicorp-vault"| "cloudflare-pages"- | "bitbucket";- | "codefresh";++ | "bitbucket"++ | "codefresh"integrationAuth: Types.ObjectId;}@@@ -146,7 -146,7 +148,8 @@@ const integrationSchema = new Schema<IIINTEGRATION_CHECKLY,INTEGRATION_HASHICORP_VAULT,INTEGRATION_CLOUDFLARE_PAGES,+ INTEGRATION_BITBUCKET,+ INTEGRATION_CODEFRESH],required: true,},diff --cc backend/src/models/integrationAuth.tsindex 26073c3b03,2330c79383..4908ee2bdd--- a/backend/src/models/integrationAuth.ts+++ b/backend/src/models/integrationAuth.ts@@@ -26,25 -26,7 +27,26 @@@ importexport interface IIntegrationAuth extends Document {_id: Types.ObjectId;workspace: Types.ObjectId;- integration: 'heroku' | 'vercel' | 'netlify' | 'github' | 'gitlab' | 'render' | 'railway' | 'flyio' | 'azure-key-vault' | 'laravel-forge' | 'circleci' | 'travisci' | 'supabase' | 'aws-parameter-store' | 'aws-secret-manager' | 'checkly' | 'cloudflare-pages' | 'codefresh';+ integration:+ | "heroku"+ | "vercel"+ | "netlify"+ | "github"+ | "gitlab"+ | "render"+ | "railway"+ | "flyio"+ | "azure-key-vault"+ | "laravel-forge"+ | "circleci"+ | "travisci"+ | "supabase"+ | "aws-parameter-store"+ | "aws-secret-manager"+ | "checkly"+ | "cloudflare-pages"++ | "codefresh"+ | "bitbucket";teamId: string;accountId: string;url: string;@@@ -90,7 -72,7 +92,8 @@@ const integrationAuthSchema = new SchemINTEGRATION_SUPABASE,INTEGRATION_HASHICORP_VAULT,INTEGRATION_CLOUDFLARE_PAGES,- INTEGRATION_BITBUCKET++ INTEGRATION_BITBUCKET,+ INTEGRATION_CODEFRESH],required: true,},diff --cc backend/src/variables/integration.tsindex 041d1d1095,ba3f0e9058..e99b5a3bf8--- a/backend/src/variables/integration.ts+++ b/backend/src/variables/integration.ts@@@ -27,7 -26,7 +27,8 @@@ export const INTEGRATION_SUPABASE = "suexport const INTEGRATION_CHECKLY = "checkly";export const INTEGRATION_HASHICORP_VAULT = "hashicorp-vault";export const INTEGRATION_CLOUDFLARE_PAGES = "cloudflare-pages";+export const INTEGRATION_BITBUCKET = "bitbucket";+ export const INTEGRATION_CODEFRESH = "codefresh";export const INTEGRATION_SET = new Set([INTEGRATION_AZURE_KEY_VAULT,INTEGRATION_HEROKU,@@@ -44,7 -43,7 +45,8 @@@INTEGRATION_CHECKLY,INTEGRATION_HASHICORP_VAULT,INTEGRATION_CLOUDFLARE_PAGES,- INTEGRATION_BITBUCKET++ INTEGRATION_BITBUCKET,+ INTEGRATION_CODEFRESH]);// integration types@@@ -75,7 -73,7 +77,8 @@@ export const INTEGRATION_SUPABASE_API_Uexport const INTEGRATION_LARAVELFORGE_API_URL = "https://forge.laravel.com";export const INTEGRATION_CHECKLY_API_URL = "https://api.checklyhq.com";export const INTEGRATION_CLOUDFLARE_PAGES_API_URL = "https://api.cloudflare.com";+export const INTEGRATION_BITBUCKET_API_URL = "https://api.bitbucket.org";+ export const INTEGRATION_CODEFRESH_API_URL = "https://g.codefresh.io/api";export const getIntegrationOptions = async () => {const INTEGRATION_OPTIONS = [@@@ -251,15 -249,15 +254,24 @@@clientId: "",docsLink: ""},+ {+ name: "BitBucket",+ slug: "bitbucket",+ image: "BitBucket.png",+ isAvailable: true,+ type: "oauth",+ clientId: await getClientIdBitBucket(),+ docsLink: ""++ },+ {+ name: "Codefresh",+ slug: "codefresh",+ image: "Codefresh.png",+ isAvailable: true,+ type: "pat",+ clientId: "",+ docsLink: "",- },+ }]return INTEGRATION_OPTIONS;diff --cc frontend/public/data/frequentConstants.tsindex 64f824de2a,17c30d38c9..d4c0aa7290--- a/frontend/public/data/frequentConstants.ts+++ b/frontend/public/data/frequentConstants.ts@@@ -3,26 -3,26 +3,27 @@@ interface Mapping}const integrationSlugNameMapping: Mapping = {- 'azure-key-vault': 'Azure Key Vault',- 'aws-parameter-store': 'AWS Parameter Store',- 'aws-secret-manager': 'AWS Secret Manager',- 'heroku': 'Heroku',- 'vercel': 'Vercel',- 'netlify': 'Netlify',- 'github': 'GitHub',- 'gitlab': 'GitLab',- 'render': 'Render',- 'laravel-forge': "Laravel Forge",- 'railway': 'Railway',- 'flyio': 'Fly.io',- 'circleci': 'CircleCI',- 'travisci': 'TravisCI',- 'supabase': 'Supabase',- 'checkly': 'Checkly',- 'hashicorp-vault': 'Vault',- 'cloudflare-pages': 'Cloudflare Pages',- 'codefresh': 'Codefresh'-}+ "azure-key-vault": "Azure Key Vault",+ "aws-parameter-store": "AWS Parameter Store",+ "aws-secret-manager": "AWS Secret Manager",+ heroku: "Heroku",+ vercel: "Vercel",+ netlify: "Netlify",+ github: "GitHub",+ gitlab: "GitLab",+ render: "Render",+ "laravel-forge": "Laravel Forge",+ railway: "Railway",+ flyio: "Fly.io",+ circleci: "CircleCI",+ travisci: "TravisCI",+ supabase: "Supabase",+ checkly: "Checkly",+ "hashicorp-vault": "Vault",+ "cloudflare-pages": "Cloudflare Pages",++ "codefresh": "Codefresh",+ bitbucket: "BitBucket"+};const envMapping: Mapping = {Development: "dev",diff --cc frontend/src/views/IntegrationsPage/IntegrationPage.utils.tsxindex 6759c2207c,e2cfbc5ed0..a5be325021--- a/frontend/src/views/IntegrationsPage/IntegrationPage.utils.tsx+++ b/frontend/src/views/IntegrationsPage/IntegrationPage.utils.tsx@@@ -92,9 -92,10 +92,12 @@@ export const redirectForProviderAuth =case "cloudflare-pages":link = `${window.location.origin}/integrations/cloudflare-pages/authorize`;break;- case "codefresh":+ case "bitbucket":+ link = `https://bitbucket.org/site/oauth2/authorize?client_id=${integrationOption.clientId}&response_type=code&redirect_uri=${window.location.origin}/integrations/bitbucket/oauth2/callback&state=${state}`;+ break;++ case "codefresh":+ link = `${window.location.origin}/integrations/codefresh/authorize`;+ break;-default:break;}