@coffre/core 0.15.0 → 0.16.1
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/README.md +1 -1
- package/dist/{access-CgQTlUMz.js → access-CF8UG59J.js} +70 -95
- package/dist/{access-DqLJjnLM.d.ts → access-ERdGGHG7.d.ts} +45 -64
- package/dist/access.d.ts +2 -2
- package/dist/access.js +2 -2
- package/dist/envelope.d.ts +28 -9
- package/dist/envelope.js +25 -8
- package/dist/identity.d.ts +3 -1018
- package/dist/identity.js +885 -623
- package/dist/index-DuG9p3GH.d.ts +1233 -0
- package/dist/kek.d.ts +10 -16
- package/dist/kek.js +26 -41
- package/dist/log.d.ts +114 -0
- package/dist/log.js +291 -0
- package/dist/mcp.d.ts +27 -4
- package/dist/mcp.js +31 -10
- package/dist/recipe-BgJpmJum.d.ts +128 -0
- package/dist/recipe.d.ts +2 -127
- package/dist/{registry-D7X-x202.d.ts → registry-B7_LUDsJ.d.ts} +30 -5
- package/dist/schemas.d.ts +11 -9
- package/dist/schemas.js +16 -14
- package/dist/{types-Cp3lB_-W.js → types-DwTO_b4H.js} +17 -5
- package/dist/vault.d.ts +1771 -1419
- package/dist/vault.js +96 -302
- package/dist/{workloads-D049JH0M.d.ts → workloads-CW2dK4AW.d.ts} +1 -9
- package/dist/workloads.d.ts +2 -2
- package/dist/workloads.js +1 -9
- package/package.json +7 -7
- package/src/access.ts +63 -95
- package/src/changes/access.ts +140 -0
- package/src/changes/freezes.ts +40 -0
- package/src/changes/mcp.ts +150 -0
- package/src/changes/places.ts +219 -0
- package/src/changes/secrets.ts +235 -0
- package/src/changes/signin.ts +197 -0
- package/src/changes/workloads.ts +166 -0
- package/src/context.ts +18 -2
- package/src/envelope.ts +35 -12
- package/src/identity/auth.ts +11 -3
- package/src/identity/aws.ts +62 -0
- package/src/identity/github-app.ts +45 -24
- package/src/identity/index.ts +3 -2
- package/src/identity/{profile-rules.ts → profiles.ts} +1 -9
- package/src/identity/proofs.ts +306 -0
- package/src/identity/signin/config.ts +1 -1
- package/src/identity/tokens.ts +10 -3
- package/src/identity/verifier.ts +73 -14
- package/src/identity/workload-token.ts +4 -0
- package/src/identity/workloads.ts +0 -11
- package/src/kek/aws-kms.ts +18 -13
- package/src/kek/check.ts +16 -46
- package/src/kek/index.ts +2 -2
- package/src/kek/types.ts +15 -3
- package/src/log/index.ts +7 -0
- package/src/{audit → log}/tiles.ts +18 -49
- package/src/{audit → log}/tree.ts +2 -2
- package/src/mcp.ts +36 -9
- package/src/schemas.ts +15 -12
- package/src/vault.ts +251 -1150
- package/dist/merkle.d.ts +0 -456
- package/dist/merkle.js +0 -964
- package/src/answers.ts +0 -209
- package/src/audit/leaf.ts +0 -81
- package/src/audit/merkle.ts +0 -13
- package/src/audit/note.ts +0 -187
- package/src/audit/pair.ts +0 -86
- package/src/audit/verify.ts +0 -393
- package/src/audit/witness.ts +0 -50
- package/src/checkpoint.ts +0 -22
- package/src/identity/run-proof.ts +0 -159
package/dist/vault.js
CHANGED
|
@@ -1,25 +1,4 @@
|
|
|
1
|
-
import { B as isInstanceRole, H as isScope, M as grantKind, O as definitionProblem, _ as ROLES, b as UNWRITTEN_FORK_MS, i as EVERYWHERE, l as INSTANCE_ROLES, t as DEFAULT_POLICY } from "./access-CgQTlUMz.js";
|
|
2
1
|
import { createHash } from "node:crypto";
|
|
3
|
-
//#region src/checkpoint.ts
|
|
4
|
-
/** What a checkpoint's signature covers: the prefix of the log up to entry `seq`, and when. */
|
|
5
|
-
function checkpointMessage(checkpoint) {
|
|
6
|
-
const { seq, hash, signedAt } = checkpoint;
|
|
7
|
-
return new Uint8Array(new TextEncoder().encode(`coffre.checkpoint.v3|${seq}|${hash}|${signedAt}`));
|
|
8
|
-
}
|
|
9
|
-
/** Whether `checkpoint` was signed by the key whose raw public half is `publicKey`. */
|
|
10
|
-
async function verifyCheckpoint(checkpoint, publicKey) {
|
|
11
|
-
return (await checkpointVerifier(publicKey))(checkpoint);
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* `verifyCheckpoint` for many checkpoints signed by one key, the key
|
|
15
|
-
* imported once: a full verification checks every checkpoint, one every
|
|
16
|
-
* five minutes.
|
|
17
|
-
*/
|
|
18
|
-
async function checkpointVerifier(publicKey) {
|
|
19
|
-
const key = await crypto.subtle.importKey("raw", new Uint8Array(Buffer.from(publicKey, "base64")), { name: "Ed25519" }, false, ["verify"]);
|
|
20
|
-
return (checkpoint) => crypto.subtle.verify("Ed25519", key, new Uint8Array(Buffer.from(checkpoint.signature, "base64")), checkpointMessage(checkpoint));
|
|
21
|
-
}
|
|
22
|
-
//#endregion
|
|
23
2
|
//#region src/access-fault.ts
|
|
24
3
|
/** The fault in a sentence, with whatever names the caller can give. */
|
|
25
4
|
function describeAccessFault(fault, names = {}) {
|
|
@@ -41,201 +20,84 @@ function describeAccessFault(fault, names = {}) {
|
|
|
41
20
|
}
|
|
42
21
|
}
|
|
43
22
|
//#endregion
|
|
44
|
-
//#region src/
|
|
45
|
-
/** A member: `user:<email>` or `token:<name>`. */
|
|
46
|
-
const PRINCIPAL = /^(user|token):[^\s:][^\s]*$/;
|
|
47
|
-
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
48
|
-
/**
|
|
49
|
-
* What `access` answers about `principal`, from their row and their
|
|
50
|
-
* grants, lapsed ones too, as of `at`; `tampered` when a row failed the
|
|
51
|
-
* vault's check, which only the vault can tell.
|
|
52
|
-
*/
|
|
53
|
-
function answerFrom(principal, row, held, at, tampered, policy) {
|
|
54
|
-
const active = PRINCIPAL.test(principal) && !tampered && row?.status === "active";
|
|
55
|
-
const access = {
|
|
56
|
-
principal,
|
|
57
|
-
status: tampered ? "tampered" : !PRINCIPAL.test(principal) ? "unknown" : row?.status ?? "unknown",
|
|
58
|
-
generation: row?.generation ?? 0,
|
|
59
|
-
...active ? roleOf(principal, row) : {
|
|
60
|
-
role: "member",
|
|
61
|
-
scope: EVERYWHERE
|
|
62
|
-
},
|
|
63
|
-
grants: active ? held.filter((grant) => live(grant, at) && grantKind(grant) !== null).map(view) : [],
|
|
64
|
-
since: row ? iso(row.statusChangedAt) : null,
|
|
65
|
-
by: row?.statusChangedBy ?? null,
|
|
66
|
-
policy
|
|
67
|
-
};
|
|
68
|
-
return {
|
|
69
|
-
...access,
|
|
70
|
-
revision: accessRevision(access)
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
/** A member's instance role, as their row has it: service accounts are members, whatever a row says. */
|
|
74
|
-
function roleOf(principal, row) {
|
|
75
|
-
return principal.startsWith("user:") ? {
|
|
76
|
-
role: row.role,
|
|
77
|
-
scope: row.scope
|
|
78
|
-
} : {
|
|
79
|
-
role: "member",
|
|
80
|
-
scope: EVERYWHERE
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
/** Whether a grant still holds at `at`. */
|
|
84
|
-
function live(grant, at) {
|
|
85
|
-
return grant.expiresAt === null || grant.expiresAt > at;
|
|
86
|
-
}
|
|
87
|
-
/** A grant as `access` answers it. */
|
|
88
|
-
function view(grant) {
|
|
89
|
-
return {
|
|
90
|
-
projectId: grant.projectId,
|
|
91
|
-
environmentId: grant.environmentId,
|
|
92
|
-
role: grant.role,
|
|
93
|
-
expiresAt: grant.expiresAt === null ? null : iso(grant.expiresAt),
|
|
94
|
-
grantedAt: iso(grant.grantedAt),
|
|
95
|
-
grantedBy: grant.grantedBy
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
function iso(ms) {
|
|
99
|
-
return new Date(ms).toISOString();
|
|
100
|
-
}
|
|
101
|
-
const NO_EDITS = {
|
|
102
|
-
roles: {},
|
|
103
|
-
instanceRoles: {},
|
|
104
|
-
protected: []
|
|
105
|
-
};
|
|
106
|
-
/** A role holding nothing, which every role but Owner is under the closed policy. */
|
|
107
|
-
const NOTHING_HELD = (definition) => ({
|
|
108
|
-
...definition,
|
|
109
|
-
permissions: [],
|
|
110
|
-
protected: []
|
|
111
|
-
});
|
|
112
|
-
/**
|
|
113
|
-
* The policy when the log has some, but none the vault wrote within reach:
|
|
114
|
-
* whoever inserted rows may have hidden an Owner's narrowing, so no role
|
|
115
|
-
* holds anything, a service account's neither, but Owner, which holds
|
|
116
|
-
* everything always and so may write the policy again.
|
|
117
|
-
*/
|
|
118
|
-
const CLOSED_POLICY = {
|
|
119
|
-
roles: Object.fromEntries(Object.entries(ROLES).map(([id, definition]) => [id, id === "owner" ? definition : NOTHING_HELD(definition)])),
|
|
120
|
-
instanceRoles: Object.fromEntries(Object.entries(INSTANCE_ROLES).map(([id, definition]) => [id, id === "owner" ? definition : NOTHING_HELD(definition)])),
|
|
121
|
-
protected: ["*"],
|
|
122
|
-
protectedIn: {}
|
|
123
|
-
};
|
|
124
|
-
/**
|
|
125
|
-
* The policy the newest `policy.change` says, from its metadata, as of
|
|
126
|
-
* `at`, with the rows of the environments it protects: none for no entry,
|
|
127
|
-
* the roles as they ship; and closed for one whose edits do not hold.
|
|
128
|
-
*/
|
|
129
|
-
function policyFrom(metadata, rows, at) {
|
|
130
|
-
if (metadata === null) return {
|
|
131
|
-
policy: DEFAULT_POLICY,
|
|
132
|
-
edits: NO_EDITS,
|
|
133
|
-
readable: true
|
|
134
|
-
};
|
|
135
|
-
let stored;
|
|
136
|
-
try {
|
|
137
|
-
stored = JSON.parse(metadata);
|
|
138
|
-
} catch {}
|
|
139
|
-
const edits = typeof stored === "object" && stored !== null ? readEdits(stored) : null;
|
|
140
|
-
if (edits === null) return {
|
|
141
|
-
policy: CLOSED_POLICY,
|
|
142
|
-
edits: NO_EDITS,
|
|
143
|
-
readable: false
|
|
144
|
-
};
|
|
145
|
-
return {
|
|
146
|
-
policy: livePolicy(rows, edits, at),
|
|
147
|
-
edits,
|
|
148
|
-
readable: true
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
/** A policy entry's edits, checked as the vault wrote them, or null for any that does not hold. */
|
|
152
|
-
function readEdits(stored) {
|
|
153
|
-
const edits = stored.policy;
|
|
154
|
-
if (typeof edits !== "object" || edits === null) return null;
|
|
155
|
-
const { roles, instanceRoles, protected: protectedIds } = edits;
|
|
156
|
-
if (typeof roles !== "object" || roles === null || typeof instanceRoles !== "object" || instanceRoles === null || !Array.isArray(protectedIds)) return null;
|
|
157
|
-
const defined = (table) => Object.values(table).every((definition) => definitionProblem(definition) === null);
|
|
158
|
-
if (!defined(roles) || !defined(instanceRoles) || Object.keys(instanceRoles).some((role) => !isInstanceRole(role))) return null;
|
|
159
|
-
if (protectedIds.some((place) => typeof place !== "object" || place === null || !UUID.test(place.projectId) || !UUID.test(place.environmentId) || !Number.isSafeInteger(place.at))) return null;
|
|
160
|
-
return {
|
|
161
|
-
roles,
|
|
162
|
-
instanceRoles,
|
|
163
|
-
protected: protectedIds
|
|
164
|
-
};
|
|
165
|
-
}
|
|
23
|
+
//#region src/vault.ts
|
|
166
24
|
/**
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
* no row yet stays, protected before it is written, ten minutes: one with
|
|
173
|
-
* none after that is a fork refused or abandoned, never written. Each
|
|
174
|
-
* keeps its slug, which a scoped instance role's filters read. The edits
|
|
175
|
-
* keep them all: no write is needed.
|
|
25
|
+
* Why someone reads, which the log shows. `use`: the credential proxy
|
|
26
|
+
* injects the value into a request and never hands it back. Every other
|
|
27
|
+
* hands the value back: `reveal` of one key, `run` of an environment,
|
|
28
|
+
* `compare` of a guess in a dry run, `expose` by the proxy to a person's
|
|
29
|
+
* own app.
|
|
176
30
|
*/
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
roles: {
|
|
185
|
-
...ROLES,
|
|
186
|
-
...edits.roles
|
|
187
|
-
},
|
|
188
|
-
instanceRoles: {
|
|
189
|
-
...INSTANCE_ROLES,
|
|
190
|
-
...edits.instanceRoles
|
|
191
|
-
},
|
|
192
|
-
protected: live.map((place) => place.environmentId),
|
|
193
|
-
protectedIn: live.reduce((byProject, place) => ({
|
|
194
|
-
...byProject,
|
|
195
|
-
[place.projectId]: [...byProject[place.projectId] ?? [], {
|
|
196
|
-
environmentId: place.environmentId,
|
|
197
|
-
slug: slugOf(place)
|
|
198
|
-
}]
|
|
199
|
-
}), {})
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
/** The settings before anyone changed them: people set up service accounts anywhere they hold access. */
|
|
203
|
-
const DEFAULT_SETTINGS = { serviceAccounts: EVERYWHERE };
|
|
204
|
-
/** The settings when the log has some, but none the vault wrote within reach: people set up no service accounts. */
|
|
205
|
-
const CLOSED_SETTINGS = { serviceAccounts: {
|
|
206
|
-
projects: { only: [] },
|
|
207
|
-
environments: "all"
|
|
208
|
-
} };
|
|
209
|
-
/** The settings the newest `settings.change` says, from its metadata: none for no entry, the default; closed for one that does not hold. */
|
|
210
|
-
function settingsFrom(metadata) {
|
|
211
|
-
if (metadata === null) return DEFAULT_SETTINGS;
|
|
212
|
-
let stored;
|
|
213
|
-
try {
|
|
214
|
-
stored = JSON.parse(metadata);
|
|
215
|
-
} catch {}
|
|
216
|
-
const serviceAccounts = typeof stored === "object" && stored !== null ? stored.serviceAccounts : void 0;
|
|
217
|
-
return isScope(serviceAccounts) ? { serviceAccounts } : CLOSED_SETTINGS;
|
|
218
|
-
}
|
|
219
|
-
//#endregion
|
|
220
|
-
//#region src/vault.ts
|
|
31
|
+
const PURPOSES = [
|
|
32
|
+
"reveal",
|
|
33
|
+
"run",
|
|
34
|
+
"compare",
|
|
35
|
+
"expose",
|
|
36
|
+
"use"
|
|
37
|
+
];
|
|
221
38
|
/**
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
* (`isUnsealed`), and the change is in force.
|
|
39
|
+
* Every action the vault writes to the log, an entry's `action`: each
|
|
40
|
+
* writer's is typed on it, and the audit page keys its sentences on it
|
|
41
|
+
* (`@coffre/ui`, `TEMPLATES`), so an action added without its sentence,
|
|
42
|
+
* or a sentence left for one no writer writes, fails the typecheck.
|
|
227
43
|
*/
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
44
|
+
const LOG_ACTIONS = [
|
|
45
|
+
"secret.read",
|
|
46
|
+
"secret.write",
|
|
47
|
+
"secret.loosen",
|
|
48
|
+
"secret.rename",
|
|
49
|
+
"secret.refile",
|
|
50
|
+
"reference.break",
|
|
51
|
+
"missing.dismiss",
|
|
52
|
+
"project.create",
|
|
53
|
+
"project.update",
|
|
54
|
+
"project.archive",
|
|
55
|
+
"project.restore",
|
|
56
|
+
"project.move",
|
|
57
|
+
"project.delete",
|
|
58
|
+
"folder.refile",
|
|
59
|
+
"environment.create",
|
|
60
|
+
"environment.update",
|
|
61
|
+
"environment.archive",
|
|
62
|
+
"environment.restore",
|
|
63
|
+
"environment.delete",
|
|
64
|
+
"environment.protect",
|
|
65
|
+
"environment.unprotect",
|
|
66
|
+
"upstream.freeze",
|
|
67
|
+
"upstream.thaw",
|
|
68
|
+
"member.add",
|
|
69
|
+
"member.restore",
|
|
70
|
+
"member.role",
|
|
71
|
+
"member.remove",
|
|
72
|
+
"access.grant",
|
|
73
|
+
"access.revoke",
|
|
74
|
+
"policy.change",
|
|
75
|
+
"settings.change",
|
|
76
|
+
"sign_in",
|
|
77
|
+
"sign_out",
|
|
78
|
+
"token.create",
|
|
79
|
+
"token.revoke",
|
|
80
|
+
"account.link",
|
|
81
|
+
"account.unlink",
|
|
82
|
+
"device.start",
|
|
83
|
+
"device.approve",
|
|
84
|
+
"device.deny",
|
|
85
|
+
"token.exchange",
|
|
86
|
+
"workload.renew",
|
|
87
|
+
"token.bind",
|
|
88
|
+
"token.unbind",
|
|
89
|
+
"workload.freeze",
|
|
90
|
+
"workload.unfreeze",
|
|
91
|
+
"mcp.connect",
|
|
92
|
+
"mcp.token",
|
|
93
|
+
"mcp.disconnect",
|
|
94
|
+
"oauth.register",
|
|
95
|
+
"mcp.ask",
|
|
96
|
+
"mcp.approve",
|
|
97
|
+
"mcp.deny",
|
|
98
|
+
"upkeep.expire",
|
|
99
|
+
"vault.adopt"
|
|
100
|
+
];
|
|
239
101
|
/**
|
|
240
102
|
* The vault's entries that change what a member holds: what their row's
|
|
241
103
|
* `access_seq` names, and what a finding about them is newer than while it
|
|
@@ -250,77 +112,6 @@ const ACCESS_ACTIONS = [
|
|
|
250
112
|
"access.grant",
|
|
251
113
|
"access.revoke"
|
|
252
114
|
];
|
|
253
|
-
/** What each refusal says, as the vault answers it and the app shows it. */
|
|
254
|
-
const REFUSAL_MESSAGES = {
|
|
255
|
-
removed: "this member was removed",
|
|
256
|
-
not_a_member: "not a member",
|
|
257
|
-
no_grant: "no grant covers this",
|
|
258
|
-
expired: "the grant that covered this has expired",
|
|
259
|
-
bulk_limit: "too many secrets read in too short a time",
|
|
260
|
-
bad_claim: "the key does not belong to this secret",
|
|
261
|
-
deleted: "this project or environment was deleted",
|
|
262
|
-
ended: "the reference read through was ended",
|
|
263
|
-
personal: "a personal config's values are its owner's alone",
|
|
264
|
-
sensitive: "a sensitive value is never shown to anyone, Owners included: `coffre run` gives your app a placeholder for it through the credential proxy, and a service account reads it",
|
|
265
|
-
not_owner_issued: "a service account reads a sensitive value only on a token or trust binding an Owner of its project issued",
|
|
266
|
-
use_only: "a workload uses this value through coffre and never holds it: list it in its binding's reads, where the value is held, if it must",
|
|
267
|
-
not_allowed: "not allowed to change this",
|
|
268
|
-
last_owner: "the last Owner of the whole instance stays one: make someone else an Owner first",
|
|
269
|
-
invalid: "not something the rules allow",
|
|
270
|
-
policy_changed: "the instance's roles or protected environments changed while this was asked: try again",
|
|
271
|
-
access_changed: "what this member holds changed since the read was decided: try again",
|
|
272
|
-
log_broken: "the vault log does not hold from the last checkpoint",
|
|
273
|
-
wrong_kek: "this vault's key does not open the data it holds",
|
|
274
|
-
tampered: "this member's record failed the vault's integrity check"
|
|
275
|
-
};
|
|
276
|
-
/**
|
|
277
|
-
* A use's purpose, keepsSensitive and way in as 0.15's log stores them, in
|
|
278
|
-
* one smallint (`log_uses.purpose`, schema 0022, 0046): the purpose's code,
|
|
279
|
-
* plus 256 when a copy keeps values sensitive, plus 512 times its way in's
|
|
280
|
-
* (`USE_WAYS`; T147). The vault writes them; the audit pages read them back
|
|
281
|
-
* (T166).
|
|
282
|
-
*/
|
|
283
|
-
const USE_PURPOSES = [
|
|
284
|
-
"reveal",
|
|
285
|
-
"run",
|
|
286
|
-
"compare",
|
|
287
|
-
"copy",
|
|
288
|
-
"use",
|
|
289
|
-
"expose"
|
|
290
|
-
];
|
|
291
|
-
/** Each way in by its code: a credential's, 0, as every use before T147; then `UseWay`'s. */
|
|
292
|
-
const USE_WAYS = [
|
|
293
|
-
"credential",
|
|
294
|
-
"connection",
|
|
295
|
-
"binding",
|
|
296
|
-
"access"
|
|
297
|
-
];
|
|
298
|
-
/** A use's code (`USE_PURPOSES`). */
|
|
299
|
-
function useCode(use) {
|
|
300
|
-
return USE_PURPOSES.indexOf(use.purpose) + (use.keepsSensitive === true ? 256 : 0) + 512 * USE_WAYS.indexOf(use.way ?? "credential");
|
|
301
|
-
}
|
|
302
|
-
/** The purpose, keepsSensitive and way in a use's code stores; null for a code no release writes. */
|
|
303
|
-
function useOfCode(code) {
|
|
304
|
-
const purpose = USE_PURPOSES[code % 256];
|
|
305
|
-
const way = USE_WAYS[Math.floor(code / 512)];
|
|
306
|
-
if (!Number.isInteger(code) || code < 0 || purpose === void 0 || way === void 0) return null;
|
|
307
|
-
return {
|
|
308
|
-
purpose,
|
|
309
|
-
keepsSensitive: code % 512 >= 256,
|
|
310
|
-
...way === "credential" ? {} : { way }
|
|
311
|
-
};
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* Whether a read hands values back to whoever asked, which a person never
|
|
315
|
-
* gets of a sensitive value: every purpose but the proxy's `use` and a
|
|
316
|
-
* fork's `copy` that keeps them sensitive (`keepsSensitive`), a dry run's
|
|
317
|
-
* `compare` included, which tells them whether a guess was right, and any
|
|
318
|
-
* purpose a later app may name.
|
|
319
|
-
*/
|
|
320
|
-
function handsBack(read) {
|
|
321
|
-
if (read.purpose === "use") return false;
|
|
322
|
-
return !(read.purpose === "copy" && read.keepsSensitive === true);
|
|
323
|
-
}
|
|
324
115
|
/**
|
|
325
116
|
* The longest `UseRecord.metadata` the vault appends, in characters: room for
|
|
326
117
|
* a use naming a few hundred keys. The app appends a longer one itself, under
|
|
@@ -363,23 +154,26 @@ function policyRevision(seq, policy) {
|
|
|
363
154
|
}
|
|
364
155
|
/** A revision as `policyRevision` writes it. */
|
|
365
156
|
const POLICY_REVISION = /^(none|[1-9][0-9]{0,15})\.[0-9a-f]{16}$/;
|
|
366
|
-
/**
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
157
|
+
/**
|
|
158
|
+
* A role's revision, as a change of it is confirmed with
|
|
159
|
+
* (`policy.change`'s `revision`): a digest of what it holds, its columns in
|
|
160
|
+
* any order, or of none. The app answers it with a change's preview; the
|
|
161
|
+
* vault takes the change only while the role's row still says what was
|
|
162
|
+
* weighed.
|
|
163
|
+
*
|
|
164
|
+
* 9c41e07b5d2a8f13 developer, as it ships
|
|
165
|
+
* 74d0b1e6a9c3f852 no such role
|
|
166
|
+
*/
|
|
167
|
+
function roleRevision(definition) {
|
|
168
|
+
const said = definition === null ? null : [
|
|
169
|
+
definition.name,
|
|
170
|
+
definition.description,
|
|
171
|
+
[...definition.permissions].sort(),
|
|
172
|
+
[...definition.protected].sort()
|
|
173
|
+
];
|
|
174
|
+
return createHash("sha256").update(JSON.stringify(said)).digest("hex").slice(0, 16);
|
|
175
|
+
}
|
|
176
|
+
/** A revision as `roleRevision` writes it. */
|
|
177
|
+
const ROLE_REVISION = /^[0-9a-f]{16}$/;
|
|
384
178
|
//#endregion
|
|
385
|
-
export { ACCESS_ACTIONS,
|
|
179
|
+
export { ACCESS_ACTIONS, LOG_ACTIONS, POLICY_REVISION, PURPOSES, ROLE_REVISION, USE_METADATA_LENGTH, accessRevision, describeAccessFault, policyRevision, roleRevision };
|
|
@@ -315,14 +315,6 @@ type BindingPolicy = {
|
|
|
315
315
|
readonly onContention?: 'alert';
|
|
316
316
|
readonly unsignedUploads?: true;
|
|
317
317
|
};
|
|
318
|
-
/** How long a credential an exchange issues lives: one `coffre run` needs it for seconds. The vault holds a sign-in to it (T149). */
|
|
319
|
-
declare const EXCHANGED_CREDENTIAL_MS: number;
|
|
320
|
-
/** How long a session lives past each renewal, unless its proof says less: an hour (section 5.4). The vault holds a sign-in to it. */
|
|
321
|
-
declare const SESSION_MS: number;
|
|
322
|
-
/** A workload's sign-in route, whose URL on the instance its DPoP proof signs: the app's route, and what the vault checks the proof for (PR 3b). */
|
|
323
|
-
declare const WORKLOAD_SIGN_IN_PATH = "/api/auth/workload";
|
|
324
|
-
/** How far a sign-in's DPoP proof's `iat` may be from now: it carries no nonce, so its clock bounds it (section 4.1). The app and the vault alike. */
|
|
325
|
-
declare const EXCHANGE_SKEW_SECONDS = 60;
|
|
326
318
|
/** What a field left out of a policy means. */
|
|
327
319
|
declare const POLICY_DEFAULTS: {
|
|
328
320
|
readonly keyAudience: false;
|
|
@@ -424,4 +416,4 @@ type WorkloadAlert = {
|
|
|
424
416
|
readonly text: string;
|
|
425
417
|
};
|
|
426
418
|
//#endregion
|
|
427
|
-
export {
|
|
419
|
+
export { parseAddress as $, REPEATING_PROFILES as A, checkFetchUrl as B, MAX_READ_PLACES as C, POLICY_FIELDS as D, POLICY_DEFAULTS as E, WorkloadCaller as F, differingClaims as G, claimAt as H, WorkloadProfile as I, githubEventsAt as J, freezeTarget as K, addressWithin as L, Starts as M, WORKLOAD_PROFILES as N, PROFILE_URNS as O, WorkloadAlert as P, isBearerProfile as Q, canonicalClaims as R, MAX_READ_KEYS as S, OIDC_PROFILES as T, claimValues as U, checkPolicy as V, defaultIssuer as W, githubWorkflow as X, githubReusable as Y, gitlabProject as Z, KEY_NAMING_PROFILES as _, BindingPolicy as a, MAX_CONSTRAINTS as at, MAX_CLAIM_BYTES as b, CheckedBinding as c, constraintsText as ct, EVENT_EXPOSURE as d, parseCidr as et, GITHUB_EVENTS as f, GOOGLE_ISSUER as g, GITLAB_PIPELINE_SOURCES as h, BindingInvalid as i, ConstraintsInvalid as it, REQUIRED_CLAIMS as j, Preset as k, Cidr as l, intersect as lt, GITLAB_ISSUER as m, BearerProfile as n, workflowRef as nt, BindingReads as o, checkConstraints as ot, GITHUB_ISSUER as p, fullRef as q, BindingClaims as r, Constraints as rt, CREDENTIAL_NAME as s, constraintsAllow as st, BEARER_PROFILES as t, policyText as tt, ClaimValue as u, MAX_BINDINGS as v, MAX_SOURCES as w, MAX_ISSUER_BYTES as x, MAX_CLAIMS as y, checkBinding as z };
|
package/dist/workloads.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { BEARER_PROFILES, BearerProfile, BindingClaims, BindingInvalid, BindingPolicy, BindingReads, CREDENTIAL_NAME, CheckedBinding, Cidr, ClaimValue, EVENT_EXPOSURE,
|
|
1
|
+
import { $ as parseAddress, A as REPEATING_PROFILES, B as checkFetchUrl, C as MAX_READ_PLACES, D as POLICY_FIELDS, E as POLICY_DEFAULTS, F as WorkloadCaller, G as differingClaims, H as claimAt, I as WorkloadProfile, J as githubEventsAt, K as freezeTarget, L as addressWithin, M as Starts, N as WORKLOAD_PROFILES, O as PROFILE_URNS, P as WorkloadAlert, Q as isBearerProfile, R as canonicalClaims, S as MAX_READ_KEYS, T as OIDC_PROFILES, U as claimValues, V as checkPolicy, W as defaultIssuer, X as githubWorkflow, Y as githubReusable, Z as gitlabProject, _ as KEY_NAMING_PROFILES, a as BindingPolicy, b as MAX_CLAIM_BYTES, c as CheckedBinding, d as EVENT_EXPOSURE, et as parseCidr, f as GITHUB_EVENTS, g as GOOGLE_ISSUER, h as GITLAB_PIPELINE_SOURCES, i as BindingInvalid, j as REQUIRED_CLAIMS, k as Preset, l as Cidr, m as GITLAB_ISSUER, n as BearerProfile, nt as workflowRef, o as BindingReads, p as GITHUB_ISSUER, q as fullRef, r as BindingClaims, s as CREDENTIAL_NAME, t as BEARER_PROFILES, tt as policyText, u as ClaimValue, v as MAX_BINDINGS, w as MAX_SOURCES, x as MAX_ISSUER_BYTES, y as MAX_CLAIMS, z as checkBinding } from "./workloads-CW2dK4AW.js";
|
|
2
|
+
export { BEARER_PROFILES, BearerProfile, BindingClaims, BindingInvalid, BindingPolicy, BindingReads, CREDENTIAL_NAME, CheckedBinding, Cidr, ClaimValue, EVENT_EXPOSURE, GITHUB_EVENTS, GITHUB_ISSUER, GITLAB_ISSUER, GITLAB_PIPELINE_SOURCES, GOOGLE_ISSUER, KEY_NAMING_PROFILES, MAX_BINDINGS, MAX_CLAIMS, MAX_CLAIM_BYTES, MAX_ISSUER_BYTES, MAX_READ_KEYS, MAX_READ_PLACES, MAX_SOURCES, OIDC_PROFILES, POLICY_DEFAULTS, POLICY_FIELDS, PROFILE_URNS, Preset, REPEATING_PROFILES, REQUIRED_CLAIMS, Starts, WORKLOAD_PROFILES, WorkloadAlert, WorkloadCaller, WorkloadProfile, addressWithin, canonicalClaims, checkBinding, checkFetchUrl, checkPolicy, claimAt, claimValues, defaultIssuer, differingClaims, freezeTarget, fullRef, githubEventsAt, githubReusable, githubWorkflow, gitlabProject, isBearerProfile, parseAddress, parseCidr, policyText, workflowRef };
|
package/dist/workloads.js
CHANGED
|
@@ -539,14 +539,6 @@ function gitlabProject(input) {
|
|
|
539
539
|
}
|
|
540
540
|
};
|
|
541
541
|
}
|
|
542
|
-
/** How long a credential an exchange issues lives: one `coffre run` needs it for seconds. The vault holds a sign-in to it (T149). */
|
|
543
|
-
const EXCHANGED_CREDENTIAL_MS = 3e5;
|
|
544
|
-
/** How long a session lives past each renewal, unless its proof says less: an hour (section 5.4). The vault holds a sign-in to it. */
|
|
545
|
-
const SESSION_MS = 36e5;
|
|
546
|
-
/** A workload's sign-in route, whose URL on the instance its DPoP proof signs: the app's route, and what the vault checks the proof for (PR 3b). */
|
|
547
|
-
const WORKLOAD_SIGN_IN_PATH = "/api/auth/workload";
|
|
548
|
-
/** How far a sign-in's DPoP proof's `iat` may be from now: it carries no nonce, so its clock bounds it (section 4.1). The app and the vault alike. */
|
|
549
|
-
const EXCHANGE_SKEW_SECONDS = 60;
|
|
550
542
|
/** What a field left out of a policy means. */
|
|
551
543
|
const POLICY_DEFAULTS = {
|
|
552
544
|
keyAudience: false,
|
|
@@ -852,4 +844,4 @@ function freezeTarget(text) {
|
|
|
852
844
|
}
|
|
853
845
|
}
|
|
854
846
|
//#endregion
|
|
855
|
-
export { BEARER_PROFILES, BindingInvalid, CREDENTIAL_NAME, EVENT_EXPOSURE,
|
|
847
|
+
export { BEARER_PROFILES, BindingInvalid, CREDENTIAL_NAME, EVENT_EXPOSURE, GITHUB_EVENTS, GITHUB_ISSUER, GITLAB_ISSUER, GITLAB_PIPELINE_SOURCES, GOOGLE_ISSUER, KEY_NAMING_PROFILES, MAX_BINDINGS, MAX_CLAIMS, MAX_CLAIM_BYTES, MAX_ISSUER_BYTES, MAX_READ_KEYS, MAX_READ_PLACES, MAX_SOURCES, OIDC_PROFILES, POLICY_DEFAULTS, POLICY_FIELDS, PROFILE_URNS, REPEATING_PROFILES, REQUIRED_CLAIMS, WORKLOAD_PROFILES, addressWithin, canonicalClaims, checkBinding, checkFetchUrl, checkPolicy, claimAt, claimValues, defaultIssuer, differingClaims, freezeTarget, fullRef, githubEventsAt, githubReusable, githubWorkflow, gitlabProject, isBearerProfile, parseAddress, parseCidr, policyText, workflowRef };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coffre/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.1",
|
|
4
4
|
"description": "What coffre's packages share: roles, envelopes, identity, the audit chain and the vault's contract.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
"types": "./dist/kek.d.ts",
|
|
48
48
|
"default": "./dist/kek.js"
|
|
49
49
|
},
|
|
50
|
-
"./
|
|
51
|
-
"coffre:source": "./src/
|
|
52
|
-
"types": "./dist/
|
|
53
|
-
"default": "./dist/
|
|
50
|
+
"./log": {
|
|
51
|
+
"coffre:source": "./src/log/index.ts",
|
|
52
|
+
"types": "./dist/log.d.ts",
|
|
53
|
+
"default": "./dist/log.js"
|
|
54
54
|
},
|
|
55
55
|
"./mcp": {
|
|
56
56
|
"coffre:source": "./src/mcp.ts",
|
|
@@ -88,14 +88,14 @@
|
|
|
88
88
|
"jose": "6.2.3",
|
|
89
89
|
"oauth4webapi": "3.8.8",
|
|
90
90
|
"zod": "4.4.3",
|
|
91
|
-
"@coffre/client": "0.
|
|
91
|
+
"@coffre/client": "0.16.1"
|
|
92
92
|
},
|
|
93
93
|
"devDependencies": {
|
|
94
94
|
"@hegeldev/hegel": "0.4.7",
|
|
95
95
|
"@types/node": "26.1.1",
|
|
96
96
|
"tsdown": "0.23.0",
|
|
97
97
|
"typescript": "5.9.3",
|
|
98
|
-
"@coffre/conformance": "0.
|
|
98
|
+
"@coffre/conformance": "0.16.1"
|
|
99
99
|
},
|
|
100
100
|
"scripts": {
|
|
101
101
|
"build": "tsdown",
|