@coffre/ui 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/dist/chunks/audit-sentence-BhHmvQX_.js +660 -0
  2. package/dist/chunks/audit-sentence-BhHmvQX_.js.map +1 -0
  3. package/dist/chunks/connected-apps-CUOyEZXR.js +146 -0
  4. package/dist/chunks/connected-apps-CUOyEZXR.js.map +1 -0
  5. package/dist/chunks/delete-place-CRX7ntE8.js +206 -0
  6. package/dist/chunks/delete-place-CRX7ntE8.js.map +1 -0
  7. package/dist/chunks/{directory-CSjWWUQ1.js → directory-CxxrnGUL.js} +177 -60
  8. package/dist/chunks/directory-CxxrnGUL.js.map +1 -0
  9. package/dist/chunks/folders-DoBmCwOi.js +207 -0
  10. package/dist/chunks/folders-DoBmCwOi.js.map +1 -0
  11. package/dist/chunks/grants-CXcmhujY.js +669 -0
  12. package/dist/chunks/grants-CXcmhujY.js.map +1 -0
  13. package/dist/chunks/offboarding-6eAduCsM.js +305 -0
  14. package/dist/chunks/offboarding-6eAduCsM.js.map +1 -0
  15. package/dist/chunks/one-time-DXEl9hbg.js +35 -0
  16. package/dist/chunks/one-time-DXEl9hbg.js.map +1 -0
  17. package/dist/chunks/page-DvsgZ2Hd.js +391 -0
  18. package/dist/chunks/page-DvsgZ2Hd.js.map +1 -0
  19. package/dist/chunks/principal-BIN-xwZw.js +42 -0
  20. package/dist/chunks/principal-BIN-xwZw.js.map +1 -0
  21. package/dist/chunks/{principal-page-D_91OA0l.js → principal-page-B9R2zPlp.js} +259 -251
  22. package/dist/chunks/principal-page-B9R2zPlp.js.map +1 -0
  23. package/dist/chunks/project-page-SRCtRe2g.js +17 -0
  24. package/dist/chunks/project-page-SRCtRe2g.js.map +1 -0
  25. package/dist/chunks/{queries-CQ81o4so.js → queries-DVR_i3rA.js} +132 -30
  26. package/dist/chunks/queries-DVR_i3rA.js.map +1 -0
  27. package/dist/chunks/references-B6pLT1uQ.js +343 -0
  28. package/dist/chunks/references-B6pLT1uQ.js.map +1 -0
  29. package/dist/chunks/{row-state-0PsrEzOL.js → row-state-DOPUsjQK.js} +3 -3
  30. package/dist/chunks/{row-state-0PsrEzOL.js.map → row-state-DOPUsjQK.js.map} +1 -1
  31. package/dist/chunks/signin-errors--ykMFuqN.js +57 -0
  32. package/dist/chunks/signin-errors--ykMFuqN.js.map +1 -0
  33. package/dist/chunks/tabs-BmwKfUeK.js +22 -0
  34. package/dist/chunks/tabs-BmwKfUeK.js.map +1 -0
  35. package/dist/chunks/{theme-B2vQolVR.js → theme-DJuz-xLM.js} +3 -3
  36. package/dist/chunks/{theme-B2vQolVR.js.map → theme-DJuz-xLM.js.map} +1 -1
  37. package/dist/chunks/{ui-DixXLQvQ.js → ui-DJje3gST.js} +6 -3
  38. package/dist/chunks/ui-DJje3gST.js.map +1 -0
  39. package/dist/chunks/{use-change-c6CeLRin.js → use-change-CZdI2MJG.js} +75 -21
  40. package/dist/chunks/use-change-CZdI2MJG.js.map +1 -0
  41. package/dist/chunks/{use-shell-jxd7Tzd-.js → use-shell-rNKfGjdj.js} +3 -3
  42. package/dist/chunks/{use-shell-jxd7Tzd-.js.map → use-shell-rNKfGjdj.js.map} +1 -1
  43. package/dist/chunks/validation-D312_NLf.js +87 -0
  44. package/dist/chunks/validation-D312_NLf.js.map +1 -0
  45. package/dist/index.d.ts +385 -31
  46. package/dist/index.js +188 -102
  47. package/dist/index.js.map +1 -1
  48. package/dist/pages/account.d.ts +2 -2
  49. package/dist/pages/account.js +174 -135
  50. package/dist/pages/account.js.map +1 -1
  51. package/dist/pages/approval.d.ts +9 -0
  52. package/dist/pages/approval.js +207 -0
  53. package/dist/pages/approval.js.map +1 -0
  54. package/dist/pages/audit.js +17 -542
  55. package/dist/pages/audit.js.map +1 -1
  56. package/dist/pages/device-login.js +2 -3
  57. package/dist/pages/device-login.js.map +1 -1
  58. package/dist/pages/environment.js +647 -257
  59. package/dist/pages/environment.js.map +1 -1
  60. package/dist/pages/login.js +18 -7
  61. package/dist/pages/login.js.map +1 -1
  62. package/dist/pages/oauth-authorize.d.ts +10 -0
  63. package/dist/pages/oauth-authorize.js +249 -0
  64. package/dist/pages/oauth-authorize.js.map +1 -0
  65. package/dist/pages/project-access.d.ts +6 -0
  66. package/dist/pages/project-access.js +370 -0
  67. package/dist/pages/project-access.js.map +1 -0
  68. package/dist/pages/project-environments.d.ts +4 -0
  69. package/dist/pages/project-environments.js +593 -0
  70. package/dist/pages/project-environments.js.map +1 -0
  71. package/dist/pages/project-settings.d.ts +4 -0
  72. package/dist/pages/project-settings.js +242 -0
  73. package/dist/pages/project-settings.js.map +1 -0
  74. package/dist/pages/project.d.ts +10 -2
  75. package/dist/pages/project.js +57 -934
  76. package/dist/pages/project.js.map +1 -1
  77. package/dist/pages/projects.js +53 -21
  78. package/dist/pages/projects.js.map +1 -1
  79. package/dist/pages/service-account.d.ts +10 -0
  80. package/dist/pages/{token.js → service-account.js} +112 -54
  81. package/dist/pages/service-account.js.map +1 -0
  82. package/dist/pages/service-accounts.d.ts +3 -0
  83. package/dist/pages/service-accounts.js +38 -0
  84. package/dist/pages/service-accounts.js.map +1 -0
  85. package/dist/pages/settings.d.ts +1 -0
  86. package/dist/pages/settings.js +104 -42
  87. package/dist/pages/settings.js.map +1 -1
  88. package/dist/pages/unregistered.js +2 -3
  89. package/dist/pages/unregistered.js.map +1 -1
  90. package/dist/pages/user.d.ts +6 -1
  91. package/dist/pages/user.js +18 -6
  92. package/dist/pages/user.js.map +1 -1
  93. package/dist/pages/users.js +6 -10
  94. package/dist/pages/users.js.map +1 -1
  95. package/package.json +3 -3
  96. package/src/components/actions-log.tsx +117 -0
  97. package/src/components/audit-sentence.tsx +55 -0
  98. package/src/components/command-palette.tsx +4 -4
  99. package/src/components/connected-apps.tsx +138 -0
  100. package/src/components/delete-place.tsx +180 -0
  101. package/src/components/directory.tsx +266 -110
  102. package/src/components/every-project.tsx +287 -0
  103. package/src/components/expiry-field.tsx +42 -0
  104. package/src/components/folders.tsx +219 -0
  105. package/src/components/grants.tsx +11 -4
  106. package/src/components/icons.tsx +2 -0
  107. package/src/components/missing.tsx +110 -0
  108. package/src/components/offboarding.tsx +62 -34
  109. package/src/components/page.tsx +4 -1
  110. package/src/components/principal-page.tsx +154 -108
  111. package/src/components/principal-picker.tsx +5 -5
  112. package/src/components/principal.tsx +4 -4
  113. package/src/components/references.tsx +323 -0
  114. package/src/components/service-tokens.tsx +112 -93
  115. package/src/components/shell.tsx +11 -32
  116. package/src/components/tabs.tsx +18 -0
  117. package/src/components/trusted-workloads.tsx +97 -79
  118. package/src/components/ui.tsx +8 -1
  119. package/src/index.ts +13 -3
  120. package/src/layout.tsx +2 -2
  121. package/src/lib/access-plan.ts +2 -2
  122. package/src/lib/audit-sentences.ts +161 -77
  123. package/src/lib/changes.ts +77 -5
  124. package/src/lib/coffre.ts +3 -2
  125. package/src/lib/one-time.ts +32 -0
  126. package/src/lib/project-access.ts +11 -23
  127. package/src/lib/project-page.ts +14 -0
  128. package/src/lib/queries.ts +126 -32
  129. package/src/lib/search.ts +25 -0
  130. package/src/lib/signin-errors.ts +45 -1
  131. package/src/lib/validation.ts +14 -0
  132. package/src/options.ts +187 -42
  133. package/src/pages/account.tsx +176 -133
  134. package/src/pages/approval.tsx +197 -0
  135. package/src/pages/audit.tsx +9 -61
  136. package/src/pages/environment.tsx +585 -286
  137. package/src/pages/login.tsx +8 -2
  138. package/src/pages/oauth-authorize.tsx +233 -0
  139. package/src/pages/project-access.tsx +219 -0
  140. package/src/pages/project-environments.tsx +582 -0
  141. package/src/pages/project-settings.tsx +259 -0
  142. package/src/pages/project.tsx +52 -879
  143. package/src/pages/projects.tsx +55 -18
  144. package/src/pages/service-account.tsx +50 -0
  145. package/src/pages/{tokens.tsx → service-accounts.tsx} +9 -6
  146. package/src/pages/settings.tsx +62 -8
  147. package/src/pages/user.tsx +16 -4
  148. package/src/pages/users.tsx +2 -2
  149. package/src/parity.ts +160 -0
  150. package/src/register.ts +57 -10
  151. package/src/router.tsx +4 -0
  152. package/src/shared/models.ts +6 -2
  153. package/src/styles/globals.css +536 -31
  154. package/dist/chunks/directory-CSjWWUQ1.js.map +0 -1
  155. package/dist/chunks/grants-saMQagmG.js +0 -160
  156. package/dist/chunks/grants-saMQagmG.js.map +0 -1
  157. package/dist/chunks/icons-D-PfAfnH.js +0 -203
  158. package/dist/chunks/icons-D-PfAfnH.js.map +0 -1
  159. package/dist/chunks/offboarding-C6l30DZR.js +0 -263
  160. package/dist/chunks/offboarding-C6l30DZR.js.map +0 -1
  161. package/dist/chunks/page-C5HcNqf2.js +0 -190
  162. package/dist/chunks/page-C5HcNqf2.js.map +0 -1
  163. package/dist/chunks/principal-page-D_91OA0l.js.map +0 -1
  164. package/dist/chunks/queries-CQ81o4so.js.map +0 -1
  165. package/dist/chunks/signin-errors-BEFlVDbQ.js +0 -30
  166. package/dist/chunks/signin-errors-BEFlVDbQ.js.map +0 -1
  167. package/dist/chunks/ui-DixXLQvQ.js.map +0 -1
  168. package/dist/chunks/use-action-CWsg_YWU.js +0 -49
  169. package/dist/chunks/use-action-CWsg_YWU.js.map +0 -1
  170. package/dist/chunks/use-change-c6CeLRin.js.map +0 -1
  171. package/dist/chunks/validation-BQtqPe2V.js +0 -29
  172. package/dist/chunks/validation-BQtqPe2V.js.map +0 -1
  173. package/dist/pages/token.d.ts +0 -3
  174. package/dist/pages/token.js.map +0 -1
  175. package/dist/pages/tokens.d.ts +0 -3
  176. package/dist/pages/tokens.js +0 -39
  177. package/dist/pages/tokens.js.map +0 -1
  178. package/dist/project-BqIy8gYR.d.ts +0 -5
  179. package/src/lib/instance.ts +0 -13
  180. package/src/pages/token.tsx +0 -34
@@ -0,0 +1,207 @@
1
+ import { a as ErrorLine, c as Notice, l as Spinner, r as CopyButton, u as Timestamp } from "../chunks/ui-DJje3gST.js";
2
+ import { N as Link, X as SlashCircle, c as statusOf, n as ClosedDoor, o as failureMessage, u as useCoffre, v as CheckCircle } from "../chunks/page-DvsgZ2Hd.js";
3
+ import { t as pageRoute } from "../chunks/page-route-Drfw7lmn.js";
4
+ import { useState } from "react";
5
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
6
+ //#region src/pages/approval.tsx
7
+ var Route = pageRoute();
8
+ /**
9
+ * Where an MCP client sends you to confirm a change it asked for: what it
10
+ * would do, read afresh, and Approve, which makes it here and now, as you.
11
+ * The app only hears what became of it. Nothing changes until you press
12
+ * Approve, and a value you type goes to coffre and nowhere else.
13
+ */
14
+ function ApprovalPage() {
15
+ const loaded = Route.useLoaderData();
16
+ const [decided, setDecided] = useState(null);
17
+ if (decided !== null) return /* @__PURE__ */ jsx(Decided, {
18
+ decision: decided,
19
+ reveal: loaded.ok && loaded.approval.kind === "reveal"
20
+ });
21
+ if (!loaded.ok) return /* @__PURE__ */ jsx(ClosedDoor, {
22
+ icon: /* @__PURE__ */ jsx(SlashCircle, { size: 18 }),
23
+ label: "Approve a change",
24
+ title: "This approval can't be shown",
25
+ children: /* @__PURE__ */ jsx("p", { children: loaded.error })
26
+ });
27
+ const view = loaded.approval;
28
+ if (view.status !== "pending") return /* @__PURE__ */ jsx(Settled, { view });
29
+ return /* @__PURE__ */ jsx(Approve, {
30
+ view,
31
+ onDecided: setDecided
32
+ });
33
+ }
34
+ var SETTLED = {
35
+ approved: "You approved this",
36
+ denied: "You denied this",
37
+ cancelled: "The app cancelled this",
38
+ failed: "This change failed",
39
+ expired: "This approval expired"
40
+ };
41
+ function Settled({ view }) {
42
+ const status = view.status;
43
+ return /* @__PURE__ */ jsx(ClosedDoor, {
44
+ icon: status === "approved" ? /* @__PURE__ */ jsx(CheckCircle, { size: 18 }) : /* @__PURE__ */ jsx(SlashCircle, { size: 18 }),
45
+ label: "Approve a change",
46
+ title: SETTLED[status],
47
+ children: /* @__PURE__ */ jsxs("p", { children: [
48
+ view.client.name,
49
+ " asked to ",
50
+ view.summary,
51
+ ".",
52
+ " ",
53
+ view.outcome?.text ?? (status === "expired" ? "Nothing changed. The app can ask again." : "Nothing changed.")
54
+ ] })
55
+ });
56
+ }
57
+ function Decided({ decision, reveal }) {
58
+ const done = decision.status === "approved";
59
+ return /* @__PURE__ */ jsxs(ClosedDoor, {
60
+ icon: done ? /* @__PURE__ */ jsx(CheckCircle, { size: 18 }) : /* @__PURE__ */ jsx(SlashCircle, { size: 18 }),
61
+ label: reveal ? "Show a value" : "Approve a change",
62
+ title: done ? reveal ? "The value" : "Done" : decision.status === "denied" ? "Denied" : reveal ? "It could not be shown" : "The change failed",
63
+ children: [
64
+ !(reveal && done) && /* @__PURE__ */ jsx("p", { children: decision.outcome.text }),
65
+ decision.shown.length > 0 && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Notice, {
66
+ tone: "warn",
67
+ children: reveal ? "Shown here only, and logged as your reveal: the app does not get it." : "Shown once, here only: copy it now. The app does not get it."
68
+ }), /* @__PURE__ */ jsx("dl", {
69
+ className: "facts device-facts",
70
+ children: decision.shown.map((line) => /* @__PURE__ */ jsxs("div", {
71
+ className: "fact",
72
+ children: [/* @__PURE__ */ jsx("dt", { children: line.label }), /* @__PURE__ */ jsxs("dd", {
73
+ className: "cell-account",
74
+ children: [/* @__PURE__ */ jsx("span", {
75
+ className: "mono approval-shown",
76
+ children: line.value
77
+ }), /* @__PURE__ */ jsx(CopyButton, {
78
+ value: line.value,
79
+ label: `Copy ${line.label.toLowerCase()}`
80
+ })]
81
+ })]
82
+ }, line.label))
83
+ })] }),
84
+ /* @__PURE__ */ jsx("p", { children: "You can close this tab: the app hears the outcome when it asks." })
85
+ ]
86
+ });
87
+ }
88
+ function Approve({ view, onDecided }) {
89
+ const coffre = useCoffre();
90
+ const [value, setValue] = useState("");
91
+ const [pending, setPending] = useState(null);
92
+ const [error, setError] = useState(null);
93
+ const { client } = view;
94
+ const asksValue = view.asks?.value ?? null;
95
+ const reveal = view.kind === "reveal";
96
+ async function decide(approve) {
97
+ setPending(approve ? "approve" : "deny");
98
+ try {
99
+ onDecided(await coffre.approvals.decide(view.id, {
100
+ approve,
101
+ digest: view.digest,
102
+ ...approve && asksValue !== null ? { value } : {}
103
+ }));
104
+ } catch (error) {
105
+ setError(statusOf(error) === void 0 ? "The answer could not be sent. Nothing changed." : failureMessage(error));
106
+ setPending(null);
107
+ }
108
+ }
109
+ return /* @__PURE__ */ jsxs("section", {
110
+ className: "card signin",
111
+ "aria-labelledby": "approval-title",
112
+ children: [
113
+ /* @__PURE__ */ jsxs("div", {
114
+ className: "signin-head",
115
+ children: [/* @__PURE__ */ jsx("h1", {
116
+ className: "signin-title",
117
+ id: "approval-title",
118
+ children: reveal ? "Show this value?" : "Approve this change?"
119
+ }), /* @__PURE__ */ jsxs("p", {
120
+ className: "signin-lede",
121
+ children: [
122
+ client.name,
123
+ " asks to ",
124
+ /* @__PURE__ */ jsx("strong", { children: view.summary }),
125
+ ".",
126
+ " ",
127
+ reveal ? "Reveal shows it here, to you, logged as your reveal; it is never sent to the app." : "Read what it does: nothing changes until you approve, and then coffre makes it, as you."
128
+ ]
129
+ })]
130
+ }),
131
+ /* @__PURE__ */ jsxs("div", {
132
+ className: "consent-client",
133
+ children: [/* @__PURE__ */ jsx(Link, { size: 16 }), /* @__PURE__ */ jsxs("span", {
134
+ className: "cell-stack",
135
+ children: [client.host !== null ? /* @__PURE__ */ jsx("span", {
136
+ className: "consent-host mono",
137
+ children: client.host
138
+ }) : /* @__PURE__ */ jsx("span", {
139
+ className: "consent-host",
140
+ children: client.name
141
+ }), /* @__PURE__ */ jsxs("span", { children: [client.host !== null && /* @__PURE__ */ jsxs(Fragment$1, { children: [client.name, " "] }), client.registration === "dcr" && /* @__PURE__ */ jsx("span", {
142
+ className: "tag tag-amber",
143
+ children: "Unverified"
144
+ })] })]
145
+ })]
146
+ }),
147
+ /* @__PURE__ */ jsxs("dl", {
148
+ className: "facts device-facts",
149
+ children: [view.details.map((line) => /* @__PURE__ */ jsxs("div", {
150
+ className: "fact",
151
+ children: [/* @__PURE__ */ jsx("dt", { children: line.label }), /* @__PURE__ */ jsx("dd", {
152
+ className: line.kind === "mono" ? "mono" : void 0,
153
+ children: line.kind === "time" ? /* @__PURE__ */ jsx(Timestamp, { iso: line.value }) : line.value
154
+ })]
155
+ }, line.label)), /* @__PURE__ */ jsxs("div", {
156
+ className: "fact",
157
+ children: [/* @__PURE__ */ jsx("dt", { children: "Expires (UTC)" }), /* @__PURE__ */ jsx("dd", { children: /* @__PURE__ */ jsx(Timestamp, { iso: view.expiresAt }) })]
158
+ })]
159
+ }),
160
+ asksValue !== null && /* @__PURE__ */ jsxs("label", {
161
+ className: "field approval-field",
162
+ children: [
163
+ /* @__PURE__ */ jsx("span", {
164
+ className: "label",
165
+ children: asksValue.label
166
+ }),
167
+ /* @__PURE__ */ jsx("textarea", {
168
+ className: "input mono approval-value",
169
+ name: "value",
170
+ rows: 3,
171
+ autoComplete: "off",
172
+ spellCheck: false,
173
+ value,
174
+ disabled: pending !== null,
175
+ onChange: (event) => setValue(event.target.value)
176
+ }),
177
+ /* @__PURE__ */ jsx("small", { children: asksValue.note })
178
+ ]
179
+ }),
180
+ /* @__PURE__ */ jsxs("div", {
181
+ className: "consent-notices",
182
+ children: [client.registration === "dcr" && /* @__PURE__ */ jsx(Notice, {
183
+ tone: "warn",
184
+ children: "This app registered itself: its name is its own claim. Approve only what you asked it to do."
185
+ }), /* @__PURE__ */ jsx(ErrorLine, { error })]
186
+ }),
187
+ /* @__PURE__ */ jsxs("div", {
188
+ className: "device-actions",
189
+ children: [/* @__PURE__ */ jsxs("button", {
190
+ className: "btn",
191
+ disabled: pending !== null,
192
+ onClick: () => void decide(false),
193
+ children: [pending === "deny" && /* @__PURE__ */ jsx(Spinner, {}), "Deny"]
194
+ }), /* @__PURE__ */ jsxs("button", {
195
+ className: "btn btn-primary",
196
+ disabled: pending !== null || asksValue !== null && value === "",
197
+ onClick: () => void decide(true),
198
+ children: [pending === "approve" && /* @__PURE__ */ jsx(Spinner, {}), reveal ? "Reveal" : "Approve"]
199
+ })]
200
+ })
201
+ ]
202
+ });
203
+ }
204
+ //#endregion
205
+ export { ApprovalPage };
206
+
207
+ //# sourceMappingURL=approval.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval.js","names":[],"sources":["../../src/pages/approval.tsx"],"sourcesContent":["import { useState } from 'react';\nimport type { ApprovalView, Decision } from '@coffre/client';\n\nimport { failureMessage, statusOf, useCoffre } from '../lib/coffre';\nimport { ClosedDoor } from '../components/page';\nimport { CopyButton, ErrorLine, Notice, Spinner, Timestamp } from '../components/ui';\nimport { CheckCircle, Link as LinkIcon, SlashCircle } from '../components/icons';\nimport { pageRoute } from '../lib/page-route';\nimport type { approval } from '../options';\n\nconst Route = pageRoute<typeof approval>();\n\n/**\n * Where an MCP client sends you to confirm a change it asked for: what it\n * would do, read afresh, and Approve, which makes it here and now, as you.\n * The app only hears what became of it. Nothing changes until you press\n * Approve, and a value you type goes to coffre and nowhere else.\n */\nexport function ApprovalPage() {\n const loaded = Route.useLoaderData();\n const [decided, setDecided] = useState<Decision | null>(null);\n\n if (decided !== null) return <Decided decision={decided} reveal={loaded.ok && loaded.approval.kind === 'reveal'} />;\n if (!loaded.ok) {\n return (\n <ClosedDoor icon={<SlashCircle size={18} />} label=\"Approve a change\" title=\"This approval can't be shown\">\n <p>{loaded.error}</p>\n </ClosedDoor>\n );\n }\n const view = loaded.approval;\n if (view.status !== 'pending') return <Settled view={view} />;\n return <Approve view={view} onDecided={setDecided} />;\n}\n\nconst SETTLED: Record<Exclude<ApprovalView['status'], 'pending'>, string> = {\n approved: 'You approved this',\n denied: 'You denied this',\n cancelled: 'The app cancelled this',\n failed: 'This change failed',\n expired: 'This approval expired',\n};\n\nfunction Settled({ view }: { view: ApprovalView }) {\n const status = view.status as keyof typeof SETTLED;\n return (\n <ClosedDoor\n icon={status === 'approved' ? <CheckCircle size={18} /> : <SlashCircle size={18} />}\n label=\"Approve a change\"\n title={SETTLED[status]}\n >\n <p>\n {view.client.name} asked to {view.summary}.{' '}\n {view.outcome?.text ?? (status === 'expired' ? 'Nothing changed. The app can ask again.' : 'Nothing changed.')}\n </p>\n </ClosedDoor>\n );\n}\n\nfunction Decided({ decision, reveal }: { decision: Decision; reveal: boolean }) {\n const done = decision.status === 'approved';\n return (\n <ClosedDoor\n icon={done ? <CheckCircle size={18} /> : <SlashCircle size={18} />}\n label={reveal ? 'Show a value' : 'Approve a change'}\n title={done ? (reveal ? 'The value' : 'Done') : decision.status === 'denied' ? 'Denied' : reveal ? 'It could not be shown' : 'The change failed'}\n >\n {!(reveal && done) && <p>{decision.outcome.text}</p>}\n {decision.shown.length > 0 && (\n <>\n <Notice tone=\"warn\">{reveal ? 'Shown here only, and logged as your reveal: the app does not get it.' : 'Shown once, here only: copy it now. The app does not get it.'}</Notice>\n <dl className=\"facts device-facts\">\n {decision.shown.map((line) => (\n <div className=\"fact\" key={line.label}>\n <dt>{line.label}</dt>\n <dd className=\"cell-account\">\n <span className=\"mono approval-shown\">{line.value}</span>\n <CopyButton value={line.value} label={`Copy ${line.label.toLowerCase()}`} />\n </dd>\n </div>\n ))}\n </dl>\n </>\n )}\n <p>You can close this tab: the app hears the outcome when it asks.</p>\n </ClosedDoor>\n );\n}\n\nfunction Approve({ view, onDecided }: { view: ApprovalView; onDecided: (decision: Decision) => void }) {\n const coffre = useCoffre();\n const [value, setValue] = useState('');\n const [pending, setPending] = useState<'approve' | 'deny' | null>(null);\n const [error, setError] = useState<string | null>(null);\n const { client } = view;\n const asksValue = view.asks?.value ?? null;\n const reveal = view.kind === 'reveal';\n\n async function decide(approve: boolean) {\n setPending(approve ? 'approve' : 'deny');\n try {\n onDecided(\n await coffre.approvals.decide(view.id, {\n approve,\n digest: view.digest,\n ...(approve && asksValue !== null ? { value } : {}),\n }),\n );\n } catch (error) {\n setError(statusOf(error) === undefined ? 'The answer could not be sent. Nothing changed.' : failureMessage(error));\n setPending(null);\n }\n }\n\n return (\n <section className=\"card signin\" aria-labelledby=\"approval-title\">\n <div className=\"signin-head\">\n <h1 className=\"signin-title\" id=\"approval-title\">\n {reveal ? 'Show this value?' : 'Approve this change?'}\n </h1>\n <p className=\"signin-lede\">\n {client.name} asks to <strong>{view.summary}</strong>.{' '}\n {reveal\n ? 'Reveal shows it here, to you, logged as your reveal; it is never sent to the app.'\n : 'Read what it does: nothing changes until you approve, and then coffre makes it, as you.'}\n </p>\n </div>\n\n <div className=\"consent-client\">\n <LinkIcon size={16} />\n <span className=\"cell-stack\">\n {client.host !== null ? <span className=\"consent-host mono\">{client.host}</span> : <span className=\"consent-host\">{client.name}</span>}\n <span>\n {client.host !== null && <>{client.name} </>}\n {client.registration === 'dcr' && <span className=\"tag tag-amber\">Unverified</span>}\n </span>\n </span>\n </div>\n\n <dl className=\"facts device-facts\">\n {view.details.map((line) => (\n <div className=\"fact\" key={line.label}>\n <dt>{line.label}</dt>\n <dd className={line.kind === 'mono' ? 'mono' : undefined}>\n {line.kind === 'time' ? <Timestamp iso={line.value} /> : line.value}\n </dd>\n </div>\n ))}\n <div className=\"fact\">\n <dt>Expires (UTC)</dt>\n <dd>\n <Timestamp iso={view.expiresAt} />\n </dd>\n </div>\n </dl>\n\n {asksValue !== null && (\n <label className=\"field approval-field\">\n <span className=\"label\">{asksValue.label}</span>\n <textarea\n className=\"input mono approval-value\"\n name=\"value\"\n rows={3}\n autoComplete=\"off\"\n spellCheck={false}\n value={value}\n disabled={pending !== null}\n onChange={(event) => setValue(event.target.value)}\n />\n <small>{asksValue.note}</small>\n </label>\n )}\n\n <div className=\"consent-notices\">\n {client.registration === 'dcr' && (\n <Notice tone=\"warn\">This app registered itself: its name is its own claim. Approve only what you asked it to do.</Notice>\n )}\n <ErrorLine error={error} />\n </div>\n\n <div className=\"device-actions\">\n <button className=\"btn\" disabled={pending !== null} onClick={() => void decide(false)}>\n {pending === 'deny' && <Spinner />}\n Deny\n </button>\n <button\n className=\"btn btn-primary\"\n disabled={pending !== null || (asksValue !== null && value === '')}\n onClick={() => void decide(true)}\n >\n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