@coffre/ui 0.6.2 → 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.
Files changed (86) hide show
  1. package/dist/chunks/{audit-sentence-BVv_9_nq.js → audit-sentence-C1_gRxWW.js} +90 -25
  2. package/dist/chunks/audit-sentence-C1_gRxWW.js.map +1 -0
  3. package/dist/chunks/{connected-apps-rBF9XUob.js → connected-apps-Bn5rEoV2.js} +2 -2
  4. package/dist/chunks/{connected-apps-rBF9XUob.js.map → connected-apps-Bn5rEoV2.js.map} +1 -1
  5. package/dist/chunks/{delete-place-CkGezx5R.js → delete-place-CQCDHkne.js} +3 -3
  6. package/dist/chunks/{delete-place-CkGezx5R.js.map → delete-place-CQCDHkne.js.map} +1 -1
  7. package/dist/chunks/{directory-SRN01yP6.js → directory-BQNOdze_.js} +6 -5
  8. package/dist/chunks/{directory-SRN01yP6.js.map → directory-BQNOdze_.js.map} +1 -1
  9. package/dist/chunks/{grants-1E1vqkM0.js → grants-CJIBrkod.js} +3 -3
  10. package/dist/chunks/{grants-1E1vqkM0.js.map → grants-CJIBrkod.js.map} +1 -1
  11. package/dist/chunks/{offboarding-Bt7KSixm.js → offboarding-CrgwaetA.js} +3 -3
  12. package/dist/chunks/offboarding-CrgwaetA.js.map +1 -0
  13. package/dist/chunks/personal-tokens-B8rkT-DI.js +138 -0
  14. package/dist/chunks/personal-tokens-B8rkT-DI.js.map +1 -0
  15. package/dist/chunks/{principal-page-Cbx2l6XL.js → principal-page-DDmmV1KQ.js} +25 -12
  16. package/dist/chunks/principal-page-DDmmV1KQ.js.map +1 -0
  17. package/dist/chunks/{project-page-DKo2AFYg.js → project-page-BI--vjt3.js} +2 -2
  18. package/dist/chunks/{project-page-DKo2AFYg.js.map → project-page-BI--vjt3.js.map} +1 -1
  19. package/dist/chunks/{queries-BvSw1xBN.js → queries-epz4MIuW.js} +19 -5
  20. package/dist/chunks/queries-epz4MIuW.js.map +1 -0
  21. package/dist/chunks/{references-DCoSPtvw.js → references-DImfw0cz.js} +3 -3
  22. package/dist/chunks/{references-DCoSPtvw.js.map → references-DImfw0cz.js.map} +1 -1
  23. package/dist/chunks/{role-field-D98CvNEg.js → role-field-C1KhNaIR.js} +2 -2
  24. package/dist/chunks/{role-field-D98CvNEg.js.map → role-field-C1KhNaIR.js.map} +1 -1
  25. package/dist/chunks/{use-action-Bv7yQ0DW.js → use-action-BB-RcHo1.js} +2 -2
  26. package/dist/chunks/{use-action-Bv7yQ0DW.js.map → use-action-BB-RcHo1.js.map} +1 -1
  27. package/dist/chunks/{use-change-DIQTGXER.js → use-change-CQyDpCqw.js} +268 -17
  28. package/dist/chunks/use-change-CQyDpCqw.js.map +1 -0
  29. package/dist/chunks/{use-shell-DhFoHjDS.js → use-shell-C_NmvCt_.js} +2 -2
  30. package/dist/chunks/{use-shell-DhFoHjDS.js.map → use-shell-C_NmvCt_.js.map} +1 -1
  31. package/dist/index.d.ts +33 -0
  32. package/dist/index.js +4 -3
  33. package/dist/index.js.map +1 -1
  34. package/dist/pages/account.d.ts +1 -1
  35. package/dist/pages/account.js +26 -9
  36. package/dist/pages/account.js.map +1 -1
  37. package/dist/pages/audit.js +52 -32
  38. package/dist/pages/audit.js.map +1 -1
  39. package/dist/pages/environment.js +520 -192
  40. package/dist/pages/environment.js.map +1 -1
  41. package/dist/pages/login.js +1 -1
  42. package/dist/pages/project-access.js +8 -8
  43. package/dist/pages/project-access.js.map +1 -1
  44. package/dist/pages/project-environments.js +106 -19
  45. package/dist/pages/project-environments.js.map +1 -1
  46. package/dist/pages/project-settings.js +6 -6
  47. package/dist/pages/project.js +1 -1
  48. package/dist/pages/projects.js +4 -4
  49. package/dist/pages/service-account.js +278 -29
  50. package/dist/pages/service-account.js.map +1 -1
  51. package/dist/pages/service-accounts.js +4 -4
  52. package/dist/pages/settings.js +4 -4
  53. package/dist/pages/unregistered.js +1 -1
  54. package/dist/pages/user.js +5 -5
  55. package/dist/pages/users.js +4 -4
  56. package/package.json +3 -3
  57. package/src/components/actions-log.tsx +2 -1
  58. package/src/components/directory.tsx +1 -0
  59. package/src/components/generate-value.tsx +15 -7
  60. package/src/components/offboarding.tsx +1 -1
  61. package/src/components/personal-tokens.tsx +131 -0
  62. package/src/components/principal-page.tsx +20 -3
  63. package/src/components/regenerate.tsx +72 -0
  64. package/src/components/service-tokens.tsx +3 -3
  65. package/src/components/trusted-workloads.tsx +177 -8
  66. package/src/lib/audit-sentences.ts +100 -12
  67. package/src/lib/bindings.ts +41 -3
  68. package/src/lib/changes.ts +155 -20
  69. package/src/lib/generate.ts +3 -146
  70. package/src/lib/queries.ts +15 -4
  71. package/src/lib/recipes.ts +63 -0
  72. package/src/lib/reveal.ts +7 -1
  73. package/src/lib/secret-edit-batch.ts +64 -5
  74. package/src/options.ts +5 -1
  75. package/src/pages/account.tsx +27 -5
  76. package/src/pages/audit.tsx +23 -7
  77. package/src/pages/environment.tsx +357 -39
  78. package/src/pages/project-access.tsx +1 -1
  79. package/src/pages/project-environments.tsx +85 -12
  80. package/src/parity.ts +18 -2
  81. package/src/styles/globals.css +56 -3
  82. package/dist/chunks/audit-sentence-BVv_9_nq.js.map +0 -1
  83. package/dist/chunks/offboarding-Bt7KSixm.js.map +0 -1
  84. package/dist/chunks/principal-page-Cbx2l6XL.js.map +0 -1
  85. package/dist/chunks/queries-BvSw1xBN.js.map +0 -1
  86. package/dist/chunks/use-change-DIQTGXER.js.map +0 -1
@@ -1,27 +1,28 @@
1
- import { E as isActiveAccessibleEnvironment, i as keys, t as affects, v as queries, w as canRevealSecrets } from "../chunks/queries-BvSw1xBN.js";
1
+ import { E as isActiveAccessibleEnvironment, i as keys, t as affects, v as queries, w as canRevealSecrets } from "../chunks/queries-epz4MIuW.js";
2
2
  import { a as ErrorLine, c as Notice, d as Tip, g as createCopier, h as breakAfterUnderscores, i as EmptyState, l as Spinner, n as ConfirmDialog, o as MenuPopup, r as CopyButton, s as Modal, t as ConfirmButton, u as Timestamp } from "../chunks/ui-2kwXXfrX.js";
3
3
  import { i as SecretReadOnly } from "../chunks/affordances-Dtyha68j.js";
4
- import { $ as SlashCircle, A as History, D as Generate, E as Folder, G as Plus, H as MoreHorizontal, J as Search, L as Lock, M as Key, S as Clock, T as EyeOff, W as Pencil, Z as Shuffle, _ as Check, g as ArrowRight, h as Archive, i as PageHeader, k as Hash, n as ClosedDoor, o as failureMessage, p as AlertCircle, q as RotateBack, rt as Upload, st as X, t as Card, tt as Terminal, u as useCoffre, w as Eye, x as ChevronsUpDown, y as ChevronDown } from "../chunks/page-JTORvh-N.js";
4
+ import { $ as SlashCircle, A as History, D as Generate, E as Folder, G as Plus, H as MoreHorizontal, J as Search, L as Lock, M as Key, S as Clock, T as EyeOff, W as Pencil, Z as Shuffle, _ as Check, g as ArrowRight, h as Archive, i as PageHeader, k as Hash, n as ClosedDoor, nt as Trash, o as failureMessage, p as AlertCircle, q as RotateBack, rt as Upload, st as X, t as Card, tt as Terminal, u as useCoffre, w as Eye, x as ChevronsUpDown, y as ChevronDown } from "../chunks/page-JTORvh-N.js";
5
5
  import { a as rowClass, i as RowPending, r as RowFailure } from "../chunks/row-state-BsIHspy4.js";
6
- import { t as useShell } from "../chunks/use-shell-DhFoHjDS.js";
7
- import { A as saveSecrets, D as restoreSecret, E as restoreMissing, M as companionsOf, N as hasSecretEditConflict, P as secretChangeFor, a as UnsavedEdits, b as missingList, i as changeOptions, m as dismissMissing, n as useChangeStatus, r as changeKey, s as archiveSecret, t as useChange, x as moveSecret } from "../chunks/use-change-DIQTGXER.js";
6
+ import { t as useShell } from "../chunks/use-shell-C_NmvCt_.js";
7
+ import { B as regeneratedKeys, F as companionsOf, I as hasSecretEditConflict, L as secretChangeFor, N as saveSecrets, O as restoreMissing, R as liveGeneration, S as moveSecret, _ as forkKey, a as UnsavedEdits, i as changeOptions, k as restoreSecret, m as dismissMissing, n as useChangeStatus, r as changeKey, s as archiveSecret, t as useChange, w as regenerateSecret, x as missingList, z as regenerateWaits } from "../chunks/use-change-CQyDpCqw.js";
8
8
  import { i as secretKeyProblem, n as folderProblem } from "../chunks/validation-DiHIwZRA.js";
9
9
  import { t as pageRoute } from "../chunks/page-route-Drfw7lmn.js";
10
- import { t as useAction } from "../chunks/use-action-Bv7yQ0DW.js";
10
+ import { t as useAction } from "../chunks/use-action-BB-RcHo1.js";
11
11
  import { n as FolderRow, r as MoveToFolder, t as FolderMenu } from "../chunks/folders-Dw240WMJ.js";
12
12
  import { t as MultiCombobox } from "../chunks/multi-combobox-CsIXihuc.js";
13
- import { i as ReferenceValue, n as LentReferences, o as archiveBlockers, r as MakeReference, t as ArchiveBlocked } from "../chunks/references-DCoSPtvw.js";
13
+ import { i as ReferenceValue, n as LentReferences, o as archiveBlockers, r as MakeReference, t as ArchiveBlocked } from "../chunks/references-DImfw0cz.js";
14
14
  import { useEffect, useId, useReducer, useRef, useState } from "react";
15
- import { Link } from "@tanstack/react-router";
15
+ import { Link, useNavigate } from "@tanstack/react-router";
16
16
  import { toast } from "sonner";
17
17
  import { Menu } from "@base-ui/react/menu";
18
18
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
19
19
  import { useMutation, useQuery, useQueryClient, useSuspenseQuery } from "@tanstack/react-query";
20
20
  import { CoffreError, ageInDays, byFolder, foldersOf, olderThan, planImport, shownMember } from "@coffre/client";
21
+ import { DEFAULT_RECIPE, ENCODINGS, MAX_BYTES, MIN_BYTES, PAIRS, describeRecipe, encodedLength, formatRecipe, generate, parseRecipe, publicKeyName, recipeProblem } from "@coffre/core/recipe";
21
22
  import { parseDotenv } from "@coffre/core/dotenv";
22
23
  //#region src/lib/reveal.ts
23
- function revealIsCurrent(reveal, currentVersion) {
24
- return reveal !== null && reveal.version === currentVersion;
24
+ function revealIsCurrent(reveal, currentVersion, currentFrom) {
25
+ return reveal !== null && reveal.version === currentVersion && reveal.from === currentFrom;
25
26
  }
26
27
  //#endregion
27
28
  //#region src/lib/row-reads.ts
@@ -102,136 +103,10 @@ function inDialog(target) {
102
103
  //#endregion
103
104
  //#region src/lib/generate.ts
104
105
  /**
105
- * Values the browser makes for a secret: random strings, AES keys and EC key
106
- * pairs, from Web Crypto alone.
107
- *
108
- * Nothing here talks to the server. A value made here goes into the row's
109
- * field like a typed one, and leaves the page only when that row is saved.
106
+ * What the Generate dialog checks of the names it saves a key pair under.
107
+ * The values themselves, and their recipes, are `@coffre/core/recipe`'s,
108
+ * which the CLI makes them by too.
110
109
  */
111
- var DEFAULT_RECIPE = {
112
- kind: "random",
113
- encoding: "base62",
114
- bytes: 32
115
- };
116
- var ENCODINGS = [
117
- {
118
- id: "base62",
119
- name: "Letters and digits"
120
- },
121
- {
122
- id: "hex",
123
- name: "Hex"
124
- },
125
- {
126
- id: "base64",
127
- name: "Base64"
128
- },
129
- {
130
- id: "base64url",
131
- name: "Base64 URL"
132
- }
133
- ];
134
- /** Strongest first, as a new key should be. */
135
- var PAIRS = [
136
- {
137
- algorithm: "ECDSA",
138
- curve: "P-521"
139
- },
140
- {
141
- algorithm: "ECDSA",
142
- curve: "P-384"
143
- },
144
- {
145
- algorithm: "ECDSA",
146
- curve: "P-256"
147
- },
148
- {
149
- algorithm: "ECDH",
150
- curve: "P-521"
151
- },
152
- {
153
- algorithm: "ECDH",
154
- curve: "P-384"
155
- },
156
- {
157
- algorithm: "ECDH",
158
- curve: "P-256"
159
- }
160
- ];
161
- var BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
162
- /**
163
- * The largest multiple of 62 a byte reaches: 248. A byte below it is taken
164
- * modulo 62, and each of the 62 characters has four bytes that make it. The
165
- * eight bytes from 248 up are thrown away, as taking them would make the
166
- * first eight characters a little likelier than the rest.
167
- */
168
- var BASE62_LIMIT = 256 - 256 % 62;
169
- var randomBytes = (bytes) => crypto.getRandomValues(bytes);
170
- /**
171
- * How many characters carry `bytes` of entropy. Hex and base64 encode the
172
- * bytes themselves; base62 draws whole characters, each worth log2(62) bits,
173
- * so it takes as many as reach the same number of bits: 43 for 32 bytes.
174
- * Base64 pads to a multiple of four; base64 URL leaves the padding off.
175
- */
176
- function encodedLength(encoding, bytes) {
177
- switch (encoding) {
178
- case "hex": return bytes * 2;
179
- case "base64": return Math.ceil(bytes / 3) * 4;
180
- case "base64url": return Math.ceil(bytes * 8 / 6);
181
- case "base62": return Math.ceil(bytes * 8 / Math.log2(62));
182
- }
183
- }
184
- /** `length` characters of base62, each drawn uniformly by rejecting the bytes 248 to 255. */
185
- function base62(length, random = randomBytes) {
186
- let out = "";
187
- while (out.length < length) for (const byte of random(new Uint8Array(length - out.length + 8))) {
188
- if (byte >= BASE62_LIMIT) continue;
189
- out += BASE62[byte % 62];
190
- if (out.length === length) break;
191
- }
192
- return out;
193
- }
194
- function randomValue(encoding, bytes, random = randomBytes) {
195
- if (encoding === "base62") return base62(encodedLength("base62", bytes), random);
196
- const drawn = random(new Uint8Array(bytes));
197
- if (encoding === "hex") return [...drawn].map((byte) => byte.toString(16).padStart(2, "0")).join("");
198
- const base64 = toBase64(drawn);
199
- return encoding === "base64" ? base64 : base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
200
- }
201
- async function generate(recipe) {
202
- switch (recipe.kind) {
203
- case "random": return { value: randomValue(recipe.encoding, recipe.bytes) };
204
- case "aes": {
205
- const key = await subtle().generateKey({
206
- name: "AES-GCM",
207
- length: recipe.size
208
- }, true, ["encrypt", "decrypt"]);
209
- return { value: toBase64(await subtle().exportKey("raw", key)) };
210
- }
211
- case "pair": {
212
- const usages = recipe.algorithm === "ECDSA" ? ["sign", "verify"] : ["deriveBits"];
213
- const pair = await subtle().generateKey({
214
- name: recipe.algorithm,
215
- namedCurve: recipe.curve
216
- }, true, usages);
217
- return {
218
- value: toBase64(await subtle().exportKey("pkcs8", pair.privateKey)),
219
- publicKey: toBase64(await subtle().exportKey("spki", pair.publicKey))
220
- };
221
- }
222
- }
223
- }
224
- /**
225
- * The name a key pair's public key gets beside its private key's:
226
- * `JWT_PRIVATE_KEY` gives `JWT_PUBLIC_KEY`, any other name gains `_PUBLIC`.
227
- */
228
- function publicKeyName(privateName) {
229
- const name = privateName.trim();
230
- if (name === "") return "";
231
- if (/PRIVATE/.test(name)) return name.replace(/PRIVATE/g, "PUBLIC");
232
- if (/private/.test(name)) return name.replace(/private/g, "public");
233
- return `${name}_PUBLIC`;
234
- }
235
110
  /** What stops a key pair's two names from being saved, if anything. */
236
111
  function pairNameProblem(privateName, publicName) {
237
112
  const names = [privateName.trim(), publicName.trim()];
@@ -242,16 +117,6 @@ function pairNameProblem(privateName, publicName) {
242
117
  }
243
118
  return names[0] === names[1] ? "The two keys need different names." : null;
244
119
  }
245
- /** Web Crypto's keys need a secure context: HTTPS, or the machine's own address. */
246
- function subtle() {
247
- if (globalThis.crypto?.subtle === void 0) throw new Error("This page is not served over HTTPS, so the browser makes no keys here.");
248
- return globalThis.crypto.subtle;
249
- }
250
- function toBase64(bytes) {
251
- let binary = "";
252
- for (const byte of new Uint8Array(bytes)) binary += String.fromCharCode(byte);
253
- return btoa(binary);
254
- }
255
120
  //#endregion
256
121
  //#region src/components/masked.tsx
257
122
  /**
@@ -367,7 +232,10 @@ function GenerateForm({ name, renamable, publicName: pendingPublicName, onCancel
367
232
  let current = true;
368
233
  setGenerated(null);
369
234
  setError(null);
370
- generate(recipe).then((made) => current && setGenerated(made), (failure) => current && setError(failure instanceof Error ? failure.message : "The browser made no value."));
235
+ generate(recipe).then((made) => current && setGenerated({
236
+ ...made,
237
+ recipe: formatRecipe(recipe)
238
+ }), (failure) => current && setError(failure instanceof Error ? failure.message : "The browser made no value."));
371
239
  return () => {
372
240
  current = false;
373
241
  };
@@ -380,13 +248,15 @@ function GenerateForm({ name, renamable, publicName: pendingPublicName, onCancel
380
248
  onUse(kind === "pair" && generated.publicKey !== void 0 ? {
381
249
  value: generated.value,
382
250
  name: privateName.trim(),
251
+ recipe: generated.recipe,
383
252
  companion: {
384
253
  key: publicKey.trim(),
385
254
  value: generated.publicKey
386
255
  }
387
256
  } : {
388
257
  value: generated.value,
389
- name
258
+ name,
259
+ recipe: generated.recipe
390
260
  });
391
261
  }
392
262
  return /* @__PURE__ */ jsxs("form", {
@@ -479,8 +349,8 @@ function GenerateForm({ name, renamable, publicName: pendingPublicName, onCancel
479
349
  type: "range",
480
350
  "aria-label": "Length in bytes",
481
351
  "aria-valuetext": `${bytes} bytes`,
482
- min: 1,
483
- max: 256,
352
+ min: MIN_BYTES,
353
+ max: MAX_BYTES,
484
354
  value: bytes,
485
355
  onChange: (event) => {
486
356
  setBytes(Number(event.target.value));
@@ -492,14 +362,14 @@ function GenerateForm({ name, renamable, publicName: pendingPublicName, onCancel
492
362
  className: "input generate-bytes",
493
363
  type: "number",
494
364
  inputMode: "numeric",
495
- min: 1,
496
- max: 256,
365
+ min: MIN_BYTES,
366
+ max: MAX_BYTES,
497
367
  value: bytesText,
498
368
  "aria-describedby": `${id}-entropy`,
499
369
  onChange: (event) => {
500
370
  setBytesText(event.target.value);
501
371
  const typed = Number(event.target.value);
502
- if (Number.isInteger(typed) && typed >= 1 && typed <= 256) setBytes(typed);
372
+ if (Number.isInteger(typed) && typed >= MIN_BYTES && typed <= MAX_BYTES) setBytes(typed);
503
373
  },
504
374
  onBlur: () => setBytesText(String(bytes))
505
375
  }),
@@ -550,6 +420,17 @@ function GenerateForm({ name, renamable, publicName: pendingPublicName, onCancel
550
420
  format: kind === "aes" ? `the raw key, base64, ${size === 256 ? 44 : 24} characters` : void 0,
551
421
  value: generated?.value ?? null
552
422
  }),
423
+ /* @__PURE__ */ jsxs("p", {
424
+ className: "hint",
425
+ children: [
426
+ "Saved with its recipe, ",
427
+ /* @__PURE__ */ jsx("span", {
428
+ className: "mono",
429
+ children: formatRecipe(recipe)
430
+ }),
431
+ ", so Regenerate makes the next one alike."
432
+ ]
433
+ }),
553
434
  /* @__PURE__ */ jsx(ErrorLine, { error }),
554
435
  /* @__PURE__ */ jsxs("div", {
555
436
  className: "dialog-actions generate-actions",
@@ -627,6 +508,63 @@ function NamedValue({ label, format, name, onName, value, describedBy }) {
627
508
  });
628
509
  }
629
510
  //#endregion
511
+ //#region src/components/regenerate.tsx
512
+ /** What a generated key's recipe makes, in words; null for one this page does not know. */
513
+ function recipeInWords(generated) {
514
+ return recipeProblem(generated.recipe) === null ? describeRecipe(parseRecipe(generated.recipe)) : null;
515
+ }
516
+ /** Beside a key whose value was generated: how, on hover or focus. */
517
+ function RecipeMark({ generated }) {
518
+ const label = `Generated: ${recipeInWords(generated) ?? generated.recipe}`;
519
+ return /* @__PURE__ */ jsx(Tip, {
520
+ label,
521
+ children: /* @__PURE__ */ jsx("span", {
522
+ className: "recipe-mark",
523
+ tabIndex: 0,
524
+ role: "img",
525
+ "aria-label": label,
526
+ children: /* @__PURE__ */ jsx(Generate, { size: 12 })
527
+ })
528
+ });
529
+ }
530
+ /**
531
+ * Asks before regenerating a key by its recipe (`regenerateSecret`, which
532
+ * the row runs on confirm): a new value made in this browser, written as
533
+ * its next version, and never shown. A key pair's either half makes the
534
+ * pair again, both keys in one write, in the environment the page is on.
535
+ */
536
+ function RegenerateSecret({ open, onOpenChange, place, entry, generated, onConfirm }) {
537
+ const made = recipeInWords(generated);
538
+ const body = generated.pair === void 0 ? `A new value, ${made ?? generated.recipe}, is made in this browser and saved as v${(entry.version ?? 0) + 1}. Nobody sees it; whatever reads ${place} gets it from now on.` : `A new key pair is made in this browser and saved as ${generated.pair.private} and ${generated.pair.public}, together. Nobody sees it; whatever reads ${place} gets both from now on.`;
539
+ return /* @__PURE__ */ jsx(ConfirmDialog, {
540
+ open,
541
+ onOpenChange,
542
+ title: /* @__PURE__ */ jsxs(Fragment$1, { children: [
543
+ "Regenerate ",
544
+ /* @__PURE__ */ jsx("span", {
545
+ className: "mono",
546
+ children: entry.key
547
+ }),
548
+ generated.pair !== void 0 && " and its pair",
549
+ "?"
550
+ ] }),
551
+ body,
552
+ detail: /* @__PURE__ */ jsxs("p", {
553
+ className: "hint",
554
+ children: [
555
+ "Recipe ",
556
+ /* @__PURE__ */ jsx("span", {
557
+ className: "mono",
558
+ children: generated.recipe
559
+ }),
560
+ generated.pair !== void 0 && made !== null && /* @__PURE__ */ jsxs(Fragment$1, { children: [": ", made] })
561
+ ]
562
+ }),
563
+ confirmLabel: "Regenerate",
564
+ onConfirm
565
+ });
566
+ }
567
+ //#endregion
630
568
  //#region src/lib/dismissal.ts
631
569
  /**
632
570
  * Dismiss missing keys, and say so at once in a toast with Undo. A refused
@@ -782,15 +720,21 @@ function EnvironmentPage() {
782
720
  }),
783
721
  children: result.error
784
722
  });
723
+ if (result.personal?.fallback === true) return /* @__PURE__ */ jsx(NoPersonalConfig, {
724
+ project,
725
+ of: result.personal.of
726
+ });
785
727
  return /* @__PURE__ */ jsx(EnvironmentLedger, {
786
728
  project,
787
729
  environment,
788
730
  permissions: result.permissions,
789
731
  keys: result.keys,
732
+ parents: result.parents ?? [],
733
+ personal: result.personal != null,
790
734
  rotateAfterDays: result.rotateAfterDays
791
735
  }, `${project}/${environment}`);
792
736
  }
793
- function EnvironmentLedger({ project, environment, permissions, keys: keys$1, rotateAfterDays }) {
737
+ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, parents, personal, rotateAfterDays }) {
794
738
  const coffre = useCoffre();
795
739
  const queryClient = useQueryClient();
796
740
  const { principal } = useShell();
@@ -810,6 +754,28 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
810
754
  project,
811
755
  environment
812
756
  }));
757
+ const regenerate = useChange(regenerateSecret(coffre, {
758
+ project,
759
+ environment
760
+ }, principal?.id ?? null));
761
+ const forkChanges = {
762
+ remove: useChange(forkKey(coffre, {
763
+ project,
764
+ environment
765
+ }, "remove")),
766
+ restore: useChange(forkKey(coffre, {
767
+ project,
768
+ environment
769
+ }, "restore")),
770
+ reset: useChange(forkKey(coffre, {
771
+ project,
772
+ environment
773
+ }, "reset")),
774
+ override: useChange(forkKey(coffre, {
775
+ project,
776
+ environment
777
+ }, "override"))
778
+ };
813
779
  const { data: references } = useQuery(queries.references(coffre, `${project}/${environment}`));
814
780
  const lentBy = /* @__PURE__ */ new Map();
815
781
  for (const reference of references?.ok === true ? references.references : []) {
@@ -817,7 +783,7 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
817
783
  if (sourceProject !== project || sourceEnvironment !== environment) continue;
818
784
  lentBy.set(key, [...lentBy.get(key) ?? [], reference]);
819
785
  }
820
- const readable = useShell().projects.flatMap((each) => each.environments.filter(isActiveAccessibleEnvironment).map((one) => `${each.slug}/${one.slug}`));
786
+ const readable = useShell().projects.flatMap((each) => each.environments.filter((one) => isActiveAccessibleEnvironment(one) && !one.personal).map((one) => `${each.slug}/${one.slug}`));
821
787
  const { status, dismiss } = useChangeStatus(keys.secrets({
822
788
  project,
823
789
  environment
@@ -842,10 +808,11 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
842
808
  const canReveal = canRevealSecrets(permissions);
843
809
  const active = byFolder(keys$1.filter((entry) => !entry.archived)).flatMap(([, entries]) => entries);
844
810
  const folders = foldersOf(active);
845
- const settled = active.filter((entry) => status(entry.key).state !== "pending" && secretChangeFor(changes, entry.key) === void 0);
811
+ const heldHere = (entry) => entry.parent === null || entry.parent.state === "overridden";
812
+ const settled = active.filter((entry) => heldHere(entry) && status(entry.key).state !== "pending" && secretChangeFor(changes, entry.key) === void 0);
846
813
  const refile = useAction();
847
814
  const place = `${project}/${environment}`;
848
- const folderMenu = (folder, count) => canWrite && /* @__PURE__ */ jsx(FolderMenu, {
815
+ const folderMenu = (folder, count) => canWrite && count > 0 && /* @__PURE__ */ jsx(FolderMenu, {
849
816
  folder,
850
817
  count,
851
818
  what: "key",
@@ -868,6 +835,12 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
868
835
  const archived = keys$1.filter((entry) => entry.archived);
869
836
  const existing = new Set(keys$1.map((entry) => entry.key));
870
837
  const versionOf = (key) => keys$1.find((entry) => entry.key === key.trim())?.version ?? null;
838
+ /** The listed version id of each key, those with one: what a regenerate replaces. */
839
+ const versionIdOf = (name) => active.find((entry) => entry.key === name)?.versionId ?? null;
840
+ const versionsOf = (names) => Object.fromEntries(names.flatMap((name) => {
841
+ const version = versionIdOf(name);
842
+ return version === null ? [] : [[name, version]];
843
+ }));
871
844
  const changedEntries = active.filter((entry) => secretChangeFor(changes, entry.key) !== void 0);
872
845
  const hasConflict = hasSecretEditConflict(active, drafts, changes);
873
846
  const pendingNames = [
@@ -1018,6 +991,30 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
1018
991
  onClick: () => archive({ key })
1019
992
  } }) });
1020
993
  }
994
+ /**
995
+ * In a fork, a key against its parent's: removed, restored, reset to the
996
+ * parent's value or overriding it again. Each is undone by its opposite,
997
+ * so it gets an Undo rather than a confirmation dialog in front of it.
998
+ */
999
+ function forkAction(entry, action) {
1000
+ const from = entry.parent?.from ?? parents[0] ?? "its parent";
1001
+ const undo = {
1002
+ remove: "restore",
1003
+ restore: "remove",
1004
+ reset: "override",
1005
+ override: "reset"
1006
+ };
1007
+ const said = {
1008
+ remove: `${entry.key} removed: ${environment} does without ${from}'s`,
1009
+ restore: `${entry.key} inherited from ${from} again`,
1010
+ reset: `${entry.key} reads ${from}'s value again; its own is kept`,
1011
+ override: `${entry.key} overrides ${from} again`
1012
+ };
1013
+ forkChanges[action]({ key: entry.key }, { onSuccess: () => toast.success(said[action], { action: {
1014
+ label: "Undo",
1015
+ onClick: () => forkChanges[undo[action]]({ key: entry.key })
1016
+ } }) });
1017
+ }
1021
1018
  const saveRef = useRef(saveChanges);
1022
1019
  saveRef.current = saveChanges;
1023
1020
  useEffect(() => {
@@ -1050,6 +1047,10 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
1050
1047
  key: entry.key,
1051
1048
  what: `→ ${change.key.trim()}`
1052
1049
  };
1050
+ if (entry.parent !== null && entry.parent.state !== "overridden") return {
1051
+ key: entry.key,
1052
+ what: withCompanion(`overrides ${entry.parent.from}`, change.companion)
1053
+ };
1053
1054
  return {
1054
1055
  key: entry.key,
1055
1056
  what: withCompanion("new value", change.companion)
@@ -1062,7 +1063,70 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
1062
1063
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
1063
1064
  /* @__PURE__ */ jsx(PageHeader, {
1064
1065
  tile: project,
1065
- title: environment
1066
+ title: environment,
1067
+ actions: personal ? /* @__PURE__ */ jsx(DeletePersonal, {
1068
+ project,
1069
+ environment,
1070
+ of: parents[0]
1071
+ }) : principal?.type === "user" && canReveal && /* @__PURE__ */ jsxs(Link, {
1072
+ className: "btn btn-sm",
1073
+ to: "/projects/$project/$environment",
1074
+ params: {
1075
+ project,
1076
+ environment: `${environment}@me`
1077
+ },
1078
+ children: [
1079
+ /* @__PURE__ */ jsx(Key, { size: 14 }),
1080
+ "My own ",
1081
+ environment
1082
+ ]
1083
+ }),
1084
+ description: personal ? /* @__PURE__ */ jsxs("span", {
1085
+ className: "inherits",
1086
+ children: [
1087
+ "Your own",
1088
+ " ",
1089
+ /* @__PURE__ */ jsxs(Link, {
1090
+ className: "mono",
1091
+ to: "/projects/$project/$environment",
1092
+ params: {
1093
+ project,
1094
+ environment: parents[0]
1095
+ },
1096
+ children: [
1097
+ project,
1098
+ "/",
1099
+ parents[0]
1100
+ ]
1101
+ }),
1102
+ ": what you set here, only you read, while you read ",
1103
+ parents[0],
1104
+ "; the rest is ",
1105
+ parents[0],
1106
+ "'s, as it changes."
1107
+ ]
1108
+ }) : parents.length > 0 && /* @__PURE__ */ jsxs("span", {
1109
+ className: "inherits",
1110
+ children: [
1111
+ "Inherits from",
1112
+ " ",
1113
+ /* @__PURE__ */ jsxs(Link, {
1114
+ className: "mono",
1115
+ to: "/projects/$project/$environment",
1116
+ params: {
1117
+ project,
1118
+ environment: parents[0]
1119
+ },
1120
+ children: [
1121
+ project,
1122
+ "/",
1123
+ parents[0]
1124
+ ]
1125
+ }),
1126
+ parents.length > 1 && /* @__PURE__ */ jsxs(Fragment$1, { children: [", which inherits from ", parents.slice(1).map((parent) => `${project}/${parent}`).join(", then ")] }),
1127
+ ": its keys, as they change, but for those set or removed here."
1128
+ ]
1129
+ })
1066
1130
  }),
1067
1131
  (active.length > 0 || drafts.length > 0) && /* @__PURE__ */ jsxs("div", {
1068
1132
  className: "toolbar",
@@ -1175,7 +1239,7 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
1175
1239
  folder,
1176
1240
  count: entries.length,
1177
1241
  columns,
1178
- actions: folderMenu(folder, entries.length)
1242
+ actions: folderMenu(folder, entries.filter(heldHere).length)
1179
1243
  }, `folder:${folder}`)], ...entries.map((entry) => {
1180
1244
  const change = secretChangeFor(changes, entry.key);
1181
1245
  const state = status(entry.key);
@@ -1184,6 +1248,13 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
1184
1248
  project,
1185
1249
  environment,
1186
1250
  entry,
1251
+ generated: liveGeneration(entry, active),
1252
+ busy: (key) => status(key).state === "pending" || editing.has(key) || secretChangeFor(changes, key) !== void 0 || drafts.some((draft) => draft.key.trim() === key || draft.companion?.key.trim() === key) || versionIdOf(key) === null,
1253
+ onRegenerate: (generated) => regenerate({
1254
+ key: entry.key,
1255
+ generated,
1256
+ versions: versionsOf(regeneratedKeys(entry.key, generated))
1257
+ }, { onSuccess: () => toast.success(`Regenerated ${regeneratedKeys(entry.key, generated).join(" and ")}`) }),
1187
1258
  rotateAfterDays,
1188
1259
  change: change ?? {
1189
1260
  key: entry.key,
@@ -1200,11 +1271,12 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
1200
1271
  folder
1201
1272
  }),
1202
1273
  lent: lentBy.get(entry.key) ?? [],
1203
- environments: readable,
1274
+ environments: personal ? [] : readable,
1204
1275
  status: state,
1205
1276
  disabled: state.state === "pending",
1206
1277
  onDismiss: dismiss,
1207
1278
  columns,
1279
+ onFork: (action) => forkAction(entry, action),
1208
1280
  onEdit: () => setEditing((current) => new Set(current).add(entry.key)),
1209
1281
  onPatch: (patch) => patchChange(entry, patch),
1210
1282
  onUndo: () => dropChange(entry.key),
@@ -1628,7 +1700,7 @@ function useSecondsLeft(reveal) {
1628
1700
  if (reveal === null) return 0;
1629
1701
  return Math.max(0, Math.ceil(REVEAL_TTL_SECONDS - (now - reveal.at) / 1e3));
1630
1702
  }
1631
- function SecretRow({ number, project, environment, entry, rotateAfterDays, change, editing, canWrite, canArchive, canReveal, folders, onMove, lent, environments, status, disabled, onDismiss, columns, onEdit, onPatch, onUndo, onSave, versionOf, saveReady, onMarkArchive }) {
1703
+ function SecretRow({ number, project, environment, entry, generated, busy, onRegenerate, rotateAfterDays, change, editing, canWrite, canArchive, canReveal, folders, onMove, lent, environments, status, disabled, onDismiss, columns, onFork, onEdit, onPatch, onUndo, onSave, versionOf, saveReady, onMarkArchive }) {
1632
1704
  const [reads, dispatch] = useReducer(rowReads, noReads);
1633
1705
  const { reveal, revealing, error, copyError } = reads;
1634
1706
  const setReveal = (next) => dispatch({
@@ -1640,25 +1712,37 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
1640
1712
  const [moving, setMoving] = useState(false);
1641
1713
  const [referring, setReferring] = useState(false);
1642
1714
  const [breaking, setBreaking] = useState(null);
1715
+ const [regenerating, setRegenerating] = useState(false);
1643
1716
  const [lentOpen, setLentOpen] = useState(false);
1644
1717
  const [archiveBlocked, setArchiveBlocked] = useState(false);
1645
1718
  const blockers = archiveBlockers(`${project}/${environment}/${entry.key}`, lent);
1646
1719
  const { run: act, error: actError } = useAction();
1647
- const { reference } = entry;
1720
+ const { reference, parent } = entry;
1721
+ const inherited = parent?.state === "inherited";
1722
+ const removed = parent?.state === "removed";
1723
+ const overridden = parent?.state === "overridden";
1724
+ const own = !inherited && !removed;
1725
+ const parentHidden = inherited && entry.version === null && reference === null;
1726
+ const canRead = canReveal && !removed && !parentHidden;
1648
1727
  const readVersion = reference === null ? entry.version : reference.version;
1728
+ const readFrom = `${inherited ? parent.from : "."}:${reference?.source ?? ""}`;
1649
1729
  const holderPath = `${project}/${environment}/${entry.key}`;
1650
1730
  const [base, setBase] = useState(null);
1651
- const shown = revealIsCurrent(reveal, readVersion) ? reveal : null;
1731
+ const shown = revealIsCurrent(reveal, readVersion, readFrom) ? reveal : null;
1652
1732
  useEffect(() => {
1653
- if (reveal !== null && !revealIsCurrent(reveal, readVersion)) setReveal(null);
1654
- }, [reveal, readVersion]);
1733
+ if (reveal !== null && !revealIsCurrent(reveal, readVersion, readFrom)) setReveal(null);
1734
+ }, [
1735
+ reveal,
1736
+ readVersion,
1737
+ readFrom
1738
+ ]);
1655
1739
  useEffect(() => {
1656
1740
  if (reveal === null) return;
1657
1741
  const timer = setTimeout(() => setReveal(null), REVEAL_TTL_SECONDS * 1e3);
1658
1742
  return () => clearTimeout(timer);
1659
1743
  }, [reveal]);
1660
1744
  const secondsLeft = useSecondsLeft(shown);
1661
- const editBase = editing && revealIsCurrent(base, readVersion) ? base : null;
1745
+ const editBase = editing && revealIsCurrent(base, readVersion, readFrom) ? base : null;
1662
1746
  useEffect(() => {
1663
1747
  if (!editing) setBase(null);
1664
1748
  }, [editing]);
@@ -1672,6 +1756,7 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
1672
1756
  reveal: show ? {
1673
1757
  value,
1674
1758
  version: readVersion,
1759
+ from: readFrom,
1675
1760
  at: Date.now()
1676
1761
  } : null
1677
1762
  });
@@ -1713,7 +1798,7 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
1713
1798
  const [focusName, setFocusName] = useState(false);
1714
1799
  async function startEdit({ name = false } = {}) {
1715
1800
  setFocusName(name);
1716
- if (canReveal) {
1801
+ if (canRead) {
1717
1802
  setOpening(true);
1718
1803
  const value = await readValue({ show: false });
1719
1804
  setOpening(false);
@@ -1721,6 +1806,7 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
1721
1806
  setBase({
1722
1807
  value,
1723
1808
  version: readVersion,
1809
+ from: readFrom,
1724
1810
  at: Date.now()
1725
1811
  });
1726
1812
  }
@@ -1731,7 +1817,7 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
1731
1817
  const renamed = change.key !== entry.key;
1732
1818
  const valueChanged = change.value !== null;
1733
1819
  const keyProblem = editing ? secretKeyProblem(change.key.trim()) : null;
1734
- const state = leaving ? " is-leaving" : editing && (renamed || valueChanged) ? " is-changed" : shown !== null ? " is-revealed" : "";
1820
+ const state = leaving ? " is-leaving" : editing && (renamed || valueChanged) ? " is-changed" : shown !== null ? " is-revealed" : removed ? " is-removed" : inherited ? " is-inherited" : "";
1735
1821
  const version = entry.version ?? 0;
1736
1822
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
1737
1823
  /* @__PURE__ */ jsxs("tr", {
@@ -1744,7 +1830,7 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
1744
1830
  /* @__PURE__ */ jsx("td", {
1745
1831
  className: "cell-key",
1746
1832
  "data-label": "Key",
1747
- children: editing && canWrite ? /* @__PURE__ */ jsxs("div", {
1833
+ children: editing && canWrite && own ? /* @__PURE__ */ jsxs("div", {
1748
1834
  className: "edit-stack",
1749
1835
  children: [/* @__PURE__ */ jsx("input", {
1750
1836
  className: "input input-mono",
@@ -1770,10 +1856,16 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
1770
1856
  className: "key-cell",
1771
1857
  children: [
1772
1858
  /* @__PURE__ */ jsx("span", { children: breakAfterUnderscores(entry.key) }),
1859
+ generated !== null && /* @__PURE__ */ jsx(RecipeMark, { generated }),
1773
1860
  leaving && /* @__PURE__ */ jsx("span", {
1774
1861
  className: "tag tag-red",
1775
1862
  children: "Will be archived"
1776
1863
  }),
1864
+ parent !== null && /* @__PURE__ */ jsx(Standing, {
1865
+ project,
1866
+ secretKey: entry.key,
1867
+ parent
1868
+ }),
1777
1869
  lent.length > 0 && /* @__PURE__ */ jsxs("button", {
1778
1870
  type: "button",
1779
1871
  className: "tag tag-button tag-violet",
@@ -1806,16 +1898,18 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
1806
1898
  autoFocus: !focusName,
1807
1899
  onChange: (value) => onPatch({
1808
1900
  value: value === (editBase?.value ?? "") ? null : value,
1809
- companion: void 0
1901
+ companion: void 0,
1902
+ recipe: void 0
1810
1903
  }),
1811
1904
  onEscape: onUndo,
1812
1905
  generate: {
1813
1906
  name: change.key,
1814
1907
  renamable: false,
1815
1908
  companion: change.companion,
1816
- onUse: ({ value, companion }) => onPatch({
1909
+ onUse: ({ value, companion, recipe }) => onPatch({
1817
1910
  value,
1818
- companion
1911
+ companion,
1912
+ recipe
1819
1913
  })
1820
1914
  }
1821
1915
  }),
@@ -1823,6 +1917,14 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
1823
1917
  companion: change.companion,
1824
1918
  versionOf
1825
1919
  }),
1920
+ !overridden && parent !== null && /* @__PURE__ */ jsxs("span", {
1921
+ className: "edit-note",
1922
+ children: [
1923
+ "Saved here, over ",
1924
+ parent.from,
1925
+ "'s value"
1926
+ ]
1927
+ }),
1826
1928
  reference !== null && reference.state === "live" && /* @__PURE__ */ jsxs("span", {
1827
1929
  className: "edit-note",
1828
1930
  children: ["Saving a value stops following ", /* @__PURE__ */ jsx("span", {
@@ -1852,6 +1954,9 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
1852
1954
  "aria-hidden": true
1853
1955
  })
1854
1956
  ]
1957
+ }) : removed ? /* @__PURE__ */ jsx("span", {
1958
+ className: "cell-muted",
1959
+ children: "Not served here"
1855
1960
  }) : reference !== null ? /* @__PURE__ */ jsx(ReferenceValue, { reference }) : /* @__PURE__ */ jsx("span", {
1856
1961
  className: "mask",
1857
1962
  "aria-label": "Hidden",
@@ -1877,8 +1982,14 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
1877
1982
  "aria-label": leaving ? `Keep ${entry.key}` : `Cancel editing ${entry.key}`,
1878
1983
  children: /* @__PURE__ */ jsx(X, { size: 15 })
1879
1984
  })
1880
- })] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(SecretReadOnly, {
1881
- canReveal,
1985
+ })] }) : removed ? canWrite && /* @__PURE__ */ jsx("button", {
1986
+ type: "button",
1987
+ className: "btn btn-sm",
1988
+ onClick: () => onFork("restore"),
1989
+ disabled,
1990
+ children: "Restore"
1991
+ }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(SecretReadOnly, {
1992
+ canReveal: canRead,
1882
1993
  children: [/* @__PURE__ */ jsx(CopyButton, {
1883
1994
  variant: "act",
1884
1995
  copier,
@@ -1895,12 +2006,12 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
1895
2006
  })
1896
2007
  })]
1897
2008
  }), canWrite && /* @__PURE__ */ jsx(Tip, {
1898
- label: "Edit",
2009
+ label: inherited ? `Override ${parent.from}'s` : "Edit",
1899
2010
  children: /* @__PURE__ */ jsx("button", {
1900
2011
  className: "act act-icon",
1901
2012
  onClick: () => void startEdit(),
1902
2013
  disabled: disabled || revealing,
1903
- "aria-label": `Edit ${entry.key}`,
2014
+ "aria-label": inherited ? `Override ${entry.key}` : `Edit ${entry.key}`,
1904
2015
  children: opening ? /* @__PURE__ */ jsx(Spinner, { size: 13 }) : /* @__PURE__ */ jsx(Pencil, { size: 14 })
1905
2016
  })
1906
2017
  })] })
@@ -1910,7 +2021,10 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
1910
2021
  /* @__PURE__ */ jsx("td", {
1911
2022
  className: "col-version",
1912
2023
  "data-label": "Version",
1913
- children: editing && valueChanged ? /* @__PURE__ */ jsxs("span", {
2024
+ children: editing && valueChanged && !overridden && parent !== null ? /* @__PURE__ */ jsx("span", {
2025
+ className: "version-shift",
2026
+ children: /* @__PURE__ */ jsx("b", { children: "own" })
2027
+ }) : editing && valueChanged ? /* @__PURE__ */ jsxs("span", {
1914
2028
  className: "version-shift",
1915
2029
  children: [
1916
2030
  "v",
@@ -1920,21 +2034,21 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
1920
2034
  ]
1921
2035
  }) : /* @__PURE__ */ jsx("span", {
1922
2036
  className: "version-shift",
1923
- title: reference === null ? void 0 : "The source's version",
2037
+ title: inherited ? `${parent.from}'s version` : reference === null ? void 0 : "The source's version",
1924
2038
  children: readVersion === null ? "—" : `v${readVersion}`
1925
2039
  })
1926
2040
  }),
1927
2041
  /* @__PURE__ */ jsx("td", {
1928
2042
  className: "col-written",
1929
2043
  "data-label": "Last written",
1930
- children: /* @__PURE__ */ jsx(Written, {
2044
+ children: !removed && /* @__PURE__ */ jsx(Written, {
1931
2045
  entry,
1932
2046
  rotateAfterDays
1933
2047
  })
1934
2048
  }),
1935
2049
  /* @__PURE__ */ jsx("td", {
1936
2050
  className: "col-actions",
1937
- children: status.state === "pending" ? /* @__PURE__ */ jsx(RowPending, { status }) : (canReveal || canWrite && !editing && !leaving || canArchive && !leaving) && /* @__PURE__ */ jsxs(Menu.Root, { children: [/* @__PURE__ */ jsx(Menu.Trigger, {
2051
+ children: status.state === "pending" ? /* @__PURE__ */ jsx(RowPending, { status }) : !removed && (canReveal || canWrite && !editing && !leaving || canArchive && !leaving && own && !overridden) && /* @__PURE__ */ jsxs(Menu.Root, { children: [/* @__PURE__ */ jsx(Menu.Trigger, {
1938
2052
  className: "act act-icon act-quiet",
1939
2053
  "aria-label": `More for ${entry.key}`,
1940
2054
  disabled,
@@ -1943,34 +2057,70 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
1943
2057
  align: "end",
1944
2058
  children: [
1945
2059
  /* @__PURE__ */ jsx(SecretReadOnly, {
1946
- canReveal,
2060
+ canReveal: canReveal && own,
1947
2061
  children: /* @__PURE__ */ jsxs(Menu.Item, {
1948
2062
  className: "menu-item",
1949
2063
  onClick: () => setHistoryOpen((open) => !open),
1950
2064
  children: [/* @__PURE__ */ jsx(History, { size: 14 }), historyOpen ? "Hide history" : "Version history"]
1951
2065
  })
1952
2066
  }),
1953
- canWrite && !editing && !leaving && /* @__PURE__ */ jsxs(Menu.Item, {
2067
+ canWrite && !editing && inherited && /* @__PURE__ */ jsxs(Fragment$1, { children: [
2068
+ /* @__PURE__ */ jsxs(Menu.Item, {
2069
+ className: "menu-item",
2070
+ onClick: () => void startEdit(),
2071
+ children: [/* @__PURE__ */ jsx(Pencil, { size: 14 }), "Override…"]
2072
+ }),
2073
+ parent.reset && /* @__PURE__ */ jsxs(Menu.Item, {
2074
+ className: "menu-item",
2075
+ onClick: () => onFork("override"),
2076
+ children: [/* @__PURE__ */ jsx(RotateBack, { size: 14 }), "Use its own value again"]
2077
+ }),
2078
+ /* @__PURE__ */ jsxs(Menu.Item, {
2079
+ className: "menu-item",
2080
+ onClick: () => onFork("remove"),
2081
+ children: [
2082
+ /* @__PURE__ */ jsx(SlashCircle, { size: 14 }),
2083
+ "Remove from ",
2084
+ environment
2085
+ ]
2086
+ })
2087
+ ] }),
2088
+ canWrite && !editing && !leaving && overridden && /* @__PURE__ */ jsxs(Menu.Item, {
2089
+ className: "menu-item",
2090
+ onClick: () => onFork("reset"),
2091
+ children: [
2092
+ /* @__PURE__ */ jsx(RotateBack, { size: 14 }),
2093
+ "Reset to ",
2094
+ parent.from
2095
+ ]
2096
+ }),
2097
+ canWrite && !editing && !leaving && own && /* @__PURE__ */ jsxs(Menu.Item, {
1954
2098
  className: "menu-item",
1955
2099
  onClick: () => void startEdit({ name: true }),
1956
2100
  children: [/* @__PURE__ */ jsx(Pencil, { size: 14 }), "Rename"]
1957
2101
  }),
1958
- canWrite && !editing && !leaving && /* @__PURE__ */ jsxs(Menu.Item, {
2102
+ canWrite && !editing && !leaving && generated !== null && /* @__PURE__ */ jsxs(Menu.Item, {
2103
+ className: "menu-item",
2104
+ disabled: regenerateWaits(entry.key, generated, busy),
2105
+ onClick: () => setRegenerating(true),
2106
+ children: [/* @__PURE__ */ jsx(Generate, { size: 14 }), "Regenerate…"]
2107
+ }),
2108
+ canWrite && !editing && !leaving && own && /* @__PURE__ */ jsxs(Menu.Item, {
1959
2109
  className: "menu-item",
1960
2110
  onClick: () => setMoving(true),
1961
2111
  children: [/* @__PURE__ */ jsx(Folder, { size: 14 }), "Move to folder…"]
1962
2112
  }),
1963
- canWrite && !editing && !leaving && /* @__PURE__ */ jsxs(Menu.Item, {
2113
+ canWrite && !editing && !leaving && own && environments.length > 0 && /* @__PURE__ */ jsxs(Menu.Item, {
1964
2114
  className: "menu-item",
1965
2115
  onClick: () => setReferring(true),
1966
2116
  children: [/* @__PURE__ */ jsx(ArrowRight, { size: 14 }), reference === null ? "Make a reference…" : "Point elsewhere…"]
1967
2117
  }),
1968
- canWrite && !editing && !leaving && reference !== null && reference.state === "live" && /* @__PURE__ */ jsxs(Menu.Item, {
2118
+ canWrite && !editing && !leaving && own && reference !== null && reference.state === "live" && /* @__PURE__ */ jsxs(Menu.Item, {
1969
2119
  className: "menu-item",
1970
2120
  onClick: () => setBreaking(holderPath),
1971
2121
  children: [/* @__PURE__ */ jsx(SlashCircle, { size: 14 }), "Break reference…"]
1972
2122
  }),
1973
- canArchive && !leaving && /* @__PURE__ */ jsxs(Fragment$1, { children: [(canReveal || canWrite) && /* @__PURE__ */ jsx(Menu.Separator, { className: "menu-sep" }), /* @__PURE__ */ jsxs(Menu.Item, {
2123
+ canArchive && !leaving && own && !overridden && /* @__PURE__ */ jsxs(Fragment$1, { children: [(canReveal || canWrite) && /* @__PURE__ */ jsx(Menu.Separator, { className: "menu-sep" }), /* @__PURE__ */ jsxs(Menu.Item, {
1974
2124
  className: "menu-item menu-item-danger",
1975
2125
  onClick: () => {
1976
2126
  setReveal(null);
@@ -2004,6 +2154,17 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
2004
2154
  onSuccess: () => toast.success(`${entry.key} reads ${source}`)
2005
2155
  })
2006
2156
  }),
2157
+ canWrite && generated !== null && /* @__PURE__ */ jsx(RegenerateSecret, {
2158
+ open: regenerating,
2159
+ onOpenChange: setRegenerating,
2160
+ place: `${project}/${environment}`,
2161
+ entry,
2162
+ generated,
2163
+ onConfirm: () => {
2164
+ setReveal(null);
2165
+ onRegenerate(generated);
2166
+ }
2167
+ }),
2007
2168
  /* @__PURE__ */ jsx(ConfirmDialog, {
2008
2169
  open: archiveBlocked,
2009
2170
  onOpenChange: setArchiveBlocked,
@@ -2085,6 +2246,161 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
2085
2246
  })
2086
2247
  ] });
2087
2248
  }
2249
+ /** Delete your personal config, from its page: its values erased; dev itself untouched. */
2250
+ function DeletePersonal({ project, environment, of }) {
2251
+ const coffre = useCoffre();
2252
+ const navigate = useNavigate();
2253
+ const [open, setOpen] = useState(false);
2254
+ const { error, run } = useAction();
2255
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
2256
+ /* @__PURE__ */ jsxs("button", {
2257
+ type: "button",
2258
+ className: "btn btn-sm",
2259
+ onClick: () => setOpen(true),
2260
+ children: [/* @__PURE__ */ jsx(Trash, { size: 14 }), "Delete…"]
2261
+ }),
2262
+ error !== null && /* @__PURE__ */ jsx(ErrorLine, { error }),
2263
+ /* @__PURE__ */ jsx(ConfirmDialog, {
2264
+ open,
2265
+ onOpenChange: setOpen,
2266
+ title: /* @__PURE__ */ jsxs(Fragment$1, { children: [
2267
+ "Delete your own ",
2268
+ /* @__PURE__ */ jsx("span", {
2269
+ className: "mono",
2270
+ children: of
2271
+ }),
2272
+ "?"
2273
+ ] }),
2274
+ body: `The values you set in ${project}/${environment} are erased for good. ${project}/${of} is untouched, and ${environment} reads it again.`,
2275
+ confirmLabel: "Delete",
2276
+ onConfirm: () => void run(() => coffre.environments.delete(`${project}/${environment}`), {
2277
+ affects: [...affects.secrets({
2278
+ project,
2279
+ environment
2280
+ }), ...affects.places()],
2281
+ onSuccess: () => {
2282
+ toast.success(`Your own ${of} is deleted`);
2283
+ navigate({
2284
+ to: "/projects/$project/$environment",
2285
+ params: {
2286
+ project,
2287
+ environment: of
2288
+ }
2289
+ });
2290
+ }
2291
+ })
2292
+ })
2293
+ ] });
2294
+ }
2295
+ /**
2296
+ * `dev@me` while you have no personal dev: what one is, and Make, which
2297
+ * makes it empty; your first write would make it too. A read of
2298
+ * `market/dev@me` meanwhile is dev's, so scripts can name it either way.
2299
+ */
2300
+ function NoPersonalConfig({ project, of }) {
2301
+ const coffre = useCoffre();
2302
+ const { pending, error, run } = useAction();
2303
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(PageHeader, {
2304
+ tile: project,
2305
+ title: `${of}@me`
2306
+ }), /* @__PURE__ */ jsx(Card, {
2307
+ labelledBy: "no-personal-config",
2308
+ title: `You have no personal ${of} yet`,
2309
+ children: /* @__PURE__ */ jsxs("div", {
2310
+ className: "card-row",
2311
+ children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("p", {
2312
+ className: "card-row-desc",
2313
+ children: [
2314
+ "A personal config is your own ",
2315
+ /* @__PURE__ */ jsxs("span", {
2316
+ className: "mono",
2317
+ children: [
2318
+ project,
2319
+ "/",
2320
+ of
2321
+ ]
2322
+ }),
2323
+ ": it reads ",
2324
+ of,
2325
+ "'s keys as they change, and the values you set or remove there are yours alone. No one else reads them, an Owner included, and you read them only while you read ",
2326
+ of,
2327
+ ". Until you make one, ",
2328
+ /* @__PURE__ */ jsxs("span", {
2329
+ className: "mono",
2330
+ children: [
2331
+ project,
2332
+ "/",
2333
+ of,
2334
+ "@me"
2335
+ ]
2336
+ }),
2337
+ " reads ",
2338
+ of,
2339
+ " itself, so a script can name it either way."
2340
+ ]
2341
+ }), error !== null && /* @__PURE__ */ jsx(ErrorLine, { error })] }), /* @__PURE__ */ jsxs("button", {
2342
+ type: "button",
2343
+ className: "btn btn-primary",
2344
+ disabled: pending,
2345
+ onClick: () => void run(() => coffre.environments.create(`${project}/${of}@me`), {
2346
+ affects: [...affects.secrets({
2347
+ project,
2348
+ environment: `${of}@me`
2349
+ }), ...affects.places()],
2350
+ onSuccess: () => toast.success(`Your own ${of} is made: what you set there is yours alone`)
2351
+ }),
2352
+ children: [
2353
+ pending ? /* @__PURE__ */ jsx(Spinner, { size: 13 }) : /* @__PURE__ */ jsx(Plus, { size: 14 }),
2354
+ "Make my own ",
2355
+ of
2356
+ ]
2357
+ })]
2358
+ })
2359
+ })] });
2360
+ }
2361
+ /**
2362
+ * Where a fork's key stands to its parent's (docs/design/forking.md):
2363
+ * inherited from it, overriding it, perhaps since it changed, or removed.
2364
+ * The parent links to its own row of the key.
2365
+ */
2366
+ function Standing({ project, secretKey, parent }) {
2367
+ const from = /* @__PURE__ */ jsx(Link, {
2368
+ className: "tag-link",
2369
+ to: "/projects/$project/$environment",
2370
+ params: {
2371
+ project,
2372
+ environment: parent.from
2373
+ },
2374
+ search: { filter: secretKey },
2375
+ children: parent.from
2376
+ });
2377
+ switch (parent.state) {
2378
+ case "inherited": return /* @__PURE__ */ jsxs("span", {
2379
+ className: "tag tag-outline",
2380
+ children: ["from ", from]
2381
+ });
2382
+ case "removed": return /* @__PURE__ */ jsxs("span", {
2383
+ className: "tag tag-outline",
2384
+ children: [
2385
+ "removed · ",
2386
+ from,
2387
+ " ",
2388
+ parent.held ? "has it" : "dropped it"
2389
+ ]
2390
+ });
2391
+ case "overridden": return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("span", {
2392
+ className: "tag tag-outline",
2393
+ children: ["overrides ", from]
2394
+ }), parent.changed && /* @__PURE__ */ jsx(Tip, {
2395
+ label: `${parent.from} has written a newer value since this one: check the override still holds`,
2396
+ children: /* @__PURE__ */ jsxs("span", {
2397
+ className: "tag tag-amber",
2398
+ tabIndex: 0,
2399
+ children: [parent.from, " changed since"]
2400
+ })
2401
+ })] });
2402
+ }
2403
+ }
2088
2404
  /**
2089
2405
  * A column header that orders the table: its first click ascending, the
2090
2406
  * next descending. Below the width where rows stack, the sortable headers
@@ -2224,17 +2540,19 @@ function DraftRow({ draft, existingVersion, disabled, onChange, onRemove, onSave
2224
2540
  disabled,
2225
2541
  onChange: (value) => onChange({
2226
2542
  value,
2227
- companion: void 0
2543
+ companion: void 0,
2544
+ recipe: void 0
2228
2545
  }),
2229
2546
  onEscape: onRemove,
2230
2547
  generate: {
2231
2548
  name: draft.key,
2232
2549
  renamable: true,
2233
2550
  companion: draft.companion,
2234
- onUse: ({ value, name, companion }) => onChange({
2551
+ onUse: ({ value, name, companion, recipe }) => onChange({
2235
2552
  key: name,
2236
2553
  value,
2237
- companion
2554
+ companion,
2555
+ recipe
2238
2556
  })
2239
2557
  }
2240
2558
  }), /* @__PURE__ */ jsx(CompanionNote, {
@@ -2464,7 +2782,17 @@ function VersionHistory({ project, environment, secretKey, currentVersion, canWr
2464
2782
  className: "nowrap",
2465
2783
  children: /* @__PURE__ */ jsx(Timestamp, { iso: version.createdAt })
2466
2784
  }),
2467
- /* @__PURE__ */ jsx("td", { children: version.createdBy }),
2785
+ /* @__PURE__ */ jsxs("td", { children: [version.createdBy, version.recipe !== null && /* @__PURE__ */ jsxs("span", {
2786
+ className: "cell-muted",
2787
+ children: [
2788
+ " ",
2789
+ "· generated, ",
2790
+ /* @__PURE__ */ jsx("span", {
2791
+ className: "mono",
2792
+ children: version.recipe
2793
+ })
2794
+ ]
2795
+ })] }),
2468
2796
  /* @__PURE__ */ jsx("td", {
2469
2797
  className: "cell-mono cell-muted nowrap",
2470
2798
  children: version.kek