@gadicc/loom 1.33.1 → 1.35.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 (110) hide show
  1. package/README.md +108 -41
  2. package/esm/src/apiKeys/authorize.d.ts.map +1 -1
  3. package/esm/src/apiKeys/authorize.js +71 -0
  4. package/esm/src/apiKeys/betterAuth.d.ts +123 -0
  5. package/esm/src/apiKeys/betterAuth.d.ts.map +1 -0
  6. package/esm/src/apiKeys/betterAuth.js +164 -0
  7. package/esm/src/apiKeys/credentials.d.ts +37 -2
  8. package/esm/src/apiKeys/credentials.d.ts.map +1 -1
  9. package/esm/src/apiKeys/credentials.js +69 -8
  10. package/esm/src/apiKeys/lifecycle.d.ts +41 -0
  11. package/esm/src/apiKeys/lifecycle.d.ts.map +1 -0
  12. package/esm/src/apiKeys/lifecycle.js +6 -0
  13. package/esm/src/apiKeys/limits.d.ts +132 -0
  14. package/esm/src/apiKeys/limits.d.ts.map +1 -0
  15. package/esm/src/apiKeys/limits.js +246 -0
  16. package/esm/src/apiKeys/mod.d.ts +4 -0
  17. package/esm/src/apiKeys/mod.d.ts.map +1 -1
  18. package/esm/src/apiKeys/mod.js +4 -0
  19. package/esm/src/apiKeys/permissions.d.ts +56 -0
  20. package/esm/src/apiKeys/permissions.d.ts.map +1 -0
  21. package/esm/src/apiKeys/permissions.js +128 -0
  22. package/esm/src/apiKeys/policy.d.ts +3 -1
  23. package/esm/src/apiKeys/policy.d.ts.map +1 -1
  24. package/esm/src/apiKeys/policy.js +3 -1
  25. package/esm/src/apiKeys/types.d.ts +68 -1
  26. package/esm/src/apiKeys/types.d.ts.map +1 -1
  27. package/esm/src/cli/localDb.d.ts +28 -0
  28. package/esm/src/cli/localDb.d.ts.map +1 -0
  29. package/esm/src/cli/localDb.js +366 -0
  30. package/esm/src/cli/localDevLock.d.ts +97 -0
  31. package/esm/src/cli/localDevLock.d.ts.map +1 -0
  32. package/esm/src/cli/localDevLock.js +312 -0
  33. package/esm/src/cli/localDevPackage.d.ts +172 -0
  34. package/esm/src/cli/localDevPackage.d.ts.map +1 -0
  35. package/esm/src/cli/localDevPackage.js +617 -0
  36. package/esm/src/cli/migrationEnv.d.ts +19 -0
  37. package/esm/src/cli/migrationEnv.d.ts.map +1 -1
  38. package/esm/src/cli/migrationEnv.js +44 -1
  39. package/esm/src/cli/mod.d.ts +69 -4
  40. package/esm/src/cli/mod.d.ts.map +1 -1
  41. package/esm/src/cli/mod.js +2822 -419
  42. package/esm/src/cli/projectTooling.d.ts +19 -1
  43. package/esm/src/cli/projectTooling.d.ts.map +1 -1
  44. package/esm/src/cli/projectTooling.js +142 -12
  45. package/esm/src/mui/apiKeys.d.ts +123 -17
  46. package/esm/src/mui/apiKeys.d.ts.map +1 -1
  47. package/esm/src/mui/apiKeys.js +219 -78
  48. package/esm/src/mui/apiKeysView.d.ts +145 -0
  49. package/esm/src/mui/apiKeysView.d.ts.map +1 -1
  50. package/esm/src/mui/apiKeysView.js +278 -0
  51. package/esm/src/next/apiKeys/mod.d.ts +8 -1
  52. package/esm/src/next/apiKeys/mod.d.ts.map +1 -1
  53. package/esm/src/next/apiKeys/mod.js +5 -2
  54. package/package.json +2 -6
  55. package/script/src/apiKeys/authorize.d.ts.map +1 -1
  56. package/script/src/apiKeys/authorize.js +71 -0
  57. package/script/src/apiKeys/betterAuth.d.ts +123 -0
  58. package/script/src/apiKeys/betterAuth.d.ts.map +1 -0
  59. package/script/src/apiKeys/betterAuth.js +169 -0
  60. package/script/src/apiKeys/credentials.d.ts +37 -2
  61. package/script/src/apiKeys/credentials.d.ts.map +1 -1
  62. package/script/src/apiKeys/credentials.js +71 -8
  63. package/script/src/apiKeys/lifecycle.d.ts +41 -0
  64. package/script/src/apiKeys/lifecycle.d.ts.map +1 -0
  65. package/script/src/apiKeys/lifecycle.js +7 -0
  66. package/script/src/apiKeys/limits.d.ts +132 -0
  67. package/script/src/apiKeys/limits.d.ts.map +1 -0
  68. package/script/src/apiKeys/limits.js +254 -0
  69. package/script/src/apiKeys/mod.d.ts +4 -0
  70. package/script/src/apiKeys/mod.d.ts.map +1 -1
  71. package/script/src/apiKeys/mod.js +4 -0
  72. package/script/src/apiKeys/permissions.d.ts +56 -0
  73. package/script/src/apiKeys/permissions.d.ts.map +1 -0
  74. package/script/src/apiKeys/permissions.js +136 -0
  75. package/script/src/apiKeys/policy.d.ts +3 -1
  76. package/script/src/apiKeys/policy.d.ts.map +1 -1
  77. package/script/src/apiKeys/policy.js +3 -1
  78. package/script/src/apiKeys/types.d.ts +68 -1
  79. package/script/src/apiKeys/types.d.ts.map +1 -1
  80. package/script/src/cli/localDb.d.ts +28 -0
  81. package/script/src/cli/localDb.d.ts.map +1 -0
  82. package/script/src/cli/localDb.js +370 -0
  83. package/script/src/cli/localDevLock.d.ts +97 -0
  84. package/script/src/cli/localDevLock.d.ts.map +1 -0
  85. package/script/src/cli/localDevLock.js +320 -0
  86. package/script/src/cli/localDevPackage.d.ts +172 -0
  87. package/script/src/cli/localDevPackage.d.ts.map +1 -0
  88. package/script/src/cli/localDevPackage.js +635 -0
  89. package/script/src/cli/migrationEnv.d.ts +19 -0
  90. package/script/src/cli/migrationEnv.d.ts.map +1 -1
  91. package/script/src/cli/migrationEnv.js +48 -1
  92. package/script/src/cli/mod.d.ts +69 -4
  93. package/script/src/cli/mod.d.ts.map +1 -1
  94. package/script/src/cli/mod.js +2823 -419
  95. package/script/src/cli/projectTooling.d.ts +19 -1
  96. package/script/src/cli/projectTooling.d.ts.map +1 -1
  97. package/script/src/cli/projectTooling.js +176 -12
  98. package/script/src/mui/apiKeys.d.ts +123 -17
  99. package/script/src/mui/apiKeys.d.ts.map +1 -1
  100. package/script/src/mui/apiKeys.js +220 -77
  101. package/script/src/mui/apiKeysView.d.ts +145 -0
  102. package/script/src/mui/apiKeysView.d.ts.map +1 -1
  103. package/script/src/mui/apiKeysView.js +291 -0
  104. package/script/src/next/apiKeys/mod.d.ts +8 -1
  105. package/script/src/next/apiKeys/mod.d.ts.map +1 -1
  106. package/script/src/next/apiKeys/mod.js +5 -2
  107. package/skills/loom/SKILL.md +116 -18
  108. package/skills/loom-api-keys/SKILL.md +101 -7
  109. package/skills/loom-auth/SKILL.md +9 -0
  110. package/skills/loom-db/SKILL.md +33 -1
@@ -1,4 +1,14 @@
1
1
  "use client";
2
+ /**
3
+ * MUI components for API-key management.
4
+ *
5
+ * Requires `@mui/material` 6 or newer (TextField `slotProps`), although the
6
+ * package's optional `@mui/material` peer stays `>=5` for `mui/mail` and
7
+ * `mui/confirm`. The dialogs track pending requests with React 19 async
8
+ * transitions; on React 18 they work but do not disable while pending.
9
+ *
10
+ * @module
11
+ */
2
12
  import Alert from "@mui/material/Alert";
3
13
  import Box from "@mui/material/Box";
4
14
  import Button from "@mui/material/Button";
@@ -24,7 +34,8 @@ import TextField from "@mui/material/TextField";
24
34
  import Tooltip from "@mui/material/Tooltip";
25
35
  import Typography from "@mui/material/Typography";
26
36
  import React from "react";
27
- import { countryCodeToFlagEmoji, formatApiKeyDate, getApiKeyStatus, } from "./apiKeysView.js";
37
+ import { describeApiKeyTransports } from "../apiKeys/credentials.js";
38
+ import { API_KEY_CREATE_FAILED_MESSAGE, API_KEY_RENAME_FAILED_MESSAGE, API_KEY_REVOKE_FAILED_MESSAGE, countryCodeToFlagEmoji, formatApiKeyDate, getApiKeyAuditReason, getApiKeyCustomExpiryInputBounds, getApiKeyExpiryOptions, getApiKeyStatus, getApiKeyTransportGuidanceCopy, resolveApiKeyCreateActionResult, resolveApiKeyCreateInput, resolveApiKeyMutationResult, resolveApiKeyRename, resolveApiKeyThrownErrorMessage, } from "./apiKeysView.js";
28
39
  export * from "./apiKeysView.js";
29
40
  function IpCountry(props) {
30
41
  const flag = countryCodeToFlagEmoji(props.countryCode);
@@ -37,57 +48,68 @@ function IpCountry(props) {
37
48
  props.ipAddress));
38
49
  }
39
50
  export function ApiKeyCreateDialog(props) {
51
+ const expiryOptions = getApiKeyExpiryOptions({
52
+ allowNoExpiry: props.allowNoExpiry,
53
+ expiryPresetDays: props.expiryPresetDays,
54
+ limits: props.limits,
55
+ });
56
+ const defaultExpiry = expiryOptions[0].value;
40
57
  const [name, setName] = React.useState("");
41
58
  const [scopeIds, setScopeIds] = React.useState([]);
42
- const [expiry, setExpiry] = React.useState("never");
59
+ const [expiryChoice, setExpiry] = React.useState(defaultExpiry);
43
60
  const [customExpiry, setCustomExpiry] = React.useState("");
44
61
  const [localError, setLocalError] = React.useState(null);
45
62
  const [pending, startTransition] = React.useTransition();
63
+ // Reference time for the custom input's min/max. It is refreshed when the
64
+ // dialog opens, when the input is chosen, focused, or changed, and on
65
+ // submit, so the bounds are never older than the last interaction. A value
66
+ // picked at the minimum and submitted more than the tolerance later is
67
+ // genuinely too soon and is rejected with the server's message.
68
+ const [boundsTime, setBoundsTime] = React.useState(() => Date.now());
69
+ const [wasOpen, setWasOpen] = React.useState(props.open);
70
+ if (props.open !== wasOpen) {
71
+ setWasOpen(props.open);
72
+ if (props.open)
73
+ setBoundsTime(Date.now());
74
+ }
75
+ // Fall back to the default if changed props removed the chosen option.
76
+ const expiry = expiryOptions.some((option) => option.value === expiryChoice)
77
+ ? expiryChoice
78
+ : defaultExpiry;
79
+ const customBounds = expiry === "custom"
80
+ ? getApiKeyCustomExpiryInputBounds(props.limits, boundsTime)
81
+ : null;
46
82
  const close = () => {
47
83
  if (!pending)
48
84
  props.onClose();
49
85
  };
50
86
  const submit = () => {
51
- const trimmedName = name.trim();
52
- if (!trimmedName) {
53
- setLocalError("Enter a name for this key.");
54
- return;
55
- }
56
- if (!scopeIds.length) {
57
- setLocalError("Choose at least one scope.");
87
+ const now = Date.now();
88
+ // A failed check below shows the picker's minimum as of now.
89
+ setBoundsTime(now);
90
+ const input = resolveApiKeyCreateInput({ customExpiry, expiry, name, scopeIds }, { allowNoExpiry: props.allowNoExpiry, limits: props.limits, now });
91
+ if (!input.ok) {
92
+ setLocalError(input.message);
58
93
  return;
59
94
  }
60
- let expiresAt = null;
61
- if (expiry === "custom") {
62
- const parsed = new Date(customExpiry);
63
- if (!customExpiry || Number.isNaN(parsed.valueOf()) || parsed <= new Date()) {
64
- setLocalError("Choose a future expiry date.");
65
- return;
66
- }
67
- expiresAt = parsed.toISOString();
68
- }
69
- else if (expiry !== "never") {
70
- expiresAt = new Date(Date.now() + Number(expiry) * 86_400_000)
71
- .toISOString();
72
- }
73
95
  setLocalError(null);
74
96
  startTransition(async () => {
75
97
  try {
76
- const result = await props.onCreate({
77
- expiresAt,
78
- name: trimmedName,
79
- scopeIds,
80
- });
81
- props.onCreated(result);
98
+ const result = resolveApiKeyCreateActionResult(await props.onCreate(input.value));
99
+ if (!result.ok) {
100
+ // Keep every field so the user can correct the input.
101
+ setLocalError(result.message);
102
+ return;
103
+ }
104
+ props.onCreated(result.created);
82
105
  setName("");
83
106
  setScopeIds([]);
84
- setExpiry("never");
107
+ setExpiry(defaultExpiry);
108
+ setCustomExpiry("");
85
109
  props.onClose();
86
110
  }
87
111
  catch (error) {
88
- setLocalError(error instanceof Error
89
- ? error.message
90
- : "The key could not be created.");
112
+ setLocalError(resolveApiKeyThrownErrorMessage(error, props.thrownErrorMessages ?? "show", API_KEY_CREATE_FAILED_MESSAGE));
91
113
  }
92
114
  });
93
115
  };
@@ -102,13 +124,18 @@ export function ApiKeyCreateDialog(props) {
102
124
  React.createElement(FormControlLabel, { control: React.createElement(Checkbox, { checked: scopeIds.includes(scope.id), onChange: (_, checked) => setScopeIds((current) => checked
103
125
  ? [...current, scope.id]
104
126
  : current.filter((id) => id !== scope.id)) }), disabled: pending || scope.disabled, label: scope.label }))))),
105
- React.createElement(TextField, { select: true, label: "Expiry", value: expiry, onChange: (event) => setExpiry(event.target.value), disabled: pending, slotProps: { select: { native: true } } },
106
- React.createElement("option", { value: "never" }, "Never"),
107
- React.createElement("option", { value: "7" }, "7 days"),
108
- React.createElement("option", { value: "30" }, "30 days"),
109
- React.createElement("option", { value: "custom" }, "Custom date")),
110
- expiry === "custom"
111
- ? (React.createElement(TextField, { type: "datetime-local", label: "Expires at", value: customExpiry, onChange: (event) => setCustomExpiry(event.target.value), slotProps: { inputLabel: { shrink: true } }, disabled: pending }))
127
+ React.createElement(TextField, { select: true, label: "Expiry", value: expiry, onChange: (event) => {
128
+ setExpiry(event.target.value);
129
+ setBoundsTime(Date.now());
130
+ }, disabled: pending, slotProps: { select: { native: true } } }, expiryOptions.map((option) => (React.createElement("option", { key: option.value, value: option.value }, option.label)))),
131
+ customBounds
132
+ ? (React.createElement(TextField, { type: "datetime-local", label: "Expires at", value: customExpiry, onChange: (event) => {
133
+ setCustomExpiry(event.target.value);
134
+ setBoundsTime(Date.now());
135
+ }, onFocus: () => setBoundsTime(Date.now()), slotProps: {
136
+ htmlInput: { max: customBounds.max, min: customBounds.min },
137
+ inputLabel: { shrink: true },
138
+ }, disabled: pending }))
112
139
  : null,
113
140
  localError || props.error
114
141
  ? React.createElement(Alert, { severity: "error" }, localError ?? props.error)
@@ -117,6 +144,17 @@ export function ApiKeyCreateDialog(props) {
117
144
  React.createElement(Button, { onClick: close, disabled: pending }, "Cancel"),
118
145
  React.createElement(Button, { onClick: submit, variant: "contained", disabled: pending }, pending ? "Creating…" : "Create key"))));
119
146
  }
147
+ /**
148
+ * Tells key holders how to send a key: the preferred transport (Bearer when
149
+ * enabled), the other accepted ones, and a URL-leakage warning when query
150
+ * credentials are enabled.
151
+ */
152
+ export function ApiKeyTransportGuidance(props) {
153
+ const copy = getApiKeyTransportGuidanceCopy(describeApiKeyTransports(props.credentialOptions));
154
+ return (React.createElement(Alert, { severity: copy.severity, sx: props.sx }, [copy.primary, copy.alternatives, copy.queryWarning]
155
+ .filter((line) => line !== null)
156
+ .map((line) => (React.createElement(Box, { key: line, component: "span", sx: { display: "block" } }, line)))));
157
+ }
120
158
  export function ApiKeySecretDialog(props) {
121
159
  const [copied, setCopied] = React.useState(false);
122
160
  React.useEffect(() => setCopied(false), [props.result]);
@@ -136,9 +174,11 @@ export function ApiKeySecretDialog(props) {
136
174
  React.createElement(TextField, { value: props.result?.key ?? "", fullWidth: true, margin: "normal", label: "API key", slotProps: {
137
175
  htmlInput: { readOnly: true, "aria-label": "New API key" },
138
176
  } }),
139
- props.queryCredentialsEnabled
140
- ? (React.createElement(Alert, { severity: "warning" }, "Query-parameter keys can appear in browser history, access logs, copied links, and referrers. Prefer an authorization header."))
141
- : null,
177
+ props.credentialOptions
178
+ ? (React.createElement(ApiKeyTransportGuidance, { credentialOptions: props.credentialOptions }))
179
+ : props.queryCredentialsEnabled
180
+ ? (React.createElement(Alert, { severity: "warning" }, "Query-parameter keys can appear in browser history, access logs, copied links, and referrers. Prefer an authorization header."))
181
+ : null,
142
182
  copied
143
183
  ? React.createElement(Alert, { severity: "success", sx: { mt: 2 } }, "Copied.")
144
184
  : null),
@@ -146,36 +186,101 @@ export function ApiKeySecretDialog(props) {
146
186
  React.createElement(Button, { onClick: copy, disabled: !props.result }, "Copy key"),
147
187
  React.createElement(Button, { onClick: props.onClose, variant: "contained" }, "I saved it"))));
148
188
  }
189
+ /**
190
+ * Edits one key name with inline validation. A failed rename keeps the dialog
191
+ * open with the typed value; an unchanged name closes it without a call.
192
+ */
193
+ export function ApiKeyRenameDialog(props) {
194
+ const formId = React.useId();
195
+ const [name, setName] = React.useState(props.currentName);
196
+ const [error, setError] = React.useState(null);
197
+ const [pending, startTransition] = React.useTransition();
198
+ // Start from the current name each time the dialog opens.
199
+ const [wasOpen, setWasOpen] = React.useState(props.open);
200
+ if (props.open !== wasOpen) {
201
+ setWasOpen(props.open);
202
+ if (props.open) {
203
+ setName(props.currentName);
204
+ setError(null);
205
+ }
206
+ }
207
+ const close = () => {
208
+ if (!pending)
209
+ props.onClose();
210
+ };
211
+ const submit = (event) => {
212
+ event.preventDefault();
213
+ if (pending)
214
+ return;
215
+ const resolved = resolveApiKeyRename(name, props.currentName, props.limits);
216
+ if (!resolved.ok) {
217
+ setError(resolved.message);
218
+ return;
219
+ }
220
+ if (resolved.value.unchanged) {
221
+ props.onClose();
222
+ return;
223
+ }
224
+ setError(null);
225
+ startTransition(async () => {
226
+ try {
227
+ const result = resolveApiKeyMutationResult(await props.onRename(resolved.value.name), API_KEY_RENAME_FAILED_MESSAGE);
228
+ if (!result.ok) {
229
+ setError(result.message);
230
+ return;
231
+ }
232
+ props.onClose();
233
+ }
234
+ catch {
235
+ setError(API_KEY_RENAME_FAILED_MESSAGE);
236
+ }
237
+ });
238
+ };
239
+ return (React.createElement(Dialog, { open: props.open, onClose: close, fullWidth: true, maxWidth: "xs", "aria-labelledby": `${formId}-title` },
240
+ React.createElement(DialogTitle, { id: `${formId}-title` }, "Rename API key"),
241
+ React.createElement(DialogContent, null,
242
+ React.createElement(Box, { component: "form", id: formId, onSubmit: submit, noValidate: true },
243
+ React.createElement(TextField, { label: "Key name", value: name, required: true, autoFocus: true, fullWidth: true, margin: "dense", onChange: (event) => setName(event.target.value), disabled: pending, error: error !== null, helperText: error ?? undefined }))),
244
+ React.createElement(DialogActions, null,
245
+ React.createElement(Button, { onClick: close, disabled: pending }, "Cancel"),
246
+ React.createElement(Button, { type: "submit", form: formId, variant: "contained", disabled: pending }, pending ? "Renaming…" : "Rename"))));
247
+ }
149
248
  function ScopeChips({ scopes }) {
150
- return (React.createElement(Stack, { direction: "row", gap: 0.5, flexWrap: "wrap" }, scopes.map((scope) => React.createElement(Chip, { key: scope, size: "small", label: scope }))));
249
+ return (React.createElement(Stack, { direction: "row", sx: { flexWrap: "wrap", gap: 0.5 } }, scopes.map((scope) => React.createElement(Chip, { key: scope, size: "small", label: scope }))));
151
250
  }
152
251
  export function ApiKeysTable(props) {
153
252
  const [pendingId, setPendingId] = React.useState(null);
253
+ const [actionError, setActionError] = React.useState(null);
254
+ const [renameRow, setRenameRow] = React.useState(null);
255
+ const [renameOpen, setRenameOpen] = React.useState(false);
154
256
  const revoke = async (row) => {
155
257
  if (!props.onRevoke ||
156
258
  !globalThis.confirm(`Revoke “${row.name}”? This cannot be undone.`))
157
259
  return;
260
+ setActionError(null);
158
261
  setPendingId(row.id);
159
262
  try {
160
- await props.onRevoke(row.id);
263
+ const result = resolveApiKeyMutationResult(await props.onRevoke(row.id), API_KEY_REVOKE_FAILED_MESSAGE);
264
+ if (!result.ok) {
265
+ setActionError({ message: result.message, rowId: row.id });
266
+ }
267
+ }
268
+ catch {
269
+ setActionError({
270
+ message: API_KEY_REVOKE_FAILED_MESSAGE,
271
+ rowId: row.id,
272
+ });
161
273
  }
162
274
  finally {
163
275
  setPendingId(null);
164
276
  }
165
277
  };
166
- const rename = async (row) => {
278
+ const rename = (row) => {
167
279
  if (!props.onRename)
168
280
  return;
169
- const name = globalThis.prompt("New key name", row.name)?.trim();
170
- if (!name || name === row.name)
171
- return;
172
- setPendingId(row.id);
173
- try {
174
- await props.onRename(row.id, name);
175
- }
176
- finally {
177
- setPendingId(null);
178
- }
281
+ setActionError(null);
282
+ setRenameRow(row);
283
+ setRenameOpen(true);
179
284
  };
180
285
  if (props.loading) {
181
286
  return (React.createElement(Box, { sx: { py: 6, textAlign: "center" } },
@@ -187,7 +292,15 @@ export function ApiKeysTable(props) {
187
292
  const actions = (row) => (React.createElement(Stack, { direction: "row", spacing: 1 },
188
293
  React.createElement(Button, { size: "small", onClick: () => rename(row), disabled: !props.onRename || pendingId === row.id }, "Rename"),
189
294
  React.createElement(Button, { size: "small", color: "error", onClick: () => revoke(row), disabled: !props.onRevoke || !row.enabled || pendingId === row.id }, "Revoke")));
295
+ const errorRowName = actionError
296
+ ? props.rows.find((row) => row.id === actionError.rowId)?.name
297
+ : undefined;
190
298
  return (React.createElement(React.Fragment, null,
299
+ actionError
300
+ ? (React.createElement(Alert, { severity: "error", onClose: () => setActionError(null), sx: { mb: 1.5 } },
301
+ errorRowName ? `“${errorRowName}”: ` : "",
302
+ actionError.message))
303
+ : null,
191
304
  React.createElement(TableContainer, { component: Paper, variant: "outlined", sx: { display: { xs: "none", md: "block" } } },
192
305
  React.createElement(Table, { size: "small", "aria-label": props.admin ? "All user API keys" : "Your API keys" },
193
306
  React.createElement(TableHead, null,
@@ -208,7 +321,7 @@ export function ApiKeysTable(props) {
208
321
  React.createElement(Typography, { variant: "caption", color: "text.secondary" }, row.ownerEmail)))
209
322
  : null,
210
323
  React.createElement(TableCell, null,
211
- React.createElement(Typography, { variant: "body2", fontWeight: 600 }, row.name),
324
+ React.createElement(Typography, { variant: "body2", sx: { fontWeight: 600 } }, row.name),
212
325
  React.createElement(Typography, { variant: "caption", color: "text.secondary" }, row.start ?? "No visible prefix")),
213
326
  React.createElement(TableCell, null,
214
327
  React.createElement(Chip, { size: "small", color: getApiKeyStatus(row) === "Active"
@@ -221,19 +334,19 @@ export function ApiKeysTable(props) {
221
334
  React.createElement(TableCell, null,
222
335
  formatApiKeyDate(row.lastUsedAt),
223
336
  row.lastUsedScope
224
- ? (React.createElement(Typography, { display: "block", variant: "caption" }, row.lastUsedScope))
337
+ ? (React.createElement(Typography, { variant: "caption", sx: { display: "block" } }, row.lastUsedScope))
225
338
  : null,
226
339
  row.lastUsedCountryCode || row.lastUsedIpAddress
227
- ? (React.createElement(Typography, { display: "block", variant: "caption" },
340
+ ? (React.createElement(Typography, { variant: "caption", sx: { display: "block" } },
228
341
  React.createElement(IpCountry, { countryCode: row.lastUsedCountryCode, ipAddress: row.lastUsedIpAddress })))
229
342
  : null),
230
343
  props.extraColumns?.map((column) => (React.createElement(TableCell, { key: column.id }, column.render(row)))),
231
344
  React.createElement(TableCell, { align: "right" }, actions(row)))))))),
232
345
  React.createElement(Stack, { spacing: 1.5, sx: { display: { xs: "flex", md: "none" } } }, props.rows.map((row) => (React.createElement(Paper, { key: row.id, variant: "outlined", sx: { p: 2 } },
233
346
  React.createElement(Stack, { spacing: 1 },
234
- React.createElement(Stack, { direction: "row", justifyContent: "space-between" },
347
+ React.createElement(Stack, { direction: "row", sx: { justifyContent: "space-between" } },
235
348
  React.createElement(Box, null,
236
- React.createElement(Typography, { fontWeight: 600 }, row.name),
349
+ React.createElement(Typography, { sx: { fontWeight: 600 } }, row.name),
237
350
  React.createElement(Typography, { variant: "caption", color: "text.secondary" }, row.start)),
238
351
  React.createElement(Chip, { size: "small", label: getApiKeyStatus(row) })),
239
352
  props.admin
@@ -249,18 +362,25 @@ export function ApiKeysTable(props) {
249
362
  " · ",
250
363
  React.createElement(IpCountry, { countryCode: row.lastUsedCountryCode, ipAddress: row.lastUsedIpAddress })))
251
364
  : null),
252
- actions(row))))))));
365
+ actions(row)))))),
366
+ props.onRename && renameRow
367
+ ? (React.createElement(ApiKeyRenameDialog, { open: renameOpen, currentName: renameRow.name, limits: props.limits, onClose: () => setRenameOpen(false), onRename: (name) => props.onRename(renameRow.id, name) }))
368
+ : null));
253
369
  }
254
370
  export function AdminApiKeysTable(props) {
255
371
  return React.createElement(ApiKeysTable, { ...props, admin: true });
256
372
  }
257
373
  export function ApiKeyAuditTable(props) {
374
+ // Inferring the key column keeps tables without snapshots exactly as before.
375
+ const showKey = props.showKey ??
376
+ props.rows.some((row) => row.keyName || row.keyStart);
258
377
  return (React.createElement(Paper, { variant: "outlined" },
259
378
  React.createElement(TableContainer, null,
260
379
  React.createElement(Table, { size: "small", "aria-label": "API-key audit history" },
261
380
  React.createElement(TableHead, null,
262
381
  React.createElement(TableRow, null,
263
382
  React.createElement(TableCell, null, "Time"),
383
+ showKey ? React.createElement(TableCell, null, "Key") : null,
264
384
  React.createElement(TableCell, null, "Scope"),
265
385
  React.createElement(TableCell, null, "Operation"),
266
386
  React.createElement(TableCell, null, "Transport"),
@@ -269,33 +389,54 @@ export function ApiKeyAuditTable(props) {
269
389
  React.createElement(TableCell, null, "Context"))),
270
390
  React.createElement(TableBody, null, props.loading
271
391
  ? (React.createElement(TableRow, null,
272
- React.createElement(TableCell, { colSpan: 7, align: "center" },
392
+ React.createElement(TableCell, { colSpan: showKey ? 8 : 7, align: "center" },
273
393
  React.createElement(CircularProgress, { size: 24, "aria-label": "Loading audit history" }))))
274
- : props.rows.map((row) => (React.createElement(TableRow, { key: row.id },
275
- React.createElement(TableCell, null, formatApiKeyDate(row.occurredAt)),
276
- React.createElement(TableCell, null, row.scope),
277
- React.createElement(TableCell, null, row.operation),
278
- React.createElement(TableCell, null, row.transport ?? "—"),
279
- React.createElement(TableCell, null,
280
- React.createElement(Typography, { variant: "body2" },
281
- React.createElement(IpCountry, { countryCode: row.countryCode, ipAddress: row.ipAddress })),
282
- React.createElement(Typography, { variant: "caption", color: "text.secondary" }, row.userAgent ?? "")),
283
- React.createElement(TableCell, null, [row.authorizationOutcome, row.operationOutcome].filter(Boolean).join(" / ")),
284
- React.createElement(TableCell, null, [row.pageName, row.functionName, row.actionName].filter(Boolean).join(" · ") || "—"))))))),
394
+ : props.rows.map((row) => {
395
+ const reason = getApiKeyAuditReason(row);
396
+ return (React.createElement(TableRow, { key: row.id },
397
+ React.createElement(TableCell, null, formatApiKeyDate(row.occurredAt)),
398
+ showKey
399
+ ? (React.createElement(TableCell, null,
400
+ React.createElement(Typography, { variant: "body2" }, row.keyName ?? "—"),
401
+ row.keyStart
402
+ ? (React.createElement(Typography, { variant: "caption", color: "text.secondary" }, row.keyStart))
403
+ : null))
404
+ : null,
405
+ React.createElement(TableCell, null, row.scope),
406
+ React.createElement(TableCell, null, row.operation),
407
+ React.createElement(TableCell, null, row.transport ?? "—"),
408
+ React.createElement(TableCell, null,
409
+ React.createElement(Typography, { variant: "body2" },
410
+ React.createElement(IpCountry, { countryCode: row.countryCode, ipAddress: row.ipAddress })),
411
+ React.createElement(Typography, { variant: "caption", color: "text.secondary" }, row.userAgent ?? "")),
412
+ React.createElement(TableCell, null,
413
+ [row.authorizationOutcome, row.operationOutcome].filter(Boolean).join(" / "),
414
+ reason
415
+ ? (React.createElement(Typography, { variant: "caption", color: "text.secondary", sx: { display: "block" } }, reason))
416
+ : null),
417
+ React.createElement(TableCell, null, [row.pageName, row.functionName, row.actionName].filter(Boolean).join(" · ") || "—")));
418
+ })))),
285
419
  React.createElement(TablePagination, { component: "div", count: props.count, page: props.page, rowsPerPage: props.rowsPerPage, rowsPerPageOptions: [props.rowsPerPage], onPageChange: (_event, page) => props.onPageChange(page) })));
286
420
  }
287
421
  export function ApiKeysManager(props) {
288
422
  const [createOpen, setCreateOpen] = React.useState(false);
289
423
  const [secret, setSecret] = React.useState(null);
290
424
  return (React.createElement(Stack, { spacing: 2 },
291
- React.createElement(Stack, { direction: { xs: "column", sm: "row" }, justifyContent: "space-between", alignItems: { sm: "center" }, gap: 1 },
425
+ React.createElement(Stack, { direction: { xs: "column", sm: "row" }, sx: {
426
+ alignItems: { sm: "center" },
427
+ gap: 1,
428
+ justifyContent: "space-between",
429
+ } },
292
430
  React.createElement(Box, null,
293
431
  React.createElement(Typography, { variant: "h5", component: "h1" }, "API keys"),
294
432
  React.createElement(Typography, { color: "text.secondary" }, "Create scoped credentials for tools you trust.")),
295
433
  React.createElement(Button, { variant: "contained", onClick: () => setCreateOpen(true), disabled: !props.onCreate }, "Create API key")),
296
434
  props.error ? React.createElement(Alert, { severity: "error" }, props.error) : null,
297
- React.createElement(ApiKeysTable, { rows: props.rows, loading: props.loading, scopes: props.scopes, extraColumns: props.extraColumns, onRename: props.onRename, onRevoke: props.onRevoke }),
298
- React.createElement(ApiKeyCreateDialog, { open: createOpen, onClose: () => setCreateOpen(false), scopes: props.scopes, error: props.error, onCreate: props.onCreate ??
299
- (() => Promise.reject(new Error("Key creation is unavailable."))), onCreated: setSecret }),
300
- React.createElement(ApiKeySecretDialog, { open: secret !== null, result: secret, queryCredentialsEnabled: props.queryCredentialsEnabled, onClose: () => setSecret(null) })));
435
+ React.createElement(ApiKeysTable, { rows: props.rows, loading: props.loading, scopes: props.scopes, extraColumns: props.extraColumns, limits: props.limits, onRename: props.onRename, onRevoke: props.onRevoke }),
436
+ React.createElement(ApiKeyCreateDialog, { open: createOpen, onClose: () => setCreateOpen(false), scopes: props.scopes, error: props.error, limits: props.limits, allowNoExpiry: props.allowNoExpiry, thrownErrorMessages: props.thrownErrorMessages, expiryPresetDays: props.expiryPresetDays, onCreate: props.onCreate ??
437
+ (() => Promise.resolve({
438
+ message: "Key creation is unavailable.",
439
+ ok: false,
440
+ })), onCreated: setSecret }),
441
+ React.createElement(ApiKeySecretDialog, { open: secret !== null, result: secret, credentialOptions: props.credentialOptions, queryCredentialsEnabled: props.queryCredentialsEnabled, onClose: () => setSecret(null) })));
301
442
  }
@@ -1,3 +1,6 @@
1
+ import { type ApiKeyLimits, type ApiKeyValidationResult } from "../apiKeys/limits.js";
2
+ import type { ApiKeyTransportDescription } from "../apiKeys/credentials.js";
3
+ import type { ApiKeyCreateActionResult, ApiKeyCreateInput, ApiKeyMutationResult } from "../apiKeys/lifecycle.js";
1
4
  export interface ApiKeyScopeDefinition {
2
5
  description?: string;
3
6
  disabled?: boolean;
@@ -31,18 +34,160 @@ export interface ApiKeyAuditRow {
31
34
  functionName?: string | null;
32
35
  id: string;
33
36
  ipAddress?: string | null;
37
+ /** Key name snapshot recorded with the event, when it was attributed. */
38
+ keyName?: string | null;
39
+ /** Non-secret key prefix snapshot recorded with the event. */
40
+ keyStart?: string | null;
34
41
  occurredAt: string;
35
42
  operation: string;
36
43
  operationOutcome?: string | null;
37
44
  pageName?: string | null;
45
+ /**
46
+ * A label for why the event was denied or failed, shown as is. Takes
47
+ * precedence over `reasonCode`.
48
+ */
49
+ reason?: string | null;
50
+ /**
51
+ * The audit event's reason code, such as `insufficient_permission`. Shown
52
+ * through `apiKeyAuditReasonLabel`, which never displays the code itself.
53
+ */
54
+ reasonCode?: string | null;
38
55
  scope: string;
39
56
  transport?: string | null;
40
57
  userAgent?: string | null;
41
58
  }
59
+ /** Shown for a reason code that `apiKeyAuditReasonLabel` does not know. */
60
+ export declare const API_KEY_AUDIT_OTHER_REASON_LABEL = "Other reason";
61
+ /**
62
+ * Maps an audit reason code to a short label. Only codes Loom records have
63
+ * labels. Any other code shows `API_KEY_AUDIT_OTHER_REASON_LABEL` and is never
64
+ * displayed itself: a stored code is not known to be free of secrets, and a
65
+ * Better Auth key without a prefix looks like any identifier. No code yields
66
+ * `null`; label an app-specific code by passing `reason` instead.
67
+ */
68
+ export declare function apiKeyAuditReasonLabel(code?: string | null): string | null;
69
+ /** The reason to show for an audit row: its label, else its code's label. */
70
+ export declare function getApiKeyAuditReason(row: ApiKeyAuditRow): string | null;
42
71
  /** Converts an ISO alpha-2 country code to its Unicode regional flag. */
43
72
  export declare function countryCodeToFlagEmoji(countryCode?: string | null): string | null;
44
73
  /** Formats ISO date values consistently while preserving an empty state. */
45
74
  export declare function formatApiKeyDate(value?: string | null): string;
46
75
  export declare function getApiKeyStatus(row: ApiKeyRow, now?: number): "Revoked" | "Expired" | "Active";
47
76
  export declare function getApiKeyVisibleColumnIds(admin?: boolean): string[];
77
+ export type { ApiKeyActionFailure, ApiKeyCreateActionResult, ApiKeyCreateInput, ApiKeyCreateResult, ApiKeyMutationResult, } from "../apiKeys/lifecycle.js";
78
+ export declare const API_KEY_CREATE_FAILED_MESSAGE = "The key could not be created.";
79
+ export declare const API_KEY_RENAME_FAILED_MESSAGE = "The key could not be renamed.";
80
+ export declare const API_KEY_REVOKE_FAILED_MESSAGE = "The key could not be revoked.";
81
+ /** Expiry presets offered by the create dialog when none are configured. */
82
+ export declare const DEFAULT_API_KEY_EXPIRY_PRESET_DAYS: readonly number[];
83
+ /**
84
+ * Normalizes what an `onCreate` callback resolved to.
85
+ *
86
+ * A value whose `ok` is a boolean is the result form; anything else is the
87
+ * original `ApiKeyCreateResult` form. A success without a usable key and name
88
+ * becomes a failure, so the secret dialog never opens empty.
89
+ */
90
+ export declare function resolveApiKeyCreateActionResult(value: unknown): ApiKeyCreateActionResult;
91
+ /**
92
+ * Normalizes what an `onRename` or `onRevoke` callback resolved to.
93
+ *
94
+ * A value whose `ok` is a boolean is the result form. Anything else, such as
95
+ * the `void` of the original callback form, is a success, as before.
96
+ */
97
+ export declare function resolveApiKeyMutationResult(value: unknown, fallbackMessage: string): ApiKeyMutationResult;
98
+ /** User-facing transport guidance derived from `describeApiKeyTransports`. */
99
+ export interface ApiKeyTransportGuidanceCopy {
100
+ /** The other accepted transports, or `null` when there are none. */
101
+ alternatives: string | null;
102
+ /** How to send a key, or a fallback when no transport is accepted. */
103
+ primary: string;
104
+ /** URL-leakage warning when query credentials are accepted, else `null`. */
105
+ queryWarning: string | null;
106
+ severity: "info" | "warning";
107
+ }
108
+ export declare const API_KEY_NO_TRANSPORT_MESSAGE = "This app does not currently accept API keys in requests.";
109
+ /**
110
+ * Builds transport guidance copy: the preferred transport, the other
111
+ * accepted ones, and a URL-leakage warning when query credentials are
112
+ * accepted. With no accepted transport it returns a plain fallback.
113
+ */
114
+ export declare function getApiKeyTransportGuidanceCopy(description: ApiKeyTransportDescription): ApiKeyTransportGuidanceCopy;
115
+ /**
116
+ * How the create dialog shows an error thrown by `onCreate`: `"show"` (the
117
+ * default, as before) displays its message; `"generic"` shows
118
+ * `API_KEY_CREATE_FAILED_MESSAGE`. Result-form callbacks should use
119
+ * `"generic"`, since their user-facing messages arrive as `{ ok: false }` and
120
+ * a thrown message is internal text in development and Next.js's masked text
121
+ * in production.
122
+ */
123
+ export type ApiKeyThrownErrorMessages = "generic" | "show";
124
+ /** The message to show for an error thrown by a lifecycle callback. */
125
+ export declare function resolveApiKeyThrownErrorMessage(error: unknown, mode: ApiKeyThrownErrorMessages, fallbackMessage: string): string;
126
+ /** Expiry choices for the create dialog. */
127
+ export interface ApiKeyExpiryChoiceOptions {
128
+ /** Offer "Never". Defaults to `true`. */
129
+ allowNoExpiry?: boolean;
130
+ /** Preset lifetimes in days. Defaults to `[7, 30]`. */
131
+ expiryPresetDays?: readonly number[];
132
+ limits?: Partial<ApiKeyLimits>;
133
+ }
134
+ /** One `<option>` of the create dialog's expiry select. */
135
+ export interface ApiKeyExpiryOption {
136
+ label: string;
137
+ /** `"never"`, `"custom"`, or a preset's day count. */
138
+ value: string;
139
+ }
140
+ /**
141
+ * Lists the create dialog's expiry choices: "Never" when allowed, presets
142
+ * within the expiry limits (invalid and duplicate presets are dropped), and
143
+ * "Custom date".
144
+ */
145
+ export declare function getApiKeyExpiryOptions(options?: ApiKeyExpiryChoiceOptions): ApiKeyExpiryOption[];
146
+ /** The create dialog's initial expiry choice: "Never" when allowed. */
147
+ export declare function getDefaultApiKeyExpiryChoice(options?: ApiKeyExpiryChoiceOptions): string;
148
+ /** Formats a time as a `datetime-local` input value in local time. */
149
+ export declare function toDateTimeLocalValue(time: number): string;
150
+ /**
151
+ * `min`/`max` attributes for the custom expiry input, in local time.
152
+ *
153
+ * The input has minute precision, so `min` is rounded up to a whole minute and
154
+ * `max` down; both therefore lie within the limits. `min` is always in the
155
+ * future.
156
+ */
157
+ export declare function getApiKeyCustomExpiryInputBounds(limits?: Partial<ApiKeyLimits>, now?: number): {
158
+ max?: string;
159
+ min: string;
160
+ };
161
+ /** The create dialog's raw field values. */
162
+ export interface ApiKeyCreateFormValues {
163
+ /** `datetime-local` value, used when `expiry` is `"custom"`. */
164
+ customExpiry: string;
165
+ /** An `ApiKeyExpiryOption` value. */
166
+ expiry: string;
167
+ name: string;
168
+ scopeIds: readonly string[];
169
+ }
170
+ /** Validation context for `resolveApiKeyCreateInput`. */
171
+ export interface ApiKeyCreateFormOptions {
172
+ /** Accept "Never". Defaults to `true`. */
173
+ allowNoExpiry?: boolean;
174
+ limits?: Partial<ApiKeyLimits>;
175
+ /** Reference time; defaults to `Date.now()`. */
176
+ now?: number;
177
+ }
178
+ /**
179
+ * Validates the create dialog's fields with the same validators and messages
180
+ * as server-side `validateApiKeyName` and `resolveApiKeyExpiresIn`, and builds
181
+ * the `onCreate` input. The server must still validate: this only spares the
182
+ * user a round trip.
183
+ */
184
+ export declare function resolveApiKeyCreateInput(values: ApiKeyCreateFormValues, options?: ApiKeyCreateFormOptions): ApiKeyValidationResult<ApiKeyCreateInput>;
185
+ /**
186
+ * Validates a rename with the server's name rules. `unchanged` is `true` when
187
+ * the trimmed name equals the current one, so no call is needed.
188
+ */
189
+ export declare function resolveApiKeyRename(name: unknown, currentName: string, limits?: Partial<ApiKeyLimits>): ApiKeyValidationResult<{
190
+ name: string;
191
+ unchanged: boolean;
192
+ }>;
48
193
  //# sourceMappingURL=apiKeysView.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"apiKeysView.d.ts","sourceRoot":"","sources":["../../../src/src/mui/apiKeysView.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CAClD;AAED,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,GAAG,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