typevault 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/access/scoped.ts +10 -6
- package/src/access/sealed-access.ts +9 -5
- package/src/access/sealed.ts +12 -8
- package/src/audit/log.ts +71 -18
- package/src/cli/commands/admin.ts +2 -1
- package/src/cli/commands/grant.ts +7 -1
- package/src/cli/commands/members.ts +22 -6
- package/src/cli/context.ts +13 -6
- package/src/cli/index.ts +5 -3
- package/src/core/admin.ts +33 -16
- package/src/core/entries.ts +7 -2
- package/src/core/init.ts +2 -1
- package/src/core/keyring.ts +5 -1
- package/src/core/layout.ts +13 -11
- package/src/core/owner-trust.ts +97 -0
- package/src/core/rotate.ts +67 -6
- package/src/core/secure-enclave.ts +61 -17
- package/src/core/state.ts +21 -23
- package/src/core/touch-id.ts +6 -0
- package/src/core/vault.ts +46 -10
- package/src/daemon/admin-routes.ts +23 -15
- package/src/daemon/agent-routes.ts +11 -7
- package/src/daemon/daemon.ts +19 -6
- package/src/daemon/requests.ts +35 -23
package/src/daemon/daemon.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { claimDaemon, type DaemonClaim, refuseForeignDaemon } from '../core/hold
|
|
|
10
10
|
import { type Layout, localLayout } from '../core/layout'
|
|
11
11
|
import { holdLock, isLockHeld } from '../core/lock'
|
|
12
12
|
import { loadState, readOwner } from '../core/state'
|
|
13
|
-
import { Vault } from '../core/vault'
|
|
13
|
+
import { readSnapshot, Vault } from '../core/vault'
|
|
14
14
|
import { worktreeVaults } from '../core/worktrees'
|
|
15
15
|
import { adminRoutes, type Ceiling } from './admin-routes'
|
|
16
16
|
import { agentRoutes, type DaemonContext } from './agent-routes'
|
|
@@ -56,7 +56,11 @@ async function openSession(context: DaemonContext, ttlMs: number): Promise<strin
|
|
|
56
56
|
const tiers = [...(await vault.keyring.reachableTiers())].sort()
|
|
57
57
|
const { token, record } = grants.issue({ tiers, only: [], ttlMs, label: 'session', ceiling: SESSION_CEILING })
|
|
58
58
|
atomicWrite(vault.layout.sessionFile, token, 0o600)
|
|
59
|
-
await appendAudit(
|
|
59
|
+
await appendAudit(
|
|
60
|
+
vault.layout,
|
|
61
|
+
{ action: 'grant.issue', mode: 'live', grant: record.id, label: 'session', tiers },
|
|
62
|
+
vault.anchorsFile,
|
|
63
|
+
)
|
|
60
64
|
return record.id
|
|
61
65
|
}
|
|
62
66
|
|
|
@@ -145,10 +149,19 @@ async function serve(options: DaemonOptions, claim: DaemonClaim, releaseLock: ()
|
|
|
145
149
|
// A shared session whose source is gone answers nothing but ping (how `stopDaemon` finds it) until it stops.
|
|
146
150
|
const bound =
|
|
147
151
|
(fetch: (request: Request) => Promise<Response>) =>
|
|
148
|
-
async (request: Request): Promise<Response> =>
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
+
async (request: Request): Promise<Response> => {
|
|
153
|
+
if (new URL(request.url).pathname === '/v1/ping') return fetch(request)
|
|
154
|
+
if (!sourceAlive()) return errorResponse(new TypeVaultError('locked', LOCKED_MESSAGE))
|
|
155
|
+
try {
|
|
156
|
+
// Includes cached redaction values and worktree attachment: neither necessarily scans the vault. The snapshot
|
|
157
|
+
// finishes an interrupted rotation and keeps a running one's half-written files out of view; it's released
|
|
158
|
+
// before dispatch so writes can take the lock.
|
|
159
|
+
await readSnapshot(layout, options.env, async () => vault.refresh())
|
|
160
|
+
} catch (error) {
|
|
161
|
+
return errorResponse(error)
|
|
162
|
+
}
|
|
163
|
+
return fetch(request)
|
|
164
|
+
}
|
|
152
165
|
const listen = (path: string, fetch: (request: Request) => Promise<Response>) => {
|
|
153
166
|
const server = Bun.serve({ unix: path, fetch, maxRequestBodySize: 1 << 20 })
|
|
154
167
|
// Windows sockets take the run directory's ACL; chmod there only toggles read-only.
|
package/src/daemon/requests.ts
CHANGED
|
@@ -96,13 +96,17 @@ export class PromptRequests {
|
|
|
96
96
|
}
|
|
97
97
|
if (!session.isLive()) throw new TypeVaultError('denied', 'the requesting grant is no longer live')
|
|
98
98
|
await session.access.set({ name: input.name, fields: payload.fields, tier })
|
|
99
|
-
await appendAudit(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
99
|
+
await appendAudit(
|
|
100
|
+
this.#vault.layout,
|
|
101
|
+
{
|
|
102
|
+
action: 'request.stored',
|
|
103
|
+
mode: 'live',
|
|
104
|
+
grant: grant.id,
|
|
105
|
+
label: grant.label,
|
|
106
|
+
entries: [input.name],
|
|
107
|
+
},
|
|
108
|
+
this.#vault.anchorsFile,
|
|
109
|
+
)
|
|
106
110
|
await handle.accept()
|
|
107
111
|
return input.name
|
|
108
112
|
} catch (error) {
|
|
@@ -111,13 +115,17 @@ export class PromptRequests {
|
|
|
111
115
|
? error
|
|
112
116
|
: new TypeVaultError('unavailable', 'the submitted secret could not be stored')
|
|
113
117
|
try {
|
|
114
|
-
await appendAudit(
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
await appendAudit(
|
|
119
|
+
this.#vault.layout,
|
|
120
|
+
{
|
|
121
|
+
action: 'request.rejected',
|
|
122
|
+
mode: 'live',
|
|
123
|
+
grant: grant.id,
|
|
124
|
+
label: grant.label,
|
|
125
|
+
entries: [input.name],
|
|
126
|
+
},
|
|
127
|
+
this.#vault.anchorsFile,
|
|
128
|
+
)
|
|
121
129
|
} finally {
|
|
122
130
|
await handle.reject(rejected)
|
|
123
131
|
}
|
|
@@ -134,15 +142,19 @@ export class PromptRequests {
|
|
|
134
142
|
if (!(error instanceof TypeVaultError)) console.error('typevault daemon: storing a prompted secret failed', error)
|
|
135
143
|
})
|
|
136
144
|
this.#pending.set(handle.id, { owner: grant.id, stored })
|
|
137
|
-
await appendAudit(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
145
|
+
await appendAudit(
|
|
146
|
+
this.#vault.layout,
|
|
147
|
+
{
|
|
148
|
+
action: 'request.open',
|
|
149
|
+
mode: 'live',
|
|
150
|
+
grant: grant.id,
|
|
151
|
+
label: grant.label,
|
|
152
|
+
entries: [input.name],
|
|
153
|
+
tiers: [tier],
|
|
154
|
+
reason: input.reason,
|
|
155
|
+
},
|
|
156
|
+
this.#vault.anchorsFile,
|
|
157
|
+
)
|
|
146
158
|
return { id: handle.id, url: handle.url, code, expiresAt }
|
|
147
159
|
}
|
|
148
160
|
|