commit 08c0e9c1075db5f5d912f763fa469fba30da76f4 Author: dahyeon Date: Sat May 2 02:30:12 2026 -0700 . diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..db326ad --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +node_modules/ +dist/ +env +env-vars/*.env +env-vars/.env.* +*.log diff --git a/PLAN.md b/PLAN.md new file mode 100644 index 0000000..78e7ab6 --- /dev/null +++ b/PLAN.md @@ -0,0 +1,211 @@ +# Machine Env Service — 구현 Plan + +홈랩 머신마다 동작하는 로컬 메타데이터 데몬. AWS IMDSv2와 동일한 프로토콜로 머신 스코프 시크릿/환경변수를 노출한다. 클라이언트(컨테이너/프로세스)는 Infisical 자격증명 없이 데몬에 HTTP로 fetch. + +## 1. 목표 + +- 각 머신에 systemd 서비스 1개로 상주하는 데몬 +- IMDSv2 프로토콜(PUT 토큰 → GET 메타데이터) 그대로 구현 +- 머신 스코프 시크릿은 데몬이 Infisical에서 가져와서 노출 +- 데몬만 Infisical machine identity 자격증명을 보유 (클라는 0개) + +## 2. 인터페이스 (IMDSv2 호환) + +### 토큰 발급 +``` +PUT /latest/api/token +Headers: + X-aws-ec2-metadata-token-ttl-seconds: <1..21600> +Response: + 200 OK, body = + 400 if header missing/invalid + 405 if method != PUT +``` + +### 메타데이터 조회 +``` +GET /latest/meta-data/... +Headers: + X-aws-ec2-metadata-token: +Response: + 200 + body + 401 if token missing/expired/invalid +``` + +### SSRF 방어 규칙 (IMDSv2와 동일) +- `PUT`이 아닌 메서드로 토큰 요청 시 `405` +- `X-Forwarded-For` 헤더가 있으면 모든 요청 거부 (`403`) +- `Host` 헤더 검증 (`169.254.169.254` 또는 listen 중인 호스트 IP) + +## 3. 시크릿 엔드포인트 + +``` +GET /latest/meta-data/secrets/ → 키 목록 (개행 구분, IMDS 컨벤션) +GET /latest/meta-data/secrets/ → 해당 키의 값 (plain text) +``` + +추가로 전체 dump (편의용, 기본 비활성, 설정으로 켜기): +``` +GET /latest/meta-data/secrets-bundle → JSON {key: value} +``` + +기존 `KNOWN_SECRET_KEYS`는 노출 화이트리스트로 활용. 화이트리스트에 없는 키는 `404`. + +## 4. 머신 식별 / 자격증명 + +- 데몬이 부팅 시 **자체적으로** dotenv 파일을 읽는다 (OS-agnostic, systemd `EnvironmentFile`과 launchd plist `EnvironmentVariables` 차이 회피) + - 경로: `MACHINE_ENV_CONFIG` env로 override 가능, 기본값 OS별 + - Linux: `/etc/machine-env-service/env` + - macOS: `/usr/local/etc/machine-env-service/env` +- 파일 내용: + - `INFISICAL_CLIENT_ID` + - `INFISICAL_CLIENT_SECRET` + - `INFISICAL_PROJECT_ID` + - `INFISICAL_ENVIRONMENT` (`dev` | `staging` | `prod`) + - `INFISICAL_SITE_URL` (기본 `https://secret-manager.dahyeon.us/`) +- 머신마다 별도의 Infisical machine identity를 부여 → 그 자격증명이 곧 머신 식별자 +- 자격증명 파일 권한은 `0600`, root 소유 + +## 5. 캐시 / 갱신 + +- 데몬 부팅 시 1회 `listSecrets` 호출 → 인메모리 맵 채움 +- 백그라운드 타이머로 TTL마다 재조회 (기본 60초, `REFRESH_INTERVAL_SEC`로 설정) +- Infisical 호출 실패 시: 마지막 성공 값 유지, 로그만 남김 +- 캐시는 read-mostly이므로 swap 갱신 시 잠시 락 또는 atomic 참조 교체 + +## 6. 토큰 저장소 (인메모리) + +- `Map` +- 토큰 발급: `crypto.randomBytes(32).toString("base64url")` +- 만료된 토큰은 lazy 청소 (요청 들어올 때 + 주기적 sweep) +- 데몬 재시작 시 모든 토큰 무효화 (의도된 동작, IMDSv2와 동일) + +## 7. 네트워크 / 컨테이너 접근 + +데몬은 두 곳에 동시에 listen한다: + +1. **`169.254.169.254:80`** — link-local. 호스트 자체에서 동작하는 프로세스용 + - **Linux**: dummy interface로 link-local 주소 추가 + ``` + ip link add dev imds-dummy type dummy + ip addr add 169.254.169.254/32 dev imds-dummy + ip link set imds-dummy up + ``` + - **macOS**: `lo0` alias로 추가 + ``` + ifconfig lo0 alias 169.254.169.254/32 up + ``` + - 두 경우 모두 재부팅 시 사라지므로 service manager가 부팅 시 setup 실행 +2. **`0.0.0.0:`** (기본 `8675`) — 호스트 LAN IP. 컨테이너에서 호스트 IP로 접근 + - Linux 컨테이너 (bridge): `http://:8675/latest/...` + - **Docker Desktop on macOS**: link-local이 VM 안에서 호스트로 라우팅 안 됨 → `http://host.docker.internal:8675/latest/...` 필수 + - host network 강제 불필요 + +**80 포트 바인딩**: +- Linux: systemd unit에서 `AmbientCapabilities=CAP_NET_BIND_SERVICE` (root 아닌 user로 실행 가능) +- macOS: `CAP_NET_BIND_SERVICE` 같은 메커니즘 없음 → launchd plist `UserName=root`로 실행 + +## 8. 보안 + +- `127.0.0.1`/`169.254.169.254`/LAN IP는 모두 신뢰 경계 안 (홈랩 내부망 전제) +- 외부 노출 금지 — 방화벽에서 metadata 포트는 LAN 외부 차단 +- 자격증명 파일은 `0600`, 데몬 user(`machine-env`)만 접근 +- 응답 본문에 시크릿 외 다른 정보 절대 포함 금지 (IMDS 스타일) + +## 9. 디렉토리 구조 + +``` +src/ + common/ + secret-manager.ts # 기존 — Infisical fetch 로직 추출/재사용 + known-secret-keys.ts # 기존 + env-loader.ts # 기존 + daemon/ + main.ts # 엔트리포인트 + server.ts # HTTP 서버 (node:http) + routes/ + token.ts # PUT /latest/api/token + metadata.ts # GET /latest/meta-data/... + secrets.ts # GET /latest/meta-data/secrets/... + middleware/ + ssrf-guard.ts # X-Forwarded-For, Host, method 검증 + token-auth.ts # 토큰 헤더 검증 + store/ + token-store.ts # 인메모리 토큰 저장소 + secret-cache.ts # Infisical 캐시 + 백그라운드 갱신 + config.ts # 환경변수 파싱 +deploy/ + systemd/ # Linux (Ubuntu) + machine-env-service.service + machine-env-setup-link-local.service # 부팅 시 dummy interface 셋업 + machine-env-service.env.example + launchd/ # macOS + us.dahyeon.machine-env-service.plist + us.dahyeon.machine-env-setup-link-local.plist + machine-env-service.env.example + scripts/ + setup-link-local-linux.sh + setup-link-local-macos.sh +``` + +## 10. 구현 단계 (codex용 체크리스트) + +1. **config 모듈** — `src/daemon/config.ts` + - 필수 env(`INFISICAL_*`) 검증, 누락 시 즉시 종료 + - 선택 env(`METADATA_PORT`, `REFRESH_INTERVAL_SEC`, 화이트리스트 모드 등) 기본값 처리 + +2. **secret-cache** — `src/daemon/store/secret-cache.ts` + - `secret-manager.ts`의 Infisical fetch 로직을 클래스/함수로 추출 + - `start()` / `stop()` / `get(key)` / `list()` API + - 부팅 시 첫 fetch는 동기적으로 await, 실패해도 빈 캐시로 계속 진행 + - TTL 기반 백그라운드 재조회 (`setInterval`) + +3. **token-store** — `src/daemon/store/token-store.ts` + - `issue(ttlSec): string` + - `validate(token): boolean` + - 만료 sweep + +4. **middleware** + - `ssrf-guard`: 메서드/X-Forwarded-For/Host 검증 + - `token-auth`: `X-aws-ec2-metadata-token` 헤더 검증 + +5. **routes** + - `PUT /latest/api/token`: TTL 헤더 파싱 → `token-store.issue()` → 응답 + - `GET /latest/meta-data/secrets/`: 화이트리스트 키 목록 (개행 구분) + - `GET /latest/meta-data/secrets/`: 캐시에서 조회, 없으면 404 + - `GET /latest/meta-data/secrets-bundle`: 설정으로 enable됐을 때만, JSON 응답 + +6. **server** — `src/daemon/server.ts` + - `node:http`로 라우팅 (외부 의존 최소화) + - 두 listener 동시 기동 (`169.254.169.254:80`, `0.0.0.0:METADATA_PORT`) + - graceful shutdown (SIGTERM → 새 요청 거부 → 인플라이트 대기 → 캐시 타이머 정리) + +7. **main** — `src/daemon/main.ts` + - config 로드 → secret-cache 초기화 → token-store 초기화 → server 기동 + - SIGTERM/SIGINT 핸들링 + +8. **deploy 자산** + - **Linux (systemd)**: + - `machine-env-service.service`: `Type=simple`, `User=machine-env`, `AmbientCapabilities=CAP_NET_BIND_SERVICE`, `CapabilityBoundingSet=CAP_NET_BIND_SERVICE`, `Restart=on-failure` + - `machine-env-setup-link-local.service`: `Type=oneshot`, `RemainAfterExit=true`, 부팅 시 `setup-link-local-linux.sh` 실행 + - `machine-env-service.service`는 `After=machine-env-setup-link-local.service`, `Requires=...` + - **macOS (launchd)**: + - `us.dahyeon.machine-env-service.plist`: `RunAtLoad=true`, `KeepAlive=true`, `UserName=root`, `ProgramArguments`에 node + 빌드 산출물 경로 + - `us.dahyeon.machine-env-setup-link-local.plist`: `RunAtLoad=true`, `LaunchOnlyOnce=false`, `setup-link-local-macos.sh` 실행 + - 설치 위치: `/Library/LaunchDaemons/` + - link-local 설정 스크립트는 idempotent (이미 alias/interface 있으면 skip) + +9. **package.json 업데이트** + - `"bin"` 또는 `"scripts"`에 데몬 실행 엔트리 + - 빌드 스크립트 (tsc) + +10. **간단한 클라이언트 예제** — `examples/fetch-secret.sh` + - `curl -X PUT -H "...ttl-seconds: 60" .../latest/api/token` → 토큰 + - `curl -H "X-aws-ec2-metadata-token: $TOKEN" .../latest/meta-data/secrets/FOO` + +## 11. 추후 (이번 범위 밖) + +- mTLS 또는 호출자 식별 기반 시크릿 범위 제한 +- Infisical webhook 연동으로 즉시 갱신 +- 머신별 dynamic 메타데이터(hostname, IP 등) 노출 (`/latest/meta-data/hostname` 등) +- IPv6 link-local (`fe80::a9fe:a9fe`) 지원 diff --git a/README.md b/README.md new file mode 100644 index 0000000..226f4f6 --- /dev/null +++ b/README.md @@ -0,0 +1,439 @@ +# Machine Env Service + +IMDSv2-compatible local metadata daemon for homelab machines. Each machine runs one daemon, and local processes or containers can fetch machine-scoped metadata and allowlisted Infisical secrets through HTTP without holding Infisical credentials. + +## What It Exposes + +Token endpoint: + +```text +PUT /latest/api/token +``` + +Metadata endpoints require `X-aws-ec2-metadata-token`: + +```text +/latest/meta-data/ +/latest/meta-data/hostname +/latest/meta-data/local-hostname +/latest/meta-data/local-ipv4 +/latest/meta-data/mac +/latest/meta-data/machine-id +/latest/meta-data/environment +/latest/meta-data/role +/latest/meta-data/tags/ +/latest/meta-data/tags/ +/latest/meta-data/tags/instance/ +/latest/meta-data/tags/instance/ +/latest/meta-data/secrets/ +/latest/meta-data/secrets/ +/latest/dynamic/instance-identity/document +/latest/user-data +``` + +`/latest/meta-data/secrets-bundle` is available only when `ALLOW_SECRETS_BUNDLE=true`. + +## Configuration + +The daemon reads its own dotenv-style config file. + +Default paths: + +```text +Linux: /etc/machine-env-service/env +macOS: /usr/local/etc/machine-env-service/env +``` + +Override with: + +```bash +MACHINE_ENV_CONFIG=/path/to/env +``` + +Minimum config: + +```env +INFISICAL_ACCESS_TOKEN= +INFISICAL_PROJECT_ID= +INFISICAL_ENVIRONMENT=prod + +KNOWN_SECRET_KEYS=FOO,BAR +METADATA_PORT=8675 +REFRESH_INTERVAL_SEC=60 +``` + +Optional machine metadata: + +```env +MACHINE_ID= +MACHINE_HOSTNAME= +MACHINE_LOCAL_HOSTNAME= +MACHINE_LOCAL_IPV4= +MACHINE_MAC= +MACHINE_ROLE=homelab-node +MACHINE_TAGS=site=home,tier=prod +USER_DATA= +USER_DATA_FILE= +``` + +If machine fields are empty, the daemon derives hostname, IPv4, MAC, and machine-id from the OS where possible. + +Secret allowlist variables are checked in this order: + +```text +KNOWN_SECRET_KEYS +EXPOSED_SECRET_KEYS +SECRET_ALLOWLIST +SECRET_WHITELIST +``` + +Values can be comma-separated or whitespace-separated. + +## Local Development + +Build: + +```bash +npm ci +npm run build +``` + +Run locally without binding `169.254.169.254:80`: + +```bash +NODE_ENV=dev LINK_LOCAL_LISTENER_ENABLED=false npm start +``` + +Request a token: + +```bash +TOKEN=$( + curl -fsS -X PUT \ + -H "X-aws-ec2-metadata-token-ttl-seconds: 60" \ + http://127.0.0.1:8675/latest/api/token +) +``` + +Fetch metadata: + +```bash +curl -fsS \ + -H "X-aws-ec2-metadata-token: $TOKEN" \ + http://127.0.0.1:8675/latest/meta-data/hostname +``` + +Fetch a secret: + +```bash +curl -fsS \ + -H "X-aws-ec2-metadata-token: $TOKEN" \ + http://127.0.0.1:8675/latest/meta-data/secrets/FOO +``` + +Or use: + +```bash +METADATA_BASE_URL=http://127.0.0.1:8675 ./examples/fetch-secret.sh FOO +``` + +## Ubuntu Install + +The included systemd units assume the app lives at `/opt/machine-env-service`. + +Install files: + +```bash +sudo mkdir -p /opt/machine-env-service +sudo chown -R "$USER:$USER" /opt/machine-env-service + +rsync -a \ + --exclude .git \ + --exclude node_modules \ + --exclude dist \ + --exclude env-vars \ + ./ /opt/machine-env-service/ + +cd /opt/machine-env-service +npm ci +npm run build +``` + +Create service user: + +```bash +sudo useradd --system --home /nonexistent --shell /usr/sbin/nologin machine-env || true +``` + +Create config: + +```bash +sudo install -d -o machine-env -g machine-env -m 0700 /etc/machine-env-service +sudo cp deploy/systemd/machine-env-service.env.example /etc/machine-env-service/env +sudo nano /etc/machine-env-service/env +sudo chown machine-env:machine-env /etc/machine-env-service/env +sudo chmod 0600 /etc/machine-env-service/env +``` + +Install and start systemd units: + +```bash +sudo cp deploy/systemd/machine-env-setup-link-local.service /etc/systemd/system/ +sudo cp deploy/systemd/machine-env-service.service /etc/systemd/system/ + +sudo systemctl daemon-reload +sudo systemctl enable --now machine-env-setup-link-local.service +sudo systemctl enable --now machine-env-service.service +``` + +Check logs: + +```bash +systemctl status machine-env-service.service +journalctl -u machine-env-service.service -f +``` + +Test the link-local endpoint: + +```bash +TOKEN=$( + curl -fsS -X PUT \ + -H "X-aws-ec2-metadata-token-ttl-seconds: 60" \ + http://169.254.169.254/latest/api/token +) + +curl -fsS \ + -H "X-aws-ec2-metadata-token: $TOKEN" \ + http://169.254.169.254/latest/meta-data/ +``` + +## macOS Install + +The included launchd plists assume: + +```text +App path: /opt/machine-env-service +Node path: /usr/local/bin/node +Config path: /usr/local/etc/machine-env-service/env +``` + +Check your Node path first: + +```bash +command -v node +``` + +If it is not `/usr/local/bin/node`, either update `deploy/launchd/us.dahyeon.machine-env-service.plist` before installing or create a system-visible symlink: + +```bash +sudo mkdir -p /usr/local/bin +sudo ln -sf "$(command -v node)" /usr/local/bin/node +``` + +When Node comes from `nvm`, the symlink is the quickest local setup. A Homebrew Node installed at a stable path is usually better for a long-lived daemon. + +Install files: + +```bash +sudo mkdir -p /opt/machine-env-service +sudo chown -R "$(id -un):admin" /opt/machine-env-service + +rsync -a \ + --exclude .git \ + --exclude node_modules \ + --exclude dist \ + --exclude env-vars \ + ./ /opt/machine-env-service/ + +cd /opt/machine-env-service +npm ci +npm run build +``` + +Create config: + +```bash +sudo install -d -m 0700 /usr/local/etc/machine-env-service +sudo cp deploy/launchd/machine-env-service.env.example /usr/local/etc/machine-env-service/env +sudo nano /usr/local/etc/machine-env-service/env +sudo chown root:wheel /usr/local/etc/machine-env-service/env +sudo chmod 0600 /usr/local/etc/machine-env-service/env +``` + +Install and start launchd daemons: + +```bash +sudo cp deploy/launchd/us.dahyeon.machine-env-setup-link-local.plist /Library/LaunchDaemons/ +sudo cp deploy/launchd/us.dahyeon.machine-env-service.plist /Library/LaunchDaemons/ + +sudo chown root:wheel /Library/LaunchDaemons/us.dahyeon.machine-env-*.plist +sudo chmod 0644 /Library/LaunchDaemons/us.dahyeon.machine-env-*.plist + +sudo launchctl bootstrap system /Library/LaunchDaemons/us.dahyeon.machine-env-setup-link-local.plist +sudo launchctl bootstrap system /Library/LaunchDaemons/us.dahyeon.machine-env-service.plist +``` + +Check logs: + +```bash +sudo launchctl print system/us.dahyeon.machine-env-service +tail -f /var/log/machine-env-service.log +tail -f /var/log/machine-env-service.err.log +``` + +Test: + +```bash +TOKEN=$( + curl -fsS -X PUT \ + -H "X-aws-ec2-metadata-token-ttl-seconds: 60" \ + http://169.254.169.254/latest/api/token +) + +curl -fsS \ + -H "X-aws-ec2-metadata-token: $TOKEN" \ + http://169.254.169.254/latest/meta-data/hostname +``` + +Docker Desktop on macOS usually cannot route container traffic to host `169.254.169.254`. Use the LAN listener instead: + +```text +http://host.docker.internal:8675/latest/meta-data/... +``` + +## Update + +Restarting the daemon invalidates issued IMDSv2 tokens. Clients should request a new token after an update. + +If `/opt/machine-env-service` is a git checkout: + +```bash +cd /opt/machine-env-service +git pull +npm ci +npm run build +``` + +If you deploy from another checkout: + +```bash +rsync -a --delete \ + --exclude .git \ + --exclude node_modules \ + --exclude dist \ + --exclude env-vars \ + ./ /opt/machine-env-service/ + +cd /opt/machine-env-service +npm ci +npm run build +``` + +Do not overwrite the machine config file: + +```text +Linux: /etc/machine-env-service/env +macOS: /usr/local/etc/machine-env-service/env +``` + +Restart after code-only updates: + +```bash +sudo systemctl restart machine-env-service.service +``` + +```bash +sudo launchctl kickstart -k system/us.dahyeon.machine-env-service +``` + +If systemd unit files changed: + +```bash +sudo cp deploy/systemd/machine-env-setup-link-local.service /etc/systemd/system/ +sudo cp deploy/systemd/machine-env-service.service /etc/systemd/system/ +sudo systemctl daemon-reload +sudo systemctl restart machine-env-setup-link-local.service +sudo systemctl restart machine-env-service.service +``` + +If launchd plist files changed: + +```bash +sudo cp deploy/launchd/us.dahyeon.machine-env-setup-link-local.plist /Library/LaunchDaemons/ +sudo cp deploy/launchd/us.dahyeon.machine-env-service.plist /Library/LaunchDaemons/ +sudo chown root:wheel /Library/LaunchDaemons/us.dahyeon.machine-env-*.plist +sudo chmod 0644 /Library/LaunchDaemons/us.dahyeon.machine-env-*.plist + +sudo launchctl bootout system /Library/LaunchDaemons/us.dahyeon.machine-env-service.plist 2>/dev/null || true +sudo launchctl bootout system /Library/LaunchDaemons/us.dahyeon.machine-env-setup-link-local.plist 2>/dev/null || true +sudo launchctl bootstrap system /Library/LaunchDaemons/us.dahyeon.machine-env-setup-link-local.plist +sudo launchctl bootstrap system /Library/LaunchDaemons/us.dahyeon.machine-env-service.plist +``` + +Check after updating: + +```bash +systemctl status machine-env-service.service +journalctl -u machine-env-service.service -n 100 +``` + +```bash +sudo launchctl print system/us.dahyeon.machine-env-service +tail -n 100 /var/log/machine-env-service.err.log +``` + +## Operations + +Restart: + +```bash +sudo systemctl restart machine-env-service.service +``` + +```bash +sudo launchctl kickstart -k system/us.dahyeon.machine-env-service +``` + +Stop: + +```bash +sudo systemctl stop machine-env-service.service +``` + +```bash +sudo launchctl bootout system /Library/LaunchDaemons/us.dahyeon.machine-env-service.plist +``` + +## Troubleshooting + +If `curl http://169.254.169.254/latest/api/token` fails with `Couldn't connect to server`, check the link-local alias and daemon separately: + +```bash +ifconfig lo0 | grep 169.254.169.254 +sudo launchctl print system/us.dahyeon.machine-env-service +``` + +If launchd shows `last exit code = 78: EX_CONFIG` and the plist points to `/usr/local/bin/node`, verify that Node exists there: + +```bash +ls -l /usr/local/bin/node +command -v node +``` + +Fix a missing `/usr/local/bin/node` with: + +```bash +sudo mkdir -p /usr/local/bin +sudo ln -sf "$(command -v node)" /usr/local/bin/node +sudo launchctl kickstart -k system/us.dahyeon.machine-env-service +``` + +Then retry token issuance. + +## Security Notes + +- Keep the config file mode at `0600`. +- Do not commit `env-vars/*.env`, production config files, or access tokens. +- Only allowlist secrets that should be readable by local machine workloads. +- Block `METADATA_PORT` from untrusted networks. +- Requests with `X-Forwarded-For` are rejected. +- Metadata requests require IMDSv2-style tokens; token TTL is `1..21600` seconds. diff --git a/deploy/launchd/machine-env-service.env.example b/deploy/launchd/machine-env-service.env.example new file mode 100644 index 0000000..1bbd766 --- /dev/null +++ b/deploy/launchd/machine-env-service.env.example @@ -0,0 +1,18 @@ +INFISICAL_ACCESS_TOKEN= +INFISICAL_PROJECT_ID= +INFISICAL_ENVIRONMENT=prod +INFISICAL_SITE_URL=https://secret-manager.dahyeon.us/ + +METADATA_PORT=8675 +REFRESH_INTERVAL_SEC=60 +ALLOW_SECRETS_BUNDLE=false +KNOWN_SECRET_KEYS=EXAMPLE_SECRET + +MACHINE_ID= +MACHINE_HOSTNAME= +MACHINE_LOCAL_HOSTNAME= +MACHINE_LOCAL_IPV4= +MACHINE_MAC= +MACHINE_ROLE=homelab-node +MACHINE_TAGS=site=home,tier=dev +USER_DATA= diff --git a/deploy/launchd/us.dahyeon.machine-env-service.plist b/deploy/launchd/us.dahyeon.machine-env-service.plist new file mode 100644 index 0000000..7560a4b --- /dev/null +++ b/deploy/launchd/us.dahyeon.machine-env-service.plist @@ -0,0 +1,31 @@ + + + + + Label + us.dahyeon.machine-env-service + ProgramArguments + + /usr/local/bin/node + /opt/machine-env-service/dist/daemon/main.js + + EnvironmentVariables + + MACHINE_ENV_CONFIG + /usr/local/etc/machine-env-service/env + + WorkingDirectory + /opt/machine-env-service + UserName + root + RunAtLoad + + KeepAlive + + StandardOutPath + /var/log/machine-env-service.log + StandardErrorPath + /var/log/machine-env-service.err.log + + diff --git a/deploy/launchd/us.dahyeon.machine-env-setup-link-local.plist b/deploy/launchd/us.dahyeon.machine-env-setup-link-local.plist new file mode 100644 index 0000000..cba4fce --- /dev/null +++ b/deploy/launchd/us.dahyeon.machine-env-setup-link-local.plist @@ -0,0 +1,23 @@ + + + + + Label + us.dahyeon.machine-env-setup-link-local + ProgramArguments + + /opt/machine-env-service/deploy/scripts/setup-link-local-macos.sh + + UserName + root + RunAtLoad + + LaunchOnlyOnce + + StandardOutPath + /var/log/machine-env-setup-link-local.log + StandardErrorPath + /var/log/machine-env-setup-link-local.err.log + + diff --git a/deploy/scripts/setup-link-local-linux.sh b/deploy/scripts/setup-link-local-linux.sh new file mode 100755 index 0000000..9616ba3 --- /dev/null +++ b/deploy/scripts/setup-link-local-linux.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +set -euo pipefail + +IFACE="${IMDS_DUMMY_INTERFACE:-imds-dummy}" +ADDR="${IMDS_LINK_LOCAL_ADDRESS:-169.254.169.254/32}" + +if ! command -v ip >/dev/null 2>&1; then + echo "ip command is required" >&2 + exit 1 +fi + +if ! ip link show "$IFACE" >/dev/null 2>&1; then + ip link add dev "$IFACE" type dummy +fi + +if ! ip addr show dev "$IFACE" | grep -q "169.254.169.254"; then + ip addr add "$ADDR" dev "$IFACE" +fi + +ip link set "$IFACE" up diff --git a/deploy/scripts/setup-link-local-macos.sh b/deploy/scripts/setup-link-local-macos.sh new file mode 100755 index 0000000..8d364d7 --- /dev/null +++ b/deploy/scripts/setup-link-local-macos.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -euo pipefail + +ADDR="${IMDS_LINK_LOCAL_ADDRESS:-169.254.169.254}" + +if ! command -v ifconfig >/dev/null 2>&1; then + echo "ifconfig command is required" >&2 + exit 1 +fi + +if ifconfig lo0 | grep -q "$ADDR"; then + exit 0 +fi + +ifconfig lo0 alias "$ADDR/32" up diff --git a/deploy/systemd/machine-env-service.env.example b/deploy/systemd/machine-env-service.env.example new file mode 100644 index 0000000..1bbd766 --- /dev/null +++ b/deploy/systemd/machine-env-service.env.example @@ -0,0 +1,18 @@ +INFISICAL_ACCESS_TOKEN= +INFISICAL_PROJECT_ID= +INFISICAL_ENVIRONMENT=prod +INFISICAL_SITE_URL=https://secret-manager.dahyeon.us/ + +METADATA_PORT=8675 +REFRESH_INTERVAL_SEC=60 +ALLOW_SECRETS_BUNDLE=false +KNOWN_SECRET_KEYS=EXAMPLE_SECRET + +MACHINE_ID= +MACHINE_HOSTNAME= +MACHINE_LOCAL_HOSTNAME= +MACHINE_LOCAL_IPV4= +MACHINE_MAC= +MACHINE_ROLE=homelab-node +MACHINE_TAGS=site=home,tier=dev +USER_DATA= diff --git a/deploy/systemd/machine-env-service.service b/deploy/systemd/machine-env-service.service new file mode 100644 index 0000000..5d43fc2 --- /dev/null +++ b/deploy/systemd/machine-env-service.service @@ -0,0 +1,26 @@ +[Unit] +Description=Machine Env Metadata Service +Documentation=https://github.com/dahyeon/machine-env-service +After=network-online.target machine-env-setup-link-local.service +Wants=network-online.target +Requires=machine-env-setup-link-local.service + +[Service] +Type=simple +User=machine-env +Group=machine-env +WorkingDirectory=/opt/machine-env-service +Environment=MACHINE_ENV_CONFIG=/etc/machine-env-service/env +ExecStart=/usr/bin/node /opt/machine-env-service/dist/daemon/main.js +Restart=on-failure +RestartSec=5 +AmbientCapabilities=CAP_NET_BIND_SERVICE +CapabilityBoundingSet=CAP_NET_BIND_SERVICE +NoNewPrivileges=true +ProtectSystem=strict +ProtectHome=true +PrivateTmp=true +ReadWritePaths=/etc/machine-env-service + +[Install] +WantedBy=multi-user.target diff --git a/deploy/systemd/machine-env-setup-link-local.service b/deploy/systemd/machine-env-setup-link-local.service new file mode 100644 index 0000000..dea2441 --- /dev/null +++ b/deploy/systemd/machine-env-setup-link-local.service @@ -0,0 +1,13 @@ +[Unit] +Description=Configure link-local IMDS address for Machine Env Service +DefaultDependencies=no +After=local-fs.target +Before=network-online.target machine-env-service.service + +[Service] +Type=oneshot +RemainAfterExit=true +ExecStart=/opt/machine-env-service/deploy/scripts/setup-link-local-linux.sh + +[Install] +WantedBy=multi-user.target diff --git a/examples/fetch-secret.sh b/examples/fetch-secret.sh new file mode 100755 index 0000000..ddba108 --- /dev/null +++ b/examples/fetch-secret.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -euo pipefail + +BASE_URL="${METADATA_BASE_URL:-http://169.254.169.254}" +SECRET_KEY="${1:-EXAMPLE_SECRET}" + +TOKEN="$( + curl -fsS \ + -X PUT \ + -H "X-aws-ec2-metadata-token-ttl-seconds: 60" \ + "$BASE_URL/latest/api/token" +)" + +curl -fsS \ + -H "X-aws-ec2-metadata-token: $TOKEN" \ + "$BASE_URL/latest/meta-data/secrets/$SECRET_KEY" diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..ae6abfa --- /dev/null +++ b/package-lock.json @@ -0,0 +1,2012 @@ +{ + "name": "machine-env-service", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "machine-env-service", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "@infisical/sdk": "^5.0.2" + }, + "bin": { + "machine-env-service": "dist/daemon/main.js" + }, + "devDependencies": { + "@types/node": "^25.6.0", + "typescript": "^6.0.3" + } + }, + "node_modules/@aws-crypto/sha256-browser": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/@aws-crypto/sha256-browser/-/sha256-browser-5.2.0.tgz", + "integrity": "sha512-AXfN/lGotSQwu6HNcEsIASo7kWXZ5HYWvfOmSNKDsEqC4OashTp8alTmaz+F7TC2L083SFv5RdB+qU3Vs1kZqw==", + "license": "Apache-2.0", + "dependencies": { + "@aws-crypto/sha256-js": "^5.2.0", + "@aws-crypto/supports-web-crypto": "^5.2.0", + "@aws-crypto/util": "^5.2.0", + "@aws-sdk/types": "^3.222.0", + "@aws-sdk/util-locate-window": "^3.0.0", + "@smithy/util-utf8": "^2.0.0", + "tslib": "^2.6.2" + } + }, + "node_modules/@aws-crypto/sha256-js": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/@aws-crypto/sha256-js/-/sha256-js-5.2.0.tgz", + "integrity": "sha512-FFQQyu7edu4ufvIZ+OadFpHHOt+eSTBaYaki44c+akjg7qZg9oOQeLlk77F6tSYqjDAFClrHJk9tMf0HdVyOvA==", + "license": "Apache-2.0", + "dependencies": { + "@aws-crypto/util": "^5.2.0", + "@aws-sdk/types": "^3.222.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@aws-crypto/supports-web-crypto": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/@aws-crypto/supports-web-crypto/-/supports-web-crypto-5.2.0.tgz", + "integrity": "sha512-iAvUotm021kM33eCdNfwIN//F77/IADDSs58i+MDaOqFrVjZo9bAal0NK7HurRuWLLpF1iLX7gbWrjHjeo+YFg==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.6.2" + } + }, + "node_modules/@aws-crypto/util": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/@aws-crypto/util/-/util-5.2.0.tgz", + "integrity": "sha512-4RkU9EsI6ZpBve5fseQlGNUWKMa1RLPQ1dnjnQoe07ldfIzcsGb5hC5W0Dm7u423KWzawlrpbjXBrXCEv9zazQ==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/types": "^3.222.0", + "@smithy/util-utf8": "^2.0.0", + "tslib": "^2.6.2" + } + }, + "node_modules/@aws-sdk/client-cognito-identity": { + "version": "3.993.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-cognito-identity/-/client-cognito-identity-3.993.0.tgz", + "integrity": "sha512-7Ne3Yk/bgQPVebAkv7W+RfhiwTRSbfER9BtbhOa2w/+dIr902LrJf6vrZlxiqaJbGj2ALx8M+ZK1YIHVxSwu9A==", + "license": "Apache-2.0", + "dependencies": { + "@aws-crypto/sha256-browser": "5.2.0", + "@aws-crypto/sha256-js": "5.2.0", + "@aws-sdk/core": "^3.973.11", + "@aws-sdk/credential-provider-node": "^3.972.10", + "@aws-sdk/middleware-host-header": "^3.972.3", + "@aws-sdk/middleware-logger": "^3.972.3", + "@aws-sdk/middleware-recursion-detection": "^3.972.3", + "@aws-sdk/middleware-user-agent": "^3.972.11", + "@aws-sdk/region-config-resolver": "^3.972.3", + "@aws-sdk/types": "^3.973.1", + "@aws-sdk/util-endpoints": "3.993.0", + "@aws-sdk/util-user-agent-browser": "^3.972.3", + "@aws-sdk/util-user-agent-node": "^3.972.9", + "@smithy/config-resolver": "^4.4.6", + "@smithy/core": "^3.23.2", + "@smithy/fetch-http-handler": "^5.3.9", + "@smithy/hash-node": "^4.2.8", + "@smithy/invalid-dependency": "^4.2.8", + "@smithy/middleware-content-length": "^4.2.8", + "@smithy/middleware-endpoint": "^4.4.16", + "@smithy/middleware-retry": "^4.4.33", + "@smithy/middleware-serde": "^4.2.9", + "@smithy/middleware-stack": "^4.2.8", + "@smithy/node-config-provider": "^4.3.8", + "@smithy/node-http-handler": "^4.4.10", + "@smithy/protocol-http": "^5.3.8", + "@smithy/smithy-client": "^4.11.5", + "@smithy/types": "^4.12.0", + "@smithy/url-parser": "^4.2.8", + "@smithy/util-base64": "^4.3.0", + "@smithy/util-body-length-browser": "^4.2.0", + "@smithy/util-body-length-node": "^4.2.1", + "@smithy/util-defaults-mode-browser": "^4.3.32", + "@smithy/util-defaults-mode-node": "^4.2.35", + "@smithy/util-endpoints": "^3.2.8", + "@smithy/util-middleware": "^4.2.8", + "@smithy/util-retry": "^4.2.8", + "@smithy/util-utf8": "^4.2.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/client-cognito-identity/node_modules/@smithy/util-utf8": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-4.2.2.tgz", + "integrity": "sha512-75MeYpjdWRe8M5E3AW0O4Cx3UadweS+cwdXjwYGBW5h/gxxnbeZ877sLPX/ZJA9GVTlL/qG0dXP29JWFCD1Ayw==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/util-buffer-from": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@aws-sdk/core": { + "version": "3.974.7", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.974.7.tgz", + "integrity": "sha512-YhRC90ofz5oolTJZlA8voU/oUrCB2azi8Usx51k8hhB5LpWbYQMMXKUqSqkoL0Cru+RQJgWTHpAfEDDIwfUhJw==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/types": "^3.973.8", + "@aws-sdk/xml-builder": "^3.972.22", + "@smithy/core": "^3.23.17", + "@smithy/node-config-provider": "^4.3.14", + "@smithy/property-provider": "^4.2.14", + "@smithy/protocol-http": "^5.3.14", + "@smithy/signature-v4": "^5.3.14", + "@smithy/smithy-client": "^4.12.13", + "@smithy/types": "^4.14.1", + "@smithy/util-base64": "^4.3.2", + "@smithy/util-middleware": "^4.2.14", + "@smithy/util-retry": "^4.3.6", + "@smithy/util-utf8": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/core/node_modules/@smithy/util-utf8": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-4.2.2.tgz", + "integrity": "sha512-75MeYpjdWRe8M5E3AW0O4Cx3UadweS+cwdXjwYGBW5h/gxxnbeZ877sLPX/ZJA9GVTlL/qG0dXP29JWFCD1Ayw==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/util-buffer-from": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-cognito-identity": { + "version": "3.972.30", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-cognito-identity/-/credential-provider-cognito-identity-3.972.30.tgz", + "integrity": "sha512-kzRNS2/J+GCJyVzI5dKoFvSKojEpM1lxZXh9AumuH1v80P4qsH6aFor6bhWUlm/OLYjTI5yo0doBw8+vF+v+mw==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/nested-clients": "^3.997.5", + "@aws-sdk/types": "^3.973.8", + "@smithy/property-provider": "^4.2.14", + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-cognito-identity/node_modules/@aws-sdk/nested-clients": { + "version": "3.997.5", + "resolved": "https://registry.npmjs.org/@aws-sdk/nested-clients/-/nested-clients-3.997.5.tgz", + "integrity": "sha512-jGFr6DxtcMTmzOkG/a0jCZYv4BBDmeNYVeO+/memSoDkYCJu4Y58xviYmzwJfYyIVSts+X/BVjJm1uGBnwHEMg==", + "license": "Apache-2.0", + "dependencies": { + "@aws-crypto/sha256-browser": "5.2.0", + "@aws-crypto/sha256-js": "5.2.0", + "@aws-sdk/core": "^3.974.7", + "@aws-sdk/middleware-host-header": "^3.972.10", + "@aws-sdk/middleware-logger": "^3.972.10", + "@aws-sdk/middleware-recursion-detection": "^3.972.11", + "@aws-sdk/middleware-user-agent": "^3.972.37", + "@aws-sdk/region-config-resolver": "^3.972.13", + "@aws-sdk/signature-v4-multi-region": "^3.996.24", + "@aws-sdk/types": "^3.973.8", + "@aws-sdk/util-endpoints": "^3.996.8", + "@aws-sdk/util-user-agent-browser": "^3.972.10", + "@aws-sdk/util-user-agent-node": "^3.973.23", + "@smithy/config-resolver": "^4.4.17", + "@smithy/core": "^3.23.17", + "@smithy/fetch-http-handler": "^5.3.17", + "@smithy/hash-node": "^4.2.14", + "@smithy/invalid-dependency": "^4.2.14", + "@smithy/middleware-content-length": "^4.2.14", + "@smithy/middleware-endpoint": "^4.4.32", + "@smithy/middleware-retry": "^4.5.7", + "@smithy/middleware-serde": "^4.2.20", + "@smithy/middleware-stack": "^4.2.14", + "@smithy/node-config-provider": "^4.3.14", + "@smithy/node-http-handler": "^4.6.1", + "@smithy/protocol-http": "^5.3.14", + "@smithy/smithy-client": "^4.12.13", + "@smithy/types": "^4.14.1", + "@smithy/url-parser": "^4.2.14", + "@smithy/util-base64": "^4.3.2", + "@smithy/util-body-length-browser": "^4.2.2", + "@smithy/util-body-length-node": "^4.2.3", + "@smithy/util-defaults-mode-browser": "^4.3.49", + "@smithy/util-defaults-mode-node": "^4.2.54", + "@smithy/util-endpoints": "^3.4.2", + "@smithy/util-middleware": "^4.2.14", + "@smithy/util-retry": "^4.3.6", + "@smithy/util-utf8": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-cognito-identity/node_modules/@aws-sdk/util-endpoints": { + "version": "3.996.8", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.996.8.tgz", + "integrity": "sha512-oOZHcRDihk5iEe5V25NVWg45b3qEA8OpHWVdU/XQh8Zj4heVPAJqWvMphQnU7LkufmUo10EpvFPZuQMiFLJK3g==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/types": "^3.973.8", + "@smithy/types": "^4.14.1", + "@smithy/url-parser": "^4.2.14", + "@smithy/util-endpoints": "^3.4.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-cognito-identity/node_modules/@smithy/util-utf8": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-4.2.2.tgz", + "integrity": "sha512-75MeYpjdWRe8M5E3AW0O4Cx3UadweS+cwdXjwYGBW5h/gxxnbeZ877sLPX/ZJA9GVTlL/qG0dXP29JWFCD1Ayw==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/util-buffer-from": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-env": { + "version": "3.972.33", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-env/-/credential-provider-env-3.972.33.tgz", + "integrity": "sha512-bJV7eViSJV6GSuuN+VIdNVPdwPsNSf75BiC2v5alPrjR/OCcqgKwSZInKbDFz9mNeizldsyf67jt6YSIiv53Cw==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.974.7", + "@aws-sdk/types": "^3.973.8", + "@smithy/property-provider": "^4.2.14", + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-http": { + "version": "3.972.35", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-http/-/credential-provider-http-3.972.35.tgz", + "integrity": "sha512-x/BQGEIdq0oI+4WxLjKmnQvT7CnF9r8ezdGt7wXwxb7ckHXQz0Zmgxt8v3Ne0JaT3R5YefmuybHX6E8EnsDXyA==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.974.7", + "@aws-sdk/types": "^3.973.8", + "@smithy/fetch-http-handler": "^5.3.17", + "@smithy/node-http-handler": "^4.6.1", + "@smithy/property-provider": "^4.2.14", + "@smithy/protocol-http": "^5.3.14", + "@smithy/smithy-client": "^4.12.13", + "@smithy/types": "^4.14.1", + "@smithy/util-stream": "^4.5.25", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-ini": { + "version": "3.972.37", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.972.37.tgz", + "integrity": "sha512-eUTpmWfd/BKsq9medhCRcu+GRAhFP2Zrn7/2jKDHHOOjCkhrMoTp/t4cEthqFoG7gE0VGp5wUxrXTdvBCmSmJg==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.974.7", + "@aws-sdk/credential-provider-env": "^3.972.33", + "@aws-sdk/credential-provider-http": "^3.972.35", + "@aws-sdk/credential-provider-login": "^3.972.37", + "@aws-sdk/credential-provider-process": "^3.972.33", + "@aws-sdk/credential-provider-sso": "^3.972.37", + "@aws-sdk/credential-provider-web-identity": "^3.972.37", + "@aws-sdk/nested-clients": "^3.997.5", + "@aws-sdk/types": "^3.973.8", + "@smithy/credential-provider-imds": "^4.2.14", + "@smithy/property-provider": "^4.2.14", + "@smithy/shared-ini-file-loader": "^4.4.9", + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-ini/node_modules/@aws-sdk/nested-clients": { + "version": "3.997.5", + "resolved": "https://registry.npmjs.org/@aws-sdk/nested-clients/-/nested-clients-3.997.5.tgz", + "integrity": "sha512-jGFr6DxtcMTmzOkG/a0jCZYv4BBDmeNYVeO+/memSoDkYCJu4Y58xviYmzwJfYyIVSts+X/BVjJm1uGBnwHEMg==", + "license": "Apache-2.0", + "dependencies": { + "@aws-crypto/sha256-browser": "5.2.0", + "@aws-crypto/sha256-js": "5.2.0", + "@aws-sdk/core": "^3.974.7", + "@aws-sdk/middleware-host-header": "^3.972.10", + "@aws-sdk/middleware-logger": "^3.972.10", + "@aws-sdk/middleware-recursion-detection": "^3.972.11", + "@aws-sdk/middleware-user-agent": "^3.972.37", + "@aws-sdk/region-config-resolver": "^3.972.13", + "@aws-sdk/signature-v4-multi-region": "^3.996.24", + "@aws-sdk/types": "^3.973.8", + "@aws-sdk/util-endpoints": "^3.996.8", + "@aws-sdk/util-user-agent-browser": "^3.972.10", + "@aws-sdk/util-user-agent-node": "^3.973.23", + "@smithy/config-resolver": "^4.4.17", + "@smithy/core": "^3.23.17", + "@smithy/fetch-http-handler": "^5.3.17", + "@smithy/hash-node": "^4.2.14", + "@smithy/invalid-dependency": "^4.2.14", + "@smithy/middleware-content-length": "^4.2.14", + "@smithy/middleware-endpoint": "^4.4.32", + "@smithy/middleware-retry": "^4.5.7", + "@smithy/middleware-serde": "^4.2.20", + "@smithy/middleware-stack": "^4.2.14", + "@smithy/node-config-provider": "^4.3.14", + "@smithy/node-http-handler": "^4.6.1", + "@smithy/protocol-http": "^5.3.14", + "@smithy/smithy-client": "^4.12.13", + "@smithy/types": "^4.14.1", + "@smithy/url-parser": "^4.2.14", + "@smithy/util-base64": "^4.3.2", + "@smithy/util-body-length-browser": "^4.2.2", + "@smithy/util-body-length-node": "^4.2.3", + "@smithy/util-defaults-mode-browser": "^4.3.49", + "@smithy/util-defaults-mode-node": "^4.2.54", + "@smithy/util-endpoints": "^3.4.2", + "@smithy/util-middleware": "^4.2.14", + "@smithy/util-retry": "^4.3.6", + "@smithy/util-utf8": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-ini/node_modules/@aws-sdk/util-endpoints": { + "version": "3.996.8", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.996.8.tgz", + "integrity": "sha512-oOZHcRDihk5iEe5V25NVWg45b3qEA8OpHWVdU/XQh8Zj4heVPAJqWvMphQnU7LkufmUo10EpvFPZuQMiFLJK3g==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/types": "^3.973.8", + "@smithy/types": "^4.14.1", + "@smithy/url-parser": "^4.2.14", + "@smithy/util-endpoints": "^3.4.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-ini/node_modules/@smithy/util-utf8": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-4.2.2.tgz", + "integrity": "sha512-75MeYpjdWRe8M5E3AW0O4Cx3UadweS+cwdXjwYGBW5h/gxxnbeZ877sLPX/ZJA9GVTlL/qG0dXP29JWFCD1Ayw==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/util-buffer-from": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-login": { + "version": "3.972.37", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-login/-/credential-provider-login-3.972.37.tgz", + "integrity": "sha512-Ty68y8ISSC+g5Q3D0K8uAaoINwvfaOslnNpsF/LgVUxyosYXHawcK2yV4HLXDVugiTTYLQfJfcw0ce5meAGkKw==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.974.7", + "@aws-sdk/nested-clients": "^3.997.5", + "@aws-sdk/types": "^3.973.8", + "@smithy/property-provider": "^4.2.14", + "@smithy/protocol-http": "^5.3.14", + "@smithy/shared-ini-file-loader": "^4.4.9", + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-login/node_modules/@aws-sdk/nested-clients": { + "version": "3.997.5", + "resolved": "https://registry.npmjs.org/@aws-sdk/nested-clients/-/nested-clients-3.997.5.tgz", + "integrity": "sha512-jGFr6DxtcMTmzOkG/a0jCZYv4BBDmeNYVeO+/memSoDkYCJu4Y58xviYmzwJfYyIVSts+X/BVjJm1uGBnwHEMg==", + "license": "Apache-2.0", + "dependencies": { + "@aws-crypto/sha256-browser": "5.2.0", + "@aws-crypto/sha256-js": "5.2.0", + "@aws-sdk/core": "^3.974.7", + "@aws-sdk/middleware-host-header": "^3.972.10", + "@aws-sdk/middleware-logger": "^3.972.10", + "@aws-sdk/middleware-recursion-detection": "^3.972.11", + "@aws-sdk/middleware-user-agent": "^3.972.37", + "@aws-sdk/region-config-resolver": "^3.972.13", + "@aws-sdk/signature-v4-multi-region": "^3.996.24", + "@aws-sdk/types": "^3.973.8", + "@aws-sdk/util-endpoints": "^3.996.8", + "@aws-sdk/util-user-agent-browser": "^3.972.10", + "@aws-sdk/util-user-agent-node": "^3.973.23", + "@smithy/config-resolver": "^4.4.17", + "@smithy/core": "^3.23.17", + "@smithy/fetch-http-handler": "^5.3.17", + "@smithy/hash-node": "^4.2.14", + "@smithy/invalid-dependency": "^4.2.14", + "@smithy/middleware-content-length": "^4.2.14", + "@smithy/middleware-endpoint": "^4.4.32", + "@smithy/middleware-retry": "^4.5.7", + "@smithy/middleware-serde": "^4.2.20", + "@smithy/middleware-stack": "^4.2.14", + "@smithy/node-config-provider": "^4.3.14", + "@smithy/node-http-handler": "^4.6.1", + "@smithy/protocol-http": "^5.3.14", + "@smithy/smithy-client": "^4.12.13", + "@smithy/types": "^4.14.1", + "@smithy/url-parser": "^4.2.14", + "@smithy/util-base64": "^4.3.2", + "@smithy/util-body-length-browser": "^4.2.2", + "@smithy/util-body-length-node": "^4.2.3", + "@smithy/util-defaults-mode-browser": "^4.3.49", + "@smithy/util-defaults-mode-node": "^4.2.54", + "@smithy/util-endpoints": "^3.4.2", + "@smithy/util-middleware": "^4.2.14", + "@smithy/util-retry": "^4.3.6", + "@smithy/util-utf8": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-login/node_modules/@aws-sdk/util-endpoints": { + "version": "3.996.8", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.996.8.tgz", + "integrity": "sha512-oOZHcRDihk5iEe5V25NVWg45b3qEA8OpHWVdU/XQh8Zj4heVPAJqWvMphQnU7LkufmUo10EpvFPZuQMiFLJK3g==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/types": "^3.973.8", + "@smithy/types": "^4.14.1", + "@smithy/url-parser": "^4.2.14", + "@smithy/util-endpoints": "^3.4.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-login/node_modules/@smithy/util-utf8": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-4.2.2.tgz", + "integrity": "sha512-75MeYpjdWRe8M5E3AW0O4Cx3UadweS+cwdXjwYGBW5h/gxxnbeZ877sLPX/ZJA9GVTlL/qG0dXP29JWFCD1Ayw==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/util-buffer-from": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-node": { + "version": "3.972.38", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-node/-/credential-provider-node-3.972.38.tgz", + "integrity": "sha512-BQ9XYnBDVxR2HuV5huXYQYF/PZMTsY+EnwfGnCU2cA8Zw63XpkOtPY8WqiMIZMQCrKPQQEiFURS/o9CIolRLqg==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/credential-provider-env": "^3.972.33", + "@aws-sdk/credential-provider-http": "^3.972.35", + "@aws-sdk/credential-provider-ini": "^3.972.37", + "@aws-sdk/credential-provider-process": "^3.972.33", + "@aws-sdk/credential-provider-sso": "^3.972.37", + "@aws-sdk/credential-provider-web-identity": "^3.972.37", + "@aws-sdk/types": "^3.973.8", + "@smithy/credential-provider-imds": "^4.2.14", + "@smithy/property-provider": "^4.2.14", + "@smithy/shared-ini-file-loader": "^4.4.9", + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-process": { + "version": "3.972.33", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-process/-/credential-provider-process-3.972.33.tgz", + "integrity": "sha512-yfjGksI9WQbdMObb0VeLXqzTLI+a0qXLJT9gCDiv0+X/xjPpI3mTz6a5FibrhpuEKIe0gSgvs3MaoFZy5cx4WA==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.974.7", + "@aws-sdk/types": "^3.973.8", + "@smithy/property-provider": "^4.2.14", + "@smithy/shared-ini-file-loader": "^4.4.9", + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-sso": { + "version": "3.972.37", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.972.37.tgz", + "integrity": "sha512-fpwE+20ntpp3i9Xb9vUuQfXLDKYHH+5I2V+ZG96SX1nBzrruhy10RXDgmN7t1etOz3c55stlA3TeQASUA451NQ==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.974.7", + "@aws-sdk/nested-clients": "^3.997.5", + "@aws-sdk/token-providers": "3.1039.0", + "@aws-sdk/types": "^3.973.8", + "@smithy/property-provider": "^4.2.14", + "@smithy/shared-ini-file-loader": "^4.4.9", + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/nested-clients": { + "version": "3.997.5", + "resolved": "https://registry.npmjs.org/@aws-sdk/nested-clients/-/nested-clients-3.997.5.tgz", + "integrity": "sha512-jGFr6DxtcMTmzOkG/a0jCZYv4BBDmeNYVeO+/memSoDkYCJu4Y58xviYmzwJfYyIVSts+X/BVjJm1uGBnwHEMg==", + "license": "Apache-2.0", + "dependencies": { + "@aws-crypto/sha256-browser": "5.2.0", + "@aws-crypto/sha256-js": "5.2.0", + "@aws-sdk/core": "^3.974.7", + "@aws-sdk/middleware-host-header": "^3.972.10", + "@aws-sdk/middleware-logger": "^3.972.10", + "@aws-sdk/middleware-recursion-detection": "^3.972.11", + "@aws-sdk/middleware-user-agent": "^3.972.37", + "@aws-sdk/region-config-resolver": "^3.972.13", + "@aws-sdk/signature-v4-multi-region": "^3.996.24", + "@aws-sdk/types": "^3.973.8", + "@aws-sdk/util-endpoints": "^3.996.8", + "@aws-sdk/util-user-agent-browser": "^3.972.10", + "@aws-sdk/util-user-agent-node": "^3.973.23", + "@smithy/config-resolver": "^4.4.17", + "@smithy/core": "^3.23.17", + "@smithy/fetch-http-handler": "^5.3.17", + "@smithy/hash-node": "^4.2.14", + "@smithy/invalid-dependency": "^4.2.14", + "@smithy/middleware-content-length": "^4.2.14", + "@smithy/middleware-endpoint": "^4.4.32", + "@smithy/middleware-retry": "^4.5.7", + "@smithy/middleware-serde": "^4.2.20", + "@smithy/middleware-stack": "^4.2.14", + "@smithy/node-config-provider": "^4.3.14", + "@smithy/node-http-handler": "^4.6.1", + "@smithy/protocol-http": "^5.3.14", + "@smithy/smithy-client": "^4.12.13", + "@smithy/types": "^4.14.1", + "@smithy/url-parser": "^4.2.14", + "@smithy/util-base64": "^4.3.2", + "@smithy/util-body-length-browser": "^4.2.2", + "@smithy/util-body-length-node": "^4.2.3", + "@smithy/util-defaults-mode-browser": "^4.3.49", + "@smithy/util-defaults-mode-node": "^4.2.54", + "@smithy/util-endpoints": "^3.4.2", + "@smithy/util-middleware": "^4.2.14", + "@smithy/util-retry": "^4.3.6", + "@smithy/util-utf8": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/util-endpoints": { + "version": "3.996.8", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.996.8.tgz", + "integrity": "sha512-oOZHcRDihk5iEe5V25NVWg45b3qEA8OpHWVdU/XQh8Zj4heVPAJqWvMphQnU7LkufmUo10EpvFPZuQMiFLJK3g==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/types": "^3.973.8", + "@smithy/types": "^4.14.1", + "@smithy/url-parser": "^4.2.14", + "@smithy/util-endpoints": "^3.4.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-sso/node_modules/@smithy/util-utf8": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-4.2.2.tgz", + "integrity": "sha512-75MeYpjdWRe8M5E3AW0O4Cx3UadweS+cwdXjwYGBW5h/gxxnbeZ877sLPX/ZJA9GVTlL/qG0dXP29JWFCD1Ayw==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/util-buffer-from": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-web-identity": { + "version": "3.972.37", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-web-identity/-/credential-provider-web-identity-3.972.37.tgz", + "integrity": "sha512-aryawqyebf+3WhAFNHfF62rekFpYtVcVN7dQ89qnAWsa4n5hJst8qBG6gXC24WHtW7Nnhkf9ScYnjwo0Brn3bw==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.974.7", + "@aws-sdk/nested-clients": "^3.997.5", + "@aws-sdk/types": "^3.973.8", + "@smithy/property-provider": "^4.2.14", + "@smithy/shared-ini-file-loader": "^4.4.9", + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-web-identity/node_modules/@aws-sdk/nested-clients": { + "version": "3.997.5", + "resolved": "https://registry.npmjs.org/@aws-sdk/nested-clients/-/nested-clients-3.997.5.tgz", + "integrity": "sha512-jGFr6DxtcMTmzOkG/a0jCZYv4BBDmeNYVeO+/memSoDkYCJu4Y58xviYmzwJfYyIVSts+X/BVjJm1uGBnwHEMg==", + "license": "Apache-2.0", + "dependencies": { + "@aws-crypto/sha256-browser": "5.2.0", + "@aws-crypto/sha256-js": "5.2.0", + "@aws-sdk/core": "^3.974.7", + "@aws-sdk/middleware-host-header": "^3.972.10", + "@aws-sdk/middleware-logger": "^3.972.10", + "@aws-sdk/middleware-recursion-detection": "^3.972.11", + "@aws-sdk/middleware-user-agent": "^3.972.37", + "@aws-sdk/region-config-resolver": "^3.972.13", + "@aws-sdk/signature-v4-multi-region": "^3.996.24", + "@aws-sdk/types": "^3.973.8", + "@aws-sdk/util-endpoints": "^3.996.8", + "@aws-sdk/util-user-agent-browser": "^3.972.10", + "@aws-sdk/util-user-agent-node": "^3.973.23", + "@smithy/config-resolver": "^4.4.17", + "@smithy/core": "^3.23.17", + "@smithy/fetch-http-handler": "^5.3.17", + "@smithy/hash-node": "^4.2.14", + "@smithy/invalid-dependency": "^4.2.14", + "@smithy/middleware-content-length": "^4.2.14", + "@smithy/middleware-endpoint": "^4.4.32", + "@smithy/middleware-retry": "^4.5.7", + "@smithy/middleware-serde": "^4.2.20", + "@smithy/middleware-stack": "^4.2.14", + "@smithy/node-config-provider": "^4.3.14", + "@smithy/node-http-handler": "^4.6.1", + "@smithy/protocol-http": "^5.3.14", + "@smithy/smithy-client": "^4.12.13", + "@smithy/types": "^4.14.1", + "@smithy/url-parser": "^4.2.14", + "@smithy/util-base64": "^4.3.2", + "@smithy/util-body-length-browser": "^4.2.2", + "@smithy/util-body-length-node": "^4.2.3", + "@smithy/util-defaults-mode-browser": "^4.3.49", + "@smithy/util-defaults-mode-node": "^4.2.54", + "@smithy/util-endpoints": "^3.4.2", + "@smithy/util-middleware": "^4.2.14", + "@smithy/util-retry": "^4.3.6", + "@smithy/util-utf8": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-web-identity/node_modules/@aws-sdk/util-endpoints": { + "version": "3.996.8", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.996.8.tgz", + "integrity": "sha512-oOZHcRDihk5iEe5V25NVWg45b3qEA8OpHWVdU/XQh8Zj4heVPAJqWvMphQnU7LkufmUo10EpvFPZuQMiFLJK3g==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/types": "^3.973.8", + "@smithy/types": "^4.14.1", + "@smithy/url-parser": "^4.2.14", + "@smithy/util-endpoints": "^3.4.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/credential-provider-web-identity/node_modules/@smithy/util-utf8": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-4.2.2.tgz", + "integrity": "sha512-75MeYpjdWRe8M5E3AW0O4Cx3UadweS+cwdXjwYGBW5h/gxxnbeZ877sLPX/ZJA9GVTlL/qG0dXP29JWFCD1Ayw==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/util-buffer-from": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@aws-sdk/credential-providers": { + "version": "3.993.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-providers/-/credential-providers-3.993.0.tgz", + "integrity": "sha512-1M/nukgPSLqe9krzOKHnE8OylUaKAiokAV3xRLdeExVHcRE7WG5uzCTKWTj1imKvPjDqXq/FWhlbbdWIn7xIwA==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/client-cognito-identity": "3.993.0", + "@aws-sdk/core": "^3.973.11", + "@aws-sdk/credential-provider-cognito-identity": "^3.972.3", + "@aws-sdk/credential-provider-env": "^3.972.9", + "@aws-sdk/credential-provider-http": "^3.972.11", + "@aws-sdk/credential-provider-ini": "^3.972.9", + "@aws-sdk/credential-provider-login": "^3.972.9", + "@aws-sdk/credential-provider-node": "^3.972.10", + "@aws-sdk/credential-provider-process": "^3.972.9", + "@aws-sdk/credential-provider-sso": "^3.972.9", + "@aws-sdk/credential-provider-web-identity": "^3.972.9", + "@aws-sdk/nested-clients": "3.993.0", + "@aws-sdk/types": "^3.973.1", + "@smithy/config-resolver": "^4.4.6", + "@smithy/core": "^3.23.2", + "@smithy/credential-provider-imds": "^4.2.8", + "@smithy/node-config-provider": "^4.3.8", + "@smithy/property-provider": "^4.2.8", + "@smithy/types": "^4.12.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/middleware-host-header": { + "version": "3.972.10", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-host-header/-/middleware-host-header-3.972.10.tgz", + "integrity": "sha512-IJSsIMeVQ8MMCPbuh1AbltkFhLBLXn7aejzfX5YKT/VLDHn++Dcz8886tXckE+wQssyPUhaXrJhdakO2VilRhg==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/types": "^3.973.8", + "@smithy/protocol-http": "^5.3.14", + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/middleware-logger": { + "version": "3.972.10", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-logger/-/middleware-logger-3.972.10.tgz", + "integrity": "sha512-OOuGvvz1Dm20SjZo5oEBePFqxt5nf8AwkNDSyUHvD9/bfNASmstcYxFAHUowy4n6Io7mWUZ04JURZwSBvyQanQ==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/types": "^3.973.8", + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/middleware-recursion-detection": { + "version": "3.972.11", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-recursion-detection/-/middleware-recursion-detection-3.972.11.tgz", + "integrity": "sha512-+zz6f79Kj9V5qFK2P+D8Ehjnw4AhphAlCAsPjUqEcInA9umtSSKMrHbSagEeOIsDNuvVrH98bjRHcyQukTrhaQ==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/types": "^3.973.8", + "@aws/lambda-invoke-store": "^0.2.2", + "@smithy/protocol-http": "^5.3.14", + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/middleware-sdk-s3": { + "version": "3.972.36", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-sdk-s3/-/middleware-sdk-s3-3.972.36.tgz", + "integrity": "sha512-YhPix+0x/MdQrb1Ug1GDKeS5fqylIy+naz800asX8II4jqfTk2KY2KhmmYCwZcky8YWtRQQwWCGdoqeAnip8Uw==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.974.7", + "@aws-sdk/types": "^3.973.8", + "@aws-sdk/util-arn-parser": "^3.972.3", + "@smithy/core": "^3.23.17", + "@smithy/node-config-provider": "^4.3.14", + "@smithy/protocol-http": "^5.3.14", + "@smithy/signature-v4": "^5.3.14", + "@smithy/smithy-client": "^4.12.13", + "@smithy/types": "^4.14.1", + "@smithy/util-config-provider": "^4.2.2", + "@smithy/util-middleware": "^4.2.14", + "@smithy/util-stream": "^4.5.25", + "@smithy/util-utf8": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/middleware-sdk-s3/node_modules/@smithy/util-utf8": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-4.2.2.tgz", + "integrity": "sha512-75MeYpjdWRe8M5E3AW0O4Cx3UadweS+cwdXjwYGBW5h/gxxnbeZ877sLPX/ZJA9GVTlL/qG0dXP29JWFCD1Ayw==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/util-buffer-from": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@aws-sdk/middleware-user-agent": { + "version": "3.972.37", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.972.37.tgz", + "integrity": "sha512-N1oNpdiLoVAWYD3WFBnUi3LlfoDA06ZHo4ozyjbsJNLvILzvt//0CnR8N+CZ0NWeYgVB/5V59ivixHCWCx2ALw==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.974.7", + "@aws-sdk/types": "^3.973.8", + "@aws-sdk/util-endpoints": "^3.996.8", + "@smithy/core": "^3.23.17", + "@smithy/protocol-http": "^5.3.14", + "@smithy/types": "^4.14.1", + "@smithy/util-retry": "^4.3.6", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/middleware-user-agent/node_modules/@aws-sdk/util-endpoints": { + "version": "3.996.8", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.996.8.tgz", + "integrity": "sha512-oOZHcRDihk5iEe5V25NVWg45b3qEA8OpHWVdU/XQh8Zj4heVPAJqWvMphQnU7LkufmUo10EpvFPZuQMiFLJK3g==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/types": "^3.973.8", + "@smithy/types": "^4.14.1", + "@smithy/url-parser": "^4.2.14", + "@smithy/util-endpoints": "^3.4.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/nested-clients": { + "version": "3.993.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/nested-clients/-/nested-clients-3.993.0.tgz", + "integrity": "sha512-iOq86f2H67924kQUIPOAvlmMaOAvOLoDOIb66I2YqSUpMYB6ufiuJW3RlREgskxv86S5qKzMnfy/X6CqMjK6XQ==", + "license": "Apache-2.0", + "dependencies": { + "@aws-crypto/sha256-browser": "5.2.0", + "@aws-crypto/sha256-js": "5.2.0", + "@aws-sdk/core": "^3.973.11", + "@aws-sdk/middleware-host-header": "^3.972.3", + "@aws-sdk/middleware-logger": "^3.972.3", + "@aws-sdk/middleware-recursion-detection": "^3.972.3", + "@aws-sdk/middleware-user-agent": "^3.972.11", + "@aws-sdk/region-config-resolver": "^3.972.3", + "@aws-sdk/types": "^3.973.1", + "@aws-sdk/util-endpoints": "3.993.0", + "@aws-sdk/util-user-agent-browser": "^3.972.3", + "@aws-sdk/util-user-agent-node": "^3.972.9", + "@smithy/config-resolver": "^4.4.6", + "@smithy/core": "^3.23.2", + "@smithy/fetch-http-handler": "^5.3.9", + "@smithy/hash-node": "^4.2.8", + "@smithy/invalid-dependency": "^4.2.8", + "@smithy/middleware-content-length": "^4.2.8", + "@smithy/middleware-endpoint": "^4.4.16", + "@smithy/middleware-retry": "^4.4.33", + "@smithy/middleware-serde": "^4.2.9", + "@smithy/middleware-stack": "^4.2.8", + "@smithy/node-config-provider": "^4.3.8", + "@smithy/node-http-handler": "^4.4.10", + "@smithy/protocol-http": "^5.3.8", + "@smithy/smithy-client": "^4.11.5", + "@smithy/types": "^4.12.0", + "@smithy/url-parser": "^4.2.8", + "@smithy/util-base64": "^4.3.0", + "@smithy/util-body-length-browser": "^4.2.0", + "@smithy/util-body-length-node": "^4.2.1", + "@smithy/util-defaults-mode-browser": "^4.3.32", + "@smithy/util-defaults-mode-node": "^4.2.35", + "@smithy/util-endpoints": "^3.2.8", + "@smithy/util-middleware": "^4.2.8", + "@smithy/util-retry": "^4.2.8", + "@smithy/util-utf8": "^4.2.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/nested-clients/node_modules/@smithy/util-utf8": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-4.2.2.tgz", + "integrity": "sha512-75MeYpjdWRe8M5E3AW0O4Cx3UadweS+cwdXjwYGBW5h/gxxnbeZ877sLPX/ZJA9GVTlL/qG0dXP29JWFCD1Ayw==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/util-buffer-from": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@aws-sdk/region-config-resolver": { + "version": "3.972.13", + "resolved": "https://registry.npmjs.org/@aws-sdk/region-config-resolver/-/region-config-resolver-3.972.13.tgz", + "integrity": "sha512-CvJ2ZIjK/jVD/lbOpowBVElJyC1YxLTIJ13yM0AEo0t2v7swOzGjSA6lJGH+DwZXQhcjUjoYwc8bVYCX5MDr1A==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/types": "^3.973.8", + "@smithy/config-resolver": "^4.4.17", + "@smithy/node-config-provider": "^4.3.14", + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/signature-v4-multi-region": { + "version": "3.996.24", + "resolved": "https://registry.npmjs.org/@aws-sdk/signature-v4-multi-region/-/signature-v4-multi-region-3.996.24.tgz", + "integrity": "sha512-amP7tLikppN940wbBFISYqiuzVmpzMS9U3mcgtmVLjX4fdWI/SNCvrXv6ZxfVzTT4cT0rPKOLhFah2xLwzREWw==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/middleware-sdk-s3": "^3.972.36", + "@aws-sdk/types": "^3.973.8", + "@smithy/protocol-http": "^5.3.14", + "@smithy/signature-v4": "^5.3.14", + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/token-providers": { + "version": "3.1039.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/token-providers/-/token-providers-3.1039.0.tgz", + "integrity": "sha512-NMSFL2HwkAOoCeLCQiqoOq5pT3vVbSjww2QZTuYgYknVwhhv125PSDzZIcL5EYnlxuPWjEOdauZK+FspkZDVdw==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/core": "^3.974.7", + "@aws-sdk/nested-clients": "^3.997.5", + "@aws-sdk/types": "^3.973.8", + "@smithy/property-provider": "^4.2.14", + "@smithy/shared-ini-file-loader": "^4.4.9", + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/token-providers/node_modules/@aws-sdk/nested-clients": { + "version": "3.997.5", + "resolved": "https://registry.npmjs.org/@aws-sdk/nested-clients/-/nested-clients-3.997.5.tgz", + "integrity": "sha512-jGFr6DxtcMTmzOkG/a0jCZYv4BBDmeNYVeO+/memSoDkYCJu4Y58xviYmzwJfYyIVSts+X/BVjJm1uGBnwHEMg==", + "license": "Apache-2.0", + "dependencies": { + "@aws-crypto/sha256-browser": "5.2.0", + "@aws-crypto/sha256-js": "5.2.0", + "@aws-sdk/core": "^3.974.7", + "@aws-sdk/middleware-host-header": "^3.972.10", + "@aws-sdk/middleware-logger": "^3.972.10", + "@aws-sdk/middleware-recursion-detection": "^3.972.11", + "@aws-sdk/middleware-user-agent": "^3.972.37", + "@aws-sdk/region-config-resolver": "^3.972.13", + "@aws-sdk/signature-v4-multi-region": "^3.996.24", + "@aws-sdk/types": "^3.973.8", + "@aws-sdk/util-endpoints": "^3.996.8", + "@aws-sdk/util-user-agent-browser": "^3.972.10", + "@aws-sdk/util-user-agent-node": "^3.973.23", + "@smithy/config-resolver": "^4.4.17", + "@smithy/core": "^3.23.17", + "@smithy/fetch-http-handler": "^5.3.17", + "@smithy/hash-node": "^4.2.14", + "@smithy/invalid-dependency": "^4.2.14", + "@smithy/middleware-content-length": "^4.2.14", + "@smithy/middleware-endpoint": "^4.4.32", + "@smithy/middleware-retry": "^4.5.7", + "@smithy/middleware-serde": "^4.2.20", + "@smithy/middleware-stack": "^4.2.14", + "@smithy/node-config-provider": "^4.3.14", + "@smithy/node-http-handler": "^4.6.1", + "@smithy/protocol-http": "^5.3.14", + "@smithy/smithy-client": "^4.12.13", + "@smithy/types": "^4.14.1", + "@smithy/url-parser": "^4.2.14", + "@smithy/util-base64": "^4.3.2", + "@smithy/util-body-length-browser": "^4.2.2", + "@smithy/util-body-length-node": "^4.2.3", + "@smithy/util-defaults-mode-browser": "^4.3.49", + "@smithy/util-defaults-mode-node": "^4.2.54", + "@smithy/util-endpoints": "^3.4.2", + "@smithy/util-middleware": "^4.2.14", + "@smithy/util-retry": "^4.3.6", + "@smithy/util-utf8": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/token-providers/node_modules/@aws-sdk/util-endpoints": { + "version": "3.996.8", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.996.8.tgz", + "integrity": "sha512-oOZHcRDihk5iEe5V25NVWg45b3qEA8OpHWVdU/XQh8Zj4heVPAJqWvMphQnU7LkufmUo10EpvFPZuQMiFLJK3g==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/types": "^3.973.8", + "@smithy/types": "^4.14.1", + "@smithy/url-parser": "^4.2.14", + "@smithy/util-endpoints": "^3.4.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/token-providers/node_modules/@smithy/util-utf8": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-4.2.2.tgz", + "integrity": "sha512-75MeYpjdWRe8M5E3AW0O4Cx3UadweS+cwdXjwYGBW5h/gxxnbeZ877sLPX/ZJA9GVTlL/qG0dXP29JWFCD1Ayw==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/util-buffer-from": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@aws-sdk/types": { + "version": "3.973.8", + "resolved": "https://registry.npmjs.org/@aws-sdk/types/-/types-3.973.8.tgz", + "integrity": "sha512-gjlAdtHMbtR9X5iIhVUvbVcy55KnznpC6bkDUWW9z915bi0ckdUr5cjf16Kp6xq0bP5HBD2xzgbL9F9Quv5vUw==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/util-arn-parser": { + "version": "3.972.3", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-arn-parser/-/util-arn-parser-3.972.3.tgz", + "integrity": "sha512-HzSD8PMFrvgi2Kserxuff5VitNq2sgf3w9qxmskKDiDTThWfVteJxuCS9JXiPIPtmCrp+7N9asfIaVhBFORllA==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/util-endpoints": { + "version": "3.993.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.993.0.tgz", + "integrity": "sha512-j6vioBeRZ4eHX4SWGvGPpwGg/xSOcK7f1GL0VM+rdf3ZFTIsUEhCFmD78B+5r2PgztcECSzEfvHQX01k8dPQPw==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/types": "^3.973.1", + "@smithy/types": "^4.12.0", + "@smithy/url-parser": "^4.2.8", + "@smithy/util-endpoints": "^3.2.8", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/util-locate-window": { + "version": "3.965.5", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-locate-window/-/util-locate-window-3.965.5.tgz", + "integrity": "sha512-WhlJNNINQB+9qtLtZJcpQdgZw3SCDCpXdUJP7cToGwHbCWCnRckGlc6Bx/OhWwIYFNAn+FIydY8SZ0QmVu3xTQ==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws-sdk/util-user-agent-browser": { + "version": "3.972.10", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-user-agent-browser/-/util-user-agent-browser-3.972.10.tgz", + "integrity": "sha512-FAzqXvfEssGdSIz8ejatan0bOdx1qefBWKF/gWmVBXIP1HkS7v/wjjaqrAGGKvyihrXTXW00/2/1nTJtxpXz7g==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/types": "^3.973.8", + "@smithy/types": "^4.14.1", + "bowser": "^2.11.0", + "tslib": "^2.6.2" + } + }, + "node_modules/@aws-sdk/util-user-agent-node": { + "version": "3.973.23", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-user-agent-node/-/util-user-agent-node-3.973.23.tgz", + "integrity": "sha512-gGwq8L2Euw0aNG6Ey4EktiAo3fSCVoDy1CaBIthd+oeaKHPXUrNaApMewQ6La5Hv0lcznOtECZaNvYyc5LXXfA==", + "license": "Apache-2.0", + "dependencies": { + "@aws-sdk/middleware-user-agent": "^3.972.37", + "@aws-sdk/types": "^3.973.8", + "@smithy/node-config-provider": "^4.3.14", + "@smithy/types": "^4.14.1", + "@smithy/util-config-provider": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "aws-crt": ">=1.0.0" + }, + "peerDependenciesMeta": { + "aws-crt": { + "optional": true + } + } + }, + "node_modules/@aws-sdk/xml-builder": { + "version": "3.972.22", + "resolved": "https://registry.npmjs.org/@aws-sdk/xml-builder/-/xml-builder-3.972.22.tgz", + "integrity": "sha512-PMYKKtJd70IsSG0yHrdAbxBr+ZWBKLvzFZfD3/urxgf6hXVMzuU5M+3MJ5G67RpOmLBu1fAUN65SbWuKUCOlAA==", + "license": "Apache-2.0", + "dependencies": { + "@nodable/entities": "2.1.0", + "@smithy/types": "^4.14.1", + "fast-xml-parser": "5.7.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@aws/lambda-invoke-store": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/@aws/lambda-invoke-store/-/lambda-invoke-store-0.2.4.tgz", + "integrity": "sha512-iY8yvjE0y651BixKNPgmv1WrQc+GZ142sb0z4gYnChDDY2YqI4P/jsSopBWrKfAt7LOJAkOXt7rC/hms+WclQQ==", + "license": "Apache-2.0", + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@infisical/sdk": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@infisical/sdk/-/sdk-5.0.2.tgz", + "integrity": "sha512-mkgghtmIgBOEOFj1gb2n/AoiroFvN+NqaEEwC8ezEQ87V55yf2yksHhnBMU2MiZ26n6b3sGcpDZHF1/H6JrgyA==", + "license": "ISC", + "dependencies": { + "@aws-crypto/sha256-js": "^5.2.0", + "@aws-sdk/credential-providers": "3.993.0", + "@smithy/protocol-http": "^5.3.8", + "@smithy/signature-v4": "^5.3.8", + "typescript": "^5.5.4", + "zod": "^3.23.8" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@infisical/sdk/node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/@nodable/entities": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@nodable/entities/-/entities-2.1.0.tgz", + "integrity": "sha512-nyT7T3nbMyBI/lvr6L5TyWbFJAI9FTgVRakNoBqCD+PmID8DzFrrNdLLtHMwMszOtqZa8PAOV24ZqDnQrhQINA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/nodable" + } + ], + "license": "MIT" + }, + "node_modules/@smithy/config-resolver": { + "version": "4.4.17", + "resolved": "https://registry.npmjs.org/@smithy/config-resolver/-/config-resolver-4.4.17.tgz", + "integrity": "sha512-TzDZcAnhTyAHbXVxWZo7/tEcrIeFq20IBk8So3OLOetWpR8EwY/yEqBMBFaJMeyEiREDq4NfEl+qO3OAUD+vbQ==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/node-config-provider": "^4.3.14", + "@smithy/types": "^4.14.1", + "@smithy/util-config-provider": "^4.2.2", + "@smithy/util-endpoints": "^3.4.2", + "@smithy/util-middleware": "^4.2.14", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/core": { + "version": "3.23.17", + "resolved": "https://registry.npmjs.org/@smithy/core/-/core-3.23.17.tgz", + "integrity": "sha512-x7BlLbUFL8NWCGjMF9C+1N5cVCxcPa7g6Tv9B4A2luWx3be3oU8hQ96wIwxe/s7OhIzvoJH73HAUSg5JXVlEtQ==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/protocol-http": "^5.3.14", + "@smithy/types": "^4.14.1", + "@smithy/url-parser": "^4.2.14", + "@smithy/util-base64": "^4.3.2", + "@smithy/util-body-length-browser": "^4.2.2", + "@smithy/util-middleware": "^4.2.14", + "@smithy/util-stream": "^4.5.25", + "@smithy/util-utf8": "^4.2.2", + "@smithy/uuid": "^1.1.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/core/node_modules/@smithy/util-utf8": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-4.2.2.tgz", + "integrity": "sha512-75MeYpjdWRe8M5E3AW0O4Cx3UadweS+cwdXjwYGBW5h/gxxnbeZ877sLPX/ZJA9GVTlL/qG0dXP29JWFCD1Ayw==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/util-buffer-from": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/credential-provider-imds": { + "version": "4.2.14", + "resolved": "https://registry.npmjs.org/@smithy/credential-provider-imds/-/credential-provider-imds-4.2.14.tgz", + "integrity": "sha512-Au28zBN48ZAoXdooGUHemuVBrkE+Ie6RPmGNIAJsFqj33Vhb6xAgRifUydZ2aY+M+KaMAETAlKk5NC5h1G7wpg==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/node-config-provider": "^4.3.14", + "@smithy/property-provider": "^4.2.14", + "@smithy/types": "^4.14.1", + "@smithy/url-parser": "^4.2.14", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/fetch-http-handler": { + "version": "5.3.17", + "resolved": "https://registry.npmjs.org/@smithy/fetch-http-handler/-/fetch-http-handler-5.3.17.tgz", + "integrity": "sha512-bXOvQzaSm6MnmLaWA1elgfQcAtN4UP3vXqV97bHuoOrHQOJiLT3ds6o9eo5bqd0TJfRFpzdGnDQdW3FACiAVdw==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/protocol-http": "^5.3.14", + "@smithy/querystring-builder": "^4.2.14", + "@smithy/types": "^4.14.1", + "@smithy/util-base64": "^4.3.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/hash-node": { + "version": "4.2.14", + "resolved": "https://registry.npmjs.org/@smithy/hash-node/-/hash-node-4.2.14.tgz", + "integrity": "sha512-8ZBDY2DD4wr+GGjTpPtiglEsqr0lUP+KHqgZcWczFf6qeZ/YRjMIOoQWVQlmwu7EtxKTd8YXD8lblmYcpBIA1g==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/types": "^4.14.1", + "@smithy/util-buffer-from": "^4.2.2", + "@smithy/util-utf8": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/hash-node/node_modules/@smithy/util-utf8": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-4.2.2.tgz", + "integrity": "sha512-75MeYpjdWRe8M5E3AW0O4Cx3UadweS+cwdXjwYGBW5h/gxxnbeZ877sLPX/ZJA9GVTlL/qG0dXP29JWFCD1Ayw==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/util-buffer-from": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/invalid-dependency": { + "version": "4.2.14", + "resolved": "https://registry.npmjs.org/@smithy/invalid-dependency/-/invalid-dependency-4.2.14.tgz", + "integrity": "sha512-c21qJiTSb25xvvOp+H2TNZzPCngrvl5vIPqPB8zQ/DmJF4QWXO19x1dWfMJZ6wZuuWUPPm0gV8C0cU3+ifcWuw==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/is-array-buffer": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@smithy/is-array-buffer/-/is-array-buffer-4.2.2.tgz", + "integrity": "sha512-n6rQ4N8Jj4YTQO3YFrlgZuwKodf4zUFs7EJIWH86pSCWBaAtAGBFfCM7Wx6D2bBJ2xqFNxGBSrUWswT3M0VJow==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/middleware-content-length": { + "version": "4.2.14", + "resolved": "https://registry.npmjs.org/@smithy/middleware-content-length/-/middleware-content-length-4.2.14.tgz", + "integrity": "sha512-xhHq7fX4/3lv5NHxLUk3OeEvl0xZ+Ek3qIbWaCL4f9JwgDZEclPBElljaZCAItdGPQl/kSM4LPMOpy1MYgprpw==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/protocol-http": "^5.3.14", + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/middleware-endpoint": { + "version": "4.4.32", + "resolved": "https://registry.npmjs.org/@smithy/middleware-endpoint/-/middleware-endpoint-4.4.32.tgz", + "integrity": "sha512-ZZkgyjnJppiZbIm6Qbx92pbXYi1uzenIvGhBSCDlc7NwuAkiqSgS75j1czAD25ZLs2FjMjYy1q7gyRVWG6JA0Q==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/core": "^3.23.17", + "@smithy/middleware-serde": "^4.2.20", + "@smithy/node-config-provider": "^4.3.14", + "@smithy/shared-ini-file-loader": "^4.4.9", + "@smithy/types": "^4.14.1", + "@smithy/url-parser": "^4.2.14", + "@smithy/util-middleware": "^4.2.14", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/middleware-retry": { + "version": "4.5.7", + "resolved": "https://registry.npmjs.org/@smithy/middleware-retry/-/middleware-retry-4.5.7.tgz", + "integrity": "sha512-bRt6ZImqVSeTk39Nm81K20ObIiAZ3WefY7G6+iz/0tZjs4dgRRjvRX2sgsH+zi6iDCRR/aQvQofLKxxz4rPBZg==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/core": "^3.23.17", + "@smithy/node-config-provider": "^4.3.14", + "@smithy/protocol-http": "^5.3.14", + "@smithy/service-error-classification": "^4.3.1", + "@smithy/smithy-client": "^4.12.13", + "@smithy/types": "^4.14.1", + "@smithy/util-middleware": "^4.2.14", + "@smithy/util-retry": "^4.3.6", + "@smithy/uuid": "^1.1.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/middleware-serde": { + "version": "4.2.20", + "resolved": "https://registry.npmjs.org/@smithy/middleware-serde/-/middleware-serde-4.2.20.tgz", + "integrity": "sha512-Lx9JMO9vArPtiChE3wbEZ5akMIDQpWQtlu90lhACQmNOXcGXRbaDywMHDzuDZ2OkZzP+9wQfZi3YJT9F67zTQQ==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/core": "^3.23.17", + "@smithy/protocol-http": "^5.3.14", + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/middleware-stack": { + "version": "4.2.14", + "resolved": "https://registry.npmjs.org/@smithy/middleware-stack/-/middleware-stack-4.2.14.tgz", + "integrity": "sha512-2dvkUKLuFdKsCRmOE4Mn63co0Djtsm+JMh0bYZQupN1pJwMeE8FmQmRLLzzEMN0dnNi7CDCYYH8F0EVwWiPBeA==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/node-config-provider": { + "version": "4.3.14", + "resolved": "https://registry.npmjs.org/@smithy/node-config-provider/-/node-config-provider-4.3.14.tgz", + "integrity": "sha512-S+gFjyo/weSVL0P1b9Ts8C/CwIfNCgUPikk3sl6QVsfE/uUuO+QsF+NsE/JkpvWqqyz1wg7HFdiaZuj5CoBMRg==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/property-provider": "^4.2.14", + "@smithy/shared-ini-file-loader": "^4.4.9", + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/node-http-handler": { + "version": "4.6.1", + "resolved": "https://registry.npmjs.org/@smithy/node-http-handler/-/node-http-handler-4.6.1.tgz", + "integrity": "sha512-iB+orM4x3xrr57X3YaXazfKnntl0LHlZB1kcXSGzMV1Tt0+YwEjGlbjk/44qEGtBzXAz6yFDzkYTKSV6Pj2HUg==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/protocol-http": "^5.3.14", + "@smithy/querystring-builder": "^4.2.14", + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/property-provider": { + "version": "4.2.14", + "resolved": "https://registry.npmjs.org/@smithy/property-provider/-/property-provider-4.2.14.tgz", + "integrity": "sha512-WuM31CgfsnQ/10i7NYr0PyxqknD72Y5uMfUMVSniPjbEPceiTErb4eIqJQ+pdxNEAUEWrewrGjIRjVbVHsxZiQ==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/protocol-http": { + "version": "5.3.14", + "resolved": "https://registry.npmjs.org/@smithy/protocol-http/-/protocol-http-5.3.14.tgz", + "integrity": "sha512-dN5F8kHx8RNU0r+pCwNmFZyz6ChjMkzShy/zup6MtkRmmix4vZzJdW+di7x//b1LiynIev88FM18ie+wwPcQtQ==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/querystring-builder": { + "version": "4.2.14", + "resolved": "https://registry.npmjs.org/@smithy/querystring-builder/-/querystring-builder-4.2.14.tgz", + "integrity": "sha512-XYA5Z0IqTeF+5XDdh4BBmSA0HvbgVZIyv4cmOoUheDNR57K1HgBp9ukUMx3Cr3XpDHHpLBnexPE3LAtDsZkj2A==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/types": "^4.14.1", + "@smithy/util-uri-escape": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/querystring-parser": { + "version": "4.2.14", + "resolved": "https://registry.npmjs.org/@smithy/querystring-parser/-/querystring-parser-4.2.14.tgz", + "integrity": "sha512-hr+YyqBD23GVvRxGGrcc/oOeNlK3PzT5Fu4dzrDXxzS1LpFiuL2PQQqKPs87M79aW7ziMs+nvB3qdw77SqE7Lw==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/service-error-classification": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/@smithy/service-error-classification/-/service-error-classification-4.3.1.tgz", + "integrity": "sha512-aUQuDGh760ts/8MU+APjIZhlLPKhIIfqyzZaJikLEIMrdxFvxuLYD0WxWzaYWpmLbQlXDe9p7EWM3HsBe0K6Gw==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/types": "^4.14.1" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/shared-ini-file-loader": { + "version": "4.4.9", + "resolved": "https://registry.npmjs.org/@smithy/shared-ini-file-loader/-/shared-ini-file-loader-4.4.9.tgz", + "integrity": "sha512-495/V2I15SHgedSJoDPD23JuSfKAp726ZI1V0wtjB07Wh7q/0tri/0e0DLefZCHgxZonrGKt/OCTpAtP1wE1kQ==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/signature-v4": { + "version": "5.3.14", + "resolved": "https://registry.npmjs.org/@smithy/signature-v4/-/signature-v4-5.3.14.tgz", + "integrity": "sha512-1D9Y/nmlVjCeSivCbhZ7hgEpmHyY1h0GvpSZt3l0xcD9JjmjVC1CHOozS6+Gh+/ldMH8JuJ6cujObQqfayAVFA==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/is-array-buffer": "^4.2.2", + "@smithy/protocol-http": "^5.3.14", + "@smithy/types": "^4.14.1", + "@smithy/util-hex-encoding": "^4.2.2", + "@smithy/util-middleware": "^4.2.14", + "@smithy/util-uri-escape": "^4.2.2", + "@smithy/util-utf8": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/signature-v4/node_modules/@smithy/util-utf8": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-4.2.2.tgz", + "integrity": "sha512-75MeYpjdWRe8M5E3AW0O4Cx3UadweS+cwdXjwYGBW5h/gxxnbeZ877sLPX/ZJA9GVTlL/qG0dXP29JWFCD1Ayw==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/util-buffer-from": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/smithy-client": { + "version": "4.12.13", + "resolved": "https://registry.npmjs.org/@smithy/smithy-client/-/smithy-client-4.12.13.tgz", + "integrity": "sha512-y/Pcj1V9+qG98gyu1gvftHB7rDpdh+7kIBIggs55yGm3JdtBV8GT8IFF3a1qxZ79QnaJHX9GXzvBG6tAd+czJA==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/core": "^3.23.17", + "@smithy/middleware-endpoint": "^4.4.32", + "@smithy/middleware-stack": "^4.2.14", + "@smithy/protocol-http": "^5.3.14", + "@smithy/types": "^4.14.1", + "@smithy/util-stream": "^4.5.25", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/types": { + "version": "4.14.1", + "resolved": "https://registry.npmjs.org/@smithy/types/-/types-4.14.1.tgz", + "integrity": "sha512-59b5HtSVrVR/eYNei3BUj3DCPKD/G7EtDDe7OEJE7i7FtQFugYo6MxbotS8mVJkLNVf8gYaAlEBwwtJ9HzhWSg==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/url-parser": { + "version": "4.2.14", + "resolved": "https://registry.npmjs.org/@smithy/url-parser/-/url-parser-4.2.14.tgz", + "integrity": "sha512-p06BiBigJ8bTA3MgnOfCtDUWnAMY0YfedO/GRpmc7p+wg3KW8vbXy1xwSu5ASy0wV7rRYtlfZOIKH4XqfhjSQQ==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/querystring-parser": "^4.2.14", + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/util-base64": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/@smithy/util-base64/-/util-base64-4.3.2.tgz", + "integrity": "sha512-XRH6b0H/5A3SgblmMa5ErXQ2XKhfbQB+Fm/oyLZ2O2kCUrwgg55bU0RekmzAhuwOjA9qdN5VU2BprOvGGUkOOQ==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/util-buffer-from": "^4.2.2", + "@smithy/util-utf8": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/util-base64/node_modules/@smithy/util-utf8": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-4.2.2.tgz", + "integrity": "sha512-75MeYpjdWRe8M5E3AW0O4Cx3UadweS+cwdXjwYGBW5h/gxxnbeZ877sLPX/ZJA9GVTlL/qG0dXP29JWFCD1Ayw==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/util-buffer-from": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/util-body-length-browser": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@smithy/util-body-length-browser/-/util-body-length-browser-4.2.2.tgz", + "integrity": "sha512-JKCrLNOup3OOgmzeaKQwi4ZCTWlYR5H4Gm1r2uTMVBXoemo1UEghk5vtMi1xSu2ymgKVGW631e2fp9/R610ZjQ==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/util-body-length-node": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/@smithy/util-body-length-node/-/util-body-length-node-4.2.3.tgz", + "integrity": "sha512-ZkJGvqBzMHVHE7r/hcuCxlTY8pQr1kMtdsVPs7ex4mMU+EAbcXppfo5NmyxMYi2XU49eqaz56j2gsk4dHHPG/g==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/util-buffer-from": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@smithy/util-buffer-from/-/util-buffer-from-4.2.2.tgz", + "integrity": "sha512-FDXD7cvUoFWwN6vtQfEta540Y/YBe5JneK3SoZg9bThSoOAC/eGeYEua6RkBgKjGa/sz6Y+DuBZj3+YEY21y4Q==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/is-array-buffer": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/util-config-provider": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@smithy/util-config-provider/-/util-config-provider-4.2.2.tgz", + "integrity": "sha512-dWU03V3XUprJwaUIFVv4iOnS1FC9HnMHDfUrlNDSh4315v0cWyaIErP8KiqGVbf5z+JupoVpNM7ZB3jFiTejvQ==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/util-defaults-mode-browser": { + "version": "4.3.49", + "resolved": "https://registry.npmjs.org/@smithy/util-defaults-mode-browser/-/util-defaults-mode-browser-4.3.49.tgz", + "integrity": "sha512-a5bNrdiONYB/qE2BuKegvUMd/+ZDwdg4vsNuuSzYE8qs2EYAdK9CynL+Rzn29PbPiUqoz/cbpRbcLzD5lEevHw==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/property-provider": "^4.2.14", + "@smithy/smithy-client": "^4.12.13", + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/util-defaults-mode-node": { + "version": "4.2.54", + "resolved": "https://registry.npmjs.org/@smithy/util-defaults-mode-node/-/util-defaults-mode-node-4.2.54.tgz", + "integrity": "sha512-g1cvrJvOnzeJgEdf7AE4luI7gp6L8weE0y9a9wQUSGtjb8QRHDbCJYuE4Sy0SD9N8RrnNPFsPltAz/OSoBR9Zw==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/config-resolver": "^4.4.17", + "@smithy/credential-provider-imds": "^4.2.14", + "@smithy/node-config-provider": "^4.3.14", + "@smithy/property-provider": "^4.2.14", + "@smithy/smithy-client": "^4.12.13", + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/util-endpoints": { + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/@smithy/util-endpoints/-/util-endpoints-3.4.2.tgz", + "integrity": "sha512-a55Tr+3OKld4TTtnT+RhKOQHyPxm3j/xL4OR83WBUhLJaKDS9dnJ7arRMOp3t31dcLhApwG9bgvrRXBHlLdIkg==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/node-config-provider": "^4.3.14", + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/util-hex-encoding": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@smithy/util-hex-encoding/-/util-hex-encoding-4.2.2.tgz", + "integrity": "sha512-Qcz3W5vuHK4sLQdyT93k/rfrUwdJ8/HZ+nMUOyGdpeGA1Wxt65zYwi3oEl9kOM+RswvYq90fzkNDahPS8K0OIg==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/util-middleware": { + "version": "4.2.14", + "resolved": "https://registry.npmjs.org/@smithy/util-middleware/-/util-middleware-4.2.14.tgz", + "integrity": "sha512-1Su2vj9RYNDEv/V+2E+jXkkwGsgR7dc4sfHn9Z7ruzQHJIEni9zzw5CauvRXlFJfmgcqYP8fWa0dkh2Q2YaQyw==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/util-retry": { + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/@smithy/util-retry/-/util-retry-4.3.6.tgz", + "integrity": "sha512-p6/FO1n2KxMeQyna067i0uJ6TSbb165ZhnRtCpWh4Foxqbfc6oW+XITaL8QkFJj3KFnDe2URt4gOhgU06EP9ew==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/service-error-classification": "^4.3.1", + "@smithy/types": "^4.14.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/util-stream": { + "version": "4.5.25", + "resolved": "https://registry.npmjs.org/@smithy/util-stream/-/util-stream-4.5.25.tgz", + "integrity": "sha512-/PFpG4k8Ze8Ei+mMKj3oiPICYekthuzePZMgZbCqMiXIHHf4n2aZ4Ps0aSRShycFTGuj/J6XldmC0x0DwednIA==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/fetch-http-handler": "^5.3.17", + "@smithy/node-http-handler": "^4.6.1", + "@smithy/types": "^4.14.1", + "@smithy/util-base64": "^4.3.2", + "@smithy/util-buffer-from": "^4.2.2", + "@smithy/util-hex-encoding": "^4.2.2", + "@smithy/util-utf8": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/util-stream/node_modules/@smithy/util-utf8": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-4.2.2.tgz", + "integrity": "sha512-75MeYpjdWRe8M5E3AW0O4Cx3UadweS+cwdXjwYGBW5h/gxxnbeZ877sLPX/ZJA9GVTlL/qG0dXP29JWFCD1Ayw==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/util-buffer-from": "^4.2.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/util-uri-escape": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@smithy/util-uri-escape/-/util-uri-escape-4.2.2.tgz", + "integrity": "sha512-2kAStBlvq+lTXHyAZYfJRb/DfS3rsinLiwb+69SstC9Vb0s9vNWkRwpnj918Pfi85mzi42sOqdV72OLxWAISnw==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@smithy/util-utf8": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-2.3.0.tgz", + "integrity": "sha512-R8Rdn8Hy72KKcebgLiv8jQcQkXoLMOGGv5uI1/k0l+snqkOzQ1R0ChUBCxWMlBsFMekWjq0wRudIweFs7sKT5A==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/util-buffer-from": "^2.2.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@smithy/util-utf8/node_modules/@smithy/is-array-buffer": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@smithy/is-array-buffer/-/is-array-buffer-2.2.0.tgz", + "integrity": "sha512-GGP3O9QFD24uGeAXYUjwSTXARoqpZykHadOmA8G5vfJPK0/DC67qa//0qvqrJzL1xc8WQWX7/yc7fwudjPHPhA==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@smithy/util-utf8/node_modules/@smithy/util-buffer-from": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@smithy/util-buffer-from/-/util-buffer-from-2.2.0.tgz", + "integrity": "sha512-IJdWBbTcMQ6DA0gdNhh/BwrLkDR+ADW5Kr1aZmd4k3DIF6ezMV4R2NIAmT08wQJ3yUK82thHWmC/TnK/wpMMIA==", + "license": "Apache-2.0", + "dependencies": { + "@smithy/is-array-buffer": "^2.2.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@smithy/uuid": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@smithy/uuid/-/uuid-1.1.2.tgz", + "integrity": "sha512-O/IEdcCUKkubz60tFbGA7ceITTAJsty+lBjNoorP4Z6XRqaFb/OjQjZODophEcuq68nKm6/0r+6/lLQ+XVpk8g==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@types/node": { + "version": "25.6.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-25.6.0.tgz", + "integrity": "sha512-+qIYRKdNYJwY3vRCZMdJbPLJAtGjQBudzZzdzwQYkEPQd+PJGixUL5QfvCLDaULoLv+RhT3LDkwEfKaAkgSmNQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~7.19.0" + } + }, + "node_modules/bowser": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/bowser/-/bowser-2.14.1.tgz", + "integrity": "sha512-tzPjzCxygAKWFOJP011oxFHs57HzIhOEracIgAePE4pqB3LikALKnSzUyU4MGs9/iCEUuHlAJTjTc5M+u7YEGg==", + "license": "MIT" + }, + "node_modules/fast-xml-builder": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/fast-xml-builder/-/fast-xml-builder-1.1.5.tgz", + "integrity": "sha512-4TJn/8FKLeslLAH3dnohXqE3QSoxkhvaMzepOIZytwJXZO69Bfz0HBdDHzOTOon6G59Zrk6VQ2bEiv1t61rfkA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + } + ], + "license": "MIT", + "dependencies": { + "path-expression-matcher": "^1.1.3" + } + }, + "node_modules/fast-xml-parser": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.7.2.tgz", + "integrity": "sha512-P7oW7tLbYnhOLQk/Gv7cZgzgMPP/XN03K02/Jy6Y/NHzyIAIpxuZIM/YqAkfiXFPxA2CTm7NtCijK9EDu09u2w==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + } + ], + "license": "MIT", + "dependencies": { + "@nodable/entities": "^2.1.0", + "fast-xml-builder": "^1.1.5", + "path-expression-matcher": "^1.5.0", + "strnum": "^2.2.3" + }, + "bin": { + "fxparser": "src/cli/cli.js" + } + }, + "node_modules/path-expression-matcher": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/path-expression-matcher/-/path-expression-matcher-1.5.0.tgz", + "integrity": "sha512-cbrerZV+6rvdQrrD+iGMcZFEiiSrbv9Tfdkvnusy6y0x0GKBXREFg/Y65GhIfm0tnLntThhzCnfKwp1WRjeCyQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + } + ], + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/strnum": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/strnum/-/strnum-2.2.3.tgz", + "integrity": "sha512-oKx6RUCuHfT3oyVjtnrmn19H1SiCqgJSg+54XqURKp5aCMbrXrhLjRN9TjuwMjiYstZ0MzDrHqkGZ5dFTKd+zg==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + } + ], + "license": "MIT" + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "license": "0BSD" + }, + "node_modules/typescript": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz", + "integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "7.19.2", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.19.2.tgz", + "integrity": "sha512-qYVnV5OEm2AW8cJMCpdV20CDyaN3g0AjDlOGf1OW4iaDEx8MwdtChUp4zu4H0VP3nDRF/8RKWH+IPp9uW0YGZg==", + "dev": true, + "license": "MIT" + }, + "node_modules/zod": { + "version": "3.25.76", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", + "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..90e1f7a --- /dev/null +++ b/package.json @@ -0,0 +1,24 @@ +{ + "name": "machine-env-service", + "version": "1.0.0", + "description": "Local IMDSv2-compatible metadata daemon for machine-scoped environment secrets.", + "license": "ISC", + "author": "", + "type": "module", + "main": "dist/daemon/main.js", + "bin": { + "machine-env-service": "./dist/daemon/main.js" + }, + "scripts": { + "build": "tsc -p tsconfig.json", + "start": "node dist/daemon/main.js", + "typecheck": "tsc -p tsconfig.json --noEmit" + }, + "devDependencies": { + "@types/node": "^25.6.0", + "typescript": "^6.0.3" + }, + "dependencies": { + "@infisical/sdk": "^5.0.2" + } +} diff --git a/src/common/dotenv.ts b/src/common/dotenv.ts new file mode 100644 index 0000000..797675b --- /dev/null +++ b/src/common/dotenv.ts @@ -0,0 +1,78 @@ +export type EnvTarget = Record; + +function unquoteValue(value: string): string { + const trimmed = value.trim(); + if (trimmed.length < 2) return trimmed; + + const quote = trimmed[0]; + if ((quote !== `"` && quote !== `'`) || trimmed[trimmed.length - 1] !== quote) { + return trimmed; + } + + const inner = trimmed.slice(1, -1); + if (quote === `'`) return inner; + + return inner + .replace(/\\n/g, "\n") + .replace(/\\r/g, "\r") + .replace(/\\t/g, "\t") + .replace(/\\"/g, `"`) + .replace(/\\\\/g, "\\"); +} + +function stripInlineComment(value: string): string { + let inSingleQuote = false; + let inDoubleQuote = false; + + for (let i = 0; i < value.length; i += 1) { + const char = value[i]; + const previous = value[i - 1]; + + if (char === `'` && !inDoubleQuote && previous !== "\\") { + inSingleQuote = !inSingleQuote; + } else if (char === `"` && !inSingleQuote && previous !== "\\") { + inDoubleQuote = !inDoubleQuote; + } else if (char === "#" && !inSingleQuote && !inDoubleQuote) { + const before = value[i - 1]; + if (before === undefined || /\s/.test(before)) { + return value.slice(0, i).trimEnd(); + } + } + } + + return value; +} + +export function parseDotenv(contents: string): Record { + const parsed: Record = {}; + const lines = contents.split(/\r?\n/); + + for (const rawLine of lines) { + const line = rawLine.trim(); + if (!line || line.startsWith("#")) continue; + + const normalized = line.startsWith("export ") ? line.slice("export ".length).trim() : line; + const separator = normalized.indexOf("="); + if (separator <= 0) continue; + + const key = normalized.slice(0, separator).trim(); + if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) continue; + + const rawValue = normalized.slice(separator + 1); + parsed[key] = unquoteValue(stripInlineComment(rawValue)); + } + + return parsed; +} + +export function mergeDotenv( + target: EnvTarget, + parsed: Record, + options: { override?: boolean } = {}, +): void { + const override = options.override ?? false; + for (const [key, value] of Object.entries(parsed)) { + if (!override && target[key] !== undefined) continue; + target[key] = value; + } +} diff --git a/src/common/env-loader.ts b/src/common/env-loader.ts new file mode 100644 index 0000000..2b78dcb --- /dev/null +++ b/src/common/env-loader.ts @@ -0,0 +1,89 @@ +import fs from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import { mergeDotenv, parseDotenv } from "./dotenv.js"; + +type NodeEnvMode = "dev" | "test" | "prod"; + +const VALID_MODES = new Set(["dev", "test", "prod"]); +const DEFAULT_MODE: NodeEnvMode = "dev"; + +let loaded = false; + +function normalizeMode(raw: string | undefined): NodeEnvMode { + const input = (raw ?? "").trim().toLowerCase(); + if (input === "development") return "dev"; + if (input === "testing") return "test"; + if (input === "production") return "prod"; + if (VALID_MODES.has(input as NodeEnvMode)) return input as NodeEnvMode; + return DEFAULT_MODE; +} + +function resolveEnvFile(mode: NodeEnvMode): string | null { + const moduleDir = path.dirname(fileURLToPath(import.meta.url)); + const candidates = [ + path.resolve(process.cwd(), "env-vars", `${mode}.env`), + path.resolve(process.cwd(), "env-vars", `.env.${mode}`), + path.resolve(moduleDir, "../../env-vars", `${mode}.env`), + path.resolve(moduleDir, "../../env-vars", `.env.${mode}`), + ]; + + for (const candidate of candidates) { + if (fs.existsSync(candidate)) return candidate; + } + return null; +} + +function resolveGlobalEnvFile(): { explicit: boolean; path: string } | null { + const explicitPath = process.env["DAHYEON_GLOBAL_ENVIRONMENT_FILE"]?.trim(); + if (explicitPath) { + return { explicit: true, path: path.resolve(explicitPath) }; + } + + const homeDir = process.env["HOME"] ?? process.env["USERPROFILE"]; + if (!homeDir) return null; + + return { + explicit: false, + path: path.resolve(homeDir, "source/global-env-vars.txt"), + }; +} + +function loadDotenvFile(filePath: string, label: string): void { + try { + mergeDotenv(process.env, parseDotenv(fs.readFileSync(filePath, "utf8"))); + } catch (error) { + const message = error instanceof Error ? error.message : String(error); + console.warn(`[Env] Failed to load ${label} (${filePath}): ${message}`); + } +} + +export function loadEnvironmentFromNodeEnv(): void { + if (loaded) return; + loaded = true; + + const mode = normalizeMode(process.env["NODE_ENV"]); + process.env["NODE_ENV"] = mode; + + const envFile = resolveEnvFile(mode); + if (!envFile) { + console.warn(`[Env] env-vars/${mode}.env not found. Skipping dotenv load.`); + return; + } + + loadDotenvFile(envFile, `env-vars/${mode}.env`); + + const globalEnvFile = resolveGlobalEnvFile(); + if (!globalEnvFile) return; + + if (!fs.existsSync(globalEnvFile.path)) { + if (globalEnvFile.explicit) { + console.warn( + `[Env] DAHYEON_GLOBAL_ENVIRONMENT_FILE not found: ${globalEnvFile.path}`, + ); + } + return; + } + + loadDotenvFile(globalEnvFile.path, "global env file"); +} diff --git a/src/common/known-secret-keys.ts b/src/common/known-secret-keys.ts new file mode 100644 index 0000000..398c2b4 --- /dev/null +++ b/src/common/known-secret-keys.ts @@ -0,0 +1,6 @@ +// Add machine-scoped secret names here to expose them through the metadata daemon. +// You can also set KNOWN_SECRET_KEYS, EXPOSED_SECRET_KEYS, or SECRET_ALLOWLIST +// in the daemon env file to configure the allowlist without rebuilding. +export const KNOWN_SECRET_KEYS = [] as const satisfies readonly string[]; + +export type KnownSecretKey = string; diff --git a/src/common/secret-manager.ts b/src/common/secret-manager.ts new file mode 100644 index 0000000..a789d40 --- /dev/null +++ b/src/common/secret-manager.ts @@ -0,0 +1,72 @@ +import { InfisicalSDK } from "@infisical/sdk"; +import { KNOWN_SECRET_KEYS, type KnownSecretKey } from "./known-secret-keys.js"; + +export type InfisicalEnvironment = "dev" | "staging" | "prod"; +export type SecretMap = Partial>; +export type RawSecretMap = Record; + +export interface InfisicalSecretConfig { + accessToken: string; + projectId: string; + environment: InfisicalEnvironment; + siteUrl: string; +} + +export interface FetchedSecrets { + known: SecretMap; + raw: RawSecretMap; +} + +export const DEFAULT_INFISICAL_SITE_URL = "https://secret-manager.dahyeon.us/"; + +let secrets: SecretMap = {}; +let rawSecrets: RawSecretMap = {}; + +function toSecretMap( + raw: RawSecretMap, + allowlist: readonly string[], +): SecretMap { + const allowed = new Set(allowlist); + const known: SecretMap = {}; + + for (const [key, value] of Object.entries(raw)) { + if (allowed.has(key)) known[key] = value; + } + + return known; +} + +export function getSecret(key: KnownSecretKey): string | undefined { + return secrets[key] ?? process.env[key]; +} + +export function getRawSecret(key: string): string | undefined { + return rawSecrets[key] ?? process.env[key]; +} + +export function getKnownSecretKeys(): readonly string[] { + return KNOWN_SECRET_KEYS; +} + +export async function fetchInfisicalSecrets( + config: InfisicalSecretConfig, + allowlist: readonly string[] = KNOWN_SECRET_KEYS, +): Promise { + const infisicalClient = new InfisicalSDK({ siteUrl: config.siteUrl }); + infisicalClient.auth().accessToken(config.accessToken); + + const res = await infisicalClient.secrets().listSecrets({ + environment: config.environment, + projectId: config.projectId, + viewSecretValue: true, + }); + + rawSecrets = {}; + for (const secret of res.secrets) { + if (!secret.secretKey) continue; + rawSecrets[secret.secretKey] = secret.secretValue ?? ""; + } + + secrets = toSecretMap(rawSecrets, allowlist); + return { known: { ...secrets }, raw: { ...rawSecrets } }; +} diff --git a/src/daemon/config.ts b/src/daemon/config.ts new file mode 100644 index 0000000..92be256 --- /dev/null +++ b/src/daemon/config.ts @@ -0,0 +1,261 @@ +import fs from "node:fs"; +import os from "node:os"; +import path from "node:path"; +import { + DEFAULT_INFISICAL_SITE_URL, + type InfisicalEnvironment, + type InfisicalSecretConfig, +} from "../common/secret-manager.js"; +import { getKnownSecretKeys } from "../common/secret-manager.js"; +import { mergeDotenv, parseDotenv, type EnvTarget } from "../common/dotenv.js"; +import { + buildMachineMetadata, + type MachineMetadata, +} from "./machine-metadata.js"; + +export interface ListenerConfig { + enabled: boolean; + host: string; + port: number; +} + +export interface DaemonConfig { + infisical: InfisicalSecretConfig; + metadataPort: number; + refreshIntervalMs: number; + tokenSweepIntervalMs: number; + allowSecretsBundle: boolean; + secretAllowlist: readonly string[]; + allowedHosts: readonly string[]; + lanListener: ListenerConfig; + linkLocalListener: ListenerConfig; + machineEnvConfigPath: string; + machineMetadata: MachineMetadata; +} + +const DEFAULT_METADATA_PORT = 8675; +const DEFAULT_REFRESH_INTERVAL_SEC = 60; +const DEFAULT_TOKEN_SWEEP_INTERVAL_SEC = 60; +const LINK_LOCAL_ADDRESS = "169.254.169.254"; + +function defaultConfigPath(platform: NodeJS.Platform): string { + if (platform === "darwin") return "/usr/local/etc/machine-env-service/env"; + return "/etc/machine-env-service/env"; +} + +function boolFromEnv( + value: string | undefined, + defaultValue: boolean, +): boolean { + if (value === undefined || value.trim() === "") return defaultValue; + const normalized = value.trim().toLowerCase(); + if (["1", "true", "yes", "on"].includes(normalized)) return true; + if (["0", "false", "no", "off"].includes(normalized)) return false; + throw new Error(`Invalid boolean value: ${value}`); +} + +function intFromEnv( + key: string, + value: string | undefined, + defaultValue: number, + options: { min: number; max?: number }, +): number { + if (value === undefined || value.trim() === "") return defaultValue; + const parsed = Number.parseInt(value, 10); + if (!Number.isInteger(parsed)) throw new Error(`${key} must be an integer`); + if (parsed < options.min) throw new Error(`${key} must be >= ${options.min}`); + if (options.max !== undefined && parsed > options.max) { + throw new Error(`${key} must be <= ${options.max}`); + } + return parsed; +} + +function required(env: EnvTarget, key: string): string { + const value = env[key]?.trim(); + if (!value) throw new Error(`Missing required environment variable: ${key}`); + return value; +} + +function parseEnvironment(value: string | undefined): InfisicalEnvironment { + const normalized = value?.trim(); + if ( + normalized === "dev" || + normalized === "staging" || + normalized === "prod" + ) { + return normalized; + } + throw new Error("INFISICAL_ENVIRONMENT must be one of: dev, staging, prod"); +} + +function parseList(value: string | undefined): string[] { + if (!value) return []; + return value + .split(/[,\s]+/) + .map((item) => item.trim()) + .filter(Boolean); +} + +function firstConfiguredList( + env: EnvTarget, + keys: readonly string[], +): string[] { + for (const key of keys) { + const parsed = parseList(env[key]); + if (parsed.length > 0) return parsed; + } + return []; +} + +function currentIpv4Hosts(): string[] { + const hosts = new Set(); + + for (const addresses of Object.values(os.networkInterfaces())) { + for (const address of addresses ?? []) { + if (address.family !== "IPv4") continue; + hosts.add(address.address); + } + } + + return [...hosts]; +} + +function normalizeHost(host: string): string { + const trimmed = host.trim().toLowerCase(); + if (!trimmed) return trimmed; + if (trimmed.startsWith("[")) { + const closingBracket = trimmed.indexOf("]"); + return closingBracket === -1 ? trimmed : trimmed.slice(1, closingBracket); + } + + const colon = trimmed.lastIndexOf(":"); + if (colon === -1) return trimmed; + + const maybePort = trimmed.slice(colon + 1); + if (/^\d+$/.test(maybePort)) return trimmed.slice(0, colon); + return trimmed; +} + +function buildAllowedHosts(env: EnvTarget, metadataPort: number): string[] { + const configured = firstConfiguredList(env, [ + "METADATA_ALLOWED_HOSTS", + "ALLOWED_HOSTS", + ]); + const hosts = new Set( + [ + LINK_LOCAL_ADDRESS, + "localhost", + "127.0.0.1", + "host.docker.internal", + ...currentIpv4Hosts(), + ...configured, + ].map(normalizeHost), + ); + + hosts.add(normalizeHost(`${LINK_LOCAL_ADDRESS}:80`)); + hosts.add(normalizeHost(`127.0.0.1:${metadataPort}`)); + return [...hosts].filter(Boolean).sort(); +} + +function warnIfWeakConfigFilePermissions(filePath: string): void { + try { + const stat = fs.statSync(filePath); + if ((stat.mode & 0o077) !== 0) { + console.warn( + `[Config] ${filePath} is readable by group/others. Recommended mode is 0600.`, + ); + } + } catch { + // Permission checks are best effort only; required values are validated below. + } +} + +function loadMachineEnvFile(env: EnvTarget): string { + const configuredPath = env["MACHINE_ENV_CONFIG"]?.trim(); + const filePath = path.resolve( + configuredPath || defaultConfigPath(process.platform), + ); + + if (!fs.existsSync(filePath)) { + if (configuredPath) { + console.warn(`[Config] MACHINE_ENV_CONFIG not found: ${filePath}`); + } + return filePath; + } + + mergeDotenv(env, parseDotenv(fs.readFileSync(filePath, "utf8"))); + warnIfWeakConfigFilePermissions(filePath); + return filePath; +} + +export function loadConfig(env: EnvTarget = process.env): DaemonConfig { + const machineEnvConfigPath = loadMachineEnvFile(env); + const metadataPort = intFromEnv( + "METADATA_PORT", + env["METADATA_PORT"], + DEFAULT_METADATA_PORT, + { + min: 1, + max: 65535, + }, + ); + const refreshIntervalSec = intFromEnv( + "REFRESH_INTERVAL_SEC", + env["REFRESH_INTERVAL_SEC"], + DEFAULT_REFRESH_INTERVAL_SEC, + { min: 1 }, + ); + const tokenSweepIntervalSec = intFromEnv( + "TOKEN_SWEEP_INTERVAL_SEC", + env["TOKEN_SWEEP_INTERVAL_SEC"], + DEFAULT_TOKEN_SWEEP_INTERVAL_SEC, + { min: 1 }, + ); + const configuredAllowlist = firstConfiguredList(env, [ + "KNOWN_SECRET_KEYS", + "EXPOSED_SECRET_KEYS", + "SECRET_ALLOWLIST", + "SECRET_WHITELIST", + ]); + const secretAllowlist = + configuredAllowlist.length > 0 + ? configuredAllowlist + : [...getKnownSecretKeys()]; + + if (secretAllowlist.length === 0) { + console.warn( + "[Config] No secret allowlist configured; metadata secret routes will be empty.", + ); + } + const infisicalEnvironment = parseEnvironment(env["INFISICAL_ENVIRONMENT"]); + + return { + infisical: { + accessToken: required(env, "INFISICAL_ACCESS_TOKEN"), + projectId: required(env, "INFISICAL_PROJECT_ID"), + environment: infisicalEnvironment, + siteUrl: env["INFISICAL_SITE_URL"]?.trim() || DEFAULT_INFISICAL_SITE_URL, + }, + metadataPort, + refreshIntervalMs: refreshIntervalSec * 1000, + tokenSweepIntervalMs: tokenSweepIntervalSec * 1000, + allowSecretsBundle: boolFromEnv(env["ALLOW_SECRETS_BUNDLE"], false), + secretAllowlist, + allowedHosts: buildAllowedHosts(env, metadataPort), + lanListener: { + enabled: boolFromEnv(env["LAN_LISTENER_ENABLED"], true), + host: env["LAN_LISTENER_HOST"]?.trim() || "0.0.0.0", + port: metadataPort, + }, + linkLocalListener: { + enabled: boolFromEnv(env["LINK_LOCAL_LISTENER_ENABLED"], true), + host: env["LINK_LOCAL_HOST"]?.trim() || LINK_LOCAL_ADDRESS, + port: intFromEnv("LINK_LOCAL_PORT", env["LINK_LOCAL_PORT"], 80, { + min: 1, + max: 65535, + }), + }, + machineEnvConfigPath, + machineMetadata: buildMachineMetadata(env, infisicalEnvironment), + }; +} diff --git a/src/daemon/http-utils.ts b/src/daemon/http-utils.ts new file mode 100644 index 0000000..4b8bd7d --- /dev/null +++ b/src/daemon/http-utils.ts @@ -0,0 +1,34 @@ +import type { IncomingHttpHeaders, IncomingMessage, ServerResponse } from "node:http"; + +export function getSingleHeader(headers: IncomingHttpHeaders, name: string): string | undefined { + const value = headers[name.toLowerCase()]; + if (Array.isArray(value)) return value[0]; + return value; +} + +export function sendText( + res: ServerResponse, + statusCode: number, + body = "", + headers: Record = {}, +): void { + res.writeHead(statusCode, { + "Content-Type": "text/plain; charset=utf-8", + "Cache-Control": "no-store", + ...headers, + }); + res.end(body); +} + +export function sendJson(res: ServerResponse, statusCode: number, body: unknown): void { + res.writeHead(statusCode, { + "Content-Type": "application/json; charset=utf-8", + "Cache-Control": "no-store", + }); + res.end(JSON.stringify(body)); +} + +export function requestPath(req: IncomingMessage): string { + const url = new URL(req.url ?? "/", "http://metadata.local"); + return url.pathname; +} diff --git a/src/daemon/machine-metadata.ts b/src/daemon/machine-metadata.ts new file mode 100644 index 0000000..3994276 --- /dev/null +++ b/src/daemon/machine-metadata.ts @@ -0,0 +1,152 @@ +import fs from "node:fs"; +import os from "node:os"; +import crypto from "node:crypto"; +import type { InfisicalEnvironment } from "../common/secret-manager.js"; +import type { EnvTarget } from "../common/dotenv.js"; + +export interface MachineMetadata { + hostname: string; + localHostname: string; + localIpv4: string; + mac: string; + machineId: string; + environment: InfisicalEnvironment; + role: string | undefined; + tags: Record; + userData: string | undefined; +} + +export interface InstanceIdentityDocument { + documentVersion: string; + service: "machine-env-service"; + machineId: string; + hostname: string; + localHostname: string; + localIpV4: string; + mac: string; + environment: InfisicalEnvironment; + role?: string; + tags: Record; +} + +interface PrimaryNetworkIdentity { + localIpv4: string; + mac: string; +} + +function readFirstExistingFile(paths: readonly string[]): string | undefined { + for (const filePath of paths) { + try { + const value = fs.readFileSync(filePath, "utf8").trim(); + if (value) return value; + } catch { + // Missing OS-specific identity files are expected on some platforms. + } + } + + return undefined; +} + +function resolvePrimaryNetworkIdentity(): PrimaryNetworkIdentity { + for (const addresses of Object.values(os.networkInterfaces())) { + for (const address of addresses ?? []) { + if (address.family !== "IPv4" || address.internal) continue; + return { + localIpv4: address.address, + mac: address.mac || "00:00:00:00:00:00", + }; + } + } + + return { + localIpv4: "127.0.0.1", + mac: "00:00:00:00:00:00", + }; +} + +function fallbackMachineId(hostname: string, localIpv4: string, mac: string): string { + return crypto + .createHash("sha256") + .update(`${hostname}|${localIpv4}|${mac}`) + .digest("hex"); +} + +function parseTags(value: string | undefined): Record { + const tags: Record = {}; + if (!value) return tags; + + for (const rawPair of value.split(/[,\n]/)) { + const pair = rawPair.trim(); + if (!pair) continue; + + const separator = pair.indexOf("="); + if (separator <= 0) continue; + + const key = pair.slice(0, separator).trim(); + const tagValue = pair.slice(separator + 1).trim(); + if (!key || key.includes("/")) continue; + + tags[key] = tagValue; + } + + return tags; +} + +function readUserData(env: EnvTarget): string | undefined { + const inline = env["USER_DATA"] ?? env["MACHINE_USER_DATA"] ?? env["METADATA_USER_DATA"]; + if (inline !== undefined) return inline; + + const filePath = env["USER_DATA_FILE"] ?? env["MACHINE_USER_DATA_FILE"] ?? env["METADATA_USER_DATA_FILE"]; + if (!filePath?.trim()) return undefined; + + try { + return fs.readFileSync(filePath.trim(), "utf8"); + } catch (error) { + const message = error instanceof Error ? error.message : String(error); + console.warn(`[Config] Failed to read user-data file ${filePath}: ${message}`); + return undefined; + } +} + +export function buildMachineMetadata( + env: EnvTarget, + environment: InfisicalEnvironment, +): MachineMetadata { + const hostname = env["MACHINE_HOSTNAME"]?.trim() || os.hostname(); + const network = resolvePrimaryNetworkIdentity(); + const localIpv4 = env["MACHINE_LOCAL_IPV4"]?.trim() || network.localIpv4; + const mac = env["MACHINE_MAC"]?.trim() || network.mac; + const machineId = + env["MACHINE_ID"]?.trim() || + readFirstExistingFile(["/etc/machine-id", "/var/lib/dbus/machine-id"]) || + fallbackMachineId(hostname, localIpv4, mac); + + return { + hostname, + localHostname: env["MACHINE_LOCAL_HOSTNAME"]?.trim() || hostname, + localIpv4, + mac, + machineId, + environment, + role: env["MACHINE_ROLE"]?.trim() || env["METADATA_ROLE"]?.trim() || undefined, + tags: parseTags(env["MACHINE_TAGS"] ?? env["METADATA_TAGS"]), + userData: readUserData(env), + }; +} + +export function buildInstanceIdentityDocument( + metadata: MachineMetadata, +): InstanceIdentityDocument { + return { + documentVersion: "2026-05-01", + service: "machine-env-service", + machineId: metadata.machineId, + hostname: metadata.hostname, + localHostname: metadata.localHostname, + localIpV4: metadata.localIpv4, + mac: metadata.mac, + environment: metadata.environment, + ...(metadata.role ? { role: metadata.role } : {}), + tags: metadata.tags, + }; +} diff --git a/src/daemon/main.ts b/src/daemon/main.ts new file mode 100644 index 0000000..3da6fe2 --- /dev/null +++ b/src/daemon/main.ts @@ -0,0 +1,54 @@ +#!/usr/bin/env node +import { loadEnvironmentFromNodeEnv } from "../common/env-loader.js"; +import { loadConfig } from "./config.js"; +import { MetadataServer } from "./server.js"; +import { SecretCache } from "./store/secret-cache.js"; +import { TokenStore } from "./store/token-store.js"; + +async function run(): Promise { + if (!process.env["MACHINE_ENV_CONFIG"]) { + loadEnvironmentFromNodeEnv(); + } + + const config = loadConfig(); + const secretCache = new SecretCache({ + infisical: config.infisical, + allowlist: config.secretAllowlist, + refreshIntervalMs: config.refreshIntervalMs, + }); + const tokenStore = new TokenStore(config.tokenSweepIntervalMs); + const server = new MetadataServer({ config, secretCache, tokenStore }); + + tokenStore.start(); + await secretCache.start(); + await server.start(); + + const shutdown = async (signal: NodeJS.Signals): Promise => { + console.info(`[Main] Received ${signal}; shutting down.`); + process.off("SIGTERM", onSigterm); + process.off("SIGINT", onSigint); + + try { + await server.stop(); + secretCache.stop(); + tokenStore.stop(); + process.exitCode = 0; + } catch (error) { + const message = error instanceof Error ? error.message : String(error); + console.error(`[Main] Shutdown failed: ${message}`); + process.exitCode = 1; + } + }; + + const onSigterm = (): void => void shutdown("SIGTERM"); + const onSigint = (): void => void shutdown("SIGINT"); + + process.on("SIGTERM", onSigterm); + process.on("SIGINT", onSigint); +} + +run().catch((error: unknown) => { + const message = error instanceof Error ? error.message : String(error); + console.error(`[Main] Failed to start: ${message}`); + process.exitCode = 1; +}); diff --git a/src/daemon/middleware/ssrf-guard.ts b/src/daemon/middleware/ssrf-guard.ts new file mode 100644 index 0000000..a8662d0 --- /dev/null +++ b/src/daemon/middleware/ssrf-guard.ts @@ -0,0 +1,47 @@ +import type { IncomingMessage, ServerResponse } from "node:http"; +import { getSingleHeader, requestPath, sendText } from "../http-utils.js"; + +export interface SsrfGuardOptions { + allowedHosts: readonly string[]; +} + +function normalizeHost(host: string): string { + const trimmed = host.trim().toLowerCase(); + if (!trimmed) return trimmed; + if (trimmed.startsWith("[")) { + const closingBracket = trimmed.indexOf("]"); + return closingBracket === -1 ? trimmed : trimmed.slice(1, closingBracket); + } + + const colon = trimmed.lastIndexOf(":"); + if (colon === -1) return trimmed; + + const maybePort = trimmed.slice(colon + 1); + if (/^\d+$/.test(maybePort)) return trimmed.slice(0, colon); + return trimmed; +} + +export function ssrfGuard( + req: IncomingMessage, + res: ServerResponse, + options: SsrfGuardOptions, +): boolean { + if (getSingleHeader(req.headers, "x-forwarded-for") !== undefined) { + sendText(res, 403); + return false; + } + + const host = getSingleHeader(req.headers, "host"); + if (!host || !options.allowedHosts.includes(normalizeHost(host))) { + sendText(res, 403); + return false; + } + + if (requestPath(req) === "/latest/api/token" && req.method !== "PUT") { + res.setHeader("Allow", "PUT"); + sendText(res, 405); + return false; + } + + return true; +} diff --git a/src/daemon/middleware/token-auth.ts b/src/daemon/middleware/token-auth.ts new file mode 100644 index 0000000..5cfdb9c --- /dev/null +++ b/src/daemon/middleware/token-auth.ts @@ -0,0 +1,19 @@ +import type { IncomingMessage, ServerResponse } from "node:http"; +import { getSingleHeader, sendText } from "../http-utils.js"; +import type { TokenStore } from "../store/token-store.js"; + +const TOKEN_HEADER = "x-aws-ec2-metadata-token"; + +export function requireMetadataToken( + req: IncomingMessage, + res: ServerResponse, + tokenStore: TokenStore, +): boolean { + const token = getSingleHeader(req.headers, TOKEN_HEADER); + if (!tokenStore.validate(token)) { + sendText(res, 401); + return false; + } + + return true; +} diff --git a/src/daemon/routes/dynamic.ts b/src/daemon/routes/dynamic.ts new file mode 100644 index 0000000..1bd215a --- /dev/null +++ b/src/daemon/routes/dynamic.ts @@ -0,0 +1,49 @@ +import type { IncomingMessage, ServerResponse } from "node:http"; +import { requestPath, sendJson, sendText } from "../http-utils.js"; +import { + buildInstanceIdentityDocument, + type MachineMetadata, +} from "../machine-metadata.js"; + +const DYNAMIC_ROOT = "/latest/dynamic/"; +const INSTANCE_IDENTITY_ROOT = "/latest/dynamic/instance-identity/"; + +export function handleDynamicRequest( + req: IncomingMessage, + res: ServerResponse, + metadata: MachineMetadata, +): void { + if (req.method !== "GET") { + res.setHeader("Allow", "GET"); + sendText(res, 405); + return; + } + + const pathname = requestPath(req); + if (pathname === "/latest/dynamic") { + sendText(res, 301, "", { Location: DYNAMIC_ROOT }); + return; + } + + if (pathname === DYNAMIC_ROOT) { + sendText(res, 200, "instance-identity/\n"); + return; + } + + if (pathname === "/latest/dynamic/instance-identity") { + sendText(res, 301, "", { Location: INSTANCE_IDENTITY_ROOT }); + return; + } + + if (pathname === INSTANCE_IDENTITY_ROOT) { + sendText(res, 200, "document\n"); + return; + } + + if (pathname === "/latest/dynamic/instance-identity/document") { + sendJson(res, 200, buildInstanceIdentityDocument(metadata)); + return; + } + + sendText(res, 404); +} diff --git a/src/daemon/routes/metadata.ts b/src/daemon/routes/metadata.ts new file mode 100644 index 0000000..a5f3e17 --- /dev/null +++ b/src/daemon/routes/metadata.ts @@ -0,0 +1,186 @@ +import type { IncomingMessage, ServerResponse } from "node:http"; +import { requestPath, sendText } from "../http-utils.js"; +import type { MachineMetadata } from "../machine-metadata.js"; +import type { SecretCache } from "../store/secret-cache.js"; +import { + handleSecretsBundle, + handleSecretsDirectory, + handleSecretValue, +} from "./secrets.js"; + +const META_DATA_ROOT = "/latest/meta-data/"; +const SECRETS_PREFIX = "/latest/meta-data/secrets/"; +const TAGS_PREFIX = "/latest/meta-data/tags/"; +const INSTANCE_TAGS_PREFIX = "/latest/meta-data/tags/instance/"; + +export interface MetadataRouteOptions { + cache: SecretCache; + allowSecretsBundle: boolean; + machineMetadata: MachineMetadata; +} + +function listRootEntries(options: MetadataRouteOptions): string { + const entries = [ + "environment", + "hostname", + "local-hostname", + "local-ipv4", + "mac", + "machine-id", + "secrets/", + "tags/", + ]; + + if (options.machineMetadata.role) entries.push("role"); + if (options.allowSecretsBundle) entries.push("secrets-bundle"); + return `${entries.sort().join("\n")}\n`; +} + +function decodePathSegment(segment: string): string | null { + try { + const decoded = decodeURIComponent(segment); + if (!decoded || decoded.includes("/")) return null; + return decoded; + } catch { + return null; + } +} + +function sendOptionalText(res: ServerResponse, value: string | undefined): void { + if (value === undefined) { + sendText(res, 404); + return; + } + + sendText(res, 200, value); +} + +function handleTagsRequest( + pathname: string, + res: ServerResponse, + metadata: MachineMetadata, +): boolean { + if (pathname === "/latest/meta-data/tags") { + sendText(res, 301, "", { Location: TAGS_PREFIX }); + return true; + } + + if (pathname === TAGS_PREFIX) { + sendText(res, 200, "instance/\n"); + return true; + } + + if (pathname === "/latest/meta-data/tags/instance") { + sendText(res, 301, "", { Location: INSTANCE_TAGS_PREFIX }); + return true; + } + + if (pathname === INSTANCE_TAGS_PREFIX) { + const keys = Object.keys(metadata.tags).sort(); + sendText(res, 200, keys.length === 0 ? "" : `${keys.join("\n")}\n`); + return true; + } + + if (pathname.startsWith(INSTANCE_TAGS_PREFIX)) { + const key = decodePathSegment(pathname.slice(INSTANCE_TAGS_PREFIX.length)); + if (!key) { + sendText(res, 404); + return true; + } + + sendOptionalText(res, metadata.tags[key]); + return true; + } + + if (pathname.startsWith(TAGS_PREFIX)) { + const key = decodePathSegment(pathname.slice(TAGS_PREFIX.length)); + if (!key || key === "instance") { + sendText(res, 404); + return true; + } + + sendOptionalText(res, metadata.tags[key]); + return true; + } + + return false; +} + +export function handleMetadataRequest( + req: IncomingMessage, + res: ServerResponse, + options: MetadataRouteOptions, +): void { + if (req.method !== "GET") { + res.setHeader("Allow", "GET"); + sendText(res, 405); + return; + } + + const pathname = requestPath(req); + if (pathname === "/latest/meta-data") { + sendText(res, 301, "", { Location: META_DATA_ROOT }); + return; + } + + if (pathname === META_DATA_ROOT) { + sendText(res, 200, listRootEntries(options)); + return; + } + + if (pathname === "/latest/meta-data/environment") { + sendText(res, 200, options.machineMetadata.environment); + return; + } + + if (pathname === "/latest/meta-data/hostname") { + sendText(res, 200, options.machineMetadata.hostname); + return; + } + + if (pathname === "/latest/meta-data/local-hostname") { + sendText(res, 200, options.machineMetadata.localHostname); + return; + } + + if (pathname === "/latest/meta-data/local-ipv4") { + sendText(res, 200, options.machineMetadata.localIpv4); + return; + } + + if (pathname === "/latest/meta-data/mac") { + sendText(res, 200, options.machineMetadata.mac); + return; + } + + if (pathname === "/latest/meta-data/machine-id") { + sendText(res, 200, options.machineMetadata.machineId); + return; + } + + if (pathname === "/latest/meta-data/role") { + sendOptionalText(res, options.machineMetadata.role); + return; + } + + if (handleTagsRequest(pathname, res, options.machineMetadata)) { + return; + } + + if (pathname === SECRETS_PREFIX) { + handleSecretsDirectory(res, options.cache); + return; + } + + if (pathname.startsWith(SECRETS_PREFIX)) { + handleSecretValue(pathname, res, options.cache); + return; + } + + if (pathname === "/latest/meta-data/secrets-bundle") { + handleSecretsBundle(res, options.cache, options.allowSecretsBundle); + return; + } + + sendText(res, 404); +} diff --git a/src/daemon/routes/secrets.ts b/src/daemon/routes/secrets.ts new file mode 100644 index 0000000..9ff1f6f --- /dev/null +++ b/src/daemon/routes/secrets.ts @@ -0,0 +1,50 @@ +import type { ServerResponse } from "node:http"; +import { sendJson, sendText } from "../http-utils.js"; +import type { SecretCache } from "../store/secret-cache.js"; + +const SECRETS_PREFIX = "/latest/meta-data/secrets/"; + +function decodeSecretKey(rawKey: string): string | null { + try { + const decoded = decodeURIComponent(rawKey); + if (!decoded || decoded.includes("/")) return null; + return decoded; + } catch { + return null; + } +} + +export function handleSecretsDirectory(res: ServerResponse, cache: SecretCache): void { + const keys = cache.list(); + sendText(res, 200, keys.length === 0 ? "" : `${keys.join("\n")}\n`); +} + +export function handleSecretValue(pathname: string, res: ServerResponse, cache: SecretCache): void { + const rawKey = pathname.slice(SECRETS_PREFIX.length); + const key = decodeSecretKey(rawKey); + if (!key || !cache.isAllowed(key)) { + sendText(res, 404); + return; + } + + const value = cache.get(key); + if (value === undefined) { + sendText(res, 404); + return; + } + + sendText(res, 200, value); +} + +export function handleSecretsBundle( + res: ServerResponse, + cache: SecretCache, + enabled: boolean, +): void { + if (!enabled) { + sendText(res, 404); + return; + } + + sendJson(res, 200, cache.bundle()); +} diff --git a/src/daemon/routes/token.ts b/src/daemon/routes/token.ts new file mode 100644 index 0000000..e701c24 --- /dev/null +++ b/src/daemon/routes/token.ts @@ -0,0 +1,39 @@ +import type { IncomingMessage, ServerResponse } from "node:http"; +import { getSingleHeader, sendText } from "../http-utils.js"; +import { + MAX_TOKEN_TTL_SECONDS, + MIN_TOKEN_TTL_SECONDS, + type TokenStore, +} from "../store/token-store.js"; + +const TTL_HEADER = "x-aws-ec2-metadata-token-ttl-seconds"; + +function parseTokenTtl(req: IncomingMessage): number | null { + const raw = getSingleHeader(req.headers, TTL_HEADER); + if (!raw) return null; + + const ttl = Number.parseInt(raw, 10); + if (!Number.isInteger(ttl) || String(ttl) !== raw.trim()) return null; + if (ttl < MIN_TOKEN_TTL_SECONDS || ttl > MAX_TOKEN_TTL_SECONDS) return null; + return ttl; +} + +export function handleTokenRequest( + req: IncomingMessage, + res: ServerResponse, + tokenStore: TokenStore, +): void { + if (req.method !== "PUT") { + res.setHeader("Allow", "PUT"); + sendText(res, 405); + return; + } + + const ttl = parseTokenTtl(req); + if (ttl === null) { + sendText(res, 400); + return; + } + + sendText(res, 200, tokenStore.issue(ttl)); +} diff --git a/src/daemon/routes/user-data.ts b/src/daemon/routes/user-data.ts new file mode 100644 index 0000000..3e4c6d7 --- /dev/null +++ b/src/daemon/routes/user-data.ts @@ -0,0 +1,22 @@ +import type { IncomingMessage, ServerResponse } from "node:http"; +import { sendText } from "../http-utils.js"; +import type { MachineMetadata } from "../machine-metadata.js"; + +export function handleUserDataRequest( + req: IncomingMessage, + res: ServerResponse, + metadata: MachineMetadata, +): void { + if (req.method !== "GET") { + res.setHeader("Allow", "GET"); + sendText(res, 405); + return; + } + + if (metadata.userData === undefined) { + sendText(res, 404); + return; + } + + sendText(res, 200, metadata.userData); +} diff --git a/src/daemon/server.ts b/src/daemon/server.ts new file mode 100644 index 0000000..735da63 --- /dev/null +++ b/src/daemon/server.ts @@ -0,0 +1,120 @@ +import http, { type IncomingMessage, type Server, type ServerResponse } from "node:http"; +import type { DaemonConfig, ListenerConfig } from "./config.js"; +import { requestPath, sendText } from "./http-utils.js"; +import { ssrfGuard } from "./middleware/ssrf-guard.js"; +import { requireMetadataToken } from "./middleware/token-auth.js"; +import { handleDynamicRequest } from "./routes/dynamic.js"; +import { handleMetadataRequest } from "./routes/metadata.js"; +import { handleTokenRequest } from "./routes/token.js"; +import { handleUserDataRequest } from "./routes/user-data.js"; +import type { SecretCache } from "./store/secret-cache.js"; +import type { TokenStore } from "./store/token-store.js"; + +export interface MetadataServerOptions { + config: DaemonConfig; + secretCache: SecretCache; + tokenStore: TokenStore; +} + +interface RunningServer { + name: string; + server: Server; +} + +export class MetadataServer { + private readonly servers: RunningServer[] = []; + private closing = false; + + constructor(private readonly options: MetadataServerOptions) {} + + async start(): Promise { + const listeners = [ + { name: "link-local", config: this.options.config.linkLocalListener }, + { name: "lan", config: this.options.config.lanListener }, + ]; + + for (const listener of listeners) { + if (!listener.config.enabled) continue; + await this.listen(listener.name, listener.config); + } + } + + async stop(): Promise { + this.closing = true; + await Promise.all( + this.servers.map( + ({ server }) => + new Promise((resolve, reject) => { + server.close((error) => { + if (error) reject(error); + else resolve(); + }); + }), + ), + ); + this.servers.length = 0; + } + + private async listen(name: string, config: ListenerConfig): Promise { + const server = http.createServer((req, res) => this.handleRequest(req, res)); + + await new Promise((resolve, reject) => { + const onError = (error: Error): void => { + server.off("listening", onListening); + reject(error); + }; + const onListening = (): void => { + server.off("error", onError); + resolve(); + }; + + server.once("error", onError); + server.once("listening", onListening); + server.listen(config.port, config.host); + }); + + this.servers.push({ name, server }); + console.info(`[Server] ${name} listener ready on ${config.host}:${config.port}`); + } + + private handleRequest(req: IncomingMessage, res: ServerResponse): void { + if (this.closing) { + sendText(res, 503); + return; + } + + if (!ssrfGuard(req, res, { allowedHosts: this.options.config.allowedHosts })) { + return; + } + + const pathname = requestPath(req); + if (pathname === "/latest/api/token") { + handleTokenRequest(req, res, this.options.tokenStore); + return; + } + + if (pathname === "/latest/meta-data" || pathname.startsWith("/latest/meta-data/")) { + if (!requireMetadataToken(req, res, this.options.tokenStore)) return; + handleMetadataRequest(req, res, { + cache: this.options.secretCache, + allowSecretsBundle: this.options.config.allowSecretsBundle, + machineMetadata: this.options.config.machineMetadata, + }); + return; + } + + if (pathname === "/latest/dynamic" || pathname.startsWith("/latest/dynamic/")) { + if (!requireMetadataToken(req, res, this.options.tokenStore)) return; + handleDynamicRequest(req, res, this.options.config.machineMetadata); + return; + } + + if (pathname === "/latest/user-data") { + if (!requireMetadataToken(req, res, this.options.tokenStore)) return; + handleUserDataRequest(req, res, this.options.config.machineMetadata); + return; + } + + sendText(res, 404); + } +} diff --git a/src/daemon/store/secret-cache.ts b/src/daemon/store/secret-cache.ts new file mode 100644 index 0000000..d8be1e9 --- /dev/null +++ b/src/daemon/store/secret-cache.ts @@ -0,0 +1,88 @@ +import { + fetchInfisicalSecrets, + type InfisicalSecretConfig, + type RawSecretMap, +} from "../../common/secret-manager.js"; + +export interface SecretCacheOptions { + infisical: InfisicalSecretConfig; + allowlist: readonly string[]; + refreshIntervalMs: number; +} + +export class SecretCache { + private readonly allowedKeys: Set; + private secrets = new Map(); + private refreshTimer: NodeJS.Timeout | undefined; + private refreshInFlight: Promise | undefined; + + lastRefreshAt: Date | undefined; + lastError: Error | undefined; + + constructor(private readonly options: SecretCacheOptions) { + this.allowedKeys = new Set(options.allowlist); + } + + async start(): Promise { + await this.refresh(); + if (this.refreshTimer) return; + + this.refreshTimer = setInterval(() => { + void this.refresh(); + }, this.options.refreshIntervalMs); + this.refreshTimer.unref(); + } + + stop(): void { + if (!this.refreshTimer) return; + clearInterval(this.refreshTimer); + this.refreshTimer = undefined; + } + + async refresh(): Promise { + if (this.refreshInFlight) return this.refreshInFlight; + + this.refreshInFlight = this.fetchAndSwap() + .catch((error: unknown) => { + this.lastError = error instanceof Error ? error : new Error(String(error)); + console.error(`[SecretCache] Refresh failed: ${this.lastError.message}`); + }) + .finally(() => { + this.refreshInFlight = undefined; + }); + + return this.refreshInFlight; + } + + get(key: string): string | undefined { + if (!this.allowedKeys.has(key)) return undefined; + return this.secrets.get(key); + } + + isAllowed(key: string): boolean { + return this.allowedKeys.has(key); + } + + list(): string[] { + return [...this.secrets.keys()].sort(); + } + + bundle(): RawSecretMap { + return Object.fromEntries([...this.secrets.entries()].sort(([left], [right]) => left.localeCompare(right))); + } + + private async fetchAndSwap(): Promise { + const fetched = await fetchInfisicalSecrets(this.options.infisical, this.options.allowlist); + const next = new Map(); + + for (const key of this.allowedKeys) { + const value = fetched.raw[key]; + if (value !== undefined) next.set(key, value); + } + + this.secrets = next; + this.lastError = undefined; + this.lastRefreshAt = new Date(); + console.info(`[SecretCache] Loaded ${this.secrets.size} allowed secret(s).`); + } +} diff --git a/src/daemon/store/token-store.ts b/src/daemon/store/token-store.ts new file mode 100644 index 0000000..4a08e15 --- /dev/null +++ b/src/daemon/store/token-store.ts @@ -0,0 +1,59 @@ +import crypto from "node:crypto"; + +export const MIN_TOKEN_TTL_SECONDS = 1; +export const MAX_TOKEN_TTL_SECONDS = 21_600; + +export class TokenStore { + private readonly tokens = new Map(); + private sweepTimer: NodeJS.Timeout | undefined; + + constructor(private readonly sweepIntervalMs: number) {} + + start(): void { + if (this.sweepTimer) return; + this.sweepTimer = setInterval(() => this.sweepExpired(), this.sweepIntervalMs); + this.sweepTimer.unref(); + } + + stop(): void { + if (!this.sweepTimer) return; + clearInterval(this.sweepTimer); + this.sweepTimer = undefined; + this.tokens.clear(); + } + + issue(ttlSeconds: number): string { + if (ttlSeconds < MIN_TOKEN_TTL_SECONDS || ttlSeconds > MAX_TOKEN_TTL_SECONDS) { + throw new Error( + `Token TTL must be between ${MIN_TOKEN_TTL_SECONDS} and ${MAX_TOKEN_TTL_SECONDS} seconds`, + ); + } + + const token = crypto.randomBytes(32).toString("base64url"); + this.tokens.set(token, Date.now() + ttlSeconds * 1000); + return token; + } + + validate(token: string | undefined): boolean { + if (!token) return false; + const expiresAt = this.tokens.get(token); + if (!expiresAt) return false; + + if (expiresAt <= Date.now()) { + this.tokens.delete(token); + return false; + } + + return true; + } + + sweepExpired(now = Date.now()): number { + let removed = 0; + for (const [token, expiresAt] of this.tokens) { + if (expiresAt > now) continue; + this.tokens.delete(token); + removed += 1; + } + return removed; + } +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..f243d2e --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "rootDir": "src", + "outDir": "dist", + "strict": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "skipLibCheck": true, + "types": ["node"] + }, + "include": ["src/**/*.ts"] +}