github-connection.mjs
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd
feat(calendar): enforce agent context tiers in retrieval AP…
Human
minor
⚠ breaking
1 day ago
| 1 | /** |
| 2 | * GitHub connection (self-hosted): store access token for "Connect GitHub" flow. |
| 3 | * Used when pushing vault to a user's repo; token is stored in data_dir (do not commit). |
| 4 | */ |
| 5 | |
| 6 | import fs from 'fs'; |
| 7 | import path from 'path'; |
| 8 | |
| 9 | const FILENAME = 'github_connection.json'; |
| 10 | |
| 11 | /** |
| 12 | * @param {string} dataDir |
| 13 | * @returns {{ access_token?: string } | null} |
| 14 | */ |
| 15 | export function readConnection(dataDir) { |
| 16 | if (!dataDir) return null; |
| 17 | const p = path.join(dataDir, FILENAME); |
| 18 | if (!fs.existsSync(p)) return null; |
| 19 | try { |
| 20 | const raw = fs.readFileSync(p, 'utf8'); |
| 21 | const data = JSON.parse(raw); |
| 22 | return data && typeof data === 'object' ? data : null; |
| 23 | } catch (_) { |
| 24 | return null; |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * @param {string} dataDir |
| 30 | * @param {{ access_token: string }} data |
| 31 | */ |
| 32 | export function writeConnection(dataDir, data) { |
| 33 | if (!dataDir) throw new Error('data_dir required'); |
| 34 | const p = path.join(dataDir, FILENAME); |
| 35 | fs.mkdirSync(dataDir, { recursive: true }); |
| 36 | fs.writeFileSync(p, JSON.stringify({ access_token: data.access_token || '' }, null, 0), 'utf8'); |
| 37 | } |
File History
2 commits
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd
feat(calendar): enforce agent context tiers in retrieval AP…
Human
minor
⚠
1 day ago
sha256:9103f98c89257ed2b01c237cea895dabb3e85ea337dccb1161c175e4422355b6
docs: accept Calendar Events v0 spec with Phase 0 security …
Human
1 day ago