@gadicc/loom 1.34.0 → 1.35.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/README.md +126 -49
- package/esm/src/apiKeys/authorize.d.ts.map +1 -1
- package/esm/src/apiKeys/authorize.js +71 -0
- package/esm/src/apiKeys/betterAuth.d.ts +123 -0
- package/esm/src/apiKeys/betterAuth.d.ts.map +1 -0
- package/esm/src/apiKeys/betterAuth.js +164 -0
- package/esm/src/apiKeys/credentials.d.ts +37 -2
- package/esm/src/apiKeys/credentials.d.ts.map +1 -1
- package/esm/src/apiKeys/credentials.js +69 -8
- package/esm/src/apiKeys/lifecycle.d.ts +41 -0
- package/esm/src/apiKeys/lifecycle.d.ts.map +1 -0
- package/esm/src/apiKeys/lifecycle.js +6 -0
- package/esm/src/apiKeys/limits.d.ts +132 -0
- package/esm/src/apiKeys/limits.d.ts.map +1 -0
- package/esm/src/apiKeys/limits.js +246 -0
- package/esm/src/apiKeys/mod.d.ts +4 -0
- package/esm/src/apiKeys/mod.d.ts.map +1 -1
- package/esm/src/apiKeys/mod.js +4 -0
- package/esm/src/apiKeys/permissions.d.ts +56 -0
- package/esm/src/apiKeys/permissions.d.ts.map +1 -0
- package/esm/src/apiKeys/permissions.js +128 -0
- package/esm/src/apiKeys/policy.d.ts +3 -1
- package/esm/src/apiKeys/policy.d.ts.map +1 -1
- package/esm/src/apiKeys/policy.js +3 -1
- package/esm/src/apiKeys/types.d.ts +68 -1
- package/esm/src/apiKeys/types.d.ts.map +1 -1
- package/esm/src/cli/localDevLock.d.ts +97 -0
- package/esm/src/cli/localDevLock.d.ts.map +1 -0
- package/esm/src/cli/localDevLock.js +312 -0
- package/esm/src/cli/localDevPackage.d.ts +172 -0
- package/esm/src/cli/localDevPackage.d.ts.map +1 -0
- package/esm/src/cli/localDevPackage.js +617 -0
- package/esm/src/cli/migrationEnv.d.ts +19 -0
- package/esm/src/cli/migrationEnv.d.ts.map +1 -1
- package/esm/src/cli/migrationEnv.js +44 -1
- package/esm/src/cli/mod.d.ts +69 -4
- package/esm/src/cli/mod.d.ts.map +1 -1
- package/esm/src/cli/mod.js +3060 -451
- package/esm/src/cli/projectTooling.d.ts +19 -1
- package/esm/src/cli/projectTooling.d.ts.map +1 -1
- package/esm/src/cli/projectTooling.js +142 -12
- package/esm/src/mui/apiKeys.d.ts +123 -17
- package/esm/src/mui/apiKeys.d.ts.map +1 -1
- package/esm/src/mui/apiKeys.js +219 -78
- package/esm/src/mui/apiKeysView.d.ts +145 -0
- package/esm/src/mui/apiKeysView.d.ts.map +1 -1
- package/esm/src/mui/apiKeysView.js +278 -0
- package/esm/src/next/apiKeys/mod.d.ts +8 -1
- package/esm/src/next/apiKeys/mod.d.ts.map +1 -1
- package/esm/src/next/apiKeys/mod.js +5 -2
- package/package.json +2 -6
- package/script/src/apiKeys/authorize.d.ts.map +1 -1
- package/script/src/apiKeys/authorize.js +71 -0
- package/script/src/apiKeys/betterAuth.d.ts +123 -0
- package/script/src/apiKeys/betterAuth.d.ts.map +1 -0
- package/script/src/apiKeys/betterAuth.js +169 -0
- package/script/src/apiKeys/credentials.d.ts +37 -2
- package/script/src/apiKeys/credentials.d.ts.map +1 -1
- package/script/src/apiKeys/credentials.js +71 -8
- package/script/src/apiKeys/lifecycle.d.ts +41 -0
- package/script/src/apiKeys/lifecycle.d.ts.map +1 -0
- package/script/src/apiKeys/lifecycle.js +7 -0
- package/script/src/apiKeys/limits.d.ts +132 -0
- package/script/src/apiKeys/limits.d.ts.map +1 -0
- package/script/src/apiKeys/limits.js +254 -0
- package/script/src/apiKeys/mod.d.ts +4 -0
- package/script/src/apiKeys/mod.d.ts.map +1 -1
- package/script/src/apiKeys/mod.js +4 -0
- package/script/src/apiKeys/permissions.d.ts +56 -0
- package/script/src/apiKeys/permissions.d.ts.map +1 -0
- package/script/src/apiKeys/permissions.js +136 -0
- package/script/src/apiKeys/policy.d.ts +3 -1
- package/script/src/apiKeys/policy.d.ts.map +1 -1
- package/script/src/apiKeys/policy.js +3 -1
- package/script/src/apiKeys/types.d.ts +68 -1
- package/script/src/apiKeys/types.d.ts.map +1 -1
- package/script/src/cli/localDevLock.d.ts +97 -0
- package/script/src/cli/localDevLock.d.ts.map +1 -0
- package/script/src/cli/localDevLock.js +320 -0
- package/script/src/cli/localDevPackage.d.ts +172 -0
- package/script/src/cli/localDevPackage.d.ts.map +1 -0
- package/script/src/cli/localDevPackage.js +635 -0
- package/script/src/cli/migrationEnv.d.ts +19 -0
- package/script/src/cli/migrationEnv.d.ts.map +1 -1
- package/script/src/cli/migrationEnv.js +48 -1
- package/script/src/cli/mod.d.ts +69 -4
- package/script/src/cli/mod.d.ts.map +1 -1
- package/script/src/cli/mod.js +3061 -451
- package/script/src/cli/projectTooling.d.ts +19 -1
- package/script/src/cli/projectTooling.d.ts.map +1 -1
- package/script/src/cli/projectTooling.js +176 -12
- package/script/src/mui/apiKeys.d.ts +123 -17
- package/script/src/mui/apiKeys.d.ts.map +1 -1
- package/script/src/mui/apiKeys.js +220 -77
- package/script/src/mui/apiKeysView.d.ts +145 -0
- package/script/src/mui/apiKeysView.d.ts.map +1 -1
- package/script/src/mui/apiKeysView.js +291 -0
- package/script/src/next/apiKeys/mod.d.ts +8 -1
- package/script/src/next/apiKeys/mod.d.ts.map +1 -1
- package/script/src/next/apiKeys/mod.js +5 -2
- package/skills/loom/SKILL.md +125 -18
- package/skills/loom-api-keys/SKILL.md +101 -7
- package/skills/loom-auth/SKILL.md +9 -0
- package/skills/loom-db/SKILL.md +3 -1
|
@@ -18,13 +18,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
exports.ApiKeyCreateDialog = ApiKeyCreateDialog;
|
|
21
|
+
exports.ApiKeyTransportGuidance = ApiKeyTransportGuidance;
|
|
21
22
|
exports.ApiKeySecretDialog = ApiKeySecretDialog;
|
|
23
|
+
exports.ApiKeyRenameDialog = ApiKeyRenameDialog;
|
|
22
24
|
exports.ApiKeysTable = ApiKeysTable;
|
|
23
25
|
exports.AdminApiKeysTable = AdminApiKeysTable;
|
|
24
26
|
exports.ApiKeyAuditTable = ApiKeyAuditTable;
|
|
25
27
|
exports.ApiKeysManager = ApiKeysManager;
|
|
26
28
|
require("../../_dnt.polyfills.js");
|
|
27
29
|
"use client";
|
|
30
|
+
/**
|
|
31
|
+
* MUI components for API-key management.
|
|
32
|
+
*
|
|
33
|
+
* Requires `@mui/material` 6 or newer (TextField `slotProps`), although the
|
|
34
|
+
* package's optional `@mui/material` peer stays `>=5` for `mui/mail` and
|
|
35
|
+
* `mui/confirm`. The dialogs track pending requests with React 19 async
|
|
36
|
+
* transitions; on React 18 they work but do not disable while pending.
|
|
37
|
+
*
|
|
38
|
+
* @module
|
|
39
|
+
*/
|
|
28
40
|
const Alert_1 = __importDefault(require("@mui/material/Alert"));
|
|
29
41
|
const Box_1 = __importDefault(require("@mui/material/Box"));
|
|
30
42
|
const Button_1 = __importDefault(require("@mui/material/Button"));
|
|
@@ -50,6 +62,7 @@ const TextField_1 = __importDefault(require("@mui/material/TextField"));
|
|
|
50
62
|
const Tooltip_1 = __importDefault(require("@mui/material/Tooltip"));
|
|
51
63
|
const Typography_1 = __importDefault(require("@mui/material/Typography"));
|
|
52
64
|
const react_1 = __importDefault(require("react"));
|
|
65
|
+
const credentials_js_1 = require("../apiKeys/credentials.js");
|
|
53
66
|
const apiKeysView_js_1 = require("./apiKeysView.js");
|
|
54
67
|
__exportStar(require("./apiKeysView.js"), exports);
|
|
55
68
|
function IpCountry(props) {
|
|
@@ -63,57 +76,68 @@ function IpCountry(props) {
|
|
|
63
76
|
props.ipAddress));
|
|
64
77
|
}
|
|
65
78
|
function ApiKeyCreateDialog(props) {
|
|
79
|
+
const expiryOptions = (0, apiKeysView_js_1.getApiKeyExpiryOptions)({
|
|
80
|
+
allowNoExpiry: props.allowNoExpiry,
|
|
81
|
+
expiryPresetDays: props.expiryPresetDays,
|
|
82
|
+
limits: props.limits,
|
|
83
|
+
});
|
|
84
|
+
const defaultExpiry = expiryOptions[0].value;
|
|
66
85
|
const [name, setName] = react_1.default.useState("");
|
|
67
86
|
const [scopeIds, setScopeIds] = react_1.default.useState([]);
|
|
68
|
-
const [
|
|
87
|
+
const [expiryChoice, setExpiry] = react_1.default.useState(defaultExpiry);
|
|
69
88
|
const [customExpiry, setCustomExpiry] = react_1.default.useState("");
|
|
70
89
|
const [localError, setLocalError] = react_1.default.useState(null);
|
|
71
90
|
const [pending, startTransition] = react_1.default.useTransition();
|
|
91
|
+
// Reference time for the custom input's min/max. It is refreshed when the
|
|
92
|
+
// dialog opens, when the input is chosen, focused, or changed, and on
|
|
93
|
+
// submit, so the bounds are never older than the last interaction. A value
|
|
94
|
+
// picked at the minimum and submitted more than the tolerance later is
|
|
95
|
+
// genuinely too soon and is rejected with the server's message.
|
|
96
|
+
const [boundsTime, setBoundsTime] = react_1.default.useState(() => Date.now());
|
|
97
|
+
const [wasOpen, setWasOpen] = react_1.default.useState(props.open);
|
|
98
|
+
if (props.open !== wasOpen) {
|
|
99
|
+
setWasOpen(props.open);
|
|
100
|
+
if (props.open)
|
|
101
|
+
setBoundsTime(Date.now());
|
|
102
|
+
}
|
|
103
|
+
// Fall back to the default if changed props removed the chosen option.
|
|
104
|
+
const expiry = expiryOptions.some((option) => option.value === expiryChoice)
|
|
105
|
+
? expiryChoice
|
|
106
|
+
: defaultExpiry;
|
|
107
|
+
const customBounds = expiry === "custom"
|
|
108
|
+
? (0, apiKeysView_js_1.getApiKeyCustomExpiryInputBounds)(props.limits, boundsTime)
|
|
109
|
+
: null;
|
|
72
110
|
const close = () => {
|
|
73
111
|
if (!pending)
|
|
74
112
|
props.onClose();
|
|
75
113
|
};
|
|
76
114
|
const submit = () => {
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
setLocalError("Choose at least one scope.");
|
|
115
|
+
const now = Date.now();
|
|
116
|
+
// A failed check below shows the picker's minimum as of now.
|
|
117
|
+
setBoundsTime(now);
|
|
118
|
+
const input = (0, apiKeysView_js_1.resolveApiKeyCreateInput)({ customExpiry, expiry, name, scopeIds }, { allowNoExpiry: props.allowNoExpiry, limits: props.limits, now });
|
|
119
|
+
if (!input.ok) {
|
|
120
|
+
setLocalError(input.message);
|
|
84
121
|
return;
|
|
85
122
|
}
|
|
86
|
-
let expiresAt = null;
|
|
87
|
-
if (expiry === "custom") {
|
|
88
|
-
const parsed = new Date(customExpiry);
|
|
89
|
-
if (!customExpiry || Number.isNaN(parsed.valueOf()) || parsed <= new Date()) {
|
|
90
|
-
setLocalError("Choose a future expiry date.");
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
expiresAt = parsed.toISOString();
|
|
94
|
-
}
|
|
95
|
-
else if (expiry !== "never") {
|
|
96
|
-
expiresAt = new Date(Date.now() + Number(expiry) * 86_400_000)
|
|
97
|
-
.toISOString();
|
|
98
|
-
}
|
|
99
123
|
setLocalError(null);
|
|
100
124
|
startTransition(async () => {
|
|
101
125
|
try {
|
|
102
|
-
const result = await props.onCreate(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
126
|
+
const result = (0, apiKeysView_js_1.resolveApiKeyCreateActionResult)(await props.onCreate(input.value));
|
|
127
|
+
if (!result.ok) {
|
|
128
|
+
// Keep every field so the user can correct the input.
|
|
129
|
+
setLocalError(result.message);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
props.onCreated(result.created);
|
|
108
133
|
setName("");
|
|
109
134
|
setScopeIds([]);
|
|
110
|
-
setExpiry(
|
|
135
|
+
setExpiry(defaultExpiry);
|
|
136
|
+
setCustomExpiry("");
|
|
111
137
|
props.onClose();
|
|
112
138
|
}
|
|
113
139
|
catch (error) {
|
|
114
|
-
setLocalError(error
|
|
115
|
-
? error.message
|
|
116
|
-
: "The key could not be created.");
|
|
140
|
+
setLocalError((0, apiKeysView_js_1.resolveApiKeyThrownErrorMessage)(error, props.thrownErrorMessages ?? "show", apiKeysView_js_1.API_KEY_CREATE_FAILED_MESSAGE));
|
|
117
141
|
}
|
|
118
142
|
});
|
|
119
143
|
};
|
|
@@ -128,13 +152,18 @@ function ApiKeyCreateDialog(props) {
|
|
|
128
152
|
react_1.default.createElement(FormControlLabel_1.default, { control: react_1.default.createElement(Checkbox_1.default, { checked: scopeIds.includes(scope.id), onChange: (_, checked) => setScopeIds((current) => checked
|
|
129
153
|
? [...current, scope.id]
|
|
130
154
|
: current.filter((id) => id !== scope.id)) }), disabled: pending || scope.disabled, label: scope.label }))))),
|
|
131
|
-
react_1.default.createElement(TextField_1.default, { select: true, label: "Expiry", value: expiry, onChange: (event) =>
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
react_1.default.createElement("option", { value:
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
155
|
+
react_1.default.createElement(TextField_1.default, { select: true, label: "Expiry", value: expiry, onChange: (event) => {
|
|
156
|
+
setExpiry(event.target.value);
|
|
157
|
+
setBoundsTime(Date.now());
|
|
158
|
+
}, disabled: pending, slotProps: { select: { native: true } } }, expiryOptions.map((option) => (react_1.default.createElement("option", { key: option.value, value: option.value }, option.label)))),
|
|
159
|
+
customBounds
|
|
160
|
+
? (react_1.default.createElement(TextField_1.default, { type: "datetime-local", label: "Expires at", value: customExpiry, onChange: (event) => {
|
|
161
|
+
setCustomExpiry(event.target.value);
|
|
162
|
+
setBoundsTime(Date.now());
|
|
163
|
+
}, onFocus: () => setBoundsTime(Date.now()), slotProps: {
|
|
164
|
+
htmlInput: { max: customBounds.max, min: customBounds.min },
|
|
165
|
+
inputLabel: { shrink: true },
|
|
166
|
+
}, disabled: pending }))
|
|
138
167
|
: null,
|
|
139
168
|
localError || props.error
|
|
140
169
|
? react_1.default.createElement(Alert_1.default, { severity: "error" }, localError ?? props.error)
|
|
@@ -143,6 +172,17 @@ function ApiKeyCreateDialog(props) {
|
|
|
143
172
|
react_1.default.createElement(Button_1.default, { onClick: close, disabled: pending }, "Cancel"),
|
|
144
173
|
react_1.default.createElement(Button_1.default, { onClick: submit, variant: "contained", disabled: pending }, pending ? "Creating…" : "Create key"))));
|
|
145
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* Tells key holders how to send a key: the preferred transport (Bearer when
|
|
177
|
+
* enabled), the other accepted ones, and a URL-leakage warning when query
|
|
178
|
+
* credentials are enabled.
|
|
179
|
+
*/
|
|
180
|
+
function ApiKeyTransportGuidance(props) {
|
|
181
|
+
const copy = (0, apiKeysView_js_1.getApiKeyTransportGuidanceCopy)((0, credentials_js_1.describeApiKeyTransports)(props.credentialOptions));
|
|
182
|
+
return (react_1.default.createElement(Alert_1.default, { severity: copy.severity, sx: props.sx }, [copy.primary, copy.alternatives, copy.queryWarning]
|
|
183
|
+
.filter((line) => line !== null)
|
|
184
|
+
.map((line) => (react_1.default.createElement(Box_1.default, { key: line, component: "span", sx: { display: "block" } }, line)))));
|
|
185
|
+
}
|
|
146
186
|
function ApiKeySecretDialog(props) {
|
|
147
187
|
const [copied, setCopied] = react_1.default.useState(false);
|
|
148
188
|
react_1.default.useEffect(() => setCopied(false), [props.result]);
|
|
@@ -162,9 +202,11 @@ function ApiKeySecretDialog(props) {
|
|
|
162
202
|
react_1.default.createElement(TextField_1.default, { value: props.result?.key ?? "", fullWidth: true, margin: "normal", label: "API key", slotProps: {
|
|
163
203
|
htmlInput: { readOnly: true, "aria-label": "New API key" },
|
|
164
204
|
} }),
|
|
165
|
-
props.
|
|
166
|
-
? (react_1.default.createElement(
|
|
167
|
-
:
|
|
205
|
+
props.credentialOptions
|
|
206
|
+
? (react_1.default.createElement(ApiKeyTransportGuidance, { credentialOptions: props.credentialOptions }))
|
|
207
|
+
: props.queryCredentialsEnabled
|
|
208
|
+
? (react_1.default.createElement(Alert_1.default, { severity: "warning" }, "Query-parameter keys can appear in browser history, access logs, copied links, and referrers. Prefer an authorization header."))
|
|
209
|
+
: null,
|
|
168
210
|
copied
|
|
169
211
|
? react_1.default.createElement(Alert_1.default, { severity: "success", sx: { mt: 2 } }, "Copied.")
|
|
170
212
|
: null),
|
|
@@ -172,36 +214,101 @@ function ApiKeySecretDialog(props) {
|
|
|
172
214
|
react_1.default.createElement(Button_1.default, { onClick: copy, disabled: !props.result }, "Copy key"),
|
|
173
215
|
react_1.default.createElement(Button_1.default, { onClick: props.onClose, variant: "contained" }, "I saved it"))));
|
|
174
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* Edits one key name with inline validation. A failed rename keeps the dialog
|
|
219
|
+
* open with the typed value; an unchanged name closes it without a call.
|
|
220
|
+
*/
|
|
221
|
+
function ApiKeyRenameDialog(props) {
|
|
222
|
+
const formId = react_1.default.useId();
|
|
223
|
+
const [name, setName] = react_1.default.useState(props.currentName);
|
|
224
|
+
const [error, setError] = react_1.default.useState(null);
|
|
225
|
+
const [pending, startTransition] = react_1.default.useTransition();
|
|
226
|
+
// Start from the current name each time the dialog opens.
|
|
227
|
+
const [wasOpen, setWasOpen] = react_1.default.useState(props.open);
|
|
228
|
+
if (props.open !== wasOpen) {
|
|
229
|
+
setWasOpen(props.open);
|
|
230
|
+
if (props.open) {
|
|
231
|
+
setName(props.currentName);
|
|
232
|
+
setError(null);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
const close = () => {
|
|
236
|
+
if (!pending)
|
|
237
|
+
props.onClose();
|
|
238
|
+
};
|
|
239
|
+
const submit = (event) => {
|
|
240
|
+
event.preventDefault();
|
|
241
|
+
if (pending)
|
|
242
|
+
return;
|
|
243
|
+
const resolved = (0, apiKeysView_js_1.resolveApiKeyRename)(name, props.currentName, props.limits);
|
|
244
|
+
if (!resolved.ok) {
|
|
245
|
+
setError(resolved.message);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
if (resolved.value.unchanged) {
|
|
249
|
+
props.onClose();
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
setError(null);
|
|
253
|
+
startTransition(async () => {
|
|
254
|
+
try {
|
|
255
|
+
const result = (0, apiKeysView_js_1.resolveApiKeyMutationResult)(await props.onRename(resolved.value.name), apiKeysView_js_1.API_KEY_RENAME_FAILED_MESSAGE);
|
|
256
|
+
if (!result.ok) {
|
|
257
|
+
setError(result.message);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
props.onClose();
|
|
261
|
+
}
|
|
262
|
+
catch {
|
|
263
|
+
setError(apiKeysView_js_1.API_KEY_RENAME_FAILED_MESSAGE);
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
return (react_1.default.createElement(Dialog_1.default, { open: props.open, onClose: close, fullWidth: true, maxWidth: "xs", "aria-labelledby": `${formId}-title` },
|
|
268
|
+
react_1.default.createElement(DialogTitle_1.default, { id: `${formId}-title` }, "Rename API key"),
|
|
269
|
+
react_1.default.createElement(DialogContent_1.default, null,
|
|
270
|
+
react_1.default.createElement(Box_1.default, { component: "form", id: formId, onSubmit: submit, noValidate: true },
|
|
271
|
+
react_1.default.createElement(TextField_1.default, { 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 }))),
|
|
272
|
+
react_1.default.createElement(DialogActions_1.default, null,
|
|
273
|
+
react_1.default.createElement(Button_1.default, { onClick: close, disabled: pending }, "Cancel"),
|
|
274
|
+
react_1.default.createElement(Button_1.default, { type: "submit", form: formId, variant: "contained", disabled: pending }, pending ? "Renaming…" : "Rename"))));
|
|
275
|
+
}
|
|
175
276
|
function ScopeChips({ scopes }) {
|
|
176
|
-
return (react_1.default.createElement(Stack_1.default, { direction: "row",
|
|
277
|
+
return (react_1.default.createElement(Stack_1.default, { direction: "row", sx: { flexWrap: "wrap", gap: 0.5 } }, scopes.map((scope) => react_1.default.createElement(Chip_1.default, { key: scope, size: "small", label: scope }))));
|
|
177
278
|
}
|
|
178
279
|
function ApiKeysTable(props) {
|
|
179
280
|
const [pendingId, setPendingId] = react_1.default.useState(null);
|
|
281
|
+
const [actionError, setActionError] = react_1.default.useState(null);
|
|
282
|
+
const [renameRow, setRenameRow] = react_1.default.useState(null);
|
|
283
|
+
const [renameOpen, setRenameOpen] = react_1.default.useState(false);
|
|
180
284
|
const revoke = async (row) => {
|
|
181
285
|
if (!props.onRevoke ||
|
|
182
286
|
!globalThis.confirm(`Revoke “${row.name}”? This cannot be undone.`))
|
|
183
287
|
return;
|
|
288
|
+
setActionError(null);
|
|
184
289
|
setPendingId(row.id);
|
|
185
290
|
try {
|
|
186
|
-
await props.onRevoke(row.id);
|
|
291
|
+
const result = (0, apiKeysView_js_1.resolveApiKeyMutationResult)(await props.onRevoke(row.id), apiKeysView_js_1.API_KEY_REVOKE_FAILED_MESSAGE);
|
|
292
|
+
if (!result.ok) {
|
|
293
|
+
setActionError({ message: result.message, rowId: row.id });
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
catch {
|
|
297
|
+
setActionError({
|
|
298
|
+
message: apiKeysView_js_1.API_KEY_REVOKE_FAILED_MESSAGE,
|
|
299
|
+
rowId: row.id,
|
|
300
|
+
});
|
|
187
301
|
}
|
|
188
302
|
finally {
|
|
189
303
|
setPendingId(null);
|
|
190
304
|
}
|
|
191
305
|
};
|
|
192
|
-
const rename =
|
|
306
|
+
const rename = (row) => {
|
|
193
307
|
if (!props.onRename)
|
|
194
308
|
return;
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
setPendingId(row.id);
|
|
199
|
-
try {
|
|
200
|
-
await props.onRename(row.id, name);
|
|
201
|
-
}
|
|
202
|
-
finally {
|
|
203
|
-
setPendingId(null);
|
|
204
|
-
}
|
|
309
|
+
setActionError(null);
|
|
310
|
+
setRenameRow(row);
|
|
311
|
+
setRenameOpen(true);
|
|
205
312
|
};
|
|
206
313
|
if (props.loading) {
|
|
207
314
|
return (react_1.default.createElement(Box_1.default, { sx: { py: 6, textAlign: "center" } },
|
|
@@ -213,7 +320,15 @@ function ApiKeysTable(props) {
|
|
|
213
320
|
const actions = (row) => (react_1.default.createElement(Stack_1.default, { direction: "row", spacing: 1 },
|
|
214
321
|
react_1.default.createElement(Button_1.default, { size: "small", onClick: () => rename(row), disabled: !props.onRename || pendingId === row.id }, "Rename"),
|
|
215
322
|
react_1.default.createElement(Button_1.default, { size: "small", color: "error", onClick: () => revoke(row), disabled: !props.onRevoke || !row.enabled || pendingId === row.id }, "Revoke")));
|
|
323
|
+
const errorRowName = actionError
|
|
324
|
+
? props.rows.find((row) => row.id === actionError.rowId)?.name
|
|
325
|
+
: undefined;
|
|
216
326
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
327
|
+
actionError
|
|
328
|
+
? (react_1.default.createElement(Alert_1.default, { severity: "error", onClose: () => setActionError(null), sx: { mb: 1.5 } },
|
|
329
|
+
errorRowName ? `“${errorRowName}”: ` : "",
|
|
330
|
+
actionError.message))
|
|
331
|
+
: null,
|
|
217
332
|
react_1.default.createElement(TableContainer_1.default, { component: Paper_1.default, variant: "outlined", sx: { display: { xs: "none", md: "block" } } },
|
|
218
333
|
react_1.default.createElement(Table_1.default, { size: "small", "aria-label": props.admin ? "All user API keys" : "Your API keys" },
|
|
219
334
|
react_1.default.createElement(TableHead_1.default, null,
|
|
@@ -234,7 +349,7 @@ function ApiKeysTable(props) {
|
|
|
234
349
|
react_1.default.createElement(Typography_1.default, { variant: "caption", color: "text.secondary" }, row.ownerEmail)))
|
|
235
350
|
: null,
|
|
236
351
|
react_1.default.createElement(TableCell_1.default, null,
|
|
237
|
-
react_1.default.createElement(Typography_1.default, { variant: "body2", fontWeight: 600 }, row.name),
|
|
352
|
+
react_1.default.createElement(Typography_1.default, { variant: "body2", sx: { fontWeight: 600 } }, row.name),
|
|
238
353
|
react_1.default.createElement(Typography_1.default, { variant: "caption", color: "text.secondary" }, row.start ?? "No visible prefix")),
|
|
239
354
|
react_1.default.createElement(TableCell_1.default, null,
|
|
240
355
|
react_1.default.createElement(Chip_1.default, { size: "small", color: (0, apiKeysView_js_1.getApiKeyStatus)(row) === "Active"
|
|
@@ -247,19 +362,19 @@ function ApiKeysTable(props) {
|
|
|
247
362
|
react_1.default.createElement(TableCell_1.default, null,
|
|
248
363
|
(0, apiKeysView_js_1.formatApiKeyDate)(row.lastUsedAt),
|
|
249
364
|
row.lastUsedScope
|
|
250
|
-
? (react_1.default.createElement(Typography_1.default, {
|
|
365
|
+
? (react_1.default.createElement(Typography_1.default, { variant: "caption", sx: { display: "block" } }, row.lastUsedScope))
|
|
251
366
|
: null,
|
|
252
367
|
row.lastUsedCountryCode || row.lastUsedIpAddress
|
|
253
|
-
? (react_1.default.createElement(Typography_1.default, {
|
|
368
|
+
? (react_1.default.createElement(Typography_1.default, { variant: "caption", sx: { display: "block" } },
|
|
254
369
|
react_1.default.createElement(IpCountry, { countryCode: row.lastUsedCountryCode, ipAddress: row.lastUsedIpAddress })))
|
|
255
370
|
: null),
|
|
256
371
|
props.extraColumns?.map((column) => (react_1.default.createElement(TableCell_1.default, { key: column.id }, column.render(row)))),
|
|
257
372
|
react_1.default.createElement(TableCell_1.default, { align: "right" }, actions(row)))))))),
|
|
258
373
|
react_1.default.createElement(Stack_1.default, { spacing: 1.5, sx: { display: { xs: "flex", md: "none" } } }, props.rows.map((row) => (react_1.default.createElement(Paper_1.default, { key: row.id, variant: "outlined", sx: { p: 2 } },
|
|
259
374
|
react_1.default.createElement(Stack_1.default, { spacing: 1 },
|
|
260
|
-
react_1.default.createElement(Stack_1.default, { direction: "row", justifyContent: "space-between" },
|
|
375
|
+
react_1.default.createElement(Stack_1.default, { direction: "row", sx: { justifyContent: "space-between" } },
|
|
261
376
|
react_1.default.createElement(Box_1.default, null,
|
|
262
|
-
react_1.default.createElement(Typography_1.default, { fontWeight: 600 }, row.name),
|
|
377
|
+
react_1.default.createElement(Typography_1.default, { sx: { fontWeight: 600 } }, row.name),
|
|
263
378
|
react_1.default.createElement(Typography_1.default, { variant: "caption", color: "text.secondary" }, row.start)),
|
|
264
379
|
react_1.default.createElement(Chip_1.default, { size: "small", label: (0, apiKeysView_js_1.getApiKeyStatus)(row) })),
|
|
265
380
|
props.admin
|
|
@@ -275,18 +390,25 @@ function ApiKeysTable(props) {
|
|
|
275
390
|
" · ",
|
|
276
391
|
react_1.default.createElement(IpCountry, { countryCode: row.lastUsedCountryCode, ipAddress: row.lastUsedIpAddress })))
|
|
277
392
|
: null),
|
|
278
|
-
actions(row))))))
|
|
393
|
+
actions(row)))))),
|
|
394
|
+
props.onRename && renameRow
|
|
395
|
+
? (react_1.default.createElement(ApiKeyRenameDialog, { open: renameOpen, currentName: renameRow.name, limits: props.limits, onClose: () => setRenameOpen(false), onRename: (name) => props.onRename(renameRow.id, name) }))
|
|
396
|
+
: null));
|
|
279
397
|
}
|
|
280
398
|
function AdminApiKeysTable(props) {
|
|
281
399
|
return react_1.default.createElement(ApiKeysTable, { ...props, admin: true });
|
|
282
400
|
}
|
|
283
401
|
function ApiKeyAuditTable(props) {
|
|
402
|
+
// Inferring the key column keeps tables without snapshots exactly as before.
|
|
403
|
+
const showKey = props.showKey ??
|
|
404
|
+
props.rows.some((row) => row.keyName || row.keyStart);
|
|
284
405
|
return (react_1.default.createElement(Paper_1.default, { variant: "outlined" },
|
|
285
406
|
react_1.default.createElement(TableContainer_1.default, null,
|
|
286
407
|
react_1.default.createElement(Table_1.default, { size: "small", "aria-label": "API-key audit history" },
|
|
287
408
|
react_1.default.createElement(TableHead_1.default, null,
|
|
288
409
|
react_1.default.createElement(TableRow_1.default, null,
|
|
289
410
|
react_1.default.createElement(TableCell_1.default, null, "Time"),
|
|
411
|
+
showKey ? react_1.default.createElement(TableCell_1.default, null, "Key") : null,
|
|
290
412
|
react_1.default.createElement(TableCell_1.default, null, "Scope"),
|
|
291
413
|
react_1.default.createElement(TableCell_1.default, null, "Operation"),
|
|
292
414
|
react_1.default.createElement(TableCell_1.default, null, "Transport"),
|
|
@@ -295,33 +417,54 @@ function ApiKeyAuditTable(props) {
|
|
|
295
417
|
react_1.default.createElement(TableCell_1.default, null, "Context"))),
|
|
296
418
|
react_1.default.createElement(TableBody_1.default, null, props.loading
|
|
297
419
|
? (react_1.default.createElement(TableRow_1.default, null,
|
|
298
|
-
react_1.default.createElement(TableCell_1.default, { colSpan: 7, align: "center" },
|
|
420
|
+
react_1.default.createElement(TableCell_1.default, { colSpan: showKey ? 8 : 7, align: "center" },
|
|
299
421
|
react_1.default.createElement(CircularProgress_1.default, { size: 24, "aria-label": "Loading audit history" }))))
|
|
300
|
-
: props.rows.map((row) =>
|
|
301
|
-
|
|
302
|
-
react_1.default.createElement(
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
422
|
+
: props.rows.map((row) => {
|
|
423
|
+
const reason = (0, apiKeysView_js_1.getApiKeyAuditReason)(row);
|
|
424
|
+
return (react_1.default.createElement(TableRow_1.default, { key: row.id },
|
|
425
|
+
react_1.default.createElement(TableCell_1.default, null, (0, apiKeysView_js_1.formatApiKeyDate)(row.occurredAt)),
|
|
426
|
+
showKey
|
|
427
|
+
? (react_1.default.createElement(TableCell_1.default, null,
|
|
428
|
+
react_1.default.createElement(Typography_1.default, { variant: "body2" }, row.keyName ?? "—"),
|
|
429
|
+
row.keyStart
|
|
430
|
+
? (react_1.default.createElement(Typography_1.default, { variant: "caption", color: "text.secondary" }, row.keyStart))
|
|
431
|
+
: null))
|
|
432
|
+
: null,
|
|
433
|
+
react_1.default.createElement(TableCell_1.default, null, row.scope),
|
|
434
|
+
react_1.default.createElement(TableCell_1.default, null, row.operation),
|
|
435
|
+
react_1.default.createElement(TableCell_1.default, null, row.transport ?? "—"),
|
|
436
|
+
react_1.default.createElement(TableCell_1.default, null,
|
|
437
|
+
react_1.default.createElement(Typography_1.default, { variant: "body2" },
|
|
438
|
+
react_1.default.createElement(IpCountry, { countryCode: row.countryCode, ipAddress: row.ipAddress })),
|
|
439
|
+
react_1.default.createElement(Typography_1.default, { variant: "caption", color: "text.secondary" }, row.userAgent ?? "")),
|
|
440
|
+
react_1.default.createElement(TableCell_1.default, null,
|
|
441
|
+
[row.authorizationOutcome, row.operationOutcome].filter(Boolean).join(" / "),
|
|
442
|
+
reason
|
|
443
|
+
? (react_1.default.createElement(Typography_1.default, { variant: "caption", color: "text.secondary", sx: { display: "block" } }, reason))
|
|
444
|
+
: null),
|
|
445
|
+
react_1.default.createElement(TableCell_1.default, null, [row.pageName, row.functionName, row.actionName].filter(Boolean).join(" · ") || "—")));
|
|
446
|
+
})))),
|
|
311
447
|
react_1.default.createElement(TablePagination_1.default, { component: "div", count: props.count, page: props.page, rowsPerPage: props.rowsPerPage, rowsPerPageOptions: [props.rowsPerPage], onPageChange: (_event, page) => props.onPageChange(page) })));
|
|
312
448
|
}
|
|
313
449
|
function ApiKeysManager(props) {
|
|
314
450
|
const [createOpen, setCreateOpen] = react_1.default.useState(false);
|
|
315
451
|
const [secret, setSecret] = react_1.default.useState(null);
|
|
316
452
|
return (react_1.default.createElement(Stack_1.default, { spacing: 2 },
|
|
317
|
-
react_1.default.createElement(Stack_1.default, { direction: { xs: "column", sm: "row" },
|
|
453
|
+
react_1.default.createElement(Stack_1.default, { direction: { xs: "column", sm: "row" }, sx: {
|
|
454
|
+
alignItems: { sm: "center" },
|
|
455
|
+
gap: 1,
|
|
456
|
+
justifyContent: "space-between",
|
|
457
|
+
} },
|
|
318
458
|
react_1.default.createElement(Box_1.default, null,
|
|
319
459
|
react_1.default.createElement(Typography_1.default, { variant: "h5", component: "h1" }, "API keys"),
|
|
320
460
|
react_1.default.createElement(Typography_1.default, { color: "text.secondary" }, "Create scoped credentials for tools you trust.")),
|
|
321
461
|
react_1.default.createElement(Button_1.default, { variant: "contained", onClick: () => setCreateOpen(true), disabled: !props.onCreate }, "Create API key")),
|
|
322
462
|
props.error ? react_1.default.createElement(Alert_1.default, { severity: "error" }, props.error) : null,
|
|
323
|
-
react_1.default.createElement(ApiKeysTable, { rows: props.rows, loading: props.loading, scopes: props.scopes, extraColumns: props.extraColumns, onRename: props.onRename, onRevoke: props.onRevoke }),
|
|
324
|
-
react_1.default.createElement(ApiKeyCreateDialog, { open: createOpen, onClose: () => setCreateOpen(false), scopes: props.scopes, error: props.error, onCreate: props.onCreate ??
|
|
325
|
-
(() => Promise.
|
|
326
|
-
|
|
463
|
+
react_1.default.createElement(ApiKeysTable, { rows: props.rows, loading: props.loading, scopes: props.scopes, extraColumns: props.extraColumns, limits: props.limits, onRename: props.onRename, onRevoke: props.onRevoke }),
|
|
464
|
+
react_1.default.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 ??
|
|
465
|
+
(() => Promise.resolve({
|
|
466
|
+
message: "Key creation is unavailable.",
|
|
467
|
+
ok: false,
|
|
468
|
+
})), onCreated: setSecret }),
|
|
469
|
+
react_1.default.createElement(ApiKeySecretDialog, { open: secret !== null, result: secret, credentialOptions: props.credentialOptions, queryCredentialsEnabled: props.queryCredentialsEnabled, onClose: () => setSecret(null) })));
|
|
327
470
|
}
|
|
@@ -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,IA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