@coffre/ui 0.6.1 → 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 (119) hide show
  1. package/dist/chunks/{audit-sentence-CUUMshIp.js → audit-sentence-C1_gRxWW.js} +91 -26
  2. package/dist/chunks/audit-sentence-C1_gRxWW.js.map +1 -0
  3. package/dist/chunks/{connected-apps-DTpatjge.js → connected-apps-Bn5rEoV2.js} +4 -4
  4. package/dist/chunks/{connected-apps-DTpatjge.js.map → connected-apps-Bn5rEoV2.js.map} +1 -1
  5. package/dist/chunks/{delete-place-SOOYVt6A.js → delete-place-CQCDHkne.js} +4 -4
  6. package/dist/chunks/{delete-place-SOOYVt6A.js.map → delete-place-CQCDHkne.js.map} +1 -1
  7. package/dist/chunks/{directory-DrtdKny2.js → directory-BQNOdze_.js} +22 -19
  8. package/dist/chunks/directory-BQNOdze_.js.map +1 -0
  9. package/dist/chunks/{folders-hR2Lnk0k.js → folders-Dw240WMJ.js} +2 -2
  10. package/dist/chunks/{folders-hR2Lnk0k.js.map → folders-Dw240WMJ.js.map} +1 -1
  11. package/dist/chunks/{grants-DDBui9YD.js → grants-CJIBrkod.js} +5 -5
  12. package/dist/chunks/{grants-DDBui9YD.js.map → grants-CJIBrkod.js.map} +1 -1
  13. package/dist/chunks/multi-combobox-CsIXihuc.js +99 -0
  14. package/dist/chunks/multi-combobox-CsIXihuc.js.map +1 -0
  15. package/dist/chunks/{offboarding-C7ECW5o0.js → offboarding-CrgwaetA.js} +4 -4
  16. package/dist/chunks/offboarding-CrgwaetA.js.map +1 -0
  17. package/dist/chunks/personal-tokens-B8rkT-DI.js +138 -0
  18. package/dist/chunks/personal-tokens-B8rkT-DI.js.map +1 -0
  19. package/dist/chunks/{principal-page-CB6dAABC.js → principal-page-DDmmV1KQ.js} +37 -27
  20. package/dist/chunks/principal-page-DDmmV1KQ.js.map +1 -0
  21. package/dist/chunks/{project-page-BHNUvr2L.js → project-page-BI--vjt3.js} +2 -2
  22. package/dist/chunks/{project-page-BHNUvr2L.js.map → project-page-BI--vjt3.js.map} +1 -1
  23. package/dist/chunks/{queries-DgQo3mC-.js → queries-epz4MIuW.js} +103 -18
  24. package/dist/chunks/queries-epz4MIuW.js.map +1 -0
  25. package/dist/chunks/{references-BQc35Q9g.js → references-DImfw0cz.js} +4 -4
  26. package/dist/chunks/{references-BQc35Q9g.js.map → references-DImfw0cz.js.map} +1 -1
  27. package/dist/chunks/{role-field-BfWRCqzl.js → role-field-C1KhNaIR.js} +2 -2
  28. package/dist/chunks/{role-field-BfWRCqzl.js.map → role-field-C1KhNaIR.js.map} +1 -1
  29. package/dist/chunks/{row-state-Zf3kZVhd.js → row-state-BsIHspy4.js} +2 -2
  30. package/dist/chunks/{row-state-Zf3kZVhd.js.map → row-state-BsIHspy4.js.map} +1 -1
  31. package/dist/chunks/{theme-B6-V9JvY.js → theme-3b4DnCow.js} +2 -2
  32. package/dist/chunks/{theme-B6-V9JvY.js.map → theme-3b4DnCow.js.map} +1 -1
  33. package/dist/chunks/{ui-Br-dNUTc.js → ui-2kwXXfrX.js} +95 -22
  34. package/dist/chunks/ui-2kwXXfrX.js.map +1 -0
  35. package/dist/chunks/{use-action-DthL5hL8.js → use-action-BB-RcHo1.js} +2 -2
  36. package/dist/chunks/{use-action-DthL5hL8.js.map → use-action-BB-RcHo1.js.map} +1 -1
  37. package/dist/chunks/{use-change-By4cG8bT.js → use-change-CQyDpCqw.js} +323 -31
  38. package/dist/chunks/use-change-CQyDpCqw.js.map +1 -0
  39. package/dist/chunks/{use-shell-D6kjSPls.js → use-shell-C_NmvCt_.js} +2 -2
  40. package/dist/chunks/{use-shell-D6kjSPls.js.map → use-shell-C_NmvCt_.js.map} +1 -1
  41. package/dist/index.d.ts +46 -164
  42. package/dist/index.js +143 -129
  43. package/dist/index.js.map +1 -1
  44. package/dist/pages/account.d.ts +1 -1
  45. package/dist/pages/account.js +29 -12
  46. package/dist/pages/account.js.map +1 -1
  47. package/dist/pages/approval.js +1 -1
  48. package/dist/pages/audit.js +96 -90
  49. package/dist/pages/audit.js.map +1 -1
  50. package/dist/pages/device-login.js +1 -1
  51. package/dist/pages/environment.js +949 -412
  52. package/dist/pages/environment.js.map +1 -1
  53. package/dist/pages/login.js +2 -2
  54. package/dist/pages/oauth-authorize.js +1 -1
  55. package/dist/pages/project-access.js +9 -9
  56. package/dist/pages/project-access.js.map +1 -1
  57. package/dist/pages/project-environments.js +112 -64
  58. package/dist/pages/project-environments.js.map +1 -1
  59. package/dist/pages/project-settings.d.ts +1 -1
  60. package/dist/pages/project-settings.js +54 -75
  61. package/dist/pages/project-settings.js.map +1 -1
  62. package/dist/pages/project.js +3 -7
  63. package/dist/pages/project.js.map +1 -1
  64. package/dist/pages/projects.js +50 -77
  65. package/dist/pages/projects.js.map +1 -1
  66. package/dist/pages/service-account.js +284 -160
  67. package/dist/pages/service-account.js.map +1 -1
  68. package/dist/pages/service-accounts.js +4 -4
  69. package/dist/pages/settings.js +5 -5
  70. package/dist/pages/unregistered.js +1 -1
  71. package/dist/pages/user.js +5 -5
  72. package/dist/pages/users.js +4 -4
  73. package/package.json +3 -3
  74. package/src/components/actions-log.tsx +3 -2
  75. package/src/components/command-palette.tsx +4 -5
  76. package/src/components/directory.tsx +7 -14
  77. package/src/components/generate-value.tsx +15 -7
  78. package/src/components/missing.tsx +63 -67
  79. package/src/components/offboarding.tsx +1 -1
  80. package/src/components/personal-tokens.tsx +131 -0
  81. package/src/components/principal-page.tsx +30 -17
  82. package/src/components/regenerate.tsx +72 -0
  83. package/src/components/service-tokens.tsx +5 -14
  84. package/src/components/shell.tsx +79 -75
  85. package/src/components/trusted-workloads.tsx +179 -19
  86. package/src/components/ui.tsx +35 -25
  87. package/src/lib/audit-sentences.ts +100 -12
  88. package/src/lib/bindings.ts +41 -3
  89. package/src/lib/changes.ts +215 -29
  90. package/src/lib/clipboard.ts +40 -0
  91. package/src/lib/copy-attempts.ts +103 -0
  92. package/src/lib/dismissal.ts +24 -0
  93. package/src/lib/generate.ts +3 -146
  94. package/src/lib/optimistic.ts +3 -1
  95. package/src/lib/queries.ts +121 -17
  96. package/src/lib/recipes.ts +63 -0
  97. package/src/lib/reveal.ts +7 -1
  98. package/src/lib/row-reads.ts +64 -0
  99. package/src/lib/secret-edit-batch.ts +64 -5
  100. package/src/options.ts +43 -51
  101. package/src/pages/account.tsx +27 -5
  102. package/src/pages/audit.tsx +38 -31
  103. package/src/pages/environment.tsx +655 -121
  104. package/src/pages/project-access.tsx +1 -1
  105. package/src/pages/project-environments.tsx +92 -45
  106. package/src/pages/project-settings.tsx +9 -20
  107. package/src/pages/project.tsx +1 -5
  108. package/src/pages/projects.tsx +13 -28
  109. package/src/parity.ts +20 -4
  110. package/src/styles/globals.css +143 -131
  111. package/dist/chunks/audit-sentence-CUUMshIp.js.map +0 -1
  112. package/dist/chunks/directory-DrtdKny2.js.map +0 -1
  113. package/dist/chunks/offboarding-C7ECW5o0.js.map +0 -1
  114. package/dist/chunks/principal-page-CB6dAABC.js.map +0 -1
  115. package/dist/chunks/project-environments-lEzFHUt4.js +0 -11
  116. package/dist/chunks/project-environments-lEzFHUt4.js.map +0 -1
  117. package/dist/chunks/queries-DgQo3mC-.js.map +0 -1
  118. package/dist/chunks/ui-Br-dNUTc.js.map +0 -1
  119. package/dist/chunks/use-change-By4cG8bT.js.map +0 -1
@@ -1,27 +1,76 @@
1
- import { n as isActiveAccessibleEnvironment } from "../chunks/project-environments-lEzFHUt4.js";
2
- import { a as ErrorLine, c as Notice, d as Tip, i as EmptyState, l as Spinner, m as breakAfterUnderscores, n as ConfirmDialog, o as MenuPopup, r as CopyButton, s as Modal, t as ConfirmButton, u as Timestamp } from "../chunks/ui-Br-dNUTc.js";
1
+ import { E as isActiveAccessibleEnvironment, i as keys, t as affects, v as queries, w as canRevealSecrets } from "../chunks/queries-epz4MIuW.js";
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";
5
- import { a as rowClass, i as RowPending, r as RowFailure } from "../chunks/row-state-Zf3kZVhd.js";
6
- import { g as queries, i as keys, t as affects, x as canRevealSecrets } from "../chunks/queries-DgQo3mC-.js";
7
- import { t as useShell } from "../chunks/use-shell-D6kjSPls.js";
8
- import { D as companionsOf, O as hasSecretEditConflict, S as restoreSecret, T as saveSecrets, _ as moveSecret, a as archiveSecret, k as secretChangeFor, n as useChangeStatus, r as UnsavedEdits, t as useChange } from "../chunks/use-change-By4cG8bT.js";
9
- import { i as secretKeyProblem } from "../chunks/validation-DiHIwZRA.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
+ 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-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
+ import { i as secretKeyProblem, n as folderProblem } from "../chunks/validation-DiHIwZRA.js";
10
9
  import { t as pageRoute } from "../chunks/page-route-Drfw7lmn.js";
11
- import { t as useAction } from "../chunks/use-action-DthL5hL8.js";
12
- import { n as FolderRow, r as MoveToFolder, t as FolderMenu } from "../chunks/folders-hR2Lnk0k.js";
13
- import { i as ReferenceValue, n as LentReferences, o as archiveBlockers, r as MakeReference, t as ArchiveBlocked } from "../chunks/references-BQc35Q9g.js";
14
- import { useEffect, useId, useRef, useState } from "react";
15
- import { Link } from "@tanstack/react-router";
10
+ import { t as useAction } from "../chunks/use-action-BB-RcHo1.js";
11
+ import { n as FolderRow, r as MoveToFolder, t as FolderMenu } from "../chunks/folders-Dw240WMJ.js";
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-DImfw0cz.js";
14
+ import { useEffect, useId, useReducer, useRef, useState } from "react";
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
- import { useQuery, useSuspenseQuery } from "@tanstack/react-query";
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;
26
+ }
27
+ //#endregion
28
+ //#region src/lib/row-reads.ts
29
+ var noReads = {
30
+ reveal: null,
31
+ revealing: false,
32
+ error: null,
33
+ copyError: null
34
+ };
35
+ function rowReads(state, action) {
36
+ switch (action.type) {
37
+ case "set-reveal": return {
38
+ ...state,
39
+ reveal: action.reveal
40
+ };
41
+ case "read-started": return {
42
+ ...state,
43
+ revealing: true
44
+ };
45
+ case "read-succeeded": return {
46
+ ...state,
47
+ revealing: false,
48
+ error: null,
49
+ reveal: action.reveal ?? state.reveal
50
+ };
51
+ case "read-failed": return {
52
+ ...state,
53
+ revealing: false,
54
+ error: action.message
55
+ };
56
+ case "copy-started":
57
+ case "copy-succeeded": return {
58
+ ...state,
59
+ copyError: null
60
+ };
61
+ case "copy-failed": return {
62
+ ...state,
63
+ copyError: action.message
64
+ };
65
+ }
66
+ }
67
+ /**
68
+ * Whether the eye button is out of reach: while a read is on its way and there
69
+ * is nothing on screen yet. Once a value is shown, Hide is always available,
70
+ * whatever else is being read.
71
+ */
72
+ function revealToggleDisabled(state, shown) {
73
+ return shown === null && state.revealing;
25
74
  }
26
75
  //#endregion
27
76
  //#region src/lib/secret-order.ts
@@ -54,136 +103,10 @@ function inDialog(target) {
54
103
  //#endregion
55
104
  //#region src/lib/generate.ts
56
105
  /**
57
- * Values the browser makes for a secret: random strings, AES keys and EC key
58
- * pairs, from Web Crypto alone.
59
- *
60
- * Nothing here talks to the server. A value made here goes into the row's
61
- * field like a typed one, and leaves the page only when that row is saved.
62
- */
63
- var DEFAULT_RECIPE = {
64
- kind: "random",
65
- encoding: "base62",
66
- bytes: 32
67
- };
68
- var ENCODINGS = [
69
- {
70
- id: "base62",
71
- name: "Letters and digits"
72
- },
73
- {
74
- id: "hex",
75
- name: "Hex"
76
- },
77
- {
78
- id: "base64",
79
- name: "Base64"
80
- },
81
- {
82
- id: "base64url",
83
- name: "Base64 URL"
84
- }
85
- ];
86
- /** Strongest first, as a new key should be. */
87
- var PAIRS = [
88
- {
89
- algorithm: "ECDSA",
90
- curve: "P-521"
91
- },
92
- {
93
- algorithm: "ECDSA",
94
- curve: "P-384"
95
- },
96
- {
97
- algorithm: "ECDSA",
98
- curve: "P-256"
99
- },
100
- {
101
- algorithm: "ECDH",
102
- curve: "P-521"
103
- },
104
- {
105
- algorithm: "ECDH",
106
- curve: "P-384"
107
- },
108
- {
109
- algorithm: "ECDH",
110
- curve: "P-256"
111
- }
112
- ];
113
- var BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
114
- /**
115
- * The largest multiple of 62 a byte reaches: 248. A byte below it is taken
116
- * modulo 62, and each of the 62 characters has four bytes that make it. The
117
- * eight bytes from 248 up are thrown away, as taking them would make the
118
- * first eight characters a little likelier than the rest.
119
- */
120
- var BASE62_LIMIT = 256 - 256 % 62;
121
- var randomBytes = (bytes) => crypto.getRandomValues(bytes);
122
- /**
123
- * How many characters carry `bytes` of entropy. Hex and base64 encode the
124
- * bytes themselves; base62 draws whole characters, each worth log2(62) bits,
125
- * so it takes as many as reach the same number of bits: 43 for 32 bytes.
126
- * Base64 pads to a multiple of four; base64 URL leaves the padding off.
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.
127
109
  */
128
- function encodedLength(encoding, bytes) {
129
- switch (encoding) {
130
- case "hex": return bytes * 2;
131
- case "base64": return Math.ceil(bytes / 3) * 4;
132
- case "base64url": return Math.ceil(bytes * 8 / 6);
133
- case "base62": return Math.ceil(bytes * 8 / Math.log2(62));
134
- }
135
- }
136
- /** `length` characters of base62, each drawn uniformly by rejecting the bytes 248 to 255. */
137
- function base62(length, random = randomBytes) {
138
- let out = "";
139
- while (out.length < length) for (const byte of random(new Uint8Array(length - out.length + 8))) {
140
- if (byte >= BASE62_LIMIT) continue;
141
- out += BASE62[byte % 62];
142
- if (out.length === length) break;
143
- }
144
- return out;
145
- }
146
- function randomValue(encoding, bytes, random = randomBytes) {
147
- if (encoding === "base62") return base62(encodedLength("base62", bytes), random);
148
- const drawn = random(new Uint8Array(bytes));
149
- if (encoding === "hex") return [...drawn].map((byte) => byte.toString(16).padStart(2, "0")).join("");
150
- const base64 = toBase64(drawn);
151
- return encoding === "base64" ? base64 : base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
152
- }
153
- async function generate(recipe) {
154
- switch (recipe.kind) {
155
- case "random": return { value: randomValue(recipe.encoding, recipe.bytes) };
156
- case "aes": {
157
- const key = await subtle().generateKey({
158
- name: "AES-GCM",
159
- length: recipe.size
160
- }, true, ["encrypt", "decrypt"]);
161
- return { value: toBase64(await subtle().exportKey("raw", key)) };
162
- }
163
- case "pair": {
164
- const usages = recipe.algorithm === "ECDSA" ? ["sign", "verify"] : ["deriveBits"];
165
- const pair = await subtle().generateKey({
166
- name: recipe.algorithm,
167
- namedCurve: recipe.curve
168
- }, true, usages);
169
- return {
170
- value: toBase64(await subtle().exportKey("pkcs8", pair.privateKey)),
171
- publicKey: toBase64(await subtle().exportKey("spki", pair.publicKey))
172
- };
173
- }
174
- }
175
- }
176
- /**
177
- * The name a key pair's public key gets beside its private key's:
178
- * `JWT_PRIVATE_KEY` gives `JWT_PUBLIC_KEY`, any other name gains `_PUBLIC`.
179
- */
180
- function publicKeyName(privateName) {
181
- const name = privateName.trim();
182
- if (name === "") return "";
183
- if (/PRIVATE/.test(name)) return name.replace(/PRIVATE/g, "PUBLIC");
184
- if (/private/.test(name)) return name.replace(/private/g, "public");
185
- return `${name}_PUBLIC`;
186
- }
187
110
  /** What stops a key pair's two names from being saved, if anything. */
188
111
  function pairNameProblem(privateName, publicName) {
189
112
  const names = [privateName.trim(), publicName.trim()];
@@ -194,16 +117,6 @@ function pairNameProblem(privateName, publicName) {
194
117
  }
195
118
  return names[0] === names[1] ? "The two keys need different names." : null;
196
119
  }
197
- /** Web Crypto's keys need a secure context: HTTPS, or the machine's own address. */
198
- function subtle() {
199
- if (globalThis.crypto?.subtle === void 0) throw new Error("This page is not served over HTTPS, so the browser makes no keys here.");
200
- return globalThis.crypto.subtle;
201
- }
202
- function toBase64(bytes) {
203
- let binary = "";
204
- for (const byte of new Uint8Array(bytes)) binary += String.fromCharCode(byte);
205
- return btoa(binary);
206
- }
207
120
  //#endregion
208
121
  //#region src/components/masked.tsx
209
122
  /**
@@ -319,7 +232,10 @@ function GenerateForm({ name, renamable, publicName: pendingPublicName, onCancel
319
232
  let current = true;
320
233
  setGenerated(null);
321
234
  setError(null);
322
- 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."));
323
239
  return () => {
324
240
  current = false;
325
241
  };
@@ -332,13 +248,15 @@ function GenerateForm({ name, renamable, publicName: pendingPublicName, onCancel
332
248
  onUse(kind === "pair" && generated.publicKey !== void 0 ? {
333
249
  value: generated.value,
334
250
  name: privateName.trim(),
251
+ recipe: generated.recipe,
335
252
  companion: {
336
253
  key: publicKey.trim(),
337
254
  value: generated.publicKey
338
255
  }
339
256
  } : {
340
257
  value: generated.value,
341
- name
258
+ name,
259
+ recipe: generated.recipe
342
260
  });
343
261
  }
344
262
  return /* @__PURE__ */ jsxs("form", {
@@ -431,8 +349,8 @@ function GenerateForm({ name, renamable, publicName: pendingPublicName, onCancel
431
349
  type: "range",
432
350
  "aria-label": "Length in bytes",
433
351
  "aria-valuetext": `${bytes} bytes`,
434
- min: 1,
435
- max: 256,
352
+ min: MIN_BYTES,
353
+ max: MAX_BYTES,
436
354
  value: bytes,
437
355
  onChange: (event) => {
438
356
  setBytes(Number(event.target.value));
@@ -444,14 +362,14 @@ function GenerateForm({ name, renamable, publicName: pendingPublicName, onCancel
444
362
  className: "input generate-bytes",
445
363
  type: "number",
446
364
  inputMode: "numeric",
447
- min: 1,
448
- max: 256,
365
+ min: MIN_BYTES,
366
+ max: MAX_BYTES,
449
367
  value: bytesText,
450
368
  "aria-describedby": `${id}-entropy`,
451
369
  onChange: (event) => {
452
370
  setBytesText(event.target.value);
453
371
  const typed = Number(event.target.value);
454
- if (Number.isInteger(typed) && typed >= 1 && typed <= 256) setBytes(typed);
372
+ if (Number.isInteger(typed) && typed >= MIN_BYTES && typed <= MAX_BYTES) setBytes(typed);
455
373
  },
456
374
  onBlur: () => setBytesText(String(bytes))
457
375
  }),
@@ -502,6 +420,17 @@ function GenerateForm({ name, renamable, publicName: pendingPublicName, onCancel
502
420
  format: kind === "aes" ? `the raw key, base64, ${size === 256 ? 44 : 24} characters` : void 0,
503
421
  value: generated?.value ?? null
504
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
+ }),
505
434
  /* @__PURE__ */ jsx(ErrorLine, { error }),
506
435
  /* @__PURE__ */ jsxs("div", {
507
436
  className: "dialog-actions generate-actions",
@@ -579,13 +508,90 @@ function NamedValue({ label, format, name, onName, value, describedBy }) {
579
508
  });
580
509
  }
581
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
568
+ //#region src/lib/dismissal.ts
569
+ /**
570
+ * Dismiss missing keys, and say so at once in a toast with Undo. A refused
571
+ * dismissal turns that toast into why it was refused, so the reason shows
572
+ * whatever the list does next: when reading it again fails too, the panel
573
+ * has no rows left to say it beneath.
574
+ */
575
+ function dismissWithUndo(entries, { dismiss, restore }) {
576
+ const said = toast.success(entries.length === 1 ? `${entries[0].key} dismissed` : `${entries.length} keys dismissed`, { action: {
577
+ label: "Undo",
578
+ onClick: () => void restore(entries).catch((error) => toast.error(`Not restored. ${failureMessage(error)}`))
579
+ } });
580
+ dismiss(entries).catch((error) => toast.error(`Not dismissed. ${failureMessage(error)}`, {
581
+ id: said,
582
+ action: void 0
583
+ }));
584
+ return said;
585
+ }
586
+ //#endregion
582
587
  //#region src/components/missing.tsx
583
588
  /**
584
589
  * Keys the environment's siblings have and it lacks, by name, whether you
585
- * read them or not (docs/design/environments.md): each with Add, which opens a new row with
586
- * its name, and Dismiss, which the whole team then sees, and below them
587
- * Dismiss all and what was dismissed, each with Restore. Nothing shows when
588
- * nothing is missing or dismissed.
590
+ * read them or not (docs/design/environments.md): each with Add, which opens
591
+ * a new row with its name, and Dismiss, which the whole team then sees, and
592
+ * below them Dismiss all. Nothing shows when nothing is missing, dismissed
593
+ * keys included: they are restored from the CLI (`coffre missing
594
+ * --dismissed`), or by Undo right after dismissing.
589
595
  */
590
596
  function MissingKeys({ project, environment, canWrite, onAdd }) {
591
597
  const coffre = useCoffre();
@@ -594,118 +600,84 @@ function MissingKeys({ project, environment, canWrite, onAdd }) {
594
600
  environment
595
601
  };
596
602
  const { data } = useQuery(queries.missing(coffre, place));
597
- const { run, pending, error } = useAction();
598
- const [showDismissed, setShowDismissed] = useState(false);
599
- if (data?.ok !== true || data.missing.length === 0 && data.dismissed.length === 0) return null;
600
- const { missing, dismissed } = data;
601
- const path = `${project}/${environment}`;
602
- const dismiss = (patch) => void run(() => coffre.environments.dismiss(path, patch), { affects: affects.secrets(place) });
603
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(Card, {
603
+ const queryClient = useQueryClient();
604
+ const dismissKeys = useMutation(changeOptions(queryClient, dismissMissing(coffre, place))).mutateAsync;
605
+ const restoreKeys = useMutation(changeOptions(queryClient, restoreMissing(coffre, place))).mutateAsync;
606
+ const list = missingList(place);
607
+ const { status, dismiss: forget } = useChangeStatus(list.queryKey);
608
+ const missing = data === void 0 ? [] : list.items(data);
609
+ if (missing.length === 0) return null;
610
+ const columns = canWrite ? 3 : 2;
611
+ const dismiss = (entries) => void dismissWithUndo(entries, {
612
+ dismiss: dismissKeys,
613
+ restore: restoreKeys
614
+ });
615
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Card, {
604
616
  wide: true,
605
617
  labelledBy: "missing-keys",
606
- title: missing.length === 0 ? "Nothing missing" : `${missing.length} ${missing.length === 1 ? "key" : "keys"} from other environments ${missing.length === 1 ? "isn't" : "aren't"} here`,
618
+ title: `${missing.length} ${missing.length === 1 ? "key" : "keys"} from other environments ${missing.length === 1 ? "isn't" : "aren't"} here`,
607
619
  description: "Compared with every other environment of the project, by key name.",
608
- children: [/* @__PURE__ */ jsx("div", {
620
+ children: /* @__PURE__ */ jsx("div", {
609
621
  className: "dt-wrap",
610
622
  children: /* @__PURE__ */ jsx("table", {
611
623
  className: "dt stacks missing-keys",
612
- children: /* @__PURE__ */ jsxs("tbody", { children: [
613
- missing.map((entry) => /* @__PURE__ */ jsxs("tr", { children: [
614
- /* @__PURE__ */ jsx("td", {
615
- className: "mono",
616
- "data-label": "Key",
617
- children: entry.key
618
- }),
619
- /* @__PURE__ */ jsxs("td", {
620
- className: "cell-muted",
621
- "data-label": "In",
622
- children: [
623
- "In ",
624
- entry.in.join(", "),
625
- entry.folder !== null && /* @__PURE__ */ jsxs(Fragment$1, { children: [
626
- ", in ",
627
- entry.folder,
628
- "/"
629
- ] })
630
- ]
631
- }),
632
- canWrite && /* @__PURE__ */ jsx("td", {
633
- className: "col-actions",
634
- children: /* @__PURE__ */ jsxs("div", {
635
- className: "acts",
636
- children: [/* @__PURE__ */ jsx("button", {
637
- type: "button",
638
- className: "btn btn-sm",
639
- onClick: () => onAdd(entry.key),
640
- children: "Add"
641
- }), /* @__PURE__ */ jsx("button", {
642
- type: "button",
643
- className: "btn btn-sm btn-quiet",
644
- disabled: pending,
645
- onClick: () => dismiss({ [entry.key]: true }),
646
- children: "Dismiss"
647
- })]
648
- })
649
- })
650
- ] }, entry.key)),
651
- showDismissed && dismissed.length > 0 && /* @__PURE__ */ jsx("tr", {
652
- className: "folder-row",
653
- children: /* @__PURE__ */ jsx("th", {
654
- colSpan: canWrite ? 3 : 2,
655
- scope: "rowgroup",
656
- children: "Dismissed"
657
- })
658
- }),
659
- showDismissed && dismissed.map((entry) => /* @__PURE__ */ jsxs("tr", { children: [
660
- /* @__PURE__ */ jsx("td", {
661
- className: "mono",
662
- "data-label": "Key",
663
- children: entry.key
664
- }),
665
- /* @__PURE__ */ jsxs("td", {
666
- className: "cell-muted",
667
- "data-label": "Dismissed",
668
- children: [
669
- "By ",
670
- entry.dismissedBy,
671
- " ",
672
- /* @__PURE__ */ jsx(Timestamp, {
673
- iso: entry.dismissedAt,
674
- display: "relative"
675
- }),
676
- "; in ",
677
- entry.in.join(", ")
678
- ]
679
- }),
680
- canWrite && /* @__PURE__ */ jsx("td", {
681
- className: "col-actions",
682
- children: /* @__PURE__ */ jsx("button", {
683
- type: "button",
684
- className: "btn btn-sm",
685
- disabled: pending,
686
- onClick: () => dismiss({ [entry.key]: null }),
687
- children: "Restore"
624
+ children: /* @__PURE__ */ jsx("tbody", { children: missing.map((entry) => {
625
+ const state = status(entry.key);
626
+ return [/* @__PURE__ */ jsxs("tr", {
627
+ className: rowClass(state),
628
+ children: [
629
+ /* @__PURE__ */ jsx("td", {
630
+ className: "mono",
631
+ "data-label": "Key",
632
+ children: entry.key
633
+ }),
634
+ /* @__PURE__ */ jsxs("td", {
635
+ className: "cell-muted",
636
+ "data-label": "In",
637
+ children: [
638
+ "In ",
639
+ entry.in.join(", "),
640
+ entry.folder !== null && /* @__PURE__ */ jsxs(Fragment$1, { children: [
641
+ ", in ",
642
+ entry.folder,
643
+ "/"
644
+ ] })
645
+ ]
646
+ }),
647
+ canWrite && /* @__PURE__ */ jsx("td", {
648
+ className: "col-actions",
649
+ children: /* @__PURE__ */ jsxs("div", {
650
+ className: "acts",
651
+ children: [/* @__PURE__ */ jsx("button", {
652
+ type: "button",
653
+ className: "btn btn-sm",
654
+ onClick: () => onAdd(entry.key),
655
+ children: "Add"
656
+ }), /* @__PURE__ */ jsx("button", {
657
+ type: "button",
658
+ className: "btn btn-sm btn-quiet",
659
+ onClick: () => dismiss([entry]),
660
+ children: "Dismiss"
661
+ })]
662
+ })
688
663
  })
689
- })
690
- ] }, `dismissed:${entry.key}`))
691
- ] })
664
+ ]
665
+ }, entry.key), /* @__PURE__ */ jsx(RowFailure, {
666
+ status: state,
667
+ columns,
668
+ onDismiss: () => state.state === "failed" && forget(state.mutationId)
669
+ }, `failure:${entry.key}`)];
670
+ }) })
692
671
  })
693
- }), error !== null && /* @__PURE__ */ jsx(ErrorLine, { error })]
694
- }), /* @__PURE__ */ jsxs("div", {
672
+ })
673
+ }), canWrite && missing.length > 1 && /* @__PURE__ */ jsx("div", {
695
674
  className: "table-actions",
696
- children: [canWrite && missing.length > 1 && /* @__PURE__ */ jsx("button", {
675
+ children: /* @__PURE__ */ jsx("button", {
697
676
  type: "button",
698
677
  className: "btn",
699
- disabled: pending,
700
- onClick: () => dismiss(Object.fromEntries(missing.map((entry) => [entry.key, true]))),
678
+ onClick: () => dismiss(missing),
701
679
  children: "Dismiss all"
702
- }), dismissed.length > 0 && /* @__PURE__ */ jsx("button", {
703
- type: "button",
704
- className: "btn btn-quiet",
705
- "aria-expanded": showDismissed,
706
- onClick: () => setShowDismissed((open) => !open),
707
- children: showDismissed ? "Hide dismissed" : `Dismissed (${dismissed.length})`
708
- })]
680
+ })
709
681
  })] });
710
682
  }
711
683
  //#endregion
@@ -719,6 +691,10 @@ var Route = pageRoute();
719
691
  * already logged, and re-revealing writes a second, honest audit row.
720
692
  */
721
693
  var REVEAL_TTL_SECONDS = 45;
694
+ /** Why a read of a secret's value failed, as the row says it. */
695
+ function readFailureMessage(failure) {
696
+ return failure instanceof CoffreError ? failureMessage(failure) : "The request could not be sent. Nothing was read.";
697
+ }
722
698
  function EnvironmentPage() {
723
699
  const { project, environment } = Route.useParams();
724
700
  const { data: result } = useSuspenseQuery(queries.secrets(useCoffre(), {
@@ -744,16 +720,23 @@ function EnvironmentPage() {
744
720
  }),
745
721
  children: result.error
746
722
  });
723
+ if (result.personal?.fallback === true) return /* @__PURE__ */ jsx(NoPersonalConfig, {
724
+ project,
725
+ of: result.personal.of
726
+ });
747
727
  return /* @__PURE__ */ jsx(EnvironmentLedger, {
748
728
  project,
749
729
  environment,
750
730
  permissions: result.permissions,
751
731
  keys: result.keys,
732
+ parents: result.parents ?? [],
733
+ personal: result.personal != null,
752
734
  rotateAfterDays: result.rotateAfterDays
753
735
  }, `${project}/${environment}`);
754
736
  }
755
- function EnvironmentLedger({ project, environment, permissions, keys: keys$1, rotateAfterDays }) {
737
+ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, parents, personal, rotateAfterDays }) {
756
738
  const coffre = useCoffre();
739
+ const queryClient = useQueryClient();
757
740
  const { principal } = useShell();
758
741
  const save = useChange(saveSecrets(coffre, {
759
742
  project,
@@ -771,6 +754,28 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
771
754
  project,
772
755
  environment
773
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
+ };
774
779
  const { data: references } = useQuery(queries.references(coffre, `${project}/${environment}`));
775
780
  const lentBy = /* @__PURE__ */ new Map();
776
781
  for (const reference of references?.ok === true ? references.references : []) {
@@ -778,7 +783,7 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
778
783
  if (sourceProject !== project || sourceEnvironment !== environment) continue;
779
784
  lentBy.set(key, [...lentBy.get(key) ?? [], reference]);
780
785
  }
781
- 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}`));
782
787
  const { status, dismiss } = useChangeStatus(keys.secrets({
783
788
  project,
784
789
  environment
@@ -796,15 +801,18 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
796
801
  by,
797
802
  descending: current.by === by && !current.descending
798
803
  }));
804
+ const [addingFolder, setAddingFolder] = useState(false);
799
805
  const nextDraftId = useRef(0);
800
806
  const canWrite = permissions.includes("secret.write");
801
807
  const canArchive = permissions.includes("secret.archive");
802
808
  const canReveal = canRevealSecrets(permissions);
803
809
  const active = byFolder(keys$1.filter((entry) => !entry.archived)).flatMap(([, entries]) => entries);
804
810
  const folders = foldersOf(active);
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);
805
813
  const refile = useAction();
806
814
  const place = `${project}/${environment}`;
807
- const folderMenu = (folder, count) => canWrite && /* @__PURE__ */ jsx(FolderMenu, {
815
+ const folderMenu = (folder, count) => canWrite && count > 0 && /* @__PURE__ */ jsx(FolderMenu, {
808
816
  folder,
809
817
  count,
810
818
  what: "key",
@@ -827,6 +835,12 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
827
835
  const archived = keys$1.filter((entry) => entry.archived);
828
836
  const existing = new Set(keys$1.map((entry) => entry.key));
829
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
+ }));
830
844
  const changedEntries = active.filter((entry) => secretChangeFor(changes, entry.key) !== void 0);
831
845
  const hasConflict = hasSecretEditConflict(active, drafts, changes);
832
846
  const pendingNames = [
@@ -893,6 +907,7 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
893
907
  function sendAlone(batch) {
894
908
  setSaveError(null);
895
909
  save(batch, { onError: (error) => {
910
+ forgetRefusal(batch);
896
911
  const left = error instanceof UnsavedEdits ? error.outcome : batch;
897
912
  setDrafts((rows) => [...rows, ...left.drafts]);
898
913
  setChanges((current) => ({
@@ -925,17 +940,25 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
925
940
  setChanges({});
926
941
  setEditing(/* @__PURE__ */ new Set());
927
942
  setSaveError(null);
928
- for (const entry of keys$1) {
929
- const state = status(entry.key);
930
- if (state.state === "failed") dismiss(state.mutationId);
931
- }
943
+ }
944
+ /**
945
+ * A refused save leaves its rows no failure of their own: its edits come
946
+ * back on them, and the bar under the table says why. Every other refused
947
+ * change, a move for one, says why beneath its row.
948
+ */
949
+ function forgetRefusal(batch) {
950
+ const saves = queryClient.getMutationCache().findAll({ mutationKey: changeKey(keys.secrets({
951
+ project,
952
+ environment
953
+ })) });
954
+ for (const each of saves) if (each.state.variables === batch) dismiss(each.mutationId);
932
955
  }
933
956
  /**
934
957
  * Write every pending edit (`saveSecrets`): renames one by one, then the
935
958
  * rest as one patch that lands whole or not at all. The edits show in the
936
959
  * list at once, each row marked as saving; whatever did not land comes
937
960
  * back as pending, so pressing save again retries exactly that, and the
938
- * save bar says why.
961
+ * bar under the table says why.
939
962
  */
940
963
  function saveChanges() {
941
964
  if (!ready) return;
@@ -949,6 +972,7 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
949
972
  setEditing(/* @__PURE__ */ new Set());
950
973
  setSaveError(null);
951
974
  save(batch, { onError: (error) => {
975
+ forgetRefusal(batch);
952
976
  const left = error instanceof UnsavedEdits ? error.outcome : batch;
953
977
  setDrafts(left.drafts);
954
978
  setChanges(left.changes);
@@ -967,6 +991,30 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
967
991
  onClick: () => archive({ key })
968
992
  } }) });
969
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
+ }
970
1018
  const saveRef = useRef(saveChanges);
971
1019
  saveRef.current = saveChanges;
972
1020
  useEffect(() => {
@@ -999,6 +1047,10 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
999
1047
  key: entry.key,
1000
1048
  what: `→ ${change.key.trim()}`
1001
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
+ };
1002
1054
  return {
1003
1055
  key: entry.key,
1004
1056
  what: withCompanion("new value", change.companion)
@@ -1012,9 +1064,68 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
1012
1064
  /* @__PURE__ */ jsx(PageHeader, {
1013
1065
  tile: project,
1014
1066
  title: environment,
1015
- aside: /* @__PURE__ */ jsx(EnvironmentName, {
1067
+ actions: personal ? /* @__PURE__ */ jsx(DeletePersonal, {
1016
1068
  project,
1017
- environment
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
+ ]
1018
1129
  })
1019
1130
  }),
1020
1131
  (active.length > 0 || drafts.length > 0) && /* @__PURE__ */ jsxs("div", {
@@ -1069,10 +1180,10 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
1069
1180
  onAdd: addDraft
1070
1181
  }),
1071
1182
  refile.error !== null && /* @__PURE__ */ jsx(ErrorLine, { error: refile.error }),
1072
- /* @__PURE__ */ jsx("section", {
1183
+ /* @__PURE__ */ jsxs("section", {
1073
1184
  className: "card card-wide",
1074
1185
  "aria-label": "Secrets",
1075
- children: active.length === 0 && drafts.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
1186
+ children: [active.length === 0 && drafts.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
1076
1187
  title: "No secrets yet",
1077
1188
  children: canWrite ? "Add them one by one, or import a .env file." : "Adding secrets here needs secret.write."
1078
1189
  }) : /* @__PURE__ */ jsx("div", {
@@ -1128,7 +1239,7 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
1128
1239
  folder,
1129
1240
  count: entries.length,
1130
1241
  columns,
1131
- actions: folderMenu(folder, entries.length)
1242
+ actions: folderMenu(folder, entries.filter(heldHere).length)
1132
1243
  }, `folder:${folder}`)], ...entries.map((entry) => {
1133
1244
  const change = secretChangeFor(changes, entry.key);
1134
1245
  const state = status(entry.key);
@@ -1137,6 +1248,13 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
1137
1248
  project,
1138
1249
  environment,
1139
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 ")}`) }),
1140
1258
  rotateAfterDays,
1141
1259
  change: change ?? {
1142
1260
  key: entry.key,
@@ -1153,10 +1271,12 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
1153
1271
  folder
1154
1272
  }),
1155
1273
  lent: lentBy.get(entry.key) ?? [],
1156
- environments: readable,
1274
+ environments: personal ? [] : readable,
1157
1275
  status: state,
1158
1276
  disabled: state.state === "pending",
1277
+ onDismiss: dismiss,
1159
1278
  columns,
1279
+ onFork: (action) => forkAction(entry, action),
1160
1280
  onEdit: () => setEditing((current) => new Set(current).add(entry.key)),
1161
1281
  onPatch: (patch) => patchChange(entry, patch),
1162
1282
  onUndo: () => dropChange(entry.key),
@@ -1205,18 +1325,39 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
1205
1325
  }, draft.id))
1206
1326
  ] })]
1207
1327
  })
1208
- })
1328
+ }), pendingCount > 0 && /* @__PURE__ */ jsx(PendingBar, {
1329
+ pending,
1330
+ ready,
1331
+ error: saveError ?? problem,
1332
+ onDiscard: discardAll,
1333
+ onSave: saveChanges
1334
+ })]
1209
1335
  }),
1210
1336
  canWrite && /* @__PURE__ */ jsxs("div", {
1211
1337
  className: "table-actions",
1212
- children: [/* @__PURE__ */ jsxs("button", {
1213
- className: "btn btn-primary",
1214
- onClick: () => addDraft(),
1215
- children: [/* @__PURE__ */ jsx(Plus, { size: 14 }), "New secret"]
1216
- }), canReveal && /* @__PURE__ */ jsx(ImportEnv, {
1217
- project,
1218
- environment
1219
- })]
1338
+ children: [
1339
+ /* @__PURE__ */ jsx(AddButton, {
1340
+ onAddSecret: () => addDraft(),
1341
+ onAddFolder: () => setAddingFolder(true),
1342
+ canAddFolder: settled.length > 0
1343
+ }),
1344
+ canReveal && /* @__PURE__ */ jsx(ImportEnv, {
1345
+ project,
1346
+ environment
1347
+ }),
1348
+ /* @__PURE__ */ jsx(AddFolder, {
1349
+ open: addingFolder,
1350
+ onOpenChange: setAddingFolder,
1351
+ keys: settled.map((entry) => entry.key),
1352
+ folders,
1353
+ onAdd: (folder, keys) => {
1354
+ for (const entry of settled) if (keys.includes(entry.key) && entry.folder !== folder) move({
1355
+ key: entry.key,
1356
+ folder
1357
+ });
1358
+ }
1359
+ })
1360
+ ]
1220
1361
  }),
1221
1362
  archived.length > 0 && /* @__PURE__ */ jsx(Card, {
1222
1363
  wide: true,
@@ -1273,68 +1414,180 @@ function EnvironmentLedger({ project, environment, permissions, keys: keys$1, ro
1273
1414
  }, entry.key)) })]
1274
1415
  })
1275
1416
  })
1276
- }),
1277
- pendingCount > 0 && /* @__PURE__ */ jsx("div", {
1278
- className: "savebar",
1279
- role: "region",
1280
- "aria-label": "Unsaved changes",
1281
- children: /* @__PURE__ */ jsxs("div", {
1282
- className: "savebar-inner",
1417
+ })
1418
+ ] });
1419
+ }
1420
+ /**
1421
+ * The pending edits, at the foot of the table they are made in: what they
1422
+ * are, Discard and Save. It sticks to the bottom of the window while the
1423
+ * table runs past it, so Save stays in reach of any row.
1424
+ */
1425
+ function PendingBar({ pending, ready, error, onDiscard, onSave }) {
1426
+ const count = pending.length;
1427
+ return /* @__PURE__ */ jsxs("div", {
1428
+ className: "pending-bar",
1429
+ role: "region",
1430
+ "aria-label": "Unsaved changes",
1431
+ children: [
1432
+ /* @__PURE__ */ jsxs("span", {
1433
+ className: "pending-count",
1283
1434
  children: [
1284
- /* @__PURE__ */ jsxs("span", {
1285
- className: "savebar-count",
1286
- children: [
1287
- /* @__PURE__ */ jsx("span", {
1288
- className: "dot",
1289
- "aria-hidden": true
1290
- }),
1291
- pendingCount,
1292
- " unsaved change",
1293
- pendingCount === 1 ? "" : "s"
1294
- ]
1295
- }),
1296
- /* @__PURE__ */ jsxs("span", {
1297
- className: "savebar-summary",
1298
- children: [pending.slice(0, 3).map((item, index) => /* @__PURE__ */ jsxs("span", { children: [
1299
- index > 0 && " · ",
1300
- /* @__PURE__ */ jsx("span", {
1301
- className: "mono",
1302
- children: item.key
1303
- }),
1304
- " ",
1305
- item.what
1306
- ] }, `${item.key}:${index}`)), pending.length > 3 && ` · and ${pending.length - 3} more`]
1435
+ /* @__PURE__ */ jsx("span", {
1436
+ className: "dot",
1437
+ "aria-hidden": true
1307
1438
  }),
1308
- /* @__PURE__ */ jsxs("div", {
1309
- className: "savebar-actions",
1310
- children: [/* @__PURE__ */ jsx("button", {
1311
- className: "btn btn-sm",
1312
- onClick: discardAll,
1313
- children: "Discard"
1314
- }), /* @__PURE__ */ jsxs("button", {
1315
- className: "btn btn-sm btn-primary",
1316
- onClick: saveChanges,
1317
- disabled: !ready,
1318
- title: "Save (⌘ Enter or Ctrl Enter)",
1319
- "aria-keyshortcuts": "Meta+Enter Control+Enter",
1320
- children: ["Save ", pendingCount === 1 ? "change" : `${pendingCount} changes`]
1321
- })]
1439
+ count,
1440
+ " unsaved change",
1441
+ count === 1 ? "" : "s"
1442
+ ]
1443
+ }),
1444
+ /* @__PURE__ */ jsxs("span", {
1445
+ className: "pending-summary",
1446
+ children: [pending.slice(0, 3).map((item, index) => /* @__PURE__ */ jsxs("span", { children: [
1447
+ index > 0 && " · ",
1448
+ /* @__PURE__ */ jsx("span", {
1449
+ className: "mono",
1450
+ children: item.key
1322
1451
  }),
1323
- (saveError ?? problem) !== null && /* @__PURE__ */ jsxs("p", {
1324
- className: "savebar-error",
1325
- role: "alert",
1326
- children: [/* @__PURE__ */ jsx(AlertCircle, { size: 14 }), /* @__PURE__ */ jsx("span", { children: saveError ?? problem })]
1452
+ " ",
1453
+ item.what
1454
+ ] }, `${item.key}:${index}`)), count > 3 && ` · and ${count - 3} more`]
1455
+ }),
1456
+ /* @__PURE__ */ jsxs("div", {
1457
+ className: "pending-actions",
1458
+ children: [/* @__PURE__ */ jsx("button", {
1459
+ className: "btn btn-sm",
1460
+ onClick: onDiscard,
1461
+ children: "Discard"
1462
+ }), /* @__PURE__ */ jsxs("button", {
1463
+ className: "btn btn-sm btn-primary",
1464
+ onClick: onSave,
1465
+ disabled: !ready,
1466
+ title: "Save (⌘ Enter or Ctrl Enter)",
1467
+ "aria-keyshortcuts": "Meta+Enter Control+Enter",
1468
+ children: ["Save ", count === 1 ? "change" : `${count} changes`]
1469
+ })]
1470
+ }),
1471
+ error !== null && /* @__PURE__ */ jsxs("p", {
1472
+ className: "pending-error",
1473
+ role: "alert",
1474
+ children: [/* @__PURE__ */ jsx(AlertCircle, { size: 14 }), /* @__PURE__ */ jsx("span", { children: error })]
1475
+ })
1476
+ ]
1477
+ });
1478
+ }
1479
+ /**
1480
+ * Add secret, and beside it a menu of the other things to add: a folder.
1481
+ * One button in look, two to the keyboard and to a screen reader, the
1482
+ * second a menu button.
1483
+ */
1484
+ function AddButton({ onAddSecret, onAddFolder, canAddFolder }) {
1485
+ return /* @__PURE__ */ jsxs("div", {
1486
+ className: "split-button",
1487
+ children: [/* @__PURE__ */ jsxs("button", {
1488
+ className: "btn btn-primary",
1489
+ onClick: onAddSecret,
1490
+ children: [/* @__PURE__ */ jsx(Plus, { size: 14 }), "Add secret"]
1491
+ }), /* @__PURE__ */ jsxs(Menu.Root, { children: [/* @__PURE__ */ jsx(Menu.Trigger, {
1492
+ className: "btn btn-primary btn-icon",
1493
+ "aria-label": "More to add",
1494
+ children: /* @__PURE__ */ jsx(ChevronDown, { size: 14 })
1495
+ }), /* @__PURE__ */ jsx(MenuPopup, {
1496
+ align: "start",
1497
+ children: /* @__PURE__ */ jsxs(Menu.Item, {
1498
+ className: "menu-item",
1499
+ onClick: onAddFolder,
1500
+ disabled: !canAddFolder,
1501
+ children: [
1502
+ /* @__PURE__ */ jsx(Folder, { size: 14 }),
1503
+ "Add folder…",
1504
+ !canAddFolder && /* @__PURE__ */ jsx("span", {
1505
+ className: "menu-hint",
1506
+ children: "after a secret"
1327
1507
  })
1328
1508
  ]
1329
1509
  })
1330
- })
1331
- ] });
1510
+ })] })]
1511
+ });
1332
1512
  }
1333
- /** The display name sits beside the slug; it comes from the shell's project tree. */
1334
- function EnvironmentName({ project, environment }) {
1335
- const { projects } = useShell();
1336
- const name = projects.find((entry) => entry.slug === project)?.environments.find((entry) => entry.slug === environment)?.name;
1337
- return name === void 0 ? null : /* @__PURE__ */ jsx(Fragment$1, { children: name });
1513
+ /**
1514
+ * A new folder, and the secrets filed in it. A folder is a name on what it
1515
+ * holds (docs/design/environments.md), so it is made with its first
1516
+ * secrets: one with nothing in it would not be there to see.
1517
+ */
1518
+ function AddFolder({ open, onOpenChange, keys, folders, onAdd }) {
1519
+ const [name, setName] = useState("");
1520
+ const [chosen, setChosen] = useState([]);
1521
+ useEffect(() => {
1522
+ if (!open) return;
1523
+ setName("");
1524
+ setChosen([]);
1525
+ }, [open]);
1526
+ const problem = folderProblem(name);
1527
+ const joins = folders.includes(name);
1528
+ const ready = name !== "" && problem === null && chosen.length > 0;
1529
+ return /* @__PURE__ */ jsx(Modal, {
1530
+ open,
1531
+ onOpenChange,
1532
+ title: "Add a folder",
1533
+ description: "Folders only arrange the list: names, values and access stay as they are.",
1534
+ children: /* @__PURE__ */ jsxs("form", {
1535
+ className: "form",
1536
+ onSubmit: (event) => {
1537
+ event.preventDefault();
1538
+ if (!ready) return;
1539
+ onAdd(name, chosen);
1540
+ onOpenChange(false);
1541
+ },
1542
+ children: [
1543
+ /* @__PURE__ */ jsxs("label", {
1544
+ className: "field",
1545
+ children: [
1546
+ /* @__PURE__ */ jsx("span", {
1547
+ className: "label",
1548
+ children: "Name"
1549
+ }),
1550
+ /* @__PURE__ */ jsx("input", {
1551
+ className: "input",
1552
+ autoFocus: true,
1553
+ spellCheck: false,
1554
+ autoComplete: "off",
1555
+ value: name,
1556
+ "aria-invalid": problem !== null,
1557
+ onChange: (event) => setName(event.target.value)
1558
+ }),
1559
+ /* @__PURE__ */ jsx("span", {
1560
+ className: `hint${problem !== null ? " edit-note-error" : ""}`,
1561
+ children: problem ?? (joins ? `${name} is in use: the secrets join it.` : "One level: no slash.")
1562
+ })
1563
+ ]
1564
+ }),
1565
+ /* @__PURE__ */ jsx(MultiCombobox, {
1566
+ label: "Secrets in it",
1567
+ options: keys,
1568
+ value: chosen,
1569
+ onChange: setChosen,
1570
+ placeholder: "Pick one or more…",
1571
+ hint: "A folder holds at least one secret.",
1572
+ mono: true
1573
+ }),
1574
+ /* @__PURE__ */ jsxs("div", {
1575
+ className: "dialog-actions",
1576
+ children: [/* @__PURE__ */ jsx("button", {
1577
+ className: "btn",
1578
+ type: "button",
1579
+ onClick: () => onOpenChange(false),
1580
+ children: "Cancel"
1581
+ }), /* @__PURE__ */ jsx("button", {
1582
+ className: "btn btn-primary",
1583
+ type: "submit",
1584
+ disabled: !ready,
1585
+ children: "Add folder"
1586
+ })]
1587
+ })
1588
+ ]
1589
+ })
1590
+ });
1338
1591
  }
1339
1592
  var lineCount = (text) => text.split("\n").length;
1340
1593
  function ValueField({ label, value, start = "", onChange, placeholder, disabled, autoFocus, onEscape, generate }) {
@@ -1447,66 +1700,105 @@ function useSecondsLeft(reveal) {
1447
1700
  if (reveal === null) return 0;
1448
1701
  return Math.max(0, Math.ceil(REVEAL_TTL_SECONDS - (now - reveal.at) / 1e3));
1449
1702
  }
1450
- function SecretRow({ number, project, environment, entry, rotateAfterDays, change, editing, canWrite, canArchive, canReveal, folders, onMove, lent, environments, status, disabled, columns, onEdit, onPatch, onUndo, onSave, versionOf, saveReady, onMarkArchive }) {
1451
- const [reveal, setReveal] = useState(null);
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 }) {
1704
+ const [reads, dispatch] = useReducer(rowReads, noReads);
1705
+ const { reveal, revealing, error, copyError } = reads;
1706
+ const setReveal = (next) => dispatch({
1707
+ type: "set-reveal",
1708
+ reveal: next
1709
+ });
1452
1710
  const coffre = useCoffre();
1453
- const [revealing, setRevealing] = useState(false);
1454
1711
  const [historyOpen, setHistoryOpen] = useState(false);
1455
1712
  const [moving, setMoving] = useState(false);
1456
1713
  const [referring, setReferring] = useState(false);
1457
1714
  const [breaking, setBreaking] = useState(null);
1715
+ const [regenerating, setRegenerating] = useState(false);
1458
1716
  const [lentOpen, setLentOpen] = useState(false);
1459
1717
  const [archiveBlocked, setArchiveBlocked] = useState(false);
1460
1718
  const blockers = archiveBlockers(`${project}/${environment}/${entry.key}`, lent);
1461
1719
  const { run: act, error: actError } = useAction();
1462
- 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;
1463
1727
  const readVersion = reference === null ? entry.version : reference.version;
1728
+ const readFrom = `${inherited ? parent.from : "."}:${reference?.source ?? ""}`;
1464
1729
  const holderPath = `${project}/${environment}/${entry.key}`;
1465
- const [error, setError] = useState(null);
1466
1730
  const [base, setBase] = useState(null);
1467
- const shown = revealIsCurrent(reveal, readVersion) ? reveal : null;
1731
+ const shown = revealIsCurrent(reveal, readVersion, readFrom) ? reveal : null;
1468
1732
  useEffect(() => {
1469
- if (reveal !== null && !revealIsCurrent(reveal, readVersion)) setReveal(null);
1470
- }, [reveal, readVersion]);
1733
+ if (reveal !== null && !revealIsCurrent(reveal, readVersion, readFrom)) setReveal(null);
1734
+ }, [
1735
+ reveal,
1736
+ readVersion,
1737
+ readFrom
1738
+ ]);
1471
1739
  useEffect(() => {
1472
1740
  if (reveal === null) return;
1473
1741
  const timer = setTimeout(() => setReveal(null), REVEAL_TTL_SECONDS * 1e3);
1474
1742
  return () => clearTimeout(timer);
1475
1743
  }, [reveal]);
1476
1744
  const secondsLeft = useSecondsLeft(shown);
1477
- const editBase = editing && revealIsCurrent(base, readVersion) ? base : null;
1745
+ const editBase = editing && revealIsCurrent(base, readVersion, readFrom) ? base : null;
1478
1746
  useEffect(() => {
1479
1747
  if (!editing) setBase(null);
1480
1748
  }, [editing]);
1481
1749
  async function readValue({ show = true } = {}) {
1482
1750
  if (shown !== null) return shown.value;
1483
- setRevealing(true);
1751
+ dispatch({ type: "read-started" });
1484
1752
  try {
1485
- const { values } = await coffre.secrets.reveal(`${project}/${environment}/${entry.key}`);
1486
- const value = values[entry.key];
1487
- setError(null);
1488
- if (show) setReveal({
1489
- value,
1490
- version: readVersion,
1491
- at: Date.now()
1753
+ const value = await fetchValue();
1754
+ dispatch({
1755
+ type: "read-succeeded",
1756
+ reveal: show ? {
1757
+ value,
1758
+ version: readVersion,
1759
+ from: readFrom,
1760
+ at: Date.now()
1761
+ } : null
1492
1762
  });
1493
1763
  return value;
1494
1764
  } catch (failure) {
1495
- setError(failure instanceof CoffreError ? failureMessage(failure) : "The request could not be sent. Nothing was read.");
1765
+ dispatch({
1766
+ type: "read-failed",
1767
+ message: readFailureMessage(failure)
1768
+ });
1496
1769
  return null;
1497
- } finally {
1498
- setRevealing(false);
1499
1770
  }
1500
1771
  }
1772
+ async function fetchValue() {
1773
+ const { values } = await coffre.secrets.reveal(`${project}/${environment}/${entry.key}`);
1774
+ return values[entry.key];
1775
+ }
1501
1776
  function toggleReveal() {
1502
1777
  if (shown !== null) setReveal(null);
1503
1778
  else readValue();
1504
1779
  }
1780
+ const [copier] = useState(() => createCopier());
1781
+ function copyValue() {
1782
+ dispatch({ type: "copy-started" });
1783
+ const read = { failed: false };
1784
+ const text = shown !== null ? shown.value : fetchValue().catch((failure) => {
1785
+ read.failed = true;
1786
+ read.failure = failure;
1787
+ throw failure;
1788
+ });
1789
+ copier.run(text).then((result) => {
1790
+ if (result.outcome === "superseded") return;
1791
+ dispatch(result.outcome === "copied" ? { type: "copy-succeeded" } : {
1792
+ type: "copy-failed",
1793
+ message: read.failed ? readFailureMessage(read.failure) : "The browser did not allow copying to the clipboard. Reveal the value and copy it by hand."
1794
+ });
1795
+ });
1796
+ }
1505
1797
  const [opening, setOpening] = useState(false);
1506
1798
  const [focusName, setFocusName] = useState(false);
1507
1799
  async function startEdit({ name = false } = {}) {
1508
1800
  setFocusName(name);
1509
- if (canReveal) {
1801
+ if (canRead) {
1510
1802
  setOpening(true);
1511
1803
  const value = await readValue({ show: false });
1512
1804
  setOpening(false);
@@ -1514,6 +1806,7 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
1514
1806
  setBase({
1515
1807
  value,
1516
1808
  version: readVersion,
1809
+ from: readFrom,
1517
1810
  at: Date.now()
1518
1811
  });
1519
1812
  }
@@ -1524,7 +1817,7 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
1524
1817
  const renamed = change.key !== entry.key;
1525
1818
  const valueChanged = change.value !== null;
1526
1819
  const keyProblem = editing ? secretKeyProblem(change.key.trim()) : null;
1527
- 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" : "";
1528
1821
  const version = entry.version ?? 0;
1529
1822
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
1530
1823
  /* @__PURE__ */ jsxs("tr", {
@@ -1537,7 +1830,7 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
1537
1830
  /* @__PURE__ */ jsx("td", {
1538
1831
  className: "cell-key",
1539
1832
  "data-label": "Key",
1540
- children: editing && canWrite ? /* @__PURE__ */ jsxs("div", {
1833
+ children: editing && canWrite && own ? /* @__PURE__ */ jsxs("div", {
1541
1834
  className: "edit-stack",
1542
1835
  children: [/* @__PURE__ */ jsx("input", {
1543
1836
  className: "input input-mono",
@@ -1563,10 +1856,16 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
1563
1856
  className: "key-cell",
1564
1857
  children: [
1565
1858
  /* @__PURE__ */ jsx("span", { children: breakAfterUnderscores(entry.key) }),
1859
+ generated !== null && /* @__PURE__ */ jsx(RecipeMark, { generated }),
1566
1860
  leaving && /* @__PURE__ */ jsx("span", {
1567
1861
  className: "tag tag-red",
1568
1862
  children: "Will be archived"
1569
1863
  }),
1864
+ parent !== null && /* @__PURE__ */ jsx(Standing, {
1865
+ project,
1866
+ secretKey: entry.key,
1867
+ parent
1868
+ }),
1570
1869
  lent.length > 0 && /* @__PURE__ */ jsxs("button", {
1571
1870
  type: "button",
1572
1871
  className: "tag tag-button tag-violet",
@@ -1599,16 +1898,18 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
1599
1898
  autoFocus: !focusName,
1600
1899
  onChange: (value) => onPatch({
1601
1900
  value: value === (editBase?.value ?? "") ? null : value,
1602
- companion: void 0
1901
+ companion: void 0,
1902
+ recipe: void 0
1603
1903
  }),
1604
1904
  onEscape: onUndo,
1605
1905
  generate: {
1606
1906
  name: change.key,
1607
1907
  renamable: false,
1608
1908
  companion: change.companion,
1609
- onUse: ({ value, companion }) => onPatch({
1909
+ onUse: ({ value, companion, recipe }) => onPatch({
1610
1910
  value,
1611
- companion
1911
+ companion,
1912
+ recipe
1612
1913
  })
1613
1914
  }
1614
1915
  }),
@@ -1616,6 +1917,14 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
1616
1917
  companion: change.companion,
1617
1918
  versionOf
1618
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
+ }),
1619
1928
  reference !== null && reference.state === "live" && /* @__PURE__ */ jsxs("span", {
1620
1929
  className: "edit-note",
1621
1930
  children: ["Saving a value stops following ", /* @__PURE__ */ jsx("span", {
@@ -1645,6 +1954,9 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
1645
1954
  "aria-hidden": true
1646
1955
  })
1647
1956
  ]
1957
+ }) : removed ? /* @__PURE__ */ jsx("span", {
1958
+ className: "cell-muted",
1959
+ children: "Not served here"
1648
1960
  }) : reference !== null ? /* @__PURE__ */ jsx(ReferenceValue, { reference }) : /* @__PURE__ */ jsx("span", {
1649
1961
  className: "mask",
1650
1962
  "aria-label": "Hidden",
@@ -1670,43 +1982,49 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
1670
1982
  "aria-label": leaving ? `Keep ${entry.key}` : `Cancel editing ${entry.key}`,
1671
1983
  children: /* @__PURE__ */ jsx(X, { size: 15 })
1672
1984
  })
1673
- })] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
1674
- shown !== null && /* @__PURE__ */ jsx(CopyButton, {
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,
1993
+ children: [/* @__PURE__ */ jsx(CopyButton, {
1675
1994
  variant: "act",
1676
- value: shown.value,
1995
+ copier,
1996
+ onCopy: copyValue,
1677
1997
  label: `Copy ${entry.key}`
1678
- }),
1679
- /* @__PURE__ */ jsx(SecretReadOnly, {
1680
- canReveal,
1681
- children: /* @__PURE__ */ jsx(Tip, {
1682
- label: shown === null ? "Reveal" : "Hide",
1683
- children: /* @__PURE__ */ jsx("button", {
1684
- className: "act act-icon act-accent",
1685
- onClick: toggleReveal,
1686
- disabled: revealing,
1687
- "aria-label": `${shown === null ? "Reveal" : "Hide"} ${entry.key}`,
1688
- children: revealing && !opening ? /* @__PURE__ */ jsx(Spinner, { size: 13 }) : shown === null ? /* @__PURE__ */ jsx(Eye, { size: 15 }) : /* @__PURE__ */ jsx(EyeOff, { size: 15 })
1689
- })
1690
- })
1691
- }),
1692
- canWrite && /* @__PURE__ */ jsx(Tip, {
1693
- label: "Edit",
1998
+ }), /* @__PURE__ */ jsx(Tip, {
1999
+ label: shown === null ? "Reveal" : "Hide",
1694
2000
  children: /* @__PURE__ */ jsx("button", {
1695
- className: "act act-icon",
1696
- onClick: () => void startEdit(),
1697
- disabled: disabled || revealing,
1698
- "aria-label": `Edit ${entry.key}`,
1699
- children: opening ? /* @__PURE__ */ jsx(Spinner, { size: 13 }) : /* @__PURE__ */ jsx(Pencil, { size: 14 })
2001
+ className: "act act-icon act-accent",
2002
+ onClick: toggleReveal,
2003
+ disabled: revealToggleDisabled(reads, shown),
2004
+ "aria-label": `${shown === null ? "Reveal" : "Hide"} ${entry.key}`,
2005
+ children: revealing && !opening ? /* @__PURE__ */ jsx(Spinner, { size: 13 }) : shown === null ? /* @__PURE__ */ jsx(Eye, { size: 15 }) : /* @__PURE__ */ jsx(EyeOff, { size: 15 })
1700
2006
  })
2007
+ })]
2008
+ }), canWrite && /* @__PURE__ */ jsx(Tip, {
2009
+ label: inherited ? `Override ${parent.from}'s` : "Edit",
2010
+ children: /* @__PURE__ */ jsx("button", {
2011
+ className: "act act-icon",
2012
+ onClick: () => void startEdit(),
2013
+ disabled: disabled || revealing,
2014
+ "aria-label": inherited ? `Override ${entry.key}` : `Edit ${entry.key}`,
2015
+ children: opening ? /* @__PURE__ */ jsx(Spinner, { size: 13 }) : /* @__PURE__ */ jsx(Pencil, { size: 14 })
1701
2016
  })
1702
- ] })
2017
+ })] })
1703
2018
  })]
1704
2019
  })
1705
2020
  }),
1706
2021
  /* @__PURE__ */ jsx("td", {
1707
2022
  className: "col-version",
1708
2023
  "data-label": "Version",
1709
- 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", {
1710
2028
  className: "version-shift",
1711
2029
  children: [
1712
2030
  "v",
@@ -1716,21 +2034,21 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
1716
2034
  ]
1717
2035
  }) : /* @__PURE__ */ jsx("span", {
1718
2036
  className: "version-shift",
1719
- title: reference === null ? void 0 : "The source's version",
2037
+ title: inherited ? `${parent.from}'s version` : reference === null ? void 0 : "The source's version",
1720
2038
  children: readVersion === null ? "—" : `v${readVersion}`
1721
2039
  })
1722
2040
  }),
1723
2041
  /* @__PURE__ */ jsx("td", {
1724
2042
  className: "col-written",
1725
2043
  "data-label": "Last written",
1726
- children: /* @__PURE__ */ jsx(Written, {
2044
+ children: !removed && /* @__PURE__ */ jsx(Written, {
1727
2045
  entry,
1728
2046
  rotateAfterDays
1729
2047
  })
1730
2048
  }),
1731
2049
  /* @__PURE__ */ jsx("td", {
1732
2050
  className: "col-actions",
1733
- 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, {
1734
2052
  className: "act act-icon act-quiet",
1735
2053
  "aria-label": `More for ${entry.key}`,
1736
2054
  disabled,
@@ -1739,34 +2057,70 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
1739
2057
  align: "end",
1740
2058
  children: [
1741
2059
  /* @__PURE__ */ jsx(SecretReadOnly, {
1742
- canReveal,
2060
+ canReveal: canReveal && own,
1743
2061
  children: /* @__PURE__ */ jsxs(Menu.Item, {
1744
2062
  className: "menu-item",
1745
2063
  onClick: () => setHistoryOpen((open) => !open),
1746
2064
  children: [/* @__PURE__ */ jsx(History, { size: 14 }), historyOpen ? "Hide history" : "Version history"]
1747
2065
  })
1748
2066
  }),
1749
- 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, {
1750
2098
  className: "menu-item",
1751
2099
  onClick: () => void startEdit({ name: true }),
1752
2100
  children: [/* @__PURE__ */ jsx(Pencil, { size: 14 }), "Rename"]
1753
2101
  }),
1754
- 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, {
1755
2109
  className: "menu-item",
1756
2110
  onClick: () => setMoving(true),
1757
2111
  children: [/* @__PURE__ */ jsx(Folder, { size: 14 }), "Move to folder…"]
1758
2112
  }),
1759
- canWrite && !editing && !leaving && /* @__PURE__ */ jsxs(Menu.Item, {
2113
+ canWrite && !editing && !leaving && own && environments.length > 0 && /* @__PURE__ */ jsxs(Menu.Item, {
1760
2114
  className: "menu-item",
1761
2115
  onClick: () => setReferring(true),
1762
2116
  children: [/* @__PURE__ */ jsx(ArrowRight, { size: 14 }), reference === null ? "Make a reference…" : "Point elsewhere…"]
1763
2117
  }),
1764
- 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, {
1765
2119
  className: "menu-item",
1766
2120
  onClick: () => setBreaking(holderPath),
1767
2121
  children: [/* @__PURE__ */ jsx(SlashCircle, { size: 14 }), "Break reference…"]
1768
2122
  }),
1769
- 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, {
1770
2124
  className: "menu-item menu-item-danger",
1771
2125
  onClick: () => {
1772
2126
  setReveal(null);
@@ -1800,6 +2154,17 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
1800
2154
  onSuccess: () => toast.success(`${entry.key} reads ${source}`)
1801
2155
  })
1802
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
+ }),
1803
2168
  /* @__PURE__ */ jsx(ConfirmDialog, {
1804
2169
  open: archiveBlocked,
1805
2170
  onOpenChange: setArchiveBlocked,
@@ -1867,16 +2232,176 @@ function SecretRow({ number, project, environment, entry, rotateAfterDays, chang
1867
2232
  })
1868
2233
  })
1869
2234
  }),
1870
- (error ?? actError) !== null && /* @__PURE__ */ jsx("tr", {
2235
+ (error ?? actError) !== null || copyError !== null ? /* @__PURE__ */ jsx("tr", {
1871
2236
  className: "row-error",
1872
- children: /* @__PURE__ */ jsx("td", {
2237
+ children: /* @__PURE__ */ jsxs("td", {
1873
2238
  colSpan: columns,
1874
- children: /* @__PURE__ */ jsx(ErrorLine, { error: error ?? actError })
2239
+ children: [/* @__PURE__ */ jsx(ErrorLine, { error: error ?? actError }), /* @__PURE__ */ jsx(ErrorLine, { error: copyError })]
2240
+ })
2241
+ }) : null,
2242
+ /* @__PURE__ */ jsx(RowFailure, {
2243
+ status,
2244
+ columns,
2245
+ onDismiss: () => status.state === "failed" && onDismiss(status.mutationId)
2246
+ })
2247
+ ] });
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
+ }
1875
2291
  })
1876
2292
  })
1877
2293
  ] });
1878
2294
  }
1879
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
+ }
2404
+ /**
1880
2405
  * A column header that orders the table: its first click ascending, the
1881
2406
  * next descending. Below the width where rows stack, the sortable headers
1882
2407
  * stay, a row of their own above the keys.
@@ -2015,17 +2540,19 @@ function DraftRow({ draft, existingVersion, disabled, onChange, onRemove, onSave
2015
2540
  disabled,
2016
2541
  onChange: (value) => onChange({
2017
2542
  value,
2018
- companion: void 0
2543
+ companion: void 0,
2544
+ recipe: void 0
2019
2545
  }),
2020
2546
  onEscape: onRemove,
2021
2547
  generate: {
2022
2548
  name: draft.key,
2023
2549
  renamable: true,
2024
2550
  companion: draft.companion,
2025
- onUse: ({ value, name, companion }) => onChange({
2551
+ onUse: ({ value, name, companion, recipe }) => onChange({
2026
2552
  key: name,
2027
2553
  value,
2028
- companion
2554
+ companion,
2555
+ recipe
2029
2556
  })
2030
2557
  }
2031
2558
  }), /* @__PURE__ */ jsx(CompanionNote, {
@@ -2255,7 +2782,17 @@ function VersionHistory({ project, environment, secretKey, currentVersion, canWr
2255
2782
  className: "nowrap",
2256
2783
  children: /* @__PURE__ */ jsx(Timestamp, { iso: version.createdAt })
2257
2784
  }),
2258
- /* @__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
+ })] }),
2259
2796
  /* @__PURE__ */ jsx("td", {
2260
2797
  className: "cell-mono cell-muted nowrap",
2261
2798
  children: version.kek