companion-keychain-fake.mjs
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd
feat(calendar): enforce agent context tiers in retrieval AP…
Human
minor
⚠ breaking
1 day ago
| 1 | /** |
| 2 | * Test-only in-memory keychain adapter for the Phase 3 token-custody module. |
| 3 | * |
| 4 | * NOT a test file (lives under test/helpers/, outside the `test/*.test.mjs` glob). It exists so |
| 5 | * the custody tests can inject a deterministic, volatile `{ get, set, delete }` adapter in place |
| 6 | * of a real OS keychain. This is exactly the seam the custody module relies on: the module never |
| 7 | * performs real keychain I/O — it delegates to whatever adapter is injected (this fake in tests; |
| 8 | * macOS Keychain / Windows DPAPI / Linux libsecret in Phase 5). |
| 9 | * |
| 10 | * Two flavors are provided to prove the custody code drives a synchronous OR a Promise-returning |
| 11 | * adapter identically (the module awaits every call). |
| 12 | */ |
| 13 | |
| 14 | /** |
| 15 | * A synchronous in-memory keychain. |
| 16 | * @returns {{ get: Function, set: Function, delete: Function, _store: Map<string,string>, writes: Array<{account:string,secret:string}> }} |
| 17 | */ |
| 18 | export function makeSyncKeychain() { |
| 19 | const store = new Map(); |
| 20 | const writes = []; |
| 21 | return { |
| 22 | _store: store, |
| 23 | writes, |
| 24 | get(account) { |
| 25 | return store.has(account) ? store.get(account) : null; |
| 26 | }, |
| 27 | set(account, secret) { |
| 28 | writes.push({ account, secret }); |
| 29 | store.set(account, secret); |
| 30 | }, |
| 31 | delete(account) { |
| 32 | store.delete(account); |
| 33 | }, |
| 34 | }; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * An async (Promise-returning) in-memory keychain — mirrors a real backend that returns Promises. |
| 39 | * @returns {{ get: Function, set: Function, delete: Function, _store: Map<string,string> }} |
| 40 | */ |
| 41 | export function makeAsyncKeychain() { |
| 42 | const store = new Map(); |
| 43 | return { |
| 44 | _store: store, |
| 45 | async get(account) { |
| 46 | return store.has(account) ? store.get(account) : null; |
| 47 | }, |
| 48 | async set(account, secret) { |
| 49 | store.set(account, secret); |
| 50 | }, |
| 51 | async delete(account) { |
| 52 | store.delete(account); |
| 53 | }, |
| 54 | }; |
| 55 | } |
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