@coffre/ui 0.0.0 → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +7 -3
- package/dist/client/.assetsignore +2 -0
- package/dist/client/_coffre/assets/account-C3Zo1l5A.js +1 -0
- package/dist/client/_coffre/assets/account-C4bNbeO7.js +2 -0
- package/dist/client/_coffre/assets/affordances-DiuJIiR2.js +1 -0
- package/dist/client/_coffre/assets/audit-1xLyuxGz.js +2 -0
- package/dist/client/_coffre/assets/audit-Dab2GuRj.js +1 -0
- package/dist/client/_coffre/assets/auth.device-BfCfeBWe.js +2 -0
- package/dist/client/_coffre/assets/auth.device-D2pCLF-X.js +1 -0
- package/dist/client/_coffre/assets/coffre-C7qL3HGR.js +1 -0
- package/dist/client/_coffre/assets/directory-C2Ou4SQv.js +1 -0
- package/dist/client/_coffre/assets/globals-Dgq4Jy0x.css +1 -0
- package/dist/client/_coffre/assets/grants-fqTtJ-aW.js +1 -0
- package/dist/client/_coffre/assets/index-BpGwbjmM.js +12 -0
- package/dist/client/_coffre/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/client/_coffre/assets/login-CR9CBXlw.js +2 -0
- package/dist/client/_coffre/assets/login-DZizFxa4.js +1 -0
- package/dist/client/_coffre/assets/offboarding-DOLJQcXU.js +1 -0
- package/dist/client/_coffre/assets/page-BxW2MwaX.js +1 -0
- package/dist/client/_coffre/assets/preload-helper-BHuP8_FL.js +46 -0
- package/dist/client/_coffre/assets/principal-page-xnBZVURr.js +1 -0
- package/dist/client/_coffre/assets/project-environments-CfIH5kFM.js +1 -0
- package/dist/client/_coffre/assets/projects._project._environment-CrWjQmIA.js +2 -0
- package/dist/client/_coffre/assets/projects._project._environment-CwRVG9Ne.js +3 -0
- package/dist/client/_coffre/assets/projects._project.index-CCDEuE-z.js +2 -0
- package/dist/client/_coffre/assets/projects._project.index-DCJsmnD7.js +1 -0
- package/dist/client/_coffre/assets/projects.index-B8eV8JIn.js +1 -0
- package/dist/client/_coffre/assets/projects.index-BNEC7Oz8.js +2 -0
- package/dist/client/_coffre/assets/settings-2BPsenNM.js +2 -0
- package/dist/client/_coffre/assets/settings-BrS0-wEt.js +1 -0
- package/dist/client/_coffre/assets/signin-errors-CroZWZgm.js +1 -0
- package/dist/client/_coffre/assets/tokens._token-B3-YwuKp.js +2 -0
- package/dist/client/_coffre/assets/tokens._token-D_hsbHx6.js +1 -0
- package/dist/client/_coffre/assets/tokens.index-BdKE2Jv8.js +2 -0
- package/dist/client/_coffre/assets/tokens.index-XvA4XRxh.js +1 -0
- package/dist/client/_coffre/assets/unregistered-CTRMtBIy.js +1 -0
- package/dist/client/_coffre/assets/use-action-DgAf-tiX.js +1 -0
- package/dist/client/_coffre/assets/users._user-BFPXcJ4y.js +2 -0
- package/dist/client/_coffre/assets/users._user-DEtMeSoh.js +1 -0
- package/dist/client/_coffre/assets/users.index-B03beUHq.js +1 -0
- package/dist/client/_coffre/assets/users.index-D8hwzM6P.js +2 -0
- package/dist/client/_coffre/assets/validation-9Cl_XS-l.js +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/server/.vite/manifest.json +572 -0
- package/dist/server/_coffre/assets/_tanstack-start-manifest_v-B6CZDfrB.js +133 -0
- package/dist/server/_coffre/assets/account-B71_b5xc.js +296 -0
- package/dist/server/_coffre/assets/account-BoO6ZqMc.js +176 -0
- package/dist/server/_coffre/assets/affordances-BNaXjMOb.js +46 -0
- package/dist/server/_coffre/assets/async-local-storage-C0cwgkEr.js +3107 -0
- package/dist/server/_coffre/assets/audit-CwRFnSAY.js +74 -0
- package/dist/server/_coffre/assets/audit-t1sYjtrf.js +964 -0
- package/dist/server/_coffre/assets/auth.device-1IcJ475s.js +208 -0
- package/dist/server/_coffre/assets/auth.device-CJwZYYtn.js +29 -0
- package/dist/server/_coffre/assets/coffre-1hxT2E_U.js +278 -0
- package/dist/server/_coffre/assets/directory-wm_JQUfk.js +396 -0
- package/dist/server/_coffre/assets/empty-plugin-adapters-Cq4--YW-.js +5 -0
- package/dist/server/_coffre/assets/globals-Dgq4Jy0x.css +1 -0
- package/dist/server/_coffre/assets/grants-BmhEY1vz.js +243 -0
- package/dist/server/_coffre/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/server/_coffre/assets/login-B5O5LPXV.js +100 -0
- package/dist/server/_coffre/assets/login-Bvc4gp0X.js +22 -0
- package/dist/server/_coffre/assets/offboarding-CvSilnSm.js +330 -0
- package/dist/server/_coffre/assets/page-BjXk0Ehu.js +2003 -0
- package/dist/server/_coffre/assets/principal-page-DkwNGzM2.js +617 -0
- package/dist/server/_coffre/assets/project-environments-lEzFHUt4.js +9 -0
- package/dist/server/_coffre/assets/projects._project._environment-7grhqlgq.js +2227 -0
- package/dist/server/_coffre/assets/projects._project._environment-ByEf6pmz.js +55 -0
- package/dist/server/_coffre/assets/projects._project.index-B1bjowP-.js +932 -0
- package/dist/server/_coffre/assets/projects._project.index-DU8wtoHD.js +22 -0
- package/dist/server/_coffre/assets/projects.index-B0DoHbCz.js +280 -0
- package/dist/server/_coffre/assets/projects.index-kMDA6pMy.js +54 -0
- package/dist/server/_coffre/assets/react-dom-qCTiwGGR.js +1352 -0
- package/dist/server/_coffre/assets/router-ChU_CwCX.js +2028 -0
- package/dist/server/_coffre/assets/settings-CM9-h7in.js +18 -0
- package/dist/server/_coffre/assets/settings-Cg5qOGij.js +60 -0
- package/dist/server/_coffre/assets/signin-errors-BEFlVDbQ.js +28 -0
- package/dist/server/_coffre/assets/start-DR3rN0St.js +4 -0
- package/dist/server/_coffre/assets/tokens._token-CCpaPMAk.js +268 -0
- package/dist/server/_coffre/assets/tokens._token-Di4OZdAA.js +18 -0
- package/dist/server/_coffre/assets/tokens.index-Do3OHR31.js +34 -0
- package/dist/server/_coffre/assets/tokens.index-tDKq4AFh.js +10 -0
- package/dist/server/_coffre/assets/ui-BNzhIAQP.js +15710 -0
- package/dist/server/_coffre/assets/unregistered-BqaWYFJK.js +51 -0
- package/dist/server/_coffre/assets/use-action-BkJXC5JM.js +953 -0
- package/dist/server/_coffre/assets/useStore-DWGPqzXR.js +892 -0
- package/dist/server/_coffre/assets/users._user-BenYva93.js +15 -0
- package/dist/server/_coffre/assets/users._user-Cp039Va-.js +10 -0
- package/dist/server/_coffre/assets/users.index-BrzG1Ecq.js +10 -0
- package/dist/server/_coffre/assets/users.index-DQ_45DQl.js +34 -0
- package/dist/server/_coffre/assets/validation-BQtqPe2V.js +27 -0
- package/dist/server/index.js +13910 -0
- package/package.json +58 -5
- package/src/components/affordances.ts +80 -0
- package/src/components/agentation.tsx +34 -0
- package/src/components/command-palette.tsx +271 -0
- package/src/components/directory.tsx +448 -0
- package/src/components/grants.tsx +204 -0
- package/src/components/icons.tsx +283 -0
- package/src/components/offboarding.tsx +286 -0
- package/src/components/page.tsx +128 -0
- package/src/components/principal-page.tsx +549 -0
- package/src/components/principal-picker.tsx +168 -0
- package/src/components/principal.tsx +53 -0
- package/src/components/route-states.tsx +60 -0
- package/src/components/service-tokens.tsx +212 -0
- package/src/components/shell.tsx +641 -0
- package/src/components/syncs.tsx +581 -0
- package/src/components/theme.tsx +141 -0
- package/src/components/tile.tsx +22 -0
- package/src/components/ui.tsx +440 -0
- package/src/entry.ts +19 -0
- package/src/lib/access-plan.ts +201 -0
- package/src/lib/audit-sentences.ts +468 -0
- package/src/lib/capabilities.ts +45 -0
- package/src/lib/coffre.ts +57 -0
- package/src/lib/project-access.ts +95 -0
- package/src/lib/project-environments.ts +23 -0
- package/src/lib/reveal.ts +21 -0
- package/src/lib/secret-edit-batch.ts +181 -0
- package/src/lib/signin-errors.ts +33 -0
- package/src/lib/use-action.ts +50 -0
- package/src/lib/validation.ts +27 -0
- package/src/routeTree.gen.ts +367 -0
- package/src/router.tsx +84 -0
- package/src/routes/__root.tsx +192 -0
- package/src/routes/access.tsx +11 -0
- package/src/routes/account.tsx +359 -0
- package/src/routes/audit.tsx +545 -0
- package/src/routes/auth.device.tsx +200 -0
- package/src/routes/index.tsx +15 -0
- package/src/routes/login.tsx +129 -0
- package/src/routes/projects.$project.$environment.tsx +1659 -0
- package/src/routes/projects.$project.index.tsx +917 -0
- package/src/routes/projects.index.tsx +353 -0
- package/src/routes/settings.tsx +72 -0
- package/src/routes/tokens.$token.tsx +35 -0
- package/src/routes/tokens.index.tsx +37 -0
- package/src/routes/unregistered.tsx +59 -0
- package/src/routes/users.$user.tsx +13 -0
- package/src/routes/users.index.tsx +37 -0
- package/src/shared/models.ts +55 -0
- package/src/styles/globals.css +4118 -0
- package/src/types.ts +21 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { C as require_react, E as __toESM, o as require_jsx_runtime } from "./useStore-DWGPqzXR.js";
|
|
2
|
+
import { D as useNavigate, E as Link, a as ErrorLine, c as Spinner, l as Timestamp } from "./ui-BNzhIAQP.js";
|
|
3
|
+
import { G as SlashCircle, Y as Terminal, d as CheckCircle, n as ClosedDoor } from "./page-BjXk0Ehu.js";
|
|
4
|
+
import { i as statusOf, n as failureMessage, s as useCoffre } from "./coffre-1hxT2E_U.js";
|
|
5
|
+
import { t as Route } from "./auth.device-CJwZYYtn.js";
|
|
6
|
+
//#region src/routes/auth.device.tsx?tsr-split=component
|
|
7
|
+
/**
|
|
8
|
+
* Where `coffre login` sends you: approve a terminal's sign-in with the
|
|
9
|
+
* session this browser already has. The terminal shows a code; this page
|
|
10
|
+
* shows the same code and where the request came from, and nothing happens
|
|
11
|
+
* until you press Approve.
|
|
12
|
+
*/
|
|
13
|
+
var import_react = /* @__PURE__ */ __toESM(require_react());
|
|
14
|
+
var import_jsx_runtime = require_jsx_runtime();
|
|
15
|
+
function DevicePage() {
|
|
16
|
+
const loaded = Route.useLoaderData();
|
|
17
|
+
const [decided, setDecided] = (0, import_react.useState)(null);
|
|
18
|
+
if (decided === "approved") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ClosedDoor, {
|
|
19
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CheckCircle, { size: 18 }),
|
|
20
|
+
label: "coffre CLI",
|
|
21
|
+
title: "Your terminal is signed in",
|
|
22
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "You can close this tab and go back to the terminal." })
|
|
23
|
+
});
|
|
24
|
+
if (decided === "denied") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ClosedDoor, {
|
|
25
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SlashCircle, { size: 18 }),
|
|
26
|
+
label: "coffre CLI",
|
|
27
|
+
title: "Sign-in refused",
|
|
28
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
|
|
29
|
+
"The terminal that asked gets nothing. If you did not run ",
|
|
30
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
31
|
+
className: "mono",
|
|
32
|
+
children: "coffre login"
|
|
33
|
+
}),
|
|
34
|
+
" yourself, someone may be trying to get you to approve theirs; the refusal is in the audit log."
|
|
35
|
+
] })
|
|
36
|
+
});
|
|
37
|
+
if (loaded === null) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CodeEntry, {});
|
|
38
|
+
if (!loaded.ok) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CodeEntry, { error: loaded.error });
|
|
39
|
+
if (loaded.request === null) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CodeEntry, { error: "That code is unknown, already used, or expired. Run coffre login again for a new one." });
|
|
40
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Approve, {
|
|
41
|
+
request: loaded.request,
|
|
42
|
+
sessionDays: loaded.sessionDays,
|
|
43
|
+
onDecided: setDecided
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function CodeEntry({ error = null }) {
|
|
47
|
+
const navigate = useNavigate();
|
|
48
|
+
const [code, setCode] = (0, import_react.useState)("");
|
|
49
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
|
|
50
|
+
className: "card signin",
|
|
51
|
+
"aria-labelledby": "device-title",
|
|
52
|
+
children: [
|
|
53
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
54
|
+
className: "signin-head",
|
|
55
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", {
|
|
56
|
+
className: "signin-title",
|
|
57
|
+
id: "device-title",
|
|
58
|
+
children: "Sign in the coffre CLI"
|
|
59
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
|
|
60
|
+
className: "signin-lede",
|
|
61
|
+
children: [
|
|
62
|
+
"Enter the code your terminal shows after ",
|
|
63
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
64
|
+
className: "mono",
|
|
65
|
+
children: "coffre login"
|
|
66
|
+
}),
|
|
67
|
+
"."
|
|
68
|
+
]
|
|
69
|
+
})]
|
|
70
|
+
}),
|
|
71
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", {
|
|
72
|
+
className: "signin-form",
|
|
73
|
+
onSubmit: (event) => {
|
|
74
|
+
event.preventDefault();
|
|
75
|
+
navigate({
|
|
76
|
+
to: "/auth/device",
|
|
77
|
+
search: { code: code.trim() }
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
|
|
81
|
+
className: "field",
|
|
82
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
83
|
+
className: "label",
|
|
84
|
+
children: "Code"
|
|
85
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
86
|
+
className: "input mono device-code-input",
|
|
87
|
+
name: "code",
|
|
88
|
+
autoComplete: "off",
|
|
89
|
+
autoCapitalize: "characters",
|
|
90
|
+
spellCheck: false,
|
|
91
|
+
placeholder: "XXXX-XXXX",
|
|
92
|
+
maxLength: 16,
|
|
93
|
+
value: code,
|
|
94
|
+
onChange: (event) => setCode(event.target.value)
|
|
95
|
+
})]
|
|
96
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
97
|
+
className: "btn btn-primary",
|
|
98
|
+
type: "submit",
|
|
99
|
+
style: { height: "2.125rem" },
|
|
100
|
+
disabled: code.trim() === "",
|
|
101
|
+
children: "Continue"
|
|
102
|
+
})]
|
|
103
|
+
}),
|
|
104
|
+
error !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
105
|
+
className: "signin-error",
|
|
106
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorLine, { error })
|
|
107
|
+
})
|
|
108
|
+
]
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function Approve({ request, sessionDays, onDecided }) {
|
|
112
|
+
const coffre = useCoffre();
|
|
113
|
+
const [pending, setPending] = (0, import_react.useState)(null);
|
|
114
|
+
const [error, setError] = (0, import_react.useState)(null);
|
|
115
|
+
async function decide(approve) {
|
|
116
|
+
setPending(approve ? "approve" : "deny");
|
|
117
|
+
try {
|
|
118
|
+
await coffre.deviceLogins.decide(request.userCode, approve);
|
|
119
|
+
onDecided(approve ? "approved" : "denied");
|
|
120
|
+
} catch (error) {
|
|
121
|
+
setError(statusOf(error) === 404 ? "That code is unknown, already used, or expired. Run coffre login again." : statusOf(error) === void 0 ? "The decision could not be sent. Nothing was approved." : failureMessage(error));
|
|
122
|
+
} finally {
|
|
123
|
+
setPending(null);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
|
|
127
|
+
className: "card signin",
|
|
128
|
+
"aria-labelledby": "device-title",
|
|
129
|
+
children: [
|
|
130
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
131
|
+
className: "signin-head",
|
|
132
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", {
|
|
133
|
+
className: "signin-title",
|
|
134
|
+
id: "device-title",
|
|
135
|
+
children: "Approve this terminal?"
|
|
136
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
|
|
137
|
+
className: "signin-lede",
|
|
138
|
+
children: [
|
|
139
|
+
"Only if you just ran ",
|
|
140
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
141
|
+
className: "mono",
|
|
142
|
+
children: "coffre login"
|
|
143
|
+
}),
|
|
144
|
+
" yourself and it shows this code. It gets your access, in your name, for ",
|
|
145
|
+
sessionDays,
|
|
146
|
+
" days or until you end it from your account page."
|
|
147
|
+
]
|
|
148
|
+
})]
|
|
149
|
+
}),
|
|
150
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
151
|
+
className: "device-code",
|
|
152
|
+
"aria-label": "Code",
|
|
153
|
+
children: request.userCode
|
|
154
|
+
}),
|
|
155
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("dl", {
|
|
156
|
+
className: "facts device-facts",
|
|
157
|
+
children: [
|
|
158
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
159
|
+
className: "fact",
|
|
160
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: "Client" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
161
|
+
className: "cell-account",
|
|
162
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Terminal, { size: 14 }), request.clientLabel ?? "coffre CLI"]
|
|
163
|
+
}) })]
|
|
164
|
+
}),
|
|
165
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
166
|
+
className: "fact",
|
|
167
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: "Requested from" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", {
|
|
168
|
+
className: "mono",
|
|
169
|
+
children: request.clientIp ?? "an unknown address"
|
|
170
|
+
})]
|
|
171
|
+
}),
|
|
172
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
173
|
+
className: "fact",
|
|
174
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: "Requested (UTC)" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Timestamp, { iso: request.createdAt }) })]
|
|
175
|
+
})
|
|
176
|
+
]
|
|
177
|
+
}),
|
|
178
|
+
error !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
179
|
+
className: "signin-error",
|
|
180
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorLine, { error })
|
|
181
|
+
}),
|
|
182
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
183
|
+
className: "device-actions",
|
|
184
|
+
children: [
|
|
185
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Link, {
|
|
186
|
+
className: "btn btn-quiet",
|
|
187
|
+
to: "/projects",
|
|
188
|
+
children: "Cancel"
|
|
189
|
+
}),
|
|
190
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
|
|
191
|
+
className: "btn",
|
|
192
|
+
disabled: pending !== null,
|
|
193
|
+
onClick: () => void decide(false),
|
|
194
|
+
children: [pending === "deny" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner, {}), "Deny"]
|
|
195
|
+
}),
|
|
196
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
|
|
197
|
+
className: "btn btn-primary",
|
|
198
|
+
disabled: pending !== null,
|
|
199
|
+
onClick: () => void decide(true),
|
|
200
|
+
children: [pending === "approve" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner, {}), "Approve"]
|
|
201
|
+
})
|
|
202
|
+
]
|
|
203
|
+
})
|
|
204
|
+
]
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
//#endregion
|
|
208
|
+
export { DevicePage as component };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { C as lazyRouteComponent, w as createFileRoute } from "./ui-BNzhIAQP.js";
|
|
2
|
+
import { o as uiResult } from "./coffre-1hxT2E_U.js";
|
|
3
|
+
//#region src/routes/auth.device.tsx
|
|
4
|
+
var $$splitComponentImporter = () => import("./auth.device-1IcJ475s.js");
|
|
5
|
+
/**
|
|
6
|
+
* Where `coffre login` sends you: approve a terminal's sign-in with the
|
|
7
|
+
* session this browser already has. The terminal shows a code; this page
|
|
8
|
+
* shows the same code and where the request came from, and nothing happens
|
|
9
|
+
* until you press Approve.
|
|
10
|
+
*/
|
|
11
|
+
var Route = createFileRoute("/auth/device")({
|
|
12
|
+
validateSearch: (search) => {
|
|
13
|
+
const code = search.code;
|
|
14
|
+
return typeof code === "string" && code.length <= 16 ? { code } : {};
|
|
15
|
+
},
|
|
16
|
+
loaderDeps: ({ search }) => ({ code: search.code }),
|
|
17
|
+
loader: async ({ context: { client }, deps, parentMatchPromise }) => {
|
|
18
|
+
if (deps.code === void 0) return null;
|
|
19
|
+
if (!(await parentMatchPromise).loaderData?.auth.signin) return {
|
|
20
|
+
ok: false,
|
|
21
|
+
error: "This instance has no CLI sign-in."
|
|
22
|
+
};
|
|
23
|
+
const code = deps.code;
|
|
24
|
+
return uiResult(() => client.deviceLogins.get(code));
|
|
25
|
+
},
|
|
26
|
+
component: lazyRouteComponent($$splitComponentImporter, "component")
|
|
27
|
+
});
|
|
28
|
+
//#endregion
|
|
29
|
+
export { Route as t };
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { i as useRouter } from "./useStore-DWGPqzXR.js";
|
|
2
|
+
//#region ../client/dist/index.js
|
|
3
|
+
function initialValues(provider) {
|
|
4
|
+
return Object.fromEntries(provider.fields.map((field) => [field.name, field.type === "text" ? "" : field.initial]));
|
|
5
|
+
}
|
|
6
|
+
/** Whether the rest of the form makes the field meaningful. */
|
|
7
|
+
function isAsked(field, values) {
|
|
8
|
+
if (field.type === "options" || field.when === void 0) return true;
|
|
9
|
+
const picked = values[field.when.field];
|
|
10
|
+
const list = Array.isArray(picked) ? picked : [];
|
|
11
|
+
return list.length === field.when.is.length && field.when.is.every((value) => list.includes(value));
|
|
12
|
+
}
|
|
13
|
+
/** The label of the first required field left empty, or null when the form can be sent. */
|
|
14
|
+
function firstMissing(provider, values) {
|
|
15
|
+
for (const field of provider.fields) {
|
|
16
|
+
if (!isAsked(field, values)) continue;
|
|
17
|
+
const value = values[field.name];
|
|
18
|
+
if ((typeof value === "string" ? value.trim() === "" : (value ?? []).length === 0) && (field.type === "options" || field.optional !== true)) return field.label;
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The provider's config. Text is trimmed, and an optional field left empty
|
|
24
|
+
* is left out rather than sent as "", which the server rightly refuses.
|
|
25
|
+
*/
|
|
26
|
+
function configFromForm(provider, values) {
|
|
27
|
+
const config = {};
|
|
28
|
+
for (const field of provider.fields) {
|
|
29
|
+
if (!isAsked(field, values)) continue;
|
|
30
|
+
const value = values[field.name];
|
|
31
|
+
if (field.type === "options") {
|
|
32
|
+
const picked = Array.isArray(value) ? value : [];
|
|
33
|
+
config[field.name] = field.multiple ? picked : picked[0];
|
|
34
|
+
} else {
|
|
35
|
+
const text = typeof value === "string" ? value.trim() : "";
|
|
36
|
+
if (text !== "") config[field.name] = text;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return config;
|
|
40
|
+
}
|
|
41
|
+
/** The API's error shape, `{ error, message }`, with the HTTP status. */
|
|
42
|
+
var COFFRE_ERROR = Symbol.for("@coffre/client:CoffreError");
|
|
43
|
+
var CoffreError = class extends Error {
|
|
44
|
+
/**
|
|
45
|
+
* `@coffre/ui`'s prebuilt pages bundle a copy of this class, and a page is
|
|
46
|
+
* handed a client the server made with this package's. So `instanceof`
|
|
47
|
+
* asks for the mark every copy leaves, rather than for this copy's prototype.
|
|
48
|
+
*/
|
|
49
|
+
static [Symbol.hasInstance](value) {
|
|
50
|
+
return typeof value === "object" && value !== null && COFFRE_ERROR in value;
|
|
51
|
+
}
|
|
52
|
+
[COFFRE_ERROR] = true;
|
|
53
|
+
status;
|
|
54
|
+
code;
|
|
55
|
+
/** The vault's own code when it refused: `no_grant`, `removed`, `bulk_limit`, ... */
|
|
56
|
+
reason;
|
|
57
|
+
constructor(status, code, message, reason) {
|
|
58
|
+
super(message);
|
|
59
|
+
this.name = "CoffreError";
|
|
60
|
+
this.status = status;
|
|
61
|
+
this.code = code;
|
|
62
|
+
this.reason = reason;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
/** `market/prod/KEY` as route parameters. */
|
|
66
|
+
function place(path) {
|
|
67
|
+
const [project = "", environment = "", key = ""] = path.replace(/^\/+|\/+$/g, "").split("/");
|
|
68
|
+
return {
|
|
69
|
+
project,
|
|
70
|
+
environment,
|
|
71
|
+
key
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function createClient(options) {
|
|
75
|
+
const origin = options.url.replace(/\/+$/, "");
|
|
76
|
+
const transport = options.transport ?? ((request) => fetch(request));
|
|
77
|
+
async function send(method, path, input) {
|
|
78
|
+
const url = new URL(`${origin}/api${path}`);
|
|
79
|
+
const headers = new Headers(await options.headers?.());
|
|
80
|
+
let body;
|
|
81
|
+
if (method === "GET") {
|
|
82
|
+
for (const [name, value] of Object.entries(input ?? {})) if (value !== void 0 && value !== null) url.searchParams.set(name, String(value));
|
|
83
|
+
} else if (input !== void 0) {
|
|
84
|
+
headers.set("content-type", "application/json");
|
|
85
|
+
body = JSON.stringify(input);
|
|
86
|
+
}
|
|
87
|
+
const response = await transport(new Request(url, {
|
|
88
|
+
method,
|
|
89
|
+
headers,
|
|
90
|
+
body
|
|
91
|
+
}));
|
|
92
|
+
const payload = await response.json().catch(() => null);
|
|
93
|
+
if (!response.ok) {
|
|
94
|
+
const error = payload;
|
|
95
|
+
throw new CoffreError(response.status, typeof error?.error === "string" ? error.error : "http_error", typeof error?.message === "string" ? error.message : `request failed with status ${response.status}`, typeof error?.reason === "string" ? error.reason : void 0);
|
|
96
|
+
}
|
|
97
|
+
return payload;
|
|
98
|
+
}
|
|
99
|
+
/** A route key and its parameters as a method and a path. */
|
|
100
|
+
function address(key, params) {
|
|
101
|
+
const [method, pattern] = key.split(" ");
|
|
102
|
+
return [method, pattern.replace(/:(\w+)/g, (_, name) => encodeURIComponent(params[name]))];
|
|
103
|
+
}
|
|
104
|
+
/** Any route by its key: `call('GET /secrets/:project/:environment', { project, environment })`. */
|
|
105
|
+
async function call(key, ...[params, input]) {
|
|
106
|
+
const [method, path] = address(key, params);
|
|
107
|
+
return await send(method, path, input);
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
call,
|
|
111
|
+
/** How this instance signs people in. Answers anyone, signed in or not. */
|
|
112
|
+
auth: () => send("GET", "/auth", void 0),
|
|
113
|
+
/** Who I am, and every place I can reach. */
|
|
114
|
+
me: () => call("GET /me", {}),
|
|
115
|
+
projects: {
|
|
116
|
+
/** With their environments. */
|
|
117
|
+
list: () => call("GET /projects", {}),
|
|
118
|
+
create: (project, input) => call("PUT /projects/:project", { project }, input),
|
|
119
|
+
update: (project, patch) => call("PATCH /projects/:project", { project }, patch)
|
|
120
|
+
},
|
|
121
|
+
environments: {
|
|
122
|
+
create: (path, input) => call("PUT /projects/:project/:environment", place(path), input),
|
|
123
|
+
update: (path, patch) => call("PATCH /projects/:project/:environment", place(path), patch)
|
|
124
|
+
},
|
|
125
|
+
secrets: {
|
|
126
|
+
/** Keys, versions and who changed what; never values. */
|
|
127
|
+
list: (path) => call("GET /secrets/:project/:environment", place(path)),
|
|
128
|
+
/** Decrypts one secret, or every secret in an environment. Logged in your name. */
|
|
129
|
+
reveal: (path) => call("POST /reveals", {}, { path }),
|
|
130
|
+
/** One transaction, a version and an audit entry per key; `null` archives. */
|
|
131
|
+
set: (path, values) => call("PATCH /secrets/:project/:environment", place(path), values),
|
|
132
|
+
/**
|
|
133
|
+
* What `set` would do to each key, `added`, `changed`, `unchanged` or
|
|
134
|
+
* `archived`, and nothing else: no value comes back and nothing is
|
|
135
|
+
* written. Comparing opens the current values, logged as reads.
|
|
136
|
+
*/
|
|
137
|
+
dryRun: (path, values) => {
|
|
138
|
+
const [method, route] = address("PATCH /secrets/:project/:environment", place(path));
|
|
139
|
+
return send(method, `${route}?dryRun=1`, values);
|
|
140
|
+
},
|
|
141
|
+
history: (path) => call("GET /secrets/:project/:environment/:key/versions", place(path)),
|
|
142
|
+
/** A new version holding the old one's value. */
|
|
143
|
+
restore: (path, version) => call("POST /secrets/:project/:environment/:key/restore", place(path), { version }),
|
|
144
|
+
rename: (path, key) => call("PATCH /secrets/:project/:environment/:key", place(path), { key }),
|
|
145
|
+
update: (path, patch) => call("PATCH /secrets/:project/:environment/:key", place(path), patch)
|
|
146
|
+
},
|
|
147
|
+
members: {
|
|
148
|
+
/** People and tokens, their role and their access; at a place, those who reach it. */
|
|
149
|
+
list: (path) => call("GET /members", {}, { path }),
|
|
150
|
+
/** What they hold, and what to rotate if they leave. */
|
|
151
|
+
get: (member) => call("GET /members/:member", { member }),
|
|
152
|
+
add: (member, input = {}) => call("PUT /members/:member", { member }, input),
|
|
153
|
+
/** Offboards; returns what to rotate. */
|
|
154
|
+
remove: (member) => call("DELETE /members/:member", { member })
|
|
155
|
+
},
|
|
156
|
+
tokens: {
|
|
157
|
+
list: (member) => call("GET /members/:member/tokens", { member }),
|
|
158
|
+
/** The value is in the answer, and only there. */
|
|
159
|
+
issue: (member, input) => call("POST /members/:member/tokens", { member }, input),
|
|
160
|
+
revoke: (member, id) => call("DELETE /members/:member/tokens/:id", {
|
|
161
|
+
member,
|
|
162
|
+
id
|
|
163
|
+
})
|
|
164
|
+
},
|
|
165
|
+
access: {
|
|
166
|
+
/** What they should hold at each place; the server applies the difference. `null` revokes. */
|
|
167
|
+
set: (member, access) => call("PATCH /access/:member", { member }, access) },
|
|
168
|
+
/** Where I am signed in. Only where coffre runs its own sign-in. */
|
|
169
|
+
sessions: {
|
|
170
|
+
list: () => call("GET /sessions", {}),
|
|
171
|
+
revoke: (id) => call("DELETE /sessions/:id", { id })
|
|
172
|
+
},
|
|
173
|
+
/** The accounts I sign in with. */
|
|
174
|
+
identities: {
|
|
175
|
+
list: () => call("GET /identities", {}),
|
|
176
|
+
unlink: (id) => call("DELETE /identities/:id", { id })
|
|
177
|
+
},
|
|
178
|
+
/** A `coffre login` waiting for someone to approve it, by the code it shows. */
|
|
179
|
+
deviceLogins: {
|
|
180
|
+
get: (code) => call("GET /device-logins/:code", { code }),
|
|
181
|
+
decide: (code, approve) => call("POST /device-logins/:code", { code }, { approve })
|
|
182
|
+
},
|
|
183
|
+
syncs: {
|
|
184
|
+
/** Where a sync can push on this instance, and what each asks for. */
|
|
185
|
+
providers: () => call("GET /syncs/providers", {}),
|
|
186
|
+
list: (path) => call("GET /syncs/:project/:environment", place(path)),
|
|
187
|
+
add: (path, input) => call("POST /syncs/:project/:environment", place(path), input),
|
|
188
|
+
update: (id, patch) => call("PATCH /syncs/by-id/:id", { id }, patch),
|
|
189
|
+
remove: (id) => call("DELETE /syncs/by-id/:id", { id }),
|
|
190
|
+
run: (id) => call("POST /syncs/by-id/:id/runs", { id })
|
|
191
|
+
},
|
|
192
|
+
audit: {
|
|
193
|
+
list: (query = {}) => call("GET /audit", {}, query),
|
|
194
|
+
verify: () => call("GET /audit/verification", {})
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* What writing these entries (a parsed `.env` file) would do, from a dry run
|
|
200
|
+
* of the write: the server compares, so no value leaves it, and the values it
|
|
201
|
+
* opens to compare are logged as reads. `changes` is what to pass to
|
|
202
|
+
* `secrets.set`: the keys that differ, so an unchanged value does not become
|
|
203
|
+
* a new version.
|
|
204
|
+
*/
|
|
205
|
+
async function planImport(coffre, path, entries) {
|
|
206
|
+
const values = Object.create(null);
|
|
207
|
+
for (const { key, value } of entries) values[key] = value;
|
|
208
|
+
const [listed, compared] = await Promise.allSettled([coffre.secrets.list(path), coffre.secrets.dryRun(path, { ...values })]);
|
|
209
|
+
if (listed.status === "rejected") throw listed.reason;
|
|
210
|
+
if (compared.status === "rejected") throw compared.reason;
|
|
211
|
+
const [{ keys }, dryRun] = [listed.value, compared.value];
|
|
212
|
+
const versions = new Map(keys.map((entry) => [entry.key, entry.version]));
|
|
213
|
+
const plan = [];
|
|
214
|
+
const changes = Object.create(null);
|
|
215
|
+
for (const [key, value] of Object.entries(values)) {
|
|
216
|
+
const action = dryRun.keys[key];
|
|
217
|
+
plan.push({
|
|
218
|
+
key,
|
|
219
|
+
action,
|
|
220
|
+
version: versions.get(key) ?? null
|
|
221
|
+
});
|
|
222
|
+
if (action !== "unchanged") changes[key] = value;
|
|
223
|
+
}
|
|
224
|
+
return {
|
|
225
|
+
plan,
|
|
226
|
+
changes: { ...changes }
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
//#endregion
|
|
230
|
+
//#region src/lib/coffre.ts
|
|
231
|
+
/**
|
|
232
|
+
* The API as whoever is looking at the page. In the browser this is plain
|
|
233
|
+
* `fetch` to `/api`, carrying the session cookie; mutations call it straight
|
|
234
|
+
* from event handlers, and loaders read through `context.client`.
|
|
235
|
+
*/
|
|
236
|
+
function useCoffre() {
|
|
237
|
+
return useRouter().options.context.client;
|
|
238
|
+
}
|
|
239
|
+
/** A refusal the page words itself, shown as it is. */
|
|
240
|
+
var Refusal = class extends Error {};
|
|
241
|
+
/** The HTTP status of an API error; undefined when the request never got an answer. */
|
|
242
|
+
function statusOf(error) {
|
|
243
|
+
return error instanceof CoffreError ? error.status : void 0;
|
|
244
|
+
}
|
|
245
|
+
/** What to tell the person when a call fails. */
|
|
246
|
+
function failureMessage(error) {
|
|
247
|
+
if (error instanceof Refusal) return error.message;
|
|
248
|
+
if (!(error instanceof CoffreError)) return "The request could not be sent. Nothing was changed.";
|
|
249
|
+
if (error.status === 401) return "Your session has ended. Sign in again, then retry.";
|
|
250
|
+
if (error.code === "cross_origin") return "coffre refused a change that did not come from this page. Reload, then retry.";
|
|
251
|
+
if (error.status === 403) return "You hold no grant that covers this. Someone with grant.manage on the project can add one.";
|
|
252
|
+
if (error.status === 404) return "Not found. It may have been renamed or archived.";
|
|
253
|
+
if (error.status === 400 || error.status === 409) return error.message;
|
|
254
|
+
return "coffre is unavailable. Nothing was read or written.";
|
|
255
|
+
}
|
|
256
|
+
function uiFailure(error) {
|
|
257
|
+
return {
|
|
258
|
+
ok: false,
|
|
259
|
+
error: failureMessage(error)
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
/** A loader's answer: what it read, or what to say instead. */
|
|
263
|
+
async function uiResult(operation) {
|
|
264
|
+
try {
|
|
265
|
+
return {
|
|
266
|
+
ok: true,
|
|
267
|
+
...await operation()
|
|
268
|
+
};
|
|
269
|
+
} catch (error) {
|
|
270
|
+
return uiFailure(error);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
/** How the API names a member: `user:ada@acme.example`, `token:ci-deploy`. */
|
|
274
|
+
function memberRef(principalType, principalId) {
|
|
275
|
+
return `${principalType === "user" ? "user" : "token"}:${principalId}`;
|
|
276
|
+
}
|
|
277
|
+
//#endregion
|
|
278
|
+
export { uiFailure as a, CoffreError as c, firstMissing as d, initialValues as f, statusOf as i, configFromForm as l, planImport as m, failureMessage as n, uiResult as o, isAsked as p, memberRef as r, useCoffre as s, Refusal as t, createClient as u };
|