@coffre/ui 0.0.0-stage → 0.1.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 (168) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +8 -2
  3. package/dist/client/.assetsignore +2 -0
  4. package/dist/client/_coffre/assets/account-C3Zo1l5A.js +1 -0
  5. package/dist/client/_coffre/assets/account-C4bNbeO7.js +2 -0
  6. package/dist/client/_coffre/assets/affordances-DiuJIiR2.js +1 -0
  7. package/dist/client/_coffre/assets/audit-1xLyuxGz.js +2 -0
  8. package/dist/client/_coffre/assets/audit-Dab2GuRj.js +1 -0
  9. package/dist/client/_coffre/assets/auth.device-BfCfeBWe.js +2 -0
  10. package/dist/client/_coffre/assets/auth.device-D2pCLF-X.js +1 -0
  11. package/dist/client/_coffre/assets/coffre-C7qL3HGR.js +1 -0
  12. package/dist/client/_coffre/assets/directory-C2Ou4SQv.js +1 -0
  13. package/dist/client/_coffre/assets/globals-Dgq4Jy0x.css +1 -0
  14. package/dist/client/_coffre/assets/grants-fqTtJ-aW.js +1 -0
  15. package/dist/client/_coffre/assets/index-BpGwbjmM.js +12 -0
  16. package/dist/client/_coffre/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
  17. package/dist/client/_coffre/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
  18. package/dist/client/_coffre/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
  19. package/dist/client/_coffre/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
  20. package/dist/client/_coffre/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
  21. package/dist/client/_coffre/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
  22. package/dist/client/_coffre/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
  23. package/dist/client/_coffre/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
  24. package/dist/client/_coffre/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  25. package/dist/client/_coffre/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  26. package/dist/client/_coffre/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  27. package/dist/client/_coffre/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  28. package/dist/client/_coffre/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  29. package/dist/client/_coffre/assets/login-CR9CBXlw.js +2 -0
  30. package/dist/client/_coffre/assets/login-DZizFxa4.js +1 -0
  31. package/dist/client/_coffre/assets/offboarding-DOLJQcXU.js +1 -0
  32. package/dist/client/_coffre/assets/page-BxW2MwaX.js +1 -0
  33. package/dist/client/_coffre/assets/preload-helper-BHuP8_FL.js +46 -0
  34. package/dist/client/_coffre/assets/principal-page-xnBZVURr.js +1 -0
  35. package/dist/client/_coffre/assets/project-environments-CfIH5kFM.js +1 -0
  36. package/dist/client/_coffre/assets/projects._project._environment-CrWjQmIA.js +2 -0
  37. package/dist/client/_coffre/assets/projects._project._environment-CwRVG9Ne.js +3 -0
  38. package/dist/client/_coffre/assets/projects._project.index-CCDEuE-z.js +2 -0
  39. package/dist/client/_coffre/assets/projects._project.index-DCJsmnD7.js +1 -0
  40. package/dist/client/_coffre/assets/projects.index-B8eV8JIn.js +1 -0
  41. package/dist/client/_coffre/assets/projects.index-BNEC7Oz8.js +2 -0
  42. package/dist/client/_coffre/assets/settings-2BPsenNM.js +2 -0
  43. package/dist/client/_coffre/assets/settings-BrS0-wEt.js +1 -0
  44. package/dist/client/_coffre/assets/signin-errors-CroZWZgm.js +1 -0
  45. package/dist/client/_coffre/assets/tokens._token-B3-YwuKp.js +2 -0
  46. package/dist/client/_coffre/assets/tokens._token-D_hsbHx6.js +1 -0
  47. package/dist/client/_coffre/assets/tokens.index-BdKE2Jv8.js +2 -0
  48. package/dist/client/_coffre/assets/tokens.index-XvA4XRxh.js +1 -0
  49. package/dist/client/_coffre/assets/unregistered-CTRMtBIy.js +1 -0
  50. package/dist/client/_coffre/assets/use-action-DgAf-tiX.js +1 -0
  51. package/dist/client/_coffre/assets/users._user-BFPXcJ4y.js +2 -0
  52. package/dist/client/_coffre/assets/users._user-DEtMeSoh.js +1 -0
  53. package/dist/client/_coffre/assets/users.index-B03beUHq.js +1 -0
  54. package/dist/client/_coffre/assets/users.index-D8hwzM6P.js +2 -0
  55. package/dist/client/_coffre/assets/validation-9Cl_XS-l.js +1 -0
  56. package/dist/index.d.ts +19 -0
  57. package/dist/server/.vite/manifest.json +572 -0
  58. package/dist/server/_coffre/assets/_tanstack-start-manifest_v-B6CZDfrB.js +133 -0
  59. package/dist/server/_coffre/assets/account-B71_b5xc.js +296 -0
  60. package/dist/server/_coffre/assets/account-BoO6ZqMc.js +176 -0
  61. package/dist/server/_coffre/assets/affordances-BNaXjMOb.js +46 -0
  62. package/dist/server/_coffre/assets/async-local-storage-C0cwgkEr.js +3107 -0
  63. package/dist/server/_coffre/assets/audit-CwRFnSAY.js +74 -0
  64. package/dist/server/_coffre/assets/audit-t1sYjtrf.js +964 -0
  65. package/dist/server/_coffre/assets/auth.device-1IcJ475s.js +208 -0
  66. package/dist/server/_coffre/assets/auth.device-CJwZYYtn.js +29 -0
  67. package/dist/server/_coffre/assets/coffre-1hxT2E_U.js +278 -0
  68. package/dist/server/_coffre/assets/directory-wm_JQUfk.js +396 -0
  69. package/dist/server/_coffre/assets/empty-plugin-adapters-Cq4--YW-.js +5 -0
  70. package/dist/server/_coffre/assets/globals-Dgq4Jy0x.css +1 -0
  71. package/dist/server/_coffre/assets/grants-BmhEY1vz.js +243 -0
  72. package/dist/server/_coffre/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
  73. package/dist/server/_coffre/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
  74. package/dist/server/_coffre/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
  75. package/dist/server/_coffre/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
  76. package/dist/server/_coffre/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
  77. package/dist/server/_coffre/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
  78. package/dist/server/_coffre/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
  79. package/dist/server/_coffre/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
  80. package/dist/server/_coffre/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  81. package/dist/server/_coffre/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  82. package/dist/server/_coffre/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  83. package/dist/server/_coffre/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  84. package/dist/server/_coffre/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  85. package/dist/server/_coffre/assets/login-B5O5LPXV.js +100 -0
  86. package/dist/server/_coffre/assets/login-Bvc4gp0X.js +22 -0
  87. package/dist/server/_coffre/assets/offboarding-CvSilnSm.js +330 -0
  88. package/dist/server/_coffre/assets/page-BjXk0Ehu.js +2003 -0
  89. package/dist/server/_coffre/assets/principal-page-DkwNGzM2.js +617 -0
  90. package/dist/server/_coffre/assets/project-environments-lEzFHUt4.js +9 -0
  91. package/dist/server/_coffre/assets/projects._project._environment-7grhqlgq.js +2227 -0
  92. package/dist/server/_coffre/assets/projects._project._environment-ByEf6pmz.js +55 -0
  93. package/dist/server/_coffre/assets/projects._project.index-B1bjowP-.js +932 -0
  94. package/dist/server/_coffre/assets/projects._project.index-DU8wtoHD.js +22 -0
  95. package/dist/server/_coffre/assets/projects.index-B0DoHbCz.js +280 -0
  96. package/dist/server/_coffre/assets/projects.index-kMDA6pMy.js +54 -0
  97. package/dist/server/_coffre/assets/react-dom-qCTiwGGR.js +1352 -0
  98. package/dist/server/_coffre/assets/router-ChU_CwCX.js +2028 -0
  99. package/dist/server/_coffre/assets/settings-CM9-h7in.js +18 -0
  100. package/dist/server/_coffre/assets/settings-Cg5qOGij.js +60 -0
  101. package/dist/server/_coffre/assets/signin-errors-BEFlVDbQ.js +28 -0
  102. package/dist/server/_coffre/assets/start-DR3rN0St.js +4 -0
  103. package/dist/server/_coffre/assets/tokens._token-CCpaPMAk.js +268 -0
  104. package/dist/server/_coffre/assets/tokens._token-Di4OZdAA.js +18 -0
  105. package/dist/server/_coffre/assets/tokens.index-Do3OHR31.js +34 -0
  106. package/dist/server/_coffre/assets/tokens.index-tDKq4AFh.js +10 -0
  107. package/dist/server/_coffre/assets/ui-BNzhIAQP.js +15710 -0
  108. package/dist/server/_coffre/assets/unregistered-BqaWYFJK.js +51 -0
  109. package/dist/server/_coffre/assets/use-action-BkJXC5JM.js +953 -0
  110. package/dist/server/_coffre/assets/useStore-DWGPqzXR.js +892 -0
  111. package/dist/server/_coffre/assets/users._user-BenYva93.js +15 -0
  112. package/dist/server/_coffre/assets/users._user-Cp039Va-.js +10 -0
  113. package/dist/server/_coffre/assets/users.index-BrzG1Ecq.js +10 -0
  114. package/dist/server/_coffre/assets/users.index-DQ_45DQl.js +34 -0
  115. package/dist/server/_coffre/assets/validation-BQtqPe2V.js +27 -0
  116. package/dist/server/index.js +13910 -0
  117. package/package.json +58 -3
  118. package/src/components/affordances.ts +80 -0
  119. package/src/components/agentation.tsx +34 -0
  120. package/src/components/command-palette.tsx +271 -0
  121. package/src/components/directory.tsx +448 -0
  122. package/src/components/grants.tsx +204 -0
  123. package/src/components/icons.tsx +283 -0
  124. package/src/components/offboarding.tsx +286 -0
  125. package/src/components/page.tsx +128 -0
  126. package/src/components/principal-page.tsx +549 -0
  127. package/src/components/principal-picker.tsx +168 -0
  128. package/src/components/principal.tsx +53 -0
  129. package/src/components/route-states.tsx +60 -0
  130. package/src/components/service-tokens.tsx +212 -0
  131. package/src/components/shell.tsx +641 -0
  132. package/src/components/syncs.tsx +581 -0
  133. package/src/components/theme.tsx +141 -0
  134. package/src/components/tile.tsx +22 -0
  135. package/src/components/ui.tsx +440 -0
  136. package/src/entry.ts +19 -0
  137. package/src/lib/access-plan.ts +201 -0
  138. package/src/lib/audit-sentences.ts +468 -0
  139. package/src/lib/capabilities.ts +45 -0
  140. package/src/lib/coffre.ts +57 -0
  141. package/src/lib/project-access.ts +95 -0
  142. package/src/lib/project-environments.ts +23 -0
  143. package/src/lib/reveal.ts +21 -0
  144. package/src/lib/secret-edit-batch.ts +181 -0
  145. package/src/lib/signin-errors.ts +33 -0
  146. package/src/lib/use-action.ts +50 -0
  147. package/src/lib/validation.ts +27 -0
  148. package/src/routeTree.gen.ts +367 -0
  149. package/src/router.tsx +84 -0
  150. package/src/routes/__root.tsx +192 -0
  151. package/src/routes/access.tsx +11 -0
  152. package/src/routes/account.tsx +359 -0
  153. package/src/routes/audit.tsx +545 -0
  154. package/src/routes/auth.device.tsx +200 -0
  155. package/src/routes/index.tsx +15 -0
  156. package/src/routes/login.tsx +129 -0
  157. package/src/routes/projects.$project.$environment.tsx +1659 -0
  158. package/src/routes/projects.$project.index.tsx +917 -0
  159. package/src/routes/projects.index.tsx +353 -0
  160. package/src/routes/settings.tsx +72 -0
  161. package/src/routes/tokens.$token.tsx +35 -0
  162. package/src/routes/tokens.index.tsx +37 -0
  163. package/src/routes/unregistered.tsx +59 -0
  164. package/src/routes/users.$user.tsx +13 -0
  165. package/src/routes/users.index.tsx +37 -0
  166. package/src/shared/models.ts +55 -0
  167. package/src/styles/globals.css +4118 -0
  168. package/src/types.ts +21 -0
@@ -0,0 +1,18 @@
1
+ import { C as lazyRouteComponent, w as createFileRoute } from "./ui-BNzhIAQP.js";
2
+ import { o as loadDirectory } from "./directory-wm_JQUfk.js";
3
+ //#region src/routes/settings.tsx
4
+ var $$splitComponentImporter = () => import("./settings-Cg5qOGij.js");
5
+ /** The workspace's settings. Your own are under Account, at the sidebar's foot. */
6
+ var Route = createFileRoute("/settings")({
7
+ loader: async ({ context: { client }, parentMatchPromise }) => {
8
+ const root = (await parentMatchPromise).loaderData;
9
+ const canManage = root?.capabilities.canManageGrants ?? false;
10
+ return {
11
+ auth: root?.auth,
12
+ directory: canManage ? await loadDirectory(client, true) : null
13
+ };
14
+ },
15
+ component: lazyRouteComponent($$splitComponentImporter, "component")
16
+ });
17
+ //#endregion
18
+ export { Route as t };
@@ -0,0 +1,60 @@
1
+ import { o as require_jsx_runtime } from "./useStore-DWGPqzXR.js";
2
+ import { E as Link } from "./ui-BNzhIAQP.js";
3
+ import { i as PageHeader, r as Fact, t as Card } from "./page-BjXk0Ehu.js";
4
+ import { t as Route } from "./settings-CM9-h7in.js";
5
+ //#region src/routes/settings.tsx?tsr-split=component
6
+ /** The workspace's settings. Your own are under Account, at the sidebar's foot. */
7
+ var import_jsx_runtime = require_jsx_runtime();
8
+ var listFormat = new Intl.ListFormat("en", { type: "disjunction" });
9
+ function SettingsPage() {
10
+ const { auth, directory } = Route.useLoaderData();
11
+ const providers = auth?.signin?.providers.map((provider) => provider.label) ?? [];
12
+ const principals = directory?.ok === true ? directory.principals : null;
13
+ const rootAdmins = principals?.filter((entry) => entry.isRootAdmin) ?? [];
14
+ const users = principals?.filter((entry) => entry.principalType === "user").length ?? 0;
15
+ const tokens = principals?.filter((entry) => entry.principalType === "service").length ?? 0;
16
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageHeader, { title: "Settings" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card, {
17
+ labelledBy: "instance",
18
+ title: "Instance",
19
+ description: "Set in the deployment's configuration, so shown here rather than edited.",
20
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("dl", {
21
+ className: "facts",
22
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fact, {
23
+ label: "Sign-in",
24
+ children: auth?.signin ? `coffre’s own sign-in, with ${listFormat.format(providers)}. Only invited members get in.` : "Cloudflare Access. coffre has no sign-in of its own; every request carries an Access assertion that is verified at the origin."
25
+ }), principals !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fact, {
26
+ label: "Root admins",
27
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
28
+ className: "fact-list",
29
+ children: rootAdmins.map((admin) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
30
+ className: "mono",
31
+ children: admin.principalId
32
+ }, admin.principalId))
33
+ })
34
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fact, {
35
+ label: "Directory",
36
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
37
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Link, {
38
+ to: "/users",
39
+ children: [
40
+ users,
41
+ " user",
42
+ users === 1 ? "" : "s"
43
+ ]
44
+ }),
45
+ " · ",
46
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Link, {
47
+ to: "/tokens",
48
+ children: [
49
+ tokens,
50
+ " token",
51
+ tokens === 1 ? "" : "s"
52
+ ]
53
+ })
54
+ ] })
55
+ })] })]
56
+ })
57
+ })] });
58
+ }
59
+ //#endregion
60
+ export { SettingsPage as component };
@@ -0,0 +1,28 @@
1
+ //#region src/lib/signin-errors.ts
2
+ /**
3
+ * What went wrong with a sign-in, in words. The callback redirects with a
4
+ * code rather than a sentence so the URL stays short and nothing the provider
5
+ * said is reflected into the page.
6
+ */
7
+ var MESSAGES = {
8
+ provider_denied: "The sign-in was cancelled, or the provider refused it.",
9
+ state_mismatch: "This sign-in expired or was started in another tab. Start again from this page.",
10
+ invalid_response: "The provider answered in a way coffre could not verify. Try again; if it keeps happening, tell whoever runs coffre.",
11
+ provider_unavailable: "The provider could not be reached. Try again in a moment.",
12
+ no_verified_email: "That account has no verified email address, so coffre cannot match it to an invitation.",
13
+ wrong_domain: "That account is outside the organization this instance belongs to.",
14
+ not_in_organization: "That GitHub account is not a member of the required organization. If it is, grant coffre access to the organization when GitHub asks.",
15
+ not_registered: "Nobody has invited that account’s email address. Ask an owner to add you under Users, then sign in again.",
16
+ deactivated: "Your access to this coffre was removed. Ask an owner if that is a mistake.",
17
+ account_mismatch: "Your email already signs in with a different account. Use that one, then link this account from your account page.",
18
+ already_linked: "That account is already linked to someone else.",
19
+ tampered: "Your access record failed coffre’s integrity check: it was changed outside coffre. An owner must remove you and add you again.",
20
+ unknown_provider: "That sign-in option is not configured here.",
21
+ link_session: "Your session changed while linking. Sign in again, then retry."
22
+ };
23
+ function signinErrorMessage(code) {
24
+ if (code === void 0) return null;
25
+ return MESSAGES[code] ?? "The sign-in did not complete. Try again.";
26
+ }
27
+ //#endregion
28
+ export { signinErrorMessage as t };
@@ -0,0 +1,4 @@
1
+ //#region ../../node_modules/.pnpm/@tanstack+react-start@1.168.32_esbuild@0.28.1_react-dom@19.2.7_react@19.2.7__react@19.2_25463611d577cfc3cbee287b278aee95/node_modules/@tanstack/react-start/dist/plugin/default-entry/start.ts
2
+ var startInstance = void 0;
3
+ //#endregion
4
+ export { startInstance };
@@ -0,0 +1,268 @@
1
+ import { C as require_react, E as __toESM, o as require_jsx_runtime } from "./useStore-DWGPqzXR.js";
2
+ import { a as ErrorLine, c as Spinner, i as EmptyState, l as Timestamp, o as Modal, r as CopyButton, s as Notice, t as ConfirmButton } from "./ui-BNzhIAQP.js";
3
+ import { C as Key, R as Plus, et as X, t as Card } from "./page-BjXk0Ehu.js";
4
+ import { r as memberRef, s as useCoffre } from "./coffre-1hxT2E_U.js";
5
+ import { r as toast, t as useAction } from "./use-action-BkJXC5JM.js";
6
+ import { t as PrincipalPage } from "./principal-page-DkwNGzM2.js";
7
+ import { t as Route } from "./tokens._token-Di4OZdAA.js";
8
+ //#region src/components/service-tokens.tsx
9
+ var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
10
+ var import_jsx_runtime = require_jsx_runtime();
11
+ var LIFETIMES = [
12
+ 30,
13
+ 90,
14
+ 180,
15
+ 365
16
+ ];
17
+ /**
18
+ * The bearer tokens a service presents to the API. A value exists in exactly
19
+ * one place, this dialog, for as long as it stays open: coffre keeps a hash.
20
+ */
21
+ function ServiceTokens({ serviceId, tokens }) {
22
+ const coffre = useCoffre();
23
+ const { pending, error, run } = useAction();
24
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Card, {
25
+ labelledBy: "service-tokens",
26
+ title: "Credentials",
27
+ description: "Bearer tokens this service presents to the API. Each is shown once, when it is issued; coffre keeps only a hash.",
28
+ actions: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IssueToken, { serviceId }),
29
+ children: [error !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
30
+ className: "card-body",
31
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorLine, { error })
32
+ }), tokens.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmptyState, {
33
+ title: "No live credentials",
34
+ children: "Nothing can act as this service until a token is issued."
35
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
36
+ className: "dt-wrap",
37
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("table", {
38
+ className: "dt",
39
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
40
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "Token" }),
41
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {
42
+ className: "col-shrink",
43
+ children: "Issued (UTC)"
44
+ }),
45
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {
46
+ className: "col-shrink",
47
+ children: "Last used"
48
+ }),
49
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {
50
+ className: "col-shrink",
51
+ children: "Expires"
52
+ }),
53
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {
54
+ className: "col-actions",
55
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
56
+ className: "visually-hidden",
57
+ children: "Actions"
58
+ })
59
+ })
60
+ ] }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { children: tokens.map((token) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
61
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
62
+ className: "cell-account",
63
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Key, { size: 15 }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
64
+ className: "cell-stack",
65
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: token.label ?? "Unlabelled" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", {
66
+ className: "mono",
67
+ children: token.hint
68
+ })]
69
+ })]
70
+ }) }),
71
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
72
+ className: "nowrap",
73
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
74
+ className: "cell-stack",
75
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Timestamp, { iso: token.createdAt }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("small", { children: ["by ", token.createdBy] })]
76
+ })
77
+ }),
78
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
79
+ className: "nowrap cell-muted",
80
+ children: token.lastUsedAt === null ? "Never" : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
81
+ className: "cell-stack",
82
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Timestamp, {
83
+ iso: token.lastUsedAt,
84
+ display: "relative"
85
+ }), token.lastUsedIp !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", {
86
+ className: "mono",
87
+ children: token.lastUsedIp
88
+ })]
89
+ })
90
+ }),
91
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
92
+ className: "nowrap cell-muted",
93
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Timestamp, {
94
+ iso: token.expiresAt,
95
+ display: "relative"
96
+ })
97
+ }),
98
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
99
+ className: "col-actions",
100
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConfirmButton, {
101
+ trigger: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
102
+ className: "act",
103
+ disabled: pending,
104
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(X, { size: 13 }), "Revoke"]
105
+ }),
106
+ title: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
107
+ "Revoke ",
108
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
109
+ className: "mono",
110
+ children: token.hint
111
+ }),
112
+ "?"
113
+ ] }),
114
+ body: "Whatever uses it is refused from its next request. Issue a new token first if the service should keep working.",
115
+ confirmLabel: "Revoke token",
116
+ onConfirm: () => run(() => coffre.tokens.revoke(memberRef("service", serviceId), token.id), () => toast.success("Token revoked"))
117
+ })
118
+ })
119
+ ] }, token.id)) })]
120
+ })
121
+ })]
122
+ });
123
+ }
124
+ function IssueToken({ serviceId }) {
125
+ const [open, setOpen] = (0, import_react.useState)(false);
126
+ const [label, setLabel] = (0, import_react.useState)("");
127
+ const [days, setDays] = (0, import_react.useState)(90);
128
+ const [issued, setIssued] = (0, import_react.useState)(null);
129
+ const coffre = useCoffre();
130
+ const { pending, error, setError, run } = useAction();
131
+ function close() {
132
+ setOpen(false);
133
+ setIssued(null);
134
+ setLabel("");
135
+ setError(null);
136
+ }
137
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
138
+ className: "btn btn-sm",
139
+ onClick: () => setOpen(true),
140
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Plus, { size: 14 }), "Issue token"]
141
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Modal, {
142
+ open,
143
+ onOpenChange: (next) => next ? setOpen(true) : close(),
144
+ title: issued === null ? "Issue a token" : "Copy the token now",
145
+ children: issued === null ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", {
146
+ className: "form",
147
+ onSubmit: (event) => {
148
+ event.preventDefault();
149
+ run(() => coffre.tokens.issue(memberRef("service", serviceId), {
150
+ label: label.trim() === "" ? null : label.trim(),
151
+ expiresInDays: days
152
+ }), (credential) => setIssued(credential));
153
+ },
154
+ children: [
155
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
156
+ className: "form-row",
157
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
158
+ className: "field",
159
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
160
+ className: "label",
161
+ children: "Label"
162
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
163
+ className: "input",
164
+ value: label,
165
+ maxLength: 120,
166
+ placeholder: "GitHub Actions deploy",
167
+ onChange: (event) => setLabel(event.target.value)
168
+ })]
169
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
170
+ className: "field",
171
+ style: { flex: "0 0 9rem" },
172
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
173
+ className: "label",
174
+ children: "Expires after"
175
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", {
176
+ className: "select",
177
+ value: days,
178
+ onChange: (event) => setDays(Number(event.target.value)),
179
+ children: LIFETIMES.map((lifetime) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("option", {
180
+ value: lifetime,
181
+ children: [lifetime, " days"]
182
+ }, lifetime))
183
+ })]
184
+ })]
185
+ }),
186
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorLine, { error }),
187
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
188
+ className: "dialog-actions",
189
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
190
+ className: "btn",
191
+ type: "button",
192
+ onClick: close,
193
+ children: "Cancel"
194
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
195
+ className: "btn btn-primary",
196
+ type: "submit",
197
+ disabled: pending,
198
+ children: [pending && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner, {}), "Issue token"]
199
+ })]
200
+ })
201
+ ]
202
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
203
+ className: "form",
204
+ children: [
205
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Notice, {
206
+ tone: "info",
207
+ children: [
208
+ "This is the only time the value is shown. Store it where the service reads its configuration, as ",
209
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
210
+ className: "mono",
211
+ children: "COFFRE_TOKEN"
212
+ }),
213
+ "."
214
+ ]
215
+ }),
216
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
217
+ className: "token-once",
218
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", {
219
+ className: "mono",
220
+ children: issued.token
221
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CopyButton, {
222
+ value: issued.token,
223
+ label: "Copy token"
224
+ })]
225
+ }),
226
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
227
+ className: "hint",
228
+ children: [
229
+ "Expires ",
230
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Timestamp, { iso: issued.expiresAt }),
231
+ ". Send it as",
232
+ " ",
233
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
234
+ className: "mono",
235
+ children: "Authorization: Bearer …"
236
+ })
237
+ ]
238
+ }),
239
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
240
+ className: "dialog-actions",
241
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
242
+ className: "btn btn-primary",
243
+ type: "button",
244
+ onClick: close,
245
+ children: "Done"
246
+ })
247
+ })
248
+ ]
249
+ })
250
+ })] });
251
+ }
252
+ //#endregion
253
+ //#region src/routes/tokens.$token.tsx?tsr-split=component
254
+ function TokenPage() {
255
+ const { token } = Route.useParams();
256
+ const { page, credentials } = Route.useLoaderData();
257
+ const active = page.report?.ok === true && page.report.report?.status === "active";
258
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrincipalPage, {
259
+ principalType: "service",
260
+ principalId: token,
261
+ data: page
262
+ }), active && credentials?.ok === true && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ServiceTokens, {
263
+ serviceId: token,
264
+ tokens: credentials.tokens
265
+ })] });
266
+ }
267
+ //#endregion
268
+ export { TokenPage as component };
@@ -0,0 +1,18 @@
1
+ import { C as lazyRouteComponent, w as createFileRoute } from "./ui-BNzhIAQP.js";
2
+ import { o as uiResult, r as memberRef } from "./coffre-1hxT2E_U.js";
3
+ import { n as loadPrincipalPage } from "./principal-page-DkwNGzM2.js";
4
+ //#region src/routes/tokens.$token.tsx
5
+ var $$splitComponentImporter = () => import("./tokens._token-CCpaPMAk.js");
6
+ var Route = createFileRoute("/tokens/$token")({
7
+ loader: async ({ context: { client }, params, parentMatchPromise }) => {
8
+ const root = (await parentMatchPromise).loaderData;
9
+ const [page, credentials] = await Promise.all([loadPrincipalPage(client, "service", params.token, root), root?.capabilities.canManageGrants && root.auth.signin !== null ? uiResult(() => client.tokens.list(memberRef("service", params.token))) : Promise.resolve(null)]);
10
+ return {
11
+ page,
12
+ credentials
13
+ };
14
+ },
15
+ component: lazyRouteComponent($$splitComponentImporter, "component")
16
+ });
17
+ //#endregion
18
+ export { Route as t };
@@ -0,0 +1,34 @@
1
+ import { o as require_jsx_runtime } from "./useStore-DWGPqzXR.js";
2
+ import { C as Key, i as PageHeader, n as ClosedDoor } from "./page-BjXk0Ehu.js";
3
+ import { n as DirectoryTable, t as AddPrincipal } from "./directory-wm_JQUfk.js";
4
+ import { t as Route } from "./tokens.index-tDKq4AFh.js";
5
+ import { n as RemovedList } from "./offboarding-CvSilnSm.js";
6
+ //#region src/routes/tokens.index.tsx?tsr-split=component
7
+ var import_jsx_runtime = require_jsx_runtime();
8
+ function TokensPage() {
9
+ const result = Route.useLoaderData();
10
+ if (!result.ok) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ClosedDoor, {
11
+ icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Key, { size: 18 }),
12
+ label: "Tokens",
13
+ title: "Tokens are closed to you",
14
+ children: result.error
15
+ });
16
+ const tokens = result.principals.filter((principal) => principal.principalType === "service");
17
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
18
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageHeader, {
19
+ title: "Tokens",
20
+ actions: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AddPrincipal, { principalType: "service" })
21
+ }),
22
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DirectoryTable, {
23
+ principalType: "service",
24
+ principals: tokens,
25
+ hasRemoved: result.removed.some((principal) => principal.principalType === "service")
26
+ }),
27
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RemovedList, {
28
+ principalType: "service",
29
+ removed: result.removed
30
+ })
31
+ ] });
32
+ }
33
+ //#endregion
34
+ export { TokensPage as component };
@@ -0,0 +1,10 @@
1
+ import { C as lazyRouteComponent, w as createFileRoute } from "./ui-BNzhIAQP.js";
2
+ import { o as loadDirectory } from "./directory-wm_JQUfk.js";
3
+ //#region src/routes/tokens.index.tsx
4
+ var $$splitComponentImporter = () => import("./tokens.index-Do3OHR31.js");
5
+ var Route = createFileRoute("/tokens/")({
6
+ loader: async ({ context: { client }, parentMatchPromise }) => loadDirectory(client, (await parentMatchPromise).loaderData?.capabilities.canManageGrants ?? false),
7
+ component: lazyRouteComponent($$splitComponentImporter, "component")
8
+ });
9
+ //#endregion
10
+ export { Route as t };