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
feat: added support for app octokit
Sheen Capadnganb8f3814df017
diff --git a/.env.example b/.env.exampleindex 6c76a75fdd..9292780811 100644--- a/.env.example+++ b/.env.example@@ -49,6 +49,9 @@ CLIENT_SECRET_GITLAB=CLIENT_SECRET_BITBUCKET=CLIENT_SLUG_VERCEL=+GITHUB_APP_PRIVATE_KEY=+GITHUB_APP_ID=+# Sentry (optional) for monitoring errorsSENTRY_DSN=diff --git a/backend/package-lock.json b/backend/package-lock.jsonindex 847eb2ba66..62ac1d209a 100644--- a/backend/package-lock.json+++ b/backend/package-lock.json@@ -27,6 +27,7 @@"@fastify/swagger": "^8.14.0","@fastify/swagger-ui": "^2.1.0","@node-saml/passport-saml": "^4.0.4",+ "@octokit/auth-app": "^7.1.1","@octokit/plugin-retry": "^5.0.5","@octokit/rest": "^20.0.2","@octokit/webhooks-types": "^7.3.1",@@ -4976,24 +4977,73 @@}},"node_modules/@octokit/auth-app": {- "version": "6.0.3",- "resolved": "https://registry.npmjs.org/@octokit/auth-app/-/auth-app-6.0.3.tgz",- "integrity": "sha512-9N7IlBAKEJR3tJgPSubCxIDYGXSdc+2xbkjYpk9nCyqREnH8qEMoMhiEB1WgoA9yTFp91El92XNXAi+AjuKnfw==",- "dependencies": {- "@octokit/auth-oauth-app": "^7.0.0",- "@octokit/auth-oauth-user": "^4.0.0",- "@octokit/request": "^8.0.2",- "@octokit/request-error": "^5.0.0",- "@octokit/types": "^12.0.0",- "deprecation": "^2.3.1",+ "version": "7.1.1",+ "resolved": "https://registry.npmjs.org/@octokit/auth-app/-/auth-app-7.1.1.tgz",+ "integrity": "sha512-kRAd6yelV9OgvlEJE88H0VLlQdZcag9UlLr7dV0YYP37X8PPDvhgiTy66QVhDXdyoT0AleFN2w/qXkPdrSzINg==",+ "dependencies": {+ "@octokit/auth-oauth-app": "^8.1.0",+ "@octokit/auth-oauth-user": "^5.1.0",+ "@octokit/request": "^9.1.1",+ "@octokit/request-error": "^6.1.1",+ "@octokit/types": "^13.4.1","lru-cache": "^10.0.0",- "universal-github-app-jwt": "^1.1.2",- "universal-user-agent": "^6.0.0"+ "universal-github-app-jwt": "^2.2.0",+ "universal-user-agent": "^7.0.0"+ },+ "engines": {+ "node": ">= 18"+ }+ },+ "node_modules/@octokit/auth-app/node_modules/@octokit/endpoint": {+ "version": "10.1.1",+ "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-10.1.1.tgz",+ "integrity": "sha512-JYjh5rMOwXMJyUpj028cu0Gbp7qe/ihxfJMLc8VZBMMqSwLgOxDI1911gV4Enl1QSavAQNJcwmwBF9M0VvLh6Q==",+ "dependencies": {+ "@octokit/types": "^13.0.0",+ "universal-user-agent": "^7.0.2"},"engines": {"node": ">= 18"}},+ "node_modules/@octokit/auth-app/node_modules/@octokit/openapi-types": {+ "version": "22.2.0",+ "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-22.2.0.tgz",+ "integrity": "sha512-QBhVjcUa9W7Wwhm6DBFu6ZZ+1/t/oYxqc2tp81Pi41YNuJinbFRx8B133qVOrAaBbF7D/m0Et6f9/pZt9Rc+tg=="+ },+ "node_modules/@octokit/auth-app/node_modules/@octokit/request": {+ "version": "9.1.3",+ "resolved": "https://registry.npmjs.org/@octokit/request/-/request-9.1.3.tgz",+ "integrity": "sha512-V+TFhu5fdF3K58rs1pGUJIDH5RZLbZm5BI+MNF+6o/ssFNT4vWlCh/tVpF3NxGtP15HUxTTMUbsG5llAuU2CZA==",+ "dependencies": {+ "@octokit/endpoint": "^10.0.0",+ "@octokit/request-error": "^6.0.1",+ "@octokit/types": "^13.1.0",+ "universal-user-agent": "^7.0.2"+ },+ "engines": {+ "node": ">= 18"+ }+ },+ "node_modules/@octokit/auth-app/node_modules/@octokit/request-error": {+ "version": "6.1.5",+ "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-6.1.5.tgz",+ "integrity": "sha512-IlBTfGX8Yn/oFPMwSfvugfncK2EwRLjzbrpifNaMY8o/HTEAFqCA1FZxjD9cWvSKBHgrIhc4CSBIzMxiLsbzFQ==",+ "dependencies": {+ "@octokit/types": "^13.0.0"+ },+ "engines": {+ "node": ">= 18"+ }+ },+ "node_modules/@octokit/auth-app/node_modules/@octokit/types": {+ "version": "13.6.1",+ "resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.6.1.tgz",+ "integrity": "sha512-PHZE9Z+kWXb23Ndik8MKPirBPziOc0D2/3KH1P+6jK5nGWe96kadZuE4jev2/Jq7FvIfTlT2Ltg8Fv2x1v0a5g==",+ "dependencies": {+ "@octokit/openapi-types": "^22.2.0"+ }+ },"node_modules/@octokit/auth-app/node_modules/lru-cache": {"version": "10.2.0","resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.0.tgz",@@ -5002,53 +5052,220 @@"node": "14 || >=16.14"}},+ "node_modules/@octokit/auth-app/node_modules/universal-user-agent": {+ "version": "7.0.2",+ "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-7.0.2.tgz",+ "integrity": "sha512-0JCqzSKnStlRRQfCdowvqy3cy0Dvtlb8xecj/H8JFZuCze4rwjPZQOgvFvn0Ws/usCHQFGpyr+pB9adaGwXn4Q=="+ },"node_modules/@octokit/auth-oauth-app": {- "version": "7.0.1",- "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-app/-/auth-oauth-app-7.0.1.tgz",- "integrity": "sha512-RE0KK0DCjCHXHlQBoubwlLijXEKfhMhKm9gO56xYvFmP1QTMb+vvwRPmQLLx0V+5AvV9N9I3lr1WyTzwL3rMDg==",+ "version": "8.1.1",+ "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-app/-/auth-oauth-app-8.1.1.tgz",+ "integrity": "sha512-5UtmxXAvU2wfcHIPPDWzVSAWXVJzG3NWsxb7zCFplCWEmMCArSZV0UQu5jw5goLQXbFyOr5onzEH37UJB3zQQg==","dependencies": {- "@octokit/auth-oauth-device": "^6.0.0",- "@octokit/auth-oauth-user": "^4.0.0",- "@octokit/request": "^8.0.2",- "@octokit/types": "^12.0.0",- "@types/btoa-lite": "^1.0.0",- "btoa-lite": "^1.0.0",- "universal-user-agent": "^6.0.0"+ "@octokit/auth-oauth-device": "^7.0.0",+ "@octokit/auth-oauth-user": "^5.0.1",+ "@octokit/request": "^9.0.0",+ "@octokit/types": "^13.0.0",+ "universal-user-agent": "^7.0.0"+ },+ "engines": {+ "node": ">= 18"+ }+ },+ "node_modules/@octokit/auth-oauth-app/node_modules/@octokit/endpoint": {+ "version": "10.1.1",+ "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-10.1.1.tgz",+ "integrity": "sha512-JYjh5rMOwXMJyUpj028cu0Gbp7qe/ihxfJMLc8VZBMMqSwLgOxDI1911gV4Enl1QSavAQNJcwmwBF9M0VvLh6Q==",+ "dependencies": {+ "@octokit/types": "^13.0.0",+ "universal-user-agent": "^7.0.2"+ },+ "engines": {+ "node": ">= 18"+ }+ },+ "node_modules/@octokit/auth-oauth-app/node_modules/@octokit/openapi-types": {+ "version": "22.2.0",+ "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-22.2.0.tgz",+ "integrity": "sha512-QBhVjcUa9W7Wwhm6DBFu6ZZ+1/t/oYxqc2tp81Pi41YNuJinbFRx8B133qVOrAaBbF7D/m0Et6f9/pZt9Rc+tg=="+ },+ "node_modules/@octokit/auth-oauth-app/node_modules/@octokit/request": {+ "version": "9.1.3",+ "resolved": "https://registry.npmjs.org/@octokit/request/-/request-9.1.3.tgz",+ "integrity": "sha512-V+TFhu5fdF3K58rs1pGUJIDH5RZLbZm5BI+MNF+6o/ssFNT4vWlCh/tVpF3NxGtP15HUxTTMUbsG5llAuU2CZA==",+ "dependencies": {+ "@octokit/endpoint": "^10.0.0",+ "@octokit/request-error": "^6.0.1",+ "@octokit/types": "^13.1.0",+ "universal-user-agent": "^7.0.2"+ },+ "engines": {+ "node": ">= 18"+ }+ },+ "node_modules/@octokit/auth-oauth-app/node_modules/@octokit/request-error": {+ "version": "6.1.5",+ "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-6.1.5.tgz",+ "integrity": "sha512-IlBTfGX8Yn/oFPMwSfvugfncK2EwRLjzbrpifNaMY8o/HTEAFqCA1FZxjD9cWvSKBHgrIhc4CSBIzMxiLsbzFQ==",+ "dependencies": {+ "@octokit/types": "^13.0.0"},"engines": {"node": ">= 18"}},+ "node_modules/@octokit/auth-oauth-app/node_modules/@octokit/types": {+ "version": "13.6.1",+ "resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.6.1.tgz",+ "integrity": "sha512-PHZE9Z+kWXb23Ndik8MKPirBPziOc0D2/3KH1P+6jK5nGWe96kadZuE4jev2/Jq7FvIfTlT2Ltg8Fv2x1v0a5g==",+ "dependencies": {+ "@octokit/openapi-types": "^22.2.0"+ }+ },+ "node_modules/@octokit/auth-oauth-app/node_modules/universal-user-agent": {+ "version": "7.0.2",+ "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-7.0.2.tgz",+ "integrity": "sha512-0JCqzSKnStlRRQfCdowvqy3cy0Dvtlb8xecj/H8JFZuCze4rwjPZQOgvFvn0Ws/usCHQFGpyr+pB9adaGwXn4Q=="+ },"node_modules/@octokit/auth-oauth-device": {- "version": "6.0.1",- "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-device/-/auth-oauth-device-6.0.1.tgz",- "integrity": "sha512-yxU0rkL65QkjbqQedgVx3gmW7YM5fF+r5uaSj9tM/cQGVqloXcqP2xK90eTyYvl29arFVCW8Vz4H/t47mL0ELw==",+ "version": "7.1.1",+ "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-device/-/auth-oauth-device-7.1.1.tgz",+ "integrity": "sha512-HWl8lYueHonuyjrKKIup/1tiy0xcmQCdq5ikvMO1YwkNNkxb6DXfrPjrMYItNLyCP/o2H87WuijuE+SlBTT8eg==","dependencies": {- "@octokit/oauth-methods": "^4.0.0",- "@octokit/request": "^8.0.0",- "@octokit/types": "^12.0.0",- "universal-user-agent": "^6.0.0"+ "@octokit/oauth-methods": "^5.0.0",+ "@octokit/request": "^9.0.0",+ "@octokit/types": "^13.0.0",+ "universal-user-agent": "^7.0.0"+ },+ "engines": {+ "node": ">= 18"+ }+ },+ "node_modules/@octokit/auth-oauth-device/node_modules/@octokit/endpoint": {+ "version": "10.1.1",+ "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-10.1.1.tgz",+ "integrity": "sha512-JYjh5rMOwXMJyUpj028cu0Gbp7qe/ihxfJMLc8VZBMMqSwLgOxDI1911gV4Enl1QSavAQNJcwmwBF9M0VvLh6Q==",+ "dependencies": {+ "@octokit/types": "^13.0.0",+ "universal-user-agent": "^7.0.2"+ },+ "engines": {+ "node": ">= 18"+ }+ },+ "node_modules/@octokit/auth-oauth-device/node_modules/@octokit/openapi-types": {+ "version": "22.2.0",+ "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-22.2.0.tgz",+ "integrity": "sha512-QBhVjcUa9W7Wwhm6DBFu6ZZ+1/t/oYxqc2tp81Pi41YNuJinbFRx8B133qVOrAaBbF7D/m0Et6f9/pZt9Rc+tg=="+ },+ "node_modules/@octokit/auth-oauth-device/node_modules/@octokit/request": {+ "version": "9.1.3",+ "resolved": "https://registry.npmjs.org/@octokit/request/-/request-9.1.3.tgz",+ "integrity": "sha512-V+TFhu5fdF3K58rs1pGUJIDH5RZLbZm5BI+MNF+6o/ssFNT4vWlCh/tVpF3NxGtP15HUxTTMUbsG5llAuU2CZA==",+ "dependencies": {+ "@octokit/endpoint": "^10.0.0",+ "@octokit/request-error": "^6.0.1",+ "@octokit/types": "^13.1.0",+ "universal-user-agent": "^7.0.2"+ },+ "engines": {+ "node": ">= 18"+ }+ },+ "node_modules/@octokit/auth-oauth-device/node_modules/@octokit/request-error": {+ "version": "6.1.5",+ "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-6.1.5.tgz",+ "integrity": "sha512-IlBTfGX8Yn/oFPMwSfvugfncK2EwRLjzbrpifNaMY8o/HTEAFqCA1FZxjD9cWvSKBHgrIhc4CSBIzMxiLsbzFQ==",+ "dependencies": {+ "@octokit/types": "^13.0.0"},"engines": {"node": ">= 18"}},+ "node_modules/@octokit/auth-oauth-device/node_modules/@octokit/types": {+ "version": "13.6.1",+ "resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.6.1.tgz",+ "integrity": "sha512-PHZE9Z+kWXb23Ndik8MKPirBPziOc0D2/3KH1P+6jK5nGWe96kadZuE4jev2/Jq7FvIfTlT2Ltg8Fv2x1v0a5g==",+ "dependencies": {+ "@octokit/openapi-types": "^22.2.0"+ }+ },+ "node_modules/@octokit/auth-oauth-device/node_modules/universal-user-agent": {+ "version": "7.0.2",+ "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-7.0.2.tgz",+ "integrity": "sha512-0JCqzSKnStlRRQfCdowvqy3cy0Dvtlb8xecj/H8JFZuCze4rwjPZQOgvFvn0Ws/usCHQFGpyr+pB9adaGwXn4Q=="+ },"node_modules/@octokit/auth-oauth-user": {- "version": "4.0.1",- "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-user/-/auth-oauth-user-4.0.1.tgz",- "integrity": "sha512-N94wWW09d0hleCnrO5wt5MxekatqEJ4zf+1vSe8MKMrhZ7gAXKFOKrDEZW2INltvBWJCyDUELgGRv8gfErH1Iw==",+ "version": "5.1.1",+ "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-user/-/auth-oauth-user-5.1.1.tgz",+ "integrity": "sha512-rRkMz0ErOppdvEfnemHJXgZ9vTPhBuC6yASeFaB7I2yLMd7QpjfrL1mnvRPlyKo+M6eeLxrKanXJ9Qte29SRsw==","dependencies": {- "@octokit/auth-oauth-device": "^6.0.0",- "@octokit/oauth-methods": "^4.0.0",- "@octokit/request": "^8.0.2",- "@octokit/types": "^12.0.0",- "btoa-lite": "^1.0.0",- "universal-user-agent": "^6.0.0"+ "@octokit/auth-oauth-device": "^7.0.1",+ "@octokit/oauth-methods": "^5.0.0",+ "@octokit/request": "^9.0.1",+ "@octokit/types": "^13.0.0",+ "universal-user-agent": "^7.0.0"+ },+ "engines": {+ "node": ">= 18"+ }+ },+ "node_modules/@octokit/auth-oauth-user/node_modules/@octokit/endpoint": {+ "version": "10.1.1",+ "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-10.1.1.tgz",+ "integrity": "sha512-JYjh5rMOwXMJyUpj028cu0Gbp7qe/ihxfJMLc8VZBMMqSwLgOxDI1911gV4Enl1QSavAQNJcwmwBF9M0VvLh6Q==",+ "dependencies": {+ "@octokit/types": "^13.0.0",+ "universal-user-agent": "^7.0.2"+ },+ "engines": {+ "node": ">= 18"+ }+ },+ "node_modules/@octokit/auth-oauth-user/node_modules/@octokit/openapi-types": {+ "version": "22.2.0",+ "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-22.2.0.tgz",+ "integrity": "sha512-QBhVjcUa9W7Wwhm6DBFu6ZZ+1/t/oYxqc2tp81Pi41YNuJinbFRx8B133qVOrAaBbF7D/m0Et6f9/pZt9Rc+tg=="+ },+ "node_modules/@octokit/auth-oauth-user/node_modules/@octokit/request": {+ "version": "9.1.3",+ "resolved": "https://registry.npmjs.org/@octokit/request/-/request-9.1.3.tgz",+ "integrity": "sha512-V+TFhu5fdF3K58rs1pGUJIDH5RZLbZm5BI+MNF+6o/ssFNT4vWlCh/tVpF3NxGtP15HUxTTMUbsG5llAuU2CZA==",+ "dependencies": {+ "@octokit/endpoint": "^10.0.0",+ "@octokit/request-error": "^6.0.1",+ "@octokit/types": "^13.1.0",+ "universal-user-agent": "^7.0.2"+ },+ "engines": {+ "node": ">= 18"+ }+ },+ "node_modules/@octokit/auth-oauth-user/node_modules/@octokit/request-error": {+ "version": "6.1.5",+ "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-6.1.5.tgz",+ "integrity": "sha512-IlBTfGX8Yn/oFPMwSfvugfncK2EwRLjzbrpifNaMY8o/HTEAFqCA1FZxjD9cWvSKBHgrIhc4CSBIzMxiLsbzFQ==",+ "dependencies": {+ "@octokit/types": "^13.0.0"},"engines": {"node": ">= 18"}},+ "node_modules/@octokit/auth-oauth-user/node_modules/@octokit/types": {+ "version": "13.6.1",+ "resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.6.1.tgz",+ "integrity": "sha512-PHZE9Z+kWXb23Ndik8MKPirBPziOc0D2/3KH1P+6jK5nGWe96kadZuE4jev2/Jq7FvIfTlT2Ltg8Fv2x1v0a5g==",+ "dependencies": {+ "@octokit/openapi-types": "^22.2.0"+ }+ },+ "node_modules/@octokit/auth-oauth-user/node_modules/universal-user-agent": {+ "version": "7.0.2",+ "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-7.0.2.tgz",+ "integrity": "sha512-0JCqzSKnStlRRQfCdowvqy3cy0Dvtlb8xecj/H8JFZuCze4rwjPZQOgvFvn0Ws/usCHQFGpyr+pB9adaGwXn4Q=="+ },"node_modules/@octokit/auth-token": {"version": "4.0.0","resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-4.0.0.tgz",@@ -5112,28 +5329,82 @@}},"node_modules/@octokit/oauth-authorization-url": {- "version": "6.0.2",- "resolved": "https://registry.npmjs.org/@octokit/oauth-authorization-url/-/oauth-authorization-url-6.0.2.tgz",- "integrity": "sha512-CdoJukjXXxqLNK4y/VOiVzQVjibqoj/xHgInekviUJV73y/BSIcwvJ/4aNHPBPKcPWFnd4/lO9uqRV65jXhcLA==",+ "version": "7.1.1",+ "resolved": "https://registry.npmjs.org/@octokit/oauth-authorization-url/-/oauth-authorization-url-7.1.1.tgz",+ "integrity": "sha512-ooXV8GBSabSWyhLUowlMIVd9l1s2nsOGQdlP2SQ4LnkEsGXzeCvbSbCPdZThXhEFzleGPwbapT0Sb+YhXRyjCA==","engines": {"node": ">= 18"}},"node_modules/@octokit/oauth-methods": {- "version": "4.0.1",- "resolved": "https://registry.npmjs.org/@octokit/oauth-methods/-/oauth-methods-4.0.1.tgz",- "integrity": "sha512-1NdTGCoBHyD6J0n2WGXg9+yDLZrRNZ0moTEex/LSPr49m530WNKcCfXDghofYptr3st3eTii+EHoG5k/o+vbtw==",+ "version": "5.1.2",+ "resolved": "https://registry.npmjs.org/@octokit/oauth-methods/-/oauth-methods-5.1.2.tgz",+ "integrity": "sha512-C5lglRD+sBlbrhCUTxgJAFjWgJlmTx5bQ7Ch0+2uqRjYv7Cfb5xpX4WuSC9UgQna3sqRGBL9EImX9PvTpMaQ7g==","dependencies": {- "@octokit/oauth-authorization-url": "^6.0.2",- "@octokit/request": "^8.0.2",- "@octokit/request-error": "^5.0.0",- "@octokit/types": "^12.0.0",- "btoa-lite": "^1.0.0"+ "@octokit/oauth-authorization-url": "^7.0.0",+ "@octokit/request": "^9.1.0",+ "@octokit/request-error": "^6.1.0",+ "@octokit/types": "^13.0.0"+ },+ "engines": {+ "node": ">= 18"+ }+ },+ "node_modules/@octokit/oauth-methods/node_modules/@octokit/endpoint": {+ "version": "10.1.1",+ "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-10.1.1.tgz",+ "integrity": "sha512-JYjh5rMOwXMJyUpj028cu0Gbp7qe/ihxfJMLc8VZBMMqSwLgOxDI1911gV4Enl1QSavAQNJcwmwBF9M0VvLh6Q==",+ "dependencies": {+ "@octokit/types": "^13.0.0",+ "universal-user-agent": "^7.0.2"+ },+ "engines": {+ "node": ">= 18"+ }+ },+ "node_modules/@octokit/oauth-methods/node_modules/@octokit/openapi-types": {+ "version": "22.2.0",+ "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-22.2.0.tgz",+ "integrity": "sha512-QBhVjcUa9W7Wwhm6DBFu6ZZ+1/t/oYxqc2tp81Pi41YNuJinbFRx8B133qVOrAaBbF7D/m0Et6f9/pZt9Rc+tg=="+ },+ "node_modules/@octokit/oauth-methods/node_modules/@octokit/request": {+ "version": "9.1.3",+ "resolved": "https://registry.npmjs.org/@octokit/request/-/request-9.1.3.tgz",+ "integrity": "sha512-V+TFhu5fdF3K58rs1pGUJIDH5RZLbZm5BI+MNF+6o/ssFNT4vWlCh/tVpF3NxGtP15HUxTTMUbsG5llAuU2CZA==",+ "dependencies": {+ "@octokit/endpoint": "^10.0.0",+ "@octokit/request-error": "^6.0.1",+ "@octokit/types": "^13.1.0",+ "universal-user-agent": "^7.0.2"+ },+ "engines": {+ "node": ">= 18"+ }+ },+ "node_modules/@octokit/oauth-methods/node_modules/@octokit/request-error": {+ "version": "6.1.5",+ "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-6.1.5.tgz",+ "integrity": "sha512-IlBTfGX8Yn/oFPMwSfvugfncK2EwRLjzbrpifNaMY8o/HTEAFqCA1FZxjD9cWvSKBHgrIhc4CSBIzMxiLsbzFQ==",+ "dependencies": {+ "@octokit/types": "^13.0.0"},"engines": {"node": ">= 18"}},+ "node_modules/@octokit/oauth-methods/node_modules/@octokit/types": {+ "version": "13.6.1",+ "resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.6.1.tgz",+ "integrity": "sha512-PHZE9Z+kWXb23Ndik8MKPirBPziOc0D2/3KH1P+6jK5nGWe96kadZuE4jev2/Jq7FvIfTlT2Ltg8Fv2x1v0a5g==",+ "dependencies": {+ "@octokit/openapi-types": "^22.2.0"+ }+ },+ "node_modules/@octokit/oauth-methods/node_modules/universal-user-agent": {+ "version": "7.0.2",+ "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-7.0.2.tgz",+ "integrity": "sha512-0JCqzSKnStlRRQfCdowvqy3cy0Dvtlb8xecj/H8JFZuCze4rwjPZQOgvFvn0Ws/usCHQFGpyr+pB9adaGwXn4Q=="+ },"node_modules/@octokit/openapi-types": {"version": "19.1.0","resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-19.1.0.tgz",@@ -5248,13 +5519,13 @@}},"node_modules/@octokit/request": {- "version": "8.1.6",- "resolved": "https://registry.npmjs.org/@octokit/request/-/request-8.1.6.tgz",- "integrity": "sha512-YhPaGml3ncZC1NfXpP3WZ7iliL1ap6tLkAp6MvbK2fTTPytzVUyUesBBogcdMm86uRYO5rHaM1xIWxigWZ17MQ==",+ "version": "8.4.0",+ "resolved": "https://registry.npmjs.org/@octokit/request/-/request-8.4.0.tgz",+ "integrity": "sha512-9Bb014e+m2TgBeEJGEbdplMVWwPmL1FPtggHQRkV+WVsMggPtEkLKPlcVYm/o8xKLkpJ7B+6N8WfQMtDLX2Dpw==","dependencies": {- "@octokit/endpoint": "^9.0.0",- "@octokit/request-error": "^5.0.0",- "@octokit/types": "^12.0.0",+ "@octokit/endpoint": "^9.0.1",+ "@octokit/request-error": "^5.1.0",+ "@octokit/types": "^13.1.0","universal-user-agent": "^6.0.0"},"engines": {@@ -5262,11 +5533,11 @@}},"node_modules/@octokit/request-error": {- "version": "5.0.1",- "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-5.0.1.tgz",- "integrity": "sha512-X7pnyTMV7MgtGmiXBwmO6M5kIPrntOXdyKZLigNfQWSEQzVxR4a4vo49vJjTWX70mPndj8KhfT4Dx+2Ng3vnBQ==",+ "version": "5.1.0",+ "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-5.1.0.tgz",+ "integrity": "sha512-GETXfE05J0+7H2STzekpKObFe765O5dlAKUTLNGeH+x47z7JjXHfsHKo5z21D/o/IOZTUEI6nyWyR+bZVP/n5Q==","dependencies": {- "@octokit/types": "^12.0.0",+ "@octokit/types": "^13.1.0","deprecation": "^2.0.0","once": "^1.4.0"},@@ -5274,6 +5545,32 @@"node": ">= 18"}},+ "node_modules/@octokit/request-error/node_modules/@octokit/openapi-types": {+ "version": "22.2.0",+ "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-22.2.0.tgz",+ "integrity": "sha512-QBhVjcUa9W7Wwhm6DBFu6ZZ+1/t/oYxqc2tp81Pi41YNuJinbFRx8B133qVOrAaBbF7D/m0Et6f9/pZt9Rc+tg=="+ },+ "node_modules/@octokit/request-error/node_modules/@octokit/types": {+ "version": "13.6.1",+ "resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.6.1.tgz",+ "integrity": "sha512-PHZE9Z+kWXb23Ndik8MKPirBPziOc0D2/3KH1P+6jK5nGWe96kadZuE4jev2/Jq7FvIfTlT2Ltg8Fv2x1v0a5g==",+ "dependencies": {+ "@octokit/openapi-types": "^22.2.0"+ }+ },+ "node_modules/@octokit/request/node_modules/@octokit/openapi-types": {+ "version": "22.2.0",+ "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-22.2.0.tgz",+ "integrity": "sha512-QBhVjcUa9W7Wwhm6DBFu6ZZ+1/t/oYxqc2tp81Pi41YNuJinbFRx8B133qVOrAaBbF7D/m0Et6f9/pZt9Rc+tg=="+ },+ "node_modules/@octokit/request/node_modules/@octokit/types": {+ "version": "13.6.1",+ "resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.6.1.tgz",+ "integrity": "sha512-PHZE9Z+kWXb23Ndik8MKPirBPziOc0D2/3KH1P+6jK5nGWe96kadZuE4jev2/Jq7FvIfTlT2Ltg8Fv2x1v0a5g==",+ "dependencies": {+ "@octokit/openapi-types": "^22.2.0"+ }+ },"node_modules/@octokit/rest": {"version": "20.0.2","resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-20.0.2.tgz",@@ -14160,6 +14457,154 @@"@octokit/core": ">=5"}},+ "node_modules/octokit-auth-probot/node_modules/@octokit/auth-app": {+ "version": "6.1.2",+ "resolved": "https://registry.npmjs.org/@octokit/auth-app/-/auth-app-6.1.2.tgz",+ "integrity": "sha512-fWjIOpxnL8/YFY3kqquciFQ4o99aCqHw5kMFoGPYbz/h5HNZ11dJlV9zag5wS2nt0X1wJ5cs9BUo+CsAPfW4jQ==",+ "dependencies": {+ "@octokit/auth-oauth-app": "^7.1.0",+ "@octokit/auth-oauth-user": "^4.1.0",+ "@octokit/request": "^8.3.1",+ "@octokit/request-error": "^5.1.0",+ "@octokit/types": "^13.1.0",+ "deprecation": "^2.3.1",+ "lru-cache": "^10.0.0",+ "universal-github-app-jwt": "^1.1.2",+ "universal-user-agent": "^6.0.0"+ },+ "engines": {+ "node": ">= 18"+ }+ },+ "node_modules/octokit-auth-probot/node_modules/@octokit/auth-app/node_modules/@octokit/types": {+ "version": "13.6.1",+ "resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.6.1.tgz",+ "integrity": "sha512-PHZE9Z+kWXb23Ndik8MKPirBPziOc0D2/3KH1P+6jK5nGWe96kadZuE4jev2/Jq7FvIfTlT2Ltg8Fv2x1v0a5g==",+ "dependencies": {+ "@octokit/openapi-types": "^22.2.0"+ }+ },+ "node_modules/octokit-auth-probot/node_modules/@octokit/auth-oauth-app": {+ "version": "7.1.0",+ "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-app/-/auth-oauth-app-7.1.0.tgz",+ "integrity": "sha512-w+SyJN/b0l/HEb4EOPRudo7uUOSW51jcK1jwLa+4r7PA8FPFpoxEnHBHMITqCsc/3Vo2qqFjgQfz/xUUvsSQnA==",+ "dependencies": {+ "@octokit/auth-oauth-device": "^6.1.0",+ "@octokit/auth-oauth-user": "^4.1.0",+ "@octokit/request": "^8.3.1",+ "@octokit/types": "^13.0.0",+ "@types/btoa-lite": "^1.0.0",+ "btoa-lite": "^1.0.0",+ "universal-user-agent": "^6.0.0"+ },+ "engines": {+ "node": ">= 18"+ }+ },+ "node_modules/octokit-auth-probot/node_modules/@octokit/auth-oauth-app/node_modules/@octokit/types": {+ "version": "13.6.1",+ "resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.6.1.tgz",+ "integrity": "sha512-PHZE9Z+kWXb23Ndik8MKPirBPziOc0D2/3KH1P+6jK5nGWe96kadZuE4jev2/Jq7FvIfTlT2Ltg8Fv2x1v0a5g==",+ "dependencies": {+ "@octokit/openapi-types": "^22.2.0"+ }+ },+ "node_modules/octokit-auth-probot/node_modules/@octokit/auth-oauth-device": {+ "version": "6.1.0",+ "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-device/-/auth-oauth-device-6.1.0.tgz",+ "integrity": "sha512-FNQ7cb8kASufd6Ej4gnJ3f1QB5vJitkoV1O0/g6e6lUsQ7+VsSNRHRmFScN2tV4IgKA12frrr/cegUs0t+0/Lw==",+ "dependencies": {+ "@octokit/oauth-methods": "^4.1.0",+ "@octokit/request": "^8.3.1",+ "@octokit/types": "^13.0.0",+ "universal-user-agent": "^6.0.0"+ },+ "engines": {+ "node": ">= 18"+ }+ },+ "node_modules/octokit-auth-probot/node_modules/@octokit/auth-oauth-device/node_modules/@octokit/types": {+ "version": "13.6.1",+ "resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.6.1.tgz",+ "integrity": "sha512-PHZE9Z+kWXb23Ndik8MKPirBPziOc0D2/3KH1P+6jK5nGWe96kadZuE4jev2/Jq7FvIfTlT2Ltg8Fv2x1v0a5g==",+ "dependencies": {+ "@octokit/openapi-types": "^22.2.0"+ }+ },+ "node_modules/octokit-auth-probot/node_modules/@octokit/auth-oauth-user": {+ "version": "4.1.0",+ "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-user/-/auth-oauth-user-4.1.0.tgz",+ "integrity": "sha512-FrEp8mtFuS/BrJyjpur+4GARteUCrPeR/tZJzD8YourzoVhRics7u7we/aDcKv+yywRNwNi/P4fRi631rG/OyQ==",+ "dependencies": {+ "@octokit/auth-oauth-device": "^6.1.0",+ "@octokit/oauth-methods": "^4.1.0",+ "@octokit/request": "^8.3.1",+ "@octokit/types": "^13.0.0",+ "btoa-lite": "^1.0.0",+ "universal-user-agent": "^6.0.0"+ },+ "engines": {+ "node": ">= 18"+ }+ },+ "node_modules/octokit-auth-probot/node_modules/@octokit/auth-oauth-user/node_modules/@octokit/types": {+ "version": "13.6.1",+ "resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.6.1.tgz",+ "integrity": "sha512-PHZE9Z+kWXb23Ndik8MKPirBPziOc0D2/3KH1P+6jK5nGWe96kadZuE4jev2/Jq7FvIfTlT2Ltg8Fv2x1v0a5g==",+ "dependencies": {+ "@octokit/openapi-types": "^22.2.0"+ }+ },+ "node_modules/octokit-auth-probot/node_modules/@octokit/oauth-authorization-url": {+ "version": "6.0.2",+ "resolved": "https://registry.npmjs.org/@octokit/oauth-authorization-url/-/oauth-authorization-url-6.0.2.tgz",+ "integrity": "sha512-CdoJukjXXxqLNK4y/VOiVzQVjibqoj/xHgInekviUJV73y/BSIcwvJ/4aNHPBPKcPWFnd4/lO9uqRV65jXhcLA==",+ "engines": {+ "node": ">= 18"+ }+ },+ "node_modules/octokit-auth-probot/node_modules/@octokit/oauth-methods": {+ "version": "4.1.0",+ "resolved": "https://registry.npmjs.org/@octokit/oauth-methods/-/oauth-methods-4.1.0.tgz",+ "integrity": "sha512-4tuKnCRecJ6CG6gr0XcEXdZtkTDbfbnD5oaHBmLERTjTMZNi2CbfEHZxPU41xXLDG4DfKf+sonu00zvKI9NSbw==",+ "dependencies": {+ "@octokit/oauth-authorization-url": "^6.0.2",+ "@octokit/request": "^8.3.1",+ "@octokit/request-error": "^5.1.0",+ "@octokit/types": "^13.0.0",+ "btoa-lite": "^1.0.0"+ },+ "engines": {+ "node": ">= 18"+ }+ },+ "node_modules/octokit-auth-probot/node_modules/@octokit/oauth-methods/node_modules/@octokit/types": {+ "version": "13.6.1",+ "resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.6.1.tgz",+ "integrity": "sha512-PHZE9Z+kWXb23Ndik8MKPirBPziOc0D2/3KH1P+6jK5nGWe96kadZuE4jev2/Jq7FvIfTlT2Ltg8Fv2x1v0a5g==",+ "dependencies": {+ "@octokit/openapi-types": "^22.2.0"+ }+ },+ "node_modules/octokit-auth-probot/node_modules/@octokit/openapi-types": {+ "version": "22.2.0",+ "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-22.2.0.tgz",+ "integrity": "sha512-QBhVjcUa9W7Wwhm6DBFu6ZZ+1/t/oYxqc2tp81Pi41YNuJinbFRx8B133qVOrAaBbF7D/m0Et6f9/pZt9Rc+tg=="+ },+ "node_modules/octokit-auth-probot/node_modules/lru-cache": {+ "version": "10.4.3",+ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz",+ "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ=="+ },+ "node_modules/octokit-auth-probot/node_modules/universal-github-app-jwt": {+ "version": "1.2.0",+ "resolved": "https://registry.npmjs.org/universal-github-app-jwt/-/universal-github-app-jwt-1.2.0.tgz",+ "integrity": "sha512-dncpMpnsKBk0eetwfN8D8OUHGfiDhhJ+mtsbMl+7PfW7mYjiH8LIcqRmYMtzYLgSh47HjfdBtrBwIQ/gizKR3g==",+ "dependencies": {+ "@types/jsonwebtoken": "^9.0.0",+ "jsonwebtoken": "^9.0.2"+ }+ },"node_modules/oidc-token-hash": {"version": "5.0.3","resolved": "https://registry.npmjs.org/oidc-token-hash/-/oidc-token-hash-5.0.3.tgz",@@ -18143,13 +18588,9 @@}},"node_modules/universal-github-app-jwt": {- "version": "1.1.2",- "resolved": "https://registry.npmjs.org/universal-github-app-jwt/-/universal-github-app-jwt-1.1.2.tgz",- "integrity": "sha512-t1iB2FmLFE+yyJY9+3wMx0ejB+MQpEVkH0gQv7dR6FZyltyq+ZZO0uDpbopxhrZ3SLEO4dCEkIujOMldEQ2iOA==",- "dependencies": {- "@types/jsonwebtoken": "^9.0.0",- "jsonwebtoken": "^9.0.2"- }+ "version": "2.2.0",+ "resolved": "https://registry.npmjs.org/universal-github-app-jwt/-/universal-github-app-jwt-2.2.0.tgz",+ "integrity": "sha512-G5o6f95b5BggDGuUfKDApKaCgNYy2x7OdHY0zSMF081O0EJobw+1130VONhrA7ezGSV2FNOGyM+KQpQZAr9bIQ=="},"node_modules/universal-user-agent": {"version": "6.0.1",diff --git a/backend/package.json b/backend/package.jsonindex 332c5a9610..7b02a7b4d2 100644--- a/backend/package.json+++ b/backend/package.json@@ -131,6 +131,7 @@"@fastify/swagger": "^8.14.0","@fastify/swagger-ui": "^2.1.0","@node-saml/passport-saml": "^4.0.4",+ "@octokit/auth-app": "^7.1.1","@octokit/plugin-retry": "^5.0.5","@octokit/rest": "^20.0.2","@octokit/webhooks-types": "^7.3.1",diff --git a/backend/src/lib/config/env.ts b/backend/src/lib/config/env.tsindex a11762564d..7c10c433cc 100644--- a/backend/src/lib/config/env.ts+++ b/backend/src/lib/config/env.ts@@ -124,6 +124,8 @@ const envSchema = z// github appCLIENT_ID_GITHUB_APP: zpStr(z.string().optional()),CLIENT_SECRET_GITHUB_APP: zpStr(z.string().optional()),+ GITHUB_APP_PRIVATE_KEY: zpStr(z.string().optional()),+ GITHUB_APP_ID: z.coerce.number().optional(),// azureCLIENT_ID_AZURE: zpStr(z.string().optional()),diff --git a/backend/src/services/integration-auth/integration-app-list.ts b/backend/src/services/integration-auth/integration-app-list.tsindex e61aa4a543..85fff9857c 100644--- a/backend/src/services/integration-auth/integration-app-list.ts+++ b/backend/src/services/integration-auth/integration-app-list.ts@@ -1,9 +1,12 @@/* eslint-disable no-await-in-loop */+import { createAppAuth } from "@octokit/auth-app";import { Octokit } from "@octokit/rest";+import { getConfig } from "@app/lib/config/env";import { request } from "@app/lib/config/request";import { NotFoundError } from "@app/lib/errors";+import { TIntegrationAuthMetadata } from "./integration-auth-schema";import { Integrations, IntegrationUrls } from "./integration-list";// akhilmhdh: check this part later. Copied from old base@@ -230,7 +233,13 @@ const getAppsNetlify = async ({ accessToken }: { accessToken: string }) => {/*** Return list of repositories for Github integration*/-const getAppsGithub = async ({ accessToken }: { accessToken: string }) => {+const getAppsGithub = async ({+ accessToken,+ authMetadata+}: {+ accessToken: string;+ authMetadata?: TIntegrationAuthMetadata;+}) => {interface GitHubApp {id: string;name: string;@@ -242,6 +251,29 @@ const getAppsGithub = async ({ accessToken }: { accessToken: string }) => {};}+ if (authMetadata?.installationId) {+ const appCfg = getConfig();+ const octokit = new Octokit({+ authStrategy: createAppAuth,+ auth: {+ appId: appCfg.GITHUB_APP_ID,+ privateKey: appCfg.GITHUB_APP_PRIVATE_KEY,+ installationId: authMetadata.installationId+ }+ });++ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion+ const repos = await octokit.paginate("GET /installation/repositories", {+ per_page: 100+ });++ return repos.map((a) => ({+ appId: String(a.id),+ name: a.name,+ owner: a.owner.login+ }));+ }+// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertionconst repos = (await new Octokit({auth: accessToken@@ -1061,11 +1093,13 @@ export const getApps = async ({teamId,azureDevOpsOrgName,workspaceSlug,+ authMetadata,url}: {integration: string;accessToken: string;accessId?: string;+ authMetadata: TIntegrationAuthMetadata;teamId?: string | null;azureDevOpsOrgName?: string | null;workspaceSlug?: string;@@ -1099,7 +1133,8 @@ export const getApps = async ({case Integrations.GITHUB:return getAppsGithub({- accessToken+ accessToken,+ authMetadata});case Integrations.GITLAB:diff --git a/backend/src/services/integration-auth/integration-auth-schema.ts b/backend/src/services/integration-auth/integration-auth-schema.tsnew file mode 100644index 0000000000..94a68cc72c--- /dev/null+++ b/backend/src/services/integration-auth/integration-auth-schema.ts@@ -0,0 +1,7 @@+import { z } from "zod";++export const IntegrationAuthMetadataSchema = z.object({+ installationId: z.string().optional()+});++export type TIntegrationAuthMetadata = z.infer<typeof IntegrationAuthMetadataSchema>;diff --git a/backend/src/services/integration-auth/integration-auth-service.ts b/backend/src/services/integration-auth/integration-auth-service.tsindex 83e880b3ec..08b5e64fc2 100644--- a/backend/src/services/integration-auth/integration-auth-service.ts+++ b/backend/src/services/integration-auth/integration-auth-service.ts@@ -1,10 +1,12 @@import { ForbiddenError } from "@casl/ability";+import { createAppAuth } from "@octokit/auth-app";import { Octokit } from "@octokit/rest";import AWS from "aws-sdk";import { SecretEncryptionAlgo, SecretKeyEncoding, TIntegrationAuths, TIntegrationAuthsInsert } from "@app/db/schemas";import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service";import { ProjectPermissionActions, ProjectPermissionSub } from "@app/ee/services/permission/project-permission";+import { getConfig } from "@app/lib/config/env";import { request } from "@app/lib/config/request";import { decryptSymmetric128BitHexKeyUTF8, encryptSymmetric128BitHexKeyUTF8 } from "@app/lib/crypto";import { BadRequestError, NotFoundError } from "@app/lib/errors";@@ -16,6 +18,7 @@ import { KmsDataKey } from "../kms/kms-types";import { TProjectBotServiceFactory } from "../project-bot/project-bot-service";import { getApps } from "./integration-app-list";import { TIntegrationAuthDALFactory } from "./integration-auth-dal";+import { IntegrationAuthMetadataSchema } from "./integration-auth-schema";import {TBitbucketWorkspace,TChecklyGroups,@@ -345,6 +348,13 @@ export const integrationAuthServiceFactory = ({) {return { accessToken: "", accessId: "" };}+ if (+ integrationAuth.integration === Integrations.GITHUB &&+ IntegrationAuthMetadataSchema.parse(integrationAuth.metadata).installationId+ ) {+ return { accessToken: "", accessId: "" };+ }+if (shouldUseSecretV2Bridge) {const { decryptor: secretManagerDecryptor, encryptor: secretManagerEncryptor } =await kmsService.createCipherPairWithDataKey({@@ -471,6 +481,7 @@ export const integrationAuthServiceFactory = ({const { accessToken, accessId } = await getIntegrationAccessToken(integrationAuth, shouldUseSecretV2Bridge, botKey);const apps = await getApps({integration: integrationAuth.integration,+ authMetadata: IntegrationAuthMetadataSchema.parse(integrationAuth.metadata),accessToken,accessId,teamId,@@ -586,6 +597,7 @@ export const integrationAuthServiceFactory = ({};const getGithubOrgs = async ({ actorId, actor, actorOrgId, actorAuthMethod, id }: TIntegrationAuthGithubOrgsDTO) => {+ const appCfg = getConfig();const integrationAuth = await integrationAuthDAL.findById(id);if (!integrationAuth) throw new NotFoundError({ message: "Failed to find integration" });@@ -598,9 +610,44 @@ export const integrationAuthServiceFactory = ({);ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);const { shouldUseSecretV2Bridge, botKey } = await projectBotService.getBotKey(integrationAuth.projectId);- const { accessToken } = await getIntegrationAccessToken(integrationAuth, shouldUseSecretV2Bridge, botKey);- const octokit = new Octokit({+ let octokit: Octokit;+ const { installationId } = integrationAuth.metadata as { installationId: string };+ if (installationId) {+ octokit = new Octokit({+ authStrategy: createAppAuth,+ auth: {+ appId: appCfg.GITHUB_APP_ID,+ privateKey: appCfg.GITHUB_APP_PRIVATE_KEY,+ installationId+ }+ });++ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion+ const repos = await octokit.paginate("GET /installation/repositories", {+ per_page: 100+ });++ const orgSet: Set<string> = new Set();++ return repos+ .filter((repo) => repo.owner.type === "Organization")+ .map((repo) => ({+ name: repo.owner.login,+ orgId: String(repo.owner.id)+ }))+ .filter((org) => {+ const isOrgProcessed = !orgSet.has(org.orgId);+ if (!isOrgProcessed) {+ orgSet.add(org.orgId);+ }++ return isOrgProcessed;+ });+ }++ const { accessToken } = await getIntegrationAccessToken(integrationAuth, shouldUseSecretV2Bridge, botKey);+ octokit = new Octokit({auth: accessToken});@@ -609,7 +656,9 @@ export const integrationAuthServiceFactory = ({"X-GitHub-Api-Version": "2022-11-28"}});- if (!data) return [];+ if (!data) {+ return [];+ }return data.map(({ login: name, id: orgId }) => ({ name, orgId: String(orgId) }));};@@ -637,9 +686,24 @@ export const integrationAuthServiceFactory = ({const { shouldUseSecretV2Bridge, botKey } = await projectBotService.getBotKey(integrationAuth.projectId);const { accessToken } = await getIntegrationAccessToken(integrationAuth, shouldUseSecretV2Bridge, botKey);- const octokit = new Octokit({- auth: accessToken- });+ let octokit: Octokit;+ const appCfg = getConfig();++ const authMetadata = IntegrationAuthMetadataSchema.parse(integrationAuth.metadata);+ if (authMetadata.installationId) {+ octokit = new Octokit({+ authStrategy: createAppAuth,+ auth: {+ appId: appCfg.GITHUB_APP_ID,+ privateKey: appCfg.GITHUB_APP_PRIVATE_KEY,+ installationId: authMetadata.installationId+ }+ });+ } else {+ octokit = new Octokit({+ auth: accessToken+ });+ }const {data: { environments }diff --git a/backend/src/services/integration-auth/integration-delete-secret.ts b/backend/src/services/integration-auth/integration-delete-secret.tsindex bd9619ad4b..a404f59119 100644--- a/backend/src/services/integration-auth/integration-delete-secret.ts+++ b/backend/src/services/integration-auth/integration-delete-secret.ts@@ -1,7 +1,10 @@+/* eslint-disable @typescript-eslint/no-unsafe-member-access */+import { createAppAuth } from "@octokit/auth-app";import { retry } from "@octokit/plugin-retry";import { Octokit } from "@octokit/rest";import { TIntegrationAuths, TIntegrations } from "@app/db/schemas";+import { getConfig } from "@app/lib/config/env";import { decryptSymmetric128BitHexKeyUTF8 } from "@app/lib/crypto";import { BadRequestError, NotFoundError } from "@app/lib/errors";import { logger } from "@app/lib/logger";@@ -15,6 +18,7 @@ import { TSecretFolderDALFactory } from "../secret-folder/secret-folder-dal";import { TSecretImportDALFactory } from "../secret-import/secret-import-dal";import { fnSecretsV2FromImports } from "../secret-import/secret-import-fns";import { TSecretV2BridgeDALFactory } from "../secret-v2-bridge/secret-v2-bridge-dal";+import { IntegrationAuthMetadataSchema, TIntegrationAuthMetadata } from "./integration-auth-schema";import { TIntegrationAuthServiceFactory } from "./integration-auth-service";import { Integrations } from "./integration-list";@@ -154,10 +158,12 @@ const getIntegrationSecretsV1 = async (export const deleteGithubSecrets = async ({integration,+ authMetadata,secrets,accessToken}: {integration: Omit<TIntegrations, "envId">;+ authMetadata: TIntegrationAuthMetadata;secrets: Record<string, boolean>;accessToken: string;}) => {@@ -170,9 +176,23 @@ export const deleteGithubSecrets = async ({}const OctokitWithRetry = Octokit.plugin(retry);- const octokit = new OctokitWithRetry({- auth: accessToken- });+ let octokit: Octokit;+ const appCfg = getConfig();++ if (authMetadata.installationId) {+ octokit = new OctokitWithRetry({+ authStrategy: createAppAuth,+ auth: {+ appId: appCfg.GITHUB_APP_ID,+ privateKey: appCfg.GITHUB_APP_PRIVATE_KEY,+ installationId: authMetadata.installationId+ }+ });+ } else {+ octokit = new OctokitWithRetry({+ auth: accessToken+ });+ }enum GithubScope {Repo = "github-repo",@@ -192,6 +212,7 @@ export const deleteGithubSecrets = async ({break;}case GithubScope.Env: {+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignmentencryptedGithubSecrets = (await octokit.request("GET /repositories/{repository_id}/environments/{environment_name}/secrets", {repository_id: Number(integration.appId),@@ -346,6 +367,7 @@ export const deleteIntegrationSecrets = async ({case Integrations.GITHUB: {await deleteGithubSecrets({integration,+ authMetadata: IntegrationAuthMetadataSchema.parse(integrationAuth.metadata),accessToken,secrets: Object.keys(suffixedSecrets).length !== 0 ? suffixedSecrets : secrets});diff --git a/backend/src/services/integration-auth/integration-sync-secret.ts b/backend/src/services/integration-auth/integration-sync-secret.tsindex c9711c7df9..c08cff98dd 100644--- a/backend/src/services/integration-auth/integration-sync-secret.ts+++ b/backend/src/services/integration-auth/integration-sync-secret.ts@@ -18,6 +18,7 @@ import {UpdateSecretCommand} from "@aws-sdk/client-secrets-manager";import { AssumeRoleCommand, STSClient } from "@aws-sdk/client-sts";+import { createAppAuth } from "@octokit/auth-app";import { Octokit } from "@octokit/rest";import AWS, { AWSError } from "aws-sdk";import { AxiosError } from "axios";@@ -35,6 +36,7 @@ import { TCreateManySecretsRawFn, TUpdateManySecretsRawFn } from "@app/services/import { TIntegrationDALFactory } from "../integration/integration-dal";import { IntegrationMetadataSchema } from "../integration/integration-schema";+import { IntegrationAuthMetadataSchema } from "./integration-auth-schema";import { TIntegrationsWithEnvironment } from "./integration-auth-types";import {IntegrationInitialSyncBehavior,@@ -1527,11 +1529,13 @@ const syncSecretsNetlify = async ({*/const syncSecretsGitHub = async ({integration,+ integrationAuth,secrets,accessToken,appendices}: {integration: TIntegrations;+ integrationAuth: TIntegrationAuths;secrets: Record<string, { value: string; comment?: string }>;accessToken: string;appendices?: { prefix: string; suffix: string };@@ -1553,9 +1557,24 @@ const syncSecretsGitHub = async ({selected_repositories_url?: string | undefined;}- const octokit = new Octokit({- auth: accessToken- });+ const authMetadata = IntegrationAuthMetadataSchema.parse(integrationAuth.metadata);+ let octokit: Octokit;+ const appCfg = getConfig();++ if (authMetadata.installationId) {+ octokit = new Octokit({+ authStrategy: createAppAuth,+ auth: {+ appId: appCfg.GITHUB_APP_ID,+ privateKey: appCfg.GITHUB_APP_PRIVATE_KEY,+ installationId: authMetadata.installationId+ }+ });+ } else {+ octokit = new Octokit({+ auth: accessToken+ });+ }enum GithubScope {Repo = "github-repo",@@ -4054,6 +4073,7 @@ export const syncIntegrationSecrets = async ({case Integrations.GITHUB:await syncSecretsGitHub({integration,+ integrationAuth,secrets,accessToken,appendicesdiff --git a/backend/src/services/integration/integration-service.ts b/backend/src/services/integration/integration-service.tsindex 24e1dd5c49..47a92c3844 100644--- a/backend/src/services/integration/integration-service.ts+++ b/backend/src/services/integration/integration-service.ts@@ -258,27 +258,7 @@ export const integrationServiceFactory = ({});}- const deletedIntegration = await integrationDAL.transaction(async (tx) => {- // delete integration- const deletedIntegrationResult = await integrationDAL.deleteById(id, tx);-- // check if there are other integrations that share the same integration auth- const integrations = await integrationDAL.find(- {- integrationAuthId: integration.integrationAuthId- },- tx- );-- if (integrations.length === 0) {- // no other integration shares the same integration auth- // -> delete the integration auth- await integrationAuthDAL.deleteById(integration.integrationAuthId, tx);- }-- return deletedIntegrationResult;- });-+ const deletedIntegration = await integrationDAL.deleteById(id);return { ...integration, ...deletedIntegration };};