@coffre/core 0.8.2 → 0.10.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/dist/{access-CONhKG2P.d.ts → access-CF4noOjL.d.ts} +214 -36
- package/dist/{access-B1wpMzEB.js → access-Dl13x6mB.js} +284 -46
- package/dist/access.d.ts +2 -2
- package/dist/access.js +2 -2
- package/dist/envelope.d.ts +8 -5
- package/dist/envelope.js +13 -5
- package/dist/identity.d.ts +1 -1
- package/dist/kek.d.ts +1 -1
- package/dist/kek.js +3 -2
- package/dist/recipe.d.ts +3 -2
- package/dist/{registry-Bd7hPoY4.d.ts → registry-D7X-x202.d.ts} +9 -4
- package/dist/schemas.d.ts +2 -0
- package/dist/schemas.js +4 -2
- package/dist/{types-E1Sz50n6.js → types-Cp3lB_-W.js} +3 -2
- package/dist/vault.d.ts +121 -23
- package/dist/vault.js +28 -8
- package/package.json +2 -2
- package/src/access-conversion.ts +1 -1
- package/src/access.ts +312 -58
- package/src/context.ts +11 -5
- package/src/envelope.ts +14 -6
- package/src/identity/tokens.ts +1 -1
- package/src/kek/aws-kms.ts +2 -0
- package/src/recipe.ts +3 -3
- package/src/schemas.ts +4 -1
- package/src/vault.ts +117 -17
package/dist/recipe.d.ts
CHANGED
|
@@ -94,13 +94,14 @@ export declare function randomValue(encoding: Encoding, bytes: number, random?:
|
|
|
94
94
|
export declare function generate(recipe: Recipe): Promise<Generated>;
|
|
95
95
|
/**
|
|
96
96
|
* What a write of generated values sends, by key: each value with how it
|
|
97
|
-
* was made,
|
|
98
|
-
* holds it to.
|
|
97
|
+
* was made, for a regenerate the version it replaces, which the server
|
|
98
|
+
* holds it to, and who sees it, where the write says.
|
|
99
99
|
*/
|
|
100
100
|
export type GeneratedWrite = Record<string, {
|
|
101
101
|
value: string;
|
|
102
102
|
generated: Generation;
|
|
103
103
|
replaces?: string;
|
|
104
|
+
sensitivity?: 'secret' | 'sensitive';
|
|
104
105
|
}>;
|
|
105
106
|
/**
|
|
106
107
|
* A value made by the recipe for `key`, as a write sends it, and for a key
|
|
@@ -11,9 +11,12 @@
|
|
|
11
11
|
* names would mean that renaming an environment or a secret key makes every
|
|
12
12
|
* existing ciphertext permanently undecryptable.
|
|
13
13
|
*
|
|
14
|
-
* A personal config's values are bound to their owner too, `owner`,
|
|
15
|
-
* only the vault's wrap of
|
|
16
|
-
*
|
|
14
|
+
* A personal config's values are bound to their owner too, `owner`, and a
|
|
15
|
+
* sensitive value to being one, `sensitive`, which only the vault's wrap of
|
|
16
|
+
* the data key carries (docs/design/forking.md, section 4;
|
|
17
|
+
* docs/design/credential-proxy.md, section 2): a forged owner or sensitivity
|
|
18
|
+
* column fails to open, rather than granting. The value's own ciphertext
|
|
19
|
+
* binds the ids alone, so a version made sensitive keeps its ciphertext.
|
|
17
20
|
*/
|
|
18
21
|
type SecretContext = {
|
|
19
22
|
projectId: string;
|
|
@@ -21,13 +24,15 @@ type SecretContext = {
|
|
|
21
24
|
secretId: string;
|
|
22
25
|
/** A personal config's owner, as `ownerKey` hashes them. */
|
|
23
26
|
owner?: string;
|
|
27
|
+
/** A sensitive value's: never handed back to a person (`sensitive` in @coffre/core/vault). Absent otherwise, never false. */
|
|
28
|
+
sensitive?: true;
|
|
24
29
|
};
|
|
25
30
|
/**
|
|
26
31
|
* Version prefix for the AAD encoding. If the encoding ever changes, this
|
|
27
32
|
* changes with it, and old ciphertexts keep decrypting under the old rule.
|
|
28
33
|
*/
|
|
29
34
|
declare const AAD_VERSION = "coffre.aad.v1";
|
|
30
|
-
/** Throw unless every field is a lowercase UUID,
|
|
35
|
+
/** Throw unless every field is a lowercase UUID, an owner a lowercase SHA-256, and `sensitive` true if there. */
|
|
31
36
|
declare function checkContext(ctx: SecretContext): void;
|
|
32
37
|
/**
|
|
33
38
|
* A personal config's owner as its values' context binds them: the SHA-256
|
package/dist/schemas.d.ts
CHANGED
|
@@ -45,6 +45,8 @@ export declare const instanceRole: z.ZodEnum<{
|
|
|
45
45
|
member: "member";
|
|
46
46
|
admin: "admin";
|
|
47
47
|
}>;
|
|
48
|
+
/** A project role's id: one coffre ships, or one an Owner made (`ROLE_ID`). Which the instance defines, its policy says. */
|
|
49
|
+
export declare const roleId: z.ZodString;
|
|
48
50
|
/** Which projects or environments a scope takes in, by slug: `all`, `{ only: [...] }` or `{ except: [...] }`. */
|
|
49
51
|
export declare const scopeFilter: z.ZodUnion<readonly [z.ZodLiteral<"all">, z.ZodObject<{
|
|
50
52
|
only: z.ZodArray<z.ZodString>;
|
package/dist/schemas.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { m as ROLE_ID, s as INSTANCE_ROLE_NAMES } from "./access-Dl13x6mB.js";
|
|
2
2
|
import { PROJECT_PAGES } from "./pages.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region src/schemas.ts
|
|
@@ -47,6 +47,8 @@ function shownMember(member) {
|
|
|
47
47
|
const principalType = z.enum(["user", "service"]);
|
|
48
48
|
const principalId = z.string().trim().min(1).max(320);
|
|
49
49
|
const instanceRole = z.enum(INSTANCE_ROLE_NAMES);
|
|
50
|
+
/** A project role's id: one coffre ships, or one an Owner made (`ROLE_ID`). Which the instance defines, its policy says. */
|
|
51
|
+
const roleId = z.string().regex(ROLE_ID, "a role is named by lowercase letters, digits and dashes, 2 to 32, starting with a letter");
|
|
50
52
|
/** Which projects or environments a scope takes in, by slug: `all`, `{ only: [...] }` or `{ except: [...] }`. */
|
|
51
53
|
const scopeFilter = z.union([
|
|
52
54
|
z.literal("all"),
|
|
@@ -61,4 +63,4 @@ const scopeInput = z.object({
|
|
|
61
63
|
const grantId = z.string().uuid();
|
|
62
64
|
const emailAddress = z.string().email().max(320);
|
|
63
65
|
//#endregion
|
|
64
|
-
export { PERSONAL_SUFFIX, TOMBSTONE, displayName, emailAddress, environmentPath, environmentSlug, folderName, grantId, instanceRole, isTombstone, personalOf, principalId, principalType, scopeFilter, scopeInput, secretKey, shownMember, slug, tombstoneOf };
|
|
66
|
+
export { PERSONAL_SUFFIX, TOMBSTONE, displayName, emailAddress, environmentPath, environmentSlug, folderName, grantId, instanceRole, isTombstone, personalOf, principalId, principalType, roleId, scopeFilter, scopeInput, secretKey, shownMember, slug, tombstoneOf };
|
|
@@ -9,12 +9,13 @@ const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
|
|
|
9
9
|
function assertUuid(value, field) {
|
|
10
10
|
if (typeof value !== "string" || !UUID_RE.test(value)) throw new Error(`context.${field} must be a lowercase UUID, got: ${String(value)}`);
|
|
11
11
|
}
|
|
12
|
-
/** Throw unless every field is a lowercase UUID,
|
|
12
|
+
/** Throw unless every field is a lowercase UUID, an owner a lowercase SHA-256, and `sensitive` true if there. */
|
|
13
13
|
function checkContext(ctx) {
|
|
14
14
|
assertUuid(ctx.projectId, "projectId");
|
|
15
15
|
assertUuid(ctx.environmentId, "environmentId");
|
|
16
16
|
assertUuid(ctx.secretId, "secretId");
|
|
17
17
|
if (ctx.owner !== void 0 && (typeof ctx.owner !== "string" || !OWNER_RE.test(ctx.owner))) throw new Error(`context.owner must be a lowercase SHA-256, got: ${String(ctx.owner)}`);
|
|
18
|
+
if (ctx.sensitive !== void 0 && ctx.sensitive !== true) throw new Error(`context.sensitive is true or absent, got: ${String(ctx.sensitive)}`);
|
|
18
19
|
}
|
|
19
20
|
const OWNER_RE = /^[0-9a-f]{64}$/;
|
|
20
21
|
/**
|
|
@@ -34,7 +35,7 @@ function ownerKey(member) {
|
|
|
34
35
|
*/
|
|
35
36
|
function encodeAad(ctx) {
|
|
36
37
|
checkContext(ctx);
|
|
37
|
-
return Buffer.from(`${AAD_VERSION}|${ctx.projectId}|${ctx.environmentId}|${ctx.secretId}${ctx.owner === void 0 ? "" : `|owner:${ctx.owner}`}`, "utf8");
|
|
38
|
+
return Buffer.from(`${AAD_VERSION}|${ctx.projectId}|${ctx.environmentId}|${ctx.secretId}${ctx.owner === void 0 ? "" : `|owner:${ctx.owner}`}${ctx.sensitive === true ? "|sensitive" : ""}`, "utf8");
|
|
38
39
|
}
|
|
39
40
|
//#endregion
|
|
40
41
|
//#region src/kek/types.ts
|
package/dist/vault.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as RoleDefinition, E as Role, O as Scope, S as Policy, j as ServiceSetting, m as InstanceRole, r as CredentialScope, u as GrantPlace } from "./access-CF4noOjL.js";
|
|
2
2
|
//#region src/access-fault.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Why the vault's members and grants do not follow from its log, as facts
|
|
@@ -100,21 +100,20 @@ export interface Vault {
|
|
|
100
100
|
/**
|
|
101
101
|
* Wrap fresh data keys for new versions `principal` writes: all, or none.
|
|
102
102
|
* `seqs` are the `key.wrap` entries, one per key, which the app's
|
|
103
|
-
* `secret.write` entries name as related.
|
|
103
|
+
* `secret.write` entries name as related. `sensitive` says, per key,
|
|
104
|
+
* whether its wrap binds it as sensitive: a vault older than 0.10 answers
|
|
105
|
+
* none, binding none, and the app stores no sensitive version it wrapped.
|
|
104
106
|
*/
|
|
105
|
-
wrap(input: WrapInput): Promise<Outcome<
|
|
106
|
-
wrapped: WrappedKey[];
|
|
107
|
-
seqs: number[];
|
|
108
|
-
}>>;
|
|
107
|
+
wrap(input: WrapInput): Promise<Outcome<Wrapped>>;
|
|
109
108
|
/**
|
|
110
109
|
* Wrap existing data keys again for new versions of the same secrets,
|
|
111
|
-
* under the current key: restoring an old value
|
|
112
|
-
* not a read one, since the key never leaves the
|
|
110
|
+
* under the current key: restoring an old value, or making one stricter.
|
|
111
|
+
* It needs a write grant, not a read one, since the key never leaves the
|
|
112
|
+
* vault. A new version is never less sensitive than the one it is made
|
|
113
|
+
* from, or than its secret's newest: a value is made looser only by
|
|
114
|
+
* being written again (`invalid`).
|
|
113
115
|
*/
|
|
114
|
-
rewrap(input: RewrapInput): Promise<Outcome<
|
|
115
|
-
wrapped: WrappedKey[];
|
|
116
|
-
seqs: number[];
|
|
117
|
-
}>>;
|
|
116
|
+
rewrap(input: RewrapInput): Promise<Outcome<Wrapped>>;
|
|
118
117
|
/**
|
|
119
118
|
* Make secrets references to others: whoever can read the holder's
|
|
120
119
|
* environment reads the source through it (docs/design/environments.md).
|
|
@@ -179,6 +178,31 @@ export interface Vault {
|
|
|
179
178
|
setSettings(input: SetSettingsInput): Promise<Outcome<{
|
|
180
179
|
settings: Settings;
|
|
181
180
|
}>>;
|
|
181
|
+
/**
|
|
182
|
+
* The instance's access policy (`Policy` in @coffre/core/access): its
|
|
183
|
+
* roles, as an Owner edited and made them, and its protected
|
|
184
|
+
* environments, as the vault's newest `policy.change` says, by its MAC.
|
|
185
|
+
* As it ships, before any. A vault older than 0.10 has none, and the app
|
|
186
|
+
* decides as it ships.
|
|
187
|
+
*/
|
|
188
|
+
policy(): Promise<Policy>;
|
|
189
|
+
/**
|
|
190
|
+
* Change the policy by one change, its own `policy.change` entry, which
|
|
191
|
+
* names it and what it was (docs/design/roles.md):
|
|
192
|
+
* - a project or instance role defined, or put back as it ships (null),
|
|
193
|
+
* or, one an Owner made, deleted while no grant names it: an Owner of
|
|
194
|
+
* the whole instance, and never the Owner role, nor the instance's
|
|
195
|
+
* Member;
|
|
196
|
+
* - environments of one project protected, by whoever manages its
|
|
197
|
+
* environments, before their rows exist too (a fork's); or
|
|
198
|
+
* unprotected, by an Owner of the whole instance.
|
|
199
|
+
* The policy after it, and the newest `policy.change`, which it is as of:
|
|
200
|
+
* the change's own, when it changed anything.
|
|
201
|
+
*/
|
|
202
|
+
changePolicy(input: ChangePolicyInput): Promise<Outcome<{
|
|
203
|
+
policy: Policy;
|
|
204
|
+
seq: number | null;
|
|
205
|
+
}>>;
|
|
182
206
|
/**
|
|
183
207
|
* Sign the log up to its last entry, in an `audit.checkpoint` entry of
|
|
184
208
|
* the vault's, if the chain recomputes, the vault's entries by their MACs,
|
|
@@ -255,11 +279,11 @@ export type RefusalCode =
|
|
|
255
279
|
/** The wrapped key does not belong to the secret it was presented as, or a reference is not the vault's. */
|
|
256
280
|
'bad_claim' |
|
|
257
281
|
/**
|
|
258
|
-
* A person asked for
|
|
259
|
-
*
|
|
260
|
-
* proxy
|
|
282
|
+
* A person asked for a sensitive value to be handed back (`handsBack`):
|
|
283
|
+
* nobody sees one, Owners included. Their apps use it through the
|
|
284
|
+
* credential proxy, and service accounts read it.
|
|
261
285
|
*/
|
|
262
|
-
'
|
|
286
|
+
'sensitive' |
|
|
263
287
|
/**
|
|
264
288
|
* The project or environment was deleted for good: nothing under it is
|
|
265
289
|
* opened or wrapped again, whatever grant would cover it.
|
|
@@ -283,6 +307,11 @@ export type RefusalCode =
|
|
|
283
307
|
'last_owner' |
|
|
284
308
|
/** Well-formed, but not something the rules allow: a project role on an environment, a service account with an instance role. */
|
|
285
309
|
'invalid' |
|
|
310
|
+
/**
|
|
311
|
+
* A change to the policy weighed from one revision of it (`revision`)
|
|
312
|
+
* when another came since: asked again, it is weighed as the policy is now.
|
|
313
|
+
*/
|
|
314
|
+
'policy_changed' |
|
|
286
315
|
/** The vault's own log no longer carries the head the last checkpoint signed, or does not rehash since. */
|
|
287
316
|
'log_broken' |
|
|
288
317
|
/**
|
|
@@ -315,6 +344,20 @@ export type SecretRef = {
|
|
|
315
344
|
version: number;
|
|
316
345
|
/** `market/prod/DATABASE_URL`. */
|
|
317
346
|
path: string;
|
|
347
|
+
/**
|
|
348
|
+
* Whether the version is sensitive: its value is never handed back to a
|
|
349
|
+
* person, on any credential of theirs, only used for them or read by a
|
|
350
|
+
* service account. Its data key's wrap binds it, so a version written
|
|
351
|
+
* sensitive opens as nothing else. Absent, or false, for a secret or a
|
|
352
|
+
* plain value.
|
|
353
|
+
*/
|
|
354
|
+
sensitive?: boolean;
|
|
355
|
+
};
|
|
356
|
+
/** What a wrap or rewrap answers: each key as wrapped, its entry, and whether its wrap binds it sensitive. */
|
|
357
|
+
export type Wrapped = {
|
|
358
|
+
wrapped: WrappedKey[];
|
|
359
|
+
seqs: number[];
|
|
360
|
+
sensitive: boolean[];
|
|
318
361
|
};
|
|
319
362
|
/** A wrapped data key and the key encryption key that wrapped it; `bytes` is base64. */
|
|
320
363
|
export type WrappedKey = {
|
|
@@ -341,17 +384,21 @@ export type KeyChecks = {
|
|
|
341
384
|
/**
|
|
342
385
|
* Why someone reads: shown in the log, and the same rules apply to each. A
|
|
343
386
|
* fork reads to `copy`. The credential proxy reads to `use`, a value it
|
|
344
|
-
* injects into a request and never hands back, or to `expose`, one
|
|
345
|
-
*
|
|
346
|
-
* (`people: 'stand-ins'`), a person opens nothing to `reveal`, `run` or
|
|
347
|
-
* `compare` (`HANDED_BACK`).
|
|
387
|
+
* injects into a request and never hands back, or to `expose`, one it
|
|
388
|
+
* gives a person's app as it is (`coffre run`'s plan).
|
|
348
389
|
*/
|
|
349
390
|
export type Purpose = 'reveal' | 'run' | 'compare' | 'copy' | 'use' | 'expose';
|
|
350
391
|
/**
|
|
351
|
-
*
|
|
352
|
-
*
|
|
392
|
+
* Whether a read hands values back to whoever asked, which a person never
|
|
393
|
+
* gets of a sensitive value: every purpose but the proxy's `use` and a
|
|
394
|
+
* fork's `copy` that keeps them sensitive (`keepsSensitive`), a dry run's
|
|
395
|
+
* `compare` included, which tells them whether a guess was right, and any
|
|
396
|
+
* purpose a later app may name.
|
|
353
397
|
*/
|
|
354
|
-
export declare
|
|
398
|
+
export declare function handsBack(read: {
|
|
399
|
+
purpose: string;
|
|
400
|
+
keepsSensitive?: boolean;
|
|
401
|
+
}): boolean;
|
|
355
402
|
/** Ties the vault's entries to the app's request and audit rows. */
|
|
356
403
|
type Correlation = {
|
|
357
404
|
requestId?: string | null;
|
|
@@ -379,6 +426,13 @@ export type Through = {
|
|
|
379
426
|
export type UnwrapInput = Correlation & Through & {
|
|
380
427
|
principal: string;
|
|
381
428
|
purpose: Purpose;
|
|
429
|
+
/**
|
|
430
|
+
* That a `copy` keeps each sensitive value sensitive in what it writes:
|
|
431
|
+
* the vault opens a sensitive value to copy for a person only when told
|
|
432
|
+
* so, which an app older than 0.10, that would write it as a secret
|
|
433
|
+
* anyone with read sees, never says.
|
|
434
|
+
*/
|
|
435
|
+
keepsSensitive?: boolean;
|
|
382
436
|
/**
|
|
383
437
|
* `via` reads a source's current version through a reference: the vault
|
|
384
438
|
* checks the reader's grants on the holder's environment, as its
|
|
@@ -468,6 +522,8 @@ export type Access = {
|
|
|
468
522
|
/** When the status last changed, and who changed it; null for strangers. */
|
|
469
523
|
since: string | null;
|
|
470
524
|
by: string | null;
|
|
525
|
+
/** The instance's policy, which every decision about them reads: absent from a vault older than 0.10, which decides as it ships. */
|
|
526
|
+
policy?: Policy;
|
|
471
527
|
};
|
|
472
528
|
/**
|
|
473
529
|
* One place: a role to hold there, with an optional end, or null for none.
|
|
@@ -524,6 +580,48 @@ export type SetSettingsInput = Correlation & Through & {
|
|
|
524
580
|
actor: string;
|
|
525
581
|
settings: Settings;
|
|
526
582
|
};
|
|
583
|
+
/** One change to the policy (`changePolicy`). */
|
|
584
|
+
export type PolicyChange = {
|
|
585
|
+
kind: 'role';
|
|
586
|
+
role: Role;
|
|
587
|
+
definition: RoleDefinition | null;
|
|
588
|
+
} | {
|
|
589
|
+
kind: 'instance-role';
|
|
590
|
+
role: InstanceRole;
|
|
591
|
+
definition: RoleDefinition | null;
|
|
592
|
+
} | {
|
|
593
|
+
kind: 'protect';
|
|
594
|
+
projectId: string;
|
|
595
|
+
environmentIds: string[];
|
|
596
|
+
protected: boolean;
|
|
597
|
+
};
|
|
598
|
+
/**
|
|
599
|
+
* A policy's revision, as a decision made from it names it: its newest
|
|
600
|
+
* `policy.change` (null for none), and the slug of each environment it
|
|
601
|
+
* protects, by id, which a scoped instance role's filters match, and
|
|
602
|
+
* which a rename or a deletion changes with no `policy.change` of its own
|
|
603
|
+
* (docs/design/roles.md, "What changes the policy"). Equal revisions decide
|
|
604
|
+
* alike.
|
|
605
|
+
*
|
|
606
|
+
* 57.3f9a0c2e81b4d7a6 change 57, prod protected as `prod`
|
|
607
|
+
* 57.b20e94d1c6a8f305 change 57, prod renamed `staging`
|
|
608
|
+
*/
|
|
609
|
+
export declare function policyRevision(seq: number | bigint | null, policy: Pick<Policy, 'protectedIn'>): string;
|
|
610
|
+
/** A revision as `policyRevision` writes it. */
|
|
611
|
+
export declare const POLICY_REVISION: RegExp;
|
|
612
|
+
export type ChangePolicyInput = Correlation & Through & {
|
|
613
|
+
actor: string;
|
|
614
|
+
change: PolicyChange;
|
|
615
|
+
/**
|
|
616
|
+
* The policy the caller decided from, as its revision
|
|
617
|
+
* (`policyRevision`): its newest `policy.change` and the rows of the
|
|
618
|
+
* environments it protects. Refused, `policy_changed`, unless the policy
|
|
619
|
+
* under the vault's head is still that one, so that a request carries on
|
|
620
|
+
* from the policy it made (`seq`) only where nothing came between, and a
|
|
621
|
+
* change previewed is made as previewed. Unchecked when absent.
|
|
622
|
+
*/
|
|
623
|
+
revision?: string;
|
|
624
|
+
};
|
|
527
625
|
/**
|
|
528
626
|
* A prefix of the log the vault signed: every entry up to `seq`, the last
|
|
529
627
|
* of which has `hash`, which pins every byte before it. Kept as the vault's
|
package/dist/vault.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
1
2
|
//#region src/checkpoint.ts
|
|
2
3
|
/** What a checkpoint's signature covers: the prefix of the log up to entry `seq`, and when. */
|
|
3
4
|
function checkpointMessage(checkpoint) {
|
|
@@ -55,13 +56,32 @@ const ACCESS_ACTIONS = [
|
|
|
55
56
|
"access.revoke"
|
|
56
57
|
];
|
|
57
58
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
59
|
+
* Whether a read hands values back to whoever asked, which a person never
|
|
60
|
+
* gets of a sensitive value: every purpose but the proxy's `use` and a
|
|
61
|
+
* fork's `copy` that keeps them sensitive (`keepsSensitive`), a dry run's
|
|
62
|
+
* `compare` included, which tells them whether a guess was right, and any
|
|
63
|
+
* purpose a later app may name.
|
|
60
64
|
*/
|
|
61
|
-
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
function handsBack(read) {
|
|
66
|
+
if (read.purpose === "use") return false;
|
|
67
|
+
return !(read.purpose === "copy" && read.keepsSensitive === true);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* A policy's revision, as a decision made from it names it: its newest
|
|
71
|
+
* `policy.change` (null for none), and the slug of each environment it
|
|
72
|
+
* protects, by id, which a scoped instance role's filters match, and
|
|
73
|
+
* which a rename or a deletion changes with no `policy.change` of its own
|
|
74
|
+
* (docs/design/roles.md, "What changes the policy"). Equal revisions decide
|
|
75
|
+
* alike.
|
|
76
|
+
*
|
|
77
|
+
* 57.3f9a0c2e81b4d7a6 change 57, prod protected as `prod`
|
|
78
|
+
* 57.b20e94d1c6a8f305 change 57, prod renamed `staging`
|
|
79
|
+
*/
|
|
80
|
+
function policyRevision(seq, policy) {
|
|
81
|
+
const places = Object.values(policy.protectedIn).flat().map(({ environmentId, slug }) => `${environmentId}=${slug ?? ""}`).sort();
|
|
82
|
+
return `${seq === null ? "none" : String(seq)}.${createHash("sha256").update(places.join("\n")).digest("hex").slice(0, 16)}`;
|
|
83
|
+
}
|
|
84
|
+
/** A revision as `policyRevision` writes it. */
|
|
85
|
+
const POLICY_REVISION = /^(none|[1-9][0-9]{0,15})\.[0-9a-f]{16}$/;
|
|
66
86
|
//#endregion
|
|
67
|
-
export { ACCESS_ACTIONS,
|
|
87
|
+
export { ACCESS_ACTIONS, POLICY_REVISION, checkpointMessage, checkpointVerifier, describeAccessFault, handsBack, policyRevision, verifyCheckpoint };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coffre/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
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": {
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"@types/node": "26.1.1",
|
|
90
90
|
"tsdown": "0.23.0",
|
|
91
91
|
"typescript": "5.9.3",
|
|
92
|
-
"@coffre/conformance": "0.
|
|
92
|
+
"@coffre/conformance": "0.10.0"
|
|
93
93
|
},
|
|
94
94
|
"scripts": {
|
|
95
95
|
"build": "tsdown",
|