Skip to content

Commit

Permalink
chore: add octokit for app auth
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Sep 4, 2024
1 parent 96990a5 commit ec8dca5
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 16 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"grammy-guard": "0.5.0",
"hono": "^4.5.9",
"iso-639-1": "3.1.2",
"octokit": "^4.0.2",
"pino": "9.3.2",
"pino-pretty": "11.2.2",
"telegram": "^2.24.11",
Expand Down Expand Up @@ -109,4 +110,4 @@
]
},
"packageManager": "[email protected]"
}
}
3 changes: 1 addition & 2 deletions src/handlers/repository-dispatch.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { getAppOctokit } from "#root/helpers/authenticated-octokit.js";
import { PluginContext } from "#root/utils/plugin-context-single.js";
import { Context } from "../types";
import { WorkflowFunction } from "../workflow-functions";

/**
* Used by the worker instance to kick off workflows within it's own repository.
Expand All @@ -15,7 +14,7 @@ import { WorkflowFunction } from "../workflow-functions";
*
*/

export async function repositoryDispatch(context: Context, workflow: WorkflowFunction) {
export async function repositoryDispatch(context: Context, workflow: string) {
const inputs = PluginContext.getInstance().getInputs();
const { logger } = context;
const repository = "telegram--bot";
Expand Down
14 changes: 6 additions & 8 deletions src/helpers/authenticated-octokit.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { Octokit } from "@octokit/rest";
import { App } from "octokit";
import { Context } from "../types";

export async function getAppOctokit(context: Context) {
const { env } = context;
const { APP_ID, APP_PRIVATE_KEY } = env;
const appOctokit = new Octokit({
auth: {
appId: APP_ID,
privateKey: APP_PRIVATE_KEY,
},
});
const app = new App({
appId: APP_ID,
privateKey: APP_PRIVATE_KEY,
})

return appOctokit;
return app.octokit;
}
164 changes: 159 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2406,6 +2406,65 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@octokit/app@^15.0.0":
version "15.1.0"
resolved "https://registry.yarnpkg.com/@octokit/app/-/app-15.1.0.tgz#b330d8826be088ec8d1d43a59dc27ef57d1232b2"
integrity sha512-TkBr7QgOmE6ORxvIAhDbZsqPkF7RSqTY4pLTtUQCvr6dTXqvi2fFo46q3h1lxlk/sGMQjqyZ0kEahkD/NyzOHg==
dependencies:
"@octokit/auth-app" "^7.0.0"
"@octokit/auth-unauthenticated" "^6.0.0"
"@octokit/core" "^6.1.2"
"@octokit/oauth-app" "^7.0.0"
"@octokit/plugin-paginate-rest" "^11.0.0"
"@octokit/types" "^13.0.0"
"@octokit/webhooks" "^13.0.0"

"@octokit/auth-app@^7.0.0":
version "7.1.1"
resolved "https://registry.yarnpkg.com/@octokit/auth-app/-/auth-app-7.1.1.tgz#d8916ad01e6ffb0a0a50507aa613e91fe7a49b93"
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 "^2.2.0"
universal-user-agent "^7.0.0"

"@octokit/auth-oauth-app@^8.0.0", "@octokit/auth-oauth-app@^8.1.0":
version "8.1.1"
resolved "https://registry.yarnpkg.com/@octokit/auth-oauth-app/-/auth-oauth-app-8.1.1.tgz#6204affa6e86f535016799cadf2af9befe5e893c"
integrity sha512-5UtmxXAvU2wfcHIPPDWzVSAWXVJzG3NWsxb7zCFplCWEmMCArSZV0UQu5jw5goLQXbFyOr5onzEH37UJB3zQQg==
dependencies:
"@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"

"@octokit/auth-oauth-device@^7.0.0", "@octokit/auth-oauth-device@^7.0.1":
version "7.1.1"
resolved "https://registry.yarnpkg.com/@octokit/auth-oauth-device/-/auth-oauth-device-7.1.1.tgz#7b4f8f97cbcadbe9894d48cde4406dbdef39875a"
integrity sha512-HWl8lYueHonuyjrKKIup/1tiy0xcmQCdq5ikvMO1YwkNNkxb6DXfrPjrMYItNLyCP/o2H87WuijuE+SlBTT8eg==
dependencies:
"@octokit/oauth-methods" "^5.0.0"
"@octokit/request" "^9.0.0"
"@octokit/types" "^13.0.0"
universal-user-agent "^7.0.0"

"@octokit/auth-oauth-user@^5.0.1", "@octokit/auth-oauth-user@^5.1.0":
version "5.1.1"
resolved "https://registry.yarnpkg.com/@octokit/auth-oauth-user/-/auth-oauth-user-5.1.1.tgz#4f1570c6ee15bb9ddc3dcca83308dcaa159e3848"
integrity sha512-rRkMz0ErOppdvEfnemHJXgZ9vTPhBuC6yASeFaB7I2yLMd7QpjfrL1mnvRPlyKo+M6eeLxrKanXJ9Qte29SRsw==
dependencies:
"@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"

"@octokit/auth-token@^4.0.0":
version "4.0.0"
resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-4.0.0.tgz#40d203ea827b9f17f42a29c6afb93b7745ef80c7"
Expand All @@ -2416,6 +2475,14 @@
resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-5.1.1.tgz#3bbfe905111332a17f72d80bd0b51a3e2fa2cf07"
integrity sha512-rh3G3wDO8J9wSjfI436JUKzHIxq8NaiL0tVeB2aXmG6p/9859aUOAjA9pmSPNGGZxfwmaJ9ozOJImuNVJdpvbA==

"@octokit/auth-unauthenticated@^6.0.0", "@octokit/auth-unauthenticated@^6.0.0-beta.1":
version "6.1.0"
resolved "https://registry.yarnpkg.com/@octokit/auth-unauthenticated/-/auth-unauthenticated-6.1.0.tgz#de0fe923bb06ed93aea526ab99972a98c546d0bf"
integrity sha512-zPSmfrUAcspZH/lOFQnVnvjQZsIvmfApQH6GzJrkIunDooU1Su2qt2FfMTSVPRp7WLTQyC20Kd55lF+mIYaohQ==
dependencies:
"@octokit/request-error" "^6.0.1"
"@octokit/types" "^13.0.0"

"@octokit/core@^5.0.1":
version "5.2.0"
resolved "https://registry.yarnpkg.com/@octokit/core/-/core-5.2.0.tgz#ddbeaefc6b44a39834e1bb2e58a49a117672a7ea"
Expand All @@ -2429,7 +2496,7 @@
before-after-hook "^2.2.0"
universal-user-agent "^6.0.0"

"@octokit/core@^6.1.2":
"@octokit/core@^6.0.0", "@octokit/core@^6.1.2":
version "6.1.2"
resolved "https://registry.yarnpkg.com/@octokit/core/-/core-6.1.2.tgz#20442d0a97c411612da206411e356014d1d1bd17"
integrity sha512-hEb7Ma4cGJGEUNOAVmyfdB/3WirWMg5hDuNFVejGEDFqupeOysLc2sG6HJxY2etBp5YQu5Wtxwi020jS9xlUwg==
Expand Down Expand Up @@ -2476,6 +2543,35 @@
"@octokit/types" "^13.0.0"
universal-user-agent "^7.0.0"

"@octokit/oauth-app@^7.0.0":
version "7.1.3"
resolved "https://registry.yarnpkg.com/@octokit/oauth-app/-/oauth-app-7.1.3.tgz#a0f256dd185e7c00bfbc3e6bc3c5aad66e42c609"
integrity sha512-EHXbOpBkSGVVGF1W+NLMmsnSsJRkcrnVmDKt0TQYRBb6xWfWzoi9sBD4DIqZ8jGhOWO/V8t4fqFyJ4vDQDn9bg==
dependencies:
"@octokit/auth-oauth-app" "^8.0.0"
"@octokit/auth-oauth-user" "^5.0.1"
"@octokit/auth-unauthenticated" "^6.0.0-beta.1"
"@octokit/core" "^6.0.0"
"@octokit/oauth-authorization-url" "^7.0.0"
"@octokit/oauth-methods" "^5.0.0"
"@types/aws-lambda" "^8.10.83"
universal-user-agent "^7.0.0"

"@octokit/oauth-authorization-url@^7.0.0":
version "7.1.1"
resolved "https://registry.yarnpkg.com/@octokit/oauth-authorization-url/-/oauth-authorization-url-7.1.1.tgz#0e17c2225eb66b58ec902d02b6f1315ffe9ff04b"
integrity sha512-ooXV8GBSabSWyhLUowlMIVd9l1s2nsOGQdlP2SQ4LnkEsGXzeCvbSbCPdZThXhEFzleGPwbapT0Sb+YhXRyjCA==

"@octokit/oauth-methods@^5.0.0":
version "5.1.2"
resolved "https://registry.yarnpkg.com/@octokit/oauth-methods/-/oauth-methods-5.1.2.tgz#fd31d2a69f4c91d1abc1ed1814dda5252c697e02"
integrity sha512-C5lglRD+sBlbrhCUTxgJAFjWgJlmTx5bQ7Ch0+2uqRjYv7Cfb5xpX4WuSC9UgQna3sqRGBL9EImX9PvTpMaQ7g==
dependencies:
"@octokit/oauth-authorization-url" "^7.0.0"
"@octokit/request" "^9.1.0"
"@octokit/request-error" "^6.1.0"
"@octokit/types" "^13.0.0"

"@octokit/openapi-types@^20.0.0":
version "20.0.0"
resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-20.0.0.tgz#9ec2daa0090eeb865ee147636e0c00f73790c6e5"
Expand All @@ -2491,6 +2587,11 @@
resolved "https://registry.yarnpkg.com/@octokit/openapi-webhooks-types/-/openapi-webhooks-types-8.3.0.tgz#a7a4da00c0f27f7f5708eb3fcebefa08f8d51125"
integrity sha512-vKLsoR4xQxg4Z+6rU/F65ItTUz/EXbD+j/d4mlq2GW8TsA4Tc8Kdma2JTAAJ5hrKWUQzkR/Esn2fjsqiVRYaQg==

"@octokit/plugin-paginate-graphql@^5.0.0":
version "5.2.2"
resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-graphql/-/plugin-paginate-graphql-5.2.2.tgz#54e2afef55bb204eb945a891b85a169b9ddad1f8"
integrity sha512-7znSVvlNAOJisCqAnjN1FtEziweOHSjPGAuc5W58NeGNAr/ZB57yCsjQbXDlWsVryA7hHQaEQPcBbJYFawlkyg==

"@octokit/plugin-paginate-rest@^11.0.0":
version "11.3.3"
resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-11.3.3.tgz#efc97ba66aae6797e2807a082f99b9cfc0e05aba"
Expand Down Expand Up @@ -2524,6 +2625,23 @@
dependencies:
"@octokit/types" "^13.5.0"

"@octokit/plugin-retry@^7.0.0":
version "7.1.1"
resolved "https://registry.yarnpkg.com/@octokit/plugin-retry/-/plugin-retry-7.1.1.tgz#a84483e4afdd068dd71da81abe206a9e442c1288"
integrity sha512-G9Ue+x2odcb8E1XIPhaFBnTTIrrUDfXN05iFXiqhR+SeeeDMMILcAnysOsxUpEWcQp2e5Ft397FCXTcPkiPkLw==
dependencies:
"@octokit/request-error" "^6.0.0"
"@octokit/types" "^13.0.0"
bottleneck "^2.15.3"

"@octokit/plugin-throttling@^9.0.0":
version "9.3.1"
resolved "https://registry.yarnpkg.com/@octokit/plugin-throttling/-/plugin-throttling-9.3.1.tgz#5648165e1e70e861625f3a16af6c55cafe861061"
integrity sha512-Qd91H4liUBhwLB2h6jZ99bsxoQdhgPk6TdwnClPyTBSDAdviGPceViEgUwj+pcQDmB/rfAXAXK7MTochpHM3yQ==
dependencies:
"@octokit/types" "^13.0.0"
bottleneck "^2.15.3"

"@octokit/request-error@^5.1.0":
version "5.1.0"
resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-5.1.0.tgz#ee4138538d08c81a60be3f320cd71063064a3b30"
Expand All @@ -2533,7 +2651,7 @@
deprecation "^2.0.0"
once "^1.4.0"

"@octokit/request-error@^6.0.1":
"@octokit/request-error@^6.0.0", "@octokit/request-error@^6.0.1", "@octokit/request-error@^6.1.0", "@octokit/request-error@^6.1.1":
version "6.1.4"
resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-6.1.4.tgz#ad96e29148d19edc2ba8009fc2b5a24a36c90f16"
integrity sha512-VpAhIUxwhWZQImo/dWAN/NpPqqojR6PSLgLYAituLM6U+ddx9hCioFGwBr5Mi+oi5CLeJkcAs3gJ0PYYzU6wUg==
Expand All @@ -2550,7 +2668,7 @@
"@octokit/types" "^13.1.0"
universal-user-agent "^6.0.0"

"@octokit/request@^9.0.0":
"@octokit/request@^9.0.0", "@octokit/request@^9.0.1", "@octokit/request@^9.1.0", "@octokit/request@^9.1.1":
version "9.1.3"
resolved "https://registry.yarnpkg.com/@octokit/request/-/request-9.1.3.tgz#42b693bc06238f43af3c037ebfd35621c6457838"
integrity sha512-V+TFhu5fdF3K58rs1pGUJIDH5RZLbZm5BI+MNF+6o/ssFNT4vWlCh/tVpF3NxGtP15HUxTTMUbsG5llAuU2CZA==
Expand All @@ -2577,7 +2695,7 @@
dependencies:
"@octokit/openapi-types" "^20.0.0"

"@octokit/types@^13.0.0", "@octokit/types@^13.1.0", "@octokit/types@^13.5.0":
"@octokit/types@^13.0.0", "@octokit/types@^13.1.0", "@octokit/types@^13.4.1", "@octokit/types@^13.5.0":
version "13.5.0"
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-13.5.0.tgz#4796e56b7b267ebc7c921dcec262b3d5bfb18883"
integrity sha512-HdqWTf5Z3qwDVlzCrP8UJquMwunpDiMPt5er+QjGzL4hqr/vBVY/MauQgS1xWxCDT1oMx1EULyqxncdCY/NVSQ==
Expand All @@ -2589,7 +2707,7 @@
resolved "https://registry.yarnpkg.com/@octokit/webhooks-methods/-/webhooks-methods-5.1.0.tgz#13b6c08f89902c1ab0ddf31c6eeeec9c2772cfe6"
integrity sha512-yFZa3UH11VIxYnnoOYCVoJ3q4ChuSOk2IVBBQ0O3xtKX4x9bmKb/1t+Mxixv2iUhzMdOl1qeWJqEhouXXzB3rQ==

"@octokit/[email protected]":
"@octokit/[email protected]", "@octokit/webhooks@^13.0.0":
version "13.3.0"
resolved "https://registry.yarnpkg.com/@octokit/webhooks/-/webhooks-13.3.0.tgz#fd5d54d47c789c75d60a00eb04e982152d7c654a"
integrity sha512-TUkJLtI163Bz5+JK0O+zDkQpn4gKwN+BovclUvCj6pI/6RXrFqQvUMRS2M+Rt8Rv0qR3wjoMoOPmpJKeOh0nBg==
Expand Down Expand Up @@ -2711,6 +2829,11 @@
"@supabase/realtime-js" "2.10.2"
"@supabase/storage-js" "2.7.0"

"@types/aws-lambda@^8.10.83":
version "8.10.145"
resolved "https://registry.yarnpkg.com/@types/aws-lambda/-/aws-lambda-8.10.145.tgz#b2d31a987f4888e5553ff1819f57cafa475594d9"
integrity sha512-dtByW6WiFk5W5Jfgz1VM+YPA21xMXTuSFoLYIDY0L44jDLLflVPtZkYuu3/YxpGcvjzKFBZLU+GyKjR0HOYtyw==

"@types/babel__core@^7.1.14":
version "7.20.5"
resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.20.5.tgz#3df15f27ba85319caa07ba08d0721889bb39c017"
Expand Down Expand Up @@ -3518,6 +3641,11 @@ blake3-wasm@^2.1.5:
resolved "https://registry.yarnpkg.com/blake3-wasm/-/blake3-wasm-2.1.5.tgz#b22dbb84bc9419ed0159caa76af4b1b132e6ba52"
integrity sha512-F1+K8EbfOZE49dtoPtmxUQrpXaBIl3ICvasLh+nJta0xkz+9kF/7uet9fLnwKqhDrmj6g+6K3Tw9yQPUg2ka5g==

bottleneck@^2.15.3:
version "2.19.5"
resolved "https://registry.yarnpkg.com/bottleneck/-/bottleneck-2.19.5.tgz#5df0b90f59fd47656ebe63c78a98419205cadd91"
integrity sha512-VHiNCbI1lKdl44tGrhNfU3lup0Tj/ZBMJB5/2ZbNXRCPuRCO7ed2mgcK4r17y+KB2EfuYuRaVlwNbAeaWGSpbw==

brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
Expand Down Expand Up @@ -6625,6 +6753,11 @@ loose-envify@^1.4.0:
dependencies:
js-tokens "^3.0.0 || ^4.0.0"

lru-cache@^10.0.0:
version "10.4.3"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.4.3.tgz#410fc8a17b70e598013df257c2446b7f3383f119"
integrity sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==

lru-cache@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920"
Expand Down Expand Up @@ -7014,6 +7147,22 @@ object.values@^1.1.6, object.values@^1.1.7, object.values@^1.2.0:
define-properties "^1.2.1"
es-object-atoms "^1.0.0"

octokit@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/octokit/-/octokit-4.0.2.tgz#775d68d363cdaec69d7b73d3dc82ae909d30f59b"
integrity sha512-wbqF4uc1YbcldtiBFfkSnquHtECEIpYD78YUXI6ri1Im5OO2NLo6ZVpRdbJpdnpZ05zMrVPssNiEo6JQtea+Qg==
dependencies:
"@octokit/app" "^15.0.0"
"@octokit/core" "^6.0.0"
"@octokit/oauth-app" "^7.0.0"
"@octokit/plugin-paginate-graphql" "^5.0.0"
"@octokit/plugin-paginate-rest" "^11.0.0"
"@octokit/plugin-rest-endpoint-methods" "^13.0.0"
"@octokit/plugin-retry" "^7.0.0"
"@octokit/plugin-throttling" "^9.0.0"
"@octokit/request-error" "^6.0.0"
"@octokit/types" "^13.0.0"

on-exit-leak-free@^2.1.0:
version "2.1.2"
resolved "https://registry.yarnpkg.com/on-exit-leak-free/-/on-exit-leak-free-2.1.2.tgz#fed195c9ebddb7d9e4c3842f93f281ac8dadd3b8"
Expand Down Expand Up @@ -8565,6 +8714,11 @@ unicorn-magic@^0.1.0:
resolved "https://registry.yarnpkg.com/unicorn-magic/-/unicorn-magic-0.1.0.tgz#1bb9a51c823aaf9d73a8bfcd3d1a23dde94b0ce4"
integrity sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ==

universal-github-app-jwt@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/universal-github-app-jwt/-/universal-github-app-jwt-2.2.0.tgz#dc6c8929e76f1996a766ba2a08fb420f73365d77"
integrity sha512-G5o6f95b5BggDGuUfKDApKaCgNYy2x7OdHY0zSMF081O0EJobw+1130VONhrA7ezGSV2FNOGyM+KQpQZAr9bIQ==

universal-user-agent@^6.0.0:
version "6.0.1"
resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-6.0.1.tgz#15f20f55da3c930c57bddbf1734c6654d5fd35aa"
Expand Down

0 comments on commit ec8dca5

Please sign in to comment.