Skip to content

Commit d6c3e83

Browse files
committed
Inject Koios JWT at build time from a GH Actions secret.
The Koios JWT is still public — it ends up in the JS bundle by design — but hard-coding it in `src/plugins/vue-cardano.js` *and* `src/App.vue` meant every rotation was a two-file source edit plus a release. Wire it through a build-time env var so the next rotation is a Settings → Secrets edit and a redeploy. Updates include: - Both `koios_key` declarations now read `process.env.VUE_APP_KOIOS_JWT` (the Vue CLI convention — webpack's DefinePlugin inlines `VUE_APP_*` vars into the client bundle at build time), falling back to a hard-coded default so `npm run serve` keeps working with no `.env.local` setup. The fallback has been refreshed to the JWT issued today (the previous embedded token expired in Jan 2026); future rotations only need to update the GitHub secret. - `.github/workflows/deploy.yaml` and `.github/workflows/ci.yaml` now forward `secrets.KOIOS_JWT` into the `npm run build` step as `VUE_APP_KOIOS_JWT`. CI builds against the same secret so PR builds match production. When the secret isn't set in a fork's CI, the fallback kicks in and the build still passes. - `.env.example` documents the variable for anyone running locally who wants to point at a different Koios project without touching source.
1 parent 87fa8e4 commit d6c3e83

5 files changed

Lines changed: 17 additions & 2 deletions

File tree

.env.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copy to .env.local and fill in to override build-time defaults.
2+
# Any var prefixed with VUE_APP_ is inlined into the client bundle.
3+
4+
# Koios API JWT (https://koios.rest/). Bundled into the JS — treated as public.
5+
# Production builds inject this from the KOIOS_JWT GitHub Actions secret;
6+
# leave unset to use the fallback embedded in src/plugins/vue-cardano.js.
7+
VUE_APP_KOIOS_JWT=

.github/workflows/ci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
run: npm run build
2222
env:
2323
NODE_OPTIONS: --max-old-space-size=4096
24+
VUE_APP_KOIOS_JWT: ${{ secrets.KOIOS_JWT }}
2425
# Once smoke tests exist (modernization task A4), add:
2526
# - run: npx playwright install --with-deps
2627
# - run: npm run test:e2e

.github/workflows/deploy.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
run: npm run build
2121
env:
2222
NODE_OPTIONS: --max-old-space-size=4096
23+
VUE_APP_KOIOS_JWT: ${{ secrets.KOIOS_JWT }}
2324
- uses: aws-actions/configure-aws-credentials@v4
2425
with:
2526
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}

src/App.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,11 @@ import axios from "axios";
398398
import stringify from "fast-safe-stringify";
399399
import version from "./version.json";
400400
401+
// Injected at build time via VUE_APP_KOIOS_JWT (see deploy.yaml / ci.yaml).
402+
// Fallback keeps `npm run serve` working without an .env.local override.
401403
const koios_key =
402-
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhZGRyIjoic3Rha2UxdXk1Nm5uN3c1OGRyNWsyOG1mcnhnaHBuZ25uNHo0N2pkcGdwOW1ldXZncDdrNXFtaHljbnAiLCJleHAiOjE3Njk1Mjg1MDAsInRpZXIiOjEsInByb2pJRCI6IlVuRnJhY2tJdCJ9.GrdvIKjkdDDFENR5a7Kypzt79UbuknjFAgq3SRv0oPw";
404+
process.env.VUE_APP_KOIOS_JWT ||
405+
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhZGRyIjoic3Rha2UxdTlxdDV2dWo3OHdoZm1zMzhjc2Q3NzVraGV0OGd1cWV0M3hsODJsaG1rbXl0cHEya3R6aGMiLCJleHAiOjE4MTA4NDQwMTAsInRpZXIiOjEsInByb2pJRCI6InVuZnJhY2suaXQifQ.rvAHYjwdN8XQVS_JO68QxsHwO8hYj6j6MHLAiNcxtVg";
403406
404407
class Paginate {
405408
constructor(page, limit) {

src/plugins/vue-cardano.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ import { Buffer } from "buffer";
33
import * as CSL from "@emurgo/cardano-serialization-lib-asmjs";
44
import axios from "axios";
55

6+
// Injected at build time via VUE_APP_KOIOS_JWT (see deploy.yaml / ci.yaml).
7+
// Fallback keeps `npm run serve` working without an .env.local override.
68
const koios_key =
7-
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhZGRyIjoic3Rha2UxdXk1Nm5uN3c1OGRyNWsyOG1mcnhnaHBuZ25uNHo0N2pkcGdwOW1ldXZncDdrNXFtaHljbnAiLCJleHAiOjE3Njk1Mjg1MDAsInRpZXIiOjEsInByb2pJRCI6IlVuRnJhY2tJdCJ9.GrdvIKjkdDDFENR5a7Kypzt79UbuknjFAgq3SRv0oPw";
9+
process.env.VUE_APP_KOIOS_JWT ||
10+
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhZGRyIjoic3Rha2UxdTlxdDV2dWo3OHdoZm1zMzhjc2Q3NzVraGV0OGd1cWV0M3hsODJsaG1rbXl0cHEya3R6aGMiLCJleHAiOjE4MTA4NDQwMTAsInRpZXIiOjEsInByb2pJRCI6InVuZnJhY2suaXQifQ.rvAHYjwdN8XQVS_JO68QxsHwO8hYj6j6MHLAiNcxtVg";
811

912
const defaultOptions = {
1013
retries: 10,

0 commit comments

Comments
 (0)